[jboss-cvs] JBoss Messaging SVN: r2928 - in trunk: src/main/org/jboss/messaging/core/impl and 35 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 26 20:33:56 EDT 2007
Author: timfox
Date: 2007-07-26 20:33:55 -0400 (Thu, 26 Jul 2007)
New Revision: 2928
Added:
trunk/tests/src/org/jboss/test/messaging/jms/DeliveryOrderTest.java
trunk/tests/src/org/jboss/test/messaging/tools/container/
trunk/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapper.java
trunk/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapperMBean.java
trunk/tests/src/org/jboss/test/messaging/tools/container/Command.java
trunk/tests/src/org/jboss/test/messaging/tools/container/Constants.java
trunk/tests/src/org/jboss/test/messaging/tools/container/Example.java
trunk/tests/src/org/jboss/test/messaging/tools/container/InVMContext.java
trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactory.java
trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactoryBuilder.java
trunk/tests/src/org/jboss/test/messaging/tools/container/InVMNameParser.java
trunk/tests/src/org/jboss/test/messaging/tools/container/JNPInitialContextFactory.java
trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/MBeanServerBuilder.java
trunk/tests/src/org/jboss/test/messaging/tools/container/ManagedConnectionFactoryJMXWrapper.java
trunk/tests/src/org/jboss/test/messaging/tools/container/ManagedConnectionFactoryJMXWrapperMBean.java
trunk/tests/src/org/jboss/test/messaging/tools/container/MockJBossSecurityManager.java
trunk/tests/src/org/jboss/test/messaging/tools/container/NamingDelegate.java
trunk/tests/src/org/jboss/test/messaging/tools/container/NoopInvoker.java
trunk/tests/src/org/jboss/test/messaging/tools/container/NotificationListenerID.java
trunk/tests/src/org/jboss/test/messaging/tools/container/ProxyNotificationListener.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RMINamingDelegate.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteContext.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteInitialContextFactory.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RemotingJMXWrapper.java
trunk/tests/src/org/jboss/test/messaging/tools/container/RemotingJMXWrapperMBean.java
trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceAttributeOverrides.java
trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceConfigHelper.java
trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceContainer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceContainerConfiguration.java
trunk/tests/src/org/jboss/test/messaging/tools/container/StopRMIServer.java
trunk/tests/src/org/jboss/test/messaging/tools/container/TransactionManagerJMXWrapper.java
trunk/tests/src/org/jboss/test/messaging/tools/container/TransactionManagerJMXWrapperMBean.java
Removed:
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapper.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapperMBean.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/Example.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/MBeanServerBuilder.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapper.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapperMBean.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/NoopInvoker.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapper.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapperMBean.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceConfigHelper.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapper.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapperMBean.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Command.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/NamingDelegate.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/NotificationListenerID.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/ProxyNotificationListener.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMINamingDelegate.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RemoteTestServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/Constants.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMContext.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactory.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactoryBuilder.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMNameParser.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/JNPInitialContextFactory.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/DeliveryOrderTest.java
Modified:
trunk/src/main/org/jboss/jms/tx/ResourceManagerFactory.java
trunk/src/main/org/jboss/messaging/core/impl/PagingChannelSupport.java
trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageStore.java
trunk/tests/bin/start-rmi-server
trunk/tests/bin/stop-rmi-server
trunk/tests/build.xml
trunk/tests/etc/log4j.trace.xml
trunk/tests/etc/log4j.xml
trunk/tests/src/org/jboss/test/messaging/core/IdManagerTest.java
trunk/tests/src/org/jboss/test/messaging/core/JDBCPersistenceManagerTest.java
trunk/tests/src/org/jboss/test/messaging/core/JDBCUtilTest.java
trunk/tests/src/org/jboss/test/messaging/core/MessageStoreTestBase.java
trunk/tests/src/org/jboss/test/messaging/core/MessagingQueueTestBase.java
trunk/tests/src/org/jboss/test/messaging/core/PostOfficeTestBase.java
trunk/tests/src/org/jboss/test/messaging/core/SimpleDeliveryObserver.java
trunk/tests/src/org/jboss/test/messaging/core/paging/PagingStateTestBase.java
trunk/tests/src/org/jboss/test/messaging/core/paging/PagingTest.java
trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java
trunk/tests/src/org/jboss/test/messaging/core/postoffice/SimpleJChannelFactory.java
trunk/tests/src/org/jboss/test/messaging/jms/AOPStackInitializationTest.java
trunk/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java
trunk/tests/src/org/jboss/test/messaging/jms/ConnectionConsumerTest.java
trunk/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
trunk/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
trunk/tests/src/org/jboss/test/messaging/jms/ExpiryQueueTest.java
trunk/tests/src/org/jboss/test/messaging/jms/GracefulClient.java
trunk/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java
trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
trunk/tests/src/org/jboss/test/messaging/jms/MessageCleanupTest.java
trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
trunk/tests/src/org/jboss/test/messaging/jms/MiscellaneousTest.java
trunk/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java
trunk/tests/src/org/jboss/test/messaging/jms/RemotingConnectionConfigurationTest.java
trunk/tests/src/org/jboss/test/messaging/jms/ScheduledDeliveryTest.java
trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
trunk/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java
trunk/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java
trunk/tests/src/org/jboss/test/messaging/jms/XAResourceRecoveryTest.java
trunk/tests/src/org/jboss/test/messaging/jms/XATestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringAspectInternalTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueDontUseXATest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueUseXATest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/ServerManagementTest.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashLargeLeaseTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashNegativeLeaseTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTwoConnectionsTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashZeroLeaseTest.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateClientOnServerCommand.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateHangingConsumerCommand.java
trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java
trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java
trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualQueueSoakTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/JMSDeliveryModeHeaderTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/JMSXDeliveryCountTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/MapMessageTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/MessageBodyTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/message/MessagePropertyConversionTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/MessageTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java
trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java
trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSTextMessage.java
trunk/tests/src/org/jboss/test/messaging/jms/message/TextMessageTest.java
trunk/tests/src/org/jboss/test/messaging/jms/selector/SelectorParserTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/DestinationManagerTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerConfigurationTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/connectionfactory/ConnectionFactoryTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/connectormanager/SimpleConnectorManagerTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/destination/TopicManagementTest.java
trunk/tests/src/org/jboss/test/messaging/jms/server/destination/base/DestinationManagementTestBase.java
trunk/tests/src/org/jboss/test/messaging/jms/stress/CorruptMessageStressTest.java
trunk/tests/src/org/jboss/test/messaging/jms/stress/Runner.java
trunk/tests/src/org/jboss/test/messaging/jms/stress/SeveralClientsStressTest.java
trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredQueueStressTest.java
trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
trunk/tests/src/org/jboss/test/messaging/tools/ant/DisplayWarningsAndErrors.java
trunk/tests/src/org/jboss/test/messaging/tools/ant/FailOnSerializationDebugOutput.java
trunk/tests/src/org/jboss/test/messaging/tools/ant/GenerateSmokeReport.java
trunk/tests/src/org/jboss/test/messaging/tools/aop/PoisonInterceptor.java
trunk/tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestRunner.java
trunk/tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestSuite.java
trunk/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java
trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java
trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java
trunk/tests/src/org/jboss/test/messaging/util/ProxyAssertSupport.java
trunk/tests/src/org/jboss/test/messaging/util/UtilTest.java
trunk/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackServerTimeoutTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/ManualConnectionValidatorTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/ServerAddressTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/SocketTransportCausalityTest.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java
Log:
More speedups
Modified: trunk/src/main/org/jboss/jms/tx/ResourceManagerFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/ResourceManagerFactory.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/src/main/org/jboss/jms/tx/ResourceManagerFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,6 +24,9 @@
import java.util.HashMap;
import java.util.Map;
+import org.jboss.jms.client.container.ConnectionAspect;
+import org.jboss.logging.Logger;
+
/**
* This class manages ResourceManager instances. It ensures there is one instance per instance of
* JMS server as specified by the server ID.
@@ -43,6 +46,9 @@
{
// Constants ------------------------------------------------------------------------------------
+ private static final Logger log = Logger.getLogger(ResourceManagerFactory.class);
+
+
// Static ---------------------------------------------------------------------------------------
public static ResourceManagerFactory instance = new ResourceManagerFactory();
@@ -80,7 +86,6 @@
*/
public synchronized ResourceManager checkOutResourceManager(int serverID)
{
-
Integer i = new Integer(serverID);
Holder h = (Holder)holders.get(i);
@@ -109,7 +114,7 @@
}
h.refCount--;
-
+
if (h.refCount == 0)
{
holders.remove(i);
Modified: trunk/src/main/org/jboss/messaging/core/impl/PagingChannelSupport.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/PagingChannelSupport.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/src/main/org/jboss/messaging/core/impl/PagingChannelSupport.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -210,9 +210,6 @@
}
}
-
-
-
public void unload() throws Exception
{
synchronized (lock)
@@ -222,8 +219,28 @@
throw new IllegalStateException("Cannot unload channel when active");
}
+ //We need to release any message refs so the message is released from the message store if appropriate
+
+ Iterator iter = messageRefs.iterator();
+
+ while (iter.hasNext())
+ {
+ MessageReference ref = (MessageReference)iter.next();
+
+ ref.releaseMemoryReference();
+ }
+
messageRefs.clear();
+ iter = downCache.iterator();
+
+ while (iter.hasNext())
+ {
+ MessageReference ref = (MessageReference)iter.next();
+
+ ref.releaseMemoryReference();
+ }
+
downCache.clear();
paging = false;
Modified: trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageStore.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageStore.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/src/main/org/jboss/messaging/core/impl/message/SimpleMessageStore.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -136,6 +137,19 @@
return new ArrayList(messages.keySet());
}
+ public void dump()
+ {
+ log.info("*** DUMPING " + this);
+ Iterator iter = messages.values().iterator();
+ while (iter.hasNext())
+ {
+ MessageHolder holder = (MessageHolder)iter.next();
+
+ log.info(holder.getMessage() + " count: " + holder.getInMemoryChannelCount());
+ }
+ log.info("*** End dump");
+ }
+
// MessagingComponent implementation --------------------------------
public void start() throws Exception
Modified: trunk/tests/bin/start-rmi-server
===================================================================
--- trunk/tests/bin/start-rmi-server 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/bin/start-rmi-server 2007-07-27 00:33:55 UTC (rev 2928)
@@ -91,4 +91,4 @@
fi
"$JAVA_HOME/java" $JAVA_OPTS -cp $CLASSPATH -Dtest.bind.address=localhost \
-org.jboss.test.messaging.tools.jmx.rmi.RMITestServer $port &
+org.jboss.test.messaging.tools.container.RMITestServer $port &
Modified: trunk/tests/bin/stop-rmi-server
===================================================================
--- trunk/tests/bin/stop-rmi-server 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/bin/stop-rmi-server 2007-07-27 00:33:55 UTC (rev 2928)
@@ -56,4 +56,4 @@
CLASSPATH=`cat $CLASSPATH_FILE`
"$JAVA_HOME/bin/java" $JAVA_OPTS -cp $CLASSPATH -Dtest.bind.address=localhost \
-org.jboss.test.messaging.tools.jmx.rmi.StopRMIServer
+org.jboss.test.messaging.tools.container.StopRMIServer
Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/build.xml 2007-07-27 00:33:55 UTC (rev 2928)
@@ -57,7 +57,7 @@
Functional tests.
-->
- <property name="functional.tests.database" value="oracle"/>
+ <property name="functional.tests.database" value="mysql"/>
<!--
Stress tests.
@@ -66,7 +66,7 @@
<property name="stress.tests.database" value="mysql"/>
<!-- Clustering tests -->
- <property name="clustering.tests.database" value="oracle"/>
+ <property name="clustering.tests.database" value="mysql"/>
<property name ="test-mask" value="*Test"/>
<!--
@@ -247,7 +247,7 @@
<target name="start-rmi-server" depends="init"
description="Starts the RMI server used by remote tests">
- <java classname="org.jboss.test.messaging.tools.jmx.rmi.RMITestServer" fork="true" spawn="true">
+ <java classname="org.jboss.test.messaging.tools.container.RMITestServer" fork="true" spawn="true">
<sysproperty key="module.output" value="${tests.output}"/>
<sysproperty key="test.logfile.suffix" value="${remote.server.test.logfile.suffix}"/>
<sysproperty key="test.bind.address" value="${test.bind.address}"/>
@@ -263,27 +263,9 @@
</java>
</target>
- <target name="start-rmi-server-stress" depends="init"
- description="Starts the RMI server used by remote stress tests">
-
- <java classname="org.jboss.test.messaging.tools.jmx.rmi.RMITestServer" fork="true" spawn="true">
- <jvmarg value="-Xmx768M"/>
- <sysproperty key="module.output" value="${tests.output}"/>
- <sysproperty key="test.logfile.suffix" value="remote-server-stress"/>
- <sysproperty key="test.bind.address" value="${test.bind.address}"/>
- <sysproperty key="jgroups.bind_addr" value="${test.bind.address}"/>
- <sysproperty key="test.database" value="${stress.tests.database}"/>
- <sysproperty key="test.remoting" value="${test.remoting}"/>
- <sysproperty key="objectstore.dir" value="${objectstore.dir}"/>
- <!-- <jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=rmiserver"/> -->
- <classpath refid="stress.test.execution.classpath"/>
-
- </java>
- </target>
-
<target name="stop-rmi-server" depends="init"
description="Stops the RMI server used by remote tests">
- <java classname="org.jboss.test.messaging.tools.jmx.rmi.StopRMIServer"
+ <java classname="org.jboss.test.messaging.tools.container.StopRMIServer"
classpathref="test.execution.classpath">
<sysproperty key="module.output" value="${tests.output}"/>
<sysproperty key="test.logfile.suffix" value="stop-rmi-server"/>
@@ -292,7 +274,7 @@
<target name="stop-rmi-server-clustering" depends="init"
description="Stops the RMI server used by clustering tests">
- <java classname="org.jboss.test.messaging.tools.jmx.rmi.StopRMIServer"
+ <java classname="org.jboss.test.messaging.tools.container.StopRMIServer"
classpathref="test.execution.classpath">
<sysproperty key="test.server.index" value="${test.server.index}"/>
<sysproperty key="module.output" value="${tests.output}"/>
@@ -331,6 +313,16 @@
</target>
+ <target name="short-tests" depends="tests-jar, prepare-testdirs, clear-test-logs">
+ <antcall target="crash-tests"/>
+
+ <antcall target="invm-tests"/>
+
+ <antcall target="remote-tests"/>
+
+ <antcall target="bridge-tests"/>
+ </target>
+
<target name="http-tests" depends="tests-jar, prepare-testdirs, clear-test-logs">
<antcall target="remote-tests">
<param name="test.remoting" value="http"/>
@@ -345,7 +337,8 @@
<echo message=""/>
<junit printsummary="${junit.printsummary}"
- fork="${junit.fork}"
+ fork="on"
+ forkMode="once"
includeantruntime="${junit.includeantruntime}"
haltonerror="${junit.haltonerror}"
haltonfailure="${junit.haltonfailure}"
@@ -366,15 +359,17 @@
-->
<classpath refid="test.execution.classpath"/>
<formatter type="xml" usefile="${junit.formatter.usefile}"/>
- <batchtest fork="${junit.batchtest.fork}"
- todir="${junit.batchtest.todir}"
+ <batchtest todir="${junit.batchtest.todir}"
haltonfailure="${junit.batchtest.haltonfailure}"
haltonerror="${junit.batchtest.haltonerror}">
<formatter type="plain" usefile="${junit.formatter.usefile}"/>
<fileset dir="${build.tests.classes}">
- <include name="**/${test-mask}.class"/>
+
+ <include name="**/messaging/core/**/${test-mask}.class"/>
+ <include name="**/messaging/jms/**/${test-mask}.class"/>
+ <include name="**/messaging/util/**/${test-mask}.class"/>
+
<exclude name="**/jms/MemLeakTest.class"/>
- <exclude name="**/jms/LongRunningInvocationTest.class"/>
<exclude name="**/jms/RemotingConnectionConfigurationTest.class"/>
<exclude name="**/jms/XAResourceRecoveryTest.class"/>
<exclude name="**/jms/stress/**"/>
@@ -382,7 +377,6 @@
<exclude name="**/jms/bridge/**"/>
<exclude name="**/jms/manual/**"/>
<exclude name="**/jms/clustering/**"/>
- <exclude name="**/thirdparty/**"/>
</fileset>
</batchtest>
</junit>
@@ -439,7 +433,6 @@
description="Runs remotely all tests for which it makes sense to run remotely">
<antcall target="stop-rmi-server"/>
- <antcall target="start-rmi-server"/>
<mkdir dir="${build.tests.reports}"/>
@@ -498,7 +491,8 @@
<exclude name="**/jms/PersistenceTest.class"/>
<exclude name="**/jms/MemLeakTest.class"/>
<exclude name="**/jms/ManifestTest.class"/>
- <exclude name="**/jms/JCAWrapperTest.class"/>
+ <exclude name="**/jms/JCAWrapperTest.class"/>
+ <exclude name="**/jms/ClientExitTest.class"/>
</fileset>
</batchtest>
@@ -513,7 +507,6 @@
description="Runs remotely all thirdparty tests for which it makes sense to run remotely">
<antcall target="stop-rmi-server"/>
- <antcall target="start-rmi-server"/>
<mkdir dir="${build.tests.reports}"/>
@@ -628,7 +621,6 @@
description="Runs remotely all stress tests for which it makes sense to run remotely">
<antcall target="stop-rmi-server"/>
- <antcall target="start-rmi-server-stress"/>
<mkdir dir="${build.tests.reports}"/>
<junit printsummary="${junit.printsummary}"
@@ -793,7 +785,6 @@
description="Runs bridge tests">
<antcall target="stop-rmi-server"/>
- <antcall target="start-rmi-server"/>
<mkdir dir="${build.tests.reports}"/>
@@ -1163,6 +1154,8 @@
</target>
<target name="report" depends="tests, copy-stylesheets, compile-report"/>
+
+ <target name="short-report" depends="short-tests, copy-stylesheets, compile-report"/>
<target name="stress-report" depends="stress-tests, copy-stylesheets, compile-report"/>
Modified: trunk/tests/etc/log4j.trace.xml
===================================================================
--- trunk/tests/etc/log4j.trace.xml 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/etc/log4j.trace.xml 2007-07-27 00:33:55 UTC (rev 2928)
@@ -71,7 +71,7 @@
<priority value="DEBUG"/>
</category>
- <category name="org.jboss.test.messaging.tools.jmx.MockJBossSecurityManager">
+ <category name="org.jboss.test.messaging.tools.container.MockJBossSecurityManager">
<priority value="DEBUG"/>
</category>
Modified: trunk/tests/etc/log4j.xml
===================================================================
--- trunk/tests/etc/log4j.xml 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/etc/log4j.xml 2007-07-27 00:33:55 UTC (rev 2928)
@@ -80,7 +80,7 @@
<priority value="TRACE" class="org.jboss.logging.XLevel"/>
</category>
- <category name="org.jboss.test.messaging.tools.jmx.MockJBossSecurityManager">
+ <category name="org.jboss.test.messaging.tools.container.MockJBossSecurityManager">
<priority value="DEBUG"/>
</category>
Modified: trunk/tests/src/org/jboss/test/messaging/core/IdManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/IdManagerTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/IdManagerTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -26,8 +26,7 @@
import org.jboss.messaging.core.impl.IDManager;
import org.jboss.messaging.core.impl.JDBCPersistenceManager;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
@@ -80,11 +79,9 @@
public void tearDown() throws Exception
{
- if (!ServerManagement.isRemote())
- {
- sc.stop();
- sc = null;
- }
+ sc.stop();
+ sc = null;
+
pm.stop();
super.tearDown();
}
Modified: trunk/tests/src/org/jboss/test/messaging/core/JDBCPersistenceManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/JDBCPersistenceManagerTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/JDBCPersistenceManagerTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -42,7 +42,7 @@
import org.jboss.messaging.core.impl.tx.TransactionRepository;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.test.messaging.util.CoreMessageFactory;
import org.jboss.util.id.GUID;
@@ -79,10 +79,11 @@
}
super.setUp();
+
+ ServerManagement.stop();
sc = new ServiceContainer("all");
- sc.start();
-
+ sc.start();
}
protected void doSetup(boolean batch, boolean useBinaryStream,
@@ -106,11 +107,9 @@
public void tearDown() throws Exception
{
- if (!ServerManagement.isRemote())
- {
- sc.stop();
- sc = null;
- }
+ sc.stop();
+ sc = null;
+
pm.stop();
ms.stop();
super.tearDown();
@@ -939,48 +938,6 @@
}
- //Commented out until recovery work is complete
-
-// public void testRetrievePreparedTransactions() throws Throwable
-// {
-// doSetup(false, 100);
-//
-// Channel channel = new SimpleChannel(0, ms);
-//
-// TransactionRepository txRep = new TransactionRepository(pm, new IDManager("TRANSACTION_ID", 10, pm));
-// txRep.start();
-//
-// Message[] messages = createMessages(10);
-//
-// Xid[] xids = new Xid[messages.length];
-// Transaction[] txs = new Transaction[messages.length];
-//
-// for (int i = 0; i < messages.length; i++)
-// {
-// xids[i] = new MockXid();
-// txs[i] = txRep.createTransaction(xids[i]);
-// MessageReference ref = ms.reference(messages[i]);
-// pm.addReference(channel.getChannelID(), ref, txs[i]);
-// txs[i].prepare();
-// }
-//
-// List txList = pm.retrievePreparedTransactions();
-// assertNotNull(txList);
-// assertEquals(messages.length, txList.size());
-//
-// for (int i = 0; i < xids.length; i++)
-// {
-// Xid xid = xids[i];
-// assertTrue(txList.contains(xid));
-// }
-//
-// //rollback the txs
-// for (int i = 0; i < txs.length; i++)
-// {
-// txs[i].rollback();
-// }
-// }
-
protected Message createMessage(byte i, boolean reliable) throws Throwable
{
Map headers = generateFilledMap(true);
Modified: trunk/tests/src/org/jboss/test/messaging/core/JDBCUtilTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/JDBCUtilTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/JDBCUtilTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,8 +21,8 @@
*/
package org.jboss.test.messaging.core;
+import org.jboss.messaging.util.JDBCUtil;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.messaging.util.JDBCUtil;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/core/MessageStoreTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/MessageStoreTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/MessageStoreTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -25,12 +25,12 @@
import java.util.Iterator;
import java.util.Map;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.util.CoreMessageFactory;
import org.jboss.messaging.core.contract.Message;
import org.jboss.messaging.core.contract.MessageReference;
import org.jboss.messaging.core.contract.MessageStore;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
+import org.jboss.test.messaging.util.CoreMessageFactory;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/core/MessagingQueueTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/MessagingQueueTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/MessagingQueueTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -27,7 +27,6 @@
import java.util.List;
import org.jboss.messaging.core.contract.Delivery;
-import org.jboss.messaging.core.contract.Filter;
import org.jboss.messaging.core.contract.Message;
import org.jboss.messaging.core.contract.MessageReference;
import org.jboss.messaging.core.contract.MessageStore;
@@ -36,12 +35,11 @@
import org.jboss.messaging.core.impl.IDManager;
import org.jboss.messaging.core.impl.JDBCPersistenceManager;
import org.jboss.messaging.core.impl.MessagingQueue;
-import org.jboss.messaging.core.impl.message.CoreMessage;
import org.jboss.messaging.core.impl.message.SimpleMessageStore;
import org.jboss.messaging.core.impl.tx.Transaction;
import org.jboss.messaging.core.impl.tx.TransactionRepository;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.test.messaging.util.CoreMessageFactory;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/core/PostOfficeTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/PostOfficeTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/PostOfficeTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -44,8 +44,7 @@
import org.jboss.messaging.core.impl.tx.TransactionRepository;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.core.postoffice.ClusteredPersistenceServiceConfigFileJChannelFactory;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.test.messaging.util.CoreMessageFactory;
/**
@@ -268,11 +267,9 @@
protected void tearDown() throws Exception
{
- if (!ServerManagement.isRemote())
- {
- sc.stop();
- sc = null;
- }
+ sc.stop();
+ sc = null;
+
pm.stop();
tr.stop();
ms.stop();
Modified: trunk/tests/src/org/jboss/test/messaging/core/SimpleDeliveryObserver.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/SimpleDeliveryObserver.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/SimpleDeliveryObserver.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,10 +21,10 @@
*/
package org.jboss.test.messaging.core;
+import org.jboss.logging.Logger;
import org.jboss.messaging.core.contract.Delivery;
import org.jboss.messaging.core.contract.DeliveryObserver;
import org.jboss.messaging.core.impl.tx.Transaction;
-import org.jboss.logging.Logger;
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
Modified: trunk/tests/src/org/jboss/test/messaging/core/paging/PagingStateTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/paging/PagingStateTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/paging/PagingStateTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -46,7 +46,7 @@
import org.jboss.messaging.core.impl.tx.Transaction;
import org.jboss.messaging.core.impl.tx.TransactionRepository;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.tm.TransactionManagerService;
import org.jboss.util.id.GUID;
Modified: trunk/tests/src/org/jboss/test/messaging/core/paging/PagingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/paging/PagingTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/paging/PagingTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -28,7 +28,7 @@
import org.jboss.messaging.core.impl.message.CoreMessage;
import org.jboss.messaging.core.impl.message.SimpleMessageStore;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.test.messaging.util.CoreMessageFactory;
Modified: trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/postoffice/ClusteredPersistenceServiceConfigFileJChannelFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -13,9 +13,8 @@
import org.jboss.messaging.core.contract.JChannelFactory;
import org.jboss.messaging.core.impl.jchannelfactory.MultiplexerJChannelFactory;
import org.jboss.messaging.util.XMLUtil;
+import org.jboss.test.messaging.tools.container.ServiceConfigHelper;
import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
-import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
-import org.jboss.test.messaging.tools.jmx.ServiceConfigHelper;
import org.jgroups.JChannel;
import org.w3c.dom.Element;
Modified: trunk/tests/src/org/jboss/test/messaging/core/postoffice/SimpleJChannelFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/postoffice/SimpleJChannelFactory.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/core/postoffice/SimpleJChannelFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,8 +22,8 @@
package org.jboss.test.messaging.core.postoffice;
+import org.jboss.messaging.core.contract.JChannelFactory;
import org.jgroups.JChannel;
-import org.jboss.messaging.core.contract.JChannelFactory;
/**
* A JChannelFactory that will use String JChannel configurations to create JChannel instances.
Modified: trunk/tests/src/org/jboss/test/messaging/jms/AOPStackInitializationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/AOPStackInitializationTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/AOPStackInitializationTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,13 +6,13 @@
*/
package org.jboss.test.messaging.jms;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.naming.InitialContext;
+
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import javax.naming.InitialContext;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-
/**
* Tests the very first server invocation, when the client-side AOP stack is initialized.
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,23 +21,24 @@
*/
package org.jboss.test.messaging.jms;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.jmx.rmi.Server;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.logging.Logger;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
-import javax.naming.InitialContext;
+import javax.jms.Connection;
import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
import javax.jms.Queue;
-import javax.jms.Connection;
import javax.jms.Session;
-import javax.jms.MessageConsumer;
import javax.jms.TextMessage;
-import java.io.ObjectOutputStream;
-import java.io.FileOutputStream;
-import java.io.File;
+import javax.naming.InitialContext;
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.Server;
+
/**
* A test that makes sure that a Messaging client gracefully exists after the last connection is
* closed. Test for http://jira.jboss.org/jira/browse/JBMESSAGING-417.
@@ -74,14 +75,10 @@
public void testGracefulClientExit() throws Exception
{
- if (ServerManagement.isRemote())
- {
- // doesn't make any sense to run in remote mode, since we'll start our won external VM
- return;
- }
-
Server localServer = null;
File serialized = null;
+
+ Connection conn = null;
try
{
@@ -105,7 +102,7 @@
// read the message from the queue
- Connection conn = cf.createConnection();
+ conn = cf.createConnection();
conn.start();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer cons = sess.createConsumer(queue);
@@ -120,10 +117,11 @@
p.waitFor();
assertEquals(0, p.exitValue());
-
}
finally
{
+ conn.close();
+
// TODO delete the file
if (serialized != null)
{
@@ -143,6 +141,8 @@
protected void setUp() throws Exception
{
super.setUp();
+
+ ServerManagement.stop();
}
protected void tearDown() throws Exception
Modified: trunk/tests/src/org/jboss/test/messaging/jms/ConnectionConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ConnectionConsumerTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ConnectionConsumerTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -60,7 +60,7 @@
super(name);
}
- // TestCase overrides -------------------------------------------
+ // TestCase overrides -------------------------------------------
// Public --------------------------------------------------------
@@ -307,6 +307,8 @@
{
if (connConsumer != null) connConsumer.close();
if (connConsumer != null) connProducer.close();
+
+ removeAllMessages(queue1.getQueueName(), true, 0);
}
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -35,7 +35,7 @@
import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -230,11 +230,12 @@
connection.close();
}
- public void testSetClientAfterStart()
+ public void testSetClientAfterStart() throws Exception
{
+ Connection connection = null;
try
{
- Connection connection = cf.createConnection();
+ connection = cf.createConnection();
//we start the connection
connection.start();
@@ -254,6 +255,13 @@
{
fail("Should raise a javax.jms.IllegalStateException, not a java.lang.IllegalStateException");
}
+ finally
+ {
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
}
@@ -331,7 +339,8 @@
metaData.getProviderMajorVersion();
metaData.getProviderMinorVersion();
metaData.getProviderVersion();
-
+
+ connection.close();
}
Copied: trunk/tests/src/org/jboss/test/messaging/jms/DeliveryOrderTest.java (from rev 2924, trunk/tests/src/org/jboss/test/thirdparty/remoting/DeliveryOrderTest.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/DeliveryOrderTest.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/jms/DeliveryOrderTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.test.messaging.jms;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import EDU.oswego.cs.dl.util.concurrent.Latch;
+
+/**
+ *
+ * A DeliveryOrderTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class DeliveryOrderTest extends JMSTestCase
+{
+
+ public DeliveryOrderTest(String name)
+ {
+ super(name);
+ }
+
+ public void testOutOfOrder() throws Exception
+ {
+ Connection conn = null;
+ try
+ {
+ conn = cf.createConnection();
+
+ Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
+
+ Session sess2 = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess.createProducer(queue1);
+
+ MessageConsumer cons = sess2.createConsumer(queue1);
+
+ Latch latch = new Latch();
+
+ final int NUM_MESSAGES = 1000;
+
+ MyListener listener = new MyListener(latch, NUM_MESSAGES);
+
+ cons.setMessageListener(listener);
+
+ conn.start();
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sess.createTextMessage("message" + i);
+
+ prod.send(tm);
+
+ if (i % 10 == 0)
+ {
+ sess.commit();
+ }
+ }
+
+ // need extra commit for cases in which the last message index is not a multiple of 10
+ sess.commit();
+
+ latch.acquire();
+
+ if (listener.failed)
+ {
+ fail("listener failed: " + listener.getError());
+ }
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ class MyListener implements MessageListener
+ {
+ private int c;
+ private int num;
+ private Latch latch;
+ private volatile boolean failed;
+ private String error;
+
+ MyListener(Latch latch, int num)
+ {
+ this.latch = latch;
+ this.num = num;
+ }
+
+ public void onMessage(Message msg)
+ {
+ // preserve the first error
+ if (failed)
+ {
+ return;
+ }
+
+ try
+ {
+ TextMessage tm = (TextMessage)msg;
+
+ if (!("message" + c).equals(tm.getText()))
+ {
+ // Failed
+ failed = true;
+ setError("Listener was supposed to get " + ("message" + c) +
+ " but got " + tm.getText());
+ latch.release();
+ }
+
+ c++;
+
+ if (c == num)
+ {
+ latch.release();
+ }
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+
+ // Failed
+ failed = true;
+ setError("Listener got exception " + e.toString());
+ latch.release();
+ }
+ }
+
+ public synchronized String getError()
+ {
+ return error;
+ }
+
+ private synchronized void setError(String s)
+ {
+ error = s;
+ }
+
+
+ }
+
+}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/ExpiryQueueTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ExpiryQueueTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ExpiryQueueTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -34,14 +34,11 @@
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.jms.Topic;
import javax.management.ObjectName;
-import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.message.JBossMessage;
-import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
/**
@@ -104,10 +101,6 @@
assertNotNull(expiryQueue);
- InitialContext ic = null;
-
- ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
JBossQueue q = (JBossQueue)ic.lookup("/queue/ExpiryQueue");
assertNotNull(q);
@@ -116,10 +109,7 @@
}
finally
{
- if (ic != null) ic.close();
-
ServerManagement.undeployQueue("ExpiryQueue");
-
}
}
@@ -134,26 +124,15 @@
assertNull(expiryQueue);
- InitialContext ic = null;
-
try
{
- ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+ ic.lookup("/queue/ExpiryQueue");
- try
- {
- ic.lookup("/queue/ExpiryQueue");
-
- fail();
- }
- catch (NameNotFoundException e)
- {
- //Ok
- }
+ fail();
}
- finally
+ catch (NameNotFoundException e)
{
- if (ic != null) ic.close();
+ //Ok
}
}
@@ -166,8 +145,7 @@
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
try
- {
-
+ {
ServerManagement.deployQueue("DefaultExpiry");
ServerManagement.deployQueue("OverrideExpiry");
Modified: trunk/tests/src/org/jboss/test/messaging/jms/GracefulClient.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/GracefulClient.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/GracefulClient.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,14 +21,15 @@
*/
package org.jboss.test.messaging.jms;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+
import javax.jms.Connection;
-import javax.jms.Session;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
-import javax.jms.MessageConsumer;
-import javax.jms.ConnectionFactory;
import javax.jms.Queue;
-import java.io.ObjectInputStream;
-import java.io.FileInputStream;
+import javax.jms.Session;
/**
* Code to be run in an external VM, via main().
Modified: trunk/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -92,6 +92,8 @@
assertEquals("one", rm.getText());
conn.close();
+
+ log.info("**** class is " + mcf);
}
finally
{
@@ -103,7 +105,7 @@
if (suspended != null)
{
TransactionManagerLocator.getInstance().locate().resume(suspended);
- }
+ }
}
}
@@ -163,6 +165,14 @@
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
+
+ protected void tearDown() throws Exception
+ {
+ //We don't want the managed connection pool hanging on to connections
+ ServerManagement.getServer(0).flushManagedConnectionPool();
+
+ super.tearDown();
+ }
// Private -------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/JMSTestCase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -5,6 +5,8 @@
import javax.naming.InitialContext;
import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.tx.ResourceManagerFactory;
+import org.jboss.messaging.core.impl.message.SimpleMessageStore;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -41,6 +43,8 @@
protected static String conf;
protected String overrideConf;
+
+ protected boolean startMessagingServer = true;
protected void setUp() throws Exception
{
@@ -64,15 +68,18 @@
changeServer = true;
newConf = overrideConf;
- }
+ }
- if (changeServer)
+ if (changeServer || !ServerManagement.isStarted(0))
{
log.info("Config has changed so stopping server with " + conf + " config and starting new one with " + newConf);
ServerManagement.stop();
- conf = newConf;
+ if (changeServer)
+ {
+ conf = newConf;
+ }
ServerManagement.start(0, conf);
@@ -94,6 +101,32 @@
checkNoSubscriptions(topic2);
checkNoSubscriptions(topic3);
}
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ //A few sanity checks
+
+ if (ServerManagement.isStarted(0))
+ {
+ if (!ServerManagement.isRemote())
+ {
+ SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
+
+ if (ms.messageIds().size() != 0)
+ {
+ ms.dump();
+ fail("There are messages in the message store");
+ }
+ }
+
+ checkNoMessageData();
+ }
+
+ //This will tell us if any connections have been left open
+ assertEquals(0, ResourceManagerFactory.instance.size());
+ }
public JMSTestCase(String name)
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/MessageCleanupTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/MessageCleanupTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/MessageCleanupTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -29,6 +29,7 @@
import javax.jms.Session;
import javax.jms.TemporaryQueue;
import javax.jms.TemporaryTopic;
+import javax.jms.Topic;
import org.jboss.messaging.core.impl.message.SimpleMessageStore;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -51,6 +52,8 @@
// Attributes ----------------------------------------------------
+ protected Topic ourTopic;
+
// Constructors --------------------------------------------------
public MessageCleanupTest(String name)
@@ -60,6 +63,22 @@
// TestCase overrides -------------------------------------------
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ ServerManagement.deployTopic("TestTopic", 100, 10, 10);
+
+ ourTopic = (Topic)ic.lookup("/topic/TestTopic");
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ ServerManagement.undeployTopic("TestTopic");
+ }
+
/*
* Test that all messages on a non durable sub are removed on close
*/
@@ -67,119 +86,102 @@
{
if (ServerManagement.isRemote()) return;
- Connection conn = null;
+ SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
- try
+ assertEquals(0, ms.messageIds().size());
+
+ Connection conn = cf.createConnection();
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess.createProducer(ourTopic);
+
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ MessageConsumer cons = sess.createConsumer(ourTopic);
+
+ for (int i = 0; i < 150; i++)
{
-
- conn = cf.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(topic1);
-
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- MessageConsumer cons = sess.createConsumer(topic1);
-
- for (int i = 0; i < 150; i++)
- {
- prod.send(sess.createMessage());
- }
-
- SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
-
- assertEquals(100, ms.messageIds().size());
-
- //50 Should be paged onto disk
-
- assertEquals(50, getReferenceIds().size());
-
- assertEquals(50, getMessageIds().size());
-
- //Now we close the consumer
-
- cons.close();
-
- assertEquals(0, ms.messageIds().size());
-
- assertEquals(0, getReferenceIds().size());
-
- assertEquals(0, getMessageIds().size());
+ prod.send(sess.createMessage());
}
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
+
+ assertEquals(100, ms.messageIds().size());
+
+ //50 Should be paged onto disk
+
+ assertEquals(50, getReferenceIds().size());
+
+ assertEquals(50, getMessageIds().size());
+
+ //Now we close the consumer
+
+ cons.close();
+
+ assertEquals(0, ms.messageIds().size());
+
+ assertEquals(0, getReferenceIds().size());
+
+ assertEquals(0, getMessageIds().size());
+
+ conn.close();
}
public void testNonDurableClose2() throws Exception
{
if (ServerManagement.isRemote()) return;
- Connection conn = null;
+ Connection conn = cf.createConnection();
- try
- {
- conn = cf.createConnection();
-
- conn.setClientID("wibble12345");
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(topic1);
-
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- MessageConsumer cons1 = sess.createConsumer(topic1);
-
- MessageConsumer cons2 = sess.createDurableSubscriber(topic1, "sub1");
-
- for (int i = 0; i < 150; i++)
- {
- prod.send(sess.createMessage());
- }
-
- SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
-
- assertEquals(100, ms.messageIds().size());
-
- assertEquals(100, getReferenceIds().size());
-
- assertEquals(50, getMessageIds().size());
-
- //Now we close the consumers
-
- cons1.close();
- cons2.close();
-
- assertEquals(100, ms.messageIds().size());
-
- assertEquals(50, getReferenceIds().size());
-
- assertEquals(50, getMessageIds().size());
-
- sess.unsubscribe("sub1");
-
- assertEquals(0, ms.messageIds().size());
-
- assertEquals(0, getReferenceIds().size());
-
- assertEquals(0, getMessageIds().size());
- }
- finally
+ conn.setClientID("wibble12345");
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess.createProducer(ourTopic);
+
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ MessageConsumer cons1 = sess.createConsumer(ourTopic);
+
+ MessageConsumer cons2 = sess.createDurableSubscriber(ourTopic, "sub1");
+
+ for (int i = 0; i < 150; i++)
{
- if (conn != null)
- {
- conn.close();
- }
+ prod.send(sess.createMessage());
}
+
+ SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
+
+ assertEquals(100, ms.messageIds().size());
+
+ assertEquals(100, getReferenceIds().size());
+
+ assertEquals(50, getMessageIds().size());
+
+ //Now we close the consumers
+
+ cons1.close();
+ cons2.close();
+
+ assertEquals(100, ms.messageIds().size());
+
+ assertEquals(50, getReferenceIds().size());
+
+ assertEquals(50, getMessageIds().size());
+
+ sess.unsubscribe("sub1");
+
+ assertEquals(0, ms.messageIds().size());
+
+ assertEquals(0, getReferenceIds().size());
+
+ assertEquals(0, getMessageIds().size());
+
+
+ conn.close();
}
+
/*
* Test that all messages on a temporary queue are removed on close
*/
@@ -194,52 +196,41 @@
ConnectionFactory cf2 = (ConnectionFactory)ic.lookup("/TempQueueConnectionFactory");
- Connection conn = null;
+ Connection conn = cf2.createConnection();
- try
- {
- conn = cf2.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- TemporaryQueue queue = sess.createTemporaryQueue();
-
- MessageProducer prod = sess.createProducer(queue);
-
- prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-
- conn.start();
-
- for (int i = 0; i < 150; i++)
- {
- prod.send(sess.createMessage());
- }
-
- SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
-
- assertEquals(100, ms.messageIds().size());
-
- assertEquals(50, getReferenceIds().size());
-
- assertEquals(50, getMessageIds().size());
-
- //Now we close the connection
-
- conn.close();
-
- assertEquals(0, ms.messageIds().size());
-
- assertEquals(0, getReferenceIds().size());
-
- assertEquals(0, getMessageIds().size());
- }
- finally
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ TemporaryQueue queue = sess.createTemporaryQueue();
+
+ MessageProducer prod = sess.createProducer(queue);
+
+ prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+ conn.start();
+
+ for (int i = 0; i < 150; i++)
{
- if (conn != null)
- {
- conn.close();
- }
- }
+ prod.send(sess.createMessage());
+ }
+
+ SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
+
+ assertEquals(100, ms.messageIds().size());
+
+ assertEquals(50, getReferenceIds().size());
+
+ assertEquals(50, getMessageIds().size());
+
+ //Now we close the connection
+
+ conn.close();
+
+ assertEquals(0, ms.messageIds().size());
+
+ assertEquals(0, getReferenceIds().size());
+
+ assertEquals(0, getMessageIds().size());
+
}
/*
@@ -256,56 +247,45 @@
ConnectionFactory cf2 = (ConnectionFactory)ic.lookup("/TempTopicConnectionFactory");
- Connection conn = null;
+ Connection conn = cf2.createConnection();
- try
- {
- conn = cf2.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- TemporaryTopic topic = sess.createTemporaryTopic();
-
- MessageProducer prod = sess.createProducer(topic);
-
- prod.setDeliveryMode(DeliveryMode.PERSISTENT);
-
- sess.createConsumer(topic);
-
- sess.createConsumer(topic);
-
- //Don't start the connection
-
- for (int i = 0; i < 150; i++)
- {
- prod.send(sess.createMessage());
- }
-
- SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
-
- assertEquals(100, ms.messageIds().size());
-
- assertEquals(100, getReferenceIds().size());
-
- assertEquals(50, getMessageIds().size());
-
- //Now we close the connection
-
- conn.close();
-
- assertEquals(0, ms.messageIds().size());
-
- assertEquals(0, getReferenceIds().size());
-
- assertEquals(0, getMessageIds().size());
- }
- finally
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ TemporaryTopic topic = sess.createTemporaryTopic();
+
+ MessageProducer prod = sess.createProducer(topic);
+
+ prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+ sess.createConsumer(topic);
+
+ sess.createConsumer(topic);
+
+ //Don't start the connection
+
+ for (int i = 0; i < 150; i++)
{
- if (conn != null)
- {
- conn.close();
- }
- }
+ prod.send(sess.createMessage());
+ }
+
+ SimpleMessageStore ms = (SimpleMessageStore)ServerManagement.getMessageStore();
+
+ assertEquals(100, ms.messageIds().size());
+
+ assertEquals(100, getReferenceIds().size());
+
+ assertEquals(50, getMessageIds().size());
+
+ //Now we close the connection
+
+ conn.close();
+
+ assertEquals(0, ms.messageIds().size());
+
+ assertEquals(0, getReferenceIds().size());
+
+ assertEquals(0, getMessageIds().size());
+
}
// Public --------------------------------------------------------
@@ -314,10 +294,9 @@
// Protected -----------------------------------------------------
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1358,8 +1358,9 @@
sessReceive.commit();
cons.close();
+
+ connReceive.close();
-
connReceive = cf.createConnection();
connReceive.start();
Modified: trunk/tests/src/org/jboss/test/messaging/jms/MiscellaneousTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/MiscellaneousTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/MiscellaneousTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -107,40 +107,6 @@
MessageProducer prod = s.createProducer(queue1);
Message m = s.createMessage();
prod.send(m);
- c.close();
-
- final Result result = new Result();
- Connection conn = cf.createConnection();
- s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- final MessageConsumer cons = s.createConsumer(queue1);
- cons.setMessageListener(new MessageListener()
- {
- public void onMessage(Message m)
- {
- // close the connection on the same thread that processed the message
- try
- {
- cons.close();
- result.setSuccess();
- }
- catch(Exception e)
- {
- result.setFailure(e);
- }
- }
- });
-
- conn.start();
-
- result.waitForResult();
-
- assertTrue(result.isSuccess());
- assertNull(result.getFailure());
-
- // make sure the acknowledgment made it back to the queue
-
- Thread.sleep(1000);
- assertRemainingMessages(0);
}
finally
{
@@ -149,6 +115,42 @@
c.close();
}
}
+
+ final Result result = new Result();
+ Connection conn = cf.createConnection();
+ Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ final MessageConsumer cons = s.createConsumer(queue1);
+ cons.setMessageListener(new MessageListener()
+ {
+ public void onMessage(Message m)
+ {
+ // close the connection on the same thread that processed the message
+ try
+ {
+ cons.close();
+ result.setSuccess();
+ }
+ catch(Exception e)
+ {
+ result.setFailure(e);
+ }
+ }
+ });
+
+ conn.start();
+
+ result.waitForResult();
+
+ assertTrue(result.isSuccess());
+ assertNull(result.getFailure());
+
+ // make sure the acknowledgment made it back to the queue
+
+ Thread.sleep(1000);
+ assertRemainingMessages(0);
+
+ conn.close();
+
}
/**
@@ -165,40 +167,6 @@
MessageProducer prod = s.createProducer(queue1);
Message m = s.createMessage();
prod.send(m);
- c.close();
-
- final Result result = new Result();
- Connection conn = cf.createConnection();
- final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = session.createConsumer(queue1);
- cons.setMessageListener(new MessageListener()
- {
- public void onMessage(Message m)
- {
- // close the connection on the same thread that processed the message
- try
- {
- session.close();
- result.setSuccess();
- }
- catch(Exception e)
- {
- result.setFailure(e);
- }
- }
- });
-
- conn.start();
-
- result.waitForResult();
-
- assertTrue(result.isSuccess());
- assertNull(result.getFailure());
-
- // make sure the acknowledgment made it back to the queue
-
- Thread.sleep(1000);
- assertRemainingMessages(0);
}
finally
{
@@ -207,6 +175,40 @@
c.close();
}
}
+
+ final Result result = new Result();
+ Connection conn = cf.createConnection();
+ final Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = session.createConsumer(queue1);
+ cons.setMessageListener(new MessageListener()
+ {
+ public void onMessage(Message m)
+ {
+ // close the connection on the same thread that processed the message
+ try
+ {
+ session.close();
+ result.setSuccess();
+ }
+ catch(Exception e)
+ {
+ result.setFailure(e);
+ }
+ }
+ });
+
+ conn.start();
+
+ result.waitForResult();
+
+ assertTrue(result.isSuccess());
+ assertNull(result.getFailure());
+
+ // make sure the acknowledgment made it back to the queue
+
+ Thread.sleep(1000);
+ assertRemainingMessages(0);
+ conn.close();
}
/**
@@ -223,43 +225,6 @@
MessageProducer prod = s.createProducer(queue1);
Message m = s.createMessage();
prod.send(m);
- c.close();
-
- final Result result = new Result();
- final Connection conn = cf.createConnection();
- s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = s.createConsumer(queue1);
- cons.setMessageListener(new MessageListener()
- {
- public void onMessage(Message m)
- {
- // close the connection on the same thread that processed the message
- try
- {
- log.debug("attempting close");
- conn.close();
- log.debug("conn closed");
- result.setSuccess();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- result.setFailure(e);
- }
- }
- });
-
- conn.start();
-
- result.waitForResult();
-
- assertTrue(result.isSuccess());
- assertNull(result.getFailure());
-
- // make sure the acknowledgment made it back to the queue
-
- Thread.sleep(1000);
- assertRemainingMessages(0);
}
finally
{
@@ -268,6 +233,43 @@
c.close();
}
}
+
+ final Result result = new Result();
+ final Connection conn = cf.createConnection();
+ Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = s.createConsumer(queue1);
+ cons.setMessageListener(new MessageListener()
+ {
+ public void onMessage(Message m)
+ {
+ // close the connection on the same thread that processed the message
+ try
+ {
+ conn.close();
+ result.setSuccess();
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ result.setFailure(e);
+ }
+ }
+ });
+
+ conn.start();
+
+ result.waitForResult();
+
+ assertTrue(result.isSuccess());
+ assertNull(result.getFailure());
+
+ // make sure the acknowledgment made it back to the queue
+
+ Thread.sleep(1000);
+ assertRemainingMessages(0);
+
+ conn.close();
+
}
// Test case for http://jira.jboss.com/jira/browse/JBMESSAGING-788
Modified: trunk/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -474,6 +474,10 @@
TextMessage rm = (TextMessage)ds.receive(3000);
assertNotNull(rm);
assertEquals("thebody", rm.getText());
+
+ ds.close();
+
+ s.unsubscribe("sub");
}
finally
{
@@ -558,6 +562,14 @@
}
assertEquals("message" + i, tm3.getText());
}
+
+ sub1.close();
+ sub2.close();
+ sub3.close();
+
+ sessConsume.unsubscribe("sub1");
+ sessConsume.unsubscribe("sub2");
+ sessConsume.unsubscribe("sub3");
}
finally
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/RemotingConnectionConfigurationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/RemotingConnectionConfigurationTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/RemotingConnectionConfigurationTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -36,7 +36,7 @@
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/ScheduledDeliveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ScheduledDeliveryTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ScheduledDeliveryTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,7 +22,6 @@
package org.jboss.test.messaging.jms;
import javax.jms.Connection;
-import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Session;
@@ -207,10 +206,6 @@
now2 = System.currentTimeMillis();
assertTrue(now2 - now >= 7000);
-
- Message m = cons.receive(1000);
-
- assertNull(m);
}
finally
{
@@ -349,11 +344,7 @@
assertTrue(time - now >= delay);
assertTrue(time - now < delay + 250);
- }
-
- TextMessage tm = (TextMessage)cons2.receive(1000);
-
- assertNull(tm);
+ }
}
finally
{
@@ -367,7 +358,7 @@
private void delayedRedeliveryDefaultOnRollback(long delay) throws Exception
{
Connection conn = null;
-
+
try
{
conn = cf.createConnection();
@@ -390,7 +381,7 @@
MessageConsumer cons = sess2.createConsumer(queue1);
conn.start();
-
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)cons.receive(500);
@@ -405,7 +396,7 @@
long now = System.currentTimeMillis();
sess2.rollback();
-
+
//This should redeliver with a delayed redelivery
for (int i = 0; i < NUM_MESSAGES; i++)
@@ -419,10 +410,8 @@
assertTrue(time - now >= delay);
assertTrue(time - now < delay + 250);
}
-
- TextMessage tm = (TextMessage)cons.receive(1000);
-
- assertNull(tm);
+
+ sess2.commit();
}
finally
{
@@ -562,10 +551,6 @@
assertTrue(now2 - now >= 7000);
- Message m = cons.receive(1000);
-
- assertNull(m);
-
if (tx)
{
sess.commit();
Modified: trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/SecurityTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -36,6 +36,7 @@
import javax.jms.XASession;
import javax.management.ObjectName;
import javax.transaction.xa.XAResource;
+
import org.jboss.jms.exception.MessagingXAException;
import org.jboss.jms.tx.MessagingXid;
import org.jboss.logging.Logger;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/TransactedSessionTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1159,9 +1159,10 @@
Message m = consumer.receive(500);
if (m == null) break;
count++;
+ m.acknowledge();
}
- assertEquals(NUM_MESSAGES * NUM_TX, count);
+ assertEquals(NUM_MESSAGES * NUM_TX, count);
}
finally
{
Modified: trunk/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -705,6 +705,9 @@
res.prepare(xid1);
+ conn1.close();
+ conn2.close();
+
conn1 = null;
conn2 = null;
@@ -973,6 +976,8 @@
res.prepare(xid1);
+ conn1.close();
+ conn2.close();
conn1 = null;
conn2 = null;
@@ -1533,6 +1538,10 @@
assertNull(m);
+ conn1.close();
+
+ conn2.close();
+
conn1 = null;
conn2 = null;
@@ -1836,6 +1845,10 @@
res1.prepare(xid1);
+ conn1.close();
+
+ conn2.close();
+
conn1 = null;
conn2 = null;
@@ -2321,7 +2334,8 @@
res.prepare(xid1);
-
+ conn1.close();
+ conn2.close();
conn1 = null;
conn2 = null;
@@ -2548,6 +2562,10 @@
//Now "crash" the server
+ conn1.close();
+
+ conn2.close();
+
conn1 = null;
conn2 = null;
@@ -2557,8 +2575,10 @@
ServerManagement.startServerPeer();
deployAndLookupAdministeredObjects();
+
+ conn1 = cf.createXAConnection();
- XAResource res = cf.createXAConnection().createXASession().getXAResource();
+ XAResource res = conn1.createXASession().getXAResource();
log.trace("Recovering");
@@ -2735,7 +2755,7 @@
res1.prepare(xid1);
res2.prepare(xid2);
-
+
//Now "crash" the server
ServerManagement.stopServerPeer();
@@ -2743,8 +2763,14 @@
ServerManagement.startServerPeer();
deployAndLookupAdministeredObjects();
+
+ conn1.close();
+
+ conn2.close();
+
+ conn1 = cf.createXAConnection();
- XAResource res = cf.createXAConnection().createXASession().getXAResource();
+ XAResource res = conn1.createXASession().getXAResource();
Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
assertEquals(2, xids.length);
@@ -2900,9 +2926,15 @@
ServerManagement.startServerPeer();
- deployAndLookupAdministeredObjects();
+ deployAndLookupAdministeredObjects();
+
+ conn1.close();
+
+ conn2.close();
+
+ conn1 = cf.createXAConnection();
- XAResource res = cf.createXAConnection().createXASession().getXAResource();
+ XAResource res = conn1.createXASession().getXAResource();
Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
assertEquals(2, xids.length);
@@ -3040,9 +3072,15 @@
ServerManagement.startServerPeer();
- deployAndLookupAdministeredObjects();
+ deployAndLookupAdministeredObjects();
+
+ conn1.close();
+
+ conn2.close();
+
+ conn1 = cf.createXAConnection();
- XAResource res = cf.createXAConnection().createXASession().getXAResource();
+ XAResource res = conn1.createXASession().getXAResource();
Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
assertEquals(2, xids.length);
@@ -3185,7 +3223,13 @@
deployAndLookupAdministeredObjects();
- XAResource res = cf.createXAConnection().createXASession().getXAResource();
+ conn1.close();
+
+ conn2.close();
+
+ conn1 = cf.createXAConnection();
+
+ XAResource res = conn1.createXASession().getXAResource();
Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
assertEquals(2, xids.length);
Modified: trunk/tests/src/org/jboss/test/messaging/jms/XAResourceRecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/XAResourceRecoveryTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/XAResourceRecoveryTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -26,7 +26,6 @@
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
-import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
@@ -46,8 +45,8 @@
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.TestJMSProviderAdaptor;
import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.tm.TxUtils;
import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
@@ -55,444 +54,434 @@
/**
*
* A XAResourceRecoveryTest
- *
+ *
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision: 1.1 $</tt>
- *
+ *
* $Id$
- *
+ *
*/
public class XAResourceRecoveryTest extends JMSTestCase
-{
+{
protected ServiceContainer sc;
protected JBossConnectionFactory cf1;
protected TransactionManager tm;
-
+
protected Transaction suspendedTx;
-
+
protected static Queue otherQueue;
-
+
public XAResourceRecoveryTest(String name)
{
super(name);
}
- protected void setUp() throws Exception
- {
- super.setUp();
-
- //Now start another remote server
- ServerManagement.start(1, "all", false);
-
- ResourceManagerFactory.instance.clear();
-
- //We need a local transaction and recovery manager
- //We must start this after the remote servers have been created or it won't
- //have deleted the database and the recovery manager may attempt to recover transactions
- sc = new ServiceContainer("all,-transaction,jbossjta");
+ protected void setUp() throws Exception
+ {
+ super.setUp();
- //Don't drop the tables again!
+ // Now start another remote server
+ ServerManagement.start(1, "all", false);
- sc.start(false);
-
- InitialContext localIc = new InitialContext(InVMInitialContextFactory.getJNDIEnvironment());
+ ResourceManagerFactory.instance.clear();
- tm = (TransactionManager)localIc.lookup(ServiceContainer.TRANSACTION_MANAGER_JNDI_NAME);
+ // We need a local transaction and recovery manager
+ // We must start this after the remote servers have been created or it
+ // won't
+ // have deleted the database and the recovery manager may attempt to
+ // recover transactions
+ sc = new ServiceContainer("all,-transaction,jbossjta");
- log.info("tm is " + tm.getClass().getName());
-
- assertTrue(tm instanceof TransactionManagerImple);
-
-
- ServerManagement.deployQueue("OtherQueue", 1);
-
- Hashtable props1 = ServerManagement.getJNDIEnvironment(1);
-
- InitialContext ic1 = new InitialContext(props1);
-
- cf1 = (JBossConnectionFactory)ic1.lookup("/XAConnectionFactory");
-
- otherQueue = (Queue)ic1.lookup("/queue/OtherQueue");
-
- checkOtherQueueEmpty();
-
- //Now install local JMSProviderAdaptor classes
-
- Properties p1 = new Properties();
- p1.putAll(ServerManagement.getJNDIEnvironment(1));
-
- JMSProviderAdapter targetAdaptor =
- new TestJMSProviderAdaptor(p1, "/XAConnectionFactory", "adaptor1");
-
- sc.installJMSProviderAdaptor("adaptor1", targetAdaptor);
-
- sc.startRecoveryManager();
-
- suspendedTx = tm.suspend();
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
- try
- {
- ServerManagement.undeployQueue("OtherQueue", 1);
- }
- catch (Exception ignore)
- {
- }
-
- if (TxUtils.isUncommitted(tm))
- {
- //roll it back
- try
- {
- tm.rollback();
- }
- catch (Throwable ignore)
- {
- //The connection will probably be closed so this may well throw an exception
- }
- }
- if (tm.getTransaction() != null)
- {
- Transaction tx = tm.suspend();
- if (tx != null)
- log.warn("Transaction still associated with thread " + tx + " at status " + TxUtils.getStatusAsString(tx.getStatus()));
- }
+ // Don't drop the tables again!
- if (suspendedTx != null)
- {
- tm.resume(suspendedTx);
- }
-
- sc.uninstallJMSProviderAdaptor("adaptor1");
-
- sc.stopRecoveryManager();
-
- sc.stop();
- }
-
- public void testRecoveryOnSend() throws Exception
- {
- XAConnection conn0 = null;
-
- XAConnection conn1 = null;
-
- Connection conn2 = null;
-
- Connection conn3 = null;
-
- try
- {
- conn0 = cf.createXAConnection();
-
- XASession sess0 = conn0.createXASession();
-
- MessageProducer prod0 = sess0.createProducer(queue1);
-
- XAResource res0 = sess0.getXAResource();
-
-
- conn1 = cf1.createXAConnection();
-
- XASession sess1 = conn1.createXASession();
-
- MessageProducer prod1 = sess1.createProducer(otherQueue);
-
- XAResource res1 = sess1.getXAResource();
-
-
- tm.begin();
-
- Transaction tx = tm.getTransaction();
-
- tx.enlistResource(res0);
-
- tx.enlistResource(res1);
-
-
- TextMessage tm0 = sess0.createTextMessage("message0");
-
- prod0.send(tm0);
-
-
- TextMessage tm1 = sess1.createTextMessage("message1");
-
- prod1.send(tm1);
-
- // Poison server 1 so it crashes on commit of dest but after prepare
-
- //This means the transaction branch on source will get commmitted
- //but the branch on dest won't be - it will remain prepared
- //This corresponds to a HeuristicMixedException
-
- ServerManagement.poisonTheServer(1, PoisonInterceptor.TYPE_2PC_COMMIT);
-
- log.info("Poisoned server");
-
- tx.delistResource(res0, XAResource.TMSUCCESS);
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
-
- tx.commit();
-
- conn0.close();
-
- conn1.close();
-
- //Now restart the server
-
- log.info("Restarting server");
-
- ServerManagement.start(1, "all", false);
-
- log.info("Restarted server");
-
- ServerManagement.deployQueue("OtherQueue", 1);
-
- Hashtable props1 = ServerManagement.getJNDIEnvironment(1);
-
- InitialContext ic1 = new InitialContext(props1);
-
- cf1 = (JBossConnectionFactory)ic1.lookup("/XAConnectionFactory");
-
- otherQueue = (Queue)ic1.lookup("/queue/OtherQueue");
-
- conn2 = cf.createConnection();
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons2 = sess2.createConsumer(queue1);
-
- conn2.start();
-
- TextMessage rm0 = (TextMessage)cons2.receive(2000);
-
- assertNotNull(rm0);
-
- assertEquals(tm0.getText(), rm0.getText());
-
- checkEmpty(queue1);
-
- //Now even though the commit on the second server failed since the server was dead, the recovery manager should kick in
- //eventually and recover it.
-
- conn3 = cf1.createConnection();
-
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons3 = sess3.createConsumer(otherQueue);
-
- conn3.start();
-
- log.info("**** now waiting for recovery to kick in");
- TextMessage rm1 = (TextMessage)cons3.receive(60000);
-
- assertNotNull(rm1);
-
- assertEquals(tm1.getText(), rm1.getText());
-
- checkOtherQueueEmpty();
- }
- finally
- {
- if (conn0 != null)
- {
- conn0.close();
- }
- if (conn1 != null)
- {
- conn1.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- if (conn3 != null)
- {
- conn3.close();
- }
- }
- }
-
-
- public void testRecoveryOnAck() throws Exception
- {
- XAConnection conn0 = null;
+ sc.start(false);
- XAConnection conn1 = null;
+ InitialContext localIc = new InitialContext(InVMInitialContextFactory
+ .getJNDIEnvironment());
- Connection conn2 = null;
+ tm = (TransactionManager) localIc
+ .lookup(ServiceContainer.TRANSACTION_MANAGER_JNDI_NAME);
- Connection conn3 = null;
+ assertTrue(tm instanceof TransactionManagerImple);
- try
- {
- conn0 = cf.createXAConnection();
+ ServerManagement.deployQueue("OtherQueue", 1);
- XASession sess0 = conn0.createXASession();
+ Hashtable props1 = ServerManagement.getJNDIEnvironment(1);
- MessageProducer prod0 = sess0.createProducer(queue1);
+ InitialContext ic1 = new InitialContext(props1);
- XAResource res0 = sess0.getXAResource();
+ cf1 = (JBossConnectionFactory) ic1.lookup("/XAConnectionFactory");
+ otherQueue = (Queue) ic1.lookup("/queue/OtherQueue");
- conn1 = cf1.createXAConnection();
+ checkOtherQueueEmpty();
- XASession sess1 = conn1.createXASession();
+ // Now install local JMSProviderAdaptor classes
- MessageConsumer cons1 = sess1.createConsumer(otherQueue);
+ Properties p1 = new Properties();
+ p1.putAll(ServerManagement.getJNDIEnvironment(1));
- XAResource res1 = sess1.getXAResource();
+ JMSProviderAdapter targetAdaptor = new TestJMSProviderAdaptor(p1,
+ "/XAConnectionFactory", "adaptor1");
- conn1.start();
+ sc.installJMSProviderAdaptor("adaptor1", targetAdaptor);
- //first send a few messages to server 1
+ sc.startRecoveryManager();
- conn2 = cf1.createConnection();
+ suspendedTx = tm.suspend();
+ }
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ ServerManagement.undeployQueue("OtherQueue", 1);
+ } catch (Exception ignore)
+ {
+ }
- MessageProducer prod2 = sess2.createProducer(otherQueue);
+ if (TxUtils.isUncommitted(tm))
+ {
+ // roll it back
+ try
+ {
+ tm.rollback();
+ } catch (Throwable ignore)
+ {
+ // The connection will probably be closed so this may well throw an
+ // exception
+ }
+ }
+ if (tm.getTransaction() != null)
+ {
+ Transaction tx = tm.suspend();
+ if (tx != null)
+ log.warn("Transaction still associated with thread " + tx
+ + " at status " + TxUtils.getStatusAsString(tx.getStatus()));
+ }
- TextMessage tm1 = sess1.createTextMessage("message1");
+ if (suspendedTx != null)
+ {
+ tm.resume(suspendedTx);
+ }
- prod2.send(tm1);
+ sc.uninstallJMSProviderAdaptor("adaptor1");
- TextMessage tm2 = sess1.createTextMessage("message2");
+ sc.stopRecoveryManager();
- prod2.send(tm2);
+ sc.stop();
- conn2.close();
+ // We explicitly clear the resource manager factory since the recovery
+ // manager will keep a connection open, and
+ // otherewise it will fail
- tm.begin();
+ ResourceManagerFactory.instance.clear();
- Transaction tx = tm.getTransaction();
+ super.tearDown();
+ }
- tx.enlistResource(res0);
+ public void testRecoveryOnSend() throws Exception
+ {
+ XAConnection conn0 = null;
- tx.enlistResource(res1);
+ XAConnection conn1 = null;
+ Connection conn2 = null;
- TextMessage tm0 = sess0.createTextMessage("message0");
+ Connection conn3 = null;
- prod0.send(tm0);
+ try
+ {
+ conn0 = cf.createXAConnection();
- //Consume one of the messages on dest
+ XASession sess0 = conn0.createXASession();
- TextMessage rm1 = (TextMessage)cons1.receive(1000);
+ MessageProducer prod0 = sess0.createProducer(queue1);
- assertNotNull(rm1);
+ XAResource res0 = sess0.getXAResource();
- assertEquals(tm1.getText(), rm1.getText());
+ conn1 = cf1.createXAConnection();
- // Poison server 1 so it crashes on commit of dest but after prepare
+ XASession sess1 = conn1.createXASession();
- //This means the transaction branch on source will get commmitted
- //but the branch on dest won't be - it will remain prepared
- //This corresponds to a HeuristicMixedException
+ MessageProducer prod1 = sess1.createProducer(otherQueue);
- ServerManagement.poisonTheServer(1, PoisonInterceptor.TYPE_2PC_COMMIT);
+ XAResource res1 = sess1.getXAResource();
- log.info("Poisoned server");
+ tm.begin();
- tx.delistResource(res0, XAResource.TMSUCCESS);
+ Transaction tx = tm.getTransaction();
- tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.enlistResource(res0);
- tx.commit();
+ tx.enlistResource(res1);
- conn0.close();
+ TextMessage tm0 = sess0.createTextMessage("message0");
- conn1.close();
+ prod0.send(tm0);
- //Now restart the server
+ TextMessage tm1 = sess1.createTextMessage("message1");
- log.info("Restarting server");
+ prod1.send(tm1);
- ServerManagement.start(1, "all", false);
+ // Poison server 1 so it crashes on commit of dest but after prepare
- log.info("Restarted server");
+ // This means the transaction branch on source will get commmitted
+ // but the branch on dest won't be - it will remain prepared
+ // This corresponds to a HeuristicMixedException
- ServerManagement.deployQueue("OtherQueue", 1);
+ ServerManagement.poisonTheServer(1, PoisonInterceptor.TYPE_2PC_COMMIT);
- Hashtable props1 = ServerManagement.getJNDIEnvironment(1);
+ tx.delistResource(res0, XAResource.TMSUCCESS);
- InitialContext ic1 = new InitialContext(props1);
+ tx.delistResource(res1, XAResource.TMSUCCESS);
- cf1 = (JBossConnectionFactory)ic1.lookup("/XAConnectionFactory");
+ tx.commit();
- otherQueue = (Queue)ic1.lookup("/queue/OtherQueue");
+ conn0.close();
+ conn1.close();
- conn2 = cf.createConnection();
+ // Now restart the server
- sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ ServerManagement.start(1, "all", false);
- MessageConsumer cons2 = sess2.createConsumer(queue1);
+ ServerManagement.deployQueue("OtherQueue", 1);
- conn2.start();
+ Hashtable props1 = ServerManagement.getJNDIEnvironment(1);
- TextMessage rm0 = (TextMessage)cons2.receive(2000);
+ InitialContext ic1 = new InitialContext(props1);
- assertNotNull(rm0);
+ cf1 = (JBossConnectionFactory) ic1.lookup("/XAConnectionFactory");
- assertEquals(tm0.getText(), rm0.getText());
+ otherQueue = (Queue) ic1.lookup("/queue/OtherQueue");
- checkEmpty(queue1);
+ conn2 = cf.createConnection();
- //Now even though the commit on the second server failed since the server was dead, the recovery manager should kick in
- //eventually and recover it.
+ Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- conn3 = ((ConnectionFactory)cf1).createConnection();
+ MessageConsumer cons2 = sess2.createConsumer(queue1);
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ conn2.start();
- MessageConsumer cons3 = sess3.createConsumer(otherQueue);
+ TextMessage rm0 = (TextMessage) cons2.receive(2000);
- conn3.start();
+ assertNotNull(rm0);
- log.info("***** waiting for recovery to kick in");
- TextMessage rm2 = (TextMessage)cons3.receive(60000);
+ assertEquals(tm0.getText(), rm0.getText());
- assertNotNull(rm2);
+ checkEmpty(queue1);
- //tm1 should have been acked on recovery
+ // Now even though the commit on the second server failed since the
+ // server was dead, the recovery manager should kick in
+ // eventually and recover it.
- assertEquals(tm2.getText(), rm2.getText());
+ conn3 = cf1.createConnection();
- checkOtherQueueEmpty();
- }
- finally
- {
- if (conn0 != null)
- {
- conn0.close();
- }
- if (conn1 != null)
- {
- conn1.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- if (conn3 != null)
- {
- conn3.close();
- }
- }
- }
-
- private void checkOtherQueueEmpty() throws Exception
- {
- ObjectName destObjectName = new ObjectName("jboss.messaging.destination:service=Queue,name=OtherQueue");
-
- Integer messageCount = (Integer)ServerManagement.getServer(1).getAttribute(destObjectName, "MessageCount");
-
- assertEquals(0, messageCount.intValue());
- }
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons3 = sess3.createConsumer(otherQueue);
+
+ conn3.start();
+
+ TextMessage rm1 = (TextMessage) cons3.receive(60000);
+
+ assertNotNull(rm1);
+
+ assertEquals(tm1.getText(), rm1.getText());
+
+ checkOtherQueueEmpty();
+ }
+ finally
+ {
+ if (conn0 != null)
+ {
+ conn0.close();
+ }
+ if (conn1 != null)
+ {
+ conn1.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
+ }
+ }
+
+ public void testRecoveryOnAck() throws Exception
+ {
+ XAConnection conn0 = null;
+
+ XAConnection conn1 = null;
+
+ Connection conn2 = null;
+
+ Connection conn3 = null;
+
+ try
+ {
+ conn0 = cf.createXAConnection();
+
+ XASession sess0 = conn0.createXASession();
+
+ MessageProducer prod0 = sess0.createProducer(queue1);
+
+ XAResource res0 = sess0.getXAResource();
+
+ conn1 = cf1.createXAConnection();
+
+ XASession sess1 = conn1.createXASession();
+
+ MessageConsumer cons1 = sess1.createConsumer(otherQueue);
+
+ XAResource res1 = sess1.getXAResource();
+
+ conn1.start();
+
+ // first send a few messages to server 1
+
+ conn2 = cf1.createConnection();
+
+ Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod2 = sess2.createProducer(otherQueue);
+
+ TextMessage tm1 = sess1.createTextMessage("message1");
+
+ prod2.send(tm1);
+
+ TextMessage tm2 = sess1.createTextMessage("message2");
+
+ prod2.send(tm2);
+
+ conn2.close();
+
+ tm.begin();
+
+ Transaction tx = tm.getTransaction();
+
+ tx.enlistResource(res0);
+
+ tx.enlistResource(res1);
+
+ TextMessage tm0 = sess0.createTextMessage("message0");
+
+ prod0.send(tm0);
+
+ // Consume one of the messages on dest
+
+ TextMessage rm1 = (TextMessage) cons1.receive(1000);
+
+ assertNotNull(rm1);
+
+ assertEquals(tm1.getText(), rm1.getText());
+
+ // Poison server 1 so it crashes on commit of dest but after prepare
+
+ // This means the transaction branch on source will get commmitted
+ // but the branch on dest won't be - it will remain prepared
+ // This corresponds to a HeuristicMixedException
+
+ ServerManagement.poisonTheServer(1, PoisonInterceptor.TYPE_2PC_COMMIT);
+
+ tx.delistResource(res0, XAResource.TMSUCCESS);
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+
+ tx.commit();
+
+ conn0.close();
+
+ conn1.close();
+
+ // Now restart the server
+
+ ServerManagement.start(1, "all", false);
+
+ ServerManagement.deployQueue("OtherQueue", 1);
+
+ Hashtable props1 = ServerManagement.getJNDIEnvironment(1);
+
+ InitialContext ic1 = new InitialContext(props1);
+
+ cf1 = (JBossConnectionFactory) ic1.lookup("/XAConnectionFactory");
+
+ otherQueue = (Queue) ic1.lookup("/queue/OtherQueue");
+
+ conn2 = cf.createConnection();
+
+ sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons2 = sess2.createConsumer(queue1);
+
+ conn2.start();
+
+ TextMessage rm0 = (TextMessage) cons2.receive(2000);
+
+ assertNotNull(rm0);
+
+ assertEquals(tm0.getText(), rm0.getText());
+
+ checkEmpty(queue1);
+
+ // Now even though the commit on the second server failed since the
+ // server was dead, the recovery manager should kick in
+ // eventually and recover it.
+
+ conn3 = ((ConnectionFactory) cf1).createConnection();
+
+ Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons3 = sess3.createConsumer(otherQueue);
+
+ conn3.start();
+
+ TextMessage rm2 = (TextMessage) cons3.receive(60000);
+
+ assertNotNull(rm2);
+
+ // tm1 should have been acked on recovery
+
+ assertEquals(tm2.getText(), rm2.getText());
+
+ checkOtherQueueEmpty();
+ }
+ finally
+ {
+ if (conn0 != null)
+ {
+ conn0.close();
+ }
+ if (conn1 != null)
+ {
+ conn1.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ if (conn3 != null)
+ {
+ conn3.close();
+ }
+ }
+ }
+
+ private void checkOtherQueueEmpty() throws Exception
+ {
+ ObjectName destObjectName = new ObjectName(
+ "jboss.messaging.destination:service=Queue,name=OtherQueue");
+
+ Integer messageCount = (Integer) ServerManagement.getServer(1)
+ .getAttribute(destObjectName, "MessageCount");
+
+ assertEquals(0, messageCount.intValue());
+ }
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/XATestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/XATestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/XATestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -58,8 +58,8 @@
import org.jboss.jms.tx.ResourceManagerFactory;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.tm.TransactionManagerLocator;
import org.jboss.tm.TxUtils;
@@ -1134,7 +1134,7 @@
conn1 = cf.createXAConnection();
- XAResource res = cf.createXAConnection().createXASession().getXAResource();
+ XAResource res = conn1.createXASession().getXAResource();
Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
assertEquals(1, xids.length);
@@ -2992,6 +2992,7 @@
tm.commit();
//verify that no messages are available
+ conn2.close();
conn2 = cf.createConnection();
Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn2.start();
@@ -3078,6 +3079,7 @@
tm.rollback();
//verify that second message is available
+ conn2.close();
conn2 = cf.createConnection();
Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
conn2.start();
Modified: trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/bridge/BridgeTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -43,7 +43,7 @@
import org.jboss.logging.Logger;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterLeakTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -27,19 +27,18 @@
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.jms.MessageProducer;
+import org.jboss.jms.client.FailoverValve2;
import org.jboss.jms.client.JBossConnection;
import org.jboss.jms.client.JBossMessageProducer;
-import org.jboss.jms.client.FailoverValve2;
import org.jboss.jms.client.container.ClientConsumer;
-import org.jboss.jms.client.delegate.DelegateSupport;
import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.jms.client.delegate.DelegateSupport;
import org.jboss.jms.client.state.ConnectionState;
import org.jboss.jms.client.state.ProducerState;
-import org.jboss.jms.client.state.SessionState;
import org.jboss.profiler.jvmti.InventoryDataPoint;
import org.jboss.profiler.jvmti.JVMTIInterface;
import org.jboss.test.messaging.tools.ServerManagement;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusterViewUpdateTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,14 +22,15 @@
package org.jboss.test.messaging.jms.clustering;
-import org.jboss.test.messaging.tools.ServerManagement;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Session;
+
import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.jms.client.state.ConnectionState;
import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.ConnectionFactory;
+import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.test.messaging.tools.ServerManagement;
/**
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringAspectInternalTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringAspectInternalTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringAspectInternalTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,11 +22,12 @@
package org.jboss.test.messaging.jms.clustering;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.jms.client.container.ClusteringAspect;
+import java.lang.reflect.Method;
import java.util.Map;
-import java.lang.reflect.Method;
+import org.jboss.jms.client.container.ClusteringAspect;
+import org.jboss.test.messaging.MessagingTestCase;
+
/**
* This class tests internal methods of ClusteringAspect.
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ClusteringTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -41,7 +41,7 @@
import org.jboss.jms.client.state.ConnectionState;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueDontUseXATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueDontUseXATest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueDontUseXATest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -23,7 +23,7 @@
import javax.management.ObjectName;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueUseXATest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueUseXATest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/DistributedQueueUseXATest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -23,7 +23,7 @@
import javax.management.ObjectName;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/GroupManagementTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,10 +6,12 @@
*/
package org.jboss.test.messaging.jms.clustering;
+import java.util.Set;
+
+import javax.management.ObjectName;
+
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import javax.management.ObjectName;
-import java.util.Set;
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LargeClusterTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,21 +6,21 @@
*/
package org.jboss.test.messaging.jms.clustering;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.jms.client.JBossConnection;
-import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import java.util.Set;
import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageListener;
import javax.jms.Session;
-import javax.jms.MessageListener;
-import javax.jms.Message;
import javax.jms.TextMessage;
import javax.management.ObjectName;
+import org.jboss.jms.client.JBossConnection;
+import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.test.messaging.tools.ServerManagement;
+
import EDU.oswego.cs.dl.util.concurrent.Slot;
-import java.util.Set;
-
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/LoadBalancingTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,22 +6,22 @@
*/
package org.jboss.test.messaging.jms.clustering;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-import org.jboss.test.messaging.MessagingTestCase;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
import org.jboss.jms.client.JBossConnection;
import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.DelegateSupport;
import org.jboss.jms.client.plugin.RandomLoadBalancingPolicy;
import org.jboss.jms.client.plugin.RoundRobinLoadBalancingPolicy;
-import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
-import org.jboss.jms.client.delegate.DelegateSupport;
+import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.naming.InitialContext;
-import javax.management.ObjectName;
-
/**
* This test DOESN'T extend ClusteringTestBase because I want to have control over first invocations
* to the server (which are outside of of my control if I use ClusteringTestBase).
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/MultiThreadFailoverTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Iterator;
+
import javax.jms.Connection;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
@@ -32,6 +33,7 @@
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
+
import org.jboss.jms.client.JBossConnection;
import org.jboss.jms.client.delegate.ClientConnectionDelegate;
import org.jboss.logging.Logger;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/NoFailoverTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,17 +22,18 @@
package org.jboss.test.messaging.jms.clustering;
-import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
-import org.jboss.test.messaging.tools.ServerManagement;
-import javax.jms.ConnectionFactory;
import javax.jms.Connection;
+import javax.jms.ExceptionListener;
import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
import javax.jms.Session;
-import javax.jms.MessageProducer;
-import javax.jms.MessageConsumer;
import javax.jms.TextMessage;
-import javax.jms.ExceptionListener;
+
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import org.jboss.test.messaging.tools.ServerManagement;
+
import EDU.oswego.cs.dl.util.concurrent.Latch;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/PreserveOrderingTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -31,7 +31,7 @@
import javax.management.ObjectName;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/ServerManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/ServerManagementTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/ServerManagementTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,12 +6,12 @@
*/
package org.jboss.test.messaging.jms.clustering;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import javax.naming.InitialContext;
-import javax.management.ObjectName;
-
/**
* Test spawning functionality of the ServerManagment. Used mostly in a clustered testing
* environment.
Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/XAFailoverTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,6 +6,8 @@
*/
package org.jboss.test.messaging.jms.clustering;
+import java.util.HashSet;
+
import javax.jms.Connection;
import javax.jms.Message;
import javax.jms.MessageConsumer;
@@ -26,9 +28,8 @@
import org.jboss.jms.client.JBossConnection;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
-import java.util.HashSet;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashLargeLeaseTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashLargeLeaseTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashLargeLeaseTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,14 +24,15 @@
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.naming.InitialContext;
+
import org.jboss.jms.server.ConnectionManager;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
-import org.jboss.test.messaging.tools.jmx.rmi.Server;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.Server;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashNegativeLeaseTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashNegativeLeaseTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashNegativeLeaseTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,14 +24,15 @@
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.naming.InitialContext;
+
import org.jboss.jms.server.ConnectionManager;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
-import org.jboss.test.messaging.tools.jmx.rmi.Server;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.Server;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,14 +24,15 @@
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.naming.InitialContext;
+
import org.jboss.jms.server.ConnectionManager;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
-import org.jboss.test.messaging.tools.jmx.rmi.Server;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.Server;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTwoConnectionsTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTwoConnectionsTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashTwoConnectionsTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,15 +24,16 @@
import javax.jms.ConnectionFactory;
import javax.jms.Topic;
import javax.naming.InitialContext;
+
import org.jboss.jms.server.ConnectionManager;
import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
-import org.jboss.test.messaging.tools.jmx.rmi.Server;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.Server;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashZeroLeaseTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashZeroLeaseTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/ClientCrashZeroLeaseTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,14 +24,15 @@
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
import javax.naming.InitialContext;
+
import org.jboss.jms.server.ConnectionManager;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
-import org.jboss.test.messaging.tools.jmx.rmi.Server;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.Server;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateClientOnServerCommand.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateClientOnServerCommand.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateClientOnServerCommand.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -32,7 +32,7 @@
import javax.jms.Session;
import org.jboss.jms.client.JBossConnection;
-import org.jboss.test.messaging.tools.jmx.rmi.Command;
+import org.jboss.test.messaging.tools.container.Command;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateHangingConsumerCommand.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateHangingConsumerCommand.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateHangingConsumerCommand.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -30,7 +30,7 @@
import javax.jms.Session;
import org.jboss.jms.client.JBossConnection;
-import org.jboss.test.messaging.tools.jmx.rmi.Command;
+import org.jboss.test.messaging.tools.container.Command;
/**
* @author <a href="tim.fox at jboss.com">Tim Fox</a>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/crash/CreateTwoClientOnServerCommand.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -29,7 +29,7 @@
import javax.jms.Topic;
import org.jboss.jms.client.JBossConnection;
-import org.jboss.test.messaging.tools.jmx.rmi.Command;
+import org.jboss.test.messaging.tools.container.Command;
/**
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualPagingSoakTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -26,13 +26,13 @@
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;
-import javax.jms.JMSException;
import javax.naming.Context;
import javax.naming.InitialContext;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualQueueSoakTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualQueueSoakTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/manual/ManualQueueSoakTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,24 +22,13 @@
package org.jboss.test.messaging.jms.manual;
-import org.jboss.test.messaging.jms.stress.SeveralClientsStressTest;
-import org.jboss.logging.Logger;
import java.util.Properties;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.TimeUnit;
+
import javax.naming.Context;
import javax.naming.InitialContext;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.Queue;
-import javax.jms.MessageProducer;
-import javax.jms.MessageConsumer;
-import javax.jms.Message;
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
+import org.jboss.test.messaging.jms.stress.SeveralClientsStressTest;
+
/**
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
* @version <tt>$Revision$</tt>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/JMSDeliveryModeHeaderTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/JMSDeliveryModeHeaderTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/JMSDeliveryModeHeaderTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,8 +21,8 @@
*/
package org.jboss.test.messaging.jms.message;
+import javax.jms.DeliveryMode;
import javax.jms.Message;
-import javax.jms.DeliveryMode;
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/JMSXDeliveryCountTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/JMSXDeliveryCountTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/JMSXDeliveryCountTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -39,7 +39,7 @@
import org.jboss.test.messaging.jms.JMSTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.tm.TransactionManagerLocator;
/**
@@ -490,7 +490,7 @@
tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);
- tx.rollback();
+ mgr.rollback();
mgr.begin();
@@ -514,7 +514,7 @@
tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);
- tx.rollback();
+ mgr.rollback();
mgr.begin();
@@ -538,7 +538,7 @@
tx.delistResource(consumerSess.getXAResource(), XAResource.TMSUCCESS);
- tx.rollback();
+ mgr.rollback();
//Must close consumer first
@@ -583,7 +583,7 @@
{
try
{
- tx.commit();
+ mgr.commit();
}
catch (Exception ignore)
{
@@ -605,10 +605,6 @@
{
}
}
-
- // ***********************
- // * REMOVE THIS WHEN ABOVE TEST PASSES
- removeAllMessages(queue1.getQueueName(), true, 0);
}
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MapMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MapMessageTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MapMessageTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,8 +22,8 @@
package org.jboss.test.messaging.jms.message;
+import javax.jms.JMSException;
import javax.jms.MapMessage;
-import javax.jms.JMSException;
import javax.jms.Message;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MessageBodyTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessageBodyTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessageBodyTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -94,10 +94,10 @@
public void tearDown() throws Exception
{
- super.tearDown();
-
producerConnection.close();
consumerConnection.close();
+
+ super.tearDown();
}
public void testSMBodyReadable() throws Exception
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -469,10 +469,11 @@
public void tearDown() throws Exception
{
+ producerConnection.close();
+ consumerConnection.close();
+
super.tearDown();
- producerConnection.close();
- consumerConnection.close();
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MessagePropertyConversionTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessagePropertyConversionTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessagePropertyConversionTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,17 +22,13 @@
package org.jboss.test.messaging.jms.message;
import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageFormatException;
import javax.jms.MessageProducer;
import javax.jms.Session;
-import javax.naming.InitialContext;
import org.jboss.test.messaging.jms.JMSTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
/**
*
@@ -79,11 +75,11 @@
}
public void tearDown() throws Exception
- {
- super.tearDown();
-
+ {
producerConnection.close();
consumerConnection.close();
+
+ super.tearDown();
}
public void testBooleanConversion() throws Exception
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MessageTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessageTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessageTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -79,9 +79,9 @@
public void tearDown() throws Exception
{
- super.tearDown();
+ conn.close();
- conn.close();
+ super.tearDown();
}
public void testNonPersistentSend() throws Exception
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/ObjectMessageTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,17 +21,17 @@
*/
package org.jboss.test.messaging.jms.message;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.ObjectMessage;
-import javax.jms.DeliveryMode;
-
+import java.io.File;
import java.net.URL;
import java.net.URLClassLoader;
-import java.io.File;
import java.util.ArrayList;
import java.util.StringTokenizer;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+
/**
* A test that sends/receives object messages to the JMS provider and verifies their integrity.
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,16 +21,16 @@
*/
package org.jboss.test.messaging.jms.message;
-import javax.jms.Message;
-import javax.jms.JMSException;
-import javax.jms.Destination;
-import javax.jms.DeliveryMode;
-
+import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
-import java.util.Collections;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+
/**
* Foreign message implementation. Used for testing only.
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSTextMessage.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSTextMessage.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSTextMessage.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,8 +21,8 @@
*/
package org.jboss.test.messaging.jms.message;
+import javax.jms.JMSException;
import javax.jms.TextMessage;
-import javax.jms.JMSException;
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/TextMessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/TextMessageTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/TextMessageTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,9 +22,9 @@
package org.jboss.test.messaging.jms.message;
-import javax.jms.TextMessage;
import javax.jms.JMSException;
import javax.jms.Message;
+import javax.jms.TextMessage;
/**
* A test that sends/receives text messages to the JMS provider and verifies their integrity.
Modified: trunk/tests/src/org/jboss/test/messaging/jms/selector/SelectorParserTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/selector/SelectorParserTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/selector/SelectorParserTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,10 +24,10 @@
import java.io.ByteArrayInputStream;
import java.util.HashMap;
-import org.jboss.jms.server.selector.SelectorParser;
import org.jboss.jms.server.selector.ISelectorParser;
import org.jboss.jms.server.selector.Identifier;
import org.jboss.jms.server.selector.Operator;
+import org.jboss.jms.server.selector.SelectorParser;
import org.jboss.test.messaging.MessagingTestCase;
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/DestinationManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/DestinationManagerTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/DestinationManagerTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -66,9 +66,11 @@
}
super.setUp();
- ServerManagement.start("all");
+ ServerManagement.stop();
+ ServerManagement.start("all");
+
initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
ServerManagement.undeployQueue("testQueue");
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerConfigurationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerConfigurationTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerConfigurationTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -25,9 +25,10 @@
import javax.management.RuntimeMBeanException;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
* Test ServerPeer configuration.
@@ -54,6 +55,15 @@
// Public --------------------------------------------------------
+ public void setUp() throws Exception
+ {
+ ServerManagement.stop();
+ }
+
+ public void tearDown() throws Exception
+ {
+ }
+
public void testServerPeerID() throws Exception
{
testStartupOnlyAttribute("ServerPeerID", new Integer(5), new Integer(10));
@@ -79,13 +89,16 @@
try
{
server.start("all", overrides, false, true);
- server.stop();
fail("Should have thrown an exception when setting ServerPeerID to a negative value");
}
catch (RuntimeMBeanException rmbe)
{
assertTrue(rmbe.getCause() instanceof IllegalArgumentException);
}
+ finally
+ {
+ server.stop();
+ }
}
// Package protected ---------------------------------------------
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -84,15 +84,19 @@
}
super.setUp();
- ServerManagement.start("all");
+ ServerManagement.stop();
+ ServerManagement.start("all");
+
initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
}
public void tearDown() throws Exception
{
super.tearDown();
+
+ ServerManagement.stop();
}
public void testNonContextAlreadyBound() throws Exception
@@ -135,7 +139,6 @@
{
ServerManagement.undeployQueue("SomeQueue");
ServerManagement.undeployTopic("SomeTopic");
- ServerManagement.stopServerPeer();
}
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/connectionfactory/ConnectionFactoryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/connectionfactory/ConnectionFactoryTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/connectionfactory/ConnectionFactoryTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -23,19 +23,17 @@
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
-import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.Session;
import javax.jms.TopicConnectionFactory;
import javax.jms.XAConnectionFactory;
import javax.management.ObjectName;
-import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import org.jboss.jms.client.JBossMessageConsumer;
import org.jboss.jms.client.delegate.ClientConsumerDelegate;
import org.jboss.jms.client.state.ConsumerState;
-import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.jms.JMSTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
/**
@@ -46,7 +44,7 @@
*
* $Id$
*/
-public class ConnectionFactoryTest extends MessagingTestCase
+public class ConnectionFactoryTest extends JMSTestCase
{
// Constants -----------------------------------------------------
@@ -54,8 +52,6 @@
// Attributes ----------------------------------------------------
- protected InitialContext initialContext;
-
// Constructors --------------------------------------------------
public ConnectionFactoryTest(String name)
@@ -64,55 +60,33 @@
}
// Public --------------------------------------------------------
-
- public void setUp() throws Exception
- {
- if (ServerManagement.isRemote())
- {
- fail("this test is not supposed to run in a remote configuration!");
- }
-
- super.setUp();
- ServerManagement.start("all");
-
- initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- log.debug("setup done");
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
-
- initialContext.close();
- }
-
+
public void testDefaultConnectionFactory() throws Exception
{
// These should be configured by default in connection-factories-service.xml
- ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
log.debug("ConnectionFactory: " + cf);
- XAConnectionFactory xacf = (XAConnectionFactory)initialContext.lookup("/XAConnectionFactory");
+ XAConnectionFactory xacf = (XAConnectionFactory)ic.lookup("/XAConnectionFactory");
log.debug("ConnectionFactory: " + xacf);
- cf = (ConnectionFactory)initialContext.lookup("java:/ConnectionFactory");
+ cf = (ConnectionFactory)ic.lookup("java:/ConnectionFactory");
log.debug("ConnectionFactory: " + cf);
- xacf = (XAConnectionFactory)initialContext.lookup("java:/XAConnectionFactory");
+ xacf = (XAConnectionFactory)ic.lookup("java:/XAConnectionFactory");
log.debug("ConnectionFactory: " + xacf);
- cf = (ConnectionFactory)initialContext.lookup("/ClusteredConnectionFactory");
+ cf = (ConnectionFactory)ic.lookup("/ClusteredConnectionFactory");
log.debug("ConnectionFactory: " + cf);
- xacf = (XAConnectionFactory)initialContext.lookup("/ClusteredXAConnectionFactory");
+ xacf = (XAConnectionFactory)ic.lookup("/ClusteredXAConnectionFactory");
log.debug("ConnectionFactory: " + xacf);
- cf = (ConnectionFactory)initialContext.lookup("java:/ClusteredConnectionFactory");
+ cf = (ConnectionFactory)ic.lookup("java:/ClusteredConnectionFactory");
log.debug("ConnectionFactory: " + cf);
- xacf = (XAConnectionFactory)initialContext.lookup("java:/ClusteredXAConnectionFactory");
+ xacf = (XAConnectionFactory)ic.lookup("java:/ClusteredXAConnectionFactory");
log.debug("ConnectionFactory: " + xacf);
}
@@ -123,7 +97,7 @@
ServerManagement.deployConnectionFactory(objectName, jndiBindings);
- ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/SomeConnectionFactory");
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/SomeConnectionFactory");
assertNotNull(cf);
assertTrue(cf instanceof QueueConnectionFactory);
@@ -133,7 +107,7 @@
try
{
- initialContext.lookup("/SomeConnectionFactory");
+ ic.lookup("/SomeConnectionFactory");
fail("should throw exception");
}
catch(NameNotFoundException e)
@@ -144,10 +118,6 @@
public void testDeploymentWithPrefetch() throws Exception
{
- ServerManagement.deployQueue("testQueue");
-
- Queue queue = (Queue)initialContext.lookup("/queue/testQueue");
-
String objectName = "somedomain:service=SomeConnectionFactory";
String[] jndiBindings = new String[] { "/SomeConnectionFactory" };
@@ -155,39 +125,51 @@
ServerManagement.deployConnectionFactory(objectName, jndiBindings, prefetchSize);
- ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/SomeConnectionFactory");
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/SomeConnectionFactory");
assertNotNull(cf);
assertTrue(cf instanceof QueueConnectionFactory);
assertTrue(cf instanceof TopicConnectionFactory);
- Connection conn = cf.createConnection();
+ Connection conn = null;
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- JBossMessageConsumer cons = (JBossMessageConsumer)sess.createConsumer(queue);
-
- ClientConsumerDelegate del = (ClientConsumerDelegate)cons.getDelegate();
-
- ConsumerState state = (ConsumerState)del.getState();
-
- int size = state.getBufferSize();
-
- assertEquals(prefetchSize, size);
-
- ServerManagement.undeployConnectionFactory(new ObjectName(objectName));
-
- ServerManagement.undeployQueue("testQueue");
-
try
- {
- initialContext.lookup("/SomeConnectionFactory");
- fail("should throw exception");
+ {
+ conn = cf.createConnection();
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ JBossMessageConsumer cons = (JBossMessageConsumer)sess.createConsumer(queue1);
+
+ ClientConsumerDelegate del = (ClientConsumerDelegate)cons.getDelegate();
+
+ ConsumerState state = (ConsumerState)del.getState();
+
+ int size = state.getBufferSize();
+
+ assertEquals(prefetchSize, size);
+
+ ServerManagement.undeployConnectionFactory(new ObjectName(objectName));
+
+ ServerManagement.undeployQueue("testQueue");
+
+ try
+ {
+ ic.lookup("/SomeConnectionFactory");
+ fail("should throw exception");
+ }
+ catch(NameNotFoundException e)
+ {
+ // OK
+ }
}
- catch(NameNotFoundException e)
+ finally
{
- // OK
+ if (conn != null)
+ {
+ conn.close();
+ }
}
}
@@ -197,20 +179,20 @@
String[] jndiBindings = new String[] { "/name1", "/name2", "/name3" };
ServerManagement.deployConnectionFactory(objectName, jndiBindings);
- ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/name1");
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/name1");
assertNotNull(cf);
- cf = (ConnectionFactory)initialContext.lookup("/name2");
+ cf = (ConnectionFactory)ic.lookup("/name2");
assertNotNull(cf);
- cf = (ConnectionFactory)initialContext.lookup("/name2");
+ cf = (ConnectionFactory)ic.lookup("/name2");
assertNotNull(cf);
ServerManagement.undeployConnectionFactory(new ObjectName(objectName));
try
{
- initialContext.lookup("/name1");
+ ic.lookup("/name1");
fail("should throw exception");
}
catch(NameNotFoundException e)
@@ -220,7 +202,7 @@
try
{
- initialContext.lookup("/name2");
+ ic.lookup("/name2");
fail("should throw exception");
}
catch(NameNotFoundException e)
@@ -230,7 +212,7 @@
try
{
- initialContext.lookup("/name3");
+ ic.lookup("/name3");
fail("should throw exception");
}
catch(NameNotFoundException e)
@@ -245,7 +227,7 @@
String[] jndiBindings = new String[] { "/a/compound/jndi/name" };
ServerManagement.deployConnectionFactory(objectName, jndiBindings);
- ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/a/compound/jndi/name");
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/a/compound/jndi/name");
assertNotNull(cf);
ServerManagement.undeployConnectionFactory(new ObjectName(objectName));
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -27,7 +27,6 @@
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Session;
-import javax.naming.InitialContext;
import org.jboss.jms.client.JBossConnection;
import org.jboss.jms.client.JBossConnectionFactory;
@@ -39,7 +38,7 @@
import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
import org.jboss.jms.tx.MessagingXid;
import org.jboss.jms.tx.TransactionRequest;
-import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.jms.JMSTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
/**
@@ -51,7 +50,7 @@
*
* $Id$
*/
-public class SimpleConnectionManagerTest extends MessagingTestCase
+public class SimpleConnectionManagerTest extends JMSTestCase
{
// Constants -----------------------------------------------------
@@ -59,8 +58,6 @@
// Attributes ----------------------------------------------------
- protected InitialContext initialContext;
-
// Constructors --------------------------------------------------
public SimpleConnectionManagerTest(String name)
@@ -69,69 +66,66 @@
}
// Public --------------------------------------------------------
-
- public void setUp() throws Exception
- {
- if (ServerManagement.isRemote())
- {
- fail("this test is not supposed to run in a remote configuration!");
- }
-
- super.setUp();
- ServerManagement.start("all");
-
- initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- log.debug("setup done");
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
-
- initialContext.close();
- }
-
-
+
public void testWithRealServer() throws Exception
{
- ConnectionFactory cf = (JBossConnectionFactory)initialContext.lookup("/ConnectionFactory");
+ ConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
- JBossConnection conn1 = (JBossConnection)cf.createConnection();
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ JBossConnection conn1 = null;
- JBossConnection conn2 = (JBossConnection)cf.createConnection();
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ JBossConnection conn2 = null;
- ServerPeer peer = ServerManagement.getServer().getServerPeer();
- SimpleConnectionManager cm = (SimpleConnectionManager)peer.getConnectionManager();
+ try
+ {
- //Simulate failure on connection
-
- Map jmsClients = cm.getClients();
- assertEquals(1, jmsClients.size());
-
- Map endpoints = (Map)jmsClients.values().iterator().next();
-
- assertEquals(2, endpoints.size());
-
- Iterator iter = endpoints.entrySet().iterator();
-
- Map.Entry entry = (Map.Entry)iter.next();
-
- String sessId1 = (String)entry.getKey();
-
- entry = (Map.Entry)iter.next();
-
- //Simulate failure of connection
-
- cm.handleClientFailure(sessId1, true);
-
- //both connections should be shut
-
- jmsClients = cm.getClients();
- assertEquals(0, jmsClients.size());
+ conn1 = (JBossConnection)cf.createConnection();
+ Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ conn2 = (JBossConnection)cf.createConnection();
+ Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ ServerPeer peer = ServerManagement.getServer().getServerPeer();
+
+ SimpleConnectionManager cm = (SimpleConnectionManager)peer.getConnectionManager();
+
+ //Simulate failure on connection
+
+ Map jmsClients = cm.getClients();
+ assertEquals(1, jmsClients.size());
+
+ Map endpoints = (Map)jmsClients.values().iterator().next();
+
+ assertEquals(2, endpoints.size());
+
+ Iterator iter = endpoints.entrySet().iterator();
+
+ Map.Entry entry = (Map.Entry)iter.next();
+
+ String sessId1 = (String)entry.getKey();
+
+ entry = (Map.Entry)iter.next();
+
+ //Simulate failure of connection
+
+ cm.handleClientFailure(sessId1, true);
+
+ //both connections should be shut
+
+ jmsClients = cm.getClients();
+ assertEquals(0, jmsClients.size());
+ }
+ finally
+ {
+ if (conn1 != null)
+ {
+ conn1.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
}
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/connectormanager/SimpleConnectorManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/connectormanager/SimpleConnectorManagerTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/connectormanager/SimpleConnectorManagerTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -25,7 +25,6 @@
import org.jboss.jms.server.connectormanager.SimpleConnectorManager;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
/**
*
@@ -56,28 +55,6 @@
// Public --------------------------------------------------------
- public void setUp() throws Exception
- {
- if (ServerManagement.isRemote())
- {
- fail("this test is not supposed to run in a remote configuration!");
- }
-
- super.setUp();
- ServerManagement.start("all");
-
- initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- log.debug("setup done");
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
-
- initialContext.close();
- }
-
public void testSimpleConnectorManager() throws Exception
{
SimpleConnectorManager cm = new SimpleConnectorManager();
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/destination/QueueManagementTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,7 +24,6 @@
import java.util.List;
import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -35,7 +34,6 @@
import javax.jms.TextMessage;
import javax.management.ObjectName;
import javax.management.RuntimeMBeanException;
-import javax.naming.InitialContext;
import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.server.messagecounter.MessageCounter;
@@ -71,17 +69,6 @@
// Public --------------------------------------------------------
- public void setUp() throws Exception
- {
- super.setUp();
- log.debug("setup done");
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
public void testReloadQueue() throws Exception
{
String config =
@@ -101,10 +88,6 @@
//Send some messages
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
Queue queue = (Queue)ic.lookup("/queue/ReloadQueue");
Connection conn = cf.createConnection();
@@ -179,9 +162,6 @@
public void testMessageCount() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployQueue("QueueMessageCount");
ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "enableMessageCounters", null, null);
@@ -210,7 +190,6 @@
count = (Integer)ServerManagement.getAttribute(destObjectName, "MessageCount");
assertEquals(1, count.intValue());
-
// Consume the message
conn = cf.createConnection();
session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -238,9 +217,6 @@
public void testNegativeMessageCountBug() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
final String queueName = "QueueNegativeMessageCount";
final ObjectName destObjectName =
new ObjectName("jboss.messaging.destination:service=Queue,name=" + queueName);
@@ -305,9 +281,6 @@
public void testScheduledMessageCount() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployQueue("QueueMessageCount");
ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "enableMessageCounters", null, null);
@@ -372,12 +345,10 @@
public void testMessageCountOverFullSize() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
Connection conn = null;
int fullSize = 10;
- int MESSAGE_COUNT = 100;
+ int MESSAGE_COUNT = 20;
ServerManagement.deployQueue("QueueMessageCount2", fullSize, fullSize / 2, fullSize / 2 - 1);
@@ -419,12 +390,11 @@
{
receivedCount++;
- Thread.sleep(500);
+ Thread.sleep(250);
int mc = ((Integer)ServerManagement.
getAttribute(destObjectName, "MessageCount")).intValue();
-
if ((MESSAGE_COUNT - receivedCount)!=mc)
{
retryForLogs(mc, receivedCount, MESSAGE_COUNT, destObjectName);
@@ -434,7 +404,6 @@
}
assertEquals(MESSAGE_COUNT, receivedCount);
-
}
finally
{
@@ -451,9 +420,6 @@
public void testMaxSize() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployQueue("QueueMaxSize");
try
@@ -520,9 +486,6 @@
public void testRemoveAllMessages() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployQueue("QueueRemoveMessages");
try
@@ -573,10 +536,6 @@
public void testListMessages() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployQueue("QueueListMessages");
Connection conn = null;
@@ -780,9 +739,6 @@
return;
}
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.setAttribute(ServerManagement.getServerPeerObjectName(), "MessageCounterSamplePeriod", String.valueOf(1000));
ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "enableMessageCounters", null, null);
@@ -860,14 +816,12 @@
ServerManagement.undeployQueue("QueueMessageCounter");
ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "disableMessageCounters", null, null);
+
+ conn.close();
}
public void testConsumersCount() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
-
ServerManagement.deployQueue("QueueConsumerCount");
Queue queue = (Queue)ic.lookup("/queue/QueueConsumerCount");
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/destination/TopicManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/destination/TopicManagementTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/destination/TopicManagementTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -24,7 +24,6 @@
import java.util.List;
import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Message;
import javax.jms.MessageConsumer;
@@ -33,12 +32,9 @@
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.jms.TopicConnection;
-import javax.jms.TopicConnectionFactory;
import javax.jms.TopicSession;
import javax.management.ObjectName;
-import javax.naming.InitialContext;
-import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.jms.server.destination.SubscriptionInfo;
import org.jboss.test.messaging.jms.server.destination.base.DestinationManagementTestBase;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -69,17 +65,6 @@
// Public --------------------------------------------------------
- public void setUp() throws Exception
- {
- super.setUp();
- log.debug("setup done");
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
public void testReloadTopic() throws Exception
{
String config =
@@ -92,8 +77,7 @@
ObjectName destObjectName = deploy(config);
try
- {
-
+ {
assertEquals("ReloadTopic", ServerManagement.getAttribute(destObjectName, "Name"));
String jndiName = "/topic/ReloadTopic";
@@ -102,10 +86,6 @@
//Send some messages to durable sub
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
Topic topic = (Topic)ic.lookup("/topic/ReloadTopic");
Connection conn = cf.createConnection();
@@ -197,9 +177,6 @@
*/
public void testRemoveAllMessages() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployTopic("TopicRemoveAllMessages");
try
@@ -263,8 +240,6 @@
ServerManagement.invoke(destObjectName, "removeAllMessages", null, null);
- Thread.sleep(1000);
-
count = ((Integer)ServerManagement.getAttribute(destObjectName, "AllMessageCount")).intValue();
assertEquals(0, count);
@@ -288,8 +263,6 @@
conn.close();
- Thread.sleep(1000);
-
// Remove all messages from the topic
ServerManagement.invoke(destObjectName, "removeAllMessages", null, null);
@@ -308,16 +281,12 @@
public void testMessageCount() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployTopic("TopicGetAllMessageCount");
ServerManagement.invoke(ServerManagement.getServerPeerObjectName(), "enableMessageCounters", null, null);
TopicConnection conn = null;
-
-
+
try
{
Topic topic = (Topic)ic.lookup("/topic/TopicGetAllMessageCount");
@@ -421,9 +390,6 @@
public void testSubscriptionsCount() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployTopic("TopicSubscriptionsCount");
TopicConnection conn = null;
@@ -504,9 +470,6 @@
public void testListSubscriptions() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployTopic("TopicSubscriptionList");
Topic topic = (Topic)ic.lookup("/topic/TopicSubscriptionList");
@@ -636,9 +599,6 @@
public void testListSubscriptionsAsHTML() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployTopic("TopicSubscriptionList");
Topic topic = (Topic)ic.lookup("/topic/TopicSubscriptionList");
@@ -725,9 +685,6 @@
public void testListMessages() throws Exception
{
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
- TopicConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
ServerManagement.deployTopic("TopicMessageList");
TopicConnection conn = null;
@@ -790,10 +747,7 @@
//visible
cons.close();
-
- //Give time for cancel to occur
- Thread.sleep(500);
-
+
String sub1Id = ((SubscriptionInfo)durableSubs.get(0)).getId();
List allMsgs = (List)ServerManagement.invoke(destObjectName, "listAllMessages", new Object[] { sub1Id }, new String[] { "java.lang.String" });
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/destination/base/DestinationManagementTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/destination/base/DestinationManagementTestBase.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/destination/base/DestinationManagementTestBase.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,11 +21,11 @@
*/
package org.jboss.test.messaging.jms.server.destination.base;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.Message;
import javax.jms.MessageConsumer;
@@ -35,7 +35,6 @@
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.management.ObjectName;
-import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.jms.destination.JBossDestination;
@@ -44,7 +43,7 @@
import org.jboss.jms.server.destination.ManagedDestination;
import org.jboss.jms.server.messagecounter.MessageCounter;
import org.jboss.messaging.util.XMLUtil;
-import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.jms.JMSTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
import org.w3c.dom.Element;
@@ -57,7 +56,7 @@
*
* $Id$
*/
-public abstract class DestinationManagementTestBase extends MessagingTestCase
+public abstract class DestinationManagementTestBase extends JMSTestCase
{
// Constants -----------------------------------------------------
@@ -65,8 +64,6 @@
// Attributes ----------------------------------------------------
- protected InitialContext initialContext;
-
// Constructors --------------------------------------------------
public DestinationManagementTestBase(String name)
@@ -76,20 +73,6 @@
// Public --------------------------------------------------------
- public void setUp() throws Exception
- {
- super.setUp();
- ServerManagement.start("all");
-
- initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
- }
-
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
-
public void testDeployDestinationAdministratively() throws Exception
{
ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
@@ -110,22 +93,9 @@
String jndiName = (isQueue() ? "/queue" : "/topic") + "/Kirkwood";
String s = (String)ServerManagement.getAttribute(destObjectName, "JNDIName");
assertEquals(jndiName, s);
-
- Set destinations = (Set)ServerManagement.getAttribute(serverPeerObjectName, "Destinations");
+
+ assertTrue(destinationIsDeployed("Kirkwood", isQueue()));
- assertEquals(1, destinations.size());
-
- if (isQueue())
- {
- Queue q = (Queue)destinations.iterator().next();
- assertEquals("Kirkwood", q.getQueueName());
- }
- else
- {
- Topic t = (Topic)destinations.iterator().next();
- assertEquals("Kirkwood", t.getTopicName());
- }
-
assertEquals(serverPeerObjectName,
ServerManagement.getAttribute(destObjectName, "ServerPeer"));
@@ -138,13 +108,13 @@
undeployDestination((String)ServerManagement.getAttribute(destObjectName, "Name"));
}
-
+
public void testDeployDestinationAdministrativelyWithParams() throws Exception
{
- ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
+ ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
+
+ int fullSize = 77777;
- int fullSize = 77777;
-
int pageSize = 1234;
int downCacheSize = 789;
@@ -169,22 +139,8 @@
String s = (String)ServerManagement.getAttribute(destObjectName, "JNDIName");
assertEquals(jndiName, s);
- Set destinations = (Set)ServerManagement.getAttribute(serverPeerObjectName, "Destinations");
+ assertTrue(destinationIsDeployed("Kirkwood", isQueue()));
- assertEquals(1, destinations.size());
-
- if (isQueue())
- {
- Queue q = (Queue)destinations.iterator().next();
- assertEquals("Kirkwood", q.getQueueName());
-
- }
- else
- {
- Topic t = (Topic)destinations.iterator().next();
- assertEquals("Kirkwood", t.getTopicName());
- }
-
assertEquals(serverPeerObjectName,
ServerManagement.getAttribute(destObjectName, "ServerPeer"));
@@ -270,8 +226,6 @@
assertEquals("Kirkwood", ServerManagement.getAttribute(destObjectName, "Name"));
assertEquals(testJNDIName, ServerManagement.getAttribute(destObjectName, "JNDIName"));
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
Destination d = (Destination)ic.lookup(testJNDIName);
if (isQueue())
@@ -285,8 +239,6 @@
assertEquals("Kirkwood", t.getTopicName());
}
- ic.close();
-
// try to change the JNDI name after initialization
ServerManagement.setAttribute(destObjectName, "JNDIName", "total/junk");
@@ -317,8 +269,6 @@
assertEquals(expectedJNDIName, jndiName);
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
if (isQueue())
{
Queue q = (Queue)ic.lookup(jndiName);
@@ -333,6 +283,8 @@
assertEquals(destinationName, ServerManagement.getAttribute(destObjectName, "Name"));
assertEquals(expectedJNDIName,
(String)ServerManagement.getAttribute(destObjectName, "JNDIName"));
+
+ assertTrue(destinationIsDeployed(destinationName, isQueue()));
// undeploy it
@@ -355,13 +307,7 @@
Set set = ServerManagement.query(destObjectName);
assertTrue(set.isEmpty());
- set = (Set)ServerManagement.getAttribute(serverPeerObjectName, "Destinations");
-
-
- assertTrue(set.isEmpty());
-
- ic.close();
-
+ assertFalse(destinationIsDeployed(destinationName, isQueue()));
}
public void testDeployDestinationProgrammaticallyWithParams() throws Exception
@@ -391,8 +337,6 @@
assertEquals(expectedJNDIName, jndiName);
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
if (isQueue())
{
Queue q = (Queue)ic.lookup(jndiName);
@@ -411,6 +355,7 @@
assertEquals(new Integer(fullSize), ServerManagement.getAttribute(destObjectName, "FullSize"));
assertEquals(new Integer(pageSize), ServerManagement.getAttribute(destObjectName, "PageSize"));
assertEquals(new Integer(downCacheSize), ServerManagement.getAttribute(destObjectName, "DownCacheSize"));
+ assertTrue(destinationIsDeployed(destinationName, isQueue()));
// undeploy it
@@ -434,13 +379,7 @@
Set set = ServerManagement.query(destObjectName);
assertTrue(set.isEmpty());
- set = (Set)ServerManagement.getAttribute(serverPeerObjectName, "Destinations");
-
-
- assertTrue(set.isEmpty());
-
- ic.close();
-
+ assertFalse(destinationIsDeployed(destinationName, isQueue()));
}
public void testDestroyDestinationProgrammatically() throws Exception
@@ -464,8 +403,6 @@
assertEquals(expectedJNDIName, jndiName);
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
if (isQueue())
{
Queue q = (Queue)ic.lookup(jndiName);
@@ -481,8 +418,6 @@
assertEquals(expectedJNDIName,
(String)ServerManagement.getAttribute(destObjectName, "JNDIName"));
- ConnectionFactory cf = (ConnectionFactory)this.initialContext.lookup("/ConnectionFactory");
-
Connection conn = cf.createConnection();
conn.setClientID("wibble456");
@@ -539,10 +474,7 @@
Set set = ServerManagement.query(destObjectName);
assertTrue(set.isEmpty());
- set = (Set)ServerManagement.getAttribute(serverPeerObjectName, "Destinations");
-
-
- assertTrue(set.isEmpty());
+ assertFalse(destinationIsDeployed(destinationName, isQueue()));
// Deploy it again
jndiName = (String)ServerManagement.
@@ -569,15 +501,11 @@
cons = sess.createDurableSubscriber((Topic)dest, "sub1");
}
- Message m = cons.receive(2000);
+ Message m = cons.receive(1000);
assertNull(m);
- conn.close();
-
-
- ic.close();
-
+ conn.close();
}
public void testDestroyNonProgrammaticDestination() throws Exception
@@ -692,12 +620,6 @@
public void testGetSetMessageCounterHistoryDayLimit() throws Exception
{
- if (ServerManagement.isRemote())
- {
- //This test can't be run in a remote configuration since MessageCounter is not serializable
- return;
- }
-
int defaultLimit = 12;
ServerManagement.setAttribute(ServerManagement.getServerPeerObjectName(), "DefaultMessageCounterHistoryDayLimit", String.valueOf(defaultLimit));
@@ -710,9 +632,9 @@
try
{
- initialContext.lookup("/queue/testQueue");
+ ic.lookup("/queue/testQueue");
- Topic testTopic = (Topic)initialContext.lookup("/topic/testTopic");
+ Topic testTopic = (Topic)ic.lookup("/topic/testTopic");
String queueON = "jboss.messaging.destination:service=Queue,name=testQueue";
@@ -722,8 +644,6 @@
assertEquals(defaultLimit, queueCounter.getHistoryLimit());
- ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
-
conn = cf.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -766,6 +686,41 @@
protected abstract boolean isQueue();
+ protected boolean destinationIsDeployed(String destName, boolean isQueue) throws Exception
+ {
+ ObjectName serverPeerObjectName = ServerManagement.getServerPeerObjectName();
+
+ Set destinations = (Set)ServerManagement.getAttribute(serverPeerObjectName, "Destinations");
+
+ Iterator iter = destinations.iterator();
+
+ boolean found = false;
+ while (iter.hasNext())
+ {
+ Destination dest = (Destination)iter.next();
+
+ if (dest instanceof Queue && isQueue)
+ {
+ Queue q = (Queue)dest;
+ if (q.getQueueName().equals(destName))
+ {
+ found = true;
+ break;
+ }
+ }
+ else if (dest instanceof Topic && !isQueue)
+ {
+ Topic t = (Topic)dest;
+ if (t.getTopicName().equals(destName))
+ {
+ found = true;
+ break;
+ }
+ }
+ }
+ return found;
+ }
+
protected ObjectName deploy(String destConfig) throws Exception
{
ObjectName on = ServerManagement.deploy(destConfig);
Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/CorruptMessageStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/CorruptMessageStressTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/CorruptMessageStressTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,19 +6,19 @@
*/
package org.jboss.test.messaging.jms.stress;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.logging.Logger;
-
-import javax.naming.InitialContext;
+import javax.jms.Connection;
import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
import javax.jms.Queue;
-import javax.jms.MessageProducer;
import javax.jms.Session;
-import javax.jms.Message;
-import javax.jms.DeliveryMode;
+import javax.naming.InitialContext;
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
/**
* A stress test written to investigate http://jira.jboss.org/jira/browse/JBMESSAGING-362
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/Runner.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/Runner.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/Runner.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,6 +22,7 @@
package org.jboss.test.messaging.jms.stress;
import javax.jms.Session;
+
import org.jboss.logging.Logger;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/SeveralClientsStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/SeveralClientsStressTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/SeveralClientsStressTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,27 +22,30 @@
package org.jboss.test.messaging.jms.stress;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.logging.Logger;
-import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.Queue;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Message;
-import javax.jms.DeliveryMode;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Random;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
+
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
+
/**
* In order for this test to run, you will need to edit /etc/security/limits.conf and change your max sockets to something bigger than 1024
*
Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredQueueStressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredQueueStressTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/ClusteredQueueStressTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,18 +22,21 @@
package org.jboss.test.messaging.jms.stress.clustering;
-import org.jboss.test.messaging.jms.clustering.ClusteringTestBase;
-import org.jboss.logging.Logger;
-import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
+
import javax.jms.Connection;
-import javax.jms.Session;
+import javax.jms.JMSException;
+import javax.jms.Message;
import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
import javax.jms.MessageProducer;
-import javax.jms.MessageListener;
-import javax.jms.Message;
-import javax.jms.JMSException;
+import javax.jms.Session;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.jms.clustering.ClusteringTestBase;
+
import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
public class ClusteredQueueStressTest extends ClusteringTestBase
Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -43,13 +43,13 @@
import org.jboss.messaging.core.contract.PersistenceManager;
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
-import org.jboss.test.messaging.tools.jmx.rmi.NotificationListenerID;
-import org.jboss.test.messaging.tools.jmx.rmi.RMITestServer;
-import org.jboss.test.messaging.tools.jmx.rmi.Server;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
-import org.jboss.test.messaging.tools.jndi.RemoteInitialContextFactory;
+import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
+import org.jboss.test.messaging.tools.container.LocalTestServer;
+import org.jboss.test.messaging.tools.container.NotificationListenerID;
+import org.jboss.test.messaging.tools.container.RMITestServer;
+import org.jboss.test.messaging.tools.container.RemoteInitialContextFactory;
+import org.jboss.test.messaging.tools.container.Server;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
/**
* Collection of static methods to use to start/stop and interact with the in-memory JMS server. It
@@ -477,7 +477,7 @@
sb.append(" -Djava.net.preferIPv4Stack=true ");
}
- sb.append("org.jboss.test.messaging.tools.jmx.rmi.RMITestServer");
+ sb.append("org.jboss.test.messaging.tools.container.RMITestServer");
String commandLine = sb.toString();
Modified: trunk/tests/src/org/jboss/test/messaging/tools/ant/DisplayWarningsAndErrors.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ant/DisplayWarningsAndErrors.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ant/DisplayWarningsAndErrors.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,12 +22,12 @@
package org.jboss.test.messaging.tools.ant;
+import java.io.BufferedReader;
import java.io.File;
-import java.io.BufferedReader;
import java.io.FileReader;
-import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
/**
* Greps fror WARN and ERROR entries in the specified file.
Modified: trunk/tests/src/org/jboss/test/messaging/tools/ant/FailOnSerializationDebugOutput.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ant/FailOnSerializationDebugOutput.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ant/FailOnSerializationDebugOutput.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,8 +22,8 @@
package org.jboss.test.messaging.tools.ant;
+import java.io.BufferedReader;
import java.io.File;
-import java.io.BufferedReader;
import java.io.FileReader;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/tools/ant/GenerateSmokeReport.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ant/GenerateSmokeReport.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ant/GenerateSmokeReport.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,21 +21,21 @@
*/
package org.jboss.test.messaging.tools.ant;
+import java.io.BufferedReader;
import java.io.File;
-import java.io.BufferedReader;
import java.io.FileReader;
+import java.io.FileWriter;
import java.io.PrintWriter;
-import java.io.FileWriter;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
-import java.util.Set;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.Collections;
import java.util.List;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
import java.util.StringTokenizer;
Modified: trunk/tests/src/org/jboss/test/messaging/tools/aop/PoisonInterceptor.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/aop/PoisonInterceptor.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/aop/PoisonInterceptor.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,7 +21,7 @@
import org.jboss.jms.server.endpoint.advised.SessionAdvised;
import org.jboss.jms.tx.TransactionRequest;
import org.jboss.logging.Logger;
-import org.jboss.test.messaging.tools.jmx.rmi.RMITestServer;
+import org.jboss.test.messaging.tools.container.RMITestServer;
/**
* Used to force a "poisoned" server to do all sorts of bad things. Used for testing.
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapper.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapper.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapper.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,95 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.lang.reflect.Array;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * We extend URLClassLoader just to prevent UnifiedLoaderRepository3 to generate spurious warning
+ * (in this case): "Tried to add non-URLClassLoader. Ignored". Extending ClassLoader would be fine
+ * otherwise.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ClassLoaderJMXWrapper extends URLClassLoader implements ClassLoaderJMXWrapperMBean
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private ClassLoader delegate;
+
+ // Constructors --------------------------------------------------
+
+ public ClassLoaderJMXWrapper(ClassLoader delegate)
+ {
+ super(new URL[0]);
+ this.delegate = delegate;
+ }
+
+ // ClassLoaderJMXWrapperMBean implementation ---------------------
+
+ public Class loadClass(String name) throws ClassNotFoundException
+ {
+ if (name.endsWith("[]"))
+ {
+ name = name.substring(0, name.length() - 2);
+
+ //The classloader of an array type is the classloader of it's element (if non primitive)
+
+ Class cl = delegate.loadClass(name);
+
+ Object arr = Array.newInstance(cl, 0);
+
+ return arr.getClass();
+ }
+ else
+ {
+ return delegate.loadClass(name);
+ }
+ }
+
+ // ClassLoader overrides -----------------------------------------
+
+ public URL getResource(String name)
+ {
+ return delegate.getResource(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapperMBean.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapperMBean.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapperMBean.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ClassLoaderJMXWrapperMBean.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public interface ClassLoaderJMXWrapperMBean
+{
+ Class loadClass(String name) throws ClassNotFoundException;
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/Command.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Command.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Command.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.test.messaging.tools.container;
+
+import java.io.Serializable;
+
+/**
+ *
+ * A Command.
+ *
+ * This interface is implemented by any classes that wish to be executed on a server
+ *
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1935 $</tt>
+ *
+ * $Id: Command.java 1935 2007-01-09 23:29:20Z clebert.suconic at jboss.com $
+ */
+public interface Command extends Serializable
+{
+ public Object execute() throws Exception;
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/Constants.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Constants.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Constants.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,36 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.tools.container;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: Constants.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class Constants
+{
+ // Constants -----------------------------------------------------
+
+ public static final String SERVER_INDEX_PROPERTY_NAME = "jboss.messaging.test.server.index";
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/Example.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/Example.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Example.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Example.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+
+/**
+ * An example how to use ServiceContainer to get access to an in-memory database.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class Example
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ public static void main(String[] args) throws Exception
+ {
+ ServiceContainer sc = new ServiceContainer("transaction, jca, database");
+ sc.start();
+
+ InitialContext ic = new InitialContext();
+
+ TransactionManager tm = (TransactionManager)ic.lookup("java:/TransactionManager");
+ DataSource ds = (DataSource)ic.lookup("java:/DefaultDS");
+ Connection c;
+
+
+ tm.begin();
+
+ c = ds.getConnection();
+ c.createStatement().executeUpdate("CREATE TABLE SOME_TABLE (SOME_FIELD VARCHAR)");
+
+ tm.commit();
+
+ tm.begin();
+ c = ds.getConnection();
+ c.createStatement().executeUpdate("INSERT INTO SOME_TABLE VALUES ('this shouldnt get into db')");
+
+ tm.rollback();
+
+ tm.begin();
+ c = ds.getConnection();
+ c.createStatement().executeUpdate("INSERT INTO SOME_TABLE VALUES ('some value')");
+
+ tm.commit();
+
+
+ c = ds.getConnection();
+ ResultSet rs = c.createStatement().executeQuery("SELECT SOME_FIELD FROM SOME_TABLE");
+ while (rs.next())
+ {
+ String a = rs.getString("SOME_FIELD");
+ System.out.println(a);
+ }
+
+
+ c.close();
+ sc.stop();
+ }
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/InVMContext.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/InVMContext.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/InVMContext.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,374 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Binding;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+
+import org.jboss.messaging.util.NotYetImplementedException;
+import org.jboss.util.naming.NonSerializableFactory;
+
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: InVMContext.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class InVMContext implements Context, Serializable
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = 385743957345L;
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ protected Map map;
+ protected NameParser parser = new InVMNameParser();
+
+ // Constructors --------------------------------------------------
+
+ public InVMContext()
+ {
+ map = Collections.synchronizedMap(new HashMap());
+ }
+
+ // Context implementation ----------------------------------------
+
+ public Object lookup(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object lookup(String name) throws NamingException
+ {
+ name = trimSlashes(name);
+ int i = name.indexOf("/");
+ String tok = i == -1 ? name : name.substring(0, i);
+ Object value = map.get(tok);
+ if (value == null)
+ {
+ throw new NameNotFoundException("Name not found: " + tok);
+ }
+ if (value instanceof InVMContext && i != -1)
+ {
+ return ((InVMContext)value).lookup(name.substring(i));
+ }
+ if (value instanceof Reference)
+ {
+ Reference ref = (Reference)value;
+ RefAddr refAddr = ref.get("nns");
+
+ // we only deal with references create by NonSerializableFactory
+ String key = (String)refAddr.getContent();
+ return NonSerializableFactory.lookup(key);
+ }
+ else
+ {
+ return value;
+ }
+ }
+
+ public void bind(Name name, Object obj) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void bind(String name, Object obj) throws NamingException
+ {
+ internalBind(name, obj, false);
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void rebind(String name, Object obj) throws NamingException
+ {
+ internalBind(name, obj, true);
+ }
+
+ public void unbind(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void unbind(String name) throws NamingException
+ {
+ name = trimSlashes(name);
+ int i = name.indexOf("/");
+ boolean terminal = i == -1;
+ if (terminal)
+ {
+ map.remove(name);
+ }
+ else
+ {
+ String tok = name.substring(0, i);
+ InVMContext c = (InVMContext)map.get(tok);
+ if (c == null)
+ {
+ throw new NameNotFoundException("Context not found: " + tok);
+ }
+ c.unbind(name.substring(i));
+ }
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void rename(String oldName, String newName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration list(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration list(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration listBindings(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration listBindings(String contextName) throws NamingException
+ {
+ contextName = trimSlashes(contextName);
+ if (!"".equals(contextName) && !".".equals(contextName))
+ {
+ try
+ {
+ return ((InVMContext)lookup(contextName)).listBindings("");
+ }
+ catch(Throwable t)
+ {
+ throw new NamingException(t.getMessage());
+ }
+ }
+
+ List l = new ArrayList();
+ for(Iterator i = map.keySet().iterator(); i.hasNext(); )
+ {
+ String name = (String)i.next();
+ Object object = map.get(name);
+ l.add(new Binding(name, object));
+ }
+ return new NamingEnumerationImpl(l.iterator());
+ }
+
+ public void destroySubcontext(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void destroySubcontext(String name) throws NamingException
+ {
+ map.remove(trimSlashes(name));
+ }
+
+ public Context createSubcontext(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Context createSubcontext(String name) throws NamingException
+ {
+ name = trimSlashes(name);
+ if (map.get(name) != null)
+ {
+ throw new NameAlreadyBoundException(name);
+ }
+ InVMContext c = new InVMContext();
+ map.put(name, c);
+ return c;
+ }
+
+ public Object lookupLink(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object lookupLink(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException
+ {
+ return getNameParser(name.toString());
+ }
+
+ public NameParser getNameParser(String name) throws NamingException
+ {
+ return parser;
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public String composeName(String name, String prefix) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object removeFromEnvironment(String propName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Hashtable getEnvironment() throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void close() throws NamingException
+ {
+ }
+
+ public String getNameInNamespace() throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private String trimSlashes(String s)
+ {
+ int i = 0;
+ while(true)
+ {
+ if (i == s.length() || s.charAt(i) != '/')
+ {
+ break;
+ }
+ i++;
+ }
+ s = s.substring(i);
+ i = s.length() - 1;
+ while(true)
+ {
+ if (i == -1 || s.charAt(i) != '/')
+ {
+ break;
+ }
+ i--;
+ }
+ return s.substring(0, i + 1);
+ }
+
+ private void internalBind(String name, Object obj, boolean rebind) throws NamingException
+ {
+ name = trimSlashes(name);
+ int i = name.lastIndexOf("/");
+ InVMContext c = this;
+ if (i != -1)
+ {
+ String path = name.substring(0, i);
+ c = (InVMContext)lookup(path);
+ }
+ name = name.substring(i + 1);
+ if (!rebind && c.map.get(name) != null)
+ {
+ throw new NameAlreadyBoundException(name);
+ }
+ c.map.put(name, obj);
+ }
+
+ // Inner classes -------------------------------------------------
+
+ private class NamingEnumerationImpl implements NamingEnumeration
+ {
+ private Iterator iterator;
+
+ NamingEnumerationImpl(Iterator bindingIterator)
+ {
+ this.iterator = bindingIterator;
+ }
+
+ public void close() throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public boolean hasMore() throws NamingException
+ {
+ return iterator.hasNext();
+ }
+
+ public Object next() throws NamingException
+ {
+ return iterator.next();
+ }
+
+ public boolean hasMoreElements()
+ {
+ return iterator.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ return iterator.next();
+ }
+ }
+}
+
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactory.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,139 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+/**
+ * An in-VM JNDI InitialContextFactory. Lightweight JNDI implementation used for testing.
+
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: InVMInitialContextFactory.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class InVMInitialContextFactory implements InitialContextFactory
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // List<InitialContext>
+ private static List initialContexts;
+
+ static
+ {
+ initialContexts = new ArrayList();
+ }
+
+ public static Hashtable getJNDIEnvironment()
+ {
+ return getJNDIEnvironment(0);
+ }
+
+ /**
+ * @return the JNDI environment to use to get this InitialContextFactory.
+ */
+ public static Hashtable getJNDIEnvironment(int serverIndex)
+ {
+ Hashtable env = new Hashtable();
+ env.put("java.naming.factory.initial",
+ "org.jboss.test.messaging.tools.container.InVMInitialContextFactory");
+ env.put("java.naming.provider.url", "");
+ env.put("java.naming.factory.url.pkgs", "");
+ env.put(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex));
+ return env;
+ }
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Context getInitialContext(Hashtable environment) throws NamingException
+ {
+ // try first in the environment passed as argument ...
+ String s = (String)environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
+
+ if (s == null)
+ {
+ // ... then in the global environment
+ s = System.getProperty(Constants.SERVER_INDEX_PROPERTY_NAME);
+
+ if (s == null)
+ {
+ throw new NamingException("Cannot figure out server index!");
+ }
+ }
+
+ int serverIndex;
+
+ try
+ {
+ serverIndex = Integer.parseInt(s);
+ }
+ catch(Exception e)
+ {
+ throw new NamingException("Failure parsing \"" +
+ Constants.SERVER_INDEX_PROPERTY_NAME +"\". " +
+ s + " is not an integer");
+ }
+
+ int size = initialContexts.size();
+
+ // pad the list to the right size
+
+ if (size <= serverIndex)
+ {
+ for(int i = 0; i < serverIndex - size + 1; i++)
+ {
+ initialContexts.add(null);
+ }
+ }
+
+ InVMContext ic = (InVMContext)initialContexts.get(serverIndex);
+
+ if (ic == null)
+ {
+ ic = new InVMContext();
+ ic.bind("java:/", new InVMContext());
+ initialContexts.set(serverIndex, ic);
+ }
+
+ return ic;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactoryBuilder.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactoryBuilder.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/InVMInitialContextFactoryBuilder.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,117 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.util.Hashtable;
+
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import javax.naming.spi.InitialContextFactoryBuilder;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ *
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: InVMInitialContextFactoryBuilder.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class InVMInitialContextFactoryBuilder implements InitialContextFactoryBuilder
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(InVMInitialContextFactoryBuilder.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public InVMInitialContextFactoryBuilder()
+ {
+ }
+
+ // InitialContextFactoryBuilder implementation --------------------------------------------------
+
+ public InitialContextFactory createInitialContextFactory(Hashtable environment)
+ throws NamingException
+ {
+
+ InitialContextFactory icf = null;
+
+ if (environment != null)
+ {
+ String icfName = (String)environment.get("java.naming.factory.initial");
+
+ if (icfName != null)
+ {
+ Class c = null;
+
+ try
+ {
+ c = Class.forName(icfName);
+ }
+ catch(ClassNotFoundException e)
+ {
+ log.error("\"" + icfName + "\" cannot be loaded", e);
+ throw new NamingException("\"" + icfName + "\" cannot be loaded");
+ }
+
+ try
+ {
+ icf = (InitialContextFactory)c.newInstance();
+ }
+ catch(InstantiationException e)
+ {
+ log.error(c.getName() + " cannot be instantiated", e);
+ throw new NamingException(c.getName() + " cannot be instantiated");
+ }
+ catch(IllegalAccessException e)
+ {
+ log.error(c.getName() + " instantiation generated an IllegalAccessException", e);
+ throw new NamingException(c.getName() +
+ " instantiation generated an IllegalAccessException");
+ }
+ }
+ }
+
+ if (icf == null)
+ {
+ icf = new InVMInitialContextFactory();
+ }
+
+ return icf;
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/InVMNameParser.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/InVMNameParser.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/InVMNameParser.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,81 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import javax.naming.CompoundName;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingException;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: InVMNameParser.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class InVMNameParser implements NameParser, Serializable
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = 2925203703371001031L;
+
+ // Static --------------------------------------------------------
+
+ static Properties syntax;
+
+ static
+ {
+ syntax = new Properties();
+ syntax.put("jndi.syntax.direction", "left_to_right");
+ syntax.put("jndi.syntax.ignorecase", "false");
+ syntax.put("jndi.syntax.separator", "/");
+ }
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public static Properties getSyntax()
+ {
+ return syntax;
+ }
+
+ public Name parse(String name) throws NamingException
+ {
+ return new CompoundName(name, syntax);
+ }
+
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/JNPInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/JNPInitialContextFactory.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/JNPInitialContextFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+/**
+ * An InitialContextFactory providing InitialContext to JNDI on a remote JBoss instance.
+
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 2685 $</tt>
+ *
+ * $Id: JNPInitialContextFactory.java 2685 2007-05-15 07:56:12Z timfox $
+ */
+public class JNPInitialContextFactory implements InitialContextFactory
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ /**
+ * @return the JNDI environment to use to get this InitialContextFactory.
+ */
+ public static Hashtable getJNDIEnvironment()
+ {
+ Hashtable env = new Hashtable();
+ env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
+ env.put("java.naming.provider.url", "jnp://localhost:1099");
+ env.put("java.naming.factory.url.pkg", "org.jboss.naming:org.jnp.interfaces");
+ return env;
+ }
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Context getInitialContext(Hashtable environment) throws NamingException
+ {
+ return new InitialContext(environment);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/LocalTestServer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,946 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.transaction.UserTransaction;
+
+import org.jboss.aop.AspectXmlLoader;
+import org.jboss.jms.server.DestinationManager;
+import org.jboss.jms.server.ServerPeer;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.contract.MessageStore;
+import org.jboss.messaging.core.contract.PersistenceManager;
+import org.jboss.messaging.core.contract.PostOffice;
+import org.jboss.messaging.util.XMLUtil;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
+import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
+import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
+import org.w3c.dom.Element;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>1.1</tt>
+ *
+ * LocalTestServer.java,v 1.1 2006/02/21 08:25:32 timfox Exp
+ */
+public class LocalTestServer implements Server
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(LocalTestServer.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ public static void setEnvironmentServerIndex(int serverIndex)
+ {
+ System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex));
+ }
+
+ public static void clearEnvironmentServerIndex()
+ {
+ System.getProperty(Constants.SERVER_INDEX_PROPERTY_NAME, null);
+ }
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private ServiceContainer sc;
+
+ // service dependencies
+ private ObjectName persistenceManagerObjectName;
+ private ObjectName postOfficeObjectName;
+ private ObjectName jmsUserManagerObjectName;
+
+ // the server MBean itself
+ private ObjectName serverPeerObjectName;
+
+ private int serverIndex;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public LocalTestServer()
+ {
+ super();
+ }
+
+ public LocalTestServer(int serverIndex)
+ {
+ this();
+
+ this.serverIndex = serverIndex;
+ }
+
+ // Server implementation ------------------------------------------------------------------------
+
+ public int getServerID()
+ {
+ return serverIndex;
+ }
+
+ public void start(String containerConfig,
+ boolean clearDatabase) throws Exception
+ {
+ start(containerConfig, null, clearDatabase, true);
+ }
+
+ public synchronized void start(String containerConfig,
+ ServiceAttributeOverrides attrOverrides,
+ boolean clearDatabase,
+ boolean startMessagingServer) throws Exception
+ {
+ if (isStarted())
+ {
+ return;
+ }
+
+ log.debug("starting service container");
+
+ try
+ {
+ setEnvironmentServerIndex(serverIndex);
+
+ sc = new ServiceContainer(containerConfig, null, serverIndex);
+ sc.start(clearDatabase, attrOverrides);
+
+ if (sc.getDatabaseName().equals("hsqldb") && sc.isClustered())
+ {
+ throw new IllegalStateException("The test server cannot be started in clustered mode with hsqldb as a database - must use a shared database");
+ }
+
+ if ("none".equals(containerConfig))
+ {
+ return;
+ }
+
+ if (startMessagingServer)
+ {
+ startServerPeer(serverIndex, null, null, attrOverrides, sc.isClustered(), sc.isSupportsFailover());
+ }
+
+ log.info("Server " + serverIndex + " started");
+ }
+ finally
+ {
+ clearEnvironmentServerIndex();
+ }
+ }
+
+ public synchronized boolean stop() throws Exception
+ {
+ if (!isStarted())
+ {
+ return false;
+ }
+
+ try
+ {
+ setEnvironmentServerIndex(serverIndex);
+
+ stopServerPeer();
+
+ log.debug("stopping service container");
+
+ sc.stop();
+ sc = null;
+
+ log.info("server stopped");
+ }
+ finally
+ {
+ clearEnvironmentServerIndex();
+ }
+
+ return true;
+ }
+
+
+ public void ping() throws Exception
+ {
+ // noop... do nothing
+ }
+
+ public synchronized void kill() throws Exception
+ {
+ throw new IllegalStateException("Cannot KILL a local server. Consider using stop() instead.");
+ }
+
+ public ObjectName deploy(String mbeanConfiguration) throws Exception
+ {
+ Element mbeanElement = XMLUtil.stringToElement(mbeanConfiguration);
+ MBeanConfigurationElement mbc = new MBeanConfigurationElement(mbeanElement);
+ return sc.registerAndConfigureService(mbc);
+ }
+
+ public void undeploy(ObjectName on) throws Exception
+ {
+ sc.unregisterService(on);
+ }
+
+ public Object getAttribute(ObjectName on, String attribute) throws Exception
+ {
+ return sc.getAttribute(on, attribute);
+ }
+
+ public void setAttribute(ObjectName on, String name, String valueAsString) throws Exception
+ {
+ sc.setAttribute(on, name, valueAsString);
+ }
+
+ public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
+ throws Exception
+ {
+ return sc.invoke(on, operationName, params, signature);
+ }
+
+ public void addNotificationListener(ObjectName on, NotificationListener listener)
+ throws Exception
+ {
+ sc.addNotificationListener(on, listener);
+ }
+
+ public void removeNotificationListener(ObjectName on, NotificationListener listener)
+ throws Exception
+ {
+ sc.removeNotificationListener(on, listener);
+ }
+
+ public Set query(ObjectName pattern) throws Exception
+ {
+ return sc.query(pattern);
+ }
+
+ public String getRemotingTransport()
+ {
+ return sc.getRemotingTransport();
+ }
+
+ public void log(int level, String text)
+ {
+ if (ServerManagement.FATAL == level)
+ {
+ log.fatal(text);
+ }
+ else if (ServerManagement.ERROR == level)
+ {
+ log.error(text);
+ }
+ else if (ServerManagement.WARN == level)
+ {
+ log.warn(text);
+ }
+ else if (ServerManagement.INFO == level)
+ {
+ log.info(text);
+ }
+ else if (ServerManagement.DEBUG == level)
+ {
+ log.debug(text);
+ }
+ else if (ServerManagement.TRACE == level)
+ {
+ log.trace(text);
+ }
+ else
+ {
+ // log everything else as INFO
+ log.info(text);
+ }
+ }
+
+ public synchronized boolean isStarted() throws Exception
+ {
+ return sc != null;
+ }
+
+ public void startServerPeer(int serverPeerID,
+ String defaultQueueJNDIContext,
+ String defaultTopicJNDIContext,
+ ServiceAttributeOverrides attrOverrides,
+ boolean clustered,
+ boolean supportsFailover) throws Exception
+ {
+ List toStop = new ArrayList();
+ try
+ {
+ log.debug("creating ServerPeer instance");
+
+ // we are using the "default" service deployment descriptors available in
+ // src/etc/server/default/deploy. This will allow to test the default parameters we ship.
+
+ String mainConfigFile = "server/default/deploy/messaging-service.xml";
+
+ String persistenceConfigFile = sc.getPersistenceConfigFile(clustered);
+
+ log.info(" Persistence config file .. " + persistenceConfigFile);
+
+ ServiceDeploymentDescriptor mdd = ServiceConfigHelper.loadConfigFile(mainConfigFile);
+
+ ServiceDeploymentDescriptor pdd = ServiceConfigHelper.loadConfigFile(persistenceConfigFile);
+
+ MBeanConfigurationElement persistenceManagerConfig =
+ ServiceConfigHelper.getServiceConfiguration(pdd, "PersistenceManager");
+ persistenceManagerObjectName = sc.registerAndConfigureService(persistenceManagerConfig);
+ overrideAttributes(persistenceManagerObjectName, attrOverrides);
+ toStop.add(persistenceManagerObjectName);
+ sc.invoke(persistenceManagerObjectName, "create", new Object[0], new String[0]);
+ sc.invoke(persistenceManagerObjectName, "start", new Object[0], new String[0]);
+
+ MBeanConfigurationElement jmsUserManagerConfig =
+ ServiceConfigHelper.getServiceConfiguration(pdd, "JMSUserManager");
+ jmsUserManagerObjectName = sc.registerAndConfigureService(jmsUserManagerConfig);
+ overrideAttributes(jmsUserManagerObjectName, attrOverrides);
+ toStop.add(jmsUserManagerObjectName);
+ sc.invoke(jmsUserManagerObjectName, "create", new Object[0], new String[0]);
+ sc.invoke(jmsUserManagerObjectName, "start", new Object[0], new String[0]);
+
+ // register server peer as a service, dependencies are injected automatically
+ MBeanConfigurationElement serverPeerConfig =
+ ServiceConfigHelper.getServiceConfiguration(mdd, "ServerPeer");
+
+ // overwrite the file configuration, if needed
+ overrideServerPeerConfiguration(serverPeerConfig, serverPeerID, defaultQueueJNDIContext,
+ defaultTopicJNDIContext);
+
+ serverPeerObjectName = sc.registerAndConfigureService(serverPeerConfig);
+
+ overrideAttributes(serverPeerObjectName, attrOverrides);
+
+ // overwrite the config file security domain
+ sc.setAttribute(serverPeerObjectName, "SecurityDomain",
+ MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
+
+ sc.setAttribute(serverPeerObjectName,"SupportsFailover", supportsFailover?"true":"false");
+
+ log.debug("starting JMS server");
+
+ toStop.add(serverPeerObjectName);
+ sc.invoke(serverPeerObjectName, "create", new Object[0], new String[0]);
+ sc.invoke(serverPeerObjectName, "start", new Object[0], new String[0]);
+
+
+ MBeanConfigurationElement postOfficeConfig =
+ ServiceConfigHelper.getServiceConfiguration(pdd, "PostOffice");
+
+ postOfficeObjectName = sc.registerAndConfigureService(postOfficeConfig);
+ sc.setAttribute(postOfficeObjectName, "Clustered", clustered ? "true" : "false");
+
+ overrideAttributes(postOfficeObjectName, attrOverrides);
+ toStop.add(postOfficeObjectName);
+
+ sc.invoke(postOfficeObjectName, "create", new Object[0], new String[0]);
+ sc.invoke(postOfficeObjectName, "start", new Object[0], new String[0]);
+ log.debug("deploying connection factories");
+
+ sc.startConnectionFactories(attrOverrides);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to start", e);
+
+ //Now we need to shutdown any services we did start
+ for (int i = toStop.size() - 1; i >= 0; i--)
+ {
+ ObjectName on = (ObjectName)toStop.get(i);
+ log.info("stopping: " + on);
+ try
+ {
+ sc.unregisterService(on);
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+
+ throw e;
+ }
+ }
+
+ public void stopServerPeer() throws Exception
+ {
+ if (!isServerPeerStarted())
+ {
+ log.debug("messaging server was not started, so there is no stopping");
+ return;
+ }
+
+ try
+ {
+ // if we don't find a ServerPeer instance registered under the serverPeerObjectName
+ // ObjectName, we assume that the server was already stopped and we silently exit
+ if (sc.query(serverPeerObjectName).isEmpty())
+ {
+ log.warn("ServerPeer already stopped");
+ return;
+ }
+
+ // unbind the JCA ConnectionFactory; nothing happens if no connection factory is bound
+ sc.unbindJCAJMSConnectionFactory();
+ sc.unbindDefaultJMSProvider();
+
+ log.debug("stopping connection factories");
+
+ sc.stopConnectionFactories();
+
+ log.debug("stopping all destinations");
+
+ try
+ {
+ Set destinations = (Set)sc.getAttribute(serverPeerObjectName, "Destinations");
+
+ for(Iterator i = destinations.iterator(); i.hasNext(); )
+ {
+ String name;
+ boolean isQueue = true;
+ Destination d = (Destination)i.next();
+ if (d instanceof Queue)
+ {
+ name = ((Queue)d).getQueueName();
+ }
+ else
+ {
+ isQueue = false;
+ name = ((Topic)d).getTopicName();
+ }
+
+ try
+ {
+ undeployDestination(isQueue, name);
+ }
+ catch (Exception e)
+ {
+ //needs to be resilient
+ }
+ }
+ }
+ catch (Exception ignore)
+ {
+ //Needs to be resilient on close
+ }
+
+ log.debug("stopping JMS server");
+
+ try
+ {
+ sc.invoke(serverPeerObjectName, "stop", new Object[0], new String[0]);
+ sc.invoke(serverPeerObjectName, "destroy", new Object[0], new String[0]);
+ sc.unregisterService(serverPeerObjectName);
+ }
+ catch (Exception ignore)
+ {
+ //If the serverpeer failed when starting up previously, then only some of the
+ //services may be started. The ones that didn't start will fail when attempting to shut
+ //them down.
+ //Hence we must catch and ignore or we won't shut everything down
+ }
+
+ log.debug("stopping ServerPeer's plug-in dependencies");
+
+ try
+ {
+ sc.invoke(jmsUserManagerObjectName, "stop", new Object[0], new String[0]);
+ sc.invoke(jmsUserManagerObjectName, "destroy", new Object[0], new String[0]);
+ sc.unregisterService(jmsUserManagerObjectName);
+ }
+ catch (Exception ignore)
+ {
+ //If the serverpeer failed when starting up previously, then only some of the
+ //services may be started. The ones that didn't start will fail when attempting to shut
+ //them down.
+ //Hence we must catch and ignore or we won't shut everything down
+ }
+
+ try
+ {
+ sc.invoke(postOfficeObjectName, "stop", new Object[0], new String[0]);
+ sc.invoke(postOfficeObjectName, "destroy", new Object[0], new String[0]);
+ sc.unregisterService(postOfficeObjectName);
+ }
+ catch (Exception ignore)
+ {
+ //If the serverpeer failed when starting up previously, then only some of the
+ //services may be started. The ones that didn't start will fail when attempting to shut
+ //them down.
+ //Hence we must catch and ignore or we won't shut everything down
+ }
+
+ try
+ {
+ sc.invoke(persistenceManagerObjectName, "stop", new Object[0], new String[0]);
+ sc.invoke(persistenceManagerObjectName, "destroy", new Object[0], new String[0]);
+ sc.unregisterService(persistenceManagerObjectName);
+ }
+ catch (Exception ignore)
+ {
+ //If the serverpeer failed when starting up previously, then only some of the
+ //services may be started. The ones that didn't start will fail when attempting to shut
+ //them down.
+ //Hence we must catch and ignore or we won't shut everything down
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to stop server peer", e);
+ throw e;
+ }
+ }
+
+ public boolean isServerPeerStarted() throws Exception
+ {
+ if (sc.query(serverPeerObjectName).isEmpty())
+ {
+ return false;
+ }
+ ServerPeer sp = (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
+ sp.getVersion();
+ return true;
+ }
+
+ public ObjectName getServerPeerObjectName()
+ {
+ return serverPeerObjectName;
+ }
+
+ public Set getConnectorSubsystems() throws Exception
+ {
+ RemotingJMXWrapper remoting =
+ (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+
+ return remoting.getConnectorSubsystems();
+ }
+
+ public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
+ throws Exception
+ {
+ RemotingJMXWrapper remoting =
+ (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+
+ remoting.addInvocationHandler(subsystem, handler);
+ }
+
+ public void removeServerInvocationHandler(String subsystem) throws Exception
+ {
+ RemotingJMXWrapper remoting =
+ (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
+
+ remoting.removeInvocationHandler(subsystem);
+ }
+
+ /**
+ * Only for in-VM use!
+ */
+ public MessageStore getMessageStore() throws Exception
+ {
+ ServerPeer serverPeer = (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
+ return serverPeer.getMessageStore();
+ }
+
+ public DestinationManager getDestinationManager() throws Exception
+ {
+ ServerPeer serverPeer = (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
+ return serverPeer.getDestinationManager();
+ }
+
+ public PersistenceManager getPersistenceManager() throws Exception
+ {
+ ServerPeer serverPeer = (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
+ return serverPeer.getPersistenceManagerInstance();
+ }
+
+ /**
+ * Only for in-VM use!
+ */
+ public ServerPeer getServerPeer() throws Exception
+ {
+ return (ServerPeer)sc.
+ getAttribute(serverPeerObjectName, "Instance");
+ }
+
+ public void deployTopic(String name, String jndiName, boolean clustered) throws Exception
+ {
+ deployDestination(false, name, jndiName, clustered);
+ }
+
+ public void deployTopic(String name, String jndiName, int fullSize, int pageSize,
+ int downCacheSize, boolean clustered) throws Exception
+ {
+ deployDestination(false, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
+ }
+
+ public void deployTopicProgrammatically(String name, String jndiName) throws Exception
+ {
+ sc.invoke(serverPeerObjectName, "deployTopic",
+ new Object[] { name, jndiName },
+ new String[] { "java.lang.String", "java.lang.String"} );
+ }
+
+ public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
+ {
+ deployDestination(true, name, jndiName, clustered);
+ }
+
+ public void deployQueue(String name, String jndiName, int fullSize, int pageSize,
+ int downCacheSize, boolean clustered) throws Exception
+ {
+ deployDestination(true, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
+ }
+
+ public void deployQueueProgrammatically(String name, String jndiName) throws Exception
+ {
+ sc.invoke(serverPeerObjectName, "deployQueue",
+ new Object[] { name, jndiName },
+ new String[] { "java.lang.String", "java.lang.String"} );
+ }
+
+ public void deployDestination(boolean isQueue, String name, String jndiName, boolean clustered) throws Exception
+ {
+ String config =
+ "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
+ " name=\"jboss.messaging.destination:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name + "\"" +
+ " xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
+ (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
+ "</mbean>";
+
+ MBeanConfigurationElement mbean =
+ new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName deston = sc.registerAndConfigureService(mbean);
+ sc.invoke(deston, "create", new Object[0], new String[0]);
+ sc.invoke(deston, "start", new Object[0], new String[0]);
+ }
+
+ public void deployDestination(boolean isQueue,
+ String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ boolean clustered) throws Exception
+ {
+ log.info("deploying queue, fullsize:" + fullSize + ", ps:" + pageSize + " dc size:" + downCacheSize);
+
+ String config =
+ "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
+ " name=\"jboss.messaging.destination:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name + "\"" +
+ " xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
+ (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
+ " <attribute name=\"FullSize\">" + fullSize + "</attribute>" +
+ " <attribute name=\"PageSize\">" + pageSize + "</attribute>" +
+ " <attribute name=\"DownCacheSize\">" + downCacheSize + "</attribute>" +
+ " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
+ "</mbean>";
+
+ MBeanConfigurationElement mbean =
+ new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName deston = sc.registerAndConfigureService(mbean);
+ sc.invoke(deston, "create", new Object[0], new String[0]);
+ sc.invoke(deston, "start", new Object[0], new String[0]);
+ }
+
+ public void undeployDestination(boolean isQueue, String name) throws Exception
+ {
+ ObjectName pattern =
+ new ObjectName("*:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name);
+ Set s = sc.query(pattern);
+ int size = s.size();
+ if (size == 0)
+ {
+ log.debug("No such " + (isQueue ? "queue" : "topic") + " to undeploy: " + name);
+ return;
+ }
+ if (size > 1)
+ {
+ throw new Exception("Too many destination with the same name: " + name);
+ }
+ ObjectName destinationObjectName = (ObjectName)s.iterator().next();
+ sc.invoke(destinationObjectName, "stop", new Object[0], new String[0]);
+ sc.invoke(destinationObjectName, "destroy", new Object[0], new String[0]);
+ sc.unregisterService(destinationObjectName);
+ }
+
+ public boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception
+ {
+ if (isQueue)
+ {
+ return ((Boolean)sc.invoke(serverPeerObjectName, "undeployQueue",
+ new Object[] { name },
+ new String[] { "java.lang.String"})).booleanValue();
+ }
+ else
+ {
+ return ((Boolean)sc.invoke(serverPeerObjectName, "undeployTopic",
+ new Object[] { name },
+ new String[] { "java.lang.String"})).booleanValue();
+ }
+ }
+
+ public void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ int prefetchSize) throws Exception
+ {
+ deployConnectionFactory(objectName, jndiBindings, prefetchSize, -1, -1, -1, false, false);
+ }
+
+ public void deployConnectionFactory(String objectName,
+ String[] jndiBindings) throws Exception
+ {
+ deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false);
+ }
+
+ public void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ int prefetchSize,
+ int defaultTempQueueFullSize,
+ int defaultTempQueuePageSize,
+ int defaultTempQueueDownCacheSize) throws Exception
+ {
+ this.deployConnectionFactory(objectName, jndiBindings, prefetchSize, defaultTempQueueFullSize,
+ defaultTempQueuePageSize, defaultTempQueueDownCacheSize, false, false);
+ }
+
+ public void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
+ {
+ this.deployConnectionFactory(objectName, jndiBindings, -1, -1,
+ -1, -1, supportsFailover, supportsLoadBalancing);
+ }
+
+ private void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ int prefetchSize,
+ int defaultTempQueueFullSize,
+ int defaultTempQueuePageSize,
+ int defaultTempQueueDownCacheSize,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing) throws Exception
+ {
+ log.trace("deploying connection factory with name: " + objectName);
+
+ String config =
+ "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" +
+ "name=\"" + objectName + "\"\n" +
+ "xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n" +
+ "<depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
+ "<depends optional-attribute-name=\"Connector\">" + ServiceContainer.REMOTING_OBJECT_NAME +
+ "</depends>\n";
+
+ if (defaultTempQueueFullSize != -1)
+ {
+ config += "<attribute name=\"DefaultTempQueueFullSize\">" + defaultTempQueueFullSize + "</attribute>\n";
+ }
+
+ if (defaultTempQueuePageSize != -1)
+ {
+ config += "<attribute name=\"DefaultTempQueuePageSize\">" + defaultTempQueuePageSize + "</attribute>\n";
+ }
+
+ if (defaultTempQueueDownCacheSize != -1)
+ {
+ config += "<attribute name=\"DefaultTempQueueDownCacheSize\">" + defaultTempQueueDownCacheSize + "</attribute>\n";
+ }
+
+ if (prefetchSize != -1)
+ {
+ config += "<attribute name=\"PrefetchSize\">" + prefetchSize + "</attribute>";
+ }
+
+ config += "<attribute name=\"SupportsFailover\">" + supportsFailover + "</attribute>";
+ config += "<attribute name=\"SupportsLoadBalancing\">" + supportsLoadBalancing + "</attribute>";
+
+ if (jndiBindings != null)
+ {
+ config += "<attribute name=\"JNDIBindings\"><bindings>";
+
+ for (int i = 0; i < jndiBindings.length; i++)
+ {
+ config += "<binding>" + jndiBindings[i] + "</binding>\n";
+ }
+ config += "</bindings></attribute>";
+ }
+ config += "</mbean>";
+
+ MBeanConfigurationElement mc = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
+ ObjectName on = sc.registerAndConfigureService(mc);
+
+ log.trace("Object name is now: " + on);
+
+ sc.invoke(on, "create", new Object[0], new String[0]);
+ sc.invoke(on, "start", new Object[0], new String[0]);
+ }
+
+ public void undeployConnectionFactory(ObjectName objectName) throws Exception
+ {
+ sc.invoke(objectName, "stop", new Object[0], new String[0]);
+ sc.invoke(objectName, "destroy", new Object[0], new String[0]);
+ sc.unregisterService(objectName);
+ }
+
+ public void configureSecurityForDestination(String destName, String config) throws Exception
+ {
+ Set s = sc.query(new ObjectName("*:service=Queue,name=" + destName));
+ for(Iterator i = s.iterator(); i.hasNext();)
+ {
+ ObjectName on = (ObjectName)i.next();
+ sc.setAttribute(on, "SecurityConfig", config);
+ }
+
+ s = sc.query(new ObjectName("*:service=Topic,name=" + destName));
+ for(Iterator i = s.iterator(); i.hasNext();)
+ {
+ ObjectName on = (ObjectName)i.next();
+ sc.setAttribute(on, "SecurityConfig", config);
+ }
+ }
+
+ public void setDefaultSecurityConfig(String config) throws Exception
+ {
+ sc.setAttribute(serverPeerObjectName, "DefaultSecurityConfig", config);
+ }
+
+ public String getDefaultSecurityConfig() throws Exception
+ {
+ Element element = (Element)sc.getAttribute(serverPeerObjectName, "DefaultSecurityConfig");
+ return XMLUtil.elementToString(element);
+ }
+
+ public Object executeCommand(Command command) throws Exception
+ {
+ return command.execute();
+ }
+
+ public UserTransaction getUserTransaction() throws Exception
+ {
+ return sc.getUserTransaction();
+ }
+
+ public Set getNodeIDView() throws Exception
+ {
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.nodeIDView();
+ }
+
+ public Map getFailoverMap() throws Exception
+ {
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getFailoverMap();
+ }
+
+ public Map getRecoveryArea(String queueName) throws Exception
+ {
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getRecoveryArea(queueName);
+ }
+
+ public int getRecoveryMapSize(String queueName) throws Exception
+ {
+ PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
+
+ return postOffice.getRecoveryMapSize(queueName);
+ }
+
+ public List pollNotificationListener(long listenerID) throws Exception
+ {
+ throw new IllegalStateException("Poll doesn't make sense on a local server. " +
+ "Register listeners directly instead.");
+ }
+
+ public void poisonTheServer(int type) throws Exception
+ {
+ URL url = this.getClass().getClassLoader().getResource("poison.xml");
+ AspectXmlLoader.deployXML(url);
+
+ log.debug(url + " deployed");
+
+ PoisonInterceptor.setType(type);
+ }
+
+ public void flushManagedConnectionPool()
+ {
+ sc.flushManagedConnectionPool();
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected ServiceContainer getServiceContainer()
+ {
+ return sc;
+ }
+
+ protected void overrideServerPeerConfiguration(MBeanConfigurationElement config,
+ int serverPeerID, String defaultQueueJNDIContext, String defaultTopicJNDIContext)
+ throws Exception
+ {
+ config.setAttribute("ServerPeerID", Integer.toString(serverPeerID));
+ config.setAttribute("DefaultQueueJNDIContext",
+ defaultQueueJNDIContext == null ? "/queue" : defaultQueueJNDIContext);
+ config.setAttribute("DefaultTopicJNDIContext",
+ defaultTopicJNDIContext == null? "/topic" : defaultTopicJNDIContext);
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides)
+ throws Exception
+ {
+ if (attrOverrides == null)
+ {
+ return;
+ }
+
+ Map sao = attrOverrides.get(on);
+
+ for(Iterator i = sao.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String attrName = (String)entry.getKey();
+ Object attrValue = entry.getValue();
+ sc.setAttribute(on, attrName, attrValue.toString());
+
+ }
+ }
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/MBeanServerBuilder.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/MBeanServerBuilder.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/MBeanServerBuilder.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/MBeanServerBuilder.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,57 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.tools.container;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerDelegate;
+
+import org.jboss.mx.server.MBeanServerImpl;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class MBeanServerBuilder extends javax.management.MBeanServerBuilder
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public MBeanServerBuilder()
+ {
+ }
+
+ // MBeanServerBuilder overrides ----------------------------------
+
+ public MBeanServer newMBeanServer(String defaultDomain,
+ MBeanServer outer,
+ MBeanServerDelegate delegate)
+ {
+ return new MBeanServerImpl("jboss", outer, delegate);
+ }
+
+ public MBeanServerDelegate newMBeanServerDelegate()
+ {
+ return new MBeanServerDelegate();
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/ManagedConnectionFactoryJMXWrapper.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapper.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ManagedConnectionFactoryJMXWrapper.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ManagedConnectionFactoryJMXWrapper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanNotificationInfo;
+import javax.management.NotificationBroadcaster;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.resource.spi.ManagedConnectionFactory;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ManagedConnectionFactoryJMXWrapper
+ implements ManagedConnectionFactoryJMXWrapperMBean, NotificationBroadcaster
+{
+
+ // Attributes ----------------------------------------------------
+
+ private ManagedConnectionFactory mcf;
+ private List listeners;
+
+ // Constructors --------------------------------------------------
+
+ public ManagedConnectionFactoryJMXWrapper(ManagedConnectionFactory mcf)
+ {
+ this.mcf = mcf;
+ listeners = new ArrayList();
+ }
+
+ // ManagedConnectionFactoryJMXWrapperMBean implementation --------
+
+ public ManagedConnectionFactory getManagedConnectionFactory()
+ {
+ return mcf;
+ }
+
+ public ManagedConnectionFactory getMcfInstance()
+ {
+ return mcf;
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop() throws Exception
+ {
+ }
+
+ // NotificationBroadcaster implementation ------------------------
+
+ public void addNotificationListener(NotificationListener listener, NotificationFilter filter,
+ Object handback) throws IllegalArgumentException
+ {
+ listeners.add(listener);
+ }
+
+ public void removeNotificationListener(NotificationListener listener)
+ throws ListenerNotFoundException
+ {
+ listeners.remove(listener);
+ }
+
+ public MBeanNotificationInfo[] getNotificationInfo()
+ {
+ return new MBeanNotificationInfo[0];
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/ManagedConnectionFactoryJMXWrapperMBean.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapperMBean.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ManagedConnectionFactoryJMXWrapperMBean.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ManagedConnectionFactoryJMXWrapperMBean.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import javax.resource.spi.ManagedConnectionFactory;
+
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public interface ManagedConnectionFactoryJMXWrapperMBean
+{
+
+ ManagedConnectionFactory getManagedConnectionFactory();
+ ManagedConnectionFactory getMcfInstance();
+
+ void start() throws Exception;
+ void stop() throws Exception;
+
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/MockJBossSecurityManager.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/MockJBossSecurityManager.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/MockJBossSecurityManager.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,350 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+
+import org.jboss.logging.Logger;
+import org.jboss.security.AnybodyPrincipal;
+import org.jboss.security.AuthenticationManager;
+import org.jboss.security.NobodyPrincipal;
+import org.jboss.security.RealmMapping;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimpleGroup;
+import org.jboss.security.SimplePrincipal;
+
+
+/**
+ * Mock Security manager for testing JMS security.
+ *
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ *
+ */
+public class MockJBossSecurityManager implements AuthenticationManager, RealmMapping
+{
+ public static final String TEST_SECURITY_DOMAIN = "messaging-securitydomain";
+
+ private static final Logger log = Logger.getLogger(MockJBossSecurityManager.class);
+
+ private boolean simulateJBossJaasSecurityManager;
+
+ //Authentication Manager Implementation
+
+ public String getSecurityDomain()
+ {
+ return TEST_SECURITY_DOMAIN;
+ }
+
+ public boolean isValid(Principal principal, Object credential)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isValid(Principal principal, Object credential, Subject activeSubject)
+ {
+ if (log.isTraceEnabled()) { log.trace("principal:" + principal + " credential:" + credential); }
+
+ boolean isValid = false;
+
+ String username = principal == null ? null : principal.getName();
+ char[] passwordChars = (char[])credential;
+ String password = passwordChars == null ? null : new String(passwordChars);
+
+ if (username == null)
+ {
+ isValid = true;
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "guest");
+ }
+ }
+ else if ("guest".equals(username))
+ {
+ isValid = "guest".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "guest");
+ }
+ }
+ else if ("john".equals(username))
+ {
+ isValid = "needle".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "publisher");
+ addRole(activeSubject, "durpublisher");
+ addRole(activeSubject, "def");
+ }
+ }
+ // We use this user with pre-configured clientIds
+ else if ("dilbert".equals(username))
+ {
+ isValid = "dogbert".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ addRole(activeSubject, "publisher");
+ addRole(activeSubject, "durpublisher");
+ addRole(activeSubject, "def");
+ }
+ }
+ else if ("nobody".equals(username))
+ {
+ isValid = "nobody".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "noacc");
+ }
+ }
+ else if ("dynsub".equals(username))
+ {
+ isValid = "dynsub".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "publisher");
+ addRole(activeSubject, "durpublisher");
+ }
+ }
+ else
+ {
+ isValid = false;
+ }
+
+ return isValid;
+ }
+
+ public Subject getActiveSubject()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ //RealmMapping implementation
+
+ public Principal getPrincipal(Principal principal)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private boolean containsRole(String roleName, Set roles)
+ {
+ Iterator iter = roles.iterator();
+ while (iter.hasNext())
+ {
+ Principal p = (Principal)iter.next();
+ if (p.getName().equals(roleName))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean doesUserHaveRole(Principal principal, Set roles)
+ {
+ // introduced the possiblity to "simulate" JaasSecurityManager behavior, which is ingnoring
+ // the principal passed as argument and looking at thread context for active subject; this
+ // would allow us to catch some problems earlier at functional testsuite level, and not
+ // wait for integration or smoke test. However, the "correct" place for this kind of test
+ // is at integration testsuite level.
+
+ if (simulateJBossJaasSecurityManager)
+ {
+ boolean hasRole = false;
+ // check that the caller is authenticated to the current thread
+ Subject subject = SecurityAssociation.getSubject();
+
+ if (subject != null)
+ {
+ // Check the caller's roles
+ Group subjectRoles = getSubjectRoles(subject);
+ if (subjectRoles != null)
+ {
+ Iterator iter = roles.iterator();
+ while (!hasRole && iter.hasNext())
+ {
+ Principal role = (Principal)iter.next();
+ hasRole = doesRoleGroupHaveRole(role, subjectRoles);
+ }
+ }
+ }
+ return hasRole;
+ }
+ else
+ {
+ // "alternate" MockJBossSecurityManager behavior, we actually look at 'principal' passed as
+ // parameter
+
+ String username = principal == null ? "guest" : principal.getName();
+
+ if (log.isTraceEnabled())
+ {
+ log.trace("doesUserHaveRole:" + username);
+ }
+
+ if ("guest".equals(username))
+ {
+ return containsRole("guest", roles);
+ }
+ else if ("john".equals(username))
+ {
+ return containsRole("publisher", roles) ||
+ containsRole("durpublisher", roles) ||
+ containsRole("def", roles);
+ }
+ else if ("dynsub".equals(username))
+ {
+ return containsRole("publisher", roles)||
+ containsRole("durpublisher", roles);
+ }
+ else if ("nobody".equals(username))
+ {
+ return containsRole("noacc", roles);
+ }
+ else if ("dilbert".equals(username))
+ {
+ return containsRole("durpublisher", roles);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ public Set getUserRoles(Principal principal)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setSimulateJBossJaasSecurityManager(boolean b)
+ {
+ simulateJBossJaasSecurityManager = b;
+ }
+
+ public boolean isSimulateJBossJaasSecurityManager()
+ {
+ return simulateJBossJaasSecurityManager;
+ }
+
+ /**
+ * Copied from JaasSecurityManager.
+ */
+ private Group getSubjectRoles(Subject subject)
+ {
+ Set subjectGroups = subject.getPrincipals(Group.class);
+ Iterator iter = subjectGroups.iterator();
+ Group roles = null;
+ while (iter.hasNext())
+ {
+ Group grp = (Group)iter.next();
+ String name = grp.getName();
+ if (name.equals("Roles"))
+ {
+ roles = grp;
+ }
+ }
+ return roles;
+ }
+
+ /**
+ * Copied from JaasSecurityManager.
+ */
+ private boolean doesRoleGroupHaveRole(Principal role, Group userRoles)
+ {
+ // First check that role is not a NobodyPrincipal
+ if (role instanceof NobodyPrincipal)
+ {
+ return false;
+ }
+
+ // Check for inclusion in the user's role set
+ boolean isMember = userRoles.isMember(role);
+ if (!isMember)
+ {
+ // Check the AnybodyPrincipal special cases
+ isMember = (role instanceof AnybodyPrincipal);
+ }
+
+ return isMember;
+ }
+
+ private void addRole(Subject subject, String role)
+ {
+ Set groups = subject.getPrincipals(Group.class);
+
+ if(groups == null || groups.isEmpty())
+ {
+ Group g = new SimpleGroup("Roles");
+ subject.getPrincipals().add(g);
+ groups = new HashSet();
+ groups.add(g);
+ }
+
+ Group roles = null;
+
+ for(Iterator i = groups.iterator(); i.hasNext(); )
+ {
+ Group g = (Group)i.next();
+ if ("Roles".equals(g.getName()))
+ {
+ roles = g;
+ }
+ }
+
+ if (roles == null)
+ {
+ roles = new SimpleGroup("Roles");
+ subject.getPrincipals().add(roles);
+ }
+
+ roles.addMember(new SimplePrincipal(role));
+
+ }
+
+}
\ No newline at end of file
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/NamingDelegate.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/NamingDelegate.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/NamingDelegate.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.rmi.Remote;
+
+/**
+ * The remote naming interface.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: NamingDelegate.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public interface NamingDelegate extends Remote
+{
+ Object lookup(String name) throws Exception;
+
+ void bind(String name, Object obj) throws Exception;
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/NoopInvoker.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/NoopInvoker.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/NoopInvoker.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/NoopInvoker.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.io.Serializable;
+
+import org.jboss.invocation.Invocation;
+import org.jboss.invocation.Invoker;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+class NoopInvoker implements Serializable, Invoker
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = -7508123339922333502L;
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Invoker implementation ----------------------------------------
+
+ public String getServerHostName() throws Exception
+ {
+ return "localhost";
+ }
+
+ public Object invoke(Invocation invocation) throws Exception
+ {
+ return null;
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/NotificationListenerID.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/NotificationListenerID.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/NotificationListenerID.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,59 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.tools.container;
+
+import java.io.Serializable;
+
+import javax.management.Notification;
+import javax.management.NotificationListener;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ * $Id: NotificationListenerID.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class NotificationListenerID implements Serializable, NotificationListener
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = -39839086486546L;
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private long id;
+
+ // Constructors --------------------------------------------------
+
+ public NotificationListenerID(long id)
+ {
+ this.id = id;
+ }
+
+ // NotificationListener implementation ---------------------------
+
+ public void handleNotification(Notification notification, Object object)
+ {
+ throw new IllegalStateException("Do not use this method directly!");
+ }
+
+ // Public --------------------------------------------------------
+
+ public long getID()
+ {
+ return id;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/ProxyNotificationListener.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ProxyNotificationListener.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ProxyNotificationListener.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,68 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.tools.container;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.management.Notification;
+import javax.management.NotificationListener;
+
+/**
+ * Stores notifications until they're transferred to the remote client.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ * $Id: ProxyNotificationListener.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class ProxyNotificationListener implements NotificationListener
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private List notifications;
+
+ // Constructors --------------------------------------------------
+
+ ProxyNotificationListener()
+ {
+ notifications = new ArrayList();
+ }
+
+ // NotificationListener implementation ---------------------------
+
+ public synchronized void handleNotification(Notification notification, Object object)
+ {
+ notifications.add(notification);
+ }
+
+ // Public --------------------------------------------------------
+
+ public synchronized List drain()
+ {
+ if (notifications.size() == 0)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ List old = notifications;
+ notifications = new ArrayList();
+ return old;
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/RMINamingDelegate.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RMINamingDelegate.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RMINamingDelegate.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,109 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+
+
+import java.rmi.server.UnicastRemoteObject;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: RMINamingDelegate.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class RMINamingDelegate extends UnicastRemoteObject implements NamingDelegate
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = -7123818911636174877L;
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private InitialContextAccess ica;
+ private int serverIndex;
+
+ // Constructors --------------------------------------------------
+
+ public RMINamingDelegate(int serverIndex) throws Exception
+ {
+ super();
+ this.serverIndex = serverIndex;
+ ica = new InitialContextAccess();
+ }
+
+ // NamingDelegate implementation ---------------------------------
+
+ public Object lookup(String name) throws Exception
+ {
+ return getInitialContext().lookup(name);
+ }
+
+ public void bind(String name, Object obj) throws Exception
+ {
+ getInitialContext().bind(name, obj);
+ }
+
+ // Public --------------------------------------------------------
+
+ public void reset()
+ {
+ ica.reset();
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private InitialContext getInitialContext() throws NamingException
+ {
+ return ica.getInitialContext();
+ }
+
+ // Inner classes -------------------------------------------------
+
+ private class InitialContextAccess
+ {
+ private InitialContext ic;
+
+ InitialContext getInitialContext() throws NamingException
+ {
+ if (ic == null)
+ {
+ ic = new InitialContext(InVMInitialContextFactory.getJNDIEnvironment(serverIndex));
+ }
+ return ic;
+ }
+
+ public void reset()
+ {
+ ic = null;
+ }
+ }
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RMITestServer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,564 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * 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.test.messaging.tools.container;
+
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.transaction.UserTransaction;
+
+import org.jboss.jms.server.DestinationManager;
+import org.jboss.jms.server.ServerPeer;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.contract.MessageStore;
+import org.jboss.messaging.core.contract.PersistenceManager;
+import org.jboss.remoting.ServerInvocationHandler;
+
+/**
+ * An RMI wrapper to access the ServiceContainer from a different address space.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
+ * @version <tt>1.1</tt>
+ *
+ * RMITestServer.java,v 1.1 2006/02/21 08:25:33 timfox Exp
+ */
+public class RMITestServer extends UnicastRemoteObject implements Server
+{
+ // Constants -----------------------------------------------------
+
+ public static final String RMI_SERVER_PREFIX = "messaging_rmi_server_";
+ public static final String NAMING_SERVER_PREFIX = "naming_rmi_server_";
+
+ public static final int DEFAULT_REGISTRY_PORT = 33777;
+ public static final int DEFAULT_SERVER_INDEX = 0;
+ public static final String DEFAULT_SERVER_HOST = "localhost";
+
+ private static final long serialVersionUID = -368445344011004778L;
+ private static final Logger log = Logger.getLogger(RMITestServer.class);
+
+ // Static --------------------------------------------------------
+
+ public static void main(String[] args) throws Exception
+ {
+ log.debug("initializing RMI runtime");
+
+ String host = System.getProperty("test.bind.address");
+
+ if (host == null)
+ {
+ host = DEFAULT_SERVER_HOST;
+ }
+
+ int serverIndex = DEFAULT_SERVER_INDEX;
+
+ String s = System.getProperty("test.server.index");
+
+ if (s != null)
+ {
+ serverIndex = Integer.parseInt(s);
+ }
+
+ log.info("RMI server " + serverIndex + ", bind address " + host);
+
+ RMITestServer testServer = new RMITestServer(serverIndex);
+ log.debug("RMI server " + serverIndex + " created");
+
+ // let RMI know the bind address
+ System.setProperty("java.rmi.server.hostname", host);
+
+ Registry registry;
+
+ // try to bind first
+ try
+ {
+ registry = LocateRegistry.getRegistry(DEFAULT_REGISTRY_PORT);
+ registry.bind(RMI_SERVER_PREFIX + serverIndex, testServer);
+ registry.bind(NAMING_SERVER_PREFIX + serverIndex, testServer.getNamingDelegate());
+
+ }
+ catch(Exception e)
+ {
+ log.info("Failure using an existing registry, trying creating it");
+
+ // try to create it
+ registry = LocateRegistry.createRegistry(DEFAULT_REGISTRY_PORT);
+
+ registry.bind(RMI_SERVER_PREFIX + serverIndex, testServer);
+ registry.bind(NAMING_SERVER_PREFIX + serverIndex, testServer.getNamingDelegate());
+ }
+
+ log.info("RMI server " + serverIndex + " bound");
+
+ // there is one crash test that needs to start the server, as an external VM...
+ // as one client will crash while another will be alive
+ boolean startAll=false;
+
+ for (int i=0;i<args.length;i++)
+ {
+ if (args[i].equals("-startAll"))
+ {
+ startAll=true;
+ }
+ }
+
+ if (startAll)
+ {
+ testServer.start("all", true);
+ }
+ }
+
+ // Attributes ----------------------------------------------------
+
+ protected RemoteTestServer server;
+ private RMINamingDelegate namingDelegate;
+ // Map<Long-ProxyNotificationListener>
+ private Map proxyListeners;
+
+ // Constructors --------------------------------------------------
+
+ public RMITestServer(int index) throws Exception
+ {
+ namingDelegate = new RMINamingDelegate(index);
+ server = new RemoteTestServer(index);
+ proxyListeners = new HashMap();
+ }
+
+ // Server implementation -----------------------------------------
+
+ public int getServerID()
+ {
+ return server.getServerID();
+ }
+
+ public void start(String containerConfig, boolean clearDatabase) throws Exception
+ {
+ start(containerConfig, null, clearDatabase, true);
+ }
+
+ public void start(String containerConfig, ServiceAttributeOverrides attrOverrides,
+ boolean clearDatabase, boolean startMessagingServer) throws Exception
+ {
+ server.start(containerConfig, attrOverrides, clearDatabase, startMessagingServer);
+ }
+
+ public boolean stop() throws Exception
+ {
+ boolean result = server.stop();
+ namingDelegate.reset();
+ return result;
+ }
+
+ public synchronized void kill() throws Exception
+ {
+ //We deregister in another thread, them pause, then kill the VM
+ //This ensures if the deregister hangs (which can happen if the RMI registry is dead) then it doesn't prevent
+ //the kill
+ //We always kill on this thread to ensure the kill completes in a timely manner which may not occur if it occurs
+ //on its own thread due to thread scheduling differences
+ new Thread(new Deregisterer(), "Deregisterer").start();
+
+ log.info("Killing VM!!!!");
+
+ Thread.sleep(250);
+
+ System.exit(0);
+ }
+
+ public void ping() throws Exception
+ {
+ //noop - nothing to be done
+ }
+
+ public ObjectName deploy(String mbeanConfiguration) throws Exception
+ {
+ return server.deploy(mbeanConfiguration);
+ }
+
+ public void undeploy(ObjectName on) throws Exception
+ {
+ server.undeploy(on);
+ }
+
+ public Object getAttribute(ObjectName on, String attribute) throws Exception
+ {
+ return server.getAttribute(on, attribute);
+ }
+
+ public void setAttribute(ObjectName on, String name, String valueAsString) throws Exception
+ {
+ server.setAttribute(on, name, valueAsString);
+ }
+
+ public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
+ throws Exception
+ {
+ return server.invoke(on, operationName, params, signature);
+ }
+
+ public void addNotificationListener(ObjectName on, NotificationListener listener)
+ throws Exception
+ {
+ if (!(listener instanceof NotificationListenerID))
+ {
+ throw new IllegalArgumentException("A RMITestServer can only handle NotificationListenerIDs!");
+ }
+
+ long id = ((NotificationListenerID)listener).getID();
+
+ ProxyNotificationListener pl = new ProxyNotificationListener();
+
+ synchronized(proxyListeners)
+ {
+ proxyListeners.put(new Long(id), pl);
+ }
+
+ server.addNotificationListener(on, pl);
+ }
+
+ public void removeNotificationListener(ObjectName on, NotificationListener listener)
+ throws Exception
+ {
+
+ if (!(listener instanceof NotificationListenerID))
+ {
+ throw new IllegalArgumentException("A RMITestServer can only handle NotificationListenerIDs!");
+ }
+
+ long id = ((NotificationListenerID)listener).getID();
+
+ ProxyNotificationListener pl = null;
+
+ synchronized(proxyListeners)
+ {
+ pl = (ProxyNotificationListener)proxyListeners.remove(new Long(id));
+ }
+
+ server.removeNotificationListener(on, pl);
+ }
+
+ public Set query(ObjectName pattern) throws Exception
+ {
+ return server.query(pattern);
+ }
+
+ public String getRemotingTransport()
+ {
+ return server.getRemotingTransport();
+ }
+
+ public void log(int level, String text) throws Exception
+ {
+ server.log(level, text);
+ }
+
+ public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
+ String defaultTopicJNDIContext, boolean clustered, boolean supportsFailover) throws Exception
+ {
+ startServerPeer(serverPeerID, defaultQueueJNDIContext,
+ defaultTopicJNDIContext, null, clustered, supportsFailover);
+ }
+
+
+ public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
+ String defaultTopicJNDIContext,
+ ServiceAttributeOverrides attrOverrides, boolean clustered,
+ boolean supportsFailover)
+ throws Exception
+ {
+ server.startServerPeer(serverPeerID, defaultQueueJNDIContext,
+ defaultTopicJNDIContext, attrOverrides, clustered, supportsFailover);
+ }
+
+ public void stopServerPeer() throws Exception
+ {
+ server.stopServerPeer();
+ }
+
+ public boolean isServerPeerStarted() throws Exception
+ {
+ return server.isServerPeerStarted();
+ }
+
+ public ObjectName getServerPeerObjectName() throws Exception
+ {
+ return server.getServerPeerObjectName();
+ }
+
+ public boolean isStarted() throws Exception
+ {
+ return server.isStarted();
+ }
+
+ public Set getConnectorSubsystems() throws Exception
+ {
+ return server.getConnectorSubsystems();
+ }
+
+ public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
+ throws Exception
+ {
+ server.addServerInvocationHandler(subsystem, handler);
+ }
+
+ public void removeServerInvocationHandler(String subsystem) throws Exception
+ {
+ server.removeServerInvocationHandler(subsystem);
+ }
+
+ public MessageStore getMessageStore() throws Exception
+ {
+ return server.getMessageStore();
+ }
+
+ public DestinationManager getDestinationManager() throws Exception
+ {
+ return server.getDestinationManager();
+ }
+
+ public PersistenceManager getPersistenceManager() throws Exception
+ {
+ return server.getPersistenceManager();
+ }
+
+ public ServerPeer getServerPeer() throws Exception
+ {
+ return server.getServerPeer();
+ }
+
+ public void deployTopic(String name, String jndiName, boolean clustered) throws Exception
+ {
+ server.deployTopic(name, jndiName, clustered);
+ }
+
+ public void deployTopic(String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ boolean clustered) throws Exception
+ {
+ server.deployTopic(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
+ }
+
+ public void deployTopicProgrammatically(String name, String jndiName) throws Exception
+ {
+ server.deployTopicProgrammatically(name, jndiName);
+ }
+
+ public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
+ {
+ server.deployQueue(name, jndiName, clustered);
+ }
+
+ public void deployQueue(String name,
+ String jndiName,
+ int fullSize,
+ int pageSize,
+ int downCacheSize,
+ boolean clustered) throws Exception
+ {
+ server.deployQueue(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
+ }
+
+ public void deployQueueProgrammatically(String name, String jndiName) throws Exception
+ {
+ server.deployQueueProgrammatically(name, jndiName);
+ }
+
+ public void undeployDestination(boolean isQueue, String name) throws Exception
+ {
+ server.undeployDestination(isQueue, name);
+ }
+
+ public boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception
+ {
+ return server.undeployDestinationProgrammatically(isQueue, name);
+ }
+
+ public void deployConnectionFactory(String objectName, String[] jndiBindings)
+ throws Exception
+ {
+ server.deployConnectionFactory(objectName, jndiBindings);
+ }
+
+ public void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize)
+ throws Exception
+ {
+ server.deployConnectionFactory(objectName, jndiBindings, prefetchSize);
+ }
+
+ public void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ int prefetchSize,
+ int defaultTempQueueFullSize,
+ int defaultTempQueuePageSize,
+ int defaultTempQueueDownCacheSize) throws Exception
+ {
+ server.deployConnectionFactory(objectName, jndiBindings, prefetchSize,
+ defaultTempQueueFullSize, defaultTempQueuePageSize, defaultTempQueueDownCacheSize);
+ }
+
+ public void deployConnectionFactory(String objectName,
+ String[] jndiBindings, boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
+ {
+ server.deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing);
+ }
+
+ public void undeployConnectionFactory(ObjectName objectName) throws Exception
+ {
+ server.undeployConnectionFactory(objectName);
+ }
+
+ public void configureSecurityForDestination(String destName, String config) throws Exception
+ {
+ server.configureSecurityForDestination(destName, config);
+ }
+
+ public void setDefaultSecurityConfig(String config) throws Exception
+ {
+ server.setDefaultSecurityConfig(config);
+ }
+
+ public String getDefaultSecurityConfig() throws Exception
+ {
+ return server.getDefaultSecurityConfig();
+ }
+
+ public Object executeCommand(Command command) throws Exception
+ {
+ return server.executeCommand(command);
+ }
+
+ public UserTransaction getUserTransaction() throws Exception
+ {
+ return server.getUserTransaction();
+ }
+
+ public Set getNodeIDView() throws Exception
+ {
+ return server.getNodeIDView();
+ }
+
+ public Map getFailoverMap() throws Exception
+ {
+ return server.getFailoverMap();
+ }
+
+ public Map getRecoveryArea(String queueName) throws Exception
+ {
+ return server.getRecoveryArea(queueName);
+ }
+
+ public int getRecoveryMapSize(String queueName) throws Exception
+ {
+ return server.getRecoveryMapSize(queueName);
+ }
+
+ public List pollNotificationListener(long listenerID) throws Exception
+ {
+ ProxyNotificationListener pl = null;
+
+ synchronized(proxyListeners)
+ {
+ pl = (ProxyNotificationListener)proxyListeners.get(new Long(listenerID));
+ }
+
+ if (pl == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ return pl.drain();
+ }
+
+ public void poisonTheServer(int type) throws Exception
+ {
+ server.poisonTheServer(type);
+ }
+
+ public void flushManagedConnectionPool()
+ {
+ server.flushManagedConnectionPool();
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private RMINamingDelegate getNamingDelegate()
+ {
+ return namingDelegate;
+ }
+
+ // Inner classes -------------------------------------------------
+
+ public class Deregisterer implements Runnable
+ {
+ public void run()
+ {
+ log.info("Deregistering from RMI");
+
+ try
+ {
+ // unregister myself from the RMI registry
+
+ Registry registry = LocateRegistry.getRegistry(DEFAULT_REGISTRY_PORT);
+
+ String name = RMI_SERVER_PREFIX + server.getServerID();
+ registry.unbind(name);
+ log.info("unregistered " + name + " from registry");
+ }
+ catch (Throwable t)
+ {
+ log.error("Failed to unregister", t);
+ }
+
+ try
+ {
+ // unregister myself from the RMI registry
+
+ Registry registry = LocateRegistry.getRegistry(DEFAULT_REGISTRY_PORT);
+
+ String name = NAMING_SERVER_PREFIX + server.getServerID();
+ registry.unbind(name);
+ log.info("unregistered " + name + " from registry");
+ }
+ catch (Throwable t)
+ {
+ log.error("Failed to unregister", t);
+ }
+ }
+ }
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteContext.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteContext.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteContext.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,241 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.rmi.Naming;
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.util.NotYetImplementedException;
+
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: RemoteContext.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class RemoteContext implements Context
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(RemoteContext.class);
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private NamingDelegate namingDelegate;
+
+ // Constructors --------------------------------------------------
+
+ public RemoteContext(int remoteServerIndex) throws Exception
+ {
+ String n =
+ "//localhost:" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
+ RMITestServer.NAMING_SERVER_PREFIX + remoteServerIndex;
+
+ namingDelegate = (NamingDelegate)Naming.lookup(n);
+
+ log.debug("remote context for server " + remoteServerIndex + " acquired from rmi:" + n);
+ }
+
+ // Context implementation ----------------------------------------
+
+ public Object lookup(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object lookup(String name) throws NamingException
+ {
+ try
+ {
+ return namingDelegate.lookup(name);
+ }
+ catch(Exception e)
+ {
+ log.error("naming operation failed", e);
+ throw new NamingException(e.getMessage());
+ }
+ }
+
+ public void bind(Name name, Object obj) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void bind(String name, Object obj) throws NamingException
+ {
+ try
+ {
+ namingDelegate.bind(name, obj);
+ }
+ catch(Exception e)
+ {
+ log.error("naming operation failed", e);
+ throw new NamingException(e.getMessage());
+ }
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void rebind(String name, Object obj) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void unbind(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void unbind(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void rename(String oldName, String newName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration list(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration list(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration listBindings(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration listBindings(String contextName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void destroySubcontext(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void destroySubcontext(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Context createSubcontext(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Context createSubcontext(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object lookupLink(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object lookupLink(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException
+ {
+ return getNameParser(name.toString());
+ }
+
+ public NameParser getNameParser(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public String composeName(String name, String prefix) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object removeFromEnvironment(String propName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Hashtable getEnvironment() throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void close() throws NamingException
+ {
+ }
+
+ public String getNameInNamespace() throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
+
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteInitialContextFactory.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteInitialContextFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,97 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: RemoteInitialContextFactory.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public class RemoteInitialContextFactory implements InitialContextFactory
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(RemoteInitialContextFactory.class);
+
+ // Static --------------------------------------------------------
+
+ /**
+ * @return the JNDI environment to use to get this InitialContextFactory.
+ */
+ public static Hashtable getJNDIEnvironment(int serverIndex)
+ {
+ Hashtable env = new Hashtable();
+ env.put("java.naming.factory.initial",
+ "org.jboss.test.messaging.tools.container.RemoteInitialContextFactory");
+ env.put("java.naming.provider.url", "");
+ env.put("java.naming.factory.url.pkgs", "");
+ env.put(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex));
+ return env;
+ }
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public Context getInitialContext(Hashtable environment) throws NamingException
+ {
+ String s = (String)environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
+
+ if (s == null)
+ {
+ throw new IllegalArgumentException("Initial context environment must contain " +
+ "entry for " + Constants.SERVER_INDEX_PROPERTY_NAME);
+ }
+
+ int remoteServerIndex = Integer.parseInt(s);
+
+ try
+ {
+ return new RemoteContext(remoteServerIndex);
+ }
+ catch(Exception e)
+ {
+ log.error("Cannot get the remote context", e);
+ throw new NamingException("Cannot get the remote context");
+ }
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteTestServer.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RemoteTestServer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import org.jboss.jms.server.DestinationManager;
+import org.jboss.messaging.core.contract.MessageStore;
+import org.jboss.messaging.core.contract.PersistenceManager;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>1.1</tt>
+ *
+ * RemoteTestServer.java,v 1.1 2006/02/21 08:25:33 timfox Exp
+ */
+public class RemoteTestServer extends LocalTestServer
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public RemoteTestServer(int serverIndex)
+ {
+ super(serverIndex);
+ }
+
+ // Server implementation ------------------------------------------------------------------------
+
+ /**
+ * Only for in-VM use!
+ */
+ public MessageStore getMessageStore() throws Exception
+ {
+ throw new UnsupportedOperationException("This method shouldn't be invoked on a remote server");
+ }
+
+ /**
+ * Only for in-VM use!
+ */
+ public DestinationManager getDestinationManager() throws Exception
+ {
+ throw new UnsupportedOperationException("This method shouldn't be invoked on a remote server");
+ }
+
+ /**
+ * Only for in-VM use!
+ */
+ public PersistenceManager getPersistenceManager() throws Exception
+ {
+ throw new UnsupportedOperationException("This method shouldn't be invoked on a remote server");
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/RemotingJMXWrapper.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapper.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RemotingJMXWrapper.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RemotingJMXWrapper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,158 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.transport.Connector;
+
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class RemotingJMXWrapper implements RemotingJMXWrapperMBean
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private InvokerLocator locator;
+
+ // DO NOT expose the Connector instance externally bacause consistency of subsytemToHandler map
+ // may be compromised!
+ private Connector connector;
+
+ private Map subsystemToHandler;
+
+ // Constructors --------------------------------------------------
+
+ public RemotingJMXWrapper(InvokerLocator locator)
+ {
+ this.locator = locator;
+ this.subsystemToHandler = new HashMap();
+ }
+
+ // RemotingJMXWrapper implementation -----------------------------
+
+ public void start() throws Exception
+ {
+ if (connector != null)
+ {
+ return;
+ }
+
+ connector = new Connector();
+ connector.setInvokerLocator(locator.getLocatorURI());
+ connector.start();
+ }
+
+ public void stop() throws Exception
+ {
+ if (connector == null)
+ {
+ return;
+ }
+
+ connector.stop();
+ connector = null;
+ subsystemToHandler.clear();
+ }
+
+ public RemotingJMXWrapper getInstance()
+ {
+ return this;
+ }
+
+ public String getInvokerLocator() throws Exception
+ {
+ if (connector != null)
+ {
+ return connector.getInvokerLocator();
+ }
+ return null;
+ }
+
+ public Set getConnectorSubsystems()
+ {
+ // create a serializable Set instance
+ return new HashSet(subsystemToHandler.keySet());
+ }
+
+ public ServerInvocationHandler addInvocationHandler(String subsystem, ServerInvocationHandler h)
+ throws Exception
+ {
+ if (connector != null)
+ {
+ subsystemToHandler.put(subsystem, h);
+ return connector.addInvocationHandler(subsystem, h);
+ }
+ return null;
+ }
+
+ public void removeInvocationHandler(String subsystem) throws Exception
+ {
+ subsystemToHandler.remove(subsystem);
+ connector.removeInvocationHandler(subsystem);
+ }
+
+ public void addConnectionListener(ConnectionListener listener)
+ {
+ connector.addConnectionListener(listener);
+ }
+
+ public void removeConnectionListener(ConnectionListener listener)
+ {
+ connector.removeConnectionListener(listener);
+ }
+
+ public void setLeasePeriod(long leasePeriod)
+ {
+ connector.setLeasePeriod(leasePeriod);
+ }
+
+ public long getLeasePeriod()
+ {
+ return connector.getLeasePeriod();
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/RemotingJMXWrapperMBean.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapperMBean.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/RemotingJMXWrapperMBean.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/RemotingJMXWrapperMBean.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.util.Set;
+
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.ServerInvocationHandler;
+
+/**
+ * Note: This wrapper MUST NOT allow direct access to the Connector instance. This is necessary
+ * because the wrapper is maintaining the mapping between the Connector's
+ * ServerInvocationHandler instances and their subsystem names. Remoting should do that (it
+ * should have a Connector.getSubsystemNames() or similar), but it doesn't, so I have to do
+ * this by myself.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public interface RemotingJMXWrapperMBean
+{
+ void start() throws Exception;
+ void stop() throws Exception;
+
+ RemotingJMXWrapper getInstance();
+
+ String getInvokerLocator() throws Exception;
+
+ /**
+ * This method's signature must be identical with Connector's
+ * public ServerInvocationHandler addInvocationHandler(String subsystem,
+ * ServerInvocationHandler handler) throws Exception;
+ */
+ ServerInvocationHandler addInvocationHandler(String subsystem, ServerInvocationHandler h)
+ throws Exception;
+
+ /**
+ * This method's signature must be identical with Connector's
+ * public void removeInvocationHandler(String subsystem) throws Exception;
+ */
+ void removeInvocationHandler(String subsystem) throws Exception;
+
+ /**
+ * @return Set<String> containing the subsystem names various ServerInvocationHandler instances
+ * have been added under to the Connector instance.
+ */
+ Set getConnectorSubsystems();
+
+ void addConnectionListener(ConnectionListener listener);
+
+ void removeConnectionListener(ConnectionListener listener);
+
+ void setLeasePeriod(long leasePeriod);
+
+ long getLeasePeriod();
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/Server.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,291 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.rmi.Remote;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.transaction.UserTransaction;
+
+import org.jboss.jms.server.DestinationManager;
+import org.jboss.jms.server.ServerPeer;
+import org.jboss.messaging.core.contract.MessageStore;
+import org.jboss.messaging.core.contract.PersistenceManager;
+import org.jboss.remoting.ServerInvocationHandler;
+
+/**
+ * The remote interface exposed by TestServer.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2868 $</tt>
+ *
+ * $Id: Server.java 2868 2007-07-10 20:22:16Z timfox $
+ */
+public interface Server extends Remote
+{
+ int getServerID() throws Exception;
+
+ void start(String containerConfig, boolean clearDatabase) throws Exception;
+
+ /**
+ * @param attrOverrides - service attribute overrides that will take precedence over values
+ * read from configuration files.
+ */
+ void start(String containerConfig,
+ ServiceAttributeOverrides attrOverrides,
+ boolean clearDatabase,
+ boolean startMessgingServer) throws Exception;
+
+ /**
+ * @return true if the server was stopped indeed, or false if the server was stopped already
+ * when the method was invoked.
+ */
+ boolean stop() throws Exception;
+
+ /**
+ * For a remote server, it "abruptly" kills the VM running the server. For a local server
+ * it just stops the server.
+ */
+ void kill() throws Exception;
+
+ /**
+ * When kill is called you are actually schedulling the server to be killed in few milliseconds.
+ * There are certain cases where we need to assure the server was really killed.
+ * For that we have this simple ping we can use to verify if the server still alive or not.
+ */
+ void ping() throws Exception;
+
+ /**
+ * Deploys and registers a service based on the MBean service descriptor element, specified as
+ * a String. Supports XMBeans. The implementing class and the ObjectName are inferred from the
+ * mbean element. If there are configuration attributed specified in the deployment descriptor,
+ * they are applied to the service instance.
+ */
+ ObjectName deploy(String mbeanConfiguration) throws Exception;
+
+ void undeploy(ObjectName on) throws Exception;
+
+ Object getAttribute(ObjectName on, String attribute) throws Exception;
+
+ void setAttribute(ObjectName on, String name, String valueAsString) throws Exception;
+
+ Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
+ throws Exception;
+
+ void addNotificationListener(ObjectName on, NotificationListener listener) throws Exception;
+
+ void removeNotificationListener(ObjectName on, NotificationListener listener) throws Exception;
+
+ /**
+ * Returns a set of ObjectNames corresponding to installed services.
+ */
+ Set query(ObjectName pattern) throws Exception;
+
+ /**
+ * @return one of "socket", "http", ...
+ */
+ String getRemotingTransport() throws Exception;
+
+ /**
+ * Only for remote use!
+ */
+ void log(int level, String text) throws Exception;
+
+ /**
+ * @param serverPeerID - if null, the jboss-service.xml value will be used.
+ * @param defaultQueueJNDIContext - if null, the jboss-service.xml value will be used.
+ * @param defaultTopicJNDIContext - if null, the jboss-service.xml value will be used.
+ */
+ void startServerPeer(int serverPeerID,
+ String defaultQueueJNDIContext,
+ String defaultTopicJNDIContext,
+ ServiceAttributeOverrides attrOverrides,
+ boolean clustered,
+ boolean supportsFailover) throws Exception;
+
+ void stopServerPeer() throws Exception;
+
+ boolean isServerPeerStarted() throws Exception;
+
+ ObjectName getServerPeerObjectName() throws Exception;
+
+ boolean isStarted() throws Exception;
+
+ /**
+ * @return a Set<String> with the subsystems currently registered with the Connector. It is
+ * supposed to work locally as well as remotely.
+ */
+ Set getConnectorSubsystems() throws Exception;
+
+ /**
+ * Add a ServerInvocationHandler to the remoting Connector. This method is supposed to work
+ * locally as well as remotely.
+ */
+ void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
+ throws Exception;
+
+ /**
+ * Remove a ServerInvocationHandler from the remoting Connector. This method is supposed to work
+ * locally as well as remotely.
+ */
+ void removeServerInvocationHandler(String subsystem) throws Exception;
+
+ /**
+ * Only for in-VM use!
+ */
+ MessageStore getMessageStore() throws Exception;
+
+ /**
+ * Only for in-VM use!
+ */
+ DestinationManager getDestinationManager() throws Exception;
+
+ PersistenceManager getPersistenceManager() throws Exception;
+
+ /**
+ * Only for in-VM use
+ */
+ ServerPeer getServerPeer() throws Exception;
+
+ /**
+ * Simulates a topic deployment (copying the topic descriptor in the deploy directory).
+ */
+ void deployTopic(String name, String jndiName, boolean clustered) throws Exception;
+
+ /**
+ * Simulates a topic deployment (copying the topic descriptor in the deploy directory).
+ */
+ void deployTopic(String name, String jndiName, int fullSize, int pageSize,
+ int downCacheSize, boolean clustered) throws Exception;
+
+ /**
+ * Creates a topic programatically.
+ */
+ void deployTopicProgrammatically(String name, String jndiName) throws Exception;
+
+ /**
+ * Simulates a queue deployment (copying the queue descriptor in the deploy directory).
+ */
+ void deployQueue(String name, String jndiName, boolean clustered) throws Exception;
+
+ /**
+ * Simulates a queue deployment (copying the queue descriptor in the deploy directory).
+ */
+ void deployQueue(String name, String jndiName, int fullSize, int pageSize,
+ int downCacheSize, boolean clustered) throws Exception;
+
+ /**
+ * Creates a queue programatically.
+ */
+ void deployQueueProgrammatically(String name, String jndiName) throws Exception;
+
+ /**
+ * Simulates a destination un-deployment (deleting the destination descriptor from the deploy
+ * directory).
+ */
+ void undeployDestination(boolean isQueue, String name) throws Exception;
+
+ /**
+ * Destroys a programatically created destination.
+ */
+ boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception;
+
+ void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ int prefetchSize,
+ int defaultTempQueueFullSize,
+ int defaultTempQueuePageSize,
+ int defaultTempQueueDownCacheSize
+ ) throws Exception;
+
+ void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ boolean supportsFailover,
+ boolean supportsLoadBalancing
+ ) throws Exception;
+
+ void deployConnectionFactory(String objectName,
+ String[] jndiBindings,
+ int prefetchSize) throws Exception;
+
+ void deployConnectionFactory(String objectName,
+ String[] jndiBindings) throws Exception;
+
+ void undeployConnectionFactory(ObjectName objectName) throws Exception;
+
+ /**
+ * @param config - sending 'config' as a String and not as an org.w3c.dom.Element to avoid
+ * NotSerializableExceptions that show up when running tests on JDK 1.4.
+ */
+ void configureSecurityForDestination(String destName, String config) throws Exception;
+
+ /**
+ * @param config - sending 'config' as a String and not as an org.w3c.dom.Element to avoid
+ * NotSerializableExceptions that show up when running tests on JDK 1.4.
+ */
+ void setDefaultSecurityConfig(String config) throws Exception;
+
+ /**
+ * @return a String that can be converted to an org.w3c.dom.Element using
+ * ServerManagement.toElement().
+ */
+ String getDefaultSecurityConfig() throws Exception;
+
+ /**
+ * Executes a command on the server
+ *
+ * @param command
+ * @return the return value
+ * @throws Exception
+ */
+ Object executeCommand(Command command) throws Exception;
+
+ UserTransaction getUserTransaction() throws Exception;
+
+ /**
+ * Returns a Set containing the nodeID (as Integers) of all cluster members at the time of the
+ * call.
+ *
+ * USE IT ONLY FOR CLUSTERING TESTS!
+ */
+ Set getNodeIDView() throws Exception;
+
+ Map getFailoverMap() throws Exception;
+
+ Map getRecoveryArea(String queueName) throws Exception;
+
+ int getRecoveryMapSize(String queueName) throws Exception;
+
+ /**
+ * @return List<Notification>
+ */
+ List pollNotificationListener(long listenerID) throws Exception;
+
+ void poisonTheServer(int type) throws Exception;
+
+ void flushManagedConnectionPool() throws Exception;
+
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceAttributeOverrides.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceAttributeOverrides.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceAttributeOverrides.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,78 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.tools.container;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ServiceAttributeOverrides implements Serializable
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final long serialVersionUID = 2347829429579213573L;
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Map<ObjectName - Map<attrName<String>-attrValue<Object>>
+ private Map map;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ServiceAttributeOverrides()
+ {
+ map = new HashMap();
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ /**
+ * @return a Map<attributeName<String>-attributeValue<Object>>. Can be empty, but never null.
+ */
+ public Map get(ObjectName on)
+ {
+ Map attrs = (Map)map.get(on);
+
+ if (attrs == null)
+ {
+ attrs = Collections.EMPTY_MAP;
+ }
+ return attrs;
+ }
+
+ public void put(ObjectName on, String attrName, Object attrValue)
+ {
+ Map attrs = (Map)map.get(on);
+
+ if (attrs == null)
+ {
+ attrs = new HashMap();
+ map.put(on, attrs);
+ }
+
+ attrs.put(attrName, attrValue);
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceConfigHelper.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceConfigHelper.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceConfigHelper.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceConfigHelper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * 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.test.messaging.tools.container;
+
+import java.net.URL;
+
+import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
+import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
+
+/**
+ * A helper class for loading MBean configuration files.
+ *
+ * @author <a href="sergey.koshcheyev at jboss.com">Sergey Koshcheyev</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ServiceConfigHelper
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Load a service deployment descriptor from the specified file on
+ * the class path.
+ */
+ public static ServiceDeploymentDescriptor loadConfigFile(String configFile) throws Exception
+ {
+ URL url = ServiceConfigHelper.class.getClassLoader().getResource(configFile);
+ if (url == null)
+ {
+ throw new Exception("Cannot find " + configFile + " in the classpath");
+ }
+
+ return new ServiceDeploymentDescriptor(url);
+ }
+
+ /**
+ * Load the service deployment descriptor from the specified file on
+ * the class path and return the configuration element of the specified service.
+ */
+ public static MBeanConfigurationElement loadServiceConfiguration(String configFile, String serviceName) throws Exception
+ {
+ ServiceDeploymentDescriptor sdd = loadConfigFile(configFile);
+ return getServiceConfiguration(sdd, serviceName);
+ }
+
+ public static MBeanConfigurationElement getServiceConfiguration(ServiceDeploymentDescriptor descriptor, String serviceName)
+ {
+ return (MBeanConfigurationElement) descriptor.query("service", serviceName).get(0);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceContainer.java (from rev 2925, trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceContainer.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceContainer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,1808 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.management.Attribute;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.spi.NamingManager;
+import javax.sql.DataSource;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.hsqldb.Server;
+import org.hsqldb.persist.HsqlProperties;
+import org.jboss.jms.jndi.JMSProviderAdapter;
+import org.jboss.jms.jndi.JNDIProviderAdapter;
+import org.jboss.jms.server.ServerPeer;
+import org.jboss.jms.server.remoting.JMSServerInvocationHandler;
+import org.jboss.logging.Logger;
+import org.jboss.messaging.util.JNDIUtil;
+import org.jboss.messaging.util.XMLUtil;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory;
+import org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService;
+import org.jboss.resource.adapter.jms.JmsManagedConnectionFactory;
+import org.jboss.resource.connectionmanager.CachedConnectionManager;
+import org.jboss.resource.connectionmanager.CachedConnectionManagerMBean;
+import org.jboss.resource.connectionmanager.ConnectionFactoryBindingService;
+import org.jboss.resource.connectionmanager.JBossManagedConnectionPool;
+import org.jboss.resource.connectionmanager.TxConnectionManager;
+import org.jboss.system.Registry;
+import org.jboss.system.ServiceController;
+import org.jboss.system.ServiceCreator;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
+import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
+import org.jboss.tm.TransactionManagerService;
+import org.jboss.tm.TxManager;
+import org.jboss.tm.usertx.client.ServerVMClientUserTransaction;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+
+/**
+ * An MBeanServer and a configurable set of services (TransactionManager, Remoting, etc) available
+ * for testing.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ServiceContainer
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(ServiceContainer.class);
+
+ private static final String CONFIGURATION_FILE_NAME = "container.xml";
+
+ public static final String DO_NOT_USE_MESSAGING_MARSHALLERS = "DO_NOT_USE_MESSAGING_MARSHALLERS";
+
+ // Static ---------------------------------------------------------------------------------------
+
+ public static ObjectName SERVICE_CONTROLLER_OBJECT_NAME;
+ public static ObjectName CLASS_LOADER_OBJECT_NAME;
+ public static ObjectName TRANSACTION_MANAGER_OBJECT_NAME;
+ public static ObjectName CACHED_CONNECTION_MANAGER_OBJECT_NAME;
+
+ public static ObjectName DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME;
+ public static ObjectName DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME;
+ public static ObjectName DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME;
+ public static ObjectName DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME;
+
+ public static ObjectName JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME;
+ public static ObjectName JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME;
+ public static ObjectName JMS_CONNECTION_MANAGER_OBJECT_NAME;
+ public static ObjectName JMS_CONNECTION_FACTORY_BINDING_SERVICE_OBJECT_NAME;
+
+ public static ObjectName REMOTING_OBJECT_NAME;
+
+ // Used only on testcases where Socket and HTTP are deployed at the same time
+ public static ObjectName HTTP_REMOTING_OBJECT_NAME;
+
+ public static ObjectName SERVER_PEER_OBJECT_NAME;
+
+ public static String DATA_SOURCE_JNDI_NAME = "java:/DefaultDS";
+ public static String TRANSACTION_MANAGER_JNDI_NAME = "java:/TransactionManager";
+ public static String USER_TRANSACTION_JNDI_NAME = "UserTransaction";
+ public static String JCA_JMS_CONNECTION_FACTORY_JNDI_NAME = "java:/JCAConnectionFactory";
+
+ // Must match the value in remoting-http-service.xml
+ public static long HTTP_CONNECTOR_CALLBACK_POLL_PERIOD = 102;
+
+ // List<ObjectName>
+ private List connFactoryObjectNames = new ArrayList();
+
+ static
+ {
+ try
+ {
+ SERVICE_CONTROLLER_OBJECT_NAME =
+ new ObjectName("jboss.system:service=ServiceController");
+ CLASS_LOADER_OBJECT_NAME =
+ new ObjectName("jboss.system:service=ClassLoader");
+ TRANSACTION_MANAGER_OBJECT_NAME =
+ new ObjectName("jboss:service=TransactionManager");
+ CACHED_CONNECTION_MANAGER_OBJECT_NAME =
+ new ObjectName("jboss.jca:service=CachedConnectionManager");
+
+ DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME =
+ new ObjectName("jboss.jca:name=DefaultDS,service=LocalTxCM");
+ DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME =
+ new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionFactory");
+ DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME =
+ new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionPool");
+ DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME =
+ new ObjectName("jboss.jca:name=DefaultDS,service=DataSourceBinding");
+
+ JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME =
+ new ObjectName("jboss.jca:service=ManagedConnectionFactory,name=JCAConnectionFactory");
+ JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME =
+ new ObjectName("jboss.jca:service=ManagedConnectionPool,name=JCAConnectionFactory");
+ JMS_CONNECTION_MANAGER_OBJECT_NAME =
+ new ObjectName("jboss.jca:service=TxCM,name=JCAConnectionFactory");
+ JMS_CONNECTION_FACTORY_BINDING_SERVICE_OBJECT_NAME =
+ new ObjectName("jboss.jca:service=ConnectionFactoryBinding,name=JCAConnectionFactory");
+
+ REMOTING_OBJECT_NAME =
+ new ObjectName("jboss.messaging:service=Connector,transport=bisocket");
+
+ HTTP_REMOTING_OBJECT_NAME =
+ new ObjectName("jboss.messaging:service=Connector,transport=http");
+
+ SERVER_PEER_OBJECT_NAME =
+ new ObjectName("jboss.messaging:service=ServerPeer");
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static String getCurrentAddress() throws Exception
+ {
+ String currentAddress = System.getProperty("test.bind.address");
+
+ if (currentAddress == null)
+ {
+ currentAddress = "localhost";
+ }
+ return currentAddress;
+ }
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private ServiceContainerConfiguration config;
+
+ private TransactionManager tm;
+
+ private MBeanServer mbeanServer;
+ private ServiceCreator serviceCreator; // the 'creator' helps in creating and registering XMBeans
+ private InitialContext initialContext;
+ private String jndiNamingFactory;
+ private Server hsqldbServer;
+ private RecoveryManager recoveryManager;
+ private JBossManagedConnectionPool mcp;
+
+ private boolean transaction;
+ private boolean jbossjta; //To use the ex-Arjuna tx mgr
+ private boolean database;
+ private boolean jca;
+ private boolean remoting;
+ private boolean security;
+ private boolean supportsFailover = true;
+ private boolean httpConnectionFactory;
+ private boolean multiplexer; // the JGroups channels multiplexer
+
+ private List toUnbindAtExit;
+ private String ipAddressOrHostName;
+
+ // There may be many service containers on the same machine, so we need to distinguish them
+ // so we don't start up multiple servers with services running on the same port
+ private int serverIndex;
+
+ // Static ---------------------------------------------------------------------------------------
+
+ public static Object type(MBeanInfo mbeanInfo, String attributeName, String valueAsString)
+ throws Exception
+ {
+ MBeanAttributeInfo[] attrs = mbeanInfo.getAttributes();
+ MBeanAttributeInfo attr = null;
+
+ for(int i = 0; i < attrs.length; i++)
+ {
+ if (attrs[i].getName().equals(attributeName))
+ {
+ attr = attrs[i];
+ break;
+ }
+ }
+
+ if (attr == null)
+ {
+ throw new Exception("No such attribute: " + attributeName);
+ }
+
+ String type = attr.getType();
+
+ if ("int".equals(type) || "java.lang.Integer".equals(type))
+ {
+ int i = Integer.parseInt(valueAsString);
+ return new Integer(i);
+ }
+ else if ("long".equals(type) || "java.lang.Long".equals(type))
+ {
+ long l = Long.parseLong(valueAsString);
+ return new Long(l);
+ }
+ else if ("boolean".equals(type) || "java.lang.Boolean".equals(type))
+ {
+ boolean b = Boolean.valueOf(valueAsString).booleanValue();
+ return new Boolean(b);
+ }
+ else if ("java.lang.String".equals(type))
+ {
+ return valueAsString;
+ }
+ else if ("javax.management.ObjectName".equals(type))
+ {
+ return new ObjectName(valueAsString);
+ }
+ else if ("org.w3c.dom.Element".equals(type))
+ {
+ if (valueAsString == null)
+ {
+ return null;
+ }
+ else
+ {
+ return XMLUtil.stringToElement(valueAsString);
+ }
+ }
+ else if (type.startsWith("org.jboss."))
+ {
+ Class interfazza = ServiceContainer.class.getClassLoader().loadClass(type);
+ Class implementation = ServiceContainer.class.getClassLoader().loadClass(valueAsString);
+ return implementation.newInstance();
+ }
+ else if (type.startsWith("java.util.Properties"))
+ {
+ ByteArrayInputStream is = new ByteArrayInputStream(valueAsString.getBytes());
+ Properties props = new Properties();
+ props.load(is);
+ return props;
+ }
+
+ throw new Exception("Don't know to handle type " + type);
+
+ }
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ServiceContainer(String servicesToStart) throws Exception
+ {
+ this(servicesToStart, null);
+ }
+
+ public ServiceContainer(String sevicesToStart, int serverIndex) throws Exception
+ {
+ this(sevicesToStart, null, serverIndex);
+ }
+
+ /**
+ * @param sevicesToStart - A comma separated list of services to be started. Available services:
+ * transaction, jca, database, remoting. Example: "transaction, database, remoting".
+ * "all" will start every service available. A dash in front of a service name will
+ * disable that service. Example "all,-database".
+ * @param tm - specifies a specific TransactionManager instance to bind into the mbeanServer.
+ * If null, the default JBoss TransactionManager implementation will be used.
+ */
+ public ServiceContainer(String sevicesToStart, TransactionManager tm) throws Exception
+ {
+ this.tm = tm;
+ parseConfig(sevicesToStart);
+ toUnbindAtExit = new ArrayList();
+ this.serverIndex = 0;
+ }
+
+ public ServiceContainer(String sevicesToStart, TransactionManager tm, int serverIndex)
+ throws Exception
+ {
+ this.tm = tm;
+ parseConfig(sevicesToStart);
+ toUnbindAtExit = new ArrayList();
+ this.serverIndex = serverIndex;
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void start() throws Exception
+ {
+ start(true);
+ }
+
+ public void start(boolean cleanDatabase) throws Exception
+ {
+ start(cleanDatabase, null);
+ }
+
+ public void start(boolean cleanDatabase, ServiceAttributeOverrides attrOverrides)
+ throws Exception
+ {
+ try
+ {
+ readConfigurationFile();
+
+ ipAddressOrHostName = getCurrentAddress();
+ log.debug("all server sockets will be open on address " + ipAddressOrHostName);
+
+ toUnbindAtExit.clear();
+
+ jndiNamingFactory = System.getProperty("java.naming.factory.initial");
+
+ //TODO: need to think more about this; if I don't do it, though, bind() fails because it tries to use "java.naming.provider.url"
+ try
+ {
+ NamingManager.
+ setInitialContextFactoryBuilder(new InVMInitialContextFactoryBuilder());
+ }
+ catch(IllegalStateException e)
+ {
+ // OK
+ }
+
+ Hashtable t = InVMInitialContextFactory.getJNDIEnvironment(serverIndex);
+ System.setProperty("java.naming.factory.initial",
+ (String)t.get("java.naming.factory.initial"));
+ System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME,
+ Integer.toString(serverIndex));
+
+ initialContext = new InitialContext();
+
+ boolean java5 = false;
+
+ try
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ cl.loadClass("java.lang.management.ManagementFactory");
+ java5 = true;
+ }
+ catch(ClassNotFoundException e)
+ {
+ // OK
+ }
+
+ if (java5)
+ {
+ System.setProperty("javax.management.builder.initial",
+ "org.jboss.test.messaging.tools.container.MBeanServerBuilder");
+ }
+
+ mbeanServer = MBeanServerFactory.createMBeanServer("jboss");
+
+ serviceCreator = new ServiceCreator(mbeanServer);
+
+ startServiceController();
+
+ registerClassLoader();
+
+ if (jbossjta)
+ {
+ deleteObjectStore();
+ }
+
+ if (transaction || jbossjta)
+ {
+ startTransactionManager();
+ }
+
+ if (database)
+ {
+ startInVMDatabase();
+ }
+
+ if (jca)
+ {
+ startCachedConnectionManager(CACHED_CONNECTION_MANAGER_OBJECT_NAME);
+
+ // DefaultDS specific
+ startManagedConnectionFactory(DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
+ startManagedConnectionPool(DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME,
+ DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME,
+ "ByContainer");
+ startConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME, true, true,
+ TRANSACTION_MANAGER_OBJECT_NAME,
+ CachedConnectionManagerMBean.OBJECT_NAME,
+ DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
+ startWrapperDataSourceService();
+ }
+
+ if (database && (transaction || jbossjta) && jca && cleanDatabase)
+ {
+ // We make sure the database is clean (only if we have all dependencies the database,
+ // otherwise we'll get an access error)
+ deleteAllData();
+ }
+
+ if (remoting)
+ {
+ startRemoting(attrOverrides, config.getRemotingTransport(), REMOTING_OBJECT_NAME);
+ }
+
+ if (security)
+ {
+ startSecurityManager();
+ }
+
+ if (multiplexer)
+ {
+ startMultiplexer();
+ }
+
+ loadJNDIContexts();
+
+ log.debug("loaded JNDI context");
+
+
+ String transport = config.getRemotingTransport();
+
+ log.info("Remoting type: .............. " + (remoting ? transport : "DISABLED"));
+ log.info("Clustering mode: ............ " +
+ (this.isClustered() ? "CLUSTERED" : "NON-CLUSTERED"));
+
+ log.debug(this + " started");
+ }
+ catch(Throwable e)
+ {
+ log.error("Failed to start ServiceContainer", e);
+ throw new Exception("Failed to start ServiceContainer", e);
+ }
+ }
+
+ public void dropTables() throws Exception
+ {
+ dropAllTables();
+ }
+
+ public void startConnectionFactories(ServiceAttributeOverrides attrOverrides) throws Exception
+ {
+ deployConnectionFactories("server/default/deploy/connection-factories-service.xml", attrOverrides);
+
+ log.info("HTTP ConnectionFactory " + httpConnectionFactory);
+ if (httpConnectionFactory)
+ {
+ log.info("Installing HTTP connection factory");
+ ServiceAttributeOverrides httpOverride = new ServiceAttributeOverrides();
+ startRemoting(httpOverride, "http", HTTP_REMOTING_OBJECT_NAME);
+ deployConnectionFactories("connection-factory-http.xml", attrOverrides);
+ }
+
+ // bind the default JMS provider
+ bindDefaultJMSProvider();
+ // bind the JCA ConnectionFactory
+ bindJCAJMSConnectionFactory();
+ }
+
+ public void stopConnectionFactories() throws Exception
+ {
+ for(Iterator i = connFactoryObjectNames.iterator(); i.hasNext(); )
+ {
+ try
+ {
+ ObjectName on = (ObjectName)i.next();
+ invoke(on, "stop", new Object[0], new String[0]);
+ invoke(on, "destroy", new Object[0], new String[0]);
+ unregisterService(on);
+ }
+ catch (Exception ignore)
+ {
+ //If the serverpeer failed when starting up previously, then only some of the
+ //services may be started. The ones that didn't start will fail when attempting to shut
+ //them down.
+ //Hence we must catch and ignore or we won't shut everything down
+ }
+ }
+ connFactoryObjectNames.clear();
+
+ }
+
+ public void flushManagedConnectionPool()
+ {
+ mcp.flush();
+ }
+
+
+ public void stop() throws Exception
+ {
+ log.info("Stopping serviceconatiner");
+
+ unloadJNDIContexts();
+
+ stopService(REMOTING_OBJECT_NAME);
+
+ if (httpConnectionFactory)
+ {
+ stopService(HTTP_REMOTING_OBJECT_NAME);
+ }
+
+ if (jca)
+ {
+ stopWrapperDataSourceService();
+ stopConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME);
+ stopManagedConnectionPool(DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
+ stopManagedConnectionFactory(DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
+ stopService(CACHED_CONNECTION_MANAGER_OBJECT_NAME);
+ }
+
+ stopService(TRANSACTION_MANAGER_OBJECT_NAME);
+
+ if (database)
+ {
+ stopInVMDatabase();
+ }
+
+ unregisterClassLoader();
+ stopServiceController();
+ MBeanServerFactory.releaseMBeanServer(mbeanServer);
+
+ if (security)
+ {
+ initialContext.unbind(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
+ }
+
+ cleanJNDI();
+
+ initialContext.close();
+
+ if (jndiNamingFactory != null)
+ {
+ System.setProperty("java.naming.factory.initial", jndiNamingFactory);
+ }
+
+ log.debug(this + " stopped");
+ }
+
+ public DataSource getDataSource()
+ {
+ DataSource ds = null;
+ try
+ {
+ InitialContext ic = new InitialContext();
+ ds = (DataSource)ic.lookup(DATA_SOURCE_JNDI_NAME);
+ ic.close();
+ }
+ catch(Exception e)
+ {
+ log.error("Failed to look up DataSource", e);
+ }
+ return ds;
+ }
+
+ public TransactionManager getTransactionManager()
+ {
+ TransactionManager tm = null;
+ try
+ {
+ InitialContext ic = new InitialContext();
+ tm = (TransactionManager)ic.lookup(TRANSACTION_MANAGER_JNDI_NAME);
+ ic.close();
+ }
+ catch(Exception e)
+ {
+ log.error("Failed to look up transaction manager", e);
+ }
+ return tm;
+ }
+
+ public UserTransaction getUserTransaction() throws Exception
+ {
+ return (UserTransaction)initialContext.lookup(USER_TRANSACTION_JNDI_NAME);
+ }
+
+ public Object getService(ObjectName on) throws Exception
+ {
+ return mbeanServer.invoke(on, "getInstance", new Object[0], new String[0]);
+ }
+
+ public String getPersistenceConfigFile(boolean clustered)
+ {
+ String databaseName = getDatabaseName();
+
+ return "server/default/deploy/" + databaseName + "-persistence-service.xml";
+ }
+
+ public Properties getPersistenceManagerSQLProperties() throws Exception
+ {
+ String persistenceConfigFile = getPersistenceConfigFile(false);
+ log.info("Persistence config file: .... " + persistenceConfigFile);
+
+ MBeanConfigurationElement persistenceManagerConfig =
+ ServiceConfigHelper.loadServiceConfiguration(persistenceConfigFile, "PersistenceManager");
+
+ String props = persistenceManagerConfig.getAttributeValue("SqlProperties");
+
+ if (props != null)
+ {
+ ByteArrayInputStream is = new ByteArrayInputStream(props.getBytes());
+
+ Properties sqlProperties = new Properties();
+
+ sqlProperties.load(is);
+
+ return sqlProperties;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Properties getPostOfficeSQLProperties() throws Exception
+ {
+ String persistenceConfigFile = getPersistenceConfigFile(true);
+ log.info("Persistence config file: .... " + persistenceConfigFile);
+
+ MBeanConfigurationElement postOfficeConfig =
+ ServiceConfigHelper.loadServiceConfiguration(persistenceConfigFile, "PostOffice");
+
+ String props = postOfficeConfig.getAttributeValue("SqlProperties");
+
+ if (props != null)
+ {
+ ByteArrayInputStream is = new ByteArrayInputStream(props.getBytes());
+
+ Properties sqlProperties = new Properties();
+
+ sqlProperties.load(is);
+
+ return sqlProperties;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @return Set<ObjectName>
+ */
+ public Set query(ObjectName pattern)
+ {
+ if (pattern == null)
+ {
+ return Collections.EMPTY_SET;
+ }
+ return mbeanServer.queryNames(pattern, null);
+ }
+
+ /**
+ * Creates and registers a service based on the MBean service descriptor element. Supports
+ * XMBeans. The implementing class and the ObjectName are inferred from the mbean element. If
+ * there are configuration attributed specified in the deployment descriptor, they are applied
+ * to the service instance.
+ */
+ public ObjectName registerAndConfigureService(MBeanConfigurationElement mbeanConfig)
+ throws Exception
+ {
+ ObjectName on = mbeanConfig.getObjectName();
+ serviceCreator.install(on, CLASS_LOADER_OBJECT_NAME, mbeanConfig.getDelegate());
+
+ // inject dependencies
+ for(Iterator i = mbeanConfig.dependencyOptionalAttributeNames().iterator(); i.hasNext(); )
+ {
+ String name = (String)i.next();
+ String value = mbeanConfig.getDependencyOptionalAttributeValue(name);
+ setAttribute(on, name, value);
+ }
+
+ // apply attributes
+ for(Iterator i = mbeanConfig.attributeNames().iterator(); i.hasNext();)
+ {
+ String name = (String)i.next();
+ String value = mbeanConfig.getAttributeValue(name);
+ setAttribute(on, name, value);
+ }
+
+ log.debug(mbeanConfig + " registered and configured");
+ return on;
+ }
+
+ /**
+ * Note that this method makes no assumption on whether the service was stopped or destroyed, nor
+ * does it attempt to stop/destroy the service.
+ */
+ public void unregisterService(ObjectName on) throws Exception
+ {
+ mbeanServer.unregisterMBean(on);
+ log.debug(on + " unregistered");
+ }
+
+ public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
+ throws Exception
+ {
+ try
+ {
+ return mbeanServer.invoke(on, operationName, params, signature);
+ }
+ catch(MBeanException e)
+ {
+ // unwrap the exception thrown by the service
+ throw (Exception)e.getCause();
+ }
+ }
+
+ /**
+ * Set the attribute value, performing String -> Object conversion as appropriate.
+ */
+ public void setAttribute(ObjectName on, String name, String valueAsString) throws Exception
+ {
+ MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(on);
+ Object value = type(mbeanInfo, name, valueAsString);
+ mbeanServer.setAttribute(on, new Attribute(name, value));
+ }
+
+ public Object getAttribute(ObjectName on, String name) throws Exception
+ {
+ return mbeanServer.getAttribute(on, name);
+ }
+
+ public void addNotificationListener(ObjectName on, NotificationListener listener)
+ throws Exception
+ {
+ mbeanServer.addNotificationListener(on, listener, null, null);
+ }
+
+ public void removeNotificationListener(ObjectName on, NotificationListener listener)
+ throws Exception
+ {
+ mbeanServer.removeNotificationListener(on, listener);
+ }
+
+ public MBeanServer getMBeanServer()
+ {
+ return mbeanServer;
+ }
+
+ public void bindDefaultJMSProvider() throws Exception
+ {
+ JNDIProviderAdapter pa = new JNDIProviderAdapter();
+ pa.setQueueFactoryRef("/ConnectionFactory");
+ pa.setTopicFactoryRef("/ConnectionFactory");
+ pa.setFactoryRef("/ConnectionFactory");
+ initialContext.bind("java:/DefaultJMSProvider", pa);
+ }
+
+ public void unbindDefaultJMSProvider() throws Exception
+ {
+ initialContext.unbind("java:/DefaultJMSProvider");
+ }
+
+ public void bindJCAJMSConnectionFactory() throws Exception
+ {
+ deployJBossJMSRA(JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
+
+ startManagedConnectionPool(JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME,
+ JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME,
+ "ByApplication");
+
+ startConnectionManager(JMS_CONNECTION_MANAGER_OBJECT_NAME, true, false, // not local, but XA(!)
+ TRANSACTION_MANAGER_OBJECT_NAME,
+ CachedConnectionManagerMBean.OBJECT_NAME,
+ JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
+
+ ObjectName on = JMS_CONNECTION_FACTORY_BINDING_SERVICE_OBJECT_NAME;
+
+ // create it
+ ConnectionFactoryBindingService cfBindingService = new ConnectionFactoryBindingService();
+
+ // register it
+ mbeanServer.registerMBean(cfBindingService, on);
+
+ // configure it
+ mbeanServer.setAttribute(on, new Attribute("ConnectionManager", JMS_CONNECTION_MANAGER_OBJECT_NAME));
+ mbeanServer.setAttribute(on, new Attribute("JndiName", JCA_JMS_CONNECTION_FACTORY_JNDI_NAME));
+ mbeanServer.setAttribute(on, new Attribute("UseJavaContext", Boolean.TRUE));
+
+ // start it
+ mbeanServer.invoke(on, "start", new Object[0], new String[0]);
+
+ log.debug("started " + on);
+ }
+
+ /**
+ * This method may be called twice successively, so it is important to handle graciously this
+ * situation.
+ */
+ public void unbindJCAJMSConnectionFactory() throws Exception
+ {
+ ObjectName on = JMS_CONNECTION_FACTORY_BINDING_SERVICE_OBJECT_NAME;
+
+ if (mbeanServer.isRegistered(on))
+ {
+ mbeanServer.invoke(on, "stop", new Object[0], new String[0]);
+ mbeanServer.invoke(on, "destroy", new Object[0], new String[0]);
+ mbeanServer.unregisterMBean(on);
+ }
+
+ stopConnectionManager(JMS_CONNECTION_MANAGER_OBJECT_NAME);
+ stopManagedConnectionPool(JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
+ undeployJBossJMSRA(JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
+ }
+
+ public String getDatabaseName()
+ {
+ return config.getDatabaseName();
+ }
+
+ public String getRemotingTransport()
+ {
+ return config.getRemotingTransport();
+ }
+
+ public boolean isClustered()
+ {
+ return config.isClustered();
+ }
+
+ public boolean isSupportsFailover()
+ {
+ return supportsFailover;
+ }
+
+ public void installJMSProviderAdaptor(String jndi, JMSProviderAdapter adaptor) throws Exception
+ {
+ log.info("Binding adaptor " + adaptor + " in JNDI: " + jndi);
+ initialContext.bind(jndi, adaptor);
+
+ }
+
+ public void uninstallJMSProviderAdaptor(String jndi) throws Exception
+ {
+ initialContext.unbind(jndi);
+ }
+
+ public void startRecoveryManager()
+ {
+ log.info("Starting arjuna recovery manager");
+
+ //Need to start the recovery manager manually - if deploying
+ //inside JBoss this wouldn't be necessary - since you would use
+ //the TransactionManagerService MBean which would start the recovery manager
+ //for you
+ recoveryManager = RecoveryManager.manager(RecoveryManager.INDIRECT_MANAGEMENT);
+
+ log.info("Started recovery manager");
+ }
+
+ public void stopRecoveryManager()
+ {
+ if (recoveryManager != null)
+ {
+ recoveryManager.stop();
+ }
+ }
+
+ public String toString()
+ {
+ return "ServiceContainer[" + Integer.toHexString(hashCode()) + "]";
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ /**
+ * Note that this method makes no assumption on whether the service was created or started, nor
+ * does it attempt to create/start the service.
+ *
+ * @param service - a Standard/DynamicMBean instance.
+ */
+ private void registerService(Object service, ObjectName on) throws Exception
+ {
+ mbeanServer.registerMBean(service, on);
+ log.debug(service + " registered as " + on);
+ }
+
+ private void readConfigurationFile() throws Exception
+ {
+ InputStream cs = getClass().getClassLoader().getResourceAsStream(CONFIGURATION_FILE_NAME);
+ if (cs == null)
+ {
+ throw new Exception("Cannot file container's configuration file " +
+ CONFIGURATION_FILE_NAME + ". Make sure it is in the classpath.");
+ }
+
+ try
+ {
+ config = new ServiceContainerConfiguration(cs);
+ }
+ finally
+ {
+ cs.close();
+ }
+ }
+
+ private void loadJNDIContexts() throws Exception
+ {
+ String[] names = {ServerManagement.DEFAULT_QUEUE_CONTEXT,
+ ServerManagement.DEFAULT_TOPIC_CONTEXT};
+
+ for (int i = 0; i < names.length; i++)
+ {
+ try
+ {
+ initialContext.lookup(names[i]);
+ }
+ catch(NameNotFoundException e)
+ {
+ JNDIUtil.createContext(initialContext, names[i]);
+ log.debug("created context /" + names[i]);
+ }
+ }
+ }
+
+ private void unloadJNDIContexts() throws Exception
+ {
+ // ServerPeer should do that upon its shutdown, this is redundant
+
+ String[] context = { "/topic", "/queue" };
+ for(int i = 0; i < context.length; i++)
+ {
+ try
+ {
+ Context c = (Context)initialContext.lookup(context[i]);
+ JNDIUtil.tearDownRecursively(c);
+ }
+ catch(NameNotFoundException e)
+ {
+ // OK
+ log.debug("no context " + context[i] + " to unload, cleanup already performed");
+ }
+ }
+ }
+
+ private void startServiceController() throws Exception
+ {
+ // I don't really need it, because I enforce dependencies by hand, but this will keep some
+ // services happy.
+ ServiceController sc = new ServiceController();
+ mbeanServer.registerMBean(sc, SERVICE_CONTROLLER_OBJECT_NAME);
+ }
+
+ private void stopServiceController() throws Exception
+ {
+ mbeanServer.unregisterMBean(SERVICE_CONTROLLER_OBJECT_NAME);
+ }
+
+ /**
+ * Register a class loader used to instantiate other services.
+ */
+ private void registerClassLoader() throws Exception
+ {
+ ClassLoader cl = getClass().getClassLoader();
+ mbeanServer.registerMBean(new ClassLoaderJMXWrapper(cl), CLASS_LOADER_OBJECT_NAME);
+ }
+
+ private void unregisterClassLoader() throws Exception
+ {
+ mbeanServer.unregisterMBean(CLASS_LOADER_OBJECT_NAME);
+ }
+
+ private void startInVMDatabase() throws Exception
+ {
+ if (!"hsqldb".equals(config.getDatabaseName()))
+ {
+ // is an out-of-process DB, and it must be stared externally
+ return;
+ }
+
+ log.debug("starting " + config.getDatabaseName() + " in-VM");
+
+ String url = config.getDatabaseConnectionURL();
+ HsqlProperties props = new HsqlProperties();
+ props.setProperty("server.database.0", ServiceContainerConfiguration.getHypersonicDatabase(url));
+ props.setProperty("server.dbname.0", ServiceContainerConfiguration.getHypersonicDbname(url));
+ props.setProperty("server.trace", "false");
+ props.setProperty("server.silent", "true");
+ props.setProperty("server.no_system_exit", "true");
+ props.setProperty("server.port", 27862);
+ props.setProperty("server.address", ipAddressOrHostName);
+
+ hsqldbServer = new Server();
+ hsqldbServer.setLogWriter(null);
+ hsqldbServer.setProperties(props);
+ hsqldbServer.start();
+
+ log.debug("started " + config.getDatabaseName() + " in-VM");
+ }
+
+ private void stopInVMDatabase() throws Exception
+ {
+ if (!"hsqldb".equals(config.getDatabaseName()))
+ {
+ // is an out-of-process DB, and it must be stopped externally
+ return;
+ }
+
+ log.debug("stop " + hsqldbServer);
+
+ Class.forName(config.getDatabaseDriverClass());
+
+ Connection conn =
+ DriverManager.getConnection(config.getDatabaseConnectionURL(),
+ config.getDatabaseUserName(),
+ config.getDatabasePassword());
+
+ Statement stat = conn.createStatement();
+ stat.executeUpdate("SHUTDOWN");
+ conn.close();
+
+ // faster stop
+ // hsqldbServer.stop();
+ }
+
+ private void startTransactionManager() throws Exception
+ {
+ if (tm == null)
+ {
+ if (jbossjta)
+ {
+ log.info("Starting arjuna tx mgr");
+ tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+ }
+ else
+ {
+ log.info("Starting non arjuna tx mgr");
+ tm = TxManager.getInstance();
+ }
+ }
+
+ TransactionManagerJMXWrapper mbean = new TransactionManagerJMXWrapper(tm);
+ mbeanServer.registerMBean(mbean, TRANSACTION_MANAGER_OBJECT_NAME);
+ mbeanServer.invoke(TRANSACTION_MANAGER_OBJECT_NAME, "start", new Object[0], new String[0]);
+ log.debug("started " + TRANSACTION_MANAGER_OBJECT_NAME);
+
+ initialContext.bind(TRANSACTION_MANAGER_JNDI_NAME, tm);
+ toUnbindAtExit.add(TRANSACTION_MANAGER_JNDI_NAME);
+
+ log.debug("bound " + TRANSACTION_MANAGER_JNDI_NAME);
+
+ initialContext.
+ rebind(USER_TRANSACTION_JNDI_NAME, ServerVMClientUserTransaction.getSingleton());
+
+ log.debug("bound " + USER_TRANSACTION_JNDI_NAME);
+ }
+
+ private boolean deleteDirectory(File directory)
+ {
+ if (directory.isDirectory())
+ {
+ String[] files = directory.list();
+
+ for (int j = 0; j < files.length; j++)
+ {
+ if (!deleteDirectory(new File(directory, files[j])))
+ {
+ return false;
+ }
+ }
+ }
+
+ return directory.delete();
+ }
+
+ private void deleteObjectStore()
+ {
+ // First delete the object store - might have been left over from a previous run
+
+ String objectStoreDir = System.getProperty("objectstore.dir");
+
+ log.info("Deleting object store: " + objectStoreDir);
+
+ if (objectStoreDir == null)
+ {
+ log.warn("Cannot find objectstore.dir parameter");
+ }
+ else
+ {
+ File f = new File(objectStoreDir);
+
+ deleteDirectory(f);
+ }
+ }
+
+
+
+ private void startCachedConnectionManager(ObjectName on) throws Exception
+ {
+ CachedConnectionManager ccm = new CachedConnectionManager();
+
+ // dependencies
+ ccm.setTransactionManagerServiceName(TRANSACTION_MANAGER_OBJECT_NAME);
+
+ mbeanServer.registerMBean(ccm, on);
+ mbeanServer.invoke(on, "start", new Object[0], new String[0]);
+ log.debug("started " + on);
+
+ }
+
+ /**
+ * Database specific.
+ */
+ private void startManagedConnectionFactory(ObjectName on) throws Exception
+ {
+ LocalManagedConnectionFactory mcf = new LocalManagedConnectionFactory();
+
+ log.info("connection url:" + config.getDatabaseConnectionURL());
+ log.info("driver:" + config.getDatabaseConnectionURL());
+ log.info("username:" + config.getDatabaseUserName());
+ log.info("password:" + config.getDatabasePassword());
+
+ mcf.setConnectionURL(config.getDatabaseConnectionURL());
+ mcf.setDriverClass(config.getDatabaseDriverClass());
+ mcf.setUserName(config.getDatabaseUserName());
+ mcf.setPassword(config.getDatabasePassword());
+ String isolation = config.getDatabaseTransactionIsolation();
+ if (isolation != null)
+ {
+ mcf.setTransactionIsolation(isolation);
+ }
+
+ ManagedConnectionFactoryJMXWrapper mbean = new ManagedConnectionFactoryJMXWrapper(mcf);
+ mbeanServer.registerMBean(mbean, on);
+ mbeanServer.invoke(on, "start", new Object[0], new String[0]);
+ log.debug("started " + on);
+ }
+
+ /**
+ * This method may be called twice successively, so it is important to handle graciously this
+ * situation.
+ */
+ private void stopManagedConnectionFactory(ObjectName on) throws Exception
+ {
+ stopService(on);
+ }
+
+ private void startManagedConnectionPool(ObjectName on,
+ ObjectName managedConnectionFactoryObjectName,
+ String criteria) throws Exception
+ {
+ mcp = new JBossManagedConnectionPool();
+ mcp.setCriteria(criteria);
+
+ // dependencies
+ mcp.setManagedConnectionFactoryName(managedConnectionFactoryObjectName);
+
+ mbeanServer.registerMBean(mcp, on);
+ mbeanServer.invoke(on, "start", new Object[0], new String[0]);
+ log.debug("started " + on);
+
+
+ }
+
+ /**
+ * This method may be called twice successively, so it is important to handle graciously this
+ * situation.
+ */
+ private void stopManagedConnectionPool(ObjectName on) throws Exception
+ {
+ stopService(on);
+ }
+
+ private TxConnectionManager startConnectionManager(ObjectName on,
+ boolean trackConnectionByTx,
+ boolean localTransactions,
+ ObjectName transactionManagerObjectName,
+ ObjectName cachedConnectionManagerObjectName,
+ ObjectName managedConnectionPoolObjectName)
+ throws Exception
+ {
+ TxConnectionManager cm = new TxConnectionManager();
+ cm.preRegister(mbeanServer, on);
+ cm.setTrackConnectionByTx(trackConnectionByTx);
+ cm.setLocalTransactions(localTransactions);
+
+ // dependencies
+ cm.setTransactionManagerService(transactionManagerObjectName);
+ cm.setCachedConnectionManager(cachedConnectionManagerObjectName);
+ cm.setManagedConnectionPool(managedConnectionPoolObjectName);
+
+ mbeanServer.registerMBean(cm, on);
+ mbeanServer.invoke(on, "start", new Object[0], new String[0]);
+ log.debug("started " + on);
+
+ return cm;
+ }
+
+ /**
+ * This method may be called twice successively, so it is important to handle graciously this
+ * situation.
+ */
+ private void stopConnectionManager(ObjectName on) throws Exception
+ {
+ stopService(on);
+ }
+
+ private void startWrapperDataSourceService() throws Exception
+ {
+ WrapperDataSourceService wdss = new WrapperDataSourceService();
+ wdss.setJndiName(DATA_SOURCE_JNDI_NAME);
+
+ // dependencies
+ wdss.setConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME);
+ ObjectName irrelevant = new ObjectName(":name=irrelevant");
+ wdss.setJMXInvokerName(irrelevant);
+ Registry.bind(irrelevant, new NoopInvoker());
+
+ mbeanServer.registerMBean(wdss, DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME);
+ mbeanServer.invoke(DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME, "start", new Object[0], new String[0]);
+
+ log.debug("started " + DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME);
+ }
+
+ private void stopWrapperDataSourceService() throws Exception
+ {
+ stopService(DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME);
+ }
+
+ private void deployJBossJMSRA(ObjectName managedConnFactoryObjectName) throws Exception
+ {
+ JmsManagedConnectionFactory mcf = new JmsManagedConnectionFactory();
+// mcf.setClientID("");
+// mcf.setUserName("");
+// mcf.setPassword("");
+ mcf.setJmsProviderAdapterJNDI("java:/DefaultJMSProvider");
+ mcf.setStrict(true);
+ mcf.setSessionDefaultType("javax.jms.Queue");
+
+ registerService(new ManagedConnectionFactoryJMXWrapper(mcf), managedConnFactoryObjectName);
+ }
+
+ /**
+ * This method may be called twice successively, so it is important to handle graciously this
+ * situation.
+ */
+ private void undeployJBossJMSRA(ObjectName managedConnFactoryObjectName) throws Exception
+ {
+ stopService(managedConnFactoryObjectName);
+ }
+
+ private String buildLocatorURI(String transport, Map overrideMap) throws Exception
+ {
+ // We use this from thirdparty remoting tests when we don't want to send stuff through
+ // JMSWireFormat, but we want everything else in the connector's configuration to be
+ // identical with what we use in Messaging
+ boolean overrideMarshallers =
+ overrideMap != null && overrideMap.get(DO_NOT_USE_MESSAGING_MARSHALLERS) != null;
+
+ // Note that we DO NOT want the direct thread pool on the server side - since that can lead
+ // to deadlocks
+
+ String configFileName = "remoting/remoting-" + transport + "-service.xml";
+
+ MBeanConfigurationElement connectorServiceConfig =
+ ServiceConfigHelper.loadServiceConfiguration(configFileName, "Connector");
+
+ String invokerConfig = connectorServiceConfig.getAttributeValue("Configuration");
+
+ Element invokerElement = (Element) XMLUtil
+ .stringToElement(invokerConfig)
+ .getElementsByTagName("invoker").item(0);
+
+ NodeList invokerAttributes = invokerElement.getElementsByTagName("attribute");
+
+ StringBuffer paramsBuffer = new StringBuffer();
+
+ for (int i = 0; i < invokerAttributes.getLength(); i++)
+ {
+ Element attr = (Element) invokerAttributes.item(i);
+ if (attr.getAttribute("isParam").equals(""))
+ {
+ continue;
+ }
+
+ String key = attr.getAttribute("name");
+ String value = attr.getTextContent().trim();
+
+ if (overrideMarshallers &&
+ (key.equals("marshaller") || key.equals("unmarshaller")))
+ {
+ continue;
+ }
+
+ if (paramsBuffer.length() > 0)
+ {
+ paramsBuffer.append('&');
+ }
+
+ if (overrideMap != null)
+ {
+ String valueOverride = (String)overrideMap.get(key);
+ if (valueOverride != null)
+ {
+ value = valueOverride;
+ }
+ }
+
+ paramsBuffer.append(key).append('=').append(value);
+ }
+
+ int freePort = PortUtil.findFreePort(ipAddressOrHostName);
+
+ return new StringBuffer()
+ .append(transport).append("://")
+ .append(ipAddressOrHostName).append(':').append(freePort)
+ .append("/?").append(paramsBuffer)
+ .toString();
+ }
+
+ private void startRemoting(ServiceAttributeOverrides attrOverrides,
+ String transport,
+ ObjectName objectName) throws Exception
+ {
+ log.debug("Starting remoting transport=" + transport + " objectName=" + objectName);
+ RemotingJMXWrapper mbean;
+ String locatorURI = null;
+
+ // some tests may want specific locator URI overrides to simulate special conditions; use
+ // that with priority, if available
+ Map overrideMap = null;
+
+ if (attrOverrides != null)
+ {
+ overrideMap = attrOverrides.get(objectName);
+
+ if (overrideMap != null)
+ {
+ locatorURI = (String)overrideMap.get("LocatorURI");
+ }
+ }
+
+ if (locatorURI == null)
+ {
+ locatorURI = buildLocatorURI(transport, overrideMap);
+ log.info("creating server for: " + locatorURI);
+ }
+
+ log.debug("Using locator uri: " + locatorURI);
+
+ InvokerLocator locator = new InvokerLocator(locatorURI);
+
+ log.debug("Started remoting connector on uri:" + locator.getLocatorURI());
+
+ mbean = new RemotingJMXWrapper(locator);
+ mbeanServer.registerMBean(mbean, objectName);
+ mbeanServer.invoke(objectName, "start", new Object[0], new String[0]);
+
+ ServerInvocationHandler handler = new JMSServerInvocationHandler();
+
+ mbeanServer.invoke(objectName, "addInvocationHandler",
+ new Object[] { ServerPeer.REMOTING_JMS_SUBSYSTEM, handler},
+ new String[] { "java.lang.String",
+ "org.jboss.remoting.ServerInvocationHandler"});
+
+ log.debug("started " + objectName);
+ }
+
+
+ private void startSecurityManager() throws Exception
+ {
+ MockJBossSecurityManager sm = new MockJBossSecurityManager();
+ this.initialContext.bind(MockJBossSecurityManager.TEST_SECURITY_DOMAIN, sm);
+
+ log.debug("started JBoss Mock Security Manager");
+ }
+
+ private void stopService(ObjectName target) throws Exception
+ {
+ if (mbeanServer.isRegistered(target))
+ {
+ mbeanServer.invoke(target, "stop", new Object[0], new String[0]);
+ mbeanServer.unregisterMBean(target);
+ log.debug("stopped " + target);
+ }
+ }
+
+ private void cleanJNDI() throws Exception
+ {
+ for (Iterator i = toUnbindAtExit.iterator(); i.hasNext(); )
+ {
+ String name = (String)i.next();
+
+ initialContext.unbind(name);
+ }
+ }
+
+ private void executeStatement(TransactionManager mgr, DataSource ds, String statement) throws Exception
+ {
+ Connection conn = null;
+ boolean exception = false;
+
+ try
+ {
+ try
+ {
+ mgr.begin();
+
+ conn = ds.getConnection();
+
+ log.debug("executing " + statement);
+
+ PreparedStatement ps = conn.prepareStatement(statement);
+
+ ps.executeUpdate();
+
+ log.debug(statement + " executed");
+
+ ps.close();
+ }
+ catch (SQLException e)
+ {
+ // Ignore
+ log.debug("Failed to execute statement", e);
+ exception = true;
+ }
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+
+ if (exception)
+ {
+ mgr.rollback();
+ }
+ else
+ {
+ mgr.commit();
+ }
+ }
+
+
+ }
+
+ protected void dropAllTables() throws Exception
+ {
+ log.info("DROPPING ALL TABLES FROM DATABASE!");
+
+ InitialContext ctx = new InitialContext();
+
+ // We need to execute each drop in its own transaction otherwise postgresql will not execute
+ // further commands after one fails
+
+ TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
+ DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
+
+ javax.transaction.Transaction txOld = mgr.suspend();
+
+ executeStatement(mgr, ds, "DROP TABLE JBM_POSTOFFICE");
+
+ executeStatement(mgr, ds, "DROP TABLE JBM_MSG_REF");
+
+ executeStatement(mgr, ds, "DROP TABLE JBM_MSG");
+
+ executeStatement(mgr, ds, "DROP TABLE JBM_TX");
+
+ executeStatement(mgr, ds, "DROP TABLE JBM_COUNTER");
+
+ executeStatement(mgr, ds, "DROP TABLE JBM_USER");
+
+ executeStatement(mgr, ds, "DROP TABLE JBM_ROLE");
+
+ if (txOld != null)
+ {
+ mgr.resume(txOld);
+ }
+
+ log.debug("done with dropping tables");
+ }
+
+ protected void deleteAllData() throws Exception
+ {
+ log.info("DELETING ALL DATA FROM DATABASE!");
+
+ InitialContext ctx = new InitialContext();
+
+ // We need to execute each drop in its own transaction otherwise postgresql will not execute
+ // further commands after one fails
+
+ TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
+ DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
+
+ javax.transaction.Transaction txOld = mgr.suspend();
+
+ executeStatement(mgr, ds, "DELETE FROM JBM_POSTOFFICE");
+
+ executeStatement(mgr, ds, "DELETE FROM JBM_MSG_REF");
+
+ executeStatement(mgr, ds, "DELETE FROM JBM_MSG");
+
+ executeStatement(mgr, ds, "DELETE FROM JBM_TX");
+
+ executeStatement(mgr, ds, "DELETE FROM JBM_COUNTER");
+
+ executeStatement(mgr, ds, "DELETE FROM JBM_USER");
+
+ executeStatement(mgr, ds, "DELETE FROM JBM_ROLE");
+
+ if (txOld != null)
+ {
+ mgr.resume(txOld);
+ }
+
+ log.debug("done with the deleting data");
+ }
+
+ private void startMultiplexer() throws Exception
+ {
+ log.debug("Starting multiplexer");
+
+ String multiplexerConfigFile = "server/default/deploy/multiplexer-service.xml";
+ URL multiplexerCofigURL = getClass().getClassLoader().getResource(multiplexerConfigFile);
+
+ if (multiplexerCofigURL == null)
+ {
+ throw new Exception("Cannot find " + multiplexerCofigURL + " in the classpath");
+ }
+
+ ServiceDeploymentDescriptor multiplexerDD = ServiceConfigHelper.loadConfigFile(multiplexerConfigFile);
+
+ List services = multiplexerDD.query("name", "Multiplexer");
+
+ if (services.isEmpty())
+ {
+ log.info("Couldn't find multiplexer config");
+ }
+ else
+ {
+ log.info("Could find multiplexer config");
+ }
+
+ MBeanConfigurationElement multiplexerConfig =
+ (MBeanConfigurationElement)services.iterator().next();
+ ObjectName nameMultiplexer = registerAndConfigureService(multiplexerConfig);
+ invoke(nameMultiplexer,"create", new Object[0], new String[0]);
+ invoke(nameMultiplexer,"start", new Object[0], new String[0]);
+ }
+
+ private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides)
+ throws Exception
+ {
+ if (attrOverrides == null)
+ {
+ return;
+ }
+
+ Map sao = attrOverrides.get(on);
+
+ for(Iterator i = sao.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String attrName = (String)entry.getKey();
+ Object attrValue = entry.getValue();
+ setAttribute(on, attrName, attrValue.toString());
+
+ }
+ }
+
+ public void deployConnectionFactories(String connFactoryConfigFile,
+ ServiceAttributeOverrides attrOverrides) throws Exception
+ {
+ connFactoryObjectNames.clear();
+
+ ServiceDeploymentDescriptor cfdd = ServiceConfigHelper.loadConfigFile(connFactoryConfigFile);
+
+ List connFactoryElements = cfdd.query("service", "ConnectionFactory");
+
+ for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
+ {
+ MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
+ ObjectName on = registerAndConfigureService(connFactoryElement);
+ overrideAttributes(on, attrOverrides);
+ // dependencies have been automatically injected already
+ invoke(on, "create", new Object[0], new String[0]);
+ invoke(on, "start", new Object[0], new String[0]);
+ connFactoryObjectNames.add(on);
+ }
+
+ connFactoryElements = cfdd.query("service", "ClusteredConnectionFactory");
+
+ for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
+ {
+ MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
+ ObjectName on = registerAndConfigureService(connFactoryElement);
+ overrideAttributes(on, attrOverrides);
+ // dependencies have been automatically injected already
+ invoke(on, "create", new Object[0], new String[0]);
+ invoke(on, "start", new Object[0], new String[0]);
+ connFactoryObjectNames.add(on);
+ }
+
+ connFactoryElements = cfdd.query("service", "HTTPConnectionFactory");
+
+ for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
+ {
+ MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
+ ObjectName on = registerAndConfigureService(connFactoryElement);
+ overrideAttributes(on, attrOverrides);
+ // dependencies have been automatically injected already
+ invoke(on, "create", new Object[0], new String[0]);
+ invoke(on, "start", new Object[0], new String[0]);
+ connFactoryObjectNames.add(on);
+ }
+
+ connFactoryElements = cfdd.query("service", "ClusterPullConnectionFactory");
+
+ for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
+ {
+ MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
+ ObjectName on = registerAndConfigureService(connFactoryElement);
+ overrideAttributes(on, attrOverrides);
+ // dependencies have been automatically injected already
+ invoke(on, "create", new Object[0], new String[0]);
+ invoke(on, "start", new Object[0], new String[0]);
+ connFactoryObjectNames.add(on);
+ }
+ }
+
+
+
+ private void parseConfig(String config)
+ {
+ config = config.toLowerCase();
+ for (StringTokenizer st = new StringTokenizer(config, ", "); st.hasMoreTokens(); )
+ {
+ String tok = st.nextToken();
+ boolean minus = false;
+
+ supportsFailover = true;
+
+ if (tok.startsWith("-"))
+ {
+ tok = tok.substring(1);
+ minus = true;
+ }
+
+ if ("all".equals(tok))
+ {
+ transaction = true;
+ database = true;
+ jca = true;
+ remoting = true;
+ security = true;
+ }
+ else
+ if ("all-failover".equals(tok))
+ {
+ transaction = true;
+ database = true;
+ jca = true;
+ remoting = true;
+ security = true;
+ supportsFailover = false;
+ }
+ else
+ if ("all+http".equals(tok))
+ {
+ transaction = true;
+ database = true;
+ jca = true;
+ remoting = true;
+ security = true;
+ httpConnectionFactory = true;
+ }
+ else if ("transaction".equals(tok))
+ {
+ transaction = true;
+ if (minus)
+ {
+ transaction = false;
+ }
+ }
+ else if ("jbossjta".equals(tok))
+ {
+ if (transaction)
+ {
+ throw new IllegalArgumentException("Cannot have the old JBoss transaction manager AND the JBoss Transactions transaction manager");
+ }
+
+ //Use the JBoss Transactions (ex Arjuna) JTA
+ jbossjta = true;
+ if (minus)
+ {
+ jbossjta = false;
+ }
+ }
+ else if ("database".equals(tok))
+ {
+ database = true;
+ if (minus)
+ {
+ database = false;
+ }
+ }
+ else if ("jca".equals(tok))
+ {
+ jca = true;
+ if (minus)
+ {
+ jca = false;
+ }
+ }
+ else if ("remoting".equals(tok))
+ {
+ remoting = true;
+ if (minus)
+ {
+ remoting = false;
+ }
+ }
+ else if ("security".equals(tok))
+ {
+ security = true;
+ if (minus)
+ {
+ security = false;
+ }
+ }
+ else if ("multiplexer".equals(tok))
+ {
+ multiplexer = true;
+ if (minus)
+ {
+ multiplexer = false;
+ }
+ }
+ else if ("none".equals(tok))
+ {
+ transaction = false;
+ database = false;
+ jca = false;
+ remoting = false;
+ security = false;
+ multiplexer = false;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown service: " + tok);
+ }
+ }
+ }
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceContainerConfiguration.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceContainerConfiguration.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/ServiceContainerConfiguration.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,424 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.tools.container;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import org.jboss.messaging.util.XMLUtil;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+class ServiceContainerConfiguration
+{
+ // Constants -----------------------------------------------------
+
+ public static final boolean DEFAULT_CLUSTERED_MODE = false;
+
+ // Static --------------------------------------------------------
+
+ public static String getHypersonicDatabase(String connectionURL)
+ {
+ StringTokenizer st = new StringTokenizer(connectionURL, ":");
+
+ if (!"jdbc".equals(st.nextToken()) || !"hsqldb".equals(st.nextToken()))
+ {
+ throw new IllegalArgumentException("Invalid Hypersonic connection URL: " + connectionURL);
+ }
+
+ String s = st.nextToken();
+ String s2 = st.nextToken();
+
+ return s + ":" + s2;
+ }
+
+ public static String getHypersonicDbname(String connectionURL)
+ {
+ StringTokenizer st = new StringTokenizer(connectionURL, ":");
+
+ if (!"jdbc".equals(st.nextToken()) || !"hsqldb".equals(st.nextToken()))
+ {
+ throw new IllegalArgumentException("Invalid Hypersonic connection URL: " + connectionURL);
+ }
+
+ String s = st.nextToken();
+ String s2 = st.nextToken();
+
+ return s + s2;
+ }
+
+ public static void validateTransactionIsolation(String s) throws IllegalArgumentException
+ {
+ if (!"NONE".equals(s) && !"TRANSACTION_READ_COMMITTED".equals(s))
+ {
+ throw new IllegalArgumentException("Invalid transaction isolation: " + s);
+ }
+ }
+
+ // Attributes ----------------------------------------------------
+
+ private String database;
+ private Map dbConfigurations;
+ private String remotingTransport;
+ private Boolean clusteredMode;
+
+ // Constructors --------------------------------------------------
+
+ public ServiceContainerConfiguration(InputStream is) throws Exception
+ {
+ dbConfigurations = new HashMap();
+ parse(is);
+ validate();
+ }
+
+ // Public --------------------------------------------------------
+
+ public String getDatabaseName()
+ {
+ return database;
+ }
+
+ public String getDatabaseConnectionURL()
+ {
+ DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
+ return dbc.getDatabaseConnectionURL();
+ }
+
+ public String getDatabaseDriverClass()
+ {
+ DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
+ return dbc.getDatabaseDriverClass();
+ }
+
+ public String getDatabaseTransactionIsolation()
+ {
+ DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
+ return dbc.getDatabaseTransactionIsolation();
+ }
+
+ public String getDatabaseUserName()
+ {
+ DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
+ return dbc.getDatabaseUserName();
+ }
+
+ public String getDatabasePassword()
+ {
+ DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
+ return dbc.getDatabasePassword();
+ }
+
+ /**
+ * @return the transport the container wants the Remoting Connector to use.
+ */
+ public String getRemotingTransport()
+ {
+ return remotingTransport;
+ }
+
+ /**
+ * @return the clustered mode in which the container should run an individual test.
+ */
+ public boolean isClustered()
+ {
+ return clusteredMode.booleanValue();
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private void parse(InputStream is) throws Exception
+ {
+ Reader reader = new InputStreamReader(is);
+ String currentDatabase = null;
+ String currentRemotingTransport = null;
+ boolean currentClusteredMode = DEFAULT_CLUSTERED_MODE;
+
+ try
+ {
+ Element root = XMLUtil.readerToElement(reader);
+
+ if (!"container".equals(root.getNodeName()))
+ {
+ throw new Exception("Invalid root element: " + root.getNodeName());
+ }
+
+ if (root.hasChildNodes())
+ {
+ NodeList nl = root.getChildNodes();
+ for(int i = 0; i < nl.getLength(); i++)
+ {
+ Node n = nl.item(i);
+ int type = n.getNodeType();
+
+ if (type == Node.TEXT_NODE ||
+ type == Node.COMMENT_NODE)
+ {
+ continue;
+ }
+
+ String name = n.getNodeName();
+
+ if ("database-configurations".equals(name))
+ {
+ parseDatabaseConfigurations(n);
+ }
+ else if ("database".equals(name))
+ {
+ currentDatabase = XMLUtil.getTextContent(n);
+ }
+ else if ("remoting-transport".equals(name))
+ {
+ currentRemotingTransport = XMLUtil.getTextContent(n);
+ }
+ else if ("clustered".equals(name))
+ {
+ currentClusteredMode = Boolean.getBoolean(XMLUtil.getTextContent(n));
+ }
+ else
+ {
+ throw new Exception("Unexpected child <" + name + "> of node " +
+ root.getNodeName() + ", type " + type);
+ }
+ }
+ }
+
+ setCurrentDatabase(currentDatabase);
+ setCurrentRemotingTransport(currentRemotingTransport);
+ setCurrentClusteredMode(currentClusteredMode);
+ }
+ finally
+ {
+ reader.close();
+ }
+ }
+
+ /**
+ * Always the value of "test.database" system property takes precedence over the configuration
+ * file value.
+ */
+ private void setCurrentDatabase(String xmlConfigDatabase)
+ {
+ database = System.getProperty("test.database");
+ if (database == null)
+ {
+ database = xmlConfigDatabase;
+ }
+ }
+
+ private void setCurrentRemotingTransport(String xmlRemotingTransport)
+ {
+ remotingTransport = System.getProperty("test.remoting");
+ if (remotingTransport == null)
+ {
+ remotingTransport = xmlRemotingTransport;
+ }
+ }
+
+
+ /**
+ * Always the value of "test.clustered" system property takes precedence over the configuration
+ * file value.
+ */
+ private void setCurrentClusteredMode(boolean xmlClusteredMode) throws Exception
+ {
+ String s = System.getProperty("test.clustered");
+ if (s != null)
+ {
+ clusteredMode = Boolean.valueOf(s);
+ }
+
+ if (clusteredMode == null)
+ {
+ clusteredMode = new Boolean(xmlClusteredMode);
+ }
+ }
+
+ private void validate() throws Exception
+ {
+ // make sure that I have a corresponding "database-configuration"
+ if (database == null)
+ {
+ throw new Exception("No configured database!");
+ }
+
+ if (dbConfigurations.get(database) == null)
+ {
+ throw new Exception("No such database configuration: \"" + database + "\"");
+ }
+ }
+
+ private void parseDatabaseConfigurations(Node dbcs) throws Exception
+ {
+ if (!"database-configurations".equals(dbcs.getNodeName()))
+ {
+ throw new Exception("Expecting <database-configurations> and got <" +
+ dbcs.getNodeName() + ">");
+ }
+
+ if (dbcs.hasChildNodes())
+ {
+ NodeList nl = dbcs.getChildNodes();
+ for(int i = 0; i < nl.getLength(); i++)
+ {
+ Node n = nl.item(i);
+
+ if (n.getNodeType() == Node.TEXT_NODE)
+ {
+ continue;
+ }
+ parseDatabaseConfiguration(n);
+ }
+ }
+ }
+
+ private void parseDatabaseConfiguration(Node dbcn) throws Exception
+ {
+ if (!"database-configuration".equals(dbcn.getNodeName()))
+ {
+ throw new Exception("Expecting <database-configuration> and got <" +
+ dbcn.getNodeName() + ">");
+ }
+
+ NamedNodeMap attrs = dbcn.getAttributes();
+ Node nameNode = attrs.getNamedItem("name");
+ String configName = nameNode.getNodeValue();
+ DatabaseConfiguration dbc = new DatabaseConfiguration();
+ dbConfigurations.put(configName, dbc);
+
+ if (dbcn.hasChildNodes())
+ {
+ NodeList nl = dbcn.getChildNodes();
+ for(int i = 0; i < nl.getLength(); i++)
+ {
+ Node n = nl.item(i);
+
+ if (n.getNodeType() == Node.TEXT_NODE)
+ {
+ continue;
+ }
+
+ String name = n.getNodeName();
+ String value = XMLUtil.getTextContent(n);
+
+ if ("url".equals(name))
+ {
+ dbc.setDatabaseConnectionURL(value);
+ }
+ else if ("driver".equals(name))
+ {
+ dbc.setDatabaseDriverClass(value);
+ }
+ else if ("isolation".equals(name))
+ {
+ String s = value.toUpperCase();
+ validateTransactionIsolation(s);
+ dbc.setDatabaseTransactionIsolation(s);
+ }
+ else if ("username".equals(name))
+ {
+ dbc.setDatabaseUserName(value);
+ }
+ else if ("password".equals(name))
+ {
+ dbc.setDatabasePassword(value);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Unknown element: " + name);
+ }
+ }
+ }
+ }
+
+ // Inner classes -------------------------------------------------
+
+ private class DatabaseConfiguration
+ {
+ private String connectionURL;
+ private String driverClass;
+ private String transactionIsolation;
+ private String username;
+ private String password;
+
+ void setDatabaseConnectionURL(String s)
+ {
+ StringTokenizer st = new StringTokenizer(s, ":");
+ if (!st.hasMoreTokens())
+ {
+ throw new IllegalArgumentException("Invalid connection URL: " + s);
+ }
+ st.nextToken();
+ if (!st.hasMoreTokens())
+ {
+ throw new IllegalArgumentException("Invalid connection URL: " + s);
+ }
+
+ this.connectionURL = s;
+ }
+
+ String getDatabaseConnectionURL()
+ {
+ return connectionURL;
+ }
+
+ void setDatabaseDriverClass(String s)
+ {
+ this.driverClass = s;
+ }
+
+ String getDatabaseDriverClass()
+ {
+ return driverClass;
+ }
+
+ void setDatabaseTransactionIsolation(String s)
+ {
+ this.transactionIsolation = s;
+ }
+
+ String getDatabaseTransactionIsolation()
+ {
+ return transactionIsolation;
+ }
+
+ void setDatabaseUserName(String s)
+ {
+ this.username = s;
+ }
+
+ String getDatabaseUserName()
+ {
+ return username;
+ }
+
+ void setDatabasePassword(String s)
+ {
+ this.password = s;
+ }
+
+ String getDatabasePassword()
+ {
+ return password;
+ }
+ }
+}
Added: trunk/tests/src/org/jboss/test/messaging/tools/container/StopRMIServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/StopRMIServer.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/StopRMIServer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,117 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import java.rmi.ConnectException;
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A utility to stop runaway rmi servers.
+ *
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2876 $</tt>
+ *
+ * $Id: StopRMIServer.java 2876 2007-07-11 18:00:52Z timfox $
+ */
+public class StopRMIServer
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(StopRMIServer.class);
+
+ // Static --------------------------------------------------------
+
+ public static void main(String[] args) throws Exception
+ {
+
+ String host = System.getProperty("test.bind.address");
+ if (host == null)
+ {
+ host = "localhost";
+ }
+
+ int index;
+
+ String serverIndex = System.getProperty("test.server.index");
+ if (serverIndex == null)
+ {
+ index = RMITestServer.DEFAULT_SERVER_INDEX;
+ }
+ else
+ {
+ index = Integer.parseInt(serverIndex);
+ }
+
+ String name =
+ "//" + host + ":" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
+ RMITestServer.RMI_SERVER_PREFIX + index;
+
+ log.info("Stopping " + name);
+
+ Server server;
+ try
+ {
+ server = (Server)Naming.lookup(name);
+ }
+ catch(ConnectException e)
+ {
+ log.info("Cannot contact the registry, the server is probably shut down already");
+ return;
+ }
+ catch(NotBoundException e)
+ {
+ log.info("Cannot lookup " + name + ", the server is probably shut down already");
+ return;
+ }
+
+ try
+ {
+ server.kill();
+ }
+ catch (Throwable t)
+ {
+ }
+
+ // The last RMI server will take with it the registry too
+
+ log.info("RMI server stopped");
+
+ }
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/TransactionManagerJMXWrapper.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapper.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/TransactionManagerJMXWrapper.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/TransactionManagerJMXWrapper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import javax.transaction.TransactionManager;
+
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class TransactionManagerJMXWrapper implements TransactionManagerJMXWrapperMBean
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private TransactionManager tm;
+
+ // Constructors --------------------------------------------------
+
+ public TransactionManagerJMXWrapper(TransactionManager tm)
+ {
+ this.tm = tm;
+ }
+
+ // TransactionManagerJMXWrapperMBean implementation --------------
+
+ public TransactionManager getTransactionManager()
+ {
+ return tm;
+ }
+
+ public void start() throws Exception
+ {
+ }
+
+ public void stop() throws Exception
+ {
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/TransactionManagerJMXWrapperMBean.java (from rev 2924, trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapperMBean.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/TransactionManagerJMXWrapperMBean.java (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/TransactionManagerJMXWrapperMBean.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* 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.test.messaging.tools.container;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public interface TransactionManagerJMXWrapperMBean
+{
+ TransactionManager getTransactionManager();
+
+ void start() throws Exception;
+ void stop() throws Exception;
+
+}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapper.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapper.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,95 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import java.lang.reflect.Array;
-import java.net.URLClassLoader;
-import java.net.URL;
-
-/**
- * We extend URLClassLoader just to prevent UnifiedLoaderRepository3 to generate spurious warning
- * (in this case): "Tried to add non-URLClassLoader. Ignored". Extending ClassLoader would be fine
- * otherwise.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ClassLoaderJMXWrapper extends URLClassLoader implements ClassLoaderJMXWrapperMBean
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private ClassLoader delegate;
-
- // Constructors --------------------------------------------------
-
- public ClassLoaderJMXWrapper(ClassLoader delegate)
- {
- super(new URL[0]);
- this.delegate = delegate;
- }
-
- // ClassLoaderJMXWrapperMBean implementation ---------------------
-
- public Class loadClass(String name) throws ClassNotFoundException
- {
- if (name.endsWith("[]"))
- {
- name = name.substring(0, name.length() - 2);
-
- //The classloader of an array type is the classloader of it's element (if non primitive)
-
- Class cl = delegate.loadClass(name);
-
- Object arr = Array.newInstance(cl, 0);
-
- return arr.getClass();
- }
- else
- {
- return delegate.loadClass(name);
- }
- }
-
- // ClassLoader overrides -----------------------------------------
-
- public URL getResource(String name)
- {
- return delegate.getResource(name);
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapperMBean.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapperMBean.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ClassLoaderJMXWrapperMBean.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,33 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface ClassLoaderJMXWrapperMBean
-{
- Class loadClass(String name) throws ClassNotFoundException;
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/Example.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/Example.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/Example.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,102 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import javax.transaction.TransactionManager;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.ResultSet;
-
-/**
- * An example how to use ServiceContainer to get access to an in-memory database.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class Example
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- public static void main(String[] args) throws Exception
- {
- ServiceContainer sc = new ServiceContainer("transaction, jca, database");
- sc.start();
-
- InitialContext ic = new InitialContext();
-
- TransactionManager tm = (TransactionManager)ic.lookup("java:/TransactionManager");
- DataSource ds = (DataSource)ic.lookup("java:/DefaultDS");
- Connection c;
-
-
- tm.begin();
-
- c = ds.getConnection();
- c.createStatement().executeUpdate("CREATE TABLE SOME_TABLE (SOME_FIELD VARCHAR)");
-
- tm.commit();
-
- tm.begin();
- c = ds.getConnection();
- c.createStatement().executeUpdate("INSERT INTO SOME_TABLE VALUES ('this shouldnt get into db')");
-
- tm.rollback();
-
- tm.begin();
- c = ds.getConnection();
- c.createStatement().executeUpdate("INSERT INTO SOME_TABLE VALUES ('some value')");
-
- tm.commit();
-
-
- c = ds.getConnection();
- ResultSet rs = c.createStatement().executeQuery("SELECT SOME_FIELD FROM SOME_TABLE");
- while (rs.next())
- {
- String a = rs.getString("SOME_FIELD");
- System.out.println(a);
- }
-
-
- c.close();
- sc.stop();
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/MBeanServerBuilder.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/MBeanServerBuilder.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/MBeanServerBuilder.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,57 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.tools.jmx;
-
-import org.jboss.mx.server.MBeanServerImpl;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerDelegate;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class MBeanServerBuilder extends javax.management.MBeanServerBuilder
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public MBeanServerBuilder()
- {
- }
-
- // MBeanServerBuilder overrides ----------------------------------
-
- public MBeanServer newMBeanServer(String defaultDomain,
- MBeanServer outer,
- MBeanServerDelegate delegate)
- {
- return new MBeanServerImpl("jboss", outer, delegate);
- }
-
- public MBeanServerDelegate newMBeanServerDelegate()
- {
- return new MBeanServerDelegate();
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapper.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapper.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,102 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import javax.resource.spi.ManagedConnectionFactory;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationListener;
-import javax.management.NotificationFilter;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ManagedConnectionFactoryJMXWrapper
- implements ManagedConnectionFactoryJMXWrapperMBean, NotificationBroadcaster
-{
-
- // Attributes ----------------------------------------------------
-
- private ManagedConnectionFactory mcf;
- private List listeners;
-
- // Constructors --------------------------------------------------
-
- public ManagedConnectionFactoryJMXWrapper(ManagedConnectionFactory mcf)
- {
- this.mcf = mcf;
- listeners = new ArrayList();
- }
-
- // ManagedConnectionFactoryJMXWrapperMBean implementation --------
-
- public ManagedConnectionFactory getManagedConnectionFactory()
- {
- return mcf;
- }
-
- public ManagedConnectionFactory getMcfInstance()
- {
- return mcf;
- }
-
- public void start() throws Exception
- {
- }
-
- public void stop() throws Exception
- {
- }
-
- // NotificationBroadcaster implementation ------------------------
-
- public void addNotificationListener(NotificationListener listener, NotificationFilter filter,
- Object handback) throws IllegalArgumentException
- {
- listeners.add(listener);
- }
-
- public void removeNotificationListener(NotificationListener listener)
- throws ListenerNotFoundException
- {
- listeners.remove(listener);
- }
-
- public MBeanNotificationInfo[] getNotificationInfo()
- {
- return new MBeanNotificationInfo[0];
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapperMBean.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapperMBean.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ManagedConnectionFactoryJMXWrapperMBean.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,42 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import javax.resource.spi.ManagedConnectionFactory;
-
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface ManagedConnectionFactoryJMXWrapperMBean
-{
-
- ManagedConnectionFactory getManagedConnectionFactory();
- ManagedConnectionFactory getMcfInstance();
-
- void start() throws Exception;
- void stop() throws Exception;
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,350 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import java.security.Principal;
-import java.security.acl.Group;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashSet;
-
-import javax.security.auth.Subject;
-
-import org.jboss.logging.Logger;
-import org.jboss.security.AuthenticationManager;
-import org.jboss.security.RealmMapping;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.NobodyPrincipal;
-import org.jboss.security.AnybodyPrincipal;
-import org.jboss.security.SimpleGroup;
-import org.jboss.security.SimplePrincipal;
-
-
-/**
- * Mock Security manager for testing JMS security.
- *
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- *
- */
-public class MockJBossSecurityManager implements AuthenticationManager, RealmMapping
-{
- public static final String TEST_SECURITY_DOMAIN = "messaging-securitydomain";
-
- private static final Logger log = Logger.getLogger(MockJBossSecurityManager.class);
-
- private boolean simulateJBossJaasSecurityManager;
-
- //Authentication Manager Implementation
-
- public String getSecurityDomain()
- {
- return TEST_SECURITY_DOMAIN;
- }
-
- public boolean isValid(Principal principal, Object credential)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isValid(Principal principal, Object credential, Subject activeSubject)
- {
- if (log.isTraceEnabled()) { log.trace("principal:" + principal + " credential:" + credential); }
-
- boolean isValid = false;
-
- String username = principal == null ? null : principal.getName();
- char[] passwordChars = (char[])credential;
- String password = passwordChars == null ? null : new String(passwordChars);
-
- if (username == null)
- {
- isValid = true;
-
- if (isValid && simulateJBossJaasSecurityManager)
- {
- // modify the activeSubject, need to add to it its current roles
- // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
- // implementation must be coalesced
- addRole(activeSubject, "guest");
- }
- }
- else if ("guest".equals(username))
- {
- isValid = "guest".equals(password);
-
- if (isValid && simulateJBossJaasSecurityManager)
- {
- // modify the activeSubject, need to add to it its current roles
- // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
- // implementation must be coalesced
- addRole(activeSubject, "guest");
- }
- }
- else if ("john".equals(username))
- {
- isValid = "needle".equals(password);
-
- if (isValid && simulateJBossJaasSecurityManager)
- {
- // modify the activeSubject, need to add to it its current roles
- // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
- // implementation must be coalesced
- addRole(activeSubject, "publisher");
- addRole(activeSubject, "durpublisher");
- addRole(activeSubject, "def");
- }
- }
- // We use this user with pre-configured clientIds
- else if ("dilbert".equals(username))
- {
- isValid = "dogbert".equals(password);
-
- if (isValid && simulateJBossJaasSecurityManager)
- {
- addRole(activeSubject, "publisher");
- addRole(activeSubject, "durpublisher");
- addRole(activeSubject, "def");
- }
- }
- else if ("nobody".equals(username))
- {
- isValid = "nobody".equals(password);
-
- if (isValid && simulateJBossJaasSecurityManager)
- {
- // modify the activeSubject, need to add to it its current roles
- // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
- // implementation must be coalesced
- addRole(activeSubject, "noacc");
- }
- }
- else if ("dynsub".equals(username))
- {
- isValid = "dynsub".equals(password);
-
- if (isValid && simulateJBossJaasSecurityManager)
- {
- // modify the activeSubject, need to add to it its current roles
- // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
- // implementation must be coalesced
- addRole(activeSubject, "publisher");
- addRole(activeSubject, "durpublisher");
- }
- }
- else
- {
- isValid = false;
- }
-
- return isValid;
- }
-
- public Subject getActiveSubject()
- {
- throw new UnsupportedOperationException();
- }
-
- //RealmMapping implementation
-
- public Principal getPrincipal(Principal principal)
- {
- throw new UnsupportedOperationException();
- }
-
- private boolean containsRole(String roleName, Set roles)
- {
- Iterator iter = roles.iterator();
- while (iter.hasNext())
- {
- Principal p = (Principal)iter.next();
- if (p.getName().equals(roleName))
- {
- return true;
- }
- }
- return false;
- }
-
- public boolean doesUserHaveRole(Principal principal, Set roles)
- {
- // introduced the possiblity to "simulate" JaasSecurityManager behavior, which is ingnoring
- // the principal passed as argument and looking at thread context for active subject; this
- // would allow us to catch some problems earlier at functional testsuite level, and not
- // wait for integration or smoke test. However, the "correct" place for this kind of test
- // is at integration testsuite level.
-
- if (simulateJBossJaasSecurityManager)
- {
- boolean hasRole = false;
- // check that the caller is authenticated to the current thread
- Subject subject = SecurityAssociation.getSubject();
-
- if (subject != null)
- {
- // Check the caller's roles
- Group subjectRoles = getSubjectRoles(subject);
- if (subjectRoles != null)
- {
- Iterator iter = roles.iterator();
- while (!hasRole && iter.hasNext())
- {
- Principal role = (Principal)iter.next();
- hasRole = doesRoleGroupHaveRole(role, subjectRoles);
- }
- }
- }
- return hasRole;
- }
- else
- {
- // "alternate" MockJBossSecurityManager behavior, we actually look at 'principal' passed as
- // parameter
-
- String username = principal == null ? "guest" : principal.getName();
-
- if (log.isTraceEnabled())
- {
- log.trace("doesUserHaveRole:" + username);
- }
-
- if ("guest".equals(username))
- {
- return containsRole("guest", roles);
- }
- else if ("john".equals(username))
- {
- return containsRole("publisher", roles) ||
- containsRole("durpublisher", roles) ||
- containsRole("def", roles);
- }
- else if ("dynsub".equals(username))
- {
- return containsRole("publisher", roles)||
- containsRole("durpublisher", roles);
- }
- else if ("nobody".equals(username))
- {
- return containsRole("noacc", roles);
- }
- else if ("dilbert".equals(username))
- {
- return containsRole("durpublisher", roles);
- }
- else
- {
- return false;
- }
- }
- }
-
- public Set getUserRoles(Principal principal)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setSimulateJBossJaasSecurityManager(boolean b)
- {
- simulateJBossJaasSecurityManager = b;
- }
-
- public boolean isSimulateJBossJaasSecurityManager()
- {
- return simulateJBossJaasSecurityManager;
- }
-
- /**
- * Copied from JaasSecurityManager.
- */
- private Group getSubjectRoles(Subject subject)
- {
- Set subjectGroups = subject.getPrincipals(Group.class);
- Iterator iter = subjectGroups.iterator();
- Group roles = null;
- while (iter.hasNext())
- {
- Group grp = (Group)iter.next();
- String name = grp.getName();
- if (name.equals("Roles"))
- {
- roles = grp;
- }
- }
- return roles;
- }
-
- /**
- * Copied from JaasSecurityManager.
- */
- private boolean doesRoleGroupHaveRole(Principal role, Group userRoles)
- {
- // First check that role is not a NobodyPrincipal
- if (role instanceof NobodyPrincipal)
- {
- return false;
- }
-
- // Check for inclusion in the user's role set
- boolean isMember = userRoles.isMember(role);
- if (!isMember)
- {
- // Check the AnybodyPrincipal special cases
- isMember = (role instanceof AnybodyPrincipal);
- }
-
- return isMember;
- }
-
- private void addRole(Subject subject, String role)
- {
- Set groups = subject.getPrincipals(Group.class);
-
- if(groups == null || groups.isEmpty())
- {
- Group g = new SimpleGroup("Roles");
- subject.getPrincipals().add(g);
- groups = new HashSet();
- groups.add(g);
- }
-
- Group roles = null;
-
- for(Iterator i = groups.iterator(); i.hasNext(); )
- {
- Group g = (Group)i.next();
- if ("Roles".equals(g.getName()))
- {
- roles = g;
- }
- }
-
- if (roles == null)
- {
- roles = new SimpleGroup("Roles");
- subject.getPrincipals().add(roles);
- }
-
- roles.addMember(new SimplePrincipal(role));
-
- }
-
-}
\ No newline at end of file
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/NoopInvoker.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/NoopInvoker.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/NoopInvoker.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,69 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import java.io.Serializable;
-
-import org.jboss.invocation.Invocation;
-import org.jboss.invocation.Invoker;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-class NoopInvoker implements Serializable, Invoker
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = -7508123339922333502L;
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Invoker implementation ----------------------------------------
-
- public String getServerHostName() throws Exception
- {
- return "localhost";
- }
-
- public Object invoke(Invocation invocation) throws Exception
- {
- return null;
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapper.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapper.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,158 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.remoting.ConnectionListener;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.transport.Connector;
-
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class RemotingJMXWrapper implements RemotingJMXWrapperMBean
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private InvokerLocator locator;
-
- // DO NOT expose the Connector instance externally bacause consistency of subsytemToHandler map
- // may be compromised!
- private Connector connector;
-
- private Map subsystemToHandler;
-
- // Constructors --------------------------------------------------
-
- public RemotingJMXWrapper(InvokerLocator locator)
- {
- this.locator = locator;
- this.subsystemToHandler = new HashMap();
- }
-
- // RemotingJMXWrapper implementation -----------------------------
-
- public void start() throws Exception
- {
- if (connector != null)
- {
- return;
- }
-
- connector = new Connector();
- connector.setInvokerLocator(locator.getLocatorURI());
- connector.start();
- }
-
- public void stop() throws Exception
- {
- if (connector == null)
- {
- return;
- }
-
- connector.stop();
- connector = null;
- subsystemToHandler.clear();
- }
-
- public RemotingJMXWrapper getInstance()
- {
- return this;
- }
-
- public String getInvokerLocator() throws Exception
- {
- if (connector != null)
- {
- return connector.getInvokerLocator();
- }
- return null;
- }
-
- public Set getConnectorSubsystems()
- {
- // create a serializable Set instance
- return new HashSet(subsystemToHandler.keySet());
- }
-
- public ServerInvocationHandler addInvocationHandler(String subsystem, ServerInvocationHandler h)
- throws Exception
- {
- if (connector != null)
- {
- subsystemToHandler.put(subsystem, h);
- return connector.addInvocationHandler(subsystem, h);
- }
- return null;
- }
-
- public void removeInvocationHandler(String subsystem) throws Exception
- {
- subsystemToHandler.remove(subsystem);
- connector.removeInvocationHandler(subsystem);
- }
-
- public void addConnectionListener(ConnectionListener listener)
- {
- connector.addConnectionListener(listener);
- }
-
- public void removeConnectionListener(ConnectionListener listener)
- {
- connector.removeConnectionListener(listener);
- }
-
- public void setLeasePeriod(long leasePeriod)
- {
- connector.setLeasePeriod(leasePeriod);
- }
-
- public long getLeasePeriod()
- {
- return connector.getLeasePeriod();
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapperMBean.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapperMBean.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/RemotingJMXWrapperMBean.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,77 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import org.jboss.remoting.ConnectionListener;
-import org.jboss.remoting.ServerInvocationHandler;
-
-import java.util.Set;
-
-/**
- * Note: This wrapper MUST NOT allow direct access to the Connector instance. This is necessary
- * because the wrapper is maintaining the mapping between the Connector's
- * ServerInvocationHandler instances and their subsystem names. Remoting should do that (it
- * should have a Connector.getSubsystemNames() or similar), but it doesn't, so I have to do
- * this by myself.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface RemotingJMXWrapperMBean
-{
- void start() throws Exception;
- void stop() throws Exception;
-
- RemotingJMXWrapper getInstance();
-
- String getInvokerLocator() throws Exception;
-
- /**
- * This method's signature must be identical with Connector's
- * public ServerInvocationHandler addInvocationHandler(String subsystem,
- * ServerInvocationHandler handler) throws Exception;
- */
- ServerInvocationHandler addInvocationHandler(String subsystem, ServerInvocationHandler h)
- throws Exception;
-
- /**
- * This method's signature must be identical with Connector's
- * public void removeInvocationHandler(String subsystem) throws Exception;
- */
- void removeInvocationHandler(String subsystem) throws Exception;
-
- /**
- * @return Set<String> containing the subsystem names various ServerInvocationHandler instances
- * have been added under to the Connector instance.
- */
- Set getConnectorSubsystems();
-
- void addConnectionListener(ConnectionListener listener);
-
- void removeConnectionListener(ConnectionListener listener);
-
- void setLeasePeriod(long leasePeriod);
-
- long getLeasePeriod();
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceAttributeOverrides.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,77 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.tools.jmx;
-
-import javax.management.ObjectName;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ServiceAttributeOverrides implements Serializable
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final long serialVersionUID = 2347829429579213573L;
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Map<ObjectName - Map<attrName<String>-attrValue<Object>>
- private Map map;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ServiceAttributeOverrides()
- {
- map = new HashMap();
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- /**
- * @return a Map<attributeName<String>-attributeValue<Object>>. Can be empty, but never null.
- */
- public Map get(ObjectName on)
- {
- Map attrs = (Map)map.get(on);
-
- if (attrs == null)
- {
- attrs = Collections.EMPTY_MAP;
- }
- return attrs;
- }
-
- public void put(ObjectName on, String attrName, Object attrValue)
- {
- Map attrs = (Map)map.get(on);
-
- if (attrs == null)
- {
- attrs = new HashMap();
- map.put(on, attrs);
- }
-
- attrs.put(attrName, attrValue);
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceConfigHelper.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceConfigHelper.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceConfigHelper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, JBoss Inc., and individual contributors as indicated
- * 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.test.messaging.tools.jmx;
-
-import java.net.URL;
-
-import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
-import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
-
-/**
- * A helper class for loading MBean configuration files.
- *
- * @author <a href="sergey.koshcheyev at jboss.com">Sergey Koshcheyev</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ServiceConfigHelper
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- /**
- * Load a service deployment descriptor from the specified file on
- * the class path.
- */
- public static ServiceDeploymentDescriptor loadConfigFile(String configFile) throws Exception
- {
- URL url = ServiceConfigHelper.class.getClassLoader().getResource(configFile);
- if (url == null)
- {
- throw new Exception("Cannot find " + configFile + " in the classpath");
- }
-
- return new ServiceDeploymentDescriptor(url);
- }
-
- /**
- * Load the service deployment descriptor from the specified file on
- * the class path and return the configuration element of the specified service.
- */
- public static MBeanConfigurationElement loadServiceConfiguration(String configFile, String serviceName) throws Exception
- {
- ServiceDeploymentDescriptor sdd = loadConfigFile(configFile);
- return getServiceConfiguration(sdd, serviceName);
- }
-
- public static MBeanConfigurationElement getServiceConfiguration(ServiceDeploymentDescriptor descriptor, String serviceName)
- {
- return (MBeanConfigurationElement) descriptor.query("service", serviceName).get(0);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,1802 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import javax.management.Attribute;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.spi.NamingManager;
-import javax.sql.DataSource;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-
-import org.hsqldb.Server;
-import org.hsqldb.persist.HsqlProperties;
-import org.jboss.jms.jndi.JMSProviderAdapter;
-import org.jboss.jms.jndi.JNDIProviderAdapter;
-import org.jboss.jms.server.ServerPeer;
-import org.jboss.jms.server.remoting.JMSServerInvocationHandler;
-import org.jboss.logging.Logger;
-import org.jboss.messaging.util.JNDIUtil;
-import org.jboss.messaging.util.XMLUtil;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory;
-import org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService;
-import org.jboss.resource.adapter.jms.JmsManagedConnectionFactory;
-import org.jboss.resource.connectionmanager.CachedConnectionManager;
-import org.jboss.resource.connectionmanager.CachedConnectionManagerMBean;
-import org.jboss.resource.connectionmanager.ConnectionFactoryBindingService;
-import org.jboss.resource.connectionmanager.JBossManagedConnectionPool;
-import org.jboss.resource.connectionmanager.TxConnectionManager;
-import org.jboss.system.Registry;
-import org.jboss.system.ServiceController;
-import org.jboss.system.ServiceCreator;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
-import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
-import org.jboss.test.messaging.tools.jndi.Constants;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactoryBuilder;
-import org.jboss.tm.TransactionManagerService;
-import org.jboss.tm.TxManager;
-import org.jboss.tm.usertx.client.ServerVMClientUserTransaction;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import com.arjuna.ats.arjuna.recovery.RecoveryManager;
-
-/**
- * An MBeanServer and a configurable set of services (TransactionManager, Remoting, etc) available
- * for testing.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ServiceContainer
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(ServiceContainer.class);
-
- private static final String CONFIGURATION_FILE_NAME = "container.xml";
-
- public static final String DO_NOT_USE_MESSAGING_MARSHALLERS = "DO_NOT_USE_MESSAGING_MARSHALLERS";
-
- // Static ---------------------------------------------------------------------------------------
-
- public static ObjectName SERVICE_CONTROLLER_OBJECT_NAME;
- public static ObjectName CLASS_LOADER_OBJECT_NAME;
- public static ObjectName TRANSACTION_MANAGER_OBJECT_NAME;
- public static ObjectName CACHED_CONNECTION_MANAGER_OBJECT_NAME;
-
- public static ObjectName DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME;
- public static ObjectName DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME;
- public static ObjectName DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME;
- public static ObjectName DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME;
-
- public static ObjectName JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME;
- public static ObjectName JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME;
- public static ObjectName JMS_CONNECTION_MANAGER_OBJECT_NAME;
- public static ObjectName JMS_CONNECTION_FACTORY_BINDING_SERVICE_OBJECT_NAME;
-
- public static ObjectName REMOTING_OBJECT_NAME;
-
- // Used only on testcases where Socket and HTTP are deployed at the same time
- public static ObjectName HTTP_REMOTING_OBJECT_NAME;
-
- public static ObjectName SERVER_PEER_OBJECT_NAME;
-
- public static String DATA_SOURCE_JNDI_NAME = "java:/DefaultDS";
- public static String TRANSACTION_MANAGER_JNDI_NAME = "java:/TransactionManager";
- public static String USER_TRANSACTION_JNDI_NAME = "UserTransaction";
- public static String JCA_JMS_CONNECTION_FACTORY_JNDI_NAME = "java:/JCAConnectionFactory";
-
- // Must match the value in remoting-http-service.xml
- public static long HTTP_CONNECTOR_CALLBACK_POLL_PERIOD = 102;
-
- // List<ObjectName>
- private List connFactoryObjectNames = new ArrayList();
-
- static
- {
- try
- {
- SERVICE_CONTROLLER_OBJECT_NAME =
- new ObjectName("jboss.system:service=ServiceController");
- CLASS_LOADER_OBJECT_NAME =
- new ObjectName("jboss.system:service=ClassLoader");
- TRANSACTION_MANAGER_OBJECT_NAME =
- new ObjectName("jboss:service=TransactionManager");
- CACHED_CONNECTION_MANAGER_OBJECT_NAME =
- new ObjectName("jboss.jca:service=CachedConnectionManager");
-
- DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME =
- new ObjectName("jboss.jca:name=DefaultDS,service=LocalTxCM");
- DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME =
- new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionFactory");
- DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME =
- new ObjectName("jboss.jca:name=DefaultDS,service=ManagedConnectionPool");
- DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME =
- new ObjectName("jboss.jca:name=DefaultDS,service=DataSourceBinding");
-
- JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME =
- new ObjectName("jboss.jca:service=ManagedConnectionFactory,name=JCAConnectionFactory");
- JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME =
- new ObjectName("jboss.jca:service=ManagedConnectionPool,name=JCAConnectionFactory");
- JMS_CONNECTION_MANAGER_OBJECT_NAME =
- new ObjectName("jboss.jca:service=TxCM,name=JCAConnectionFactory");
- JMS_CONNECTION_FACTORY_BINDING_SERVICE_OBJECT_NAME =
- new ObjectName("jboss.jca:service=ConnectionFactoryBinding,name=JCAConnectionFactory");
-
- REMOTING_OBJECT_NAME =
- new ObjectName("jboss.messaging:service=Connector,transport=bisocket");
-
- HTTP_REMOTING_OBJECT_NAME =
- new ObjectName("jboss.messaging:service=Connector,transport=http");
-
- SERVER_PEER_OBJECT_NAME =
- new ObjectName("jboss.messaging:service=ServerPeer");
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public static String getCurrentAddress() throws Exception
- {
- String currentAddress = System.getProperty("test.bind.address");
-
- if (currentAddress == null)
- {
- currentAddress = "localhost";
- }
- return currentAddress;
- }
-
- // Attributes -----------------------------------------------------------------------------------
-
- private ServiceContainerConfiguration config;
-
- private TransactionManager tm;
-
- private MBeanServer mbeanServer;
- private ServiceCreator serviceCreator; // the 'creator' helps in creating and registering XMBeans
- private InitialContext initialContext;
- private String jndiNamingFactory;
- private Server hsqldbServer;
- private RecoveryManager recoveryManager;
-
- private boolean transaction;
- private boolean jbossjta; //To use the ex-Arjuna tx mgr
- private boolean database;
- private boolean jca;
- private boolean remoting;
- private boolean security;
- private boolean supportsFailover = true;
- private boolean httpConnectionFactory;
- private boolean multiplexer; // the JGroups channels multiplexer
-
- private List toUnbindAtExit;
- private String ipAddressOrHostName;
-
- // There may be many service containers on the same machine, so we need to distinguish them
- // so we don't start up multiple servers with services running on the same port
- private int serverIndex;
-
- // Static ---------------------------------------------------------------------------------------
-
- public static Object type(MBeanInfo mbeanInfo, String attributeName, String valueAsString)
- throws Exception
- {
- MBeanAttributeInfo[] attrs = mbeanInfo.getAttributes();
- MBeanAttributeInfo attr = null;
-
- for(int i = 0; i < attrs.length; i++)
- {
- if (attrs[i].getName().equals(attributeName))
- {
- attr = attrs[i];
- break;
- }
- }
-
- if (attr == null)
- {
- throw new Exception("No such attribute: " + attributeName);
- }
-
- String type = attr.getType();
-
- if ("int".equals(type) || "java.lang.Integer".equals(type))
- {
- int i = Integer.parseInt(valueAsString);
- return new Integer(i);
- }
- else if ("long".equals(type) || "java.lang.Long".equals(type))
- {
- long l = Long.parseLong(valueAsString);
- return new Long(l);
- }
- else if ("boolean".equals(type) || "java.lang.Boolean".equals(type))
- {
- boolean b = Boolean.valueOf(valueAsString).booleanValue();
- return new Boolean(b);
- }
- else if ("java.lang.String".equals(type))
- {
- return valueAsString;
- }
- else if ("javax.management.ObjectName".equals(type))
- {
- return new ObjectName(valueAsString);
- }
- else if ("org.w3c.dom.Element".equals(type))
- {
- if (valueAsString == null)
- {
- return null;
- }
- else
- {
- return XMLUtil.stringToElement(valueAsString);
- }
- }
- else if (type.startsWith("org.jboss."))
- {
- Class interfazza = ServiceContainer.class.getClassLoader().loadClass(type);
- Class implementation = ServiceContainer.class.getClassLoader().loadClass(valueAsString);
- return implementation.newInstance();
- }
- else if (type.startsWith("java.util.Properties"))
- {
- ByteArrayInputStream is = new ByteArrayInputStream(valueAsString.getBytes());
- Properties props = new Properties();
- props.load(is);
- return props;
- }
-
- throw new Exception("Don't know to handle type " + type);
-
- }
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ServiceContainer(String servicesToStart) throws Exception
- {
- this(servicesToStart, null);
- }
-
- public ServiceContainer(String sevicesToStart, int serverIndex) throws Exception
- {
- this(sevicesToStart, null, serverIndex);
- }
-
- /**
- * @param sevicesToStart - A comma separated list of services to be started. Available services:
- * transaction, jca, database, remoting. Example: "transaction, database, remoting".
- * "all" will start every service available. A dash in front of a service name will
- * disable that service. Example "all,-database".
- * @param tm - specifies a specific TransactionManager instance to bind into the mbeanServer.
- * If null, the default JBoss TransactionManager implementation will be used.
- */
- public ServiceContainer(String sevicesToStart, TransactionManager tm) throws Exception
- {
- this.tm = tm;
- parseConfig(sevicesToStart);
- toUnbindAtExit = new ArrayList();
- this.serverIndex = 0;
- }
-
- public ServiceContainer(String sevicesToStart, TransactionManager tm, int serverIndex)
- throws Exception
- {
- this.tm = tm;
- parseConfig(sevicesToStart);
- toUnbindAtExit = new ArrayList();
- this.serverIndex = serverIndex;
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public void start() throws Exception
- {
- start(true);
- }
-
- public void start(boolean cleanDatabase) throws Exception
- {
- start(cleanDatabase, null);
- }
-
- public void start(boolean cleanDatabase, ServiceAttributeOverrides attrOverrides)
- throws Exception
- {
- try
- {
- readConfigurationFile();
-
- ipAddressOrHostName = getCurrentAddress();
- log.debug("all server sockets will be open on address " + ipAddressOrHostName);
-
- toUnbindAtExit.clear();
-
- jndiNamingFactory = System.getProperty("java.naming.factory.initial");
-
- //TODO: need to think more about this; if I don't do it, though, bind() fails because it tries to use "java.naming.provider.url"
- try
- {
- NamingManager.
- setInitialContextFactoryBuilder(new InVMInitialContextFactoryBuilder());
- }
- catch(IllegalStateException e)
- {
- // OK
- }
-
- Hashtable t = InVMInitialContextFactory.getJNDIEnvironment(serverIndex);
- System.setProperty("java.naming.factory.initial",
- (String)t.get("java.naming.factory.initial"));
- System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME,
- Integer.toString(serverIndex));
-
- initialContext = new InitialContext();
-
- boolean java5 = false;
-
- try
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- cl.loadClass("java.lang.management.ManagementFactory");
- java5 = true;
- }
- catch(ClassNotFoundException e)
- {
- // OK
- }
-
- if (java5)
- {
- System.setProperty("javax.management.builder.initial",
- "org.jboss.test.messaging.tools.jmx.MBeanServerBuilder");
- }
-
- mbeanServer = MBeanServerFactory.createMBeanServer("jboss");
-
- serviceCreator = new ServiceCreator(mbeanServer);
-
- startServiceController();
-
- registerClassLoader();
-
- if (jbossjta)
- {
- deleteObjectStore();
- }
-
- if (transaction || jbossjta)
- {
- startTransactionManager();
- }
-
- if (database)
- {
- startInVMDatabase();
- }
-
- if (jca)
- {
- startCachedConnectionManager(CACHED_CONNECTION_MANAGER_OBJECT_NAME);
-
- // DefaultDS specific
- startManagedConnectionFactory(DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
- startManagedConnectionPool(DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME,
- DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME,
- "ByContainer");
- startConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME, true, true,
- TRANSACTION_MANAGER_OBJECT_NAME,
- CachedConnectionManagerMBean.OBJECT_NAME,
- DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
- startWrapperDataSourceService();
- }
-
- if (database && (transaction || jbossjta) && jca && cleanDatabase)
- {
- // We make sure the database is clean (only if we have all dependencies the database,
- // otherwise we'll get an access error)
- deleteAllData();
- }
-
- if (remoting)
- {
- startRemoting(attrOverrides, config.getRemotingTransport(), REMOTING_OBJECT_NAME);
- }
-
- if (security)
- {
- startSecurityManager();
- }
-
- if (multiplexer)
- {
- startMultiplexer();
- }
-
- loadJNDIContexts();
-
- log.debug("loaded JNDI context");
-
-
- String transport = config.getRemotingTransport();
-
- log.info("Remoting type: .............. " + (remoting ? transport : "DISABLED"));
- log.info("Clustering mode: ............ " +
- (this.isClustered() ? "CLUSTERED" : "NON-CLUSTERED"));
-
- log.debug(this + " started");
- }
- catch(Throwable e)
- {
- log.error("Failed to start ServiceContainer", e);
- throw new Exception("Failed to start ServiceContainer", e);
- }
- }
-
- public void dropTables() throws Exception
- {
- dropAllTables();
- }
-
- public void startConnectionFactories(ServiceAttributeOverrides attrOverrides) throws Exception
- {
- deployConnectionFactories("server/default/deploy/connection-factories-service.xml", attrOverrides);
-
- log.info("HTTP ConnectionFactory " + httpConnectionFactory);
- if (httpConnectionFactory)
- {
- log.info("Installing HTTP connection factory");
- ServiceAttributeOverrides httpOverride = new ServiceAttributeOverrides();
- startRemoting(httpOverride, "http", HTTP_REMOTING_OBJECT_NAME);
- deployConnectionFactories("connection-factory-http.xml", attrOverrides);
- }
-
- // bind the default JMS provider
- bindDefaultJMSProvider();
- // bind the JCA ConnectionFactory
- bindJCAJMSConnectionFactory();
- }
-
- public void stopConnectionFactories() throws Exception
- {
- for(Iterator i = connFactoryObjectNames.iterator(); i.hasNext(); )
- {
- try
- {
- ObjectName on = (ObjectName)i.next();
- invoke(on, "stop", new Object[0], new String[0]);
- invoke(on, "destroy", new Object[0], new String[0]);
- unregisterService(on);
- }
- catch (Exception ignore)
- {
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
- }
- }
- connFactoryObjectNames.clear();
-
- }
-
- public void stop() throws Exception
- {
- log.info("Stopping serviceconatiner");
-
- unloadJNDIContexts();
-
- stopService(REMOTING_OBJECT_NAME);
-
- if (httpConnectionFactory)
- {
- stopService(HTTP_REMOTING_OBJECT_NAME);
- }
-
- if (jca)
- {
- stopWrapperDataSourceService();
- stopConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME);
- stopManagedConnectionPool(DEFAULTDS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
- stopManagedConnectionFactory(DEFAULTDS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
- stopService(CACHED_CONNECTION_MANAGER_OBJECT_NAME);
- }
-
- stopService(TRANSACTION_MANAGER_OBJECT_NAME);
-
- if (database)
- {
- stopInVMDatabase();
- }
-
- unregisterClassLoader();
- stopServiceController();
- MBeanServerFactory.releaseMBeanServer(mbeanServer);
-
- if (security)
- {
- initialContext.unbind(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
- }
-
- cleanJNDI();
-
- initialContext.close();
-
- if (jndiNamingFactory != null)
- {
- System.setProperty("java.naming.factory.initial", jndiNamingFactory);
- }
-
- log.debug(this + " stopped");
- }
-
- public DataSource getDataSource()
- {
- DataSource ds = null;
- try
- {
- InitialContext ic = new InitialContext();
- ds = (DataSource)ic.lookup(DATA_SOURCE_JNDI_NAME);
- ic.close();
- }
- catch(Exception e)
- {
- log.error("Failed to look up DataSource", e);
- }
- return ds;
- }
-
- public TransactionManager getTransactionManager()
- {
- TransactionManager tm = null;
- try
- {
- InitialContext ic = new InitialContext();
- tm = (TransactionManager)ic.lookup(TRANSACTION_MANAGER_JNDI_NAME);
- ic.close();
- }
- catch(Exception e)
- {
- log.error("Failed to look up transaction manager", e);
- }
- return tm;
- }
-
- public UserTransaction getUserTransaction() throws Exception
- {
- return (UserTransaction)initialContext.lookup(USER_TRANSACTION_JNDI_NAME);
- }
-
- public Object getService(ObjectName on) throws Exception
- {
- return mbeanServer.invoke(on, "getInstance", new Object[0], new String[0]);
- }
-
- public String getPersistenceConfigFile(boolean clustered)
- {
- String databaseName = getDatabaseName();
-
- return "server/default/deploy/" + databaseName + "-persistence-service.xml";
- }
-
- public Properties getPersistenceManagerSQLProperties() throws Exception
- {
- String persistenceConfigFile = getPersistenceConfigFile(false);
- log.info("Persistence config file: .... " + persistenceConfigFile);
-
- MBeanConfigurationElement persistenceManagerConfig =
- ServiceConfigHelper.loadServiceConfiguration(persistenceConfigFile, "PersistenceManager");
-
- String props = persistenceManagerConfig.getAttributeValue("SqlProperties");
-
- if (props != null)
- {
- ByteArrayInputStream is = new ByteArrayInputStream(props.getBytes());
-
- Properties sqlProperties = new Properties();
-
- sqlProperties.load(is);
-
- return sqlProperties;
- }
- else
- {
- return null;
- }
- }
-
- public Properties getPostOfficeSQLProperties() throws Exception
- {
- String persistenceConfigFile = getPersistenceConfigFile(true);
- log.info("Persistence config file: .... " + persistenceConfigFile);
-
- MBeanConfigurationElement postOfficeConfig =
- ServiceConfigHelper.loadServiceConfiguration(persistenceConfigFile, "PostOffice");
-
- String props = postOfficeConfig.getAttributeValue("SqlProperties");
-
- if (props != null)
- {
- ByteArrayInputStream is = new ByteArrayInputStream(props.getBytes());
-
- Properties sqlProperties = new Properties();
-
- sqlProperties.load(is);
-
- return sqlProperties;
- }
- else
- {
- return null;
- }
- }
-
- /**
- * @return Set<ObjectName>
- */
- public Set query(ObjectName pattern)
- {
- if (pattern == null)
- {
- return Collections.EMPTY_SET;
- }
- return mbeanServer.queryNames(pattern, null);
- }
-
- /**
- * Creates and registers a service based on the MBean service descriptor element. Supports
- * XMBeans. The implementing class and the ObjectName are inferred from the mbean element. If
- * there are configuration attributed specified in the deployment descriptor, they are applied
- * to the service instance.
- */
- public ObjectName registerAndConfigureService(MBeanConfigurationElement mbeanConfig)
- throws Exception
- {
- ObjectName on = mbeanConfig.getObjectName();
- serviceCreator.install(on, CLASS_LOADER_OBJECT_NAME, mbeanConfig.getDelegate());
-
- // inject dependencies
- for(Iterator i = mbeanConfig.dependencyOptionalAttributeNames().iterator(); i.hasNext(); )
- {
- String name = (String)i.next();
- String value = mbeanConfig.getDependencyOptionalAttributeValue(name);
- setAttribute(on, name, value);
- }
-
- // apply attributes
- for(Iterator i = mbeanConfig.attributeNames().iterator(); i.hasNext();)
- {
- String name = (String)i.next();
- String value = mbeanConfig.getAttributeValue(name);
- setAttribute(on, name, value);
- }
-
- log.debug(mbeanConfig + " registered and configured");
- return on;
- }
-
- /**
- * Note that this method makes no assumption on whether the service was stopped or destroyed, nor
- * does it attempt to stop/destroy the service.
- */
- public void unregisterService(ObjectName on) throws Exception
- {
- mbeanServer.unregisterMBean(on);
- log.debug(on + " unregistered");
- }
-
- public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
- throws Exception
- {
- try
- {
- return mbeanServer.invoke(on, operationName, params, signature);
- }
- catch(MBeanException e)
- {
- // unwrap the exception thrown by the service
- throw (Exception)e.getCause();
- }
- }
-
- /**
- * Set the attribute value, performing String -> Object conversion as appropriate.
- */
- public void setAttribute(ObjectName on, String name, String valueAsString) throws Exception
- {
- MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(on);
- Object value = type(mbeanInfo, name, valueAsString);
- mbeanServer.setAttribute(on, new Attribute(name, value));
- }
-
- public Object getAttribute(ObjectName on, String name) throws Exception
- {
- return mbeanServer.getAttribute(on, name);
- }
-
- public void addNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
- {
- mbeanServer.addNotificationListener(on, listener, null, null);
- }
-
- public void removeNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
- {
- mbeanServer.removeNotificationListener(on, listener);
- }
-
- public MBeanServer getMBeanServer()
- {
- return mbeanServer;
- }
-
- public void bindDefaultJMSProvider() throws Exception
- {
- JNDIProviderAdapter pa = new JNDIProviderAdapter();
- pa.setQueueFactoryRef("/ConnectionFactory");
- pa.setTopicFactoryRef("/ConnectionFactory");
- pa.setFactoryRef("/ConnectionFactory");
- initialContext.bind("java:/DefaultJMSProvider", pa);
- }
-
- public void unbindDefaultJMSProvider() throws Exception
- {
- initialContext.unbind("java:/DefaultJMSProvider");
- }
-
- public void bindJCAJMSConnectionFactory() throws Exception
- {
- deployJBossJMSRA(JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
-
- startManagedConnectionPool(JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME,
- JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME,
- "ByApplication");
-
- startConnectionManager(JMS_CONNECTION_MANAGER_OBJECT_NAME, true, false, // not local, but XA(!)
- TRANSACTION_MANAGER_OBJECT_NAME,
- CachedConnectionManagerMBean.OBJECT_NAME,
- JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
-
- ObjectName on = JMS_CONNECTION_FACTORY_BINDING_SERVICE_OBJECT_NAME;
-
- // create it
- ConnectionFactoryBindingService cfBindingService = new ConnectionFactoryBindingService();
-
- // register it
- mbeanServer.registerMBean(cfBindingService, on);
-
- // configure it
- mbeanServer.setAttribute(on, new Attribute("ConnectionManager", JMS_CONNECTION_MANAGER_OBJECT_NAME));
- mbeanServer.setAttribute(on, new Attribute("JndiName", JCA_JMS_CONNECTION_FACTORY_JNDI_NAME));
- mbeanServer.setAttribute(on, new Attribute("UseJavaContext", Boolean.TRUE));
-
- // start it
- mbeanServer.invoke(on, "start", new Object[0], new String[0]);
-
- log.debug("started " + on);
- }
-
- /**
- * This method may be called twice successively, so it is important to handle graciously this
- * situation.
- */
- public void unbindJCAJMSConnectionFactory() throws Exception
- {
- ObjectName on = JMS_CONNECTION_FACTORY_BINDING_SERVICE_OBJECT_NAME;
-
- if (mbeanServer.isRegistered(on))
- {
- mbeanServer.invoke(on, "stop", new Object[0], new String[0]);
- mbeanServer.invoke(on, "destroy", new Object[0], new String[0]);
- mbeanServer.unregisterMBean(on);
- }
-
- stopConnectionManager(JMS_CONNECTION_MANAGER_OBJECT_NAME);
- stopManagedConnectionPool(JMS_MANAGED_CONNECTION_POOL_OBJECT_NAME);
- undeployJBossJMSRA(JMS_MANAGED_CONNECTION_FACTORY_OBJECT_NAME);
- }
-
- public String getDatabaseName()
- {
- return config.getDatabaseName();
- }
-
- public String getRemotingTransport()
- {
- return config.getRemotingTransport();
- }
-
- public boolean isClustered()
- {
- return config.isClustered();
- }
-
- public boolean isSupportsFailover()
- {
- return supportsFailover;
- }
-
- public void installJMSProviderAdaptor(String jndi, JMSProviderAdapter adaptor) throws Exception
- {
- log.info("Binding adaptor " + adaptor + " in JNDI: " + jndi);
- initialContext.bind(jndi, adaptor);
-
- }
-
- public void uninstallJMSProviderAdaptor(String jndi) throws Exception
- {
- initialContext.unbind(jndi);
- }
-
- public void startRecoveryManager()
- {
- log.info("Starting arjuna recovery manager");
-
- //Need to start the recovery manager manually - if deploying
- //inside JBoss this wouldn't be necessary - since you would use
- //the TransactionManagerService MBean which would start the recovery manager
- //for you
- recoveryManager = RecoveryManager.manager(RecoveryManager.INDIRECT_MANAGEMENT);
-
- log.info("Started recovery manager");
- }
-
- public void stopRecoveryManager()
- {
- if (recoveryManager != null)
- {
- recoveryManager.stop();
- }
- }
-
- public String toString()
- {
- return "ServiceContainer[" + Integer.toHexString(hashCode()) + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- /**
- * Note that this method makes no assumption on whether the service was created or started, nor
- * does it attempt to create/start the service.
- *
- * @param service - a Standard/DynamicMBean instance.
- */
- private void registerService(Object service, ObjectName on) throws Exception
- {
- mbeanServer.registerMBean(service, on);
- log.debug(service + " registered as " + on);
- }
-
- private void readConfigurationFile() throws Exception
- {
- InputStream cs = getClass().getClassLoader().getResourceAsStream(CONFIGURATION_FILE_NAME);
- if (cs == null)
- {
- throw new Exception("Cannot file container's configuration file " +
- CONFIGURATION_FILE_NAME + ". Make sure it is in the classpath.");
- }
-
- try
- {
- config = new ServiceContainerConfiguration(cs);
- }
- finally
- {
- cs.close();
- }
- }
-
- private void loadJNDIContexts() throws Exception
- {
- String[] names = {ServerManagement.DEFAULT_QUEUE_CONTEXT,
- ServerManagement.DEFAULT_TOPIC_CONTEXT};
-
- for (int i = 0; i < names.length; i++)
- {
- try
- {
- initialContext.lookup(names[i]);
- }
- catch(NameNotFoundException e)
- {
- JNDIUtil.createContext(initialContext, names[i]);
- log.debug("created context /" + names[i]);
- }
- }
- }
-
- private void unloadJNDIContexts() throws Exception
- {
- // ServerPeer should do that upon its shutdown, this is redundant
-
- String[] context = { "/topic", "/queue" };
- for(int i = 0; i < context.length; i++)
- {
- try
- {
- Context c = (Context)initialContext.lookup(context[i]);
- JNDIUtil.tearDownRecursively(c);
- }
- catch(NameNotFoundException e)
- {
- // OK
- log.debug("no context " + context[i] + " to unload, cleanup already performed");
- }
- }
- }
-
- private void startServiceController() throws Exception
- {
- // I don't really need it, because I enforce dependencies by hand, but this will keep some
- // services happy.
- ServiceController sc = new ServiceController();
- mbeanServer.registerMBean(sc, SERVICE_CONTROLLER_OBJECT_NAME);
- }
-
- private void stopServiceController() throws Exception
- {
- mbeanServer.unregisterMBean(SERVICE_CONTROLLER_OBJECT_NAME);
- }
-
- /**
- * Register a class loader used to instantiate other services.
- */
- private void registerClassLoader() throws Exception
- {
- ClassLoader cl = getClass().getClassLoader();
- mbeanServer.registerMBean(new ClassLoaderJMXWrapper(cl), CLASS_LOADER_OBJECT_NAME);
- }
-
- private void unregisterClassLoader() throws Exception
- {
- mbeanServer.unregisterMBean(CLASS_LOADER_OBJECT_NAME);
- }
-
- private void startInVMDatabase() throws Exception
- {
- if (!"hsqldb".equals(config.getDatabaseName()))
- {
- // is an out-of-process DB, and it must be stared externally
- return;
- }
-
- log.debug("starting " + config.getDatabaseName() + " in-VM");
-
- String url = config.getDatabaseConnectionURL();
- HsqlProperties props = new HsqlProperties();
- props.setProperty("server.database.0", ServiceContainerConfiguration.getHypersonicDatabase(url));
- props.setProperty("server.dbname.0", ServiceContainerConfiguration.getHypersonicDbname(url));
- props.setProperty("server.trace", "false");
- props.setProperty("server.silent", "true");
- props.setProperty("server.no_system_exit", "true");
- props.setProperty("server.port", 27862);
- props.setProperty("server.address", ipAddressOrHostName);
-
- hsqldbServer = new Server();
- hsqldbServer.setLogWriter(null);
- hsqldbServer.setProperties(props);
- hsqldbServer.start();
-
- log.debug("started " + config.getDatabaseName() + " in-VM");
- }
-
- private void stopInVMDatabase() throws Exception
- {
- if (!"hsqldb".equals(config.getDatabaseName()))
- {
- // is an out-of-process DB, and it must be stopped externally
- return;
- }
-
- log.debug("stop " + hsqldbServer);
-
- Class.forName(config.getDatabaseDriverClass());
-
- Connection conn =
- DriverManager.getConnection(config.getDatabaseConnectionURL(),
- config.getDatabaseUserName(),
- config.getDatabasePassword());
-
- Statement stat = conn.createStatement();
- stat.executeUpdate("SHUTDOWN");
- conn.close();
-
- // faster stop
- // hsqldbServer.stop();
- }
-
- private void startTransactionManager() throws Exception
- {
- if (tm == null)
- {
- if (jbossjta)
- {
- log.info("Starting arjuna tx mgr");
- tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- }
- else
- {
- log.info("Starting non arjuna tx mgr");
- tm = TxManager.getInstance();
- }
- }
-
- TransactionManagerJMXWrapper mbean = new TransactionManagerJMXWrapper(tm);
- mbeanServer.registerMBean(mbean, TRANSACTION_MANAGER_OBJECT_NAME);
- mbeanServer.invoke(TRANSACTION_MANAGER_OBJECT_NAME, "start", new Object[0], new String[0]);
- log.debug("started " + TRANSACTION_MANAGER_OBJECT_NAME);
-
- initialContext.bind(TRANSACTION_MANAGER_JNDI_NAME, tm);
- toUnbindAtExit.add(TRANSACTION_MANAGER_JNDI_NAME);
-
- log.debug("bound " + TRANSACTION_MANAGER_JNDI_NAME);
-
- initialContext.
- rebind(USER_TRANSACTION_JNDI_NAME, ServerVMClientUserTransaction.getSingleton());
-
- log.debug("bound " + USER_TRANSACTION_JNDI_NAME);
- }
-
- private boolean deleteDirectory(File directory)
- {
- if (directory.isDirectory())
- {
- String[] files = directory.list();
-
- for (int j = 0; j < files.length; j++)
- {
- if (!deleteDirectory(new File(directory, files[j])))
- {
- return false;
- }
- }
- }
-
- return directory.delete();
- }
-
- private void deleteObjectStore()
- {
- // First delete the object store - might have been left over from a previous run
-
- String objectStoreDir = System.getProperty("objectstore.dir");
-
- log.info("Deleting object store: " + objectStoreDir);
-
- if (objectStoreDir == null)
- {
- log.warn("Cannot find objectstore.dir parameter");
- }
- else
- {
- File f = new File(objectStoreDir);
-
- deleteDirectory(f);
- }
- }
-
-
-
- private void startCachedConnectionManager(ObjectName on) throws Exception
- {
- CachedConnectionManager ccm = new CachedConnectionManager();
-
- // dependencies
- ccm.setTransactionManagerServiceName(TRANSACTION_MANAGER_OBJECT_NAME);
-
- mbeanServer.registerMBean(ccm, on);
- mbeanServer.invoke(on, "start", new Object[0], new String[0]);
- log.debug("started " + on);
-
- }
-
- /**
- * Database specific.
- */
- private void startManagedConnectionFactory(ObjectName on) throws Exception
- {
- LocalManagedConnectionFactory mcf = new LocalManagedConnectionFactory();
-
- log.info("connection url:" + config.getDatabaseConnectionURL());
- log.info("driver:" + config.getDatabaseConnectionURL());
- log.info("username:" + config.getDatabaseUserName());
- log.info("password:" + config.getDatabasePassword());
-
- mcf.setConnectionURL(config.getDatabaseConnectionURL());
- mcf.setDriverClass(config.getDatabaseDriverClass());
- mcf.setUserName(config.getDatabaseUserName());
- mcf.setPassword(config.getDatabasePassword());
- String isolation = config.getDatabaseTransactionIsolation();
- if (isolation != null)
- {
- mcf.setTransactionIsolation(isolation);
- }
-
- ManagedConnectionFactoryJMXWrapper mbean = new ManagedConnectionFactoryJMXWrapper(mcf);
- mbeanServer.registerMBean(mbean, on);
- mbeanServer.invoke(on, "start", new Object[0], new String[0]);
- log.debug("started " + on);
- }
-
- /**
- * This method may be called twice successively, so it is important to handle graciously this
- * situation.
- */
- private void stopManagedConnectionFactory(ObjectName on) throws Exception
- {
- stopService(on);
- }
-
- private void startManagedConnectionPool(ObjectName on,
- ObjectName managedConnectionFactoryObjectName,
- String criteria) throws Exception
- {
- JBossManagedConnectionPool mcp = new JBossManagedConnectionPool();
- mcp.setCriteria(criteria);
-
- // dependencies
- mcp.setManagedConnectionFactoryName(managedConnectionFactoryObjectName);
-
- mbeanServer.registerMBean(mcp, on);
- mbeanServer.invoke(on, "start", new Object[0], new String[0]);
- log.debug("started " + on);
- }
-
- /**
- * This method may be called twice successively, so it is important to handle graciously this
- * situation.
- */
- private void stopManagedConnectionPool(ObjectName on) throws Exception
- {
- stopService(on);
- }
-
- private TxConnectionManager startConnectionManager(ObjectName on,
- boolean trackConnectionByTx,
- boolean localTransactions,
- ObjectName transactionManagerObjectName,
- ObjectName cachedConnectionManagerObjectName,
- ObjectName managedConnectionPoolObjectName)
- throws Exception
- {
- TxConnectionManager cm = new TxConnectionManager();
- cm.preRegister(mbeanServer, on);
- cm.setTrackConnectionByTx(trackConnectionByTx);
- cm.setLocalTransactions(localTransactions);
-
- // dependencies
- cm.setTransactionManagerService(transactionManagerObjectName);
- cm.setCachedConnectionManager(cachedConnectionManagerObjectName);
- cm.setManagedConnectionPool(managedConnectionPoolObjectName);
-
- mbeanServer.registerMBean(cm, on);
- mbeanServer.invoke(on, "start", new Object[0], new String[0]);
- log.debug("started " + on);
-
- return cm;
- }
-
- /**
- * This method may be called twice successively, so it is important to handle graciously this
- * situation.
- */
- private void stopConnectionManager(ObjectName on) throws Exception
- {
- stopService(on);
- }
-
- private void startWrapperDataSourceService() throws Exception
- {
- WrapperDataSourceService wdss = new WrapperDataSourceService();
- wdss.setJndiName(DATA_SOURCE_JNDI_NAME);
-
- // dependencies
- wdss.setConnectionManager(DEFAULTDS_CONNECTION_MANAGER_OBJECT_NAME);
- ObjectName irrelevant = new ObjectName(":name=irrelevant");
- wdss.setJMXInvokerName(irrelevant);
- Registry.bind(irrelevant, new NoopInvoker());
-
- mbeanServer.registerMBean(wdss, DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME);
- mbeanServer.invoke(DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME, "start", new Object[0], new String[0]);
-
- log.debug("started " + DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME);
- }
-
- private void stopWrapperDataSourceService() throws Exception
- {
- stopService(DEFAULTDS_WRAPPER_DATA_SOURCE_SERVICE_OBJECT_NAME);
- }
-
- private void deployJBossJMSRA(ObjectName managedConnFactoryObjectName) throws Exception
- {
- JmsManagedConnectionFactory mcf = new JmsManagedConnectionFactory();
-// mcf.setClientID("");
-// mcf.setUserName("");
-// mcf.setPassword("");
- mcf.setJmsProviderAdapterJNDI("java:/DefaultJMSProvider");
- mcf.setStrict(true);
- mcf.setSessionDefaultType("javax.jms.Queue");
-
- registerService(new ManagedConnectionFactoryJMXWrapper(mcf), managedConnFactoryObjectName);
- }
-
- /**
- * This method may be called twice successively, so it is important to handle graciously this
- * situation.
- */
- private void undeployJBossJMSRA(ObjectName managedConnFactoryObjectName) throws Exception
- {
- stopService(managedConnFactoryObjectName);
- }
-
- private String buildLocatorURI(String transport, Map overrideMap) throws Exception
- {
- // We use this from thirdparty remoting tests when we don't want to send stuff through
- // JMSWireFormat, but we want everything else in the connector's configuration to be
- // identical with what we use in Messaging
- boolean overrideMarshallers =
- overrideMap != null && overrideMap.get(DO_NOT_USE_MESSAGING_MARSHALLERS) != null;
-
- // Note that we DO NOT want the direct thread pool on the server side - since that can lead
- // to deadlocks
-
- String configFileName = "remoting/remoting-" + transport + "-service.xml";
-
- MBeanConfigurationElement connectorServiceConfig =
- ServiceConfigHelper.loadServiceConfiguration(configFileName, "Connector");
-
- String invokerConfig = connectorServiceConfig.getAttributeValue("Configuration");
-
- Element invokerElement = (Element) XMLUtil
- .stringToElement(invokerConfig)
- .getElementsByTagName("invoker").item(0);
-
- NodeList invokerAttributes = invokerElement.getElementsByTagName("attribute");
-
- StringBuffer paramsBuffer = new StringBuffer();
-
- for (int i = 0; i < invokerAttributes.getLength(); i++)
- {
- Element attr = (Element) invokerAttributes.item(i);
- if (attr.getAttribute("isParam").equals(""))
- {
- continue;
- }
-
- String key = attr.getAttribute("name");
- String value = attr.getTextContent().trim();
-
- if (overrideMarshallers &&
- (key.equals("marshaller") || key.equals("unmarshaller")))
- {
- continue;
- }
-
- if (paramsBuffer.length() > 0)
- {
- paramsBuffer.append('&');
- }
-
- if (overrideMap != null)
- {
- String valueOverride = (String)overrideMap.get(key);
- if (valueOverride != null)
- {
- value = valueOverride;
- }
- }
-
- paramsBuffer.append(key).append('=').append(value);
- }
-
- int freePort = PortUtil.findFreePort(ipAddressOrHostName);
-
- return new StringBuffer()
- .append(transport).append("://")
- .append(ipAddressOrHostName).append(':').append(freePort)
- .append("/?").append(paramsBuffer)
- .toString();
- }
-
- private void startRemoting(ServiceAttributeOverrides attrOverrides,
- String transport,
- ObjectName objectName) throws Exception
- {
- log.debug("Starting remoting transport=" + transport + " objectName=" + objectName);
- RemotingJMXWrapper mbean;
- String locatorURI = null;
-
- // some tests may want specific locator URI overrides to simulate special conditions; use
- // that with priority, if available
- Map overrideMap = null;
-
- if (attrOverrides != null)
- {
- overrideMap = attrOverrides.get(objectName);
-
- if (overrideMap != null)
- {
- locatorURI = (String)overrideMap.get("LocatorURI");
- }
- }
-
- if (locatorURI == null)
- {
- locatorURI = buildLocatorURI(transport, overrideMap);
- log.info("creating server for: " + locatorURI);
- }
-
- log.debug("Using locator uri: " + locatorURI);
-
- InvokerLocator locator = new InvokerLocator(locatorURI);
-
- log.debug("Started remoting connector on uri:" + locator.getLocatorURI());
-
- mbean = new RemotingJMXWrapper(locator);
- mbeanServer.registerMBean(mbean, objectName);
- mbeanServer.invoke(objectName, "start", new Object[0], new String[0]);
-
- ServerInvocationHandler handler = new JMSServerInvocationHandler();
-
- mbeanServer.invoke(objectName, "addInvocationHandler",
- new Object[] { ServerPeer.REMOTING_JMS_SUBSYSTEM, handler},
- new String[] { "java.lang.String",
- "org.jboss.remoting.ServerInvocationHandler"});
-
- log.debug("started " + objectName);
- }
-
-
- private void startSecurityManager() throws Exception
- {
- MockJBossSecurityManager sm = new MockJBossSecurityManager();
- this.initialContext.bind(MockJBossSecurityManager.TEST_SECURITY_DOMAIN, sm);
-
- log.debug("started JBoss Mock Security Manager");
- }
-
- private void stopService(ObjectName target) throws Exception
- {
- if (mbeanServer.isRegistered(target))
- {
- mbeanServer.invoke(target, "stop", new Object[0], new String[0]);
- mbeanServer.unregisterMBean(target);
- log.debug("stopped " + target);
- }
- }
-
- private void cleanJNDI() throws Exception
- {
- for (Iterator i = toUnbindAtExit.iterator(); i.hasNext(); )
- {
- String name = (String)i.next();
-
- initialContext.unbind(name);
- }
- }
-
- private void executeStatement(TransactionManager mgr, DataSource ds, String statement) throws Exception
- {
- Connection conn = null;
- boolean exception = false;
-
- try
- {
- try
- {
- mgr.begin();
-
- conn = ds.getConnection();
-
- log.debug("executing " + statement);
-
- PreparedStatement ps = conn.prepareStatement(statement);
-
- ps.executeUpdate();
-
- log.debug(statement + " executed");
-
- ps.close();
- }
- catch (SQLException e)
- {
- // Ignore
- log.debug("Failed to execute statement", e);
- exception = true;
- }
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
-
- if (exception)
- {
- mgr.rollback();
- }
- else
- {
- mgr.commit();
- }
- }
-
-
- }
-
- protected void dropAllTables() throws Exception
- {
- log.info("DROPPING ALL TABLES FROM DATABASE!");
-
- InitialContext ctx = new InitialContext();
-
- // We need to execute each drop in its own transaction otherwise postgresql will not execute
- // further commands after one fails
-
- TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
- DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
-
- javax.transaction.Transaction txOld = mgr.suspend();
-
- executeStatement(mgr, ds, "DROP TABLE JBM_POSTOFFICE");
-
- executeStatement(mgr, ds, "DROP TABLE JBM_MSG_REF");
-
- executeStatement(mgr, ds, "DROP TABLE JBM_MSG");
-
- executeStatement(mgr, ds, "DROP TABLE JBM_TX");
-
- executeStatement(mgr, ds, "DROP TABLE JBM_COUNTER");
-
- executeStatement(mgr, ds, "DROP TABLE JBM_USER");
-
- executeStatement(mgr, ds, "DROP TABLE JBM_ROLE");
-
- if (txOld != null)
- {
- mgr.resume(txOld);
- }
-
- log.debug("done with dropping tables");
- }
-
- protected void deleteAllData() throws Exception
- {
- log.info("DELETING ALL DATA FROM DATABASE!");
-
- InitialContext ctx = new InitialContext();
-
- // We need to execute each drop in its own transaction otherwise postgresql will not execute
- // further commands after one fails
-
- TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
- DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
-
- javax.transaction.Transaction txOld = mgr.suspend();
-
- executeStatement(mgr, ds, "DELETE FROM JBM_POSTOFFICE");
-
- executeStatement(mgr, ds, "DELETE FROM JBM_MSG_REF");
-
- executeStatement(mgr, ds, "DELETE FROM JBM_MSG");
-
- executeStatement(mgr, ds, "DELETE FROM JBM_TX");
-
- executeStatement(mgr, ds, "DELETE FROM JBM_COUNTER");
-
- executeStatement(mgr, ds, "DELETE FROM JBM_USER");
-
- executeStatement(mgr, ds, "DELETE FROM JBM_ROLE");
-
- if (txOld != null)
- {
- mgr.resume(txOld);
- }
-
- log.debug("done with the deleting data");
- }
-
- private void startMultiplexer() throws Exception
- {
- log.debug("Starting multiplexer");
-
- String multiplexerConfigFile = "server/default/deploy/multiplexer-service.xml";
- URL multiplexerCofigURL = getClass().getClassLoader().getResource(multiplexerConfigFile);
-
- if (multiplexerCofigURL == null)
- {
- throw new Exception("Cannot find " + multiplexerCofigURL + " in the classpath");
- }
-
- ServiceDeploymentDescriptor multiplexerDD = ServiceConfigHelper.loadConfigFile(multiplexerConfigFile);
-
- List services = multiplexerDD.query("name", "Multiplexer");
-
- if (services.isEmpty())
- {
- log.info("Couldn't find multiplexer config");
- }
- else
- {
- log.info("Could find multiplexer config");
- }
-
- MBeanConfigurationElement multiplexerConfig =
- (MBeanConfigurationElement)services.iterator().next();
- ObjectName nameMultiplexer = registerAndConfigureService(multiplexerConfig);
- invoke(nameMultiplexer,"create", new Object[0], new String[0]);
- invoke(nameMultiplexer,"start", new Object[0], new String[0]);
- }
-
- private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides)
- throws Exception
- {
- if (attrOverrides == null)
- {
- return;
- }
-
- Map sao = attrOverrides.get(on);
-
- for(Iterator i = sao.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String attrName = (String)entry.getKey();
- Object attrValue = entry.getValue();
- setAttribute(on, attrName, attrValue.toString());
-
- }
- }
-
- public void deployConnectionFactories(String connFactoryConfigFile,
- ServiceAttributeOverrides attrOverrides) throws Exception
- {
- connFactoryObjectNames.clear();
-
- ServiceDeploymentDescriptor cfdd = ServiceConfigHelper.loadConfigFile(connFactoryConfigFile);
-
- List connFactoryElements = cfdd.query("service", "ConnectionFactory");
-
- for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
- {
- MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
- ObjectName on = registerAndConfigureService(connFactoryElement);
- overrideAttributes(on, attrOverrides);
- // dependencies have been automatically injected already
- invoke(on, "create", new Object[0], new String[0]);
- invoke(on, "start", new Object[0], new String[0]);
- connFactoryObjectNames.add(on);
- }
-
- connFactoryElements = cfdd.query("service", "ClusteredConnectionFactory");
-
- for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
- {
- MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
- ObjectName on = registerAndConfigureService(connFactoryElement);
- overrideAttributes(on, attrOverrides);
- // dependencies have been automatically injected already
- invoke(on, "create", new Object[0], new String[0]);
- invoke(on, "start", new Object[0], new String[0]);
- connFactoryObjectNames.add(on);
- }
-
- connFactoryElements = cfdd.query("service", "HTTPConnectionFactory");
-
- for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
- {
- MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
- ObjectName on = registerAndConfigureService(connFactoryElement);
- overrideAttributes(on, attrOverrides);
- // dependencies have been automatically injected already
- invoke(on, "create", new Object[0], new String[0]);
- invoke(on, "start", new Object[0], new String[0]);
- connFactoryObjectNames.add(on);
- }
-
- connFactoryElements = cfdd.query("service", "ClusterPullConnectionFactory");
-
- for (Iterator i = connFactoryElements.iterator(); i.hasNext();)
- {
- MBeanConfigurationElement connFactoryElement = (MBeanConfigurationElement) i.next();
- ObjectName on = registerAndConfigureService(connFactoryElement);
- overrideAttributes(on, attrOverrides);
- // dependencies have been automatically injected already
- invoke(on, "create", new Object[0], new String[0]);
- invoke(on, "start", new Object[0], new String[0]);
- connFactoryObjectNames.add(on);
- }
- }
-
-
-
- private void parseConfig(String config)
- {
- config = config.toLowerCase();
- for (StringTokenizer st = new StringTokenizer(config, ", "); st.hasMoreTokens(); )
- {
- String tok = st.nextToken();
- boolean minus = false;
-
- supportsFailover = true;
-
- if (tok.startsWith("-"))
- {
- tok = tok.substring(1);
- minus = true;
- }
-
- if ("all".equals(tok))
- {
- transaction = true;
- database = true;
- jca = true;
- remoting = true;
- security = true;
- }
- else
- if ("all-failover".equals(tok))
- {
- transaction = true;
- database = true;
- jca = true;
- remoting = true;
- security = true;
- supportsFailover = false;
- }
- else
- if ("all+http".equals(tok))
- {
- transaction = true;
- database = true;
- jca = true;
- remoting = true;
- security = true;
- httpConnectionFactory = true;
- }
- else if ("transaction".equals(tok))
- {
- transaction = true;
- if (minus)
- {
- transaction = false;
- }
- }
- else if ("jbossjta".equals(tok))
- {
- if (transaction)
- {
- throw new IllegalArgumentException("Cannot have the old JBoss transaction manager AND the JBoss Transactions transaction manager");
- }
-
- //Use the JBoss Transactions (ex Arjuna) JTA
- jbossjta = true;
- if (minus)
- {
- jbossjta = false;
- }
- }
- else if ("database".equals(tok))
- {
- database = true;
- if (minus)
- {
- database = false;
- }
- }
- else if ("jca".equals(tok))
- {
- jca = true;
- if (minus)
- {
- jca = false;
- }
- }
- else if ("remoting".equals(tok))
- {
- remoting = true;
- if (minus)
- {
- remoting = false;
- }
- }
- else if ("security".equals(tok))
- {
- security = true;
- if (minus)
- {
- security = false;
- }
- }
- else if ("multiplexer".equals(tok))
- {
- multiplexer = true;
- if (minus)
- {
- multiplexer = false;
- }
- }
- else if ("none".equals(tok))
- {
- transaction = false;
- database = false;
- jca = false;
- remoting = false;
- security = false;
- multiplexer = false;
- }
- else
- {
- throw new IllegalArgumentException("Unknown service: " + tok);
- }
- }
- }
-
- // Inner classes --------------------------------------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainerConfiguration.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,424 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.tools.jmx;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.jboss.messaging.util.XMLUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-class ServiceContainerConfiguration
-{
- // Constants -----------------------------------------------------
-
- public static final boolean DEFAULT_CLUSTERED_MODE = false;
-
- // Static --------------------------------------------------------
-
- public static String getHypersonicDatabase(String connectionURL)
- {
- StringTokenizer st = new StringTokenizer(connectionURL, ":");
-
- if (!"jdbc".equals(st.nextToken()) || !"hsqldb".equals(st.nextToken()))
- {
- throw new IllegalArgumentException("Invalid Hypersonic connection URL: " + connectionURL);
- }
-
- String s = st.nextToken();
- String s2 = st.nextToken();
-
- return s + ":" + s2;
- }
-
- public static String getHypersonicDbname(String connectionURL)
- {
- StringTokenizer st = new StringTokenizer(connectionURL, ":");
-
- if (!"jdbc".equals(st.nextToken()) || !"hsqldb".equals(st.nextToken()))
- {
- throw new IllegalArgumentException("Invalid Hypersonic connection URL: " + connectionURL);
- }
-
- String s = st.nextToken();
- String s2 = st.nextToken();
-
- return s + s2;
- }
-
- public static void validateTransactionIsolation(String s) throws IllegalArgumentException
- {
- if (!"NONE".equals(s) && !"TRANSACTION_READ_COMMITTED".equals(s))
- {
- throw new IllegalArgumentException("Invalid transaction isolation: " + s);
- }
- }
-
- // Attributes ----------------------------------------------------
-
- private String database;
- private Map dbConfigurations;
- private String remotingTransport;
- private Boolean clusteredMode;
-
- // Constructors --------------------------------------------------
-
- public ServiceContainerConfiguration(InputStream is) throws Exception
- {
- dbConfigurations = new HashMap();
- parse(is);
- validate();
- }
-
- // Public --------------------------------------------------------
-
- public String getDatabaseName()
- {
- return database;
- }
-
- public String getDatabaseConnectionURL()
- {
- DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
- return dbc.getDatabaseConnectionURL();
- }
-
- public String getDatabaseDriverClass()
- {
- DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
- return dbc.getDatabaseDriverClass();
- }
-
- public String getDatabaseTransactionIsolation()
- {
- DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
- return dbc.getDatabaseTransactionIsolation();
- }
-
- public String getDatabaseUserName()
- {
- DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
- return dbc.getDatabaseUserName();
- }
-
- public String getDatabasePassword()
- {
- DatabaseConfiguration dbc = (DatabaseConfiguration)dbConfigurations.get(database);
- return dbc.getDatabasePassword();
- }
-
- /**
- * @return the transport the container wants the Remoting Connector to use.
- */
- public String getRemotingTransport()
- {
- return remotingTransport;
- }
-
- /**
- * @return the clustered mode in which the container should run an individual test.
- */
- public boolean isClustered()
- {
- return clusteredMode.booleanValue();
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- private void parse(InputStream is) throws Exception
- {
- Reader reader = new InputStreamReader(is);
- String currentDatabase = null;
- String currentRemotingTransport = null;
- boolean currentClusteredMode = DEFAULT_CLUSTERED_MODE;
-
- try
- {
- Element root = XMLUtil.readerToElement(reader);
-
- if (!"container".equals(root.getNodeName()))
- {
- throw new Exception("Invalid root element: " + root.getNodeName());
- }
-
- if (root.hasChildNodes())
- {
- NodeList nl = root.getChildNodes();
- for(int i = 0; i < nl.getLength(); i++)
- {
- Node n = nl.item(i);
- int type = n.getNodeType();
-
- if (type == Node.TEXT_NODE ||
- type == Node.COMMENT_NODE)
- {
- continue;
- }
-
- String name = n.getNodeName();
-
- if ("database-configurations".equals(name))
- {
- parseDatabaseConfigurations(n);
- }
- else if ("database".equals(name))
- {
- currentDatabase = XMLUtil.getTextContent(n);
- }
- else if ("remoting-transport".equals(name))
- {
- currentRemotingTransport = XMLUtil.getTextContent(n);
- }
- else if ("clustered".equals(name))
- {
- currentClusteredMode = Boolean.getBoolean(XMLUtil.getTextContent(n));
- }
- else
- {
- throw new Exception("Unexpected child <" + name + "> of node " +
- root.getNodeName() + ", type " + type);
- }
- }
- }
-
- setCurrentDatabase(currentDatabase);
- setCurrentRemotingTransport(currentRemotingTransport);
- setCurrentClusteredMode(currentClusteredMode);
- }
- finally
- {
- reader.close();
- }
- }
-
- /**
- * Always the value of "test.database" system property takes precedence over the configuration
- * file value.
- */
- private void setCurrentDatabase(String xmlConfigDatabase)
- {
- database = System.getProperty("test.database");
- if (database == null)
- {
- database = xmlConfigDatabase;
- }
- }
-
- private void setCurrentRemotingTransport(String xmlRemotingTransport)
- {
- remotingTransport = System.getProperty("test.remoting");
- if (remotingTransport == null)
- {
- remotingTransport = xmlRemotingTransport;
- }
- }
-
-
- /**
- * Always the value of "test.clustered" system property takes precedence over the configuration
- * file value.
- */
- private void setCurrentClusteredMode(boolean xmlClusteredMode) throws Exception
- {
- String s = System.getProperty("test.clustered");
- if (s != null)
- {
- clusteredMode = Boolean.valueOf(s);
- }
-
- if (clusteredMode == null)
- {
- clusteredMode = new Boolean(xmlClusteredMode);
- }
- }
-
- private void validate() throws Exception
- {
- // make sure that I have a corresponding "database-configuration"
- if (database == null)
- {
- throw new Exception("No configured database!");
- }
-
- if (dbConfigurations.get(database) == null)
- {
- throw new Exception("No such database configuration: \"" + database + "\"");
- }
- }
-
- private void parseDatabaseConfigurations(Node dbcs) throws Exception
- {
- if (!"database-configurations".equals(dbcs.getNodeName()))
- {
- throw new Exception("Expecting <database-configurations> and got <" +
- dbcs.getNodeName() + ">");
- }
-
- if (dbcs.hasChildNodes())
- {
- NodeList nl = dbcs.getChildNodes();
- for(int i = 0; i < nl.getLength(); i++)
- {
- Node n = nl.item(i);
-
- if (n.getNodeType() == Node.TEXT_NODE)
- {
- continue;
- }
- parseDatabaseConfiguration(n);
- }
- }
- }
-
- private void parseDatabaseConfiguration(Node dbcn) throws Exception
- {
- if (!"database-configuration".equals(dbcn.getNodeName()))
- {
- throw new Exception("Expecting <database-configuration> and got <" +
- dbcn.getNodeName() + ">");
- }
-
- NamedNodeMap attrs = dbcn.getAttributes();
- Node nameNode = attrs.getNamedItem("name");
- String configName = nameNode.getNodeValue();
- DatabaseConfiguration dbc = new DatabaseConfiguration();
- dbConfigurations.put(configName, dbc);
-
- if (dbcn.hasChildNodes())
- {
- NodeList nl = dbcn.getChildNodes();
- for(int i = 0; i < nl.getLength(); i++)
- {
- Node n = nl.item(i);
-
- if (n.getNodeType() == Node.TEXT_NODE)
- {
- continue;
- }
-
- String name = n.getNodeName();
- String value = XMLUtil.getTextContent(n);
-
- if ("url".equals(name))
- {
- dbc.setDatabaseConnectionURL(value);
- }
- else if ("driver".equals(name))
- {
- dbc.setDatabaseDriverClass(value);
- }
- else if ("isolation".equals(name))
- {
- String s = value.toUpperCase();
- validateTransactionIsolation(s);
- dbc.setDatabaseTransactionIsolation(s);
- }
- else if ("username".equals(name))
- {
- dbc.setDatabaseUserName(value);
- }
- else if ("password".equals(name))
- {
- dbc.setDatabasePassword(value);
- }
- else
- {
- throw new IllegalArgumentException("Unknown element: " + name);
- }
- }
- }
- }
-
- // Inner classes -------------------------------------------------
-
- private class DatabaseConfiguration
- {
- private String connectionURL;
- private String driverClass;
- private String transactionIsolation;
- private String username;
- private String password;
-
- void setDatabaseConnectionURL(String s)
- {
- StringTokenizer st = new StringTokenizer(s, ":");
- if (!st.hasMoreTokens())
- {
- throw new IllegalArgumentException("Invalid connection URL: " + s);
- }
- st.nextToken();
- if (!st.hasMoreTokens())
- {
- throw new IllegalArgumentException("Invalid connection URL: " + s);
- }
-
- this.connectionURL = s;
- }
-
- String getDatabaseConnectionURL()
- {
- return connectionURL;
- }
-
- void setDatabaseDriverClass(String s)
- {
- this.driverClass = s;
- }
-
- String getDatabaseDriverClass()
- {
- return driverClass;
- }
-
- void setDatabaseTransactionIsolation(String s)
- {
- this.transactionIsolation = s;
- }
-
- String getDatabaseTransactionIsolation()
- {
- return transactionIsolation;
- }
-
- void setDatabaseUserName(String s)
- {
- this.username = s;
- }
-
- String getDatabaseUserName()
- {
- return username;
- }
-
- void setDatabasePassword(String s)
- {
- this.password = s;
- }
-
- String getDatabasePassword()
- {
- return password;
- }
- }
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapper.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapper.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapper.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,75 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import javax.transaction.TransactionManager;
-
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class TransactionManagerJMXWrapper implements TransactionManagerJMXWrapperMBean
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private TransactionManager tm;
-
- // Constructors --------------------------------------------------
-
- public TransactionManagerJMXWrapper(TransactionManager tm)
- {
- this.tm = tm;
- }
-
- // TransactionManagerJMXWrapperMBean implementation --------------
-
- public TransactionManager getTransactionManager()
- {
- return tm;
- }
-
- public void start() throws Exception
- {
- }
-
- public void stop() throws Exception
- {
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapperMBean.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapperMBean.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/TransactionManagerJMXWrapperMBean.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,39 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx;
-
-import javax.transaction.TransactionManager;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface TransactionManagerJMXWrapperMBean
-{
- TransactionManager getTransactionManager();
-
- void start() throws Exception;
- void stop() throws Exception;
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Command.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Command.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Command.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * 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.test.messaging.tools.jmx.rmi;
-
-import java.io.Serializable;
-
-/**
- *
- * A Command.
- *
- * This interface is implemented by any classes that wish to be executed on a server
- *
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface Command extends Serializable
-{
- public Object execute() throws Exception;
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/LocalTestServer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,911 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx.rmi;
-
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jms.Destination;
-import javax.jms.Queue;
-import javax.jms.Topic;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.transaction.UserTransaction;
-
-import org.jboss.aop.AspectXmlLoader;
-import org.jboss.jms.server.DestinationManager;
-import org.jboss.jms.server.ServerPeer;
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.MessageStore;
-import org.jboss.messaging.core.contract.PersistenceManager;
-import org.jboss.messaging.core.contract.PostOffice;
-import org.jboss.messaging.util.XMLUtil;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.aop.PoisonInterceptor;
-import org.jboss.test.messaging.tools.jboss.MBeanConfigurationElement;
-import org.jboss.test.messaging.tools.jboss.ServiceDeploymentDescriptor;
-import org.jboss.test.messaging.tools.jmx.MockJBossSecurityManager;
-import org.jboss.test.messaging.tools.jmx.RemotingJMXWrapper;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-import org.jboss.test.messaging.tools.jmx.ServiceConfigHelper;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jndi.Constants;
-import org.w3c.dom.Element;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>1.1</tt>
- *
- * LocalTestServer.java,v 1.1 2006/02/21 08:25:32 timfox Exp
- */
-public class LocalTestServer implements Server
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(LocalTestServer.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- public static void setEnvironmentServerIndex(int serverIndex)
- {
- System.setProperty(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex));
- }
-
- public static void clearEnvironmentServerIndex()
- {
- System.getProperty(Constants.SERVER_INDEX_PROPERTY_NAME, null);
- }
-
- // Attributes -----------------------------------------------------------------------------------
-
- private ServiceContainer sc;
-
- // service dependencies
- private ObjectName persistenceManagerObjectName;
- private ObjectName postOfficeObjectName;
- private ObjectName jmsUserManagerObjectName;
-
- // the server MBean itself
- private ObjectName serverPeerObjectName;
-
- private int serverIndex;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public LocalTestServer()
- {
- super();
- }
-
- public LocalTestServer(int serverIndex)
- {
- this();
-
- this.serverIndex = serverIndex;
- }
-
- // Server implementation ------------------------------------------------------------------------
-
- public int getServerID()
- {
- return serverIndex;
- }
-
- public void start(String containerConfig,
- boolean clearDatabase) throws Exception
- {
- start(containerConfig, null, clearDatabase, true);
- }
-
- public synchronized void start(String containerConfig,
- ServiceAttributeOverrides attrOverrides,
- boolean clearDatabase,
- boolean startMessagingServer) throws Exception
- {
- if (isStarted())
- {
- return;
- }
-
- log.debug("starting service container");
-
- try
- {
- setEnvironmentServerIndex(serverIndex);
-
- sc = new ServiceContainer(containerConfig, null, serverIndex);
- sc.start(clearDatabase, attrOverrides);
-
- if (sc.getDatabaseName().equals("hsqldb") && sc.isClustered())
- {
- throw new IllegalStateException("The test server cannot be started in clustered mode with hsqldb as a database - must use a shared database");
- }
-
- if ("none".equals(containerConfig))
- {
- return;
- }
-
- if (startMessagingServer)
- {
- startServerPeer(serverIndex, null, null, attrOverrides, sc.isClustered(), sc.isSupportsFailover());
- }
-
- log.info("Server " + serverIndex + " started");
- }
- finally
- {
- clearEnvironmentServerIndex();
- }
- }
-
- public synchronized boolean stop() throws Exception
- {
- if (!isStarted())
- {
- return false;
- }
-
- try
- {
- setEnvironmentServerIndex(serverIndex);
-
- stopServerPeer();
-
- log.debug("stopping service container");
-
- sc.stop();
- sc = null;
-
- log.info("server stopped");
- }
- finally
- {
- clearEnvironmentServerIndex();
- }
-
- return true;
- }
-
-
- public void ping() throws Exception
- {
- // noop... do nothing
- }
-
- public synchronized void kill() throws Exception
- {
- throw new IllegalStateException("Cannot KILL a local server. Consider using stop() instead.");
- }
-
- public ObjectName deploy(String mbeanConfiguration) throws Exception
- {
- Element mbeanElement = XMLUtil.stringToElement(mbeanConfiguration);
- MBeanConfigurationElement mbc = new MBeanConfigurationElement(mbeanElement);
- return sc.registerAndConfigureService(mbc);
- }
-
- public void undeploy(ObjectName on) throws Exception
- {
- sc.unregisterService(on);
- }
-
- public Object getAttribute(ObjectName on, String attribute) throws Exception
- {
- return sc.getAttribute(on, attribute);
- }
-
- public void setAttribute(ObjectName on, String name, String valueAsString) throws Exception
- {
- sc.setAttribute(on, name, valueAsString);
- }
-
- public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
- throws Exception
- {
- return sc.invoke(on, operationName, params, signature);
- }
-
- public void addNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
- {
- sc.addNotificationListener(on, listener);
- }
-
- public void removeNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
- {
- sc.removeNotificationListener(on, listener);
- }
-
- public Set query(ObjectName pattern) throws Exception
- {
- return sc.query(pattern);
- }
-
- public String getRemotingTransport()
- {
- return sc.getRemotingTransport();
- }
-
- public void log(int level, String text)
- {
- if (ServerManagement.FATAL == level)
- {
- log.fatal(text);
- }
- else if (ServerManagement.ERROR == level)
- {
- log.error(text);
- }
- else if (ServerManagement.WARN == level)
- {
- log.warn(text);
- }
- else if (ServerManagement.INFO == level)
- {
- log.info(text);
- }
- else if (ServerManagement.DEBUG == level)
- {
- log.debug(text);
- }
- else if (ServerManagement.TRACE == level)
- {
- log.trace(text);
- }
- else
- {
- // log everything else as INFO
- log.info(text);
- }
- }
-
- public synchronized boolean isStarted() throws Exception
- {
- return sc != null;
- }
-
- public void startServerPeer(int serverPeerID,
- String defaultQueueJNDIContext,
- String defaultTopicJNDIContext,
- ServiceAttributeOverrides attrOverrides,
- boolean clustered,
- boolean supportsFailover) throws Exception
- {
- try
- {
- log.debug("creating ServerPeer instance");
-
- // we are using the "default" service deployment descriptors available in
- // src/etc/server/default/deploy. This will allow to test the default parameters we ship.
-
- String mainConfigFile = "server/default/deploy/messaging-service.xml";
-
- String persistenceConfigFile = sc.getPersistenceConfigFile(clustered);
-
- log.info(" Persistence config file .. " + persistenceConfigFile);
-
- ServiceDeploymentDescriptor mdd = ServiceConfigHelper.loadConfigFile(mainConfigFile);
-
- ServiceDeploymentDescriptor pdd = ServiceConfigHelper.loadConfigFile(persistenceConfigFile);
-
- MBeanConfigurationElement persistenceManagerConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "PersistenceManager");
- persistenceManagerObjectName = sc.registerAndConfigureService(persistenceManagerConfig);
- overrideAttributes(persistenceManagerObjectName, attrOverrides);
- sc.invoke(persistenceManagerObjectName, "create", new Object[0], new String[0]);
- sc.invoke(persistenceManagerObjectName, "start", new Object[0], new String[0]);
-
- MBeanConfigurationElement jmsUserManagerConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "JMSUserManager");
- jmsUserManagerObjectName = sc.registerAndConfigureService(jmsUserManagerConfig);
- overrideAttributes(jmsUserManagerObjectName, attrOverrides);
- sc.invoke(jmsUserManagerObjectName, "create", new Object[0], new String[0]);
- sc.invoke(jmsUserManagerObjectName, "start", new Object[0], new String[0]);
-
- // register server peer as a service, dependencies are injected automatically
- MBeanConfigurationElement serverPeerConfig =
- ServiceConfigHelper.getServiceConfiguration(mdd, "ServerPeer");
-
- // overwrite the file configuration, if needed
- overrideServerPeerConfiguration(serverPeerConfig, serverPeerID, defaultQueueJNDIContext,
- defaultTopicJNDIContext);
-
- serverPeerObjectName = sc.registerAndConfigureService(serverPeerConfig);
-
- overrideAttributes(serverPeerObjectName, attrOverrides);
-
- // overwrite the config file security domain
- sc.setAttribute(serverPeerObjectName, "SecurityDomain",
- MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
-
- sc.setAttribute(serverPeerObjectName,"SupportsFailover", supportsFailover?"true":"false");
-
- log.debug("starting JMS server");
-
- sc.invoke(serverPeerObjectName, "create", new Object[0], new String[0]);
- sc.invoke(serverPeerObjectName, "start", new Object[0], new String[0]);
-
- MBeanConfigurationElement postOfficeConfig =
- ServiceConfigHelper.getServiceConfiguration(pdd, "PostOffice");
-
- postOfficeObjectName = sc.registerAndConfigureService(postOfficeConfig);
- sc.setAttribute(postOfficeObjectName, "Clustered", clustered ? "true" : "false");
-
- overrideAttributes(postOfficeObjectName, attrOverrides);
- sc.invoke(postOfficeObjectName, "create", new Object[0], new String[0]);
- sc.invoke(postOfficeObjectName, "start", new Object[0], new String[0]);
-
- log.debug("deploying connection factories");
-
- sc.startConnectionFactories(attrOverrides);
- }
- catch (Exception e)
- {
- log.error("Failed to start server peer", e);
- throw e;
- }
- }
-
- public void stopServerPeer() throws Exception
- {
- if (!isServerPeerStarted())
- {
- log.debug("messaging server was not started, so there is no stopping");
- return;
- }
-
- try
- {
- // if we don't find a ServerPeer instance registered under the serverPeerObjectName
- // ObjectName, we assume that the server was already stopped and we silently exit
- if (sc.query(serverPeerObjectName).isEmpty())
- {
- log.warn("ServerPeer already stopped");
- return;
- }
-
- // unbind the JCA ConnectionFactory; nothing happens if no connection factory is bound
- sc.unbindJCAJMSConnectionFactory();
- sc.unbindDefaultJMSProvider();
-
- log.debug("stopping connection factories");
-
- sc.stopConnectionFactories();
-
- log.debug("stopping all destinations");
-
- Set destinations = (Set)sc.getAttribute(serverPeerObjectName, "Destinations");
-
- for(Iterator i = destinations.iterator(); i.hasNext(); )
- {
- String name;
- boolean isQueue = true;
- Destination d = (Destination)i.next();
- if (d instanceof Queue)
- {
- name = ((Queue)d).getQueueName();
- }
- else
- {
- isQueue = false;
- name = ((Topic)d).getTopicName();
- }
-
- undeployDestination(isQueue, name);
- }
-
- log.debug("stopping JMS server");
-
- try
- {
- sc.invoke(serverPeerObjectName, "stop", new Object[0], new String[0]);
- sc.invoke(serverPeerObjectName, "destroy", new Object[0], new String[0]);
- sc.unregisterService(serverPeerObjectName);
- }
- catch (Exception ignore)
- {
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
- }
-
- log.debug("stopping ServerPeer's plug-in dependencies");
-
- try
- {
- sc.invoke(jmsUserManagerObjectName, "stop", new Object[0], new String[0]);
- sc.invoke(jmsUserManagerObjectName, "destroy", new Object[0], new String[0]);
- sc.unregisterService(jmsUserManagerObjectName);
- }
- catch (Exception ignore)
- {
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
- }
-
- try
- {
- sc.invoke(postOfficeObjectName, "stop", new Object[0], new String[0]);
- sc.invoke(postOfficeObjectName, "destroy", new Object[0], new String[0]);
- sc.unregisterService(postOfficeObjectName);
- }
- catch (Exception ignore)
- {
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
- }
-
- try
- {
- sc.invoke(persistenceManagerObjectName, "stop", new Object[0], new String[0]);
- sc.invoke(persistenceManagerObjectName, "destroy", new Object[0], new String[0]);
- sc.unregisterService(persistenceManagerObjectName);
- }
- catch (Exception ignore)
- {
- //If the serverpeer failed when starting up previously, then only some of the
- //services may be started. The ones that didn't start will fail when attempting to shut
- //them down.
- //Hence we must catch and ignore or we won't shut everything down
- }
- }
- catch (Exception e)
- {
- log.error("Failed to stop server peer", e);
- throw e;
- }
- }
-
- public boolean isServerPeerStarted() throws Exception
- {
- if (sc.query(serverPeerObjectName).isEmpty())
- {
- return false;
- }
- ServerPeer sp = (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
- sp.getVersion();
- return true;
- }
-
- public ObjectName getServerPeerObjectName()
- {
- return serverPeerObjectName;
- }
-
- public Set getConnectorSubsystems() throws Exception
- {
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
-
- return remoting.getConnectorSubsystems();
- }
-
- public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
- throws Exception
- {
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
-
- remoting.addInvocationHandler(subsystem, handler);
- }
-
- public void removeServerInvocationHandler(String subsystem) throws Exception
- {
- RemotingJMXWrapper remoting =
- (RemotingJMXWrapper)sc.getService(ServiceContainer.REMOTING_OBJECT_NAME);
-
- remoting.removeInvocationHandler(subsystem);
- }
-
- /**
- * Only for in-VM use!
- */
- public MessageStore getMessageStore() throws Exception
- {
- ServerPeer serverPeer = (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
- return serverPeer.getMessageStore();
- }
-
- public DestinationManager getDestinationManager() throws Exception
- {
- ServerPeer serverPeer = (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
- return serverPeer.getDestinationManager();
- }
-
- public PersistenceManager getPersistenceManager() throws Exception
- {
- ServerPeer serverPeer = (ServerPeer)sc.getAttribute(serverPeerObjectName, "Instance");
- return serverPeer.getPersistenceManagerInstance();
- }
-
- /**
- * Only for in-VM use!
- */
- public ServerPeer getServerPeer() throws Exception
- {
- return (ServerPeer)sc.
- getAttribute(serverPeerObjectName, "Instance");
- }
-
- public void deployTopic(String name, String jndiName, boolean clustered) throws Exception
- {
- deployDestination(false, name, jndiName, clustered);
- }
-
- public void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception
- {
- deployDestination(false, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
- }
-
- public void deployTopicProgrammatically(String name, String jndiName) throws Exception
- {
- sc.invoke(serverPeerObjectName, "deployTopic",
- new Object[] { name, jndiName },
- new String[] { "java.lang.String", "java.lang.String"} );
- }
-
- public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
- {
- deployDestination(true, name, jndiName, clustered);
- }
-
- public void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception
- {
- deployDestination(true, name, jndiName, fullSize, pageSize, downCacheSize, clustered);
- }
-
- public void deployQueueProgrammatically(String name, String jndiName) throws Exception
- {
- sc.invoke(serverPeerObjectName, "deployQueue",
- new Object[] { name, jndiName },
- new String[] { "java.lang.String", "java.lang.String"} );
- }
-
- public void deployDestination(boolean isQueue, String name, String jndiName, boolean clustered) throws Exception
- {
- String config =
- "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
- " name=\"jboss.messaging.destination:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name + "\"" +
- " xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
- (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
- " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
- " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
- "</mbean>";
-
- MBeanConfigurationElement mbean =
- new MBeanConfigurationElement(XMLUtil.stringToElement(config));
- ObjectName deston = sc.registerAndConfigureService(mbean);
- sc.invoke(deston, "create", new Object[0], new String[0]);
- sc.invoke(deston, "start", new Object[0], new String[0]);
- }
-
- public void deployDestination(boolean isQueue,
- String name,
- String jndiName,
- int fullSize,
- int pageSize,
- int downCacheSize,
- boolean clustered) throws Exception
- {
- log.info("deploying queue, fullsize:" + fullSize + ", ps:" + pageSize + " dc size:" + downCacheSize);
-
- String config =
- "<mbean code=\"org.jboss.jms.server.destination." + (isQueue ? "QueueService" : "TopicService") + "\"" +
- " name=\"jboss.messaging.destination:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name + "\"" +
- " xmbean-dd=\"xmdesc/" + (isQueue ? "Queue" : "Topic" ) + "-xmbean.xml\">" +
- (jndiName != null ? " <attribute name=\"JNDIName\">" + jndiName + "</attribute>" : "") +
- " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>" +
- " <attribute name=\"FullSize\">" + fullSize + "</attribute>" +
- " <attribute name=\"PageSize\">" + pageSize + "</attribute>" +
- " <attribute name=\"DownCacheSize\">" + downCacheSize + "</attribute>" +
- " <attribute name=\"Clustered\">" + String.valueOf(clustered) + "</attribute>" +
- "</mbean>";
-
- MBeanConfigurationElement mbean =
- new MBeanConfigurationElement(XMLUtil.stringToElement(config));
- ObjectName deston = sc.registerAndConfigureService(mbean);
- sc.invoke(deston, "create", new Object[0], new String[0]);
- sc.invoke(deston, "start", new Object[0], new String[0]);
- }
-
- public void undeployDestination(boolean isQueue, String name) throws Exception
- {
- ObjectName pattern =
- new ObjectName("*:service=" + (isQueue ? "Queue" : "Topic") + ",name=" + name);
- Set s = sc.query(pattern);
- int size = s.size();
- if (size == 0)
- {
- log.debug("No such " + (isQueue ? "queue" : "topic") + " to undeploy: " + name);
- return;
- }
- if (size > 1)
- {
- throw new Exception("Too many destination with the same name: " + name);
- }
- ObjectName destinationObjectName = (ObjectName)s.iterator().next();
- sc.invoke(destinationObjectName, "stop", new Object[0], new String[0]);
- sc.invoke(destinationObjectName, "destroy", new Object[0], new String[0]);
- sc.unregisterService(destinationObjectName);
- }
-
- public boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception
- {
- if (isQueue)
- {
- return ((Boolean)sc.invoke(serverPeerObjectName, "undeployQueue",
- new Object[] { name },
- new String[] { "java.lang.String"})).booleanValue();
- }
- else
- {
- return ((Boolean)sc.invoke(serverPeerObjectName, "undeployTopic",
- new Object[] { name },
- new String[] { "java.lang.String"})).booleanValue();
- }
- }
-
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize) throws Exception
- {
- deployConnectionFactory(objectName, jndiBindings, prefetchSize, -1, -1, -1, false, false);
- }
-
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings) throws Exception
- {
- deployConnectionFactory(objectName, jndiBindings, -1, -1, -1, -1, false, false);
- }
-
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize,
- int defaultTempQueueFullSize,
- int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize) throws Exception
- {
- this.deployConnectionFactory(objectName, jndiBindings, prefetchSize, defaultTempQueueFullSize,
- defaultTempQueuePageSize, defaultTempQueueDownCacheSize, false, false);
- }
-
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
- {
- this.deployConnectionFactory(objectName, jndiBindings, -1, -1,
- -1, -1, supportsFailover, supportsLoadBalancing);
- }
-
- private void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize,
- int defaultTempQueueFullSize,
- int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize,
- boolean supportsFailover,
- boolean supportsLoadBalancing) throws Exception
- {
- log.trace("deploying connection factory with name: " + objectName);
-
- String config =
- "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" +
- "name=\"" + objectName + "\"\n" +
- "xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n" +
- "<depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
- "<depends optional-attribute-name=\"Connector\">" + ServiceContainer.REMOTING_OBJECT_NAME +
- "</depends>\n";
-
- if (defaultTempQueueFullSize != -1)
- {
- config += "<attribute name=\"DefaultTempQueueFullSize\">" + defaultTempQueueFullSize + "</attribute>\n";
- }
-
- if (defaultTempQueuePageSize != -1)
- {
- config += "<attribute name=\"DefaultTempQueuePageSize\">" + defaultTempQueuePageSize + "</attribute>\n";
- }
-
- if (defaultTempQueueDownCacheSize != -1)
- {
- config += "<attribute name=\"DefaultTempQueueDownCacheSize\">" + defaultTempQueueDownCacheSize + "</attribute>\n";
- }
-
- if (prefetchSize != -1)
- {
- config += "<attribute name=\"PrefetchSize\">" + prefetchSize + "</attribute>";
- }
-
- config += "<attribute name=\"SupportsFailover\">" + supportsFailover + "</attribute>";
- config += "<attribute name=\"SupportsLoadBalancing\">" + supportsLoadBalancing + "</attribute>";
-
- if (jndiBindings != null)
- {
- config += "<attribute name=\"JNDIBindings\"><bindings>";
-
- for (int i = 0; i < jndiBindings.length; i++)
- {
- config += "<binding>" + jndiBindings[i] + "</binding>\n";
- }
- config += "</bindings></attribute>";
- }
- config += "</mbean>";
-
- MBeanConfigurationElement mc = new MBeanConfigurationElement(XMLUtil.stringToElement(config));
- ObjectName on = sc.registerAndConfigureService(mc);
-
- log.trace("Object name is now: " + on);
-
- sc.invoke(on, "create", new Object[0], new String[0]);
- sc.invoke(on, "start", new Object[0], new String[0]);
- }
-
- public void undeployConnectionFactory(ObjectName objectName) throws Exception
- {
- sc.invoke(objectName, "stop", new Object[0], new String[0]);
- sc.invoke(objectName, "destroy", new Object[0], new String[0]);
- sc.unregisterService(objectName);
- }
-
- public void configureSecurityForDestination(String destName, String config) throws Exception
- {
- Set s = sc.query(new ObjectName("*:service=Queue,name=" + destName));
- for(Iterator i = s.iterator(); i.hasNext();)
- {
- ObjectName on = (ObjectName)i.next();
- sc.setAttribute(on, "SecurityConfig", config);
- }
-
- s = sc.query(new ObjectName("*:service=Topic,name=" + destName));
- for(Iterator i = s.iterator(); i.hasNext();)
- {
- ObjectName on = (ObjectName)i.next();
- sc.setAttribute(on, "SecurityConfig", config);
- }
- }
-
- public void setDefaultSecurityConfig(String config) throws Exception
- {
- sc.setAttribute(serverPeerObjectName, "DefaultSecurityConfig", config);
- }
-
- public String getDefaultSecurityConfig() throws Exception
- {
- Element element = (Element)sc.getAttribute(serverPeerObjectName, "DefaultSecurityConfig");
- return XMLUtil.elementToString(element);
- }
-
- public Object executeCommand(Command command) throws Exception
- {
- return command.execute();
- }
-
- public UserTransaction getUserTransaction() throws Exception
- {
- return sc.getUserTransaction();
- }
-
- public Set getNodeIDView() throws Exception
- {
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.nodeIDView();
- }
-
- public Map getFailoverMap() throws Exception
- {
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getFailoverMap();
- }
-
- public Map getRecoveryArea(String queueName) throws Exception
- {
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getRecoveryArea(queueName);
- }
-
- public int getRecoveryMapSize(String queueName) throws Exception
- {
- PostOffice postOffice = (PostOffice)sc.getAttribute(postOfficeObjectName, "Instance");
-
- return postOffice.getRecoveryMapSize(queueName);
- }
-
- public List pollNotificationListener(long listenerID) throws Exception
- {
- throw new IllegalStateException("Poll doesn't make sense on a local server. " +
- "Register listeners directly instead.");
- }
-
- public void poisonTheServer(int type) throws Exception
- {
- URL url = this.getClass().getClassLoader().getResource("poison.xml");
- AspectXmlLoader.deployXML(url);
-
- log.debug(url + " deployed");
-
- PoisonInterceptor.setType(type);
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- protected ServiceContainer getServiceContainer()
- {
- return sc;
- }
-
- protected void overrideServerPeerConfiguration(MBeanConfigurationElement config,
- int serverPeerID, String defaultQueueJNDIContext, String defaultTopicJNDIContext)
- throws Exception
- {
- config.setAttribute("ServerPeerID", Integer.toString(serverPeerID));
- config.setAttribute("DefaultQueueJNDIContext",
- defaultQueueJNDIContext == null ? "/queue" : defaultQueueJNDIContext);
- config.setAttribute("DefaultTopicJNDIContext",
- defaultTopicJNDIContext == null? "/topic" : defaultTopicJNDIContext);
- }
-
- // Private --------------------------------------------------------------------------------------
-
- private void overrideAttributes(ObjectName on, ServiceAttributeOverrides attrOverrides)
- throws Exception
- {
- if (attrOverrides == null)
- {
- return;
- }
-
- Map sao = attrOverrides.get(on);
-
- for(Iterator i = sao.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String attrName = (String)entry.getKey();
- Object attrValue = entry.getValue();
- sc.setAttribute(on, attrName, attrValue.toString());
-
- }
- }
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/NamingDelegate.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/NamingDelegate.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/NamingDelegate.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,39 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx.rmi;
-
-import java.rmi.Remote;
-
-/**
- * The remote naming interface.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface NamingDelegate extends Remote
-{
- Object lookup(String name) throws Exception;
-
- void bind(String name, Object obj) throws Exception;
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/NotificationListenerID.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/NotificationListenerID.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/NotificationListenerID.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,58 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.tools.jmx.rmi;
-
-import javax.management.NotificationListener;
-import javax.management.Notification;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class NotificationListenerID implements Serializable, NotificationListener
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = -39839086486546L;
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private long id;
-
- // Constructors --------------------------------------------------
-
- public NotificationListenerID(long id)
- {
- this.id = id;
- }
-
- // NotificationListener implementation ---------------------------
-
- public void handleNotification(Notification notification, Object object)
- {
- throw new IllegalStateException("Do not use this method directly!");
- }
-
- // Public --------------------------------------------------------
-
- public long getID()
- {
- return id;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/ProxyNotificationListener.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/ProxyNotificationListener.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/ProxyNotificationListener.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,67 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.tools.jmx.rmi;
-
-import javax.management.NotificationListener;
-import javax.management.Notification;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-
-/**
- * Stores notifications until they're transferred to the remote client.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class ProxyNotificationListener implements NotificationListener
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private List notifications;
-
- // Constructors --------------------------------------------------
-
- ProxyNotificationListener()
- {
- notifications = new ArrayList();
- }
-
- // NotificationListener implementation ---------------------------
-
- public synchronized void handleNotification(Notification notification, Object object)
- {
- notifications.add(notification);
- }
-
- // Public --------------------------------------------------------
-
- public synchronized List drain()
- {
- if (notifications.size() == 0)
- {
- return Collections.EMPTY_LIST;
- }
-
- List old = notifications;
- notifications = new ArrayList();
- return old;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMINamingDelegate.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMINamingDelegate.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMINamingDelegate.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,109 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx.rmi;
-
-
-import org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.rmi.server.UnicastRemoteObject;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class RMINamingDelegate extends UnicastRemoteObject implements NamingDelegate
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = -7123818911636174877L;
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private InitialContextAccess ica;
- private int serverIndex;
-
- // Constructors --------------------------------------------------
-
- public RMINamingDelegate(int serverIndex) throws Exception
- {
- super();
- this.serverIndex = serverIndex;
- ica = new InitialContextAccess();
- }
-
- // NamingDelegate implementation ---------------------------------
-
- public Object lookup(String name) throws Exception
- {
- return getInitialContext().lookup(name);
- }
-
- public void bind(String name, Object obj) throws Exception
- {
- getInitialContext().bind(name, obj);
- }
-
- // Public --------------------------------------------------------
-
- public void reset()
- {
- ica.reset();
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- private InitialContext getInitialContext() throws NamingException
- {
- return ica.getInitialContext();
- }
-
- // Inner classes -------------------------------------------------
-
- private class InitialContextAccess
- {
- private InitialContext ic;
-
- InitialContext getInitialContext() throws NamingException
- {
- if (ic == null)
- {
- ic = new InitialContext(InVMInitialContextFactory.getJNDIEnvironment(serverIndex));
- }
- return ic;
- }
-
- public void reset()
- {
- ic = null;
- }
- }
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RMITestServer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,560 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * 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.test.messaging.tools.jmx.rmi;
-
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.transaction.UserTransaction;
-
-import org.jboss.jms.server.DestinationManager;
-import org.jboss.jms.server.ServerPeer;
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.contract.MessageStore;
-import org.jboss.messaging.core.contract.PersistenceManager;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-
-/**
- * An RMI wrapper to access the ServiceContainer from a different address space.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com>Tim Fox</a>
- * @version <tt>1.1</tt>
- *
- * RMITestServer.java,v 1.1 2006/02/21 08:25:33 timfox Exp
- */
-public class RMITestServer extends UnicastRemoteObject implements Server
-{
- // Constants -----------------------------------------------------
-
- public static final String RMI_SERVER_PREFIX = "messaging_rmi_server_";
- public static final String NAMING_SERVER_PREFIX = "naming_rmi_server_";
-
- public static final int DEFAULT_REGISTRY_PORT = 33777;
- public static final int DEFAULT_SERVER_INDEX = 0;
- public static final String DEFAULT_SERVER_HOST = "localhost";
-
- private static final long serialVersionUID = -368445344011004778L;
- private static final Logger log = Logger.getLogger(RMITestServer.class);
-
- // Static --------------------------------------------------------
-
- public static void main(String[] args) throws Exception
- {
- log.debug("initializing RMI runtime");
-
- String host = System.getProperty("test.bind.address");
-
- if (host == null)
- {
- host = DEFAULT_SERVER_HOST;
- }
-
- int serverIndex = DEFAULT_SERVER_INDEX;
-
- String s = System.getProperty("test.server.index");
-
- if (s != null)
- {
- serverIndex = Integer.parseInt(s);
- }
-
- log.info("RMI server " + serverIndex + ", bind address " + host);
-
- RMITestServer testServer = new RMITestServer(serverIndex);
- log.debug("RMI server " + serverIndex + " created");
-
- // let RMI know the bind address
- System.setProperty("java.rmi.server.hostname", host);
-
- Registry registry;
-
- // try to bind first
- try
- {
- registry = LocateRegistry.getRegistry(DEFAULT_REGISTRY_PORT);
- registry.bind(RMI_SERVER_PREFIX + serverIndex, testServer);
- registry.bind(NAMING_SERVER_PREFIX + serverIndex, testServer.getNamingDelegate());
-
- }
- catch(Exception e)
- {
- log.info("Failure using an existing registry, trying creating it");
-
- // try to create it
- registry = LocateRegistry.createRegistry(DEFAULT_REGISTRY_PORT);
-
- registry.bind(RMI_SERVER_PREFIX + serverIndex, testServer);
- registry.bind(NAMING_SERVER_PREFIX + serverIndex, testServer.getNamingDelegate());
- }
-
- log.info("RMI server " + serverIndex + " bound");
-
- // there is one crash test that needs to start the server, as an external VM...
- // as one client will crash while another will be alive
- boolean startAll=false;
-
- for (int i=0;i<args.length;i++)
- {
- if (args[i].equals("-startAll"))
- {
- startAll=true;
- }
- }
-
- if (startAll)
- {
- testServer.start("all", true);
- }
- }
-
- // Attributes ----------------------------------------------------
-
- protected RemoteTestServer server;
- private RMINamingDelegate namingDelegate;
- // Map<Long-ProxyNotificationListener>
- private Map proxyListeners;
-
- // Constructors --------------------------------------------------
-
- public RMITestServer(int index) throws Exception
- {
- namingDelegate = new RMINamingDelegate(index);
- server = new RemoteTestServer(index);
- proxyListeners = new HashMap();
- }
-
- // Server implementation -----------------------------------------
-
- public int getServerID()
- {
- return server.getServerID();
- }
-
- public void start(String containerConfig, boolean clearDatabase) throws Exception
- {
- start(containerConfig, null, clearDatabase, true);
- }
-
- public void start(String containerConfig, ServiceAttributeOverrides attrOverrides,
- boolean clearDatabase, boolean startMessagingServer) throws Exception
- {
- server.start(containerConfig, attrOverrides, clearDatabase, startMessagingServer);
- }
-
- public boolean stop() throws Exception
- {
- boolean result = server.stop();
- namingDelegate.reset();
- return result;
- }
-
- public synchronized void kill() throws Exception
- {
- //We deregister in another thread, them pause, then kill the VM
- //This ensures if the deregister hangs (which can happen if the RMI registry is dead) then it doesn't prevent
- //the kill
- //We always kill on this thread to ensure the kill completes in a timely manner which may not occur if it occurs
- //on its own thread due to thread scheduling differences
- new Thread(new Deregisterer(), "Deregisterer").start();
-
- log.info("Killing VM!!!!");
-
- Thread.sleep(250);
-
- System.exit(0);
- }
-
- public void ping() throws Exception
- {
- //noop - nothing to be done
- }
-
- public ObjectName deploy(String mbeanConfiguration) throws Exception
- {
- return server.deploy(mbeanConfiguration);
- }
-
- public void undeploy(ObjectName on) throws Exception
- {
- server.undeploy(on);
- }
-
- public Object getAttribute(ObjectName on, String attribute) throws Exception
- {
- return server.getAttribute(on, attribute);
- }
-
- public void setAttribute(ObjectName on, String name, String valueAsString) throws Exception
- {
- server.setAttribute(on, name, valueAsString);
- }
-
- public Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
- throws Exception
- {
- return server.invoke(on, operationName, params, signature);
- }
-
- public void addNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
- {
- if (!(listener instanceof NotificationListenerID))
- {
- throw new IllegalArgumentException("A RMITestServer can only handle NotificationListenerIDs!");
- }
-
- long id = ((NotificationListenerID)listener).getID();
-
- ProxyNotificationListener pl = new ProxyNotificationListener();
-
- synchronized(proxyListeners)
- {
- proxyListeners.put(new Long(id), pl);
- }
-
- server.addNotificationListener(on, pl);
- }
-
- public void removeNotificationListener(ObjectName on, NotificationListener listener)
- throws Exception
- {
-
- if (!(listener instanceof NotificationListenerID))
- {
- throw new IllegalArgumentException("A RMITestServer can only handle NotificationListenerIDs!");
- }
-
- long id = ((NotificationListenerID)listener).getID();
-
- ProxyNotificationListener pl = null;
-
- synchronized(proxyListeners)
- {
- pl = (ProxyNotificationListener)proxyListeners.remove(new Long(id));
- }
-
- server.removeNotificationListener(on, pl);
- }
-
- public Set query(ObjectName pattern) throws Exception
- {
- return server.query(pattern);
- }
-
- public String getRemotingTransport()
- {
- return server.getRemotingTransport();
- }
-
- public void log(int level, String text) throws Exception
- {
- server.log(level, text);
- }
-
- public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
- String defaultTopicJNDIContext, boolean clustered, boolean supportsFailover) throws Exception
- {
- startServerPeer(serverPeerID, defaultQueueJNDIContext,
- defaultTopicJNDIContext, null, clustered, supportsFailover);
- }
-
-
- public void startServerPeer(int serverPeerID, String defaultQueueJNDIContext,
- String defaultTopicJNDIContext,
- ServiceAttributeOverrides attrOverrides, boolean clustered,
- boolean supportsFailover)
- throws Exception
- {
- server.startServerPeer(serverPeerID, defaultQueueJNDIContext,
- defaultTopicJNDIContext, attrOverrides, clustered, supportsFailover);
- }
-
- public void stopServerPeer() throws Exception
- {
- server.stopServerPeer();
- }
-
- public boolean isServerPeerStarted() throws Exception
- {
- return server.isServerPeerStarted();
- }
-
- public ObjectName getServerPeerObjectName() throws Exception
- {
- return server.getServerPeerObjectName();
- }
-
- public boolean isStarted() throws Exception
- {
- return server.isStarted();
- }
-
- public Set getConnectorSubsystems() throws Exception
- {
- return server.getConnectorSubsystems();
- }
-
- public void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
- throws Exception
- {
- server.addServerInvocationHandler(subsystem, handler);
- }
-
- public void removeServerInvocationHandler(String subsystem) throws Exception
- {
- server.removeServerInvocationHandler(subsystem);
- }
-
- public MessageStore getMessageStore() throws Exception
- {
- return server.getMessageStore();
- }
-
- public DestinationManager getDestinationManager() throws Exception
- {
- return server.getDestinationManager();
- }
-
- public PersistenceManager getPersistenceManager() throws Exception
- {
- return server.getPersistenceManager();
- }
-
- public ServerPeer getServerPeer() throws Exception
- {
- return server.getServerPeer();
- }
-
- public void deployTopic(String name, String jndiName, boolean clustered) throws Exception
- {
- server.deployTopic(name, jndiName, clustered);
- }
-
- public void deployTopic(String name,
- String jndiName,
- int fullSize,
- int pageSize,
- int downCacheSize,
- boolean clustered) throws Exception
- {
- server.deployTopic(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
- }
-
- public void deployTopicProgrammatically(String name, String jndiName) throws Exception
- {
- server.deployTopicProgrammatically(name, jndiName);
- }
-
- public void deployQueue(String name, String jndiName, boolean clustered) throws Exception
- {
- server.deployQueue(name, jndiName, clustered);
- }
-
- public void deployQueue(String name,
- String jndiName,
- int fullSize,
- int pageSize,
- int downCacheSize,
- boolean clustered) throws Exception
- {
- server.deployQueue(name, jndiName, fullSize, pageSize, downCacheSize, clustered);
- }
-
- public void deployQueueProgrammatically(String name, String jndiName) throws Exception
- {
- server.deployQueueProgrammatically(name, jndiName);
- }
-
- public void undeployDestination(boolean isQueue, String name) throws Exception
- {
- server.undeployDestination(isQueue, name);
- }
-
- public boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception
- {
- return server.undeployDestinationProgrammatically(isQueue, name);
- }
-
- public void deployConnectionFactory(String objectName, String[] jndiBindings)
- throws Exception
- {
- server.deployConnectionFactory(objectName, jndiBindings);
- }
-
- public void deployConnectionFactory(String objectName, String[] jndiBindings, int prefetchSize)
- throws Exception
- {
- server.deployConnectionFactory(objectName, jndiBindings, prefetchSize);
- }
-
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize,
- int defaultTempQueueFullSize,
- int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize) throws Exception
- {
- server.deployConnectionFactory(objectName, jndiBindings, prefetchSize,
- defaultTempQueueFullSize, defaultTempQueuePageSize, defaultTempQueueDownCacheSize);
- }
-
- public void deployConnectionFactory(String objectName,
- String[] jndiBindings, boolean supportsFailover, boolean supportsLoadBalancing) throws Exception
- {
- server.deployConnectionFactory(objectName, jndiBindings, supportsFailover, supportsLoadBalancing);
- }
-
- public void undeployConnectionFactory(ObjectName objectName) throws Exception
- {
- server.undeployConnectionFactory(objectName);
- }
-
- public void configureSecurityForDestination(String destName, String config) throws Exception
- {
- server.configureSecurityForDestination(destName, config);
- }
-
- public void setDefaultSecurityConfig(String config) throws Exception
- {
- server.setDefaultSecurityConfig(config);
- }
-
- public String getDefaultSecurityConfig() throws Exception
- {
- return server.getDefaultSecurityConfig();
- }
-
- public Object executeCommand(Command command) throws Exception
- {
- return server.executeCommand(command);
- }
-
- public UserTransaction getUserTransaction() throws Exception
- {
- return server.getUserTransaction();
- }
-
- public Set getNodeIDView() throws Exception
- {
- return server.getNodeIDView();
- }
-
- public Map getFailoverMap() throws Exception
- {
- return server.getFailoverMap();
- }
-
- public Map getRecoveryArea(String queueName) throws Exception
- {
- return server.getRecoveryArea(queueName);
- }
-
- public int getRecoveryMapSize(String queueName) throws Exception
- {
- return server.getRecoveryMapSize(queueName);
- }
-
- public List pollNotificationListener(long listenerID) throws Exception
- {
- ProxyNotificationListener pl = null;
-
- synchronized(proxyListeners)
- {
- pl = (ProxyNotificationListener)proxyListeners.get(new Long(listenerID));
- }
-
- if (pl == null)
- {
- return Collections.EMPTY_LIST;
- }
-
- return pl.drain();
- }
-
- public void poisonTheServer(int type) throws Exception
- {
- server.poisonTheServer(type);
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- private RMINamingDelegate getNamingDelegate()
- {
- return namingDelegate;
- }
-
- // Inner classes -------------------------------------------------
-
- public class Deregisterer implements Runnable
- {
- public void run()
- {
- log.info("Deregistering from RMI");
-
- try
- {
- // unregister myself from the RMI registry
-
- Registry registry = LocateRegistry.getRegistry(DEFAULT_REGISTRY_PORT);
-
- String name = RMI_SERVER_PREFIX + server.getServerID();
- registry.unbind(name);
- log.info("unregistered " + name + " from registry");
- }
- catch (Throwable t)
- {
- log.error("Failed to unregister", t);
- }
-
- try
- {
- // unregister myself from the RMI registry
-
- Registry registry = LocateRegistry.getRegistry(DEFAULT_REGISTRY_PORT);
-
- String name = NAMING_SERVER_PREFIX + server.getServerID();
- registry.unbind(name);
- log.info("unregistered " + name + " from registry");
- }
- catch (Throwable t)
- {
- log.error("Failed to unregister", t);
- }
- }
- }
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RemoteTestServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RemoteTestServer.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/RemoteTestServer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,86 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx.rmi;
-
-import org.jboss.jms.server.DestinationManager;
-import org.jboss.messaging.core.contract.MessageStore;
-import org.jboss.messaging.core.contract.PersistenceManager;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>1.1</tt>
- *
- * RemoteTestServer.java,v 1.1 2006/02/21 08:25:33 timfox Exp
- */
-public class RemoteTestServer extends LocalTestServer
-{
- // Constants ------------------------------------------------------------------------------------
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
- public RemoteTestServer(int serverIndex)
- {
- super(serverIndex);
- }
-
- // Server implementation ------------------------------------------------------------------------
-
- /**
- * Only for in-VM use!
- */
- public MessageStore getMessageStore() throws Exception
- {
- throw new UnsupportedOperationException("This method shouldn't be invoked on a remote server");
- }
-
- /**
- * Only for in-VM use!
- */
- public DestinationManager getDestinationManager() throws Exception
- {
- throw new UnsupportedOperationException("This method shouldn't be invoked on a remote server");
- }
-
- /**
- * Only for in-VM use!
- */
- public PersistenceManager getPersistenceManager() throws Exception
- {
- throw new UnsupportedOperationException("This method shouldn't be invoked on a remote server");
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/Server.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,290 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx.rmi;
-
-import java.rmi.Remote;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.transaction.UserTransaction;
-
-import org.jboss.jms.server.DestinationManager;
-import org.jboss.jms.server.ServerPeer;
-import org.jboss.messaging.core.contract.MessageStore;
-import org.jboss.messaging.core.contract.PersistenceManager;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-
-/**
- * The remote interface exposed by TestServer.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface Server extends Remote
-{
- int getServerID() throws Exception;
-
- void start(String containerConfig, boolean clearDatabase) throws Exception;
-
- /**
- * @param attrOverrides - service attribute overrides that will take precedence over values
- * read from configuration files.
- */
- void start(String containerConfig,
- ServiceAttributeOverrides attrOverrides,
- boolean clearDatabase,
- boolean startMessgingServer) throws Exception;
-
- /**
- * @return true if the server was stopped indeed, or false if the server was stopped already
- * when the method was invoked.
- */
- boolean stop() throws Exception;
-
- /**
- * For a remote server, it "abruptly" kills the VM running the server. For a local server
- * it just stops the server.
- */
- void kill() throws Exception;
-
- /**
- * When kill is called you are actually schedulling the server to be killed in few milliseconds.
- * There are certain cases where we need to assure the server was really killed.
- * For that we have this simple ping we can use to verify if the server still alive or not.
- */
- void ping() throws Exception;
-
- /**
- * Deploys and registers a service based on the MBean service descriptor element, specified as
- * a String. Supports XMBeans. The implementing class and the ObjectName are inferred from the
- * mbean element. If there are configuration attributed specified in the deployment descriptor,
- * they are applied to the service instance.
- */
- ObjectName deploy(String mbeanConfiguration) throws Exception;
-
- void undeploy(ObjectName on) throws Exception;
-
- Object getAttribute(ObjectName on, String attribute) throws Exception;
-
- void setAttribute(ObjectName on, String name, String valueAsString) throws Exception;
-
- Object invoke(ObjectName on, String operationName, Object[] params, String[] signature)
- throws Exception;
-
- void addNotificationListener(ObjectName on, NotificationListener listener) throws Exception;
-
- void removeNotificationListener(ObjectName on, NotificationListener listener) throws Exception;
-
- /**
- * Returns a set of ObjectNames corresponding to installed services.
- */
- Set query(ObjectName pattern) throws Exception;
-
- /**
- * @return one of "socket", "http", ...
- */
- String getRemotingTransport() throws Exception;
-
- /**
- * Only for remote use!
- */
- void log(int level, String text) throws Exception;
-
- /**
- * @param serverPeerID - if null, the jboss-service.xml value will be used.
- * @param defaultQueueJNDIContext - if null, the jboss-service.xml value will be used.
- * @param defaultTopicJNDIContext - if null, the jboss-service.xml value will be used.
- */
- void startServerPeer(int serverPeerID,
- String defaultQueueJNDIContext,
- String defaultTopicJNDIContext,
- ServiceAttributeOverrides attrOverrides,
- boolean clustered,
- boolean supportsFailover) throws Exception;
-
- void stopServerPeer() throws Exception;
-
- boolean isServerPeerStarted() throws Exception;
-
- ObjectName getServerPeerObjectName() throws Exception;
-
- boolean isStarted() throws Exception;
-
- /**
- * @return a Set<String> with the subsystems currently registered with the Connector. It is
- * supposed to work locally as well as remotely.
- */
- Set getConnectorSubsystems() throws Exception;
-
- /**
- * Add a ServerInvocationHandler to the remoting Connector. This method is supposed to work
- * locally as well as remotely.
- */
- void addServerInvocationHandler(String subsystem, ServerInvocationHandler handler)
- throws Exception;
-
- /**
- * Remove a ServerInvocationHandler from the remoting Connector. This method is supposed to work
- * locally as well as remotely.
- */
- void removeServerInvocationHandler(String subsystem) throws Exception;
-
- /**
- * Only for in-VM use!
- */
- MessageStore getMessageStore() throws Exception;
-
- /**
- * Only for in-VM use!
- */
- DestinationManager getDestinationManager() throws Exception;
-
- PersistenceManager getPersistenceManager() throws Exception;
-
- /**
- * Only for in-VM use
- */
- ServerPeer getServerPeer() throws Exception;
-
- /**
- * Simulates a topic deployment (copying the topic descriptor in the deploy directory).
- */
- void deployTopic(String name, String jndiName, boolean clustered) throws Exception;
-
- /**
- * Simulates a topic deployment (copying the topic descriptor in the deploy directory).
- */
- void deployTopic(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception;
-
- /**
- * Creates a topic programatically.
- */
- void deployTopicProgrammatically(String name, String jndiName) throws Exception;
-
- /**
- * Simulates a queue deployment (copying the queue descriptor in the deploy directory).
- */
- void deployQueue(String name, String jndiName, boolean clustered) throws Exception;
-
- /**
- * Simulates a queue deployment (copying the queue descriptor in the deploy directory).
- */
- void deployQueue(String name, String jndiName, int fullSize, int pageSize,
- int downCacheSize, boolean clustered) throws Exception;
-
- /**
- * Creates a queue programatically.
- */
- void deployQueueProgrammatically(String name, String jndiName) throws Exception;
-
- /**
- * Simulates a destination un-deployment (deleting the destination descriptor from the deploy
- * directory).
- */
- void undeployDestination(boolean isQueue, String name) throws Exception;
-
- /**
- * Destroys a programatically created destination.
- */
- boolean undeployDestinationProgrammatically(boolean isQueue, String name) throws Exception;
-
- void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize,
- int defaultTempQueueFullSize,
- int defaultTempQueuePageSize,
- int defaultTempQueueDownCacheSize
- ) throws Exception;
-
- void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- boolean supportsFailover,
- boolean supportsLoadBalancing
- ) throws Exception;
-
- void deployConnectionFactory(String objectName,
- String[] jndiBindings,
- int prefetchSize) throws Exception;
-
- void deployConnectionFactory(String objectName,
- String[] jndiBindings) throws Exception;
-
- void undeployConnectionFactory(ObjectName objectName) throws Exception;
-
- /**
- * @param config - sending 'config' as a String and not as an org.w3c.dom.Element to avoid
- * NotSerializableExceptions that show up when running tests on JDK 1.4.
- */
- void configureSecurityForDestination(String destName, String config) throws Exception;
-
- /**
- * @param config - sending 'config' as a String and not as an org.w3c.dom.Element to avoid
- * NotSerializableExceptions that show up when running tests on JDK 1.4.
- */
- void setDefaultSecurityConfig(String config) throws Exception;
-
- /**
- * @return a String that can be converted to an org.w3c.dom.Element using
- * ServerManagement.toElement().
- */
- String getDefaultSecurityConfig() throws Exception;
-
- /**
- * Executes a command on the server
- *
- * @param command
- * @return the return value
- * @throws Exception
- */
- Object executeCommand(Command command) throws Exception;
-
- UserTransaction getUserTransaction() throws Exception;
-
- /**
- * Returns a Set containing the nodeID (as Integers) of all cluster members at the time of the
- * call.
- *
- * USE IT ONLY FOR CLUSTERING TESTS!
- */
- Set getNodeIDView() throws Exception;
-
- Map getFailoverMap() throws Exception;
-
- Map getRecoveryArea(String queueName) throws Exception;
-
- int getRecoveryMapSize(String queueName) throws Exception;
-
- /**
- * @return List<Notification>
- */
- List pollNotificationListener(long listenerID) throws Exception;
-
- void poisonTheServer(int type) throws Exception;
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/rmi/StopRMIServer.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,117 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jmx.rmi;
-
-import java.rmi.ConnectException;
-import java.rmi.Naming;
-import java.rmi.NotBoundException;
-
-import org.jboss.logging.Logger;
-
-/**
- * A utility to stop runaway rmi servers.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class StopRMIServer
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(StopRMIServer.class);
-
- // Static --------------------------------------------------------
-
- public static void main(String[] args) throws Exception
- {
-
- String host = System.getProperty("test.bind.address");
- if (host == null)
- {
- host = "localhost";
- }
-
- int index;
-
- String serverIndex = System.getProperty("test.server.index");
- if (serverIndex == null)
- {
- index = RMITestServer.DEFAULT_SERVER_INDEX;
- }
- else
- {
- index = Integer.parseInt(serverIndex);
- }
-
- String name =
- "//" + host + ":" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
- RMITestServer.RMI_SERVER_PREFIX + index;
-
- log.info("Stopping " + name);
-
- Server server;
- try
- {
- server = (Server)Naming.lookup(name);
- }
- catch(ConnectException e)
- {
- log.info("Cannot contact the registry, the server is probably shut down already");
- return;
- }
- catch(NotBoundException e)
- {
- log.info("Cannot lookup " + name + ", the server is probably shut down already");
- return;
- }
-
- try
- {
- server.kill();
- }
- catch (Throwable t)
- {
- }
-
- // The last RMI server will take with it the registry too
-
- log.info("RMI server stopped");
-
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jndi/Constants.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/Constants.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/Constants.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,36 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.messaging.tools.jndi;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class Constants
-{
- // Constants -----------------------------------------------------
-
- public static final String SERVER_INDEX_PROPERTY_NAME = "jboss.messaging.test.server.index";
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMContext.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMContext.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMContext.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,373 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jndi;
-
-import org.jboss.messaging.util.NotYetImplementedException;
-import org.jboss.util.naming.NonSerializableFactory;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.NameNotFoundException;
-import javax.naming.NameAlreadyBoundException;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
-import javax.naming.Binding;
-import javax.naming.Reference;
-import javax.naming.RefAddr;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-import java.io.Serializable;
-
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class InVMContext implements Context, Serializable
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 385743957345L;
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- protected Map map;
- protected NameParser parser = new InVMNameParser();
-
- // Constructors --------------------------------------------------
-
- public InVMContext()
- {
- map = Collections.synchronizedMap(new HashMap());
- }
-
- // Context implementation ----------------------------------------
-
- public Object lookup(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object lookup(String name) throws NamingException
- {
- name = trimSlashes(name);
- int i = name.indexOf("/");
- String tok = i == -1 ? name : name.substring(0, i);
- Object value = map.get(tok);
- if (value == null)
- {
- throw new NameNotFoundException("Name not found: " + tok);
- }
- if (value instanceof InVMContext && i != -1)
- {
- return ((InVMContext)value).lookup(name.substring(i));
- }
- if (value instanceof Reference)
- {
- Reference ref = (Reference)value;
- RefAddr refAddr = ref.get("nns");
-
- // we only deal with references create by NonSerializableFactory
- String key = (String)refAddr.getContent();
- return NonSerializableFactory.lookup(key);
- }
- else
- {
- return value;
- }
- }
-
- public void bind(Name name, Object obj) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void bind(String name, Object obj) throws NamingException
- {
- internalBind(name, obj, false);
- }
-
- public void rebind(Name name, Object obj) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void rebind(String name, Object obj) throws NamingException
- {
- internalBind(name, obj, true);
- }
-
- public void unbind(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void unbind(String name) throws NamingException
- {
- name = trimSlashes(name);
- int i = name.indexOf("/");
- boolean terminal = i == -1;
- if (terminal)
- {
- map.remove(name);
- }
- else
- {
- String tok = name.substring(0, i);
- InVMContext c = (InVMContext)map.get(tok);
- if (c == null)
- {
- throw new NameNotFoundException("Context not found: " + tok);
- }
- c.unbind(name.substring(i));
- }
- }
-
- public void rename(Name oldName, Name newName) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void rename(String oldName, String newName) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NamingEnumeration list(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NamingEnumeration list(String name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NamingEnumeration listBindings(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NamingEnumeration listBindings(String contextName) throws NamingException
- {
- contextName = trimSlashes(contextName);
- if (!"".equals(contextName) && !".".equals(contextName))
- {
- try
- {
- return ((InVMContext)lookup(contextName)).listBindings("");
- }
- catch(Throwable t)
- {
- throw new NamingException(t.getMessage());
- }
- }
-
- List l = new ArrayList();
- for(Iterator i = map.keySet().iterator(); i.hasNext(); )
- {
- String name = (String)i.next();
- Object object = map.get(name);
- l.add(new Binding(name, object));
- }
- return new NamingEnumerationImpl(l.iterator());
- }
-
- public void destroySubcontext(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void destroySubcontext(String name) throws NamingException
- {
- map.remove(trimSlashes(name));
- }
-
- public Context createSubcontext(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Context createSubcontext(String name) throws NamingException
- {
- name = trimSlashes(name);
- if (map.get(name) != null)
- {
- throw new NameAlreadyBoundException(name);
- }
- InVMContext c = new InVMContext();
- map.put(name, c);
- return c;
- }
-
- public Object lookupLink(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object lookupLink(String name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NameParser getNameParser(Name name) throws NamingException
- {
- return getNameParser(name.toString());
- }
-
- public NameParser getNameParser(String name) throws NamingException
- {
- return parser;
- }
-
- public Name composeName(Name name, Name prefix) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public String composeName(String name, String prefix) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object addToEnvironment(String propName, Object propVal) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object removeFromEnvironment(String propName) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Hashtable getEnvironment() throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void close() throws NamingException
- {
- }
-
- public String getNameInNamespace() throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- private String trimSlashes(String s)
- {
- int i = 0;
- while(true)
- {
- if (i == s.length() || s.charAt(i) != '/')
- {
- break;
- }
- i++;
- }
- s = s.substring(i);
- i = s.length() - 1;
- while(true)
- {
- if (i == -1 || s.charAt(i) != '/')
- {
- break;
- }
- i--;
- }
- return s.substring(0, i + 1);
- }
-
- private void internalBind(String name, Object obj, boolean rebind) throws NamingException
- {
- name = trimSlashes(name);
- int i = name.lastIndexOf("/");
- InVMContext c = this;
- if (i != -1)
- {
- String path = name.substring(0, i);
- c = (InVMContext)lookup(path);
- }
- name = name.substring(i + 1);
- if (!rebind && c.map.get(name) != null)
- {
- throw new NameAlreadyBoundException(name);
- }
- c.map.put(name, obj);
- }
-
- // Inner classes -------------------------------------------------
-
- private class NamingEnumerationImpl implements NamingEnumeration
- {
- private Iterator iterator;
-
- NamingEnumerationImpl(Iterator bindingIterator)
- {
- this.iterator = bindingIterator;
- }
-
- public void close() throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public boolean hasMore() throws NamingException
- {
- return iterator.hasNext();
- }
-
- public Object next() throws NamingException
- {
- return iterator.next();
- }
-
- public boolean hasMoreElements()
- {
- return iterator.hasNext();
- }
-
- public Object nextElement()
- {
- return iterator.next();
- }
- }
-}
-
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactory.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,138 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jndi;
-
-import javax.naming.spi.InitialContextFactory;
-import javax.naming.NamingException;
-import javax.naming.Context;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * An in-VM JNDI InitialContextFactory. Lightweight JNDI implementation used for testing.
-
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class InVMInitialContextFactory implements InitialContextFactory
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // List<InitialContext>
- private static List initialContexts;
-
- static
- {
- initialContexts = new ArrayList();
- }
-
- public static Hashtable getJNDIEnvironment()
- {
- return getJNDIEnvironment(0);
- }
-
- /**
- * @return the JNDI environment to use to get this InitialContextFactory.
- */
- public static Hashtable getJNDIEnvironment(int serverIndex)
- {
- Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial",
- "org.jboss.test.messaging.tools.jndi.InVMInitialContextFactory");
- env.put("java.naming.provider.url", "");
- env.put("java.naming.factory.url.pkgs", "");
- env.put(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex));
- return env;
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public Context getInitialContext(Hashtable environment) throws NamingException
- {
- // try first in the environment passed as argument ...
- String s = (String)environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
-
- if (s == null)
- {
- // ... then in the global environment
- s = System.getProperty(Constants.SERVER_INDEX_PROPERTY_NAME);
-
- if (s == null)
- {
- throw new NamingException("Cannot figure out server index!");
- }
- }
-
- int serverIndex;
-
- try
- {
- serverIndex = Integer.parseInt(s);
- }
- catch(Exception e)
- {
- throw new NamingException("Failure parsing \"" +
- Constants.SERVER_INDEX_PROPERTY_NAME +"\". " +
- s + " is not an integer");
- }
-
- int size = initialContexts.size();
-
- // pad the list to the right size
-
- if (size <= serverIndex)
- {
- for(int i = 0; i < serverIndex - size + 1; i++)
- {
- initialContexts.add(null);
- }
- }
-
- InVMContext ic = (InVMContext)initialContexts.get(serverIndex);
-
- if (ic == null)
- {
- ic = new InVMContext();
- ic.bind("java:/", new InVMContext());
- initialContexts.set(serverIndex, ic);
- }
-
- return ic;
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactoryBuilder.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactoryBuilder.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMInitialContextFactoryBuilder.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,116 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jndi;
-
-import org.jboss.logging.Logger;
-
-import javax.naming.spi.InitialContextFactoryBuilder;
-import javax.naming.spi.InitialContextFactory;
-import javax.naming.NamingException;
-import java.util.Hashtable;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- *
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class InVMInitialContextFactoryBuilder implements InitialContextFactoryBuilder
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(InVMInitialContextFactoryBuilder.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
- public InVMInitialContextFactoryBuilder()
- {
- }
-
- // InitialContextFactoryBuilder implementation --------------------------------------------------
-
- public InitialContextFactory createInitialContextFactory(Hashtable environment)
- throws NamingException
- {
-
- InitialContextFactory icf = null;
-
- if (environment != null)
- {
- String icfName = (String)environment.get("java.naming.factory.initial");
-
- if (icfName != null)
- {
- Class c = null;
-
- try
- {
- c = Class.forName(icfName);
- }
- catch(ClassNotFoundException e)
- {
- log.error("\"" + icfName + "\" cannot be loaded", e);
- throw new NamingException("\"" + icfName + "\" cannot be loaded");
- }
-
- try
- {
- icf = (InitialContextFactory)c.newInstance();
- }
- catch(InstantiationException e)
- {
- log.error(c.getName() + " cannot be instantiated", e);
- throw new NamingException(c.getName() + " cannot be instantiated");
- }
- catch(IllegalAccessException e)
- {
- log.error(c.getName() + " instantiation generated an IllegalAccessException", e);
- throw new NamingException(c.getName() +
- " instantiation generated an IllegalAccessException");
- }
- }
- }
-
- if (icf == null)
- {
- icf = new InVMInitialContextFactory();
- }
-
- return icf;
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMNameParser.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMNameParser.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/InVMNameParser.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,80 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jndi;
-
-import javax.naming.NameParser;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.CompoundName;
-import java.util.Properties;
-import java.io.Serializable;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class InVMNameParser implements NameParser, Serializable
-{
- // Constants -----------------------------------------------------
-
- private static final long serialVersionUID = 2925203703371001031L;
-
- // Static --------------------------------------------------------
-
- static Properties syntax;
-
- static
- {
- syntax = new Properties();
- syntax.put("jndi.syntax.direction", "left_to_right");
- syntax.put("jndi.syntax.ignorecase", "false");
- syntax.put("jndi.syntax.separator", "/");
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public static Properties getSyntax()
- {
- return syntax;
- }
-
- public Name parse(String name) throws NamingException
- {
- return new CompoundName(name, syntax);
- }
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jndi/JNPInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/JNPInitialContextFactory.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/JNPInitialContextFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,75 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jndi;
-
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.naming.spi.InitialContextFactory;
-
-/**
- * An InitialContextFactory providing InitialContext to JNDI on a remote JBoss instance.
-
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class JNPInitialContextFactory implements InitialContextFactory
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- /**
- * @return the JNDI environment to use to get this InitialContextFactory.
- */
- public static Hashtable getJNDIEnvironment()
- {
- Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
- env.put("java.naming.provider.url", "jnp://localhost:1099");
- env.put("java.naming.factory.url.pkg", "org.jboss.naming:org.jnp.interfaces");
- return env;
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public Context getInitialContext(Hashtable environment) throws NamingException
- {
- return new InitialContext(environment);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteContext.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,237 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jndi;
-
-import java.rmi.Naming;
-import java.util.Hashtable;
-import javax.naming.*;
-import org.jboss.logging.Logger;
-import org.jboss.messaging.util.NotYetImplementedException;
-import org.jboss.test.messaging.tools.jmx.rmi.NamingDelegate;
-import org.jboss.test.messaging.tools.jmx.rmi.RMITestServer;
-
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class RemoteContext implements Context
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(RemoteContext.class);
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private NamingDelegate namingDelegate;
-
- // Constructors --------------------------------------------------
-
- public RemoteContext(int remoteServerIndex) throws Exception
- {
- String n =
- "//localhost:" + RMITestServer.DEFAULT_REGISTRY_PORT + "/" +
- RMITestServer.NAMING_SERVER_PREFIX + remoteServerIndex;
-
- namingDelegate = (NamingDelegate)Naming.lookup(n);
-
- log.debug("remote context for server " + remoteServerIndex + " acquired from rmi:" + n);
- }
-
- // Context implementation ----------------------------------------
-
- public Object lookup(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object lookup(String name) throws NamingException
- {
- try
- {
- return namingDelegate.lookup(name);
- }
- catch(Exception e)
- {
- log.error("naming operation failed", e);
- throw new NamingException(e.getMessage());
- }
- }
-
- public void bind(Name name, Object obj) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void bind(String name, Object obj) throws NamingException
- {
- try
- {
- namingDelegate.bind(name, obj);
- }
- catch(Exception e)
- {
- log.error("naming operation failed", e);
- throw new NamingException(e.getMessage());
- }
- }
-
- public void rebind(Name name, Object obj) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void rebind(String name, Object obj) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void unbind(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void unbind(String name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void rename(Name oldName, Name newName) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void rename(String oldName, String newName) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NamingEnumeration list(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NamingEnumeration list(String name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NamingEnumeration listBindings(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NamingEnumeration listBindings(String contextName) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void destroySubcontext(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void destroySubcontext(String name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Context createSubcontext(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Context createSubcontext(String name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object lookupLink(Name name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object lookupLink(String name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public NameParser getNameParser(Name name) throws NamingException
- {
- return getNameParser(name.toString());
- }
-
- public NameParser getNameParser(String name) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Name composeName(Name name, Name prefix) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public String composeName(String name, String prefix) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object addToEnvironment(String propName, Object propVal) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Object removeFromEnvironment(String propName) throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public Hashtable getEnvironment() throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- public void close() throws NamingException
- {
- }
-
- public String getNameInNamespace() throws NamingException
- {
- throw new NotYetImplementedException();
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
-
Deleted: trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jndi/RemoteInitialContextFactory.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,95 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* 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.test.messaging.tools.jndi;
-
-import java.util.Hashtable;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.spi.InitialContextFactory;
-import org.jboss.logging.Logger;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class RemoteInitialContextFactory implements InitialContextFactory
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(RemoteInitialContextFactory.class);
-
- // Static --------------------------------------------------------
-
- /**
- * @return the JNDI environment to use to get this InitialContextFactory.
- */
- public static Hashtable getJNDIEnvironment(int serverIndex)
- {
- Hashtable env = new Hashtable();
- env.put("java.naming.factory.initial",
- "org.jboss.test.messaging.tools.jndi.RemoteInitialContextFactory");
- env.put("java.naming.provider.url", "");
- env.put("java.naming.factory.url.pkgs", "");
- env.put(Constants.SERVER_INDEX_PROPERTY_NAME, Integer.toString(serverIndex));
- return env;
- }
-
- // Attributes ----------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public Context getInitialContext(Hashtable environment) throws NamingException
- {
- String s = (String)environment.get(Constants.SERVER_INDEX_PROPERTY_NAME);
-
- if (s == null)
- {
- throw new IllegalArgumentException("Initial context environment must contain " +
- "entry for " + Constants.SERVER_INDEX_PROPERTY_NAME);
- }
-
- int remoteServerIndex = Integer.parseInt(s);
-
- try
- {
- return new RemoteContext(remoteServerIndex);
- }
- catch(Exception e)
- {
- log.error("Cannot get the remote context", e);
- throw new NamingException("Cannot get the remote context");
- }
-
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified: trunk/tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestRunner.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestRunner.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestRunner.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,15 +21,15 @@
*/
package org.jboss.test.messaging.tools.junit;
-import junit.textui.TestRunner;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import junit.framework.Test;
import junit.framework.TestResult;
-import junit.framework.Test;
import junit.framework.TestSuite;
+import junit.textui.TestRunner;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
/**
* A text TestRunner than runs only test methods specified on command line with "-t".
*
Modified: trunk/tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestSuite.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestSuite.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/junit/SelectiveTestSuite.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,17 +21,17 @@
*/
package org.jboss.test.messaging.tools.junit;
-import junit.framework.TestSuite;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
import junit.framework.Test;
import junit.framework.TestCase;
+import junit.framework.TestSuite;
-import java.util.List;
-import java.util.Enumeration;
-import java.util.ArrayList;
-import java.util.Collections;
-
/**
* A TestSuite that filters tests.
*
Modified: trunk/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -23,9 +23,9 @@
package org.jboss.test.messaging.tools.misc;
import java.security.Permission;
-import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.StringTokenizer;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/util/JNDITest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,14 +6,15 @@
*/
package org.jboss.test.messaging.util;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.logging.Logger;
+import java.util.Hashtable;
import javax.management.ObjectName;
import javax.naming.InitialContext;
-import java.util.Hashtable;
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
*
Modified: trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/util/JNDITesterService.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,9 +6,10 @@
*/
package org.jboss.test.messaging.util;
-import javax.naming.InitialContext;
import java.util.Hashtable;
+import javax.naming.InitialContext;
+
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
Modified: trunk/tests/src/org/jboss/test/messaging/util/ProxyAssertSupport.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/ProxyAssertSupport.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/util/ProxyAssertSupport.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -22,9 +22,10 @@
package org.jboss.test.messaging.util;
-import junit.framework.TestCase;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
import org.jboss.logging.Logger;
/**
Modified: trunk/tests/src/org/jboss/test/messaging/util/UtilTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/UtilTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/messaging/util/UtilTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -21,8 +21,8 @@
*/
package org.jboss.test.messaging.util;
+import org.jboss.messaging.util.Util;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.messaging.util.Util;
Modified: trunk/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -37,7 +37,7 @@
import org.jboss.security.SimplePrincipal;
import org.jboss.test.messaging.jms.JMSTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.MockJBossSecurityManager;
+import org.jboss.test.messaging.tools.container.MockJBossSecurityManager;
/**
* Set of tests to insure consistent behavior relative to the JBoss AS security infrastructure.
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackServerTimeoutTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackServerTimeoutTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/CallbackServerTimeoutTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -20,8 +20,8 @@
import org.jboss.remoting.marshal.MarshalFactory;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.test.thirdparty.remoting.util.OnewayCallbackTrigger;
import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,16 +6,16 @@
*/
package org.jboss.test.thirdparty.remoting;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.transport.PortUtil;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
import org.jboss.test.thirdparty.remoting.util.SimpleConnectionListener;
-import org.jboss.logging.Logger;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.transport.PortUtil;
/**
* Tests for http://jira.jboss.org/jira/browse/JBMESSAGING-787,
Deleted: trunk/tests/src/org/jboss/test/thirdparty/remoting/DeliveryOrderTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/DeliveryOrderTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/DeliveryOrderTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -1,217 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * 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.test.thirdparty.remoting;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-import EDU.oswego.cs.dl.util.concurrent.Latch;
-
-/**
- *
- * A DeliveryOrderTest
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class DeliveryOrderTest extends MessagingTestCase
-{
-
- public DeliveryOrderTest(String name)
- {
- super(name);
- }
-
- private ConnectionFactory cf;
-
- private Queue queue;
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- ServerManagement.start("all");
-
- ServerManagement.deployQueue("testQueue");
-
- InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
- queue = (Queue)ic.lookup("/queue/testQueue");
-
- this.drainDestination(cf, queue);
-
- ic.close();
-
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
-
- ServerManagement.undeployQueue("testQueue");
-
- ServerManagement.stop();
- }
-
- public void testOutOfOrder() throws Exception
- {
- Connection conn = null;
- try
- {
- conn = cf.createConnection();
-
- Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
-
- Session sess2 = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(queue);
-
- MessageConsumer cons = sess2.createConsumer(queue);
-
- Latch latch = new Latch();
-
- final int NUM_MESSAGES = 2000;
-
- MyListener listener = new MyListener(latch, NUM_MESSAGES);
-
- cons.setMessageListener(listener);
-
- conn.start();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sess.createTextMessage("message" + i);
-
- prod.send(tm);
-
- if (i % 10 == 0)
- {
- sess.commit();
- }
- }
-
- // need extra commit for cases in which the last message index is not a multiple of 10
- sess.commit();
-
- latch.acquire();
-
- if (listener.failed)
- {
- fail("listener failed: " + listener.getError());
- }
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- class MyListener implements MessageListener
- {
- private int c;
- private int num;
- private Latch latch;
- private volatile boolean failed;
- private String error;
-
- MyListener(Latch latch, int num)
- {
- this.latch = latch;
- this.num = num;
- }
-
- public void onMessage(Message msg)
- {
- // preserve the first error
- if (failed)
- {
- return;
- }
-
- try
- {
- TextMessage tm = (TextMessage)msg;
-
- log.debug("got " + tm.getText());
-
- if (!("message" + c).equals(tm.getText()))
- {
- // Failed
- failed = true;
- setError("Listener was supposed to get " + ("message" + c) +
- " but got " + tm.getText());
- latch.release();
- }
-
- c++;
-
- if (c == num)
- {
- latch.release();
- }
- }
- catch (JMSException e)
- {
- e.printStackTrace();
-
- // Failed
- failed = true;
- setError("Listener got exception " + e.toString());
- latch.release();
- }
- }
-
- public synchronized String getError()
- {
- return error;
- }
-
- private synchronized void setError(String s)
- {
- error = s;
- }
-
-
- }
-
-}
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,15 +6,15 @@
*/
package org.jboss.test.thirdparty.remoting;
+import javax.management.MBeanServer;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.test.thirdparty.remoting.util.TestableSubsystem;
-import org.jboss.logging.Logger;
-import javax.management.MBeanServer;
-
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/ManualConnectionValidatorTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/ManualConnectionValidatorTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/ManualConnectionValidatorTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,12 +6,12 @@
*/
package org.jboss.test.thirdparty.remoting;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
import org.jboss.test.thirdparty.remoting.util.SimpleConnectionListener;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.Client;
/**
* This test sets the connection validator ping period to a very small value, and then let the
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/PureAsynchronousCallTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,23 +6,23 @@
*/
package org.jboss.test.thirdparty.remoting;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-import org.jboss.test.thirdparty.remoting.util.OnewayCallbackTrigger;
-import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
+import javax.management.ObjectName;
+
import org.jboss.logging.Logger;
-import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
+import org.jboss.test.thirdparty.remoting.util.OnewayCallbackTrigger;
+import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
-import javax.management.ObjectName;
-
import EDU.oswego.cs.dl.util.concurrent.Channel;
import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/RemotingConnectionFailureTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,20 +6,21 @@
*/
package org.jboss.test.thirdparty.remoting;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.ObjectName;
+
+import org.jboss.remoting.CannotConnectException;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
+import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
import org.jboss.test.thirdparty.remoting.util.SimpleConnectionListener;
-import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.CannotConnectException;
-import javax.management.ObjectName;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/ServerAddressTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/ServerAddressTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/ServerAddressTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,8 +6,8 @@
*/
package org.jboss.test.thirdparty.remoting;
+import org.jboss.remoting.transport.socket.ServerAddress;
import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.remoting.transport.socket.ServerAddress;
/**
* This test makes sure that Remoting implements ServerAddress.equals() correctly.
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/SocketTransportCausalityTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/SocketTransportCausalityTest.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/SocketTransportCausalityTest.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -8,17 +8,14 @@
import java.io.Serializable;
-import javax.management.ObjectName;
-
import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.transport.PortUtil;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.jmx.ServiceAttributeOverrides;
-import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
+import org.jboss.test.messaging.tools.container.ServiceAttributeOverrides;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
/**
*
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,23 +6,24 @@
*/
package org.jboss.test.thirdparty.remoting.util;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.MBeanServer;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
import org.jboss.test.thirdparty.remoting.SocketTransportCausalityTest;
-import org.jboss.logging.Logger;
-import javax.management.MBeanServer;
-import java.io.Serializable;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-
+import EDU.oswego.cs.dl.util.concurrent.Channel;
import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import EDU.oswego.cs.dl.util.concurrent.Channel;
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,16 +6,17 @@
*/
package org.jboss.test.thirdparty.remoting.util;
-import org.jboss.logging.Logger;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.remoting.InvocationRequest;
+import java.lang.reflect.Constructor;
+import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import javax.management.MBeanRegistration;
-import java.lang.reflect.Constructor;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.container.ServiceContainer;
+
/**
* A standard MBean service to be used when testing remoting.
*
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java 2007-07-26 04:17:46 UTC (rev 2927)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java 2007-07-27 00:33:55 UTC (rev 2928)
@@ -6,11 +6,11 @@
*/
package org.jboss.test.thirdparty.remoting.util;
+import java.io.Serializable;
+
+import org.jboss.remoting.Client;
import org.jboss.remoting.ConnectionListener;
-import org.jboss.remoting.Client;
-import java.io.Serializable;
-
import EDU.oswego.cs.dl.util.concurrent.Channel;
import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
More information about the jboss-cvs-commits
mailing list