keycloak-aplcache

Details

diff --git a/testsuite/integration-arquillian/servers/auth-server/jboss/common/datasource.xsl b/testsuite/integration-arquillian/servers/auth-server/jboss/common/datasource.xsl
index bf199cb..72b0403 100644
--- a/testsuite/integration-arquillian/servers/auth-server/jboss/common/datasource.xsl
+++ b/testsuite/integration-arquillian/servers/auth-server/jboss/common/datasource.xsl
@@ -29,24 +29,42 @@
     <!-- Remove keycloak datasource definition. -->
     <xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
 		         /*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]
-                         /*[local-name()='datasource' and starts-with(namespace-uri(), $nsDS) and @pool-name='KeycloakDS']">
+                         /*[local-name()='xa-datasource' and starts-with(namespace-uri(), $nsDS) and @pool-name='KeycloakDS']">
     </xsl:template>
     
-    <xsl:param name="jdbc.url" select="'jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE'"/>
-    <xsl:param name="driver" select="'h2'"/>
+    <xsl:param name="db.jdbc_url"/>
+    <xsl:param name="db.hostname"/>
+    <xsl:param name="db.name"/>
+    <xsl:param name="db.port"/>
+    <xsl:param name="driver"/>
+    <xsl:param name="datasource.class.xa"/>
     
-    <xsl:param name="username" select="'sa'"/>
-    <xsl:param name="password" select="'sa'"/>
-    
-    <xsl:param name="min.poolsize" select="'10'"/>
-    <xsl:param name="max.poolsize" select="'50'"/>
-    <xsl:param name="pool.prefill" select="'true'"/>
+    <xsl:param name="username"/>
+    <xsl:param name="password"/>
     
     <xsl:variable name="newDatasourceDefinition">
-        <datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" use-java-context="true">
-            <connection-url>
-                <xsl:value-of select="$jdbc.url"/>
-            </connection-url>
+        <xa-datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" use-java-context="true">
+            <xsl:choose>
+                <xsl:when test="contains($driver, 'oracle')">
+                    <xa-datasource-property name="URL">
+                        <xsl:value-of select="$db.jdbc_url"/>
+                    </xa-datasource-property>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xa-datasource-property name="ServerName">
+                        <xsl:value-of select="$db.hostname"/>
+                    </xa-datasource-property>
+                    <xa-datasource-property name="PortNumber">
+                        <xsl:value-of select="$db.port"/>
+                    </xa-datasource-property>
+                    <xa-datasource-property name="DatabaseName">
+                        <xsl:value-of select="$db.name"/>
+                    </xa-datasource-property>
+                    <xsl:if test="contains($driver, 'db2')">
+                        <xa-datasource-property name="DriverType">4</xa-datasource-property>
+                    </xsl:if>
+                </xsl:otherwise>
+            </xsl:choose>
             <driver>
                 <xsl:value-of select="$driver"/>
             </driver>
@@ -58,23 +76,16 @@
                     <xsl:value-of select="$password"/>
                 </password>
             </security>
-            <pool>
-                <min-pool-size>
-                    <xsl:value-of select="$min.poolsize"/>
-                </min-pool-size>
-                <max-pool-size>
-                    <xsl:value-of select="$max.poolsize"/>
-                </max-pool-size>
-                <prefill>
-                    <xsl:value-of select="$pool.prefill"/>
-                </prefill>
-            </pool>
-        </datasource>
+        </xa-datasource>
     </xsl:variable>
     
     <xsl:variable name="newDriverDefinition">
         <xsl:if test="$driver != 'h2'">
-            <driver name="{$driver}" module="com.{$driver}" />
+            <driver name="{$driver}" module="com.{$driver}">
+                <xa-datasource-class>
+                    <xsl:value-of select="$datasource.class.xa"/>
+                </xa-datasource-class>
+            </driver>
         </xsl:if>
     </xsl:variable>
     
diff --git a/testsuite/integration-arquillian/servers/auth-server/jboss/common/datasource-jdbc-url.xsl b/testsuite/integration-arquillian/servers/auth-server/jboss/common/datasource-jdbc-url.xsl
index 445b973..f7d35d3 100644
--- a/testsuite/integration-arquillian/servers/auth-server/jboss/common/datasource-jdbc-url.xsl
+++ b/testsuite/integration-arquillian/servers/auth-server/jboss/common/datasource-jdbc-url.xsl
@@ -15,11 +15,11 @@
     <!-- replace JDBC URL -->
     <xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
 		         /*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]
-                         /*[local-name()='datasource' and starts-with(namespace-uri(), $nsDS) and @pool-name=$pool.name]
-                         /*[local-name()='connection-url' and starts-with(namespace-uri(), $nsDS)]">
-        <connection-url>
+                         /*[local-name()='xa-datasource' and starts-with(namespace-uri(), $nsDS) and @pool-name=$pool.name]
+                         /*[local-name()='xa-datasource-property' and starts-with(namespace-uri(), $nsDS) and @name='URL']">
+        <xa-datasource-property name="URL">
             <xsl:value-of select="$jdbc.url"/>
-        </connection-url>
+        </xa-datasource-property>
     </xsl:template>
 
     <!-- Copy everything else. -->
diff --git a/testsuite/integration-arquillian/servers/auth-server/jboss/pom.xml b/testsuite/integration-arquillian/servers/auth-server/jboss/pom.xml
index 0786c3b..28d84fe 100644
--- a/testsuite/integration-arquillian/servers/auth-server/jboss/pom.xml
+++ b/testsuite/integration-arquillian/servers/auth-server/jboss/pom.xml
@@ -429,7 +429,7 @@
                                                 <property>jdbc.mvn.version</property>
                                             </requireProperty>
                                             <requireProperty>
-                                                <property>keycloak.connectionsJpa.url</property>
+                                                <property>datasource.class.xa</property>
                                             </requireProperty>
                                             <requireProperty>
                                                 <property>keycloak.connectionsJpa.user</property>
@@ -508,10 +508,26 @@
                                                 <outputDir>${auth.server.home}/standalone/configuration</outputDir>
                                                 <parameters>
                                                     <parameter>
-                                                        <name>jdbc.url</name>
+                                                        <name>db.jdbc_url</name>
                                                         <value>${keycloak.connectionsJpa.url}</value>
                                                     </parameter>
                                                     <parameter>
+                                                        <name>db.hostname</name>
+                                                        <value>${db.hostname}</value>
+                                                    </parameter>
+                                                    <parameter>
+                                                        <name>db.port</name>
+                                                        <value>${db.port}</value>
+                                                    </parameter>
+                                                    <parameter>
+                                                        <name>db.name</name>
+                                                        <value>${db.name}</value>
+                                                    </parameter>
+                                                    <parameter>
+                                                        <name>datasource.class.xa</name>
+                                                        <value>${datasource.class.xa}</value>
+                                                    </parameter>
+                                                    <parameter>
                                                         <name>driver</name>
                                                         <value>${jdbc.mvn.artifactId}</value>
                                                     </parameter>
diff --git a/testsuite/integration-arquillian/servers/migration/pom.xml b/testsuite/integration-arquillian/servers/migration/pom.xml
index 4babce3..49f5c7a 100644
--- a/testsuite/integration-arquillian/servers/migration/pom.xml
+++ b/testsuite/integration-arquillian/servers/migration/pom.xml
@@ -67,7 +67,7 @@
                                     <property>jdbc.mvn.version</property>
                                 </requireProperty>
                                 <requireProperty>
-                                    <property>keycloak.connectionsJpa.url</property>
+                                    <property>datasource.class.xa</property>
                                 </requireProperty>
                                 <requireProperty>
                                     <property>keycloak.connectionsJpa.user</property>
@@ -164,10 +164,26 @@
                                     <outputDir>${keycloak.server.home}/standalone/configuration</outputDir>
                                     <parameters>
                                         <parameter>
-                                            <name>jdbc.url</name>
+                                            <name>db.jdbc_url</name>
                                             <value>${keycloak.connectionsJpa.url}</value>
                                         </parameter>
                                         <parameter>
+                                            <name>db.hostname</name>
+                                            <value>${db.hostname}</value>
+                                        </parameter>
+                                        <parameter>
+                                            <name>db.port</name>
+                                            <value>${db.port}</value>
+                                        </parameter>
+                                        <parameter>
+                                            <name>db.name</name>
+                                            <value>${db.name}</value>
+                                        </parameter>
+                                        <parameter>
+                                            <name>datasource.class.xa</name>
+                                            <value>${datasource.class.xa}</value>
+                                        </parameter>
+                                        <parameter>
                                             <name>driver</name>
                                             <value>${jdbc.mvn.artifactId}</value>
                                         </parameter>
diff --git a/testsuite/integration-arquillian/servers/migration/src/main/xslt/datasource.xsl b/testsuite/integration-arquillian/servers/migration/src/main/xslt/datasource.xsl
index b68a3b1..797631b 100644
--- a/testsuite/integration-arquillian/servers/migration/src/main/xslt/datasource.xsl
+++ b/testsuite/integration-arquillian/servers/migration/src/main/xslt/datasource.xsl
@@ -25,27 +25,51 @@
 
     <xsl:variable name="nsDS" select="'urn:jboss:domain:datasources:'"/>
     
-    <!-- Remove keycloak datasource definition. -->
+    <!-- Remove keycloak datasource definition. For versions from 2.3.0-->
+    <xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
+		         /*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]
+                         /*[local-name()='xa-datasource' and starts-with(namespace-uri(), $nsDS) and @pool-name='KeycloakDS']">
+    </xsl:template>
+
+    <!-- Remove keycloak xa-datasource definition. For versions below 2.3.0-->
     <xsl:template match="//*[local-name()='subsystem' and starts-with(namespace-uri(), $nsDS)]
 		         /*[local-name()='datasources' and starts-with(namespace-uri(), $nsDS)]
                          /*[local-name()='datasource' and starts-with(namespace-uri(), $nsDS) and @pool-name='KeycloakDS']">
     </xsl:template>
     
-    <xsl:param name="jdbc.url" select="'jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE'"/>
-    <xsl:param name="driver" select="'h2'"/>
-    
-    <xsl:param name="username" select="'sa'"/>
-    <xsl:param name="password" select="'sa'"/>
+    <xsl:param name="db.jdbc_url"/>
+    <xsl:param name="db.hostname"/>
+    <xsl:param name="db.name"/>
+    <xsl:param name="db.port"/>
+    <xsl:param name="driver"/>
+    <xsl:param name="datasource.class.xa"/>
     
-    <xsl:param name="min.poolsize" select="'10'"/>
-    <xsl:param name="max.poolsize" select="'50'"/>
-    <xsl:param name="pool.prefill" select="'true'"/>
+    <xsl:param name="username"/>
+    <xsl:param name="password"/>
     
     <xsl:variable name="newDatasourceDefinition">
-        <datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
-            <connection-url>
-                <xsl:value-of select="$jdbc.url"/>
-            </connection-url>
+        <xa-datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
+            <xsl:choose>
+                <xsl:when test="contains($driver, 'oracle')">
+                    <xa-datasource-property name="URL">
+                        <xsl:value-of select="$db.jdbc_url"/>
+                    </xa-datasource-property>
+                </xsl:when>
+                <xsl:otherwise>
+                    <xa-datasource-property name="ServerName">
+                        <xsl:value-of select="$db.hostname"/>
+                    </xa-datasource-property>
+                    <xa-datasource-property name="PortNumber">
+                        <xsl:value-of select="$db.port"/>
+                    </xa-datasource-property>
+                    <xa-datasource-property name="DatabaseName">
+                        <xsl:value-of select="$db.name"/>
+                    </xa-datasource-property>
+                    <xsl:if test="contains($driver, 'db2')">
+                        <xa-datasource-property name="DriverType">4</xa-datasource-property>
+                    </xsl:if>
+                </xsl:otherwise>
+            </xsl:choose>
             <driver>
                 <xsl:value-of select="$driver"/>
             </driver>
@@ -57,23 +81,16 @@
                     <xsl:value-of select="$password"/>
                 </password>
             </security>
-            <pool>
-                <min-pool-size>
-                    <xsl:value-of select="$min.poolsize"/>
-                </min-pool-size>
-                <max-pool-size>
-                    <xsl:value-of select="$max.poolsize"/>
-                </max-pool-size>
-                <prefill>
-                    <xsl:value-of select="$pool.prefill"/>
-                </prefill>
-            </pool>
-        </datasource>
+        </xa-datasource>
     </xsl:variable>
     
     <xsl:variable name="newDriverDefinition">
         <xsl:if test="$driver != 'h2'">
-            <driver name="{$driver}" module="com.{$driver}" />
+            <driver name="{$driver}" module="com.{$driver}">
+                <xa-datasource-class>
+                    <xsl:value-of select="$xa.datasource.class"/>
+                </xa-datasource-class>
+            </driver>
         </xsl:if>
     </xsl:variable>