[jboss-cvs] JBoss Messaging SVN: r3966 - in branches/Branch_JBossMessaging_1_4_0_SP3_CP: tests/src/org/jboss/test/messaging/jms/clustering and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 27 14:05:53 EDT 2008
Author: clebert.suconic at jboss.com
Date: 2008-03-27 14:05:52 -0400 (Thu, 27 Mar 2008)
New Revision: 3966
Modified:
branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java
Log:
Re-enabling test after changes on JBMESSAGING-1262
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2008-03-27 18:01:52 UTC (rev 3965)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2008-03-27 18:05:52 UTC (rev 3966)
@@ -21,6 +21,7 @@
*/
package org.jboss.jms.server.endpoint;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -372,6 +373,12 @@
{
return "ConnectionFactoryEndpoint[" + id + "]";
}
+
+ /** Method used for tests and validations only */
+ public Set getCallbackHandlers()
+ {
+ return java.util.Collections.unmodifiableSet(handlers);
+ }
// Package protected ----------------------------------------------------------------------------
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java 2008-03-27 18:01:52 UTC (rev 3965)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/tests/src/org/jboss/test/messaging/jms/clustering/ClusteredClientCrashTest.java 2008-03-27 18:05:52 UTC (rev 3966)
@@ -28,6 +28,9 @@
import javax.jms.ConnectionFactory;
import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint;
+import org.jboss.jms.server.endpoint.advised.ConnectionFactoryAdvised;
+import org.jboss.jms.wireformat.Dispatcher;
import org.jboss.logging.Logger;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.container.Command;
@@ -81,11 +84,16 @@
ServerManagement.create(2);
Server remoteServer = ServerManagement.getServer(2);
- // We need to make sure that any previously downloaded CF should be released
+ // Make sure any previously downloadeded CF is released
WeakReference ref = new WeakReference(ic[0].lookup("/ClusteredConnectionFactory"));
int count=0;
while (ref.get() != null)
{
+ // put some garbage on the memory
+ for (int i=0; i<50000 ; i++)
+ {
+ String str = "Garbage " + i;
+ }
System.gc();
Thread.sleep(1000);
if ((count++>10) && ref.get() != null)
@@ -96,19 +104,32 @@
ClientClusteredConnectionFactoryDelegate cfDelegate = (ClientClusteredConnectionFactoryDelegate)cf.getDelegate();
+ log.info("(Before)Server0 - " + getCountOnServer(0, cfDelegate.getUniqueName()));
+ log.info("(Before)Server1 - " + getCountOnServer(1, cfDelegate.getUniqueName()));
+
+ assertEquals(1, getCountOnServer(0, cfDelegate.getUniqueName()));
+ assertEquals(1, getCountOnServer(1, cfDelegate.getUniqueName()));
+
cfDelegate.closeCallback();
+
+ // Validates if closeCallback is working
+ assertEquals(0, getCountOnServer(0, cfDelegate.getUniqueName()));
+ assertEquals(0, getCountOnServer(1, cfDelegate.getUniqueName()));
+
ClusterClientCrash command = new ClusterClientCrash(cf);
assertEquals("OK", remoteServer.executeCommand(command));
+
+
- //assertEquals(new Integer(1),ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
+ assertEquals(new Integer(1),ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
ServerManagement.kill(2);
Thread.sleep((long)(60000));
- // assertEquals(new Integer(0), ServerManagement.getServer(0).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
- // assertEquals(new Integer(0), ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(cfDelegate.getUniqueName())));
+ assertEquals(0, getCountOnServer(1, cfDelegate.getUniqueName()));
+ assertEquals(0, getCountOnServer(0, cfDelegate.getUniqueName()));
}
@@ -117,6 +138,11 @@
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
+
+ private int getCountOnServer(int server, String uniquename) throws Exception
+ {
+ return (Integer)ServerManagement.getServer(1).executeCommand(new VerifySizeOfCFClients(uniquename));
+ }
// Inner classes -------------------------------------------------
@@ -140,23 +166,31 @@
}
}
-// public static class VerifySizeOfCFClients implements Command
-// {
-//
-// String uniqueName;
-//
-// public VerifySizeOfCFClients(String uniqueName)
-// {
-// this.uniqueName = uniqueName;
-// }
-//
-// public Object execute(Server server) throws Exception
-// {
-//
-// int size = server.getServerPeer().getConnectionManager().getConnectionFactoryCallback(uniqueName).length;
-//
-// return new Integer(size);
-// }
-// }
+ public static class VerifySizeOfCFClients implements Command
+ {
+ private static final long serialVersionUID = 7783882344446813622L;
+
+ String uniqueName;
+
+ public VerifySizeOfCFClients(String uniqueName)
+ {
+ this.uniqueName = uniqueName;
+ }
+
+ public Object execute(Server server) throws Exception
+ {
+
+ ConnectionFactoryAdvised advised = (ConnectionFactoryAdvised)Dispatcher.instance.getTarget(uniqueName);
+ if (advised == null)
+ {
+ return -1;
+ }
+ ServerConnectionFactoryEndpoint endpoint = (ServerConnectionFactoryEndpoint)advised.getEndpoint();
+
+ int size = endpoint.getCallbackHandlers().size();
+ return new Integer(size);
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list