[jboss-cvs] JBossAS SVN: r105087 - in branches/JBPAPP_5_1/testsuite: src/main/org/jboss/test/jbossts/crash and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 21 08:18:18 EDT 2010
Author: istudens at redhat.com
Date: 2010-05-21 08:18:17 -0400 (Fri, 21 May 2010)
New Revision: 105087
Added:
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/AppServerJDBCXARecovery.java
Modified:
branches/JBPAPP_5_1/testsuite/imports/config/tests-crash-recovery.xml
branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelper.java
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/db2_97-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mssql2005-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mssql2008-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mysql50-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mysql51-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-lb-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-1-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-2-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-lb-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac1-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac2-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle10-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle11-r2-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle11-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres82-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres83-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres84-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres90-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/sybase15-xa-ds.xml
branches/JBPAPP_5_1/testsuite/src/resources/jbossts/scripts/as-tests.xml
Log:
crash recovery tests for new JCA XA recovery, JBQA-3205
Modified: branches/JBPAPP_5_1/testsuite/imports/config/tests-crash-recovery.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/imports/config/tests-crash-recovery.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/imports/config/tests-crash-recovery.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -31,6 +31,23 @@
| Usage for cluster tests:
| ./build.sh tests-ts-crash-recovery -Djbossts.db=oracle_rac -Djbossts.tstype=jts -Djbossts.target=crash-tests-single-db-tstype
|
+ | Added new option for setting of datasource credentials:
+ | -Djbossts.credentials=cr1 - the default one
+ | <xa-datasource-property name="User">crashrec</xa-datasource-property>
+ | <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ | -Djbossts.credentials=cr2
+ | <user-name>crashrec0</user-name>
+ | <password>crashrec0</password>
+ | <recover-user-name>crashrec</recover-user-name>
+ | <recover-password>crashrec</recover-password>
+ | -Djbossts.credentials=cr3
+ | <security-domain>CrashRecoveryDomain0</security-domain>
+ | <recover-user-name>crashrec</recover-user-name>
+ | <recover-password>crashrec</recover-password>
+ | -Djbossts.credentials=cr4
+ | <security-domain>CrashRecoveryDomain0</security-domain>
+ | <recover-security-domain>CrashRecoveryDomain</recover-security-domain>
+ |
| Note: If you want to force the wiping out any txs in doubt from DB before the test you can use the property -DwipeOutTxsInDoubtBeforeTest=true.
-->
<target name="tests-ts-crash-recovery"
@@ -49,6 +66,8 @@
<property name="jbossts.target" value="crash-tests" />
<property name="jbossts.max.time" value="420000" />
+ <property name="jbossts.credentials" value="cr1" />
+
<run-as-test target="${jbossts.target}" />
@@ -71,7 +90,7 @@
<path refid="junit.junit.classpath"/>
<path refid="jboss.server.manager.classpath"/>
<path refid="jboss.jbossts.classpath"/>
- <fileset dir="${jbosstest.dist}/client"/>
+ <fileset dir="${jbosstest.dist}/client"/>
</classpath>
<sysproperty key="ant.home" value="${ant.home}"/>
<sysproperty key="ant.library.dir" value="${ant.library.dir}"/>
@@ -91,6 +110,7 @@
<sysproperty key="jbossts.tstype" value="${jbossts.tstype}" />
<sysproperty key="jbossts.tsdemarc" value="${jbossts.tsdemarc}" />
<sysproperty key="jbossts.testcase" value="${jbossts.testcase}" />
+ <sysproperty key="jbossts.credentials" value="${jbossts.credentials}" />
<sysproperty key="testTime" value="${jbossts.max.time}" />
<env key="JBOSS_HOME" value="${jbosstest.dist}" />
<arg value="-f"/>
@@ -131,12 +151,15 @@
<setup-crash-recovery conf="crashrecovery-jta"/>
<setup-crash-recovery conf="crashrecovery-jts"/>
+ <setup-security-domains conf="crashrecovery-jta"/>
+ <setup-security-domains conf="crashrecovery-jts"/>
</target>
<macrodef name="setup-crash-recovery">
<attribute name="conf"/>
<sequential>
+ <echo message="Setting up crash recovery for profile @{conf}.."/>
<!-- enable crash recovery and point it to our datasource -->
<replace file="${jboss.dist}/server/@{conf}/conf/jbossts-properties.xml">
<replacetoken><![CDATA[</transaction-service>]]></replacetoken>
@@ -155,4 +178,35 @@
</sequential>
</macrodef>
+ <macrodef name="setup-security-domains">
+ <attribute name="conf"/>
+ <sequential>
+ <echo message="Setting up security domains for profile @{conf}.."/>
+ <replace file="${jboss.dist}/server/@{conf}/conf/login-config.xml">
+ <replacetoken><![CDATA[</policy>]]></replacetoken>
+ <replacevalue><![CDATA[
+ <application-policy name="CrashRecoveryDomain">
+ <authentication>
+ <login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
+ <module-option name="username">crashrec</module-option>
+ <module-option name="password">-170d8ac0642414f0207a6df87216de44</module-option>
+ <module-option name="managedConnectionFactoryName">jboss.jca:service=XATxCM,name=CrashRecoveryDS</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+ <application-policy name="CrashRecoveryDomain0">
+ <authentication>
+ <login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
+ <module-option name="username">crashrec0</module-option>
+ <module-option name="password">-170d8ac0642414f0f66025633c93b691</module-option>
+ <module-option name="managedConnectionFactoryName">jboss.jca:service=XATxCM,name=CrashRecoveryDS</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+</policy>]]></replacevalue>
+ </replace>
+ </sequential>
+ </macrodef>
+
</project>
Added: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/AppServerJDBCXARecovery.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/AppServerJDBCXARecovery.java (rev 0)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/AppServerJDBCXARecovery.java 2010-05-21 12:18:17 UTC (rev 105087)
@@ -0,0 +1,551 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author Redhat Middleware LLC.
+ */
+package org.jboss.test.jbossts.crash;
+
+import com.arjuna.ats.jta.recovery.XAResourceRecovery;
+
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.BadPaddingException;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.Cipher;
+import javax.crypto.spec.SecretKeySpec;
+import javax.transaction.xa.XAResource;
+import javax.naming.InitialContext;
+import javax.sql.XADataSource;
+import javax.sql.ConnectionEventListener;
+import javax.sql.ConnectionEvent;
+import javax.sql.XAConnection;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+import javax.management.MBeanException;
+import javax.management.InstanceNotFoundException;
+import java.sql.SQLException;
+import java.sql.Connection;
+import java.util.Properties;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.lang.reflect.Method;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.security.NoSuchAlgorithmException;
+import java.security.InvalidKeyException;
+import java.math.BigInteger;
+
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.logging.Logger;
+
+/**
+ * Taken from https://svn.jboss.org/repos/labs/labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/AppServerJDBCXARecovery.java ,
+ * some changes applied.
+ * Username/password credentials programmatically set to CrashHelper.DS_USER_NAME and CrashHelper.DS_PASSWORD.
+ *
+ *
+ * This provides recovery for compliant JDBC drivers accessed via datasources deployed in JBossAS 5
+ * It is not meant to be db driver specific.
+ *
+ * This code is based on JDBCXARecovery, which expects JNDI to contain an XADataSource implementation.
+ * In JBossAS, the object created in JNDI when a -ds.xml file containing <xa-datasource> element is used,
+ * does not implement the XADataSource interface. We therefore use this modified code to pull the
+ * datasource configuration information from the app server's JMX and instantiate an XADataSource from
+ * which it can then create an XAConnection.
+ *
+ * To use this class, add an XAResourceRecovery entry in the jta section of jbossts-properties.xml
+ * for each database for which you need recovery, ensuring the value ends with ;jndiname=<datasource-name>
+ * i.e. the same value as is in the -ds.xml jndi-name element.
+ *
+ * Note for users with secured JMX invokers, use the extended format:
+ * ;jndiname=MyExampleDbName,username=foo,password=bar
+ * The username and password refer to the JMX invoker, NOT the datasource.
+ *
+ * It's not possible to override the jdbc username and password given in the -ds.xml file at present.
+ * Since the recovery system sometimes needs greater db user privs than the app code, it may be preferable to
+ * set up a -ds.xml file only for recovery usage. This approach works for databases which allow users to
+ * recover one another's transactions, which is most of them. But consult
+ * your db docs or friendly neighbourhood DBA to be sure, then test it anyhow.
+ *
+ * You also need the XARecoveryModule enabled and appropriate values for nodeIdentifier and xaRecoveryNode set.
+ * See the JBossTS recovery guide if you are unclear on how the recovery system works.
+ *
+ * Note: This implementation expects to run inside the app server JVM. It probably won't work
+ * if you configure the recovery manager to run as a separate process. (JMX can be accessed remotely,
+ * but it would need code changes to the lookup function and some classpath additions).
+ *
+ *
+ * <properties depends="arjuna" name="jta">
+ * ...
+ * <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery1"
+ * value= "com.arjuna.ats.internal.jbossatx.jta.AppServerJDBCXARecovery;jndiname=MyExampleDbName[,username=foo,password=bar]"/>
+ * <!-- xaRecoveryNode should match value in nodeIdentifier or be * -->
+ * <property name="com.arjuna.ats.jta.xaRecoveryNode" value="1"/>
+ *
+ */
+public class AppServerJDBCXARecovery implements XAResourceRecovery {
+
+// implementation based on com.arjuna.ats.internal.jdbc.recovery.JDBCXARecovery
+
+ public AppServerJDBCXARecovery()
+ throws SQLException
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("AppServerJDBCXARecovery<init>");
+ }
+
+ _hasMoreResources = false;
+ _connectionEventListener = new LocalConnectionEventListener();
+ }
+
+ /**
+ * The recovery module will have chopped off this class name already. The
+ * parameter should specify a jndi name for the datasource.
+ */
+
+ public boolean initialise(String parameter)
+ throws SQLException
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("AppServerJDBCXARecovery.initialise(" + parameter + ")");
+ }
+
+ if (parameter == null)
+ return false;
+
+ retrieveData(parameter, _DELIMITER);
+
+ return true;
+ }
+
+ public synchronized XAResource getXAResource()
+ throws SQLException
+ {
+ createConnection();
+
+ if (_connection == null) {
+ throw new SQLException("The data source named [" + _dataSourceId + "] is not deployed.");
+ }
+
+ return _connection.getXAResource();
+ }
+
+ public boolean hasMoreResources()
+ {
+ if (_dataSource == null)
+ try
+ {
+ createDataSource();
+ }
+ catch (SQLException sqlException)
+ {
+ return false;
+ }
+
+ if (_dataSource != null)
+ {
+ _hasMoreResources = ! _hasMoreResources;
+
+ return _hasMoreResources;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Lookup the XADataSource in JNDI.
+ */
+ private final void createDataSource()
+ throws SQLException
+ {
+ // Note: the repeated use of SecurityAssociation.set[Principal|Credential] is a workaround for
+ // JBAS-7171 / JBAS-6449 / JBPAPP-2479. Although now fixed in some AS/EAP releases, we keep the
+ // workaround in place for now so we can work on older, non-fixed releases too.
+
+ try
+ {
+ if (_dataSource == null)
+ {
+ // This is where we do JBossAS specific magic. Use the JMX to fetch the name of the XADataSource class
+ // and its config params so that we don't have to duplicate the information in the -ds.xml file.
+
+ // TODO: can we make this flexible enough to handle remote app server processes, so that
+ // we can run the recovery manager out of process? The server addr would need to be on a per
+ // jndiname basis, as we may be doing recovery for a whole cluster. We would need AS
+ // jmx classes (and the db drivers naturally) on the recovery manager classpath.
+
+ InitialContext context = new InitialContext();
+ MBeanServerConnection server = (MBeanServerConnection)context.lookup("jmx/invoker/RMIAdaptor");
+ ObjectName objectName = new ObjectName("jboss.jca:name="+_dataSourceId+",service=ManagedConnectionFactory");
+
+ if(_username !=null && _password !=null)
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal(_username));
+ SecurityAssociation.setCredential(_password);
+ }
+
+ String className = (String)server.invoke(objectName, "getManagedConnectionFactoryAttribute", new Object[] {"XADataSourceClass"}, new String[] {"java.lang.String"});
+ log.debug("AppServerJDBCXARecovery datasource classname = "+className);
+
+ if(_username !=null && _password !=null)
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal(_username));
+ SecurityAssociation.setCredential(_password);
+ }
+
+ String properties = (String)server.invoke(objectName, "getManagedConnectionFactoryAttribute", new Object[] {"XADataSourceProperties"}, new String[] {"java.lang.String"});
+ // debug disabled due to security paranoia - it may log datasource password in cleartext.
+ //log.debug("AppServerJDBCXARecovery.result="+properties);
+
+/*
+ ObjectName txCmObjectName = new ObjectName("jboss.jca:name=" +_dataSourceId + ",service=XATxCM");
+
+ if(_username !=null && _password !=null)
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal(_username));
+ SecurityAssociation.setCredential(_password);
+ }
+
+ String securityDomainName = (String) server.getAttribute(txCmObjectName, "SecurityDomainJndiName");
+ log.debug("Security domain name associated with JCA ConnectionManager jboss.jca:name=" +_dataSourceId + ",service=XATxCM"+" is:"+securityDomainName);
+
+ if(securityDomainName != null && !securityDomainName.equals(""))
+ {
+ ObjectName _objectName = new ObjectName("jboss.security:service=XMLLoginConfig");
+
+ if(_username !=null && _password !=null)
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal(_username));
+ SecurityAssociation.setCredential(_password);
+ }
+
+ String config = (String)server.invoke(_objectName, "displayAppConfig", new Object[] {securityDomainName}, new String[] {"java.lang.String"});
+ String loginModuleClass = getValueForLoginModuleClass(config);
+ _dbUsername = getValueForKey(config, _USERNAME);
+ String _encryptedPassword = getValueForKey(config, _PASSWORD);
+
+ if("org.jboss.resource.security.JaasSecurityDomainIdentityLoginModule".equals(loginModuleClass))
+ {
+ String jaasSecurityDomain = getValueForKey(config, "jaasSecurityDomain");
+ if(_username !=null && _password !=null)
+ {
+ SecurityAssociation.setPrincipal(new SimplePrincipal(_username));
+ SecurityAssociation.setCredential(_password);
+ }
+ _dbPassword = decodePBE(server, _encryptedPassword, jaasSecurityDomain);
+ }
+ else
+ {
+ _dbPassword = decode(_encryptedPassword);
+ }
+
+ _encrypted = true;
+ }
+*/
+
+ try {
+ _dataSource = getXADataSource(className, properties);
+ _supportsIsValidMethod = true; // assume it does; we'll lazily check the first time we try to connect
+ } catch(Exception e) {
+ _dataSource = null;
+ log.error("AppServerJDBCXARecovery.createDataSource got exception during getXADataSource call: "+e.toString(), e);
+ throw new SQLException(e.toString());
+ }
+ }
+ }
+ catch (MBeanException mbe)
+ {
+ if (mbe.getTargetException() instanceof InstanceNotFoundException)
+ {
+ log.warn("AppServerJDBCXARecovery.createDataSource(name="+_dataSourceId+"): InstanceNotFound. Datasource not deployed, or wrong name?");
+
+ // this is an expected condition when the data source is not yet deployed
+ // just ignore this for now, the next time around, we try again to see if its deployed yet
+ return;
+ } else {
+ log.error("AppServerJDBCXARecovery.createDataSource(name="+_dataSourceId+") got exception " + mbe.toString(), mbe);
+ }
+
+ throw new SQLException(mbe.toString());
+ }
+ catch (SQLException ex)
+ {
+ log.error("AppServerJDBCXARecovery.createDataSource got exception "+ex.toString(), ex);
+
+ throw ex;
+ }
+ catch (Exception e)
+ {
+ log.error("AppServerJDBCXARecovery.createDataSource got exception "+e.toString(), e);
+
+ throw new SQLException(e.toString());
+ }
+ }
+
+ /**
+ * Create the XAConnection from the XADataSource.
+ */
+
+ private final void createConnection()
+ throws SQLException
+ {
+ try
+ {
+ if (_dataSource == null)
+ {
+ createDataSource();
+ // if we still don't have it, its because the data source isn't deployed yet
+ if (_dataSource == null) {
+ return;
+ }
+ }
+
+ Boolean isConnectionValid;
+ try {
+ if (_connection != null && _supportsIsValidMethod) {
+ Connection connection = _connection.getConnection();
+ Method method = connection.getClass().getMethod("isValid", new Class[] {Integer.class});
+ isConnectionValid = (Boolean) method.invoke(connection, new Object[] {new Integer(5)});
+ } else {
+ isConnectionValid = Boolean.FALSE;
+ }
+ } catch (NoSuchMethodException nsme) {
+ isConnectionValid = Boolean.FALSE;
+ _supportsIsValidMethod = false;
+ log.debug("XA datasource does not support isValid method - connection will always be recreated");
+ } catch (Throwable t) {
+ isConnectionValid = Boolean.FALSE;
+ log.debug("XA connection is invalid - will recreate a new one. Cause: " + t);
+ }
+
+ if (!isConnectionValid.booleanValue()) {
+ if (_connection != null) {
+ try {
+ _connection.close(); // just attempt to clean up anything that we can
+ } catch (Throwable t) {
+ } finally {
+ _connection = null;
+ }
+ }
+
+ // Check if the password is encrypted, the criteria should be the existence of <security-domain>EncryptDBPassword</security-domain>
+ // in the -ds.xml file.
+
+ if(!_encrypted) {
+ _connection = _dataSource.getXAConnection();
+ }
+ else {
+ _connection = _dataSource.getXAConnection(_dbUsername, _dbPassword);
+ }
+ _connection.addConnectionEventListener(_connectionEventListener);
+ log.debug("Created new XAConnection");
+ }
+ }
+ catch (SQLException ex)
+ {
+ log.error("AppServerJDBCXARecovery.createConnection got exception "+ex.toString(), ex);
+
+ throw ex;
+ }
+ catch (Exception e)
+ {
+ log.error("AppServerJDBCXARecovery.createConnection got exception "+e.toString(), e);
+
+ throw new SQLException(e.toString());
+ }
+ }
+
+ private class LocalConnectionEventListener implements ConnectionEventListener
+ {
+ public void connectionErrorOccurred(ConnectionEvent connectionEvent)
+ {
+ _connection.removeConnectionEventListener(_connectionEventListener);
+ _connection = null;
+ }
+
+ public void connectionClosed(ConnectionEvent connectionEvent)
+ {
+ _connection.removeConnectionEventListener(_connectionEventListener);
+ _connection = null;
+ }
+ }
+
+ // borrowed from org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory
+ // in which the equivalent functionality is protected not public :-(
+ private XADataSource getXADataSource(String xaDataSourceClassname, String propertiesString) throws Exception
+ {
+ // Map any \ to \\
+ propertiesString = propertiesString.replaceAll("\\\\", "\\\\\\\\");
+
+ Properties properties = new Properties();
+ InputStream is = new ByteArrayInputStream(propertiesString.getBytes());
+ properties.load(is);
+
+ // HACK for crash recovery tests
+ // check whether we have User and Password in XA properties
+ if (! properties.containsKey("User"))
+ {
+ properties.setProperty("User", CrashHelper.DS_USER_NAME);
+ properties.setProperty("Password", CrashHelper.DS_PASSWORD);
+ }
+ // end of hack
+
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass(xaDataSourceClassname);
+ XADataSource xads = (XADataSource) clazz.newInstance();
+ Class[] NOCLASSES = new Class[] {};
+ for (Iterator i = properties.keySet().iterator(); i.hasNext();)
+ {
+ String name = (String) i.next();
+ String value = properties.getProperty(name);
+ //This is a bad solution. On the other hand the only known example
+ // of a setter with no getter is for Oracle with password.
+ //Anyway, each xadatasource implementation should get its
+ //own subclass of this that explicitly sets the
+ //properties individually.
+ Class type = null;
+ try
+ {
+ Method getter = clazz.getMethod("get" + name, NOCLASSES);
+ type = getter.getReturnType();
+ }
+ catch (NoSuchMethodException e)
+ {
+ type = String.class;
+
+ try
+ {
+ //HACK for now until we can rethink the XADataSourceProperties variable and pass type information
+ Method getter = clazz.getMethod("is" + name, NOCLASSES);
+ type = getter.getReturnType();
+
+ }catch(NoSuchMethodException nsme)
+ {
+ type = String.class;
+
+ }
+
+ }
+
+ Method setter = clazz.getMethod("set" + name, new Class[] { type });
+ PropertyEditor editor = PropertyEditorManager.findEditor(type);
+ editor.setAsText(value);
+ setter.invoke(xads, new Object[] { editor.getValue() });
+ }
+ return xads;
+ }
+
+ public void retrieveData(String parameter,String delimiter)
+ {
+ StringTokenizer st = new StringTokenizer(parameter,delimiter);
+ while (st.hasMoreTokens())
+ {
+ String data = st.nextToken();
+ if(data.length()>9)
+ {
+ if(_USERNAME.equalsIgnoreCase(data.substring(0,8)))
+ {
+ _username =data.substring(9);
+ }
+ if(_PASSWORD.equalsIgnoreCase(data.substring(0,8)))
+ {
+ _password =data.substring(9);
+ }
+ if(_JNDINAME.equalsIgnoreCase(data.substring(0,8)))
+ {
+ _dataSourceId=data.substring(9);
+ }
+ }
+ }
+
+ if(_dataSourceId == null && parameter != null && parameter.indexOf('=') == -1) {
+ // try to fallback to old parameter format where only the dataSourceId is given, without jndiname= prefix
+ _dataSourceId = parameter;
+ }
+ }
+
+ private String getValueForKey(String config, String key)
+ {
+ Pattern usernamePattern = Pattern.compile("(name=" + key + ", value=)(.*)(</li>)");
+ Matcher m = usernamePattern.matcher(config);
+ if(m.find())
+ {
+ return m.group(2);
+ }
+ return "";
+ }
+
+ private String getValueForLoginModuleClass(String config)
+ {
+ Pattern usernamePattern = Pattern.compile("(" + _MODULE + ":)(.*)");
+ Matcher m = usernamePattern.matcher(config);
+ if(m.find())
+ {
+ return m.group(2).trim();
+ }
+ return "";
+ }
+
+ private static String decode(String secret) throws NoSuchPaddingException, NoSuchAlgorithmException,
+ InvalidKeyException, BadPaddingException, IllegalBlockSizeException
+ {
+ byte[] kbytes = "jaas is the way".getBytes();
+ SecretKeySpec key = new SecretKeySpec(kbytes, "Blowfish");
+
+ BigInteger n = new BigInteger(secret, 16);
+ byte[] encoding = n.toByteArray();
+
+ Cipher cipher = Cipher.getInstance("Blowfish");
+ cipher.init(Cipher.DECRYPT_MODE, key);
+ byte[] decode = cipher.doFinal(encoding);
+ return new String(decode);
+ }
+
+ private static String decodePBE(MBeanServerConnection server, String password, String jaasSecurityDomain) throws Exception
+ {
+ byte[] secret = (byte[]) server.invoke(new ObjectName(jaasSecurityDomain), "decode64", new Object[] {password}, new String[] {"java.lang.String"});
+ return new String(secret, "UTF-8");
+ }
+
+
+ private boolean _supportsIsValidMethod;
+ private XAConnection _connection;
+ private XADataSource _dataSource;
+ private LocalConnectionEventListener _connectionEventListener;
+ private boolean _hasMoreResources;
+ private boolean _encrypted;
+
+ private String _dataSourceId;
+ private String _username;
+ private String _password;
+ private String _dbUsername;
+ private String _dbPassword;
+
+ private final String _JNDINAME = "jndiname";
+ private final String _USERNAME = "username";
+ private final String _PASSWORD = "password";
+ private final String _MODULE = "LoginModule Class";
+ private final String _DELIMITER = ",";
+
+ private Logger log = org.jboss.logging.Logger.getLogger(AppServerJDBCXARecovery.class);
+}
Modified: branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelper.java
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelper.java 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/main/org/jboss/test/jbossts/crash/CrashHelper.java 2010-05-21 12:18:17 UTC (rev 105087)
@@ -35,9 +35,7 @@
import org.jboss.logging.Logger;
-import com.arjuna.ats.internal.jbossatx.jta.AppServerJDBCXARecovery;
-
/**
* Helper class for playing with txs in doubt.
*
@@ -54,6 +52,8 @@
* JNDI name of crash recovery datasource.
*/
public static final String DS_JNDI_NAME = "CrashRecoveryDS";
+ public static final String DS_USER_NAME = "crashrec";
+ public static final String DS_PASSWORD = "crashrec";
/**
@@ -173,6 +173,7 @@
catch (XAException e)
{
log.error("Cannot start recover scan on xares", e);
+ throw new EJBException("Cannot start recover scan on xares: " + e.getMessage());
}
finally
{
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/db2_97-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/db2_97-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/db2_97-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -15,8 +15,7 @@
<xa-datasource-class>com.ibm.db2.jcc.DB2XADataSource</xa-datasource-class>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<!-- Note, as opposed to the Type2 driver, DB2 Type 4 requires the PortNumber. By default this is 50000-->
<xa-datasource-property name="PortNumber">50000</xa-datasource-property>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mssql2005-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mssql2005-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mssql2005-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -29,8 +29,7 @@
<xa-datasource-property name="ServerName">dev30.qa.atl.jboss.com</xa-datasource-property>
<xa-datasource-property name="PortNumber">3918</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mssql2008-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mssql2008-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mssql2008-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -29,8 +29,7 @@
<xa-datasource-property name="ServerName">vmg04.mw.lab.eng.bos.redhat.com</xa-datasource-property>
<xa-datasource-property name="PortNumber">1433</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<xa-datasource-property name="SelectMethod">cursor</xa-datasource-property>
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mysql50-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mysql50-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mysql50-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -13,8 +13,7 @@
<xa-datasource-property name="ServerName">vmg08.mw.lab.eng.bos.redhat.com</xa-datasource-property>
<xa-datasource-property name="PortNumber">3306</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mysql51-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mysql51-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/mysql51-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -13,8 +13,7 @@
<xa-datasource-property name="ServerName">vmg02.mw.lab.eng.bos.redhat.com</xa-datasource-property>
<xa-datasource-property name="PortNumber">3306</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-lb-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-lb-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-lb-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -20,10 +20,9 @@
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=vmg24-vip.mw.lab.eng.bos.redhat.com)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vmg25-vip.mw.lab.eng.bos.redhat.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=qarac.jboss)))</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
- <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-1-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-1-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-1-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -20,10 +20,10 @@
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=vmg27-vip.mw.lab.eng.bos.redhat.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=qarac.jboss)))</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec0</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec0</xa-datasource-property>
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
- <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-2-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-2-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-2-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -23,7 +23,7 @@
<xa-datasource-property name="User">crashrec</xa-datasource-property>
<xa-datasource-property name="Password">crashrec</xa-datasource-property>
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
- <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-lb-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-lb-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac-r2-lb-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -20,8 +20,7 @@
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=vmg27-vip.mw.lab.eng.bos.redhat.com)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=vmg28-vip.mw.lab.eng.bos.redhat.com)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=qarac.jboss)))</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
<!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
<!-- Checks the Oracle error codes and messages for fatal errors -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac1-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac1-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac1-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -20,10 +20,10 @@
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=vmg24-vip.mw.lab.eng.bos.redhat.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=qarac.jboss)))</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <xa-datasource-property name="User">crashrec0</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec0</xa-datasource-property>
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
- <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac2-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac2-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle-rac2-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -23,7 +23,7 @@
<xa-datasource-property name="User">crashrec</xa-datasource-property>
<xa-datasource-property name="Password">crashrec</xa-datasource-property>
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
- <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle10-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle10-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle10-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -20,10 +20,9 @@
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@vmg05.mw.lab.eng.bos.redhat.com:1521:qaora10</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
- <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle11-r2-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle11-r2-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle11-r2-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -20,10 +20,9 @@
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=vmg27-vip.mw.lab.eng.bos.redhat.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=qarac.jboss)))</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
- <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle11-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle11-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/oracle11-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -20,19 +20,18 @@
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@dev04.qa.atl2.redhat.com:1521:qaora11</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
- <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name>
<!-- Checks the Oracle error codes and messages for fatal errors -->
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
<no-tx-separate-pools/>
- <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
- <metadata>
- <type-mapping>Oracle9i</type-mapping>
- </metadata>
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>Oracle9i</type-mapping>
+ </metadata>
</xa-datasource>
</datasources>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres82-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres82-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres82-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -8,7 +8,6 @@
<!--xa-datasource-property name="ServerName">dev01.qa.atl.jboss.com</xa-datasource-property-->
<xa-datasource-property name="PortNumber">5432</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
</xa-datasource>
</datasources>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres83-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres83-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres83-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -4,10 +4,18 @@
<jndi-name>CrashRecoveryDS</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
- <xa-datasource-property name="ServerName">vmg03.mw.lab.eng.bos.redhat.com</xa-datasource-property>
+ <!--xa-datasource-property name="ServerName">vmg03.mw.lab.eng.bos.redhat.com</xa-datasource-property-->
+ <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
<xa-datasource-property name="PortNumber">5432</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ <!--xa-datasource-property name="User">crashrec</xa-datasource-property>
+ <xa-datasource-property name="Password">crashrec</xa-datasource-property-->
+ <!--user-name>crashrec0</user-name>
+ <password>crashrec0</password-->
+ <!--security-domain>CrashRecoveryDomain0</security-domain>
+ <recover-security-domain>CrashRecoveryDomain</recover-security-domain-->
+ <!--recover-user-name>crashrec</recover-user-name>
+ <recover-password>crashrec</recover-password-->
+ @CREDENTIALS@
</xa-datasource>
</datasources>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres84-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres84-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres84-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -7,7 +7,6 @@
<xa-datasource-property name="ServerName">vmg03.mw.lab.eng.bos.redhat.com</xa-datasource-property>
<xa-datasource-property name="PortNumber">5432</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
</xa-datasource>
</datasources>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres90-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres90-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/postgres90-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -7,7 +7,6 @@
<xa-datasource-property name="ServerName">vmg03.mw.lab.eng.bos.redhat.com</xa-datasource-property>
<xa-datasource-property name="PortNumber">5432</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
</xa-datasource>
</datasources>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/sybase15-xa-ds.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/sybase15-xa-ds.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/resources/sybase15-xa-ds.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -18,8 +18,7 @@
<xa-datasource-property name="ServerName">vmg07.mw.lab.eng.bos.redhat.com</xa-datasource-property>
<xa-datasource-property name="PortNumber">5000</xa-datasource-property>
<xa-datasource-property name="DatabaseName">crashrec</xa-datasource-property>
- <xa-datasource-property name="User">crashrec</xa-datasource-property>
- <xa-datasource-property name="Password">crashrec</xa-datasource-property>
+ @CREDENTIALS@
<min-pool-size>1</min-pool-size>
<max-pool-size>20</max-pool-size>
<idle-timeout-minutes>15</idle-timeout-minutes>
Modified: branches/JBPAPP_5_1/testsuite/src/resources/jbossts/scripts/as-tests.xml
===================================================================
--- branches/JBPAPP_5_1/testsuite/src/resources/jbossts/scripts/as-tests.xml 2010-05-21 12:16:53 UTC (rev 105086)
+++ branches/JBPAPP_5_1/testsuite/src/resources/jbossts/scripts/as-tests.xml 2010-05-21 12:18:17 UTC (rev 105087)
@@ -437,7 +437,7 @@
<condition property="test.name.reverseOrder" value="-reverse" else="">
<istrue value="${reverseOrder}"/>
</condition>
- <property name="testname" value="${tstype}-${specs}-${test.name.cmt}${test.name.reverseOrder}"/>
+ <property name="testname" value="${tstype}-${specs}-${test.name.cmt}${test.name.reverseOrder}-${jbossts.credentials}"/>
<condition property="astest.app.jar.name" value="${astest.alternative.jar.name}">
<isset property="astest.alternative.jar.name"/>
@@ -449,9 +449,10 @@
</condition>
<property name="storeType" value="StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction" />
+ <deploy-datasource-and-set-credentials from="${product.dir}/resources/${datasource}" to="${jboss.home}/server/crashrecovery-${tstype}/deploy/${datasource}" />
<astest:server method="start" serverName="crashrecovery-${tstype}" >
<deploy from="dbdrivers/${dbdriver}" to="lib/${dbdriver}" />
- <deploy from="resources/${datasource}" to="deploy/${datasource}" />
+ <!--deploy from="resources/${datasource}" to="deploy/${datasource}" /-->
<deploy from="${astest.jar.deploy.dir}/${astest.app.jar.name}" to="deploy/${astest.app.jar.name}" />
</astest:server>
<astest:action abortOnFail="false" waitFor="10000" impl="org.jboss.test.jbossts.taskdefs.JUnitClientAction">
@@ -471,18 +472,21 @@
</astest:action>
<astest:server method="stop" serverName="crashrecovery-${tstype}" >
<undeploy from="deploy/${astest.app.jar.name}" />
- <undeploy from="deploy/${datasource}" />
+ <!--undeploy from="deploy/${datasource}" /-->
<undeploy from="lib/${dbdriver}" />
</astest:server>
- <!-- archive the server log -->
- <zip destfile="${jboss.home}/server/crashrecovery-${tstype}/log/server-${dbname}-${testname}.log.zip">
- <fileset file="${jboss.home}/server/crashrecovery-${tstype}/log/server.log"/>
+ <!-- archive artifacts -->
+ <zip destfile="${jboss.home}/server/crashrecovery-${tstype}/server-${dbname}-${testname}.artifacts.zip">
+ <fileset dir="${jboss.home}/server/crashrecovery-${tstype}">
+ <include name="log/server.log"/>
+ <include name="data/tx-object-store/**"/>
+ <include name="deploy/*-ds.xml"/>
+ <exclude name="deploy/hsqldb-ds.xml"/>
+ </fileset>
</zip>
+ <delete file="${jboss.home}/server/crashrecovery-${tstype}/deploy/${datasource}"/>
<delete file="${jboss.home}/server/crashrecovery-${tstype}/log/server.log"/>
- <copy todir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store-${dbname}-${testname}">
- <fileset dir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store" />
- </copy>
<delete dir="${jboss.home}/server/crashrecovery-${tstype}/data/tx-object-store"/>
<!-- delete work and tmp dirs otherwise tests failed due to permgen space - FIXME is this the right way how to ensure that? -->
<delete dir="${jboss.home}/server/crashrecovery-${tstype}/work"/>
@@ -491,6 +495,35 @@
</sequential>
</target>
+ <macrodef name="deploy-datasource-and-set-credentials">
+ <attribute name="from"/>
+ <attribute name="to"/>
+ <sequential>
+
+ <condition property="recover.credentials" value="<xa-datasource-property name="User">crashrec</xa-datasource-property><xa-datasource-property name="Password">crashrec</xa-datasource-property>">
+ <equals arg1="${jbossts.credentials}" arg2="cr1"/>
+ </condition>
+ <condition property="recover.credentials" value="<user-name>crashrec0</user-name><password>crashrec0</password><recover-user-name>crashrec</recover-user-name><recover-password>crashrec</recover-password>">
+ <equals arg1="${jbossts.credentials}" arg2="cr2"/>
+ </condition>
+ <condition property="recover.credentials" value="<security-domain>CrashRecoveryDomain0</security-domain><recover-user-name>crashrec</recover-user-name><recover-password>crashrec</recover-password>">
+ <equals arg1="${jbossts.credentials}" arg2="cr3"/>
+ </condition>
+ <condition property="recover.credentials" value="<security-domain>CrashRecoveryDomain0</security-domain><recover-security-domain>CrashRecoveryDomain</recover-security-domain>">
+ <equals arg1="${jbossts.credentials}" arg2="cr4"/>
+ </condition>
+
+ <echo message="Datasource: @{to}"/>
+ <echo message="Setting DS credentials to: ${recover.credentials}"/>
+
+ <copy file="@{from}" tofile="@{to}">
+ <filterset>
+ <filter token="CREDENTIALS" value="${recover.credentials}"/>
+ </filterset>
+ </copy>
+ </sequential>
+ </macrodef>
+
<target name="hack-before-astest-run" depends="hack-before-astest-run-for-db2_9.7, hack-before-astest-run-for-oracle_rac, hack-before-astest-run-for-oracle_rac_r2" />
<target name="hack-after-astest-run" depends="hack-after-astest-run-for-db2_9.7, hack-after-astest-run-for-oracle_rac, hack-after-astest-run-for-oracle_rac_r2" />
@@ -549,7 +582,7 @@
<target name="hack-before-astest-run-for-oracle_racs">
<!-- deploy the second DS configuration -->
- <copy file="${product.dir}/resources/${oracle_rac_second_ds}" todir="${jboss.home}/server/crashrecovery-${tstype}/deploy" />
+ <deploy-datasource-and-set-credentials from="${product.dir}/resources/${oracle_rac_second_ds}" to="${jboss.home}/server/crashrecovery-${tstype}/deploy/${oracle_rac_second_ds}" />
</target>
<target name="hack-after-astest-run-for-oracle_racs">
More information about the jboss-cvs-commits
mailing list