[jboss-cvs] JBoss Messaging SVN: r2098 - trunk/tests/src/org/jboss/test/thirdparty/remoting/util.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 30 02:21:00 EST 2007
Author: ovidiu.feodorov at jboss.com
Date: 2007-01-30 02:21:00 -0500 (Tue, 30 Jan 2007)
New Revision: 2098
Added:
trunk/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java
Modified:
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/RemotingTestSubsystemServiceMBean.java
Log:
Made ServerInvocationHandler implementation generically configurable for remoting tests; need to specify the implementing class name
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java 2007-01-30 06:33:33 UTC (rev 2097)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java 2007-01-30 07:21:00 UTC (rev 2098)
@@ -30,7 +30,8 @@
*
* $Id$
*/
-public class RemotingTestSubsystem implements ServerInvocationHandler, Serializable
+public class RemotingTestSubsystem
+ implements TestableSubsystem, ServerInvocationHandler, Serializable
{
// Constants ------------------------------------------------------------------------------------
@@ -59,9 +60,9 @@
private Channel invocationHistory;
private List callbackListeners;
-
+
private int[] counters = new int[10];
-
+
private boolean failed;
// Constructors ---------------------------------------------------------------------------------
@@ -95,32 +96,32 @@
log.debug(this + " ignoring invocation");
return null;
}
-
+
if (parameter instanceof SocketTransportCausalityTest.SimpleInvocation)
{
SocketTransportCausalityTest.SimpleInvocation inv = (SocketTransportCausalityTest.SimpleInvocation)parameter;
-
+
synchronized (this)
- {
+ {
int clientNum = inv.clientNumber;
-
+
int lastCount = this.counters[clientNum];
-
+
log.trace("Received client " + clientNum + " num " + inv.num);
-
+
if (inv.num != lastCount + 1)
{
//Failed - out of sequence
failed = true;
-
+
log.trace("Failed!!!! out of sequence");
}
-
+
counters[clientNum] = inv.num;
-
+
return null;
}
-
+
}
invocationHistory.put(dirtyCopy(invocation));
@@ -181,13 +182,13 @@
}
}
- // Public ---------------------------------------------------------------------------------------
+ // TestableSubsystem implementation ----------------------------------------------------------
public InvocationRequest getNextInvocation(long timeout) throws InterruptedException
{
return (InvocationRequest)invocationHistory.poll(timeout);
}
-
+
public boolean isFailed()
{
synchronized (this)
@@ -196,6 +197,13 @@
}
}
+ // Public ---------------------------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "RemotingTestSubsystem[" + Integer.toHexString(hashCode()) + "]";
+ }
+
// Package protected ----------------------------------------------------------------------------
// Protected ------------------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java 2007-01-30 06:33:33 UTC (rev 2097)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java 2007-01-30 07:21:00 UTC (rev 2098)
@@ -14,6 +14,7 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.MBeanRegistration;
+import java.lang.reflect.Constructor;
/**
* A standard MBean service to be used when testing remoting.
@@ -36,9 +37,15 @@
public static ObjectName deployService() throws Exception
{
+ return deployService("org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystem");
+ }
+
+ public static ObjectName deployService(String subsystemClassName) throws Exception
+ {
String testSubsystemConfig =
"<mbean code=\"org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService\"\n" +
" name=\"test:service=RemotingTestSubsystem\">\n" +
+ "<attribute name=\"SubsystemClassName\">" + subsystemClassName + "</attribute>" +
"</mbean>";
ObjectName on = ServerManagement.deploy(testSubsystemConfig);
@@ -61,7 +68,7 @@
new Object[] { new Long(timeout) },
new String[] { "java.lang.Long" });
}
-
+
public static boolean isFailed(ObjectName on)
throws Exception
{
@@ -74,7 +81,8 @@
private MBeanServer mbeanServer;
private ObjectName myObjectName;
- private RemotingTestSubsystem delegate;
+ private String subsystemClassName;
+ private TestableSubsystem delegate;
// Constructors ---------------------------------------------------------------------------------
@@ -104,12 +112,25 @@
// RemotingTestSubsystemServiceMBean implementation ---------------------------------------------
+ public String getSubsystemClassName()
+ {
+ return subsystemClassName;
+ }
+
+ public void setSubsystemClassName(String className)
+ {
+ this.subsystemClassName = className;
+ }
+
public void start() throws Exception
{
+ Class c = Class.forName(subsystemClassName);
+ Constructor cons = c.getConstructor(new Class[0]);
+
+ delegate = (TestableSubsystem)cons.newInstance(new Object[0]);
+
// register to the remoting connector
- delegate = new RemotingTestSubsystem();
-
mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
"addInvocationHandler",
new Object[] {SUBSYSTEM_LABEL, delegate},
@@ -150,7 +171,7 @@
return delegate.getNextInvocation(timeout.longValue());
}
-
+
public boolean isFailed() throws Exception
{
return delegate.isFailed();
Modified: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java 2007-01-30 06:33:33 UTC (rev 2097)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java 2007-01-30 07:21:00 UTC (rev 2098)
@@ -15,6 +15,9 @@
*/
public interface RemotingTestSubsystemServiceMBean
{
+ String getSubsystemClassName();
+ void setSubsystemClassName(String className);
+
void start() throws Exception;
void stop();
Added: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java
===================================================================
--- trunk/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java (rev 0)
+++ trunk/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java 2007-01-30 07:21:00 UTC (rev 2098)
@@ -0,0 +1,21 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.remoting.InvocationRequest;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public interface TestableSubsystem
+{
+ InvocationRequest getNextInvocation(long timeout) throws InterruptedException;
+
+ boolean isFailed();
+}
Property changes on: trunk/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
More information about the jboss-cvs-commits
mailing list