[jboss-cvs] JBoss Messaging SVN: r7606 - in trunk: examples/javaee/xarecovery and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 24 07:28:16 EDT 2009
Author: jmesnil
Date: 2009-07-24 07:28:15 -0400 (Fri, 24 Jul 2009)
New Revision: 7606
Added:
trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/
trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/recovery/
trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/recovery/MessagingXAResourceRecoveryTest.java
Modified:
trunk/docs/user-manual/en/appserver-integration.xml
trunk/examples/javaee/xarecovery/readme.html
trunk/examples/javaee/xarecovery/server/jbossts-properties.xml
trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceRecovery.java
trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceWrapper.java
Log:
JBMESSAGING-1506: Remove JMS & JDNI dependencies from MessagingXAResourceRecovery bean for JBoss AS 5.0
* used directly JBM Core API to recover its resources
- in TM configuration, instead of JNDI XAConnectionFactory lookup, pass transport configuration to
create a ClientSession which acts as the XAResource
* updated doc + javaee's xarecovery example
Modified: trunk/docs/user-manual/en/appserver-integration.xml
===================================================================
--- trunk/docs/user-manual/en/appserver-integration.xml 2009-07-24 11:21:42 UTC (rev 7605)
+++ trunk/docs/user-manual/en/appserver-integration.xml 2009-07-24 11:28:15 UTC (rev 7606)
@@ -827,7 +827,8 @@
(depending on the transaction outcome) when the server is restarted.</para>
<section>
<title>XA Recovery Configuration</title>
- <para>To enable JBoss Messagings XA Recovery, the following property must be added to
+ <para>To enable JBoss Messagings XA Recovery, the Recovery Manager must be configured to connect
+ to JBoss Messaging to recover its resources. The following property must be added to
the <literal>jta</literal> section of <literal>conf/jbossts-properties.xml</literal>
of JBoss AS profiles:</para>
<programlisting>
@@ -835,14 +836,69 @@
...
<property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JBMESSAGING1"
- value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;java:/XAConnectionFactory"/>
+ value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;[connection configuration]"/>
</properties>
- </programlisting>
- <para>This informs the recovery manager that it can recovers JBoss Messaging XA
- Resources using the <literal>XAConnectionFactory</literal> bound to <literal
- >java:/XAConnectionFactory</literal> in JNDI. A ConnectionFactory must have been
- configured with this JNDI name in <literal>jbm-jms.xml</literal> (see <xref
- linkend="using-jms.server.configuration"/>).</para>
+ </programlisting>
+ <para>The <literal>[connection configuration]</literal> contains all the information required to connect to
+ JBoss Messaging node under the form <literal>[connector factory class name],[user name], [password], [connector parameters]</literal>.
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para><literal>[connector factory class name]</literal> corresponds to the name of the <literal>ConnectorFactory</literal> used
+ to connect to JBoss Messaging. Values can be <literal>org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory</literal>
+ or <literal>org.jboss.messaging.integration.transports.netty.NettyConnectorFactory</literal></para>
+ </listitem>
+ <listitem>
+ <para><literal>[user name]</literal> is the user name to create a client session. It is optional</para>
+ </listitem>
+ <listitem>
+ <para><literal>[password]</literal> is the password to create a client session. It is mandatory only if the user name is specified</para>
+ </listitem>
+ <listitem>
+ <para><literal>[connector parameters]</literal> is a list of comma-separated key=value pair which are passed to the connector factory (see <xref
+ linkend="configuring-transports"/> for a list of the transport parameters).</para>
+ </listitem>
+ </itemizedlist>
+ <note>
+ <para>JBoss Messaging must have a valid acceptor which corresponds to the connector
+ specified in <literal>conf/jbossts-properties.xml</literal>.</para>
+ </note>
+ <section>
+ <title>Configuration Settings</title>
+ <para>If JBoss Messaging is configured with a default in-vm acceptor:</para>
+ <programlisting>
+<acceptor name="in-vm">
+ <factory-class>org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory</factory-class>
+</acceptor>
+ </programlisting>
+ <para>the corresponding configuration in <literal>conf/jbossts-properties.xml</literal> is:</para>
+ <programlisting>
+<property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JBMESSAGING1"
+ value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"/>
+ </programlisting>
+ <para>If it is now configured with a netty acceptor on a non-default port:</para>
+ <programlisting>
+<acceptor name="netty">
+ <factory-class>org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory</factory-class>
+ <param key="jbm.remoting.netty.port" value="8888" type="Integer"/>
+</acceptor>
+ </programlisting>
+ <para>the corresponding configuration in <literal>conf/jbossts-properties.xml</literal> is:</para>
+ <programlisting>
+<property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JBMESSAGING1"
+ value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;org.jboss.messaging.integration.transports.netty.NettyConnectorFactory, , , jbm.remoting.netty.port=8888"/>
+ </programlisting>
+ <note>
+ <para>Note the additional commas to skip the user and password before connector parameters</para>
+ </note>
+ <para>If the recovery must use <literal>admin, adminpass</literal>, the configuration would have been:</para>
+ <programlisting>
+ <property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JBMESSAGING1"
+ value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;org.jboss.messaging.integration.transports.netty.NettyConnectorFactory, admin, adminpass, jbm.remoting.netty.port=8888"/>
+ </programlisting>
+ <para>Configuring JBoss Messaging with an invm acceptor and configuring the Recovery Manager with an invm connector is the recommended
+ way to enable XA Recovery.</para>
+ </section>
</section>
<section>
<title>Example</title>
Modified: trunk/examples/javaee/xarecovery/readme.html
===================================================================
--- trunk/examples/javaee/xarecovery/readme.html 2009-07-24 11:21:42 UTC (rev 7605)
+++ trunk/examples/javaee/xarecovery/readme.html 2009-07-24 11:28:15 UTC (rev 7606)
@@ -25,15 +25,16 @@
<h3>XA Recovery configuration</h3>
<p>You need to enable XA Recovery of JBoss Messaging resources.</p>
- <p>In the <code>jta</code> section of the <code>$JBOSS_HOME/server/default-with-jbm2/conf/jbossts-properties.xml</code> configuration file, the following property
+ <p>In the <code>jta</code> section of the <code>$JBOSS_HOME/server/xarecovery-example-profile//conf/jbossts-properties.xml</code> configuration file, the following property
is added:</p>
<pre>
<code><property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JBMESSAGING1"
- value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;java:/XAConnectionFactory"/></code>
+ value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"/></code>
</pre>
- <p>This informs the Recovery Manager that it can recovers JBoss Messaging XA Resources using the <code>XAConnectionFactory</code> bound to <code>java:/XAConnectionFactory</code> in JNDI
- (as it is configured in <a href="config/jbm-jms.xml">jbm-jms.xml</a> which will be deployed to <code>$JBOSS_HOME/server/default-with-jbm2/deploy/messaging.sar/</code>).</p>
+ <p>This informs the Recovery Manager that it can recovers JBoss Messaging XA Resources by connecting to the server using an <code>InVMConnectorFactory</code>.
+ Since the Recovery Manager is in the same server than JBoss Messaging, the examples uses intra-vm communication to recover the messaging resources.
+ JBoss Messaging must have configured an invm acceptor to accept this connection (see the "in-vm"<code><acceptor></code> in <code>jbm-configuration.xml</code>).</p>
<p>The example copies a <code>jbossts-properties.xml</code> already configured for JBoss Messaging XA Recovery, so you
do not need to manually edit the profile's file.</p>
Modified: trunk/examples/javaee/xarecovery/server/jbossts-properties.xml
===================================================================
--- trunk/examples/javaee/xarecovery/server/jbossts-properties.xml 2009-07-24 11:21:42 UTC (rev 7605)
+++ trunk/examples/javaee/xarecovery/server/jbossts-properties.xml 2009-07-24 11:28:15 UTC (rev 7606)
@@ -240,7 +240,7 @@
com.arjuna.ats.internal.jta.transaction.jts.UserTransactionImple
-->
<property name="com.arjuna.ats.jta.recovery.XAResourceRecovery.JBMESSAGING1"
- value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;java:/XAConnectionFactory"/>
+ value="org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory"/>
</properties>
<properties depends="arjuna,txoj,jta" name="recoverymanager">
<!--
Modified: trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceRecovery.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceRecovery.java 2009-07-24 11:21:42 UTC (rev 7605)
+++ trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceRecovery.java 2009-07-24 11:28:15 UTC (rev 7606)
@@ -22,13 +22,14 @@
package org.jboss.messaging.jms.server.recovery;
-import org.jboss.messaging.core.logging.Logger;
+import java.util.HashMap;
+import java.util.Map;
import javax.transaction.xa.XAResource;
import com.arjuna.ats.jta.recovery.XAResourceRecovery;
-import java.util.StringTokenizer;
+import org.jboss.messaging.core.logging.Logger;
/**
*
@@ -47,14 +48,8 @@
private static final Logger log = Logger.getLogger(MessagingXAResourceRecovery.class);
- private String xaConnectionFactoryLookupName;
-
private boolean hasMore;
- private String username;
-
- private String password;
-
private MessagingXAResourceWrapper res;
public MessagingXAResourceRecovery()
@@ -66,33 +61,13 @@
{
if (log.isTraceEnabled()) { log.trace(this + " intialise: " + config); }
- StringTokenizer tok = new StringTokenizer(config, ",");
+ ConfigParser parser = new ConfigParser(config);
+ String connectorFactoryClassName = parser.getConnectorFactoryClassName();
+ Map<String, Object> connectorParams = parser.getConnectorParameters();
+ String username = parser.getUsername();
+ String password = parser.getPassword();
- //First (mandatory) param is the provider adaptor name
-
- if (!tok.hasMoreTokens())
- {
- throw new IllegalArgumentException("Must specify provider adaptor name in config");
- }
-
- xaConnectionFactoryLookupName = tok.nextToken();
-
- //Next two (optional) parameters are the username and password to use for creating the connection
- //for recovery
-
- if (tok.hasMoreTokens())
- {
- username = tok.nextToken();
-
- if (!tok.hasMoreTokens())
- {
- throw new IllegalArgumentException("If username is specified, password must be specified too");
- }
-
- password = tok.nextToken();
- }
-
- res = new MessagingXAResourceWrapper(xaConnectionFactoryLookupName, username, password);
+ res = new MessagingXAResourceWrapper(connectorFactoryClassName, connectorParams, username, password);
if (log.isTraceEnabled()) { log.trace(this + " initialised"); }
@@ -138,5 +113,92 @@
{
res.close();
}
+
+ public static class ConfigParser
+ {
+ private String connectorFactoryClassName;
+
+ private Map<String, Object> connectorParameters;
+
+ private String username;
+
+ private String password;
+
+ public ConfigParser(String config)
+ {
+ if (config == null || config.length() == 0)
+ {
+ throw new IllegalArgumentException("Must specify provider connector factory class name in config");
+ }
+
+ String[] strings = config.split(",");
+
+ //First (mandatory) param is the connector factory class name
+ if (strings.length < 1)
+ {
+ throw new IllegalArgumentException("Must specify provider connector factory class name in config");
+ }
+
+ connectorFactoryClassName = strings[0].trim();
+
+ //Next two (optional) parameters are the username and password to use for creating the session for recovery
+
+ if (strings.length >= 2)
+ {
+
+ username = strings[1].trim();
+ if (username.length() == 0)
+ {
+ username = null;
+ }
+
+ if (strings.length == 2)
+ {
+ throw new IllegalArgumentException("If username is specified, password must be specified too");
+ }
+
+ password = strings[2].trim();
+ if (password.length() == 0)
+ {
+ password = null;
+ }
+ }
+
+
+ // other tokens are for connector configurations
+ connectorParameters = new HashMap<String, Object>();
+ if (strings.length >= 3)
+ {
+ for (int i = 3; i < strings.length; i++)
+ {
+ String[] str = strings[i].split("=");
+ if (str.length == 2)
+ {
+ connectorParameters.put(str[0].trim(), str[1].trim());
+ }
+ }
+ }
+ }
+
+ public String getConnectorFactoryClassName()
+ {
+ return connectorFactoryClassName;
+ }
+
+ public Map<String, Object> getConnectorParameters()
+ {
+ return connectorParameters;
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+ }
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceWrapper.java 2009-07-24 11:21:42 UTC (rev 7605)
+++ trunk/src/main/org/jboss/messaging/jms/server/recovery/MessagingXAResourceWrapper.java 2009-07-24 11:28:15 UTC (rev 7606)
@@ -22,18 +22,19 @@
package org.jboss.messaging.jms.server.recovery;
-import javax.jms.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
-import javax.jms.XASession;
-import javax.naming.Context;
-import javax.naming.InitialContext;
+import java.util.Map;
+
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.remoting.FailureListener;
/**
* XAResourceWrapper.
@@ -50,39 +51,41 @@
*
* @version $Revision: 45341 $
*/
-public class MessagingXAResourceWrapper implements XAResource, ExceptionListener
+public class MessagingXAResourceWrapper implements XAResource, FailureListener
{
/** The log */
private static final Logger log = Logger.getLogger(MessagingXAResourceWrapper.class);
- /** The JNDI lookup for the XA connection factory */
- private final String xaConnectionFactoryLookupName;
-
/** The state lock */
private static final Object lock = new Object();
- /** The connection */
- private XAConnection connection;
+ /** The JNDI lookup for the XA connection factory */
+ private final String connectorFactoryClassName;
- /** The connectionFactory XAResource */
- private XAResource delegate;
+ private Map<String, Object> connectorConfig;
private final String username;
private final String password;
- public MessagingXAResourceWrapper(final String xaConnectionFactoryLookupName, final String username, final String password)
- {
- this.xaConnectionFactoryLookupName = xaConnectionFactoryLookupName;
+ private ClientSessionFactory csf;
- this.username = username;
+ private XAResource delegate;
+ public MessagingXAResourceWrapper(final String connectorFactoryClassName,
+ final Map<String, Object> connectorConfig,
+ final String username,
+ final String password)
+ {
+ this.connectorFactoryClassName = connectorFactoryClassName;
+ this.connectorConfig = connectorConfig;
+ this.username = username;
this.password = password;
}
public Xid[] recover(int flag) throws XAException
{
- log.debug("Recover " + xaConnectionFactoryLookupName);
+ log.debug("Recover " + connectorFactoryClassName);
XAResource xaResource = getDelegate();
try
{
@@ -96,7 +99,7 @@
public void commit(Xid xid, boolean onePhase) throws XAException
{
- log.debug("Commit " + xaConnectionFactoryLookupName + " xid " + " onePhase=" + onePhase);
+ log.debug("Commit " + connectorFactoryClassName + " xid " + " onePhase=" + onePhase);
XAResource xaResource = getDelegate();
try
{
@@ -110,7 +113,7 @@
public void rollback(Xid xid) throws XAException
{
- log.debug("Rollback " + xaConnectionFactoryLookupName + " xid ");
+ log.debug("Rollback " + connectorFactoryClassName + " xid ");
XAResource xaResource = getDelegate();
try
{
@@ -124,7 +127,7 @@
public void forget(Xid xid) throws XAException
{
- log.debug("Forget " + xaConnectionFactoryLookupName + " xid ");
+ log.debug("Forget " + connectorFactoryClassName + " xid ");
XAResource xaResource = getDelegate();
try
{
@@ -217,10 +220,11 @@
}
}
- public void onException(JMSException exception)
+ public boolean connectionFailed(MessagingException me)
{
- log.warn("Notified of connection failure in recovery connectionFactory for provider " + xaConnectionFactoryLookupName, exception);
+ log.warn("Notified of connection failure in recovery connectionFactory for provider " + connectorFactoryClassName, me);
close();
+ return true;
}
/**
@@ -245,7 +249,7 @@
if (result == null)
{
- XAException xae = new XAException("Error trying to connect to provider " + xaConnectionFactoryLookupName);
+ XAException xae = new XAException("Error trying to connect to provider " + connectorFactoryClassName);
xae.errorCode = XAException.XAER_RMERR;
if (error != null)
xae.initCause(error);
@@ -271,79 +275,44 @@
return delegate;
}
- // Create the connection
- XAConnection xaConnection;
+ TransportConfiguration config = new TransportConfiguration(connectorFactoryClassName, connectorConfig);
+ csf = new ClientSessionFactoryImpl(config);
+ ClientSession cs = null;
if (username == null)
{
- xaConnection = getConnectionFactory().createXAConnection();
+ cs = csf.createSession(true, false, false);
}
else
{
- xaConnection = getConnectionFactory().createXAConnection(username, password);
+ cs = csf.createSession(username, password, true, false, false, false, 1);
}
+ cs.addFailureListener(this);
synchronized (lock)
{
- connection = xaConnection;
+ delegate = cs;
}
-
- // Retrieve the connectionFactory XAResource
- try
- {
- XASession session = connection.createXASession();
- XAResource result = session.getXAResource();
- synchronized (lock)
- {
- delegate = result;
- }
- return delegate;
- }
- catch (Exception e)
- {
- close();
- throw e;
- }
+
+ return delegate;
}
/**
- * Get the XAConnectionFactory
- *
- * @return the connection
- * @throws Exception for any problem
- */
- protected XAConnectionFactory getConnectionFactory() throws Exception
- {
- // Get the XA Connection Factory
- if (xaConnectionFactoryLookupName == null)
- throw new IllegalArgumentException("Null XA ConnectionFactory lookup name");
- Context ctx = new InitialContext();
- try
- {
- return (XAConnectionFactory)ctx.lookup(xaConnectionFactoryLookupName);
- }
- finally
- {
- ctx.close();
- }
- }
-
- /**
* Close the connection
*/
public void close()
{
try
{
- XAConnection oldConnection = null;
+ ClientSessionFactory oldCSF = null;
synchronized (lock)
{
- oldConnection = connection;
- connection = null;
+ oldCSF = csf;
+ csf = null;
delegate = null;
}
- if (oldConnection != null)
- oldConnection.close();
+ if (oldCSF != null)
+ oldCSF.close();
}
catch (Exception ignored)
{
@@ -363,7 +332,7 @@
{
if (e.errorCode == XAException.XA_RETRY)
{
- log.debug("Fatal error in provider " + xaConnectionFactoryLookupName, e);
+ log.debug("Fatal error in provider " + connectorFactoryClassName, e);
close();
}
throw new XAException(XAException.XAER_RMFAIL);
Added: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/recovery/MessagingXAResourceRecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/recovery/MessagingXAResourceRecoveryTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/recovery/MessagingXAResourceRecoveryTest.java 2009-07-24 11:28:15 UTC (rev 7606)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.unit.jms.server.recovery;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.core.remoting.impl.invm.TransportConstants;
+import org.jboss.messaging.jms.server.recovery.MessagingXAResourceRecovery;
+
+/**
+ * A MessagingXAResourceRecoveryTest
+ *
+ * @author jmesnil
+ *
+ *
+ */
+public class MessagingXAResourceRecoveryTest extends TestCase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testConfigWithOnlyConnectorFactoryClassName() throws Exception
+ {
+ String config = "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory";
+ MessagingXAResourceRecovery.ConfigParser parser = new MessagingXAResourceRecovery.ConfigParser(config);
+
+ assertEquals(InVMConnectorFactory.class.getName(), parser.getConnectorFactoryClassName());
+ assertEquals(0, parser.getConnectorParameters().size());
+ assertNull(parser.getUsername());
+ assertNull(parser.getPassword());
+ }
+
+ public void testConfigWithConnectorFactoryClassNameAndParamsWithoutUserCredentials() throws Exception
+ {
+ String config = "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory, , , jbm.remoting.invm.serverid=99";
+ MessagingXAResourceRecovery.ConfigParser parser = new MessagingXAResourceRecovery.ConfigParser(config);
+
+ assertEquals(InVMConnectorFactory.class.getName(), parser.getConnectorFactoryClassName());
+ assertEquals(1, parser.getConnectorParameters().size());
+ assertEquals("99", parser.getConnectorParameters().get(TransportConstants.SERVER_ID_PROP_NAME));
+ assertNull(parser.getUsername());
+ assertNull(parser.getPassword());
+ }
+
+ public void testConfigWithConnectorFactoryClassNameAndParamsAndUserCredentials() throws Exception
+ {
+ String config = "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory, foo, bar, jbm.remoting.invm.serverid=99, key=val";
+ MessagingXAResourceRecovery.ConfigParser parser = new MessagingXAResourceRecovery.ConfigParser(config);
+
+ assertEquals(InVMConnectorFactory.class.getName(), parser.getConnectorFactoryClassName());
+ assertEquals(2, parser.getConnectorParameters().size());
+ assertEquals("99", parser.getConnectorParameters().get(TransportConstants.SERVER_ID_PROP_NAME));
+ assertEquals("val", parser.getConnectorParameters().get("key"));
+ assertEquals("foo", parser.getUsername());
+ assertEquals("bar", parser.getPassword());
+ }
+
+ public void testConfigWithConnectorFactoryClassNameAndUserCredentialsWithoutParams() throws Exception
+ {
+ String config = "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory, foo, bar";
+ MessagingXAResourceRecovery.ConfigParser parser = new MessagingXAResourceRecovery.ConfigParser(config);
+
+ assertEquals(InVMConnectorFactory.class.getName(), parser.getConnectorFactoryClassName());
+ assertEquals(0, parser.getConnectorParameters().size());
+ assertEquals("foo", parser.getUsername());
+ assertEquals("bar", parser.getPassword());
+ }
+
+ public void testEmptyString() throws Exception
+ {
+ try
+ {
+ String config = "";
+ new MessagingXAResourceRecovery.ConfigParser(config);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testUserNameWithoutPassword() throws Exception
+ {
+ try
+ {
+ String config = "org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory, foo";
+ new MessagingXAResourceRecovery.ConfigParser(config);
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
More information about the jboss-cvs-commits
mailing list