libjboss-remoting-java-2.5.3.SP1.orig/ 0000755 0001750 0001750 00000000000 11632407223 017370 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/lib/ 0000755 0001750 0001750 00000000000 11632407207 020140 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/ 0000755 0001750 0001750 00000000000 11632407052 020157 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/ 0000755 0001750 0001750 00000000000 11632407030 021315 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/ 0000755 0001750 0001750 00000000000 11632407030 022104 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ 0000755 0001750 0001750 00000000000 11632407044 023231 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ant/ 0000755 0001750 0001750 00000000000 11632407044 024013 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ant/taskdefs/ 0000755 0001750 0001750 00000000000 11632407044 025617 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000154 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatt0000644 0001750 0001750 00000005326 11004016503 033417 0 ustar twerner twerner /* * 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.ant.taskdefs; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest; import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter; /** * @author Tom Elrod */ public class XMLJUnitMultipleResultFormatter extends XMLJUnitResultFormatter { public void startTestSuite(final JUnitTest test) { // String configuration = SecurityUtility.getSystemProperty("jboss-junit-configuration"); String configuration = null; try { configuration = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty("jboss-junit-configuration"); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } // if sys prop is not null, empty, or contain default variable alias if(configuration != null && !configuration.trim().equals("") && configuration.indexOf("jboss-junit-configuration") == -1) { test.setName(test.getName() + "(" + configuration + ")"); } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { XMLJUnitMultipleResultFormatter.super.startTestSuite(test); return null; } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/ 0000755 0001750 0001750 00000000000 11632407044 024210 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ 0000755 0001750 0001750 00000000000 11632407044 026034 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/ 0000755 0001750 0001750 00000000000 11632407031 030026 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/ 0000755 0001750 0001750 00000000000 11632407031 031334 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000166 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/ServerExceptionTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/ServerExcep0000644 0001750 0001750 00000014015 10355142433 033516 0 ustar twerner twerner /* * 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.remoting.exception.server; import javax.management.MBeanServer; import org.jboss.logging.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import junit.framework.TestCase; /** * @author Tom Elrod */ public class ServerExceptionTestCase extends TestCase { private static final Logger log = Logger.getLogger(ServerExceptionTestCase.class); public void setupServer(String locatorURI) throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); Connector connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); TestInvocationHandler invocationHandler = new TestInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("test", invocationHandler); } public void testServerException() { try { log.debug("running testServerException()"); InvokerLocator locator = new InvokerLocator("socket://localhost:8823"); setupServer(locator.getOriginalURI()); Client client = new Client(locator, "test"); client.connect(); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); try { Object ret = client.invoke(new NameBasedInvocation("throwServerException", new Object[]{"nonserialized"}, new String[]{String.class.getName()}), null); } catch(NonSerializeTestException nonEx) { log.debug("Expected to get NonSerializable exception and got it.", nonEx); assertTrue(true); } try { Object ret = client.invoke(new NameBasedInvocation("throwServerException", new Object[]{"serialized"}, new String[]{String.class.getName()}), null); } catch(SerializedTestException ex) { log.debug("Expected to get Serializable exception and got it.", ex); assertTrue(true); } } catch(CannotConnectException cce) { log.debug("Got CannotConnectException.", cce); assertTrue("Did not expect CannotConnectException.", false); } catch(Throwable tr) { tr.printStackTrace(); assertTrue("Did not catch server exception as expected.", false); } } /** * Simple invocation handler implementation. */ public static class TestInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { String param = (String) ((NameBasedInvocation) invocation.getParameter()).getParameters()[0]; if(param.equals("serialized")) { throw new SerializedTestException("This is serialized server test exception"); } else { throw new NonSerializeTestException("This is a non serialized server test exception"); } } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { // NO OP as do not handling callback listeners in this example } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { // NO OP as do not handling callback listeners in this example } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } } ././@LongLink 0000000 0000000 0000000 00000000166 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/SerializedTestException.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/SerializedT0000644 0001750 0001750 00000002430 10355142433 033500 0 ustar twerner twerner /* * 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.remoting.exception.server; import java.io.Serializable; /** * @author Tom Elrod */ public class SerializedTestException extends Throwable implements Serializable { public SerializedTestException(String s) { super(s); } } ././@LongLink 0000000 0000000 0000000 00000000170 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/NonSerializeTestException.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/NonSerializ0000644 0001750 0001750 00000002347 10355142433 033525 0 ustar twerner twerner /* * 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.remoting.exception.server; /** * @author Tom Elrod */ public class NonSerializeTestException extends Throwable { public NonSerializeTestException(String s) { super(s); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/ 0000755 0001750 0001750 00000000000 11632407031 032662 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000145 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/rmi/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/rmi/0000755 0001750 0001750 00000000000 11632407031 033451 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/rmi/CannotConnectTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/rmi/0000644 0001750 0001750 00000004665 10355142433 033471 0 ustar twerner twerner /* * 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.remoting.exception.cannotconnect.rmi; import org.jboss.logging.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import junit.framework.TestCase; /** * @author Tom Elrod */ public class CannotConnectTestCase extends TestCase { private static final Logger log = Logger.getLogger(CannotConnectTestCase.class); public void testCannotConnect() { try { log.debug("running testCannotConnect()"); InvokerLocator locator = new InvokerLocator("rmi://localhost:8823"); Client client = new Client(locator, "mock"); client.connect(); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); Object ret = client.invoke(new NameBasedInvocation("foo", new Object[]{"bar"}, new String[]{String.class.getName()}), null); } catch(CannotConnectException cce) { log.debug("Got CannotConnectException as expected."); assertTrue(true); } catch(Throwable tr) { tr.printStackTrace(); assertTrue("Did not catch CannotConnectException as expected.", false); } } } ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011561 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/socket/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/sock0000755 0001750 0001750 00000000000 11632407031 033542 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000202 00000000000 011557 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/socket/CannotConnectTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/sock0000644 0001750 0001750 00000004673 10355142433 033561 0 ustar twerner twerner /* * 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.remoting.exception.cannotconnect.socket; import org.jboss.logging.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import junit.framework.TestCase; /** * @author Tom Elrod */ public class CannotConnectTestCase extends TestCase { private static final Logger log = Logger.getLogger(CannotConnectTestCase.class); public void testCannotConnect() { try { log.debug("running testCannotConnect()"); InvokerLocator locator = new InvokerLocator("socket://localhost:8829"); Client client = new Client(locator, "mock"); client.connect(); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); Object ret = client.invoke(new NameBasedInvocation("foo", new Object[]{"bar"}, new String[]{String.class.getName()}), null); } catch(CannotConnectException cce) { log.debug("Got CannotConnectException as expected."); assertTrue(true); } catch(Throwable tr) { tr.printStackTrace(); assertTrue("Did not catch CannotConnectException as expected.", false); } } } ././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/http/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/http0000755 0001750 0001750 00000000000 11632407031 033562 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000200 00000000000 011555 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/http/CannotConnectTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/http0000644 0001750 0001750 00000004667 10355142433 033604 0 ustar twerner twerner /* * 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.remoting.exception.cannotconnect.http; import org.jboss.logging.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import junit.framework.TestCase; /** * @author Tom Elrod */ public class CannotConnectTestCase extends TestCase { private static final Logger log = Logger.getLogger(CannotConnectTestCase.class); public void testCannotConnect() { try { log.debug("running testCannotConnect()"); InvokerLocator locator = new InvokerLocator("http://localhost:8823"); Client client = new Client(locator, "mock"); client.connect(); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); Object ret = client.invoke(new NameBasedInvocation("foo", new Object[]{"bar"}, new String[]{String.class.getName()}), null); } catch(CannotConnectException cce) { log.debug("Got CannotConnectException as expected."); assertTrue(true); } catch(Throwable tr) { tr.printStackTrace(); assertTrue("Did not catch CannotConnectException as expected.", false); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/datatype/ 0000755 0001750 0001750 00000000000 11632407032 027644 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCas0000644 0001750 0001750 00000016771 11413660476 033412 0 ustar twerner twerner /* * JBoss, Home of Professional Open Source * Copyright 2009, 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.remoting.datatype; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.MicroRemoteClientInvoker; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import EDU.oswego.cs.dl.util.concurrent.Rendezvous; /** * Unit test for JBREM-1109. * * @author Ron Sigal * @version *
* Copyright Apr 8, 2009 *
*/ public class DataTypeRaceTestCase extends TestCase { private static Logger log = Logger.getLogger(DataTypeRaceTestCase.class); private static boolean firstTime = true; protected static String dataType; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected Object lock = new Object(); public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testDataTypeRace() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test datatype race. MicroRemoteClientInvoker clientInvoker = (MicroRemoteClientInvoker) client.getInvoker(); int THREADS = 1000; TestThread[] threads = new TestThread[THREADS]; Rendezvous startBarrier = new Rendezvous(THREADS); Rendezvous stopBarrier = new Rendezvous(THREADS + 1); log.info(getName() + " creating " + THREADS + " threads"); for (int i = 0; i < THREADS; i++) { threads[i] = new TestThread(clientInvoker, startBarrier, stopBarrier, i); threads[i].start(); } log.info(getName() + " waiting on stopBarrier"); rendezvous(stopBarrier); log.info(getName() + " checking threads"); for (int i = 0; i < THREADS; i++) { assertTrue("failure in " + threads[i], threads[i].ok); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "/?" + metadata; } serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } protected static void rendezvous(Rendezvous barrier) { while (true) { try { barrier.rendezvous(null); break; } catch (InterruptedException e1) { } } } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestThread extends Thread { String name; ClientInvoker clientInvoker; Rendezvous startBarrier; Rendezvous stopBarrier; InvocationRequest request = new InvocationRequest(null, null, "abc", null, null, null); boolean ok; public TestThread(ClientInvoker clientInvoker, Rendezvous startBarrier, Rendezvous stopBarrier, int number) { this.clientInvoker = clientInvoker; this.startBarrier = startBarrier; this.stopBarrier = stopBarrier; name = "TestThread[" + number + "]"; } public void run() { // log.debug(this + " waiting on startBarrier"); rendezvous(startBarrier); // log.debug(this + " executing"); try { clientInvoker.invoke(request); // log.debug(this + " waiting on stopBarrier"); ok = true; rendezvous(stopBarrier); // log.debug(this + " done"); } catch (Throwable t) { t.printStackTrace(); rendezvous(stopBarrier); } } public String toString() { return name; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/ 0000755 0001750 0001750 00000000000 11632407044 027011 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilTestCase.java 0000644 0001750 0001750 00000006575 11003477354 033112 0 ustar twerner twerner /* * 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.remoting.util; import org.jboss.remoting.transport.PortUtil; import junit.framework.TestCase; import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt; /** * @author Tom Elrod */ public class PortUtilTestCase extends TestCase { private byte[] portArray = null; private static SynchronizedInt counter = new SynchronizedInt(0); private static SynchronizedInt countToWait = new SynchronizedInt(0); private static int errorPort = 0; private static boolean error = false; private String host = "localhost"; //private String host = "192.168.1.202"; public void setUp() { portArray = new byte[65536]; } public void testFindingFreePorts() { int maxWaitNumber = 20; int numOfThreads = 100; for(int x = 0; x < numOfThreads; x++) { new Thread(new Runnable() { public void run() { try { counter.increment(); byte portFlag = 1; int port = PortUtil.findFreePort(host); System.out.println("port found: " + port); byte portVal = portArray[port]; portArray[port] = portFlag; assertEquals("Found port already in use: " + port, 0, portVal); if(portVal == 1) { error = true; errorPort = port; } } catch(Throwable e) { error = true; assertTrue("Error: " + e.getMessage(), false); } } }).start(); } while(counter.get() < numOfThreads && !error) { countToWait.increment(); if(countToWait.get() > maxWaitNumber) { break; } try { Thread.currentThread().sleep(1000); } catch(InterruptedException e) { e.printStackTrace(); } System.out.println("counter: " + counter); } if(error) { assertTrue("Error in getting free port (duplicate port = " + errorPort + ")", false); } if(countToWait.get() >= maxWaitNumber) { assertTrue("Error in getting free port. Never got to error or reached number of counts.", false); } } } ././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWithXMLTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWi0000644 0001750 0001750 00000015326 11413660476 033475 0 ustar twerner twerner /* * JBoss, Home of Professional Open Source * Copyright 2009, 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.remoting.util; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.InetAddress; import javax.management.MBeanServer; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; /** * Unit test for JBREM-1139. * * @author Ron Sigal * @version $Revision: 2320 $ ** Copyright July 13, 2009. *
*/ public class PortUtilRangeOnServerWithXMLTestCase extends TestCase { private static Logger log = Logger.getLogger(PortUtilRangeOnServerWithXMLTestCase.class); public void testUpdateRangeOnServer() throws Exception { log.info("entering " + getName()); // Test initial values. assertEquals(1024, PortUtil.getMinPort()); assertEquals(65535, PortUtil.getMaxPort()); // Set new values. Connector connector = new Connector(); connector.setConfiguration(getXML(2000, 60000)); connector.start(); assertEquals(2000, PortUtil.getMinPort()); assertEquals(60000, PortUtil.getMaxPort()); connector.stop(); // Set more restrictive values. connector = new Connector(); connector.setConfiguration(getXML(3000, 50000)); connector.start(); assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); // Try to set less restrictive values - should have no effect. connector = new Connector(); connector.setConfiguration(getXML(2000, 60000)); connector.start(); assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); // Try to set invalid minPort - should have no effect. connector = new Connector(); connector.setConfiguration(getXML(60000, -1)); try { log.info("====================================="); log.info("EXPECT ILLEGAL_STATE_EXCEPTION"); connector.start(); } catch (Exception e) { log.info(e.getMessage()); if (e instanceof IllegalStateException && e.getMessage() != null && e.getMessage().startsWith("Error configuring invoker for connector.")) { log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION"); log.info("====================================="); } else { fail("expected IllegalStateException"); } } assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); // Try to set invalid maxPort - should have no effect. connector = new Connector(); connector.setConfiguration(getXML(-1, 2000)); try { log.info("====================================="); log.info("EXPECT ILLEGAL_STATE_EXCEPTION"); connector.start(); } catch (Exception e) { log.info(e.getMessage()); if (e instanceof IllegalStateException && e.getMessage() != null && e.getMessage().startsWith("Error configuring invoker for connector.")) { log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION"); log.info("====================================="); } else { fail("expected IllegalStateException"); } } assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); log.info(getName()+ " PASSES"); } Element getXML(int minPort, int maxPort) throws SAXException, IOException, ParserConfigurationException { String host = InetAddress.getLocalHost().getHostAddress(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append("* Copyright July 13, 2009. *
*/ public class PortUtilRangeOnServerWithServerConfigurationTestCase extends TestCase { private static Logger log = Logger.getLogger(PortUtilRangeOnServerWithServerConfigurationTestCase.class); private static boolean firstTime = true; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.DEBUG); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void testUpdateRangeOnServer() throws Exception { log.info("entering " + getName()); // Test initial values. assertEquals(1024, PortUtil.getMinPort()); assertEquals(65535, PortUtil.getMaxPort()); // Set new values. Connector connector = new Connector(); connector.setServerConfiguration(getServerConfiguration(2000, 60000)); connector.start(); assertEquals(2000, PortUtil.getMinPort()); assertEquals(60000, PortUtil.getMaxPort()); connector.stop(); // Set more restrictive values. connector = new Connector(); connector.setServerConfiguration(getServerConfiguration(3000, 50000)); connector.start(); assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); // Try to set less restrictive values - should have no effect. connector = new Connector(); connector.setServerConfiguration(getServerConfiguration(2000, 60000)); connector.start(); assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); // Try to set invalid minPort - should have no effect. connector = new Connector(); connector.setServerConfiguration(getServerConfiguration(60000, -1)); try { log.info("====================================="); log.info("EXPECT ILLEGAL_STATE_EXCEPTION"); connector.start(); } catch (Exception e) { log.info(e.getMessage()); if (e instanceof RuntimeException && e.getMessage().startsWith("Error setting up server invoker") && e.getCause() instanceof IllegalStateException && e.getCause().getMessage() != null && e.getCause().getMessage().startsWith("trying to set minPort to value greater than maxPort:")) { log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION"); log.info("====================================="); } else { fail("expected IllegalStateException: " + e.getMessage()); } } assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); // Try to set invalid maxPort - should have no effect. connector = new Connector(); connector.setServerConfiguration(getServerConfiguration(-1, 2000)); try { log.info("====================================="); log.info("EXPECT ILLEGAL_STATE_EXCEPTION"); connector.start(); } catch (Exception e) { log.info(e.getMessage()); if (e instanceof RuntimeException && e.getMessage().startsWith("Error setting up server invoker") && e.getCause() instanceof IllegalStateException && e.getCause().getMessage() != null && e.getCause().getMessage().startsWith("trying to set maxPort to value less than minPort:")) { log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION"); log.info("====================================="); } else { fail("expected IllegalStateException"); } } assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); log.info(getName()+ " PASSES"); } // Element getXML(int minPort, int maxPort) throws SAXException, IOException, ParserConfigurationException // { // String host = InetAddress.getLocalHost().getHostAddress(); // StringBuffer buf = new StringBuffer(); // buf.append("\n"); // buf.append("* Copyright Jan 18, 2007 *
*/ public class TimerUtilTestCase extends TestCase { private static Logger log = Logger.getLogger(TimerUtilTestCase.class); public void testTimerTaskDestroy() throws Exception { log.info("entering " + getName()); TestTimerTask task = new TestTimerTask(); TimerUtil.schedule(task, 500); Thread.sleep(1000); assertTrue(task.ran); assertFalse(task.stopped); assertFalse(task.stoppedTwice); assertFalse(task.continuedToRun); TimerUtil.destroy(); Thread.sleep(2000); assertTrue(task.stopped); assertTrue(task.stoppedTwice); assertFalse(task.continuedToRun); log.info(getName() + " PASSED"); } public void testTimerTaskUnschedule() throws Exception { log.info("entering " + getName()); TestTimerTask task = new TestTimerTask(); TimerUtil.schedule(task, 500); Thread.sleep(1000); assertTrue(task.ran); assertFalse(task.stopped); assertFalse(task.stoppedTwice); TimerUtil.unschedule(task); Thread.sleep(2000); assertTrue(task.stopped); assertTrue(task.stoppedTwice); assertFalse(task.continuedToRun); log.info(getName() + " PASSED"); } public void testTimerTaskStop() throws Exception { log.info("entering " + getName()); TestTimerTask task = new TestTimerTask(); TimerUtil.schedule(task, 500); Thread.sleep(1000); assertTrue(task.ran); assertFalse(task.stopped); assertFalse(task.stoppedTwice); task.stop(); Thread.sleep(2000); assertTrue(task.stopped); assertTrue(task.stoppedTwice); assertFalse(task.continuedToRun); log.info(getName() + " PASSED"); } /** * Unit test for JBREM-851. */ public void testReplaceTimer() throws Exception { log.info("entering " + getName()); TestTimerTask task = new TestTimerTask(); TimerUtil.schedule(task, 500); Thread.sleep(1000); assertTrue(task.ran); assertFalse(task.stopped); assertFalse(task.stoppedTwice); task.stop(); Thread.sleep(2000); assertTrue(task.stopped); assertTrue(task.stoppedTwice); assertFalse(task.continuedToRun); // Give TimerUtil.timer a chance to shut itself down. // Note that there is no guarantee that the Timer will, in fact, shut itself // down. The behavior is implementation dependent. Thread.sleep(120000); task = new TestTimerTask(); TimerUtil.schedule(task, 500); Thread.sleep(1000); assertTrue(task.ran); assertFalse(task.stopped); assertFalse(task.stoppedTwice); task.stop(); assertTrue(task.stopped); assertTrue(task.stoppedTwice); assertFalse(task.continuedToRun); log.info(getName() + " PASSED"); } class TestTimerTask extends TimerTask implements StoppableTimerTask { public boolean ran; public boolean stopped; public boolean stoppedTwice; public boolean continuedToRun1; public boolean continuedToRun; public void run() { log.info("run called"); ran = true; if (continuedToRun1) continuedToRun = true; if (stopped) continuedToRun1 = true; } public void stop() throws Exception { log.info("stop called"); if (stopped) stoppedTwice = true; else { stopped = true; TimerUtil.unschedule(this); cancel(); } } } } ././@LongLink 0000000 0000000 0000000 00000000160 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTe0000644 0001750 0001750 00000014162 11413660476 033463 0 ustar twerner twerner /* * JBoss, Home of Professional Open Source * Copyright 2009, 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.remoting.util; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1139. * * @author Ron Sigal * @version $Revision: 2320 $ ** Copyright July 13, 2009. *
*/ public class PortUtilRangeOnServerTestCase extends TestCase { private static Logger log = Logger.getLogger(PortUtilRangeOnServerTestCase.class); public void testUpdateRangeOnServer() throws Exception { log.info("entering " + getName()); // Test initial values. assertEquals(1024, PortUtil.getMinPort()); assertEquals(65535, PortUtil.getMaxPort()); // Set new values using configuration mapr. Map serverConfig = new HashMap(); serverConfig.put(PortUtil.MIN_PORT, "2000"); serverConfig.put(PortUtil.MAX_PORT, "60000"); String host = InetAddress.getLocalHost().getHostAddress(); InvokerLocator locator = new InvokerLocator("socket://" + host); Connector connector = new Connector(locator, serverConfig); connector.start(); log.info("InvokerLocator: " + connector.getInvokerLocator()); assertEquals(2000, PortUtil.getMinPort()); assertEquals(60000, PortUtil.getMaxPort()); connector.stop(); // Set more restrictive values using configuration map. serverConfig.put(PortUtil.MIN_PORT, "3000"); serverConfig.put(PortUtil.MAX_PORT, "50000"); connector = new Connector(locator, serverConfig); connector.start(); log.info("InvokerLocator: " + connector.getInvokerLocator()); assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); connector.stop(); // Set more restrictive values with InvokerLocator overriding configuration map. serverConfig.put(PortUtil.MIN_PORT, "3500"); serverConfig.put(PortUtil.MAX_PORT, "45000"); locator = new InvokerLocator("socket://" + host + "/?" + PortUtil.MIN_PORT + "=4000&" + PortUtil.MAX_PORT + "=40000"); connector = new Connector(locator, serverConfig); connector.start(); log.info("InvokerLocator: " + connector.getInvokerLocator()); assertEquals(4000, PortUtil.getMinPort()); assertEquals(40000, PortUtil.getMaxPort()); connector.stop(); // Try to set less restrictive values - should have no effect. serverConfig.put(PortUtil.MIN_PORT, "2000"); serverConfig.put(PortUtil.MAX_PORT, "60000"); locator = new InvokerLocator("socket://" + host); connector = new Connector(locator, serverConfig); connector.start(); log.info("InvokerLocator: " + connector.getInvokerLocator()); assertEquals(4000, PortUtil.getMinPort()); assertEquals(40000, PortUtil.getMaxPort()); connector.stop(); // Try to set invalid minPort - should have no effect. serverConfig.put(PortUtil.MIN_PORT, "60000"); serverConfig.remove(PortUtil.MAX_PORT); connector = new Connector(locator, serverConfig); try { log.info("====================================="); log.info("EXPECT ILLEGAL_STATE_EXCEPTION"); connector.start(); } catch (Exception e) { log.info(e.getCause()); if (e.getCause() instanceof IllegalStateException && e.getCause().getMessage() != null && e.getCause().getMessage().startsWith("trying to set minPort")) { log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION"); log.info("====================================="); } else { fail("expected IllegalStateException"); } } log.info("InvokerLocator: " + connector.getInvokerLocator()); assertEquals(4000, PortUtil.getMinPort()); assertEquals(40000, PortUtil.getMaxPort()); connector.stop(); // Try to set invalid maxPort - should have no effect. serverConfig.remove(PortUtil.MIN_PORT); serverConfig.put(PortUtil.MAX_PORT, "2000"); connector = new Connector(locator, serverConfig); try { log.info("====================================="); log.info("EXPECT ILLEGAL_STATE_EXCEPTION"); connector.start(); } catch (Exception e) { log.info(e.getCause()); if (e.getCause() instanceof IllegalStateException && e.getCause().getMessage() != null && e.getCause().getMessage().startsWith("trying to set maxPort")) { log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION"); log.info("====================================="); } else { fail("expected IllegalStateException"); } } log.info("InvokerLocator: " + connector.getInvokerLocator()); assertEquals(4000, PortUtil.getMinPort()); assertEquals(40000, PortUtil.getMaxPort()); connector.stop(); log.info(getName()+ " PASSES"); } } ././@LongLink 0000000 0000000 0000000 00000000160 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTe0000644 0001750 0001750 00000012477 11413660476 033442 0 ustar twerner twerner /* * JBoss, Home of Professional Open Source * Copyright 2009, 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.remoting.util; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1139. * * @author Ron Sigal * @version $Revision: 2320 $ ** Copyright July 13, 2009. *
*/ public class PortUtilRangeOnClientTestCase extends TestCase { private static Logger log = Logger.getLogger(PortUtilRangeOnClientTestCase.class); public void testUpdateRangeOnClient() throws Exception { log.info("entering " + getName()); // Test initial values. assertEquals(1024, PortUtil.getMinPort()); assertEquals(65535, PortUtil.getMaxPort()); // Set new values using configuration map. Map clientConfig = new HashMap(); clientConfig.put(PortUtil.MIN_PORT, "2000"); clientConfig.put(PortUtil.MAX_PORT, "60000"); String host = InetAddress.getLocalHost().getHostAddress(); InvokerLocator locator = new InvokerLocator("socket://" + host); Client client = new Client(locator, clientConfig); assertEquals(2000, PortUtil.getMinPort()); assertEquals(60000, PortUtil.getMaxPort()); // Set more restrictive values using configuration map. clientConfig.put(PortUtil.MIN_PORT, "3000"); clientConfig.put(PortUtil.MAX_PORT, "50000"); client = new Client(locator, clientConfig); assertEquals(3000, PortUtil.getMinPort()); assertEquals(50000, PortUtil.getMaxPort()); // Set more restrictive values with InvokerLocator overriding configuration map. clientConfig.put(PortUtil.MIN_PORT, "3500"); clientConfig.put(PortUtil.MAX_PORT, "45000"); locator = new InvokerLocator("socket://" + host + "/?" + PortUtil.MIN_PORT + "=4000&" + PortUtil.MAX_PORT + "=40000"); client = new Client(locator, clientConfig); assertEquals(4000, PortUtil.getMinPort()); assertEquals(40000, PortUtil.getMaxPort()); // Try to set less restrictive values - should have no effect. clientConfig.put(PortUtil.MIN_PORT, "2000"); clientConfig.put(PortUtil.MAX_PORT, "60000"); locator = new InvokerLocator("socket://" + host); client = new Client(locator, clientConfig); assertEquals(4000, PortUtil.getMinPort()); assertEquals(40000, PortUtil.getMaxPort()); // Try to set invalid minPort - should have no effect. clientConfig.put(PortUtil.MIN_PORT, "60000"); clientConfig.remove(PortUtil.MAX_PORT); try { log.info("====================================="); log.info("EXPECT ILLEGAL_STATE_EXCEPTION"); client = new Client(locator, clientConfig); } catch (Exception e) { log.info(e.getMessage()); if (e instanceof IllegalStateException && e.getMessage() != null && e.getMessage().startsWith("trying to set minPort")) { log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION"); log.info("====================================="); } else { fail("expected IllegalStateException"); } } assertEquals(4000, PortUtil.getMinPort()); assertEquals(40000, PortUtil.getMaxPort()); // Try to set invalid maxPort - should have no effect. clientConfig.remove(PortUtil.MIN_PORT); clientConfig.put(PortUtil.MAX_PORT, "2000"); try { log.info("====================================="); log.info("EXPECT ILLEGAL_STATE_EXCEPTION"); client = new Client(locator, clientConfig); } catch (Exception e) { log.info(e.getMessage()); if (e instanceof IllegalStateException && e.getMessage() != null && e.getMessage().startsWith("trying to set maxPort")) { log.info("GOT EXPECTED ILLEGAL_STATE_EXCEPTION"); log.info("====================================="); } else { fail("expected IllegalStateException"); } } assertEquals(4000, PortUtil.getMinPort()); assertEquals(40000, PortUtil.getMaxPort()); log.info(getName()+ " PASSES"); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ComplexReturn.java 0000644 0001750 0001750 00000003113 10355142433 031503 0 ustar twerner twerner /* * 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.remoting; import java.io.Serializable; import org.jboss.test.remoting.transport.mock.MockTest; /** * Just a dumb test class used for testing the passing of complex * objects within arrays in the invoker tests. * * @author Tom Elrod */ public class ComplexReturn implements Serializable { private MockTest[] mockTests; public ComplexReturn() { mockTests = new MockTest[2]; mockTests[0] = new MockTest(); mockTests[1] = new MockTest(); } public MockTest[] getMockTests() { return mockTests; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/client/ 0000755 0001750 0001750 00000000000 11632407044 027312 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000160 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/client/ClientSerializationTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/client/ClientSerializationTe0000644 0001750 0001750 00000014743 10567670756 033535 0 ustar twerner twerner /* * 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.remoting.client; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * ClientSerializationTestCase verifies that org.jboss.remoting.Client can be * serialized. * * See JBREM-708: http://jira.jboss.org/jira/browse/JBREM-708 * * @author Ron Sigal * @version $Revision: 2225 $ ** Copyright Feb 23, 2007 *
*/ public class ClientSerializationTestCase extends TestCase { protected static Logger log = Logger.getLogger(ClientSerializationTestCase.class); protected static boolean firstTime = true; protected static final String TEST = "test"; protected static final String RETURN_CLIENT = "returnClient"; protected InvokerLocator locator; protected Connector connector; protected Client client; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.DEBUG); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.DEBUG); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() throws Exception { client.disconnect(); connector.stop(); } /** * Calling client.invoke(RETURN_CLIENT) will cause the invoker handler to return * a Client. This method uses java serialization. */ public void testJavaSerialization() throws Throwable { log.info("entering " + getName()); init("java"); assertEquals(TEST, client.invoke(TEST)); Object response = client.invoke(RETURN_CLIENT); assertTrue(response instanceof Client); log.info("received Client"); Client returnedClient = (Client) response; assertEquals(TEST, returnedClient.invoke(TEST)); log.info(getName() + " PASSES"); } /** * Calling client.invoke(RETURN_CLIENT) will cause the invoker handler to return * a Client. This method uses jboss serialization. */ public void testJBossSerialization() throws Throwable { log.info("entering " + getName()); init("jboss"); assertEquals(TEST, client.invoke(TEST)); Object response = client.invoke(RETURN_CLIENT); assertTrue(response instanceof Client); log.info("received Client"); Client returnedClient = (Client) response; assertEquals(TEST, returnedClient.invoke(TEST)); log.info(getName() + " PASSES"); } /** * Create a Connector and a Client. */ protected void init(String serializationType) throws Exception { String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?serializationtype=" + serializationType; log.info("server locator: " + locatorURI); locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); addServerConfig(serverConfig); connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addClientConfig(clientConfig); client = new Client(locator, clientConfig); client.connect(); } protected String getTransport() { return "socket"; } protected void addServerConfig(Map config) { } protected void addClientConfig(Map config) { } public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { String command = (String) invocation.getParameter(); if (TEST.equals(command)) { return command; } else if (RETURN_CLIENT.equals(command)) { HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, config); client.connect(); if (TEST.equals(client.invoke(TEST))) return client; else throw new Exception("unable to create working client"); } else { log.error("unrecognized command: " + command); throw new Exception("unrecognized command: " + command); } } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ 0000755 0001750 0001750 00000000000 11632407044 027511 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/DisconnectInvokerTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/DisconnectInvokerTes0000644 0001750 0001750 00000012067 10410561272 033542 0 ustar twerner twerner /* * 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.remoting.invoker; import junit.framework.TestCase; import org.jboss.remoting.*; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.logging.Logger; import javax.management.MBeanServer; /** * @author Tom Elrod */ public class DisconnectInvokerTestCase extends TestCase { // Constants ----------------------------------------------------- private static final Logger log = Logger.getLogger(DisconnectInvokerTestCase.class.getName()); // Static -------------------------------------------------------- // Attributes ---------------------------------------------------- // Constructors -------------------------------------------------- public DisconnectInvokerTestCase(String name) { super(name); } // TestCase overrides ------------------------------------------- public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } public void testInvokerThreadSafety() throws Exception { Connector serverConnector = new Connector(); InvokerLocator serverLocator = new InvokerLocator("socket://localhost:9099"); serverConnector.setInvokerLocator(serverLocator.getLocatorURI()); serverConnector.create(); SimpleServerInvocationHandler invocationHandler = new SimpleServerInvocationHandler(); serverConnector.addInvocationHandler("JMS", invocationHandler); serverConnector.start(); //Create n clients each firing requests in their own thread, using the same locator final int NUM_CLIENTS = 3; Thread[] threads = new Thread[NUM_CLIENTS]; Invoker[] invokers = new Invoker[NUM_CLIENTS]; Object obj = new Object(); for (int i = 0; i < NUM_CLIENTS; i++) { invokers[i] = new Invoker(serverLocator, obj); threads[i] = new Thread(invokers[i]); threads[i].start(); } synchronized (obj) { obj.wait(); } for (int i = 0; i < NUM_CLIENTS; i++) { if (invokers[i].failed) { fail(); for (int j = 0; j < NUM_CLIENTS; j++) { threads[j].interrupt(); } } } for (int i = 0; i < NUM_CLIENTS; i++) { threads[i].join(); } for (int i = 0; i < NUM_CLIENTS; i++) { if (invokers[i].failed) { fail(); } } } class Invoker implements Runnable { boolean failed; InvokerLocator locator; Object o; Invoker(InvokerLocator locator, Object o) { this.locator = locator; this.o = o; } public void run() { try { for (int i = 0; i < 10000; i++) { Client cl = new Client(locator); cl.connect(); cl.invoke("aardvark"); cl.disconnect(); } synchronized (o) { o.notify(); } } catch (Throwable t) { failed = true; log.error("Caught throwable", t); synchronized (o) { o.notify(); } } } } class SimpleServerInvocationHandler implements ServerInvocationHandler { InvokerCallbackHandler handler; public void addListener(InvokerCallbackHandler callbackHandler) { this.handler = callbackHandler; } public Object invoke(InvocationRequest invocation) throws Throwable { //log.info("Received invocation:" + invocation); return "Sausages"; } public void removeListener(InvokerCallbackHandler callbackHandler) { // FIXME removeListener } public void setInvoker(ServerInvoker invoker) { // FIXME setInvoker } public void setMBeanServer(MBeanServer server) { // FIXME setMBeanServer } } } ././@LongLink 0000000 0000000 0000000 00000000152 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/LocalInvokerTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/LocalInvokerTestCase0000644 0001750 0001750 00000032056 11004446567 033474 0 ustar twerner twerner /* * 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.remoting.invoker; import java.net.InetAddress; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.local.LocalClientInvoker; import javax.management.MBeanServer; /** * Provides a unit test to assure that when anorg.jboss.remoting.ServerInvoker
* is deleted from org.jboss.remoting.InvokerRegistry
's tables, any
* org.jboss.remoting.transport.local.LocalClientInvoker
that
* refers to it is also deleted. (See issue JBREM-153.)
*
* Also provides a unit test to assure that any LocalClientInvoker
still accessible
* after the purging of its ServerInvoker
is disconnected and, therefore, unusable.
*
* @author ron sigal - mailto:r.sigal@computer.org
*/
public class LocalInvokerTestCase extends TestCase
{
private static final Logger log = Logger.getLogger(LocalInvokerTestCase.class);
private static final int MAX_TRIES = 10;
/**
* Tests that a newly created org.jboss.remoting.Client
* does not get an expired org.jboss.remoting.transport.local.LocalClientInvoker
from
* org.jboss.remoting.InvokerRegistry
.
*
* It does the following steps:
*
* org.jboss.remoting.transport.Connector
for socket://127.0.0.1:9090;
* org.jboss.remoting.ServerInvocationHandler
that holds secret value 3;
* org.jboss.remoting.Client
for socket://127.0.0.1:9090;
* org.jboss.remoting.InvokerRegistry
created an
* org.jboss.remoting.transport.local.LocalClientInvoker
on behalf of the Client
;
* ServerInvocationHandler
;
* Connector
;
* Connector
for socket://127.0.0.1:9090;
* Client
for socket://127.0.0.1:9090;
* org.jboss.remoting.InvokerRegistry
created a
* LocalClientInvoker
on behalf of the new Client
;
* ServerInvocationHandler
and verifies that it is 7.
* LocalClientInvoker
, which would have
* invoked the old ServerInvocationHandler
, is no longer accessible and must have been disposed of
* by InvokerRegistry
.
*
* Note. A call to Client.stop()
before the creation of the second Client
* woud assure the purging of the old LocalClientInvoker
. The call is omitted in this test to
* assure that the purging of the old LocalClientInvoker
happens automatically.
*/
public void testLocalInvokerTwoClients()
{
InvokerLocator invokerLocator = null;
try
{
String host = InetAddress.getLocalHost().getHostAddress();
int port = PortUtil.findFreePort(host);
invokerLocator = new InvokerLocator("socket://" + host + ":" + port);
Integer secret = new Integer(3);
runTestForTwoClients(invokerLocator, secret);
secret = new Integer(7);
Integer newSecret = runTestForTwoClients(invokerLocator, secret);
log.debug("newSecret = " + newSecret);
assertTrue(secret.equals(newSecret));
}
catch(Throwable t)
{
log.debug(t);
t.printStackTrace();
fail();
}
}
/**
* Tests that when an org.jboss.remoting.Client
* with an expired org.jboss.remoting.transport.local.LocalClientInvoker
executes
* invoke()
, it gets a new LocalClientInvoker
instead of using the old one.
*
* It does the following steps:
*
* org.jboss.remoting.transport.Connector
for socket://127.0.0.1:9090;
* org.jboss.remoting.ServerInvocationHandler
that holds secret value 3;
* org.jboss.remoting.Client
for socket://127.0.0.1:9090;
* org.jboss.remoting.InvokerRegistry
created an
* org.jboss.remoting.transport.local.LocalClientInvoker
on behalf of the Client
;
* ServerInvocationHandler
;
* Connector
* Connector
for socket://127.0.0.1:9090;
* ServerInvocationHandler
and verifies that it is 7.
* LocalClientInvoker
, which would have
* invoked the old ServerInvocationHandler
, must have been replaced with a new one.
*/
public void testLocalInvokerOneClient()
{
InvokerLocator invokerLocator = null;
Connector connector = null;
Client client = null;
try
{
String host = InetAddress.getLocalHost().getHostAddress();
int port = PortUtil.findFreePort(host);
invokerLocator = new InvokerLocator("socket://" + host + ":" + port);
Integer secret = new Integer(3);
connector = makeConnector(invokerLocator, secret);
client = new Client(invokerLocator);
client.connect();
// verify that InvokerRegistry has created a LocalClientInvoker for client
assertTrue(client.getInvoker() instanceof LocalClientInvoker);
Integer newSecret = (Integer) client.invoke(null);
connector.stop();
secret = new Integer(7);
connector = makeConnector(invokerLocator, secret);
newSecret = (Integer) client.invoke(null);
log.debug("newSecret = " + newSecret);
assertTrue(secret.equals(newSecret));
connector.stop();
try
{
client.invoke(null);
assertTrue("Should have thrown ServerInvoker.InvalidStateException.", false);
}
catch (ServerInvoker.InvalidStateException invalidStateEx)
{
assertTrue(true);
}
}
catch(Throwable t)
{
log.debug(t);
t.printStackTrace();
fail();
}
finally
{
if (client != null) client.disconnect();
if (connector != null) connector.stop();
}
}
/**
* Subroutine for testLocalInvokerTwoClients()
.
*
* Does the following:
*
* Connector
according to parameter invokerLocator
* ServerInvocationHandler
that holds secret value given by parameter secret
;
* org.jboss.remoting.Client
according to parameter invokerLocator
* InvokerRegistry
created a
* LocalClientInvoker
on behalf of the Client
* ServerInvocationHandler
* Connector
* Client
and Connector
* @param secret secret value for ServerInvocationHandler
* @return secret value retrieved from ServerInvocationHandler
*/
protected Integer runTestForTwoClients(InvokerLocator invokerLocator, Integer secret)
{
Connector connector = null;
Client client = null;
Integer newSecret = null;
try
{
connector = makeConnector(invokerLocator, secret);
client = new Client(invokerLocator);
client.connect();
// verify that InvokerRegistry has created a LocalClientInvoker for client
assertTrue(client.getInvoker() instanceof LocalClientInvoker);
newSecret = (Integer) client.invoke(null);
}
catch(Throwable t)
{
log.debug(t);
t.printStackTrace();
fail();
}
finally
{
connector.stop();
}
return newSecret;
}
/**
* Sets up a Connector
with a specified ServerInvocationHandler
.
*
* Does the following:
*
* Connector
according to parameter invokerLocator
* ServerInvocationHandler
that holds secret value given by parameter secret
.
* InvokerLocator
used by Connector
* @param secret value to be held by ServerInvocationHandler
* @return newly created Connector
*/
protected Connector makeConnector(InvokerLocator invokerLocator, Integer secret)
{
Connector connector = null;
try
{
connector = new Connector();
connector.setInvokerLocator(invokerLocator.getLocatorURI());
for(int i = 0; i < MAX_TRIES; i++)
{
try
{
connector.start();
break;
}
catch(Exception e)
{
log.info("error - will try again: " + e.getMessage());
Thread.sleep(60000);
}
}
SampleInvocationHandler invocationHandler = new SampleInvocationHandler(secret);
connector.addInvocationHandler("xmlrmi", invocationHandler);
}
catch(Throwable t)
{
log.debug(t);
t.printStackTrace();
fail();
}
return connector;
}
/**
* Simple invocation handler implementation.
*
* invoke()
simply returns its secret value.
*/
public class SampleInvocationHandler implements ServerInvocationHandler
{
private Object secret;
public SampleInvocationHandler(Object secret)
{
this.secret = secret;
}
/**
* called to handle a specific invocation
*
* @param invocation
* @return
* @throws Throwable
*/
public Object invoke(InvocationRequest invocation) throws Throwable
{
log.debug("SampleInvocationHandler.invoke(): " + this.hashCode());
return secret;
}
/**
* Adds a callback handler that will listen for callbacks from
* the server invoker handler.
*
* @param callbackHandler
*/
public void addListener(InvokerCallbackHandler callbackHandler)
{
// NO OP as do not handling callback listeners in this example
}
/**
* Removes the callback handler that was listening for callbacks
* from the server invoker handler.
*
* @param callbackHandler
*/
public void removeListener(InvokerCallbackHandler callbackHandler)
{
// NO OP as do not handling callback listeners in this example
}
/**
* set the mbean server that the handler can reference
*
* @param server
*/
public void setMBeanServer(MBeanServer server)
{
// NO OP as do not need reference to MBeanServer for this handler
}
/**
* set the invoker that owns this handler
*
* @param invoker
*/
public void setInvoker(ServerInvoker invoker)
{
// NO OP as do not need reference back to the server invoker
}
}
} ././@LongLink 0000000 0000000 0000000 00000000165 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDisconnectTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDisconn0000644 0001750 0001750 00000010643 10744605201 033530 0 ustar twerner twerner /*
* 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.remoting.invoker;
import java.net.InetAddress;
import junit.framework.TestCase;
import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.InvokerRegistry;
import org.jboss.remoting.RemoteClientInvoker;
import org.jboss.remoting.transport.ClientInvoker;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
import org.jboss.remoting.transport.local.LocalClientInvoker;
/**
* @author Ovidiu Feodorov
* @version $Revision: 3347 $
*
* $Id: ClientInvokerDisconnectTestCase.java 3347 2008-01-20 08:46:57Z ron.sigal@jboss.com $
*/
public class ClientInvokerDisconnectTestCase extends TestCase
{
// Constants -----------------------------------------------------
private static final Logger log = Logger.getLogger(ClientInvokerDisconnectTestCase.class);
// Static --------------------------------------------------------
// Attributes ----------------------------------------------------
private String serverURI;
private Connector server;
// Constructors --------------------------------------------------
public ClientInvokerDisconnectTestCase(String name)
{
super(name);
}
// Public --------------------------------------------------------
public void setUp() throws Exception
{
super.setUp();
String host = InetAddress.getLocalHost().getCanonicalHostName();
int port = PortUtil.findFreePort(host);
serverURI = "socket://" + host + ":" + port + "/";
server = new Connector();
server.setInvokerLocator(serverURI);
server.start();
log.info("Server " + serverURI + " started");
}
public void tearDown() throws Exception
{
server.stop();
server = null;
log.info("Server " + serverURI + " stopped");
super.tearDown();
}
public void testLocalClientInvokerDisconnect() throws Throwable
{
Client client = new Client(new InvokerLocator(serverURI));
client.connect();
ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers();
assertEquals(1, clientInvokers.length);
LocalClientInvoker clientInvoker = (LocalClientInvoker) clientInvokers[0];
assertEquals(serverURI, clientInvoker.getLocator().getLocatorURI());
client.disconnect();
clientInvokers = InvokerRegistry.getClientInvokers();
assertEquals(0, clientInvokers.length);
}
public void testRemoteClientInvokerDisconnect() throws Throwable
{
String passByValueServerURI = serverURI + "?byvalue=true";
Client client = new Client(new InvokerLocator(passByValueServerURI));
client.connect();
ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers();
assertEquals(1, clientInvokers.length);
RemoteClientInvoker clientInvoker = (RemoteClientInvoker) clientInvokers[0];
assertEquals(passByValueServerURI, clientInvoker.getLocator().getLocatorURI());
client.disconnect();
clientInvokers = InvokerRegistry.getClientInvokers();
assertEquals(0, clientInvokers.length);
}
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
}
././@LongLink 0000000 0000000 0000000 00000000175 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayed0000644 0001750 0001750 00000033662 11413660476 033521 0 ustar twerner twerner /*
* 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.remoting.invoker;
import java.lang.reflect.Field;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import javax.management.MBeanServer;
import junit.framework.TestCase;
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.InvokerRegistry;
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.transport.ClientInvoker;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
/**
* Unit tests from JBREM-877.
* Adjusted for JBREM-1176.
*
* @author Ron Sigal
* @version $Revision: 1.1 $
* * Copyright Feb 22, 2008 *
*/ public class ClientInvokerDelayedDestructionTestCase extends TestCase { private static Logger log = Logger.getLogger(ClientInvokerDelayedDestructionTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testNoDelayedDestruction() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker1 = client.getInvoker(); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good for first client"); client.disconnect(); client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker2 = client.getInvoker(); assertEquals("abc", client.invoke("abc")); log.info("connection is good for second client"); assertNotSame(invoker2, invoker1); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testZeroDelay() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.INVOKER_DESTRUCTION_DELAY, "0"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker1 = client.getInvoker(); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good for first client"); client.disconnect(); client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker2 = client.getInvoker(); assertEquals("abc", client.invoke("abc")); log.info("connection is good for second client"); assertNotSame(invoker2, invoker1); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testDelayThenGetNewInvoker() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.INVOKER_DESTRUCTION_DELAY, "5000"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker1 = client.getInvoker(); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good for first client"); client.disconnect(); Thread.sleep(10000); client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker2 = client.getInvoker(); assertEquals("abc", client.invoke("abc")); log.info("connection is good for second client"); assertNotSame(invoker2, invoker1); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testDelayThenReuseInvoker() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.INVOKER_DESTRUCTION_DELAY, "10000"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker1 = client.getInvoker(); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good for first client"); client.disconnect(); Thread.sleep(5000); client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker2 = client.getInvoker(); assertEquals("abc", client.invoke("abc")); log.info("connection is good for second client"); assertSame(invoker2, invoker1); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testEventualDestruction() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.INVOKER_DESTRUCTION_DELAY, "5000"); addExtraClientConfig(clientConfig); for (int i = 0; i < 50; i++) { Client client = new Client(clientLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); client.disconnect(); } Thread.sleep(10000); assertEquals(0, InvokerRegistry.getClientInvokers().length); shutdownServer(); log.info(getName() + " PASSES"); } public void testStaticTimer() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Verify Timer hasn't been created. Field field = Client.class.getDeclaredField("invokerDestructionTimer"); field.setAccessible(true); Timer invokerDestructionTimer = (Timer) field.get(null); assertNull(invokerDestructionTimer); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.INVOKER_DESTRUCTION_DELAY, "5000"); addExtraClientConfig(clientConfig); Client[] clients = new Client[50]; for (int i = 0; i < 50; i++) { clients[i] = new Client(clientLocator, clientConfig); clients[i].connect(); assertEquals("abc", clients[i].invoke("abc")); clients[i].disconnect(); } // Verify Timer has been created. invokerDestructionTimer = (Timer) field.get(null); assertNotNull(invokerDestructionTimer); // Verify all Clients are using the same Timer. for (int i = 0; i < 50; i++) { assertEquals("Should be the same Timer", invokerDestructionTimer, field.get(clients[i])); } Thread.sleep(10000); assertEquals(0, InvokerRegistry.getClientInvokers().length); // Verify Timer has been destroyed. invokerDestructionTimer = (Timer) field.get(null); assertNull(invokerDestructionTimer); // Recreate Clients to verify that a new Timer is created. for (int i = 0; i < 50; i++) { clients[i] = new Client(clientLocator, clientConfig); clients[i].connect(); assertEquals("abc", clients[i].invoke("abc")); clients[i].disconnect(); } // Verify Timer has been created. invokerDestructionTimer = (Timer) field.get(null); assertNotNull(invokerDestructionTimer); // Verify all Clients are using the same Timer. for (int i = 0; i < 50; i++) { assertEquals("Should be the same Timer", invokerDestructionTimer, field.get(clients[i])); } Thread.sleep(10000); assertEquals(0, InvokerRegistry.getClientInvokers().length); // Verify Timer has been destroyed. invokerDestructionTimer = (Timer) field.get(null); assertNull(invokerDestructionTimer); shutdownServer(); log.info(getName() + " PASSES"); } public void testConfigByInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "/?invokerDestructionDelay=10000"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker1 = client.getInvoker(); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good for first client"); client.disconnect(); Thread.sleep(5000); client = new Client(clientLocator, clientConfig); client.connect(); ClientInvoker invoker2 = client.getInvoker(); assertEquals("abc", client.invoke("abc")); log.info("connection is good for second client"); assertSame(invoker2, invoker1); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); } } } ././@LongLink 0000000 0000000 0000000 00000000154 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/InvokerDestructionTest.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/InvokerDestructionTe0000644 0001750 0001750 00000012140 11413660476 033573 0 ustar twerner twerner package org.jboss.test.remoting.invoker; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Demonstrates the cost of recreating a client invoker with each invocation. * See JBREM-877. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Feb 23, 2008 *
*/ public class InvokerDestructionTest extends TestCase { private static Logger log = Logger.getLogger(InvokerDestructionTest.class); private static boolean firstTime = true; protected static String metadata; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); metadata = System.getProperty("remoting.metadata", "serializationtype=java"); } } public void tearDown() { } public void testNoDelay() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(0); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); long l1 = doTest(clientLocator, clientConfig, 10000); log.info("delay 0: " + l1); shutdownServer(); log.info(getName() + " PASSES"); } public void testDelay() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(5000); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); long l1 = doTest(clientLocator, clientConfig, 10000); log.info("delay 5000: " + l1); shutdownServer(); log.info(getName() + " PASSES"); } protected long doTest(InvokerLocator locator, Map config, int count) throws Throwable { long start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { Client client = new Client(locator, config); client.connect(); client.invoke("abc"); client.disconnect(); } return System.currentTimeMillis() - start; } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(int delay) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?" + Client.INVOKER_DESTRUCTION_DELAY + "=" + delay; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/binding/ 0000755 0001750 0001750 00000000000 11632407044 027446 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000145 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/binding/BindingTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/binding/BindingTestCase.java0000644 0001750 0001750 00000027452 11005535325 033327 0 ustar twerner twerner /* * JBoss, a division of Red Hat * Copyright 2006, Red Hat Middleware, LLC, 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.remoting.binding; import java.io.ByteArrayInputStream; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.ServerSocket; import java.util.List; import javax.management.MBeanServer; import javax.xml.parsers.DocumentBuilderFactory; import junit.framework.TestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * BindingTestCase verifies that the case in which the InvokerLocator host is * 0.0.0.0 is handled correctly. * * @author Tom Elrod */ public class BindingTestCase extends TestCase { /** * Verifies correct behavior for InvokerLocator host == 0.0.0.0, where * InvokerLocator is reconstructed with host as localhost name. */ public void testBindingWithLocatorByName() throws Exception { System.setProperty(InvokerLocator.BIND_BY_HOST, "true"); int bindPort = PortUtil.findFreePort("0.0.0.0"); String locatorUrl = "socket://0.0.0.0:" + bindPort; Connector connector = new Connector(locatorUrl); connector.create(); connector.start(); // Verify that the InvokerLocator host is set properly. String connectorLocatorUrl = connector.getInvokerLocator(); System.out.println("connector locator = " + connectorLocatorUrl); String hostName = InetAddress.getLocalHost().getHostName(); assertFalse(-1 == connectorLocatorUrl.indexOf(hostName)); // Verify that the ServerSocket is bound to address 0.0.0.0. ServerInvoker si = connector.getServerInvoker(); assertTrue(si instanceof SocketServerInvoker); SocketServerInvoker ssi = (SocketServerInvoker) si; Field field = SocketServerInvoker.class.getDeclaredField("serverSockets"); field.setAccessible(true); List serverSockets = (List) field.get(ssi); ServerSocket ss = (ServerSocket) serverSockets.get(0); assertNotNull(ss); System.out.println("ServerSocket bind address: " + ss.getInetAddress()); InetAddress inetAddress = ss.getInetAddress(); assertNotNull(inetAddress); assertEquals("0.0.0.0", inetAddress.getHostAddress()); connector.stop(); connector.destroy(); // Make sure ServerInvoker was destroyed, which implies it was reregistered // under correct InvokerLocator. assertEquals(0, InvokerRegistry.getServerInvokers().length); } /** * Verifies correct behavior for InvokerLocator host == 0.0.0.0, where * InvokerLocator is reconstructed with host as localhost address. */ public void testBindingWithLocatorByAddress() throws Exception { System.setProperty(InvokerLocator.BIND_BY_HOST, "false"); int bindPort = PortUtil.findFreePort("0.0.0.0"); String locatorUrl = "socket://0.0.0.0:" + bindPort; Connector connector = new Connector(locatorUrl); connector.create(); connector.start(); // Verify that the InvokerLocator host is set properly. String connectorLocatorUrl = connector.getInvokerLocator(); System.out.println("connector locator = " + connectorLocatorUrl); String hostName = InetAddress.getLocalHost().getHostAddress(); assertFalse(-1 == connectorLocatorUrl.indexOf(hostName)); // Verify that the ServerSocket is bound to address 0.0.0.0. ServerInvoker si = connector.getServerInvoker(); assertTrue(si instanceof SocketServerInvoker); SocketServerInvoker ssi = (SocketServerInvoker) si; Field field = SocketServerInvoker.class.getDeclaredField("serverSockets"); field.setAccessible(true); List serverSockets = (List) field.get(ssi); ServerSocket ss = (ServerSocket) serverSockets.get(0); assertNotNull(ss); System.out.println("ServerSocket bind address: " + ss.getInetAddress()); InetAddress inetAddress = ss.getInetAddress(); assertNotNull(inetAddress); assertEquals("0.0.0.0", inetAddress.getHostAddress()); connector.stop(); connector.destroy(); // Make sure ServerInvoker was destroyed, which implies it was reregistered // under correct InvokerLocator. assertEquals(0, InvokerRegistry.getServerInvokers().length); } /** * Verifies correct behavior for XML document with host == 0.0.0.0, where * InvokerLocator is reconstructed with host as localhost name. */ public void testBindingsWithXMLConfigByname() throws Exception { System.setProperty(InvokerLocator.BIND_BY_HOST, "true"); int bindPort = PortUtil.findFreePort("0.0.0.0"); String xml = new StringBuffer() .append("* Copyright Mar 6, 2008 *
*/ public class RMIConfigurableVersionTestCase extends ConfigurableVersionTestParent { protected String getTransport() { return "rmi"; } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/BisocketConfigurableVersionTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/BisocketConfigurable0000644 0001750 0001750 00000002523 11413660476 033541 0 ustar twerner twerner /* * 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.remoting.version; /** * Unit test for JBREM-764. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Mar 6, 2008 *
*/ public class BisocketConfigurableVersionTestCase extends ConfigurableVersionTestParent { protected String getTransport() { return "bisocket"; } } ././@LongLink 0000000 0000000 0000000 00000000165 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/HttpConfigurableVersionTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/HttpConfigurableVers0000644 0001750 0001750 00000002513 11413660476 033554 0 ustar twerner twerner /* * 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.remoting.version; /** * Unit test for JBREM-764. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Mar 6, 2008 *
*/ public class HttpConfigurableVersionTestCase extends ConfigurableVersionTestParent { protected String getTransport() { return "http"; } } ././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/SocketConfigurableVersionTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/SocketConfigurableVe0000644 0001750 0001750 00000002517 11413660476 033524 0 ustar twerner twerner /* * 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.remoting.version; /** * Unit test for JBREM-764. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Mar 6, 2008 *
*/ public class SocketConfigurableVersionTestCase extends ConfigurableVersionTestParent { protected String getTransport() { return "socket"; } } ././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/ConfigurableVersionTestParent.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/ConfigurableVersionT0000644 0001750 0001750 00000014142 11413660476 033547 0 ustar twerner twerner /* * 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.remoting.version; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.Version; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-764. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Mar 6, 2008 *
*/ public abstract class ConfigurableVersionTestParent extends TestCase { private static Logger log = Logger.getLogger(ConfigurableVersionTestParent.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testVersions() throws Throwable { log.info("entering " + getName()); // Start servers. Connector connector1 = setupServer(Version.VERSION_1); Connector connector2 = setupServer(Version.VERSION_2); Connector connector22 = setupServer(Version.VERSION_2_2); Connector connector0 = setupServer(-1); // Create clients. Client client1 = setupClient(connector1); Client client2 = setupClient(connector2); Client client22 = setupClient(connector22); Client client0 = setupClient(connector0); // Test connections. assertEquals("abc", client1.invoke("abc")); assertEquals("abc", client2.invoke("abc")); assertEquals("abc", client22.invoke("abc")); assertEquals("abc", client0.invoke("abc")); client1.disconnect(); client2.disconnect(); client22.disconnect(); client0.disconnect(); connector1.stop(); connector2.stop(); connector22.stop(); connector0.stop(); log.info(getName() + " PASSES"); } abstract protected String getTransport(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected Connector setupServer(int version) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port + "/?"; if (version > 0) { locatorURI += Remoting.REMOTING_VERSION + "=" + version; } else { locatorURI += "x=y"; } String parameters = System.getProperty("remoting.metadata"); if (parameters != null) { locatorURI += "&" + parameters; } serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); return connector; } protected Client setupClient(Connector connector) throws Exception { InvokerLocator locator = connector.getLocator(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(locator, config); client.connect(); log.info("client is connected to: " + locator); return client; } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/ 0000755 0001750 0001750 00000000000 11632407043 027335 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011561 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerServer.j0000644 0001750 0001750 00000007243 10506110050 033471 0 ustar twerner twerner /* * 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.remoting.oneway; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * @author Tom Elrod * @version $Revision: 1467 $ */ public class OnewayInvokerServer extends ServerTestCase //implements ShutdownListener { private int serverPort = 8081; private Connector connector = null; private String transport = "socket"; private static final Logger log = Logger.getLogger(OnewayInvokerServer.class); public void init(Map metatdata) throws Exception { if(serverPort < 0) { serverPort = TestUtil.getRandomPort(); } log.debug("port = " + serverPort); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } private String buildLocatorURI(Map metadata) { if(metadata == null || metadata.size() == 0) { return transport + "://localhost:" + serverPort; } else { StringBuffer uriBuffer = new StringBuffer(transport + "://localhost:" + serverPort); Set keys = metadata.keySet(); if(keys.size() > 0) { uriBuffer.append("/?"); } Iterator itr = keys.iterator(); while(itr.hasNext()) { String key = (String) itr.next(); String value = (String) metadata.get(key); uriBuffer.append(key + "=" + value + "&"); } return uriBuffer.substring(0, uriBuffer.length() - 1); } } protected ServerInvocationHandler getServerInvocationHandler() { return new OnewayServerInvocationHandler(); } protected String getSubsystem() { return "test"; } public void setUp() throws Exception { init(null); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { OnewayInvokerServer server = new OnewayInvokerServer(); try { server.setUp(); Thread.currentThread().sleep(4000000); server.tearDown(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayThreadPoolTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayThreadPoolTestC0000644 0001750 0001750 00000070530 11015170526 033452 0 ustar twerner twerner /* * 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.remoting.oneway; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.util.threadpool.BasicThreadPool; /** * This test verifies that the default thread pool used by * org.jboss.remoting.Client and org.jboss.remoting.ServerInvoker * to do asynchronous method invocations can function properly under * heavy loads. * * See JBREM-658. * * @author Ron Sigal * @version $Revision: 4221 $ ** Copyright Feb 6, 2007 *
*/ public class OnewayThreadPoolTestCase extends TestCase { protected static String FAST = "fast"; protected static String SLOW = "slow"; protected static Logger log = Logger.getLogger(OnewayThreadPoolTestCase.class); protected static boolean firstTime = true; protected static boolean go; protected static Object lock = new Object(); protected static int poolCounter; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } /** * This test verifies that thread and queue size are correctly set * on the server side and client side. */ public void testConfiguration() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "socket://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(ServerInvoker.MAX_NUM_ONEWAY_THREADS_KEY, "3"); serverConfig.put(ServerInvoker.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "5"); Connector connector = new Connector(locator, serverConfig); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.MAX_NUM_ONEWAY_THREADS, "7"); clientConfig.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "9"); Client client = new Client(locator, clientConfig); client.connect(); client.invokeOneway(FAST, null, true); client.invokeOneway(FAST, null, false); poolCounter += 2; Thread.sleep(1000); assertEquals(2, handler.startedCount); Field field = ServerInvoker.class.getDeclaredField("onewayThreadPool"); field.setAccessible(true); BasicThreadPool pool = (BasicThreadPool) field.get(connector.getServerInvoker()); assertEquals(3, pool.getMaximumPoolSize()); assertEquals(5, pool.getMaximumQueueSize()); field = Client.class.getDeclaredField("onewayThreadPool"); field.setAccessible(true); pool = (BasicThreadPool) field.get(client); assertEquals(7, pool.getMaximumPoolSize()); assertEquals(9, pool.getMaximumQueueSize()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * This test exercises the client side thread pool using the http transport. * The http client invoker does not return until after the invocation has * returned a response. */ public void testThreadPoolHttpClientSide() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "http://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Client.MAX_NUM_ONEWAY_THREADS, "2"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); Client client = new Client(locator, config); client.connect(); Object response = client.invoke(FAST); assertEquals(FAST, response); long start = System.currentTimeMillis(); // This invocation should run in pooled thread 1. log.info("making 1st oneway invocation"); client.invokeOneway(SLOW + "1", null, true); poolCounter++; // This invocation should run in pooled thread 2. log.info("making 2nd oneway invocation"); client.invokeOneway(SLOW + "2", null, true); // This invocation should go into the queue. log.info("making 3rd oneway invocation"); client.invokeOneway(SLOW + "3", null, true); assertTrue((System.currentTimeMillis() - start < 1000)); Thread.sleep(2000); log.info("handler.count: " + handler.startedCount); assertEquals(3, handler.startedCount); // This invocation should run in the current thread, and will not return // until after a response is received. start = System.currentTimeMillis(); log.info("making 4th oneway invocation"); client.invokeOneway(SLOW + "4", null, true); log.info("made 4th oneway invocation"); log.info("wait: " + (System.currentTimeMillis() - start)); assertTrue((System.currentTimeMillis() - start >= 5000)); Thread.sleep(12000); assertEquals(5, handler.startedCount); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * This test exercises the client side thread pool using the socket transport * The socket client invoker waits for a response. See JBREM-706. */ public void testThreadPoolSocketClientSide() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "socket://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Client.MAX_NUM_ONEWAY_THREADS, "2"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); Client client = new Client(locator, config); client.connect(); Object response = client.invoke(FAST); assertEquals(FAST, response); long start = System.currentTimeMillis(); // NOTE. The following commented code precedes the fix to JBREM-706. The four // slow invocations were expected to take up to 16 seconds to start. // // The following four invocations are quite nondeterministic. In the best // // case, two will execute in the thread pool and two will execute simultaneously // // in ServerThreads. In the worst case, the last three invocations will // // find a pooled connection and connect to a ServerThread busy with the // // previous invocation. // // // Will execute in first thread pool thread. // log.info("making 1st oneway invocation"); // client.invokeOneway(SLOW + "1", null, true); // poolCounter++; // // // Will execute in first or second thread pool thread. // log.info("making 2nd oneway invocation"); // client.invokeOneway(SLOW + "2", null, true); // // // Could execute in a thread pool thread or go on the queue. // log.info("making 3rd oneway invocation"); // client.invokeOneway(SLOW + "3", null, true); // assertTrue((System.currentTimeMillis() - start < 1000)); // // // Could execute in a thread pool thread, go on the queue, or execute // // in the main thread. // log.info("making 4th oneway invocation"); // client.invokeOneway(SLOW + "4", null, true); // log.info("made 4th oneway invocation"); // log.info("wait: " + (System.currentTimeMillis() - start)); // assertTrue((System.currentTimeMillis() - start < 1000)); // // // In the worst case, the four invocations could take as much as 15 seconds // // to all start. // Thread.sleep(16000); // assertEquals(5, handler.startedCount); // The following code replaces the commented code just above. After the fix // to JBREM-706, all four slow invocations should start within just over two // seconds. // Will execute in first thread pool thread. log.info("making 1st oneway invocation"); client.invokeOneway(SLOW + "1", null, true); poolCounter++; // Will execute in second thread pool thread. log.info("making 2nd oneway invocation"); client.invokeOneway(SLOW + "2", null, true); // Will go on the queue. The attempt to read the response to the first // invocation will fail after two seconds, and the first thread will be // available to execute this invocation. log.info("making 3rd oneway invocation"); client.invokeOneway(SLOW + "3", null, true); assertTrue((System.currentTimeMillis() - start < 1000)); Thread.sleep(500); // At this point, slow invocations 1 and 2 should have started. assertEquals(3, handler.startedCount); // Will execute on the main thread. The call to client.invokeOneway() will // time out and return after two seconds. log.info("making 4th oneway invocation"); client.invokeOneway(SLOW + "4", null, true); log.info("made 4th oneway invocation"); log.info("wait: " + (System.currentTimeMillis() - start)); assertTrue((System.currentTimeMillis() - start < 3000)); // Give slow invocation 3 time to start. Thread.sleep(500); // At this point, all invocations should have started. assertEquals(5, handler.startedCount); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * This test verifies that the client side thread pool can function under * a heavy load. It uses the http transport. */ public void testHeavyLoadClientSideHttp() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "http://" + host + ":" + port; locatorURI += "/?maxProcessors=400"; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Client.MAX_NUM_ONEWAY_THREADS, "100"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "100"); Client client = new Client(locator, config); client.connect(); int INVOCATIONS = 400; OnewayThread[] threads = new OnewayThread[INVOCATIONS]; for (int i = 0; i < INVOCATIONS; i++) { threads[i] = new OnewayThread(client, i, true); threads[i].start(); } synchronized (lock) { go = true; lock.notifyAll(); } poolCounter++; Thread.sleep(15000); // Verify INVOCATIONS invocations were received. assertEquals(INVOCATIONS, handler.startedCount); // Verify only one thread pool was created. Field field = Client.class.getDeclaredField("onewayThreadPool"); field.setAccessible(true); Object pool = field.get(client); assertTrue(pool instanceof BasicThreadPool); BasicThreadPool basicThreadPool = (BasicThreadPool) pool; assertEquals(poolCounter, basicThreadPool.getPoolNumber()); for (int i = 0; i < INVOCATIONS; i++) { assertTrue("failure in thread: " + i, threads[i].ok); } client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * This test verifies that the client side thread pool can function under * a heavy load. It uses the socket transport. */ public void testHeavyLoadClientSideSocket() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "socket://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Client.MAX_NUM_ONEWAY_THREADS, "100"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "100"); Client client = new Client(locator, config); client.connect(); int INVOCATIONS = 1000; OnewayThread[] threads = new OnewayThread[INVOCATIONS]; for (int i = 0; i < INVOCATIONS; i++) { threads[i] = new OnewayThread(client, i, true); threads[i].start(); } synchronized (lock) { go = true; lock.notifyAll(); } poolCounter++; Thread.sleep(5000); // Verify INVOCATIONS invocations were received. assertEquals(INVOCATIONS, handler.startedCount); // Verify only one thread pool was created. Field field = Client.class.getDeclaredField("onewayThreadPool"); field.setAccessible(true); Object pool = field.get(client); assertTrue(pool instanceof BasicThreadPool); BasicThreadPool basicThreadPool = (BasicThreadPool) pool; assertEquals(poolCounter, basicThreadPool.getPoolNumber()); for (int i = 0; i < INVOCATIONS; i++) { assertTrue("failure in thread: " + i, threads[i].ok); } client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * This test exercises the server side thread pool using the http transport */ public void testThreadPoolHttpServerSide() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "http://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(ServerInvoker.MAX_NUM_ONEWAY_THREADS_KEY, "2"); serverConfig.put(ServerInvoker.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); Connector connector = new Connector(locator, serverConfig); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, clientConfig); client.connect(); Object response = client.invoke(FAST); assertEquals(FAST, response); long start = System.currentTimeMillis(); // This invocation should run in pooled thread 1. log.info("making 1st oneway invocation"); client.invokeOneway(SLOW + "1", null, false); poolCounter++; // Wait for connection to return to pool. Thread.sleep(500); // This invocation should run in pooled thread 2. log.info("making 2nd oneway invocation"); client.invokeOneway(SLOW + "2", null, false); // Wait for connection to return to pool. Thread.sleep(500); // This invocation should use the pooled connection and go into the queue. log.info("making 3rd oneway invocation"); client.invokeOneway(SLOW + "3", null, false); assertTrue((System.currentTimeMillis() - start < 2000)); Thread.sleep(2000); log.info("handler.count: " + handler.startedCount); assertEquals(3, handler.startedCount); // This invocation should run in the ServerThread, and will not return // until after a response is received. log.info("making 4th oneway invocation"); client.invokeOneway(SLOW + "4", null, false); log.info("made 4th oneway invocation"); log.info("wait: " + (System.currentTimeMillis() - start)); assertTrue((System.currentTimeMillis() - start >= 8000)); // By the time the 4th oneway invocation returns, the 3rd oneway invocation // should have started. assertEquals(5, handler.startedCount); assertEquals(4, handler.finishedCount); Thread.sleep(3000); assertEquals(5, handler.finishedCount); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * This test exercises the server side thread pool using the socket transport */ public void testThreadPoolSocketServerSide() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "socket://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(ServerInvoker.MAX_NUM_ONEWAY_THREADS_KEY, "2"); serverConfig.put(ServerInvoker.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); Connector connector = new Connector(locator, serverConfig); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, clientConfig); client.connect(); Object response = client.invoke(FAST); assertEquals(FAST, response); long start = System.currentTimeMillis(); // This invocation should run in pooled thread 1. log.info("making 1st oneway invocation"); client.invokeOneway(SLOW + "1", null, false); poolCounter++; // Wait for the connection to return to the pool. Thread.sleep(500); // This invocation should run in pooled thread 2. log.info("making 2nd oneway invocation"); client.invokeOneway(SLOW + "2", null, false); // Wait for the connection to return to the pool. Thread.sleep(500); // This invocation should use the pooled connection and go into the queue. log.info("making 3rd oneway invocation"); client.invokeOneway(SLOW + "3", null, false); // Wait for the connection to return to the pool. Thread.sleep(500); // This invocation should use the pooled connection and get run by the // ServerThread. The connection should go back into the pool but the // ServerThread will be busy for the next 5 seconds. log.info("making 4th oneway invocation"); client.invokeOneway(SLOW + "4", null, false); // Wait for the connection to return to the pool. Thread.sleep(500); // This invocation should use the pooled connection and have to wait // for 5 seconds. log.info("making 5th oneway invocation"); client.invokeOneway(SLOW + "5", null, false); assertTrue((System.currentTimeMillis() - start < 3000)); assertEquals(4, handler.startedCount); // It's necessary to wait for more than 5000 ms here because one or two // of the invocations might go out over preexisting pooled connections // and have to wait for the handler to finish the previous invocation. Thread.sleep(6000); assertEquals(6, handler.startedCount); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * This test verifies that the server side thread pool can function under * a heavy load. It uses the http transport. */ public void testHeavyLoadServerSideHttp() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "http://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(ServerInvoker.MAX_NUM_ONEWAY_THREADS_KEY, "100"); serverConfig.put(ServerInvoker.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "100"); Connector connector = new Connector(locator); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, clientConfig); client.connect(); // CoyoteInvoker defaults to 200 threads. int INVOCATIONS = 300; OnewayThread[] threads = new OnewayThread[INVOCATIONS]; for (int i = 0; i < INVOCATIONS; i++) { threads[i] = new OnewayThread(client, i, false); threads[i].start(); } synchronized (lock) { go = true; lock.notifyAll(); } poolCounter++; Thread.sleep(5000); // Verify INVOCATIONS invocations were received. assertEquals(INVOCATIONS, handler.startedCount); for (int i = 0; i < INVOCATIONS; i++) { assertTrue("failure in thread: " + i, threads[i].ok); } client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * This test verifies that the server side thread pool can function under * a heavy load. It uses the socket transport. */ public void testHeavyLoadServerSideSocket() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "socket://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(ServerInvoker.MAX_NUM_ONEWAY_THREADS_KEY, "100"); serverConfig.put(ServerInvoker.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "100"); Connector connector = new Connector(locator, serverConfig); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, clientConfig); client.connect(); int INVOCATIONS = 1000; OnewayThread[] threads = new OnewayThread[INVOCATIONS]; for (int i = 0; i < INVOCATIONS; i++) { threads[i] = new OnewayThread(client, i, false); threads[i].start(); } synchronized (lock) { go = true; lock.notifyAll(); } poolCounter++; Thread.sleep(10000); // Verify INVOCATION invocations were received. assertEquals(INVOCATIONS, handler.startedCount); for (int i = 0; i < INVOCATIONS; i++) { assertTrue("failure in thread: " + i, threads[i].ok); } // Verify only one thread pool was created. Field field = ServerInvoker.class.getDeclaredField("onewayThreadPool"); field.setAccessible(true); Object pool = field.get(connector.getServerInvoker()); assertTrue(pool instanceof BasicThreadPool); BasicThreadPool basicThreadPool = (BasicThreadPool) pool; assertEquals(poolCounter, basicThreadPool.getPoolNumber()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public class OnewayThread extends Thread { boolean ok; Client client; int id; boolean clientSide; public OnewayThread(Client client, int id, boolean clientSide) { this.client = client; this.id = id; this.clientSide = clientSide; } public void run() { try { synchronized (lock) { while (!go) { try {lock.wait();} catch (InterruptedException e) {} } } client.invokeOneway(FAST + id, null, clientSide); ok = true; } catch (Throwable e) { e.printStackTrace(); } } } public class TestHandler implements ServerInvocationHandler { public int startedCount; public int finishedCount; public Object lock = new Object(); public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { log.debug("invocation: " + invocation.getParameter()); synchronized (lock) { startedCount++; } String command = (String) invocation.getParameter(); if (command.startsWith(SLOW)) { log.info("startedCount: " + startedCount); log.info("invocation: " + invocation.getParameter()); Thread.sleep(5000); log.info("invocation done: " + invocation.getParameter()); log.info("finishedCount: " + finishedCount); } synchronized (lock) { finishedCount++; } log.debug("invocation done: " + invocation.getParameter()); log.debug("finishedCount: " + finishedCount); return invocation.getParameter(); } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } } ././@LongLink 0000000 0000000 0000000 00000000154 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerClientTest.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerClientTe0000644 0001750 0001750 00000013147 10716142475 033525 0 ustar twerner twerner /* * 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.remoting.oneway; import java.rmi.server.UID; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import junit.framework.TestCase; /** * This is the actual concrete test for the invoker client to test oneway calls (client and server based). * * @author Tom Elrod */ public class OnewayInvokerClientTest extends TestCase { private static final Logger log = Logger.getLogger(OnewayInvokerClientTest.class); private String transport = "socket"; private int port = 8081; private String sessionId = new UID().toString(); private Client client; public void init() { try { InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port); client = new Client(locator, "test"); client.connect(); } catch(Exception e) { log.error(e.getMessage(), e); } } public void setUp() throws Exception { init(); } public void tearDown() throws Exception { if(client != null) { client.disconnect(); } } /** * Test simple oneway client invocation * * @throws Throwable */ public void testOnewayServerInvocation() throws Throwable { log.debug("running testOnewayClientCallback()"); sessionId = client.getSessionId(); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke String param = "bar"; makeServerOnewayInvocation("saveInvocationParameter", param); Thread.currentThread().sleep(4000); Object obj = makeInvocation("getLastInvocationParameter", null); checkAssertion(param, obj); } protected void checkAssertion(String param, Object obj) { assertEquals(param, obj); } protected void makeServerOnewayInvocation(String method, String param) throws Throwable { client.invokeOneway(new NameBasedInvocation(method, new Object[]{param}, new String[]{String.class.getName()}), null, false); } /** * Test simple oneway client invocation * * @throws Throwable */ public void testOnewayClientInvocation() throws Throwable { log.debug("running testOnewayClientCallback()"); sessionId = client.getSessionId(); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke String param = "bar"; makeClientOnewayInvocation("saveInvocationParameter", param); Thread.currentThread().sleep(1000); Object obj = makeInvocation("getLastInvocationParameter", null); checkAssertion(param, obj); } /** * Test simple oneway client invocation * * @throws Throwable */ public void testClientInvocation() throws Throwable { log.debug("running testInvocation()"); sessionId = client.getSessionId(); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke String param = "bar"; Object resp = makeClientInvocation("saveInvocationParameter", param); Object obj = makeInvocation("getLastInvocationParameter", null); Thread.currentThread().sleep(1000); checkAssertion(param, obj); } protected void makeClientOnewayInvocation(String method, String param) throws Throwable { client.invokeOneway(new NameBasedInvocation(method, new Object[]{param}, new String[]{String.class.getName()}), null, true); } protected Object makeClientInvocation(String method, String param) throws Throwable { Object ret = client.invoke(new NameBasedInvocation(method, new Object[]{param}, new String[]{String.class.getName()}), null); return ret; } protected Object makeInvocation(String method, String param) throws Throwable { Object ret = client.invoke(new NameBasedInvocation(method, new Object[]{param}, new String[]{String.class.getName()}), null); return ret; } } ././@LongLink 0000000 0000000 0000000 00000000152 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerTestCase0000644 0001750 0001750 00000003264 10535452155 033526 0 ustar twerner twerner /* * 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.remoting.oneway; import org.jboss.jrunit.harness.TestDriver; /** * This should be used as the main test case for the oneway invoker client/server. * It will start one instance of the client and one of the server and will * gather the test results and report them in standard JUnit format. When * wanting to run JUnit test for oneway invoker, this is the class to use. * * @author Tom Elrod */ public class OnewayInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(OnewayInvokerClientTest.class.getName(), 1, OnewayInvokerServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayServerInvocationHandler.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayServerInvocatio0000644 0001750 0001750 00000007140 10355142433 033567 0 ustar twerner twerner /* * 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.remoting.oneway; import java.util.ArrayList; 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.callback.InvokerCallbackHandler; import org.jboss.remoting.invocation.RemoteInvocation; /** * MockServerInvocationHandler * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 566 $ */ public class OnewayServerInvocationHandler implements ServerInvocationHandler { private ServerInvoker invoker; private List listeners = new ArrayList(); private static final Logger log = Logger.getLogger(OnewayServerInvocationHandler.class); private Object lastParam = null; /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { this.invoker = invoker; } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { } public Object invoke(InvocationRequest invocation) throws Throwable { Object param = invocation.getParameter(); String methodName = ""; Object[] params = null; String[] sig = null; if(param instanceof RemoteInvocation) { RemoteInvocation rminvo = (RemoteInvocation) param; methodName = rminvo.getMethodName(); params = rminvo.getParameters(); } else { throw new Exception("Unknown invocation payload (" + param + "). " + "Should be instance of RemoteInvocation."); } Object ret = null; if(methodName.equals("saveInvocationParameter")) { if(params != null) { lastParam = params[0]; ret = lastParam; } } else if(methodName.equals("getLastInvocationParameter")) { ret = lastParam; } else { log.error("Expected parameter to be either 'saveInvocationParameter' or 'getLastInvocationParameter'."); } return ret; } public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); log.debug("added listener " + callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); log.debug("removed listener " + callbackHandler); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ShutdownListener.java 0000644 0001750 0001750 00000002247 10355142433 032224 0 ustar twerner twerner /* * 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.remoting; /** * @author Tom Elrod */ public interface ShutdownListener { public void shutdownTest() throws Exception; } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/ 0000755 0001750 0001750 00000000000 11632407042 027566 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/ 0000755 0001750 0001750 00000000000 11632407041 031563 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackT0000644 0001750 0001750 00000005071 11012356344 033332 0 ustar twerner twerner /* * 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.remoting.callback.exception; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * This should be used as the main test case for the invoker client/server. * It will start one instance of the client and one of the server and will * gather the test results and report them in standard JUnit format. When * wanting to run JUnit test for invoker, this is the class to use. * * @author Tom Elrod */ public class CallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(CallbackTestClient.class.getName(), 1, CallbackTestServer.class.getName()); } protected Level getTestLogLevel() { return Level.INFO; } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackT0000644 0001750 0001750 00000024104 10556015500 033326 0 ustar twerner twerner /* * 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.remoting.callback.exception; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.callback.CallbackTestServer; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * @author Tom Elrod */ public class CallbackTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private String locatorURI = transport + "://" + host + ":" + port; private Client remotingClient; private Connector connector; private static final Logger log = Logger.getLogger(CallbackTestClient.class); public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; private void init() throws Exception { createRemotingClient(); } public void createRemotingClient() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); // This could have been new Client(locator), but want to show that subsystem param is null // Could have also been new Client(locator, "sample"); remotingClient = new Client(locator); remotingClient.connect(); } public void makeInvocation() throws Throwable { Object response = remotingClient.invoke("Do something", null); System.out.println("Invocation response: " + response); } public void setUp() throws Exception { init(); } public void tearDown() throws Exception { if(remotingClient != null) { remotingClient.disconnect(); } if(connector != null) { connector.stop(); connector.destroy(); } } public void testPushCallback() throws Throwable { CallbackHandler callbackHandler = new CallbackHandler(); try { // Using loctor with port value one higher than the target server String callbackLocatorURI = transport + "://" + host + ":" + (port + 5); InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); log.info("testPushCallback - Setting up server."); // call to create remoting server to // receive client callbacks. setupServer(callbackLocator); // Callback handle object will be passed back as part of the callback object String callbackHandleObject = "myCallbackHandleObject"; log.info("testPushCallback - adding listener."); // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler, callbackLocator, callbackHandleObject); log.info("testPushCallback - make invocation"); // now make invocation on server, which should cause a callback to happen makeInvocation(); // need to wait for brief moment so server can callback Thread.sleep(5000); Callback callback = callbackHandler.getCallback(); log.info("testPushCallback - Callback returned was " + callback); assertNotNull("Callback returned was null.", callback); Object callbackObj = callback.getCallbackObject(); log.info("testPushCallback - Callback value should have been " + CallbackTestServer.CALLBACK_VALUE + ", and was " + callbackObj); assertEquals("Callback value should have been " + CallbackTestServer.CALLBACK_VALUE + ", but was " + callbackObj, CallbackTestServer.CALLBACK_VALUE, callbackObj); Object callbackHandleObj = callback.getCallbackHandleObject(); log.info("testPushCallback - Callback handle object should have been " + callbackHandleObject + ", and was " + callbackHandleObj); assertEquals("Callback handle object should have been " + callbackHandleObject + ", but was " + callbackHandleObj, callbackHandleObject, callbackHandleObj); InvokerLocator serverLoc = callback.getServerLocator(); log.info("testPushCallback - Callback server locator should have been " + remotingClient.getInvoker().getLocator() + ", and was " + serverLoc); assertEquals("Callback server locator should have been " + remotingClient.getInvoker().getLocator() + ", but was " + serverLoc, remotingClient.getInvoker().getLocator(), serverLoc); } finally { if(remotingClient != null) { // remove callback handler from server remotingClient.removeListener(callbackHandler); } if(connector != null) { connector.stop(); connector.destroy(); } Thread.currentThread().sleep(50000); } } public void setupServer(InvokerLocator locator) throws Exception { log.info("Starting remoting server with locator uri of: " + locator); try { connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); } catch(Exception e) { log.error("Error starting callback server", e); throw e; } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback("This is the payload of callback invocation."); System.out.println("listeners.size = " + listeners.size()); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } public class CallbackHandler implements InvokerCallbackHandler { private Callback callback; /** * Will take the callback message and send back to client. * If client locator is null, will store them till client polls to get them. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { this.callback = callback; System.out.println("Received callback value of: " + callback.getCallbackObject()); System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject()); System.out.println("Received callback server invoker of: " + callback.getServerLocator()); } public Callback getCallback() { return callback; } } } ././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackT0000644 0001750 0001750 00000014317 10556015500 033333 0 ustar twerner twerner /* * 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.remoting.callback.exception; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class CallbackTestServer extends ServerTestCase implements ServerInvocationHandler { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector; // String to be returned from invocation handler upon client invocation calls. public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public static final String CALLBACK_VALUE = "This is the payload of callback invocation."; private static boolean running = false; private static boolean started = true; private List listeners = new ArrayList(); public void setupServer() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", this); } protected void setUp() throws Exception { setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void testCallbackError() { while(started) { while(running) { // Will also fire callback to listeners if they were to exist using // simple invocation request. try { Callback callback = new Callback(CALLBACK_VALUE); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler)itr.next(); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { System.out.println("Got HandleCallbackException as expected: " + e); } } } catch(Exception e) { } } try { Thread.currentThread().sleep(1000); } catch(InterruptedException e) { e.printStackTrace(); } } assertEquals("Number of callback listener should be zero.", 0, listeners.size()); System.out.println("Number of callback listeners should be zero and is " + listeners.size()); } public void testFailurePropagationOnCallbackError() { // TODO } public static void main(String[] args) { try { CallbackTestServer server = new CallbackTestServer(); server.setUp(); server.testCallbackError(); server.testFailurePropagationOnCallbackError(); } catch(Exception e) { e.printStackTrace(); } } /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. running = true; return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { running = false; started = false; listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/ 0000755 0001750 0001750 00000000000 11632407042 030542 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000170 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/UniqueCallbackPollerTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/UniqueCallback0000644 0001750 0001750 00000014455 10665733321 033370 0 ustar twerner twerner /* * 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.remoting.callback.pull; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.CallbackPoller; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-743. * * @author Ron Sigal * @version $Revision: 2730 $ ** Copyright Aug 22, 2007 *
*/ public class UniqueCallbackPollerTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(UniqueCallbackPollerTestCase.class); private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private TestInvocationHandler invocationHandler; /** * Sets up target remoting server. */ public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } /** * Verifies that only one CallbackPoller is created for a given combination of * org.jboss.remoting.Client and InvokerCallbackHandler. */ public void testUniqueCallbackPoller() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); Field field = Client.class.getDeclaredField("callbackPollers"); field.setAccessible(true); Map callbackPollers = (Map) field.get(client); assertEquals(0, callbackPollers.size()); // Add InvokerCallbackHandler first time. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap()); assertEquals(1, callbackPollers.size()); CallbackPoller callbackPoller1 = (CallbackPoller) callbackPollers.values().iterator().next(); // Add InvokerCallbackHandler second time. client.addListener(callbackHandler, new HashMap()); assertEquals(1, callbackPollers.size()); CallbackPoller callbackPoller2 = (CallbackPoller) callbackPollers.values().iterator().next(); assertEquals(callbackPoller2, callbackPoller1); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class TestInvocationHandler implements ServerInvocationHandler { public Set listeners = new HashSet(); public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestInvokerCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; } } } ././@LongLink 0000000 0000000 0000000 00000000165 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackInvocationHandler.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackInvoca0000644 0001750 0001750 00000004210 10445574363 033332 0 ustar twerner twerner package org.jboss.test.remoting.callback.pull; import org.jboss.logging.Logger; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.List; /** * @author Tom Elrod */ public class CallbackInvocationHandler implements ServerInvocationHandler { private transient List pullListeners = new ArrayList(); private int numberOfCallbacks = 5; private static final Logger log = Logger.getLogger(CallbackInvocationHandler.class); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { String id = invocation.getSessionId(); if(pullListeners != null) { for(int x = 0; x < pullListeners.size(); x++) { ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler)pullListeners.get(x); if(callbackHandler.getClientSessionId().equals(id)) { callbackHandler.handleCallback(new Callback(id)); } } } return "Starting callback"; } public void addListener(InvokerCallbackHandler callbackHandler) { pullListeners.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { pullListeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/ 0000755 0001750 0001750 00000000000 11632407042 032052 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/TestCallback.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/TestCal0000644 0001750 0001750 00000002621 10433414054 033334 0 ustar twerner twerner /* * 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.remoting.callback.pull.memory; import java.io.Serializable; /** * @author Tom Elrod */ public class TestCallback implements Serializable { byte[] bytes = null; int counter = 0; public TestCallback(byte[] bytes, int counter) { this.bytes = bytes; this.counter = counter; } public int getCallbackNumber() { return counter; } } ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/CallbackInvocationHandler.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/Callbac0000644 0001750 0001750 00000021130 10355142433 033314 0 ustar twerner twerner /* * 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.remoting.callback.pull.memory; 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.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; /** * @author Tom Elrod */ public class CallbackInvocationHandler implements ServerInvocationHandler, Runnable { private transient List pullListeners = new ArrayList(); private transient List pushListeners = new ArrayList(); private int numberOfCallbacks = 500; private boolean isDone = false; private int callbackCounter = 0; private byte[] memHolder = null; private static final Logger log = Logger.getLogger(CallbackInvocationHandler.class); public CallbackInvocationHandler() { long max = Runtime.getRuntime().maxMemory(); System.out.println("max mem: " + max); log.info("max mem: " + max); int memSize = (int) (max * 0.9); System.out.println("90% of max: " + memSize); log.info("90% of max: " + memSize); long free = Runtime.getRuntime().freeMemory(); System.out.println("free mem: " + free); log.info("free mem: " + free); long total = Runtime.getRuntime().totalMemory(); log.info("total mem: " + total); if(total != max) { memHolder = new byte[memSize]; } else if(free > memSize) { memHolder = new byte[memSize]; } } /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { System.out.println("invoke() called on server with param: " + invocation.getParameter()); log.info("invoke() called on server with param: " + invocation.getParameter()); if("getdone".equalsIgnoreCase((String) invocation.getParameter())) { if(isDone) { return new Boolean(true); } else { return new Boolean(false); } } try { numberOfCallbacks = Integer.parseInt((String) invocation.getParameter()); System.out.println("Number of callbacks as defined by client = " + numberOfCallbacks); log.info("Number of callbacks as defined by client = " + numberOfCallbacks); } catch(NumberFormatException e) { System.out.println("Starting callbacks on server."); log.info("Starting callbacks on server."); new Thread(this).start(); return "Starting callback"; } return null; } /** * When an object implementing interfaceRunnable
is used to create a thread, starting the thread causes
* the object's run
method to be called in that separately executing thread.
*
* The general contract of the method run
is that it may take any action whatsoever.
*
* @see Thread#run()
*/
public void run()
{
try
{
System.out.println("Sending " + numberOfCallbacks + " callbacks.");
log.info("Sending " + numberOfCallbacks + " callbacks.");
synchronized(pullListeners)
{
for(int x = 0; x < numberOfCallbacks; x++)
{
if(x % 10 == 0)
{
System.out.println("Number of callbacks generated = " + x);
log.info("Number of callbacks generated = " + x);
System.out.println("Free mem = " + Runtime.getRuntime().freeMemory());
log.info("Free mem = " + Runtime.getRuntime().freeMemory());
if(isMemLow())
{
System.out.println("Mem is low, so will be sleeping (slowing test down).");
log.info("Mem is low, so will be sleeping (slowing test down).");
}
}
// Will also fire callback to listeners if they were to exist using
// simple invocation request.
synchronized(pullListeners)
{
Iterator itr = pullListeners.iterator();
while(itr.hasNext())
{
InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next();
try
{
callbackHandler.handleCallback(new Callback(getCallbackMessage()));
if(isMemLow())
{
Thread.currentThread().sleep(1000);
}
}
catch(HandleCallbackException e)
{
e.printStackTrace();
}
}
}
}
// done adding callbacks, now release memory
memHolder = null;
}
isDone = true;
synchronized(pushListeners)
{
Iterator itr = pushListeners.iterator();
while(itr.hasNext())
{
InvokerCallbackHandler handler = (InvokerCallbackHandler) itr.next();
try
{
handler.handleCallback(new Callback("Done"));
}
catch(HandleCallbackException e)
{
e.printStackTrace();
}
}
}
}
catch(Throwable e)
{
e.printStackTrace();
}
}
private boolean isMemLow()
{
Runtime runtime = Runtime.getRuntime();
long max = runtime.maxMemory();
long total = runtime.totalMemory();
long free = runtime.freeMemory();
float percentage = 100 * free / total;
if(max == total && 40 >= percentage)
{
return true;
}
else
{
return false;
}
}
/**
* Adds a callback handler that will listen for callbacks from the server invoker handler.
*
* @param callbackHandler
*/
public void addListener(InvokerCallbackHandler callbackHandler)
{
ServerInvokerCallbackHandler sih = (ServerInvokerCallbackHandler) callbackHandler;
if(!sih.isPullCallbackHandler())
{
pushListeners.add(callbackHandler);
}
else
{
pullListeners.add(callbackHandler);
}
}
/**
* Removes the callback handler that was listening for callbacks from the server invoker handler.
*
* @param callbackHandler
*/
public void removeListener(InvokerCallbackHandler callbackHandler)
{
pullListeners.remove(callbackHandler);
pushListeners.remove(callbackHandler);
}
/**
* set the mbean server that the handler can reference
*
* @param server
*/
public void setMBeanServer(MBeanServer server)
{
// NO OP as do not need reference to MBeanServer for this handler
}
/**
* set the invoker that owns this handler
*
* @param invoker
*/
public void setInvoker(ServerInvoker invoker)
{
// NO OP as do not need reference back to the server invoker
}
private Object getCallbackMessage()
{
callbackCounter++;
//byte[] bytes = new byte[5120000];
byte[] bytes = new byte[102400];
TestCallback callback = new TestCallback(bytes, callbackCounter);
return callback;
}
} ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011561 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000755 0001750 0001750 00000000000 11632407042 033473 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000206 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/JBossASCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000644 0001750 0001750 00000021004 10433770344 033500 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.nullstore;
import org.jboss.remoting.Client;
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.samples.callback.CallbackServer;
import org.jboss.remoting.transport.Connector;
import java.util.List;
/**
* @author Tom Elrod
*/
public class JBossASCallbackTestClient
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5411;
private String locatorURI = null;
private Client remotingClient;
private CallbackHandler pullCallbackHandler;
private boolean isCallbackDone = false;
private int numberOfCallbacks = 520;
public JBossASCallbackTestClient(String name, String locatorURI)
{
this.locatorURI = locatorURI;
}
public void createRemotingClient() throws Exception
{
InvokerLocator locator = new InvokerLocator(locatorURI);
System.out.println("Calling remoting server with locator uri of: " + locatorURI);
// This could have been new Client(locator), but want to show that subsystem param is null
// Could have also been new Client(locator, "sample");
remotingClient = new Client(locator);
remotingClient.connect();
}
public void makeInvocation(String param) throws Throwable
{
Object response = remotingClient.invoke(param, null);
System.out.println("Invocation response: " + response);
}
public void testPullCallback() throws Throwable
{
createRemotingClient();
numberOfCallbacks = calculateNumberOfCallbacks();
System.out.println("Number of callbacks need to activate persitence: " + numberOfCallbacks);
pullCallbackHandler = new CallbackHandler();
// by passing only the callback handler, will indicate pull callbacks
remotingClient.addListener(pullCallbackHandler);
// need to tell server handler how many
makeInvocation("" + numberOfCallbacks);
// now make invocation on server, which should cause a callback to happen
makeInvocation("Do something");
boolean didItWork = checkForCallback();
System.out.println("Did id work = " + didItWork);
int totalCallbacks = 0;
if(didItWork)
{
boolean gotExpectedException = false;
try
{
// now need to go get the callbacks until none left.
int callbacksReceived = getAllCallbacks(pullCallbackHandler);
System.out.println("callbacks received = " + callbacksReceived);
totalCallbacks = totalCallbacks + callbacksReceived;
}
catch(RuntimeException re)
{
System.out.println("Got exception as expected - " + re);
gotExpectedException = true;
}
catch(Throwable thr)
{
System.out.println("Got unexpected exception - " + thr);
}
if(gotExpectedException)
{
System.out.println("PASSED");
}
else
{
System.out.println("FAILED");
}
}
System.out.println("total callbacks received: " + totalCallbacks);
System.out.println("total callbacks expected: " + numberOfCallbacks);
remotingClient.removeListener(pullCallbackHandler);
remotingClient.disconnect();
remotingClient = null;
}
/**
* calculate how many 102400 byte callback messages it will take to consume 30%
* of the vm's memory. The CallbackInvocationHandler will take care of consuming 70%
* so need to make sure we have enough callbacks to trigger persistence.
*/
private int calculateNumberOfCallbacks()
{
long max = Runtime.getRuntime().maxMemory();
int targetMem = (int) (max * 0.3);
int num = targetMem / 102400;
return num;
}
private int getAllCallbacks(CallbackHandler pullCallbackHandler) throws Throwable
{
int counter = 0;
List callbacks = null;
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
while(callbacks.size() > 0)
{
System.out.println("callbacks.size() = " + callbacks.size());
counter = counter + callbacks.size();
for(int i = 0; i < callbacks.size(); i++)
{
((Callback) callbacks.get(i)).getCallbackObject();
}
// need to give time for server to clean up mem
Thread.currentThread().sleep(2000);
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
}
return counter;
}
private boolean checkForCallback() throws Throwable
{
boolean isComplete = false;
int waitPeriod = 1000;
int numOfWaits = 360; // means will wait 30 seconds
for(int x = 0; x < numOfWaits; x++)
{
//isComplete = pushCallbackHandler.isComplete();
isComplete = ((Boolean) remotingClient.invoke("getdone")).booleanValue();
if(!isComplete)
{
try
{
Thread.currentThread().sleep(waitPeriod);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
else
{
break;
}
}
return isComplete;
}
public void setupServer(InvokerLocator locator) throws Exception
{
System.out.println("Starting remoting server with locator uri of: " + locator);
Connector connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
connector.start();
CallbackServer.SampleInvocationHandler invocationHandler = new CallbackServer.SampleInvocationHandler();
// first parameter is sub-system name. can be any String value.
connector.addInvocationHandler("sample", invocationHandler);
}
/**
* Can pass transport and port to be used as parameters.
* Valid transports are 'rmi' and 'socket'.
*
* @param args
*/
public static void main(String[] args)
{
if(args != null && args.length == 2)
{
transport = args[0];
port = Integer.parseInt(args[1]);
}
String locatorURI = transport + "://" + host + ":" + port;
JBossASCallbackTestClient client = new JBossASCallbackTestClient(JBossASCallbackTestClient.class.getName(), locatorURI);
try
{
client.testPullCallback();
}
catch(Throwable e)
{
e.printStackTrace();
System.exit(1);
}
System.exit(0);
}
public class PushCallbackHandler extends CallbackHandler
{
}
public class CallbackHandler implements InvokerCallbackHandler
{
boolean isComplete = false;
/**
* Will take the callback message and send back to client.
* If client locator is null, will store them till client polls to get them.
*
* @param callback
* @throws org.jboss.remoting.callback.HandleCallbackException
*
*/
public void handleCallback(Callback callback) throws HandleCallbackException
{
System.out.println("Received callback value of: " + callback.getCallbackObject());
System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject());
System.out.println("Received callback server invoker of: " + callback.getServerLocator());
isComplete = true;
}
public boolean isComplete()
{
return isComplete;
}
}
} ././@LongLink 0000000 0000000 0000000 00000000206 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/NullStoreCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000644 0001750 0001750 00000005101 10535452155 033500 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.nullstore;
import org.apache.log4j.Level;
import org.jboss.jrunit.harness.TestDriver;
/**
* This should be used as the main test case for the invoker client/server.
* It will start one instance of the client and one of the server and will
* gather the test results and report them in standard JUnit format. When
* wanting to run JUnit test for invoker, this is the class to use.
*
* @author Tom Elrod
*/
public class NullStoreCallbackTestCase extends TestDriver
{
public void declareTestClasses()
{
addTestClasses(CallbackTestClient.class.getName(),
1,
CallbackTestServer.class.getName());
}
/**
* How long to wait for test results to be returned from the client(s). If goes longer than the
* specified limit, will throw an exception and kill the running test cases. Default value is
* RESULTS_TIMEOUT.
*
* @return
*/
protected long getResultsTimeout()
{
return 600000;
}
/**
* How long for the server test case to wait for tear down message. If exceeds timeout,
* will throw exception. The default value is TEARDOWN_TIMEOUT.
*
* @return
*/
protected long getTearDownTimeout()
{
return 600000;
}
/**
* How long to allow each of the test cases to run their tests. If exceeds this timeout
* will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
*
* @return
*/
protected long getRunTestTimeout()
{
return 600000;
}
} ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000644 0001750 0001750 00000017044 10433770344 033511 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.nullstore;
import junit.framework.TestCase;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import java.util.List;
/**
* @author Tom Elrod
*/
public class CallbackTestClient extends TestCase
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5411;
private String locatorURI = transport + "://" + host + ":" + port;
private Client remotingClient;
private CallbackHandler pullCallbackHandler;
private boolean isCallbackDone = false;
private int numberOfCallbacks = 520;
public void createRemotingClient() throws Exception
{
InvokerLocator locator = new InvokerLocator(locatorURI);
System.out.println("Calling remoting server with locator uri of: " + locatorURI);
// This could have been new Client(locator), but want to show that subsystem param is null
// Could have also been new Client(locator, "sample");
remotingClient = new Client(locator);
remotingClient.connect();
}
public void makeInvocation(String param) throws Throwable
{
Object response = remotingClient.invoke(param, null);
System.out.println("Invocation response: " + response);
}
public void setUp() throws Exception
{
createRemotingClient();
}
public void tearDown() throws Exception
{
if(remotingClient != null)
{
if(pullCallbackHandler != null)
{
try
{
remotingClient.removeListener(pullCallbackHandler);
}
catch(Throwable throwable)
{
throw new Exception(throwable);
}
}
remotingClient.disconnect();
}
}
public void testPullCallback() throws Throwable
{
numberOfCallbacks = calculateNumberOfCallbacks();
System.out.println("Number of callbacks need to activate persitence: " + numberOfCallbacks);
pullCallbackHandler = new CallbackHandler();
// by passing only the callback handler, will indicate pull callbacks
remotingClient.addListener(pullCallbackHandler);
// need to tell server handler how many
makeInvocation("" + numberOfCallbacks);
// now make invocation on server, which should cause a callback to happen
makeInvocation("Do something");
boolean didItWork = checkForCallback();
System.out.println("Did id work = " + didItWork);
int totalCallbacks = 0;
if(didItWork)
{
boolean gotExpectedException = false;
try
{
// now need to go get the callbacks until none left.
int callbacksReceived = getAllCallbacks(pullCallbackHandler);
System.out.println("callbacks received = " + callbacksReceived);
totalCallbacks = totalCallbacks + callbacksReceived;
}
catch(RuntimeException re)
{
System.out.println("Got exception as expected - " + re);
gotExpectedException = true;
}
catch(Throwable thr)
{
System.out.println("Got unexpected exception - " + thr);
}
if(gotExpectedException)
{
System.out.println("PASSED");
}
else
{
System.out.println("FAILED");
}
assertTrue(gotExpectedException);
}
System.out.println("total callbacks received: " + totalCallbacks);
System.out.println("total callbacks expected: " + numberOfCallbacks);
}
/**
* calculate how many 102400 byte callback messages it will take to consume 30%
* of the vm's memory. The CallbackInvocationHandler will take care of consuming 70%
* so need to make sure we have enough callbacks to trigger persistence.
*/
private int calculateNumberOfCallbacks()
{
long max = Runtime.getRuntime().maxMemory();
int targetMem = (int) (max * 0.1);
int num = targetMem / 102400;
return num;
}
private int getAllCallbacks(CallbackHandler pullCallbackHandler) throws Throwable
{
int counter = 0;
List callbacks = null;
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
while(callbacks.size() > 0)
{
System.out.println("callbacks.size() = " + callbacks.size());
counter = counter + callbacks.size();
for(int i = 0; i < callbacks.size(); i++)
{
((Callback) callbacks.get(i)).getCallbackObject();
}
// need to give time for server to clean up mem
Thread.currentThread().sleep(2000);
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
}
return counter;
}
private boolean checkForCallback() throws Throwable
{
boolean isComplete = false;
int waitPeriod = 1000;
int numOfWaits = 360; // means will wait 30 seconds
for(int x = 0; x < numOfWaits; x++)
{
//isComplete = pushCallbackHandler.isComplete();
isComplete = ((Boolean) remotingClient.invoke("getdone")).booleanValue();
if(!isComplete)
{
try
{
Thread.currentThread().sleep(waitPeriod);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
else
{
break;
}
}
return isComplete;
}
public class PushCallbackHandler extends CallbackHandler
{
}
public class CallbackHandler implements InvokerCallbackHandler
{
boolean isComplete = false;
/**
* Will take the callback message and send back to client.
* If client locator is null, will store them till client polls to get them.
*
* @param callback
* @throws org.jboss.remoting.callback.HandleCallbackException
*
*/
public void handleCallback(Callback callback) throws HandleCallbackException
{
System.out.println("Received callback value of: " + callback.getCallbackObject());
System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject());
System.out.println("Received callback server invoker of: " + callback.getServerLocator());
isComplete = true;
}
public boolean isComplete()
{
return isComplete;
}
}
} ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000644 0001750 0001750 00000005346 10355142433 033506 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.nullstore;
import org.jboss.jrunit.extensions.ServerTestCase;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.transport.Connector;
import org.jboss.test.remoting.callback.pull.memory.CallbackInvocationHandler;
/**
* Simple remoting server. Uses inner class SampleInvocationHandler
* as the invocation target handler class.
*
* @author Tom Elrod
*/
public class CallbackTestServer extends ServerTestCase
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5411;
private String locatorURI = transport + "://" + host + ":" + port;
private Connector connector;
// String to be returned from invocation handler upon client invocation calls.
private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation";
public void setupServer() throws Exception
{
InvokerLocator locator = new InvokerLocator(locatorURI);
System.out.println("Starting remoting server with locator uri of: " + locatorURI);
connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
connector.create();
CallbackInvocationHandler invocationHandler = new CallbackInvocationHandler();
// first parameter is sub-system name. can be any String value.
connector.addInvocationHandler("sample", invocationHandler);
connector.start();
}
public void setUp() throws Exception
{
setupServer();
}
public void tearDown() throws Exception
{
if(connector != null)
{
connector.stop();
connector.destroy();
}
}
} ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000755 0001750 0001750 00000000000 11632407042 033414 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000205 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/CallbackInvocationHandler.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000644 0001750 0001750 00000020525 10433414054 033421 0 ustar twerner twerner package org.jboss.test.remoting.callback.pull.memory.blocking;
import org.jboss.logging.Logger;
import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.ServerInvocationHandler;
import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
import org.jboss.test.remoting.callback.pull.memory.TestCallback;
import javax.management.MBeanServer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* @author Tom Elrod
*/
public class CallbackInvocationHandler implements ServerInvocationHandler, Runnable
{
private transient List pullListeners = new ArrayList();
private transient List pushListeners = new ArrayList();
private int numberOfCallbacks = 500;
private boolean isDone = false;
private int callbackCounter = 0;
private byte[] memHolder = null;
private static final Logger log = Logger.getLogger(CallbackInvocationHandler.class);
public CallbackInvocationHandler()
{
long max = Runtime.getRuntime().maxMemory();
System.out.println("max mem: " + max);
log.info("max mem: " + max);
int memSize = (int) (max * 0.9);
System.out.println("90% of max: " + memSize);
log.info("90% of max: " + memSize);
long free = Runtime.getRuntime().freeMemory();
System.out.println("free mem: " + free);
log.info("free mem: " + free);
long total = Runtime.getRuntime().totalMemory();
log.info("total mem: " + total);
if(total != max)
{
memHolder = new byte[memSize];
}
else if(free > memSize)
{
memHolder = new byte[memSize];
}
}
/**
* called to handle a specific invocation
*
* @param invocation
* @return
* @throws Throwable
*/
public Object invoke(InvocationRequest invocation) throws Throwable
{
System.out.println("invoke() called on server with param: " + invocation.getParameter());
log.info("invoke() called on server with param: " + invocation.getParameter());
if("getdone".equalsIgnoreCase((String) invocation.getParameter()))
{
if(isDone)
{
return new Boolean(true);
}
else
{
return new Boolean(false);
}
}
try
{
numberOfCallbacks = Integer.parseInt((String) invocation.getParameter());
System.out.println("Number of callbacks as defined by client = " + numberOfCallbacks);
log.info("Number of callbacks as defined by client = " + numberOfCallbacks);
}
catch(NumberFormatException e)
{
System.out.println("Starting callbacks on server.");
log.info("Starting callbacks on server.");
new Thread(this).start();
return "Starting callback";
}
return null;
}
/**
* When an object implementing interface Runnable
is used to create a thread, starting the thread causes
* the object's run
method to be called in that separately executing thread.
*
* The general contract of the method run
is that it may take any action whatsoever.
*
* @see Thread#run()
*/
public void run()
{
try
{
System.out.println("Sending " + numberOfCallbacks + " callbacks.");
log.info("Sending " + numberOfCallbacks + " callbacks.");
synchronized(pullListeners)
{
for(int x = 0; x < numberOfCallbacks; x++)
{
// if(x % 10 == 0)
// {
System.out.println("Number of callbacks generated = " + x);
log.info("Number of callbacks generated = " + x);
// System.out.println("Free mem = " + Runtime.getRuntime().freeMemory());
// log.info("Free mem = " + Runtime.getRuntime().freeMemory());
// if(isMemLow())
// {
// System.out.println("Mem is low, so will be sleeping (slowing test down).");
// log.info("Mem is low, so will be sleeping (slowing test down).");
// }
// }
// Will also fire callback to listeners if they were to exist using
// simple invocation request.
synchronized(pullListeners)
{
Iterator itr = pullListeners.iterator();
while(itr.hasNext())
{
InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next();
try
{
callbackHandler.handleCallback(new Callback(getCallbackMessage()));
if(isMemLow())
{
Thread.currentThread().sleep(1000);
}
}
catch(HandleCallbackException e)
{
e.printStackTrace();
}
}
}
}
// done adding callbacks, now release memory
memHolder = null;
}
isDone = true;
synchronized(pushListeners)
{
Iterator itr = pushListeners.iterator();
while(itr.hasNext())
{
InvokerCallbackHandler handler = (InvokerCallbackHandler) itr.next();
try
{
handler.handleCallback(new Callback("Done"));
}
catch(HandleCallbackException e)
{
e.printStackTrace();
}
}
}
Thread.sleep(5000);
System.gc();
Thread.sleep(5000);
for(int x = 0; x < 10; x++)
{
synchronized(pullListeners)
{
Iterator itr = pullListeners.iterator();
while(itr.hasNext())
{
InvokerCallbackHandler handler = (InvokerCallbackHandler) itr.next();
try
{
handler.handleCallback(new Callback("Done"));
}
catch(HandleCallbackException e)
{
e.printStackTrace();
}
}
}
}
}
catch(Throwable e)
{
e.printStackTrace();
}
}
private boolean isMemLow()
{
Runtime runtime = Runtime.getRuntime();
long max = runtime.maxMemory();
long total = runtime.totalMemory();
long free = runtime.freeMemory();
float percentage = 100 * free / total;
if(max == total && 40 >= percentage)
{
return true;
}
else
{
return false;
}
}
/**
* Adds a callback handler that will listen for callbacks from the server invoker handler.
*
* @param callbackHandler
*/
public void addListener(InvokerCallbackHandler callbackHandler)
{
ServerInvokerCallbackHandler sih = (ServerInvokerCallbackHandler) callbackHandler;
if(!sih.isPullCallbackHandler())
{
pushListeners.add(callbackHandler);
}
else
{
pullListeners.add(callbackHandler);
}
}
/**
* Removes the callback handler that was listening for callbacks from the server invoker handler.
*
* @param callbackHandler
*/
public void removeListener(InvokerCallbackHandler callbackHandler)
{
pullListeners.remove(callbackHandler);
pushListeners.remove(callbackHandler);
}
/**
* set the mbean server that the handler can reference
*
* @param server
*/
public void setMBeanServer(MBeanServer server)
{
// NO OP as do not need reference to MBeanServer for this handler
}
/**
* set the invoker that owns this handler
*
* @param invoker
*/
public void setInvoker(ServerInvoker invoker)
{
// NO OP as do not need reference back to the server invoker
}
private Object getCallbackMessage()
{
callbackCounter++;
//byte[] bytes = new byte[5120000];
byte[] bytes = new byte[102400];
TestCallback callback = new TestCallback(bytes, callbackCounter);
return callback;
}
}
././@LongLink 0000000 0000000 0000000 00000000211 00000000000 011557 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/BlockingStoreCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000644 0001750 0001750 00000003142 10535452155 033424 0 ustar twerner twerner package org.jboss.test.remoting.callback.pull.memory.blocking;
import org.apache.log4j.Level;
import org.jboss.jrunit.harness.TestDriver;
/**
* This should be used as the main test case for the invoker client/server.
* It will start one instance of the client and one of the server and will
* gather the test results and report them in standard JUnit format. When
* wanting to run JUnit test for invoker, this is the class to use.
*
* @author Tom Elrod
*/
public class BlockingStoreCallbackTestCase extends TestDriver
{
public void declareTestClasses()
{
addTestClasses(CallbackTestClient.class.getName(),
1,
CallbackTestServer.class.getName());
}
/**
* How long to wait for test results to be returned from the client(s). If goes longer than the
* specified limit, will throw an exception and kill the running test cases. Default value is
* RESULTS_TIMEOUT.
*
* @return
*/
protected long getResultsTimeout()
{
return 600000;
}
/**
* How long for the server test case to wait for tear down message. If exceeds timeout,
* will throw exception. The default value is TEARDOWN_TIMEOUT.
*
* @return
*/
protected long getTearDownTimeout()
{
return 600000;
}
/**
* How long to allow each of the test cases to run their tests. If exceeds this timeout
* will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
*
* @return
*/
protected long getRunTestTimeout()
{
return 600000;
}
}
././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000644 0001750 0001750 00000016407 10433770344 033434 0 ustar twerner twerner package org.jboss.test.remoting.callback.pull.memory.blocking;
import junit.framework.TestCase;
import org.jboss.remoting.Client;
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.test.remoting.callback.pull.memory.TestCallback;
import java.util.List;
/**
* @author Tom Elrod
*/
public class CallbackTestClient extends TestCase
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5411;
private String locatorURI = transport + "://" + host + ":" + port;
private Client remotingClient;
private CallbackHandler pullCallbackHandler;
private boolean isCallbackDone = false;
private int numberOfCallbacks = 520;
public void createRemotingClient() throws Exception
{
InvokerLocator locator = new InvokerLocator(locatorURI);
System.out.println("Calling remoting server with locator uri of: " + locatorURI);
// This could have been new Client(locator), but want to show that subsystem param is null
// Could have also been new Client(locator, "sample");
remotingClient = new Client(locator);
remotingClient.connect();
}
public void makeInvocation(String param) throws Throwable
{
Object response = remotingClient.invoke(param, null);
System.out.println("Invocation response: " + response);
}
public void setUp() throws Exception
{
createRemotingClient();
}
public void tearDown() throws Exception
{
if(remotingClient != null)
{
if(pullCallbackHandler != null)
{
try
{
remotingClient.removeListener(pullCallbackHandler);
}
catch(Throwable throwable)
{
throw new Exception(throwable);
}
}
remotingClient.disconnect();
}
}
public void testPullCallback() throws Throwable
{
numberOfCallbacks = calculateNumberOfCallbacks();
System.out.println("Number of callbacks need to activate persitence: " + numberOfCallbacks);
pullCallbackHandler = new CallbackHandler();
// by passing only the callback handler, will indicate pull callbacks
remotingClient.addListener(pullCallbackHandler);
// need to tell server handler how many
makeInvocation("" + numberOfCallbacks);
// now make invocation on server, which should cause a callback to happen
makeInvocation("Do something");
boolean didItWork = checkForCallback();
System.out.println("Did id work = " + didItWork);
int totalCallbacks = 0;
if(didItWork)
{
// boolean gotExpectedException = false;
try
{
// now need to go get the callbacks until none left.
int callbacksReceived = getAllCallbacks(pullCallbackHandler);
System.out.println("callbacks received = " + callbacksReceived);
totalCallbacks = totalCallbacks + callbacksReceived;
}
// catch(RuntimeException re)
// {
// System.out.println("Got exception as expected - " + re);
// gotExpectedException = true;
// }
catch(Throwable thr)
{
System.out.println("Got unexpected exception - " + thr);
}
System.out.println("total callbacks received: " + totalCallbacks);
System.out.println("total callbacks expected: " + numberOfCallbacks);
assertEquals(numberOfCallbacks, totalCallbacks);
Thread.sleep(15000);
List callbacks = remotingClient.getCallbacks(pullCallbackHandler);
System.out.println("callbacks size = " + callbacks.size());
assertEquals(10, callbacks.size());
// if(gotExpectedException)
// {
// System.out.println("PASSED");
// }
// else
// {
// System.out.println("FAILED");
// }
// assertTrue(gotExpectedException);
}
}
/**
* calculate how many 102400 byte callback messages it will take to consume 30%
* of the vm's memory. The CallbackInvocationHandler will take care of consuming 70%
* so need to make sure we have enough callbacks to trigger persistence.
*/
private int calculateNumberOfCallbacks()
{
long max = Runtime.getRuntime().maxMemory();
int targetMem = (int) (max * 0.1);
int num = targetMem / 102400;
return num;
}
private int getAllCallbacks(CallbackHandler pullCallbackHandler) throws Throwable
{
int counter = 0;
int cbNum = 0;
List callbacks = null;
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
while(callbacks.size() > 0)
{
System.out.println("callbacks.size() = " + callbacks.size());
counter = counter + callbacks.size();
System.out.println("callback counter = " + counter);
for(int i = 0; i < callbacks.size(); i++)
{
Object o = ((Callback) callbacks.get(i)).getCallbackObject();
TestCallback cb = (TestCallback)o;
cbNum = cb.getCallbackNumber();
System.out.println("Callback number: " + cbNum);
}
assertEquals(counter, cbNum);
// need to give time for server to clean up mem
Thread.currentThread().sleep(2000);
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
}
return counter;
}
private boolean checkForCallback() throws Throwable
{
boolean isComplete = false;
int waitPeriod = 1000;
// int numOfWaits = 360;
int numOfWaits = 30;
for(int x = 0; x < numOfWaits; x++)
{
//isComplete = pushCallbackHandler.isComplete();
isComplete = ((Boolean) remotingClient.invoke("getdone")).booleanValue();
if(!isComplete)
{
try
{
Thread.currentThread().sleep(waitPeriod);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
else
{
break;
}
}
//DEBUG
isComplete = true;
return isComplete;
}
public class PushCallbackHandler extends CallbackHandler
{
}
public class CallbackHandler implements InvokerCallbackHandler
{
boolean isComplete = false;
/**
* Will take the callback message and send back to client.
* If client locator is null, will store them till client polls to get them.
*
* @param callback
* @throws org.jboss.remoting.callback.HandleCallbackException
*
*/
public void handleCallback(Callback callback) throws HandleCallbackException
{
System.out.println("Received callback value of: " + callback.getCallbackObject());
System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject());
System.out.println("Received callback server invoker of: " + callback.getServerLocator());
isComplete = true;
}
public boolean isComplete()
{
return isComplete;
}
}
}
././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000644 0001750 0001750 00000004304 10433414054 033416 0 ustar twerner twerner package org.jboss.test.remoting.callback.pull.memory.blocking;
import org.jboss.jrunit.extensions.ServerTestCase;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.callback.BlockingCallbackStore;
import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
import org.jboss.remoting.transport.Connector;
/**
* Simple remoting server. Uses inner class SampleInvocationHandler
* as the invocation target handler class.
*
* @author Tom Elrod
*/
public class CallbackTestServer extends ServerTestCase
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5411;
private String locatorURI = transport + "://" + host + ":" + port + "/?" + ServerInvokerCallbackHandler.CALLBACK_STORE_KEY +
"=" + BlockingCallbackStore.class.getName();
private Connector connector;
// String to be returned from invocation handler upon client invocation calls.
private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation";
public void setupServer() throws Exception
{
InvokerLocator locator = new InvokerLocator(locatorURI);
System.out.println("Starting remoting server with locator uri of: " + locatorURI);
connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
connector.create();
CallbackInvocationHandler invocationHandler = new CallbackInvocationHandler();
// first parameter is sub-system name. can be any String value.
connector.addInvocationHandler("sample", invocationHandler);
connector.start();
}
public void setUp() throws Exception
{
setupServer();
}
public void tearDown() throws Exception
{
if (connector != null)
{
connector.stop();
connector.destroy();
}
}
public static void main(String[] args)
{
CallbackTestServer server = new CallbackTestServer();
try
{
server.setUp();
Thread.sleep(600000);
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
././@LongLink 0000000 0000000 0000000 00000000154 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000755 0001750 0001750 00000000000 11632407042 033354 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000212 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/JBossASCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000017664 10433770344 033402 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.callbackstore;
import org.jboss.remoting.Client;
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.samples.callback.CallbackServer;
import org.jboss.remoting.transport.Connector;
import java.util.List;
/**
* @author Tom Elrod
*/
public class JBossASCallbackTestClient
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5412;
private String locatorURI = null;
private Client remotingClient;
private CallbackHandler pullCallbackHandler;
private boolean isCallbackDone = false;
private int numberOfCallbacks = 520;
public JBossASCallbackTestClient(String name, String locatorURI)
{
this.locatorURI = locatorURI;
}
public void createRemotingClient() throws Exception
{
InvokerLocator locator = new InvokerLocator(locatorURI);
System.out.println("Calling remoting server with locator uri of: " + locatorURI);
// This could have been new Client(locator), but want to show that subsystem param is null
// Could have also been new Client(locator, "sample");
remotingClient = new Client(locator);
remotingClient.connect();
}
public void makeInvocation(String param) throws Throwable
{
Object response = remotingClient.invoke(param, null);
System.out.println("Invocation response: " + response);
}
public void testPullCallback() throws Throwable
{
createRemotingClient();
numberOfCallbacks = calculateNumberOfCallbacks();
System.out.println("Number of callbacks need to activate persitence: " + numberOfCallbacks);
pullCallbackHandler = new CallbackHandler();
// by passing only the callback handler, will indicate pull callbacks
remotingClient.addListener(pullCallbackHandler);
// need to tell server handler how many
makeInvocation("" + numberOfCallbacks);
// now make invocation on server, which should cause a callback to happen
makeInvocation("Do something");
boolean didItWork = checkForCallback();
System.out.println("Did id work = " + didItWork);
int totalCallbacks = 0;
if(didItWork)
{
boolean gotExpectedException = false;
// now need to go get the callbacks until none left.
int callbacksReceived = getAllCallbacks(pullCallbackHandler);
System.out.println("callbacks received = " + callbacksReceived);
totalCallbacks = totalCallbacks + callbacksReceived;
}
System.out.println("total callbacks received: " + totalCallbacks);
System.out.println("total callbacks expected: " + numberOfCallbacks);
remotingClient.removeListener(pullCallbackHandler);
remotingClient.disconnect();
remotingClient = null;
}
/**
* calculate how many 102400 byte callback messages it will take to consume 30%
* of the vm's memory. The CallbackInvocationHandler will take care of consuming 70%
* so need to make sure we have enough callbacks to trigger persistence.
*/
private int calculateNumberOfCallbacks()
{
long max = Runtime.getRuntime().maxMemory();
int targetMem = (int) (max * 0.3);
int num = targetMem / 102400;
return num;
}
private int getAllCallbacks(CallbackHandler pullCallbackHandler) throws Throwable
{
int counter = 0;
List callbacks = null;
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
while(callbacks.size() > 0)
{
System.out.println("callbacks.size() = " + callbacks.size());
counter = counter + callbacks.size();
for(int i = 0; i < callbacks.size(); i++)
{
((Callback) callbacks.get(i)).getCallbackObject();
}
// need to give time for server to clean up mem
Thread.currentThread().sleep(2000);
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
}
return counter;
}
private boolean checkForCallback() throws Throwable
{
boolean isComplete = false;
int waitPeriod = 5000;
while(true)
{
//isComplete = pushCallbackHandler.isComplete();
isComplete = ((Boolean) remotingClient.invoke("getdone")).booleanValue();
if(!isComplete)
{
try
{
Thread.currentThread().sleep(waitPeriod);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
else
{
break;
}
}
return isComplete;
}
public void setupServer(InvokerLocator locator) throws Exception
{
System.out.println("Starting remoting server with locator uri of: " + locator);
Connector connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
connector.start();
CallbackServer.SampleInvocationHandler invocationHandler = new CallbackServer.SampleInvocationHandler();
// first parameter is sub-system name. can be any String value.
connector.addInvocationHandler("sample", invocationHandler);
}
/**
* Can pass transport and port to be used as parameters.
* Valid transports are 'rmi' and 'socket'.
*
* @param args
*/
public static void main(String[] args)
{
if(args != null && args.length == 2)
{
transport = args[0];
port = Integer.parseInt(args[1]);
}
String locatorURI = transport + "://" + host + ":" + port;
JBossASCallbackTestClient client = new JBossASCallbackTestClient(JBossASCallbackTestClient.class.getName(), locatorURI);
try
{
client.testPullCallback();
}
catch(Throwable e)
{
e.printStackTrace();
System.exit(1);
}
System.exit(0);
}
public class PushCallbackHandler extends CallbackHandler
{
}
public class CallbackHandler implements InvokerCallbackHandler
{
boolean isComplete = false;
/**
* Will take the callback message and send back to client.
* If client locator is null, will store them till client polls to get them.
*
* @param callback
* @throws org.jboss.remoting.callback.HandleCallbackException
*
*/
public void handleCallback(Callback callback) throws HandleCallbackException
{
System.out.println("Received callback value of: " + callback.getCallbackObject());
System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject());
System.out.println("Received callback server invoker of: " + callback.getServerLocator());
isComplete = true;
}
public boolean isComplete()
{
return isComplete;
}
}
} ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/jbossSerialization/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000755 0001750 0001750 00000000000 11632407042 033354 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000241 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/jbossSerialization/CallbackStoreCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000004765 10535452155 033400 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.callbackstore.jbossSerialization;
import org.apache.log4j.Level;
import org.jboss.jrunit.harness.TestDriver;
/**
* Tests use of JBoss serialization by CallbackStore.
*
* @author Tom Elrod
* @author Ron Sigal
*/
public class CallbackStoreCallbackTestCase extends TestDriver
{
public void declareTestClasses()
{
addTestClasses(CallbackTestClient.class.getName(),
1,
CallbackTestServer.class.getName());
}
protected Level getTestLogLevel()
{
return Level.DEBUG;
}
/**
* How long to wait for test results to be returned from the client(s). If goes longer than the
* specified limit, will throw an exception and kill the running test cases. Default value is
* RESULTS_TIMEOUT.
*
* @return
*/
protected long getResultsTimeout()
{
return 600000;
}
/**
* How long for the server test case to wait for tear down message. If exceeds timeout,
* will throw exception. The default value is TEARDOWN_TIMEOUT.
*
* @return
*/
protected long getTearDownTimeout()
{
return 600000;
}
/**
* How long to allow each of the test cases to run their tests. If exceeds this timeout
* will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
*
* @return
*/
protected long getRunTestTimeout()
{
return 600000;
}
} ././@LongLink 0000000 0000000 0000000 00000000226 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/jbossSerialization/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000003301 10513327267 033362 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.callbackstore.jbossSerialization;
import org.jboss.remoting.InvokerLocator;
/**
*
* @author Tom Elrod
* @author Ron Sigal
*/
public class CallbackTestClient extends org.jboss.test.remoting.callback.pull.memory.callbackstore.CallbackTestClient
{
protected String getInvokerLocatorURI()
{
String baseLocatorURI = super.getInvokerLocatorURI();
if (baseLocatorURI.indexOf("/?") == -1)
return baseLocatorURI + "/?" + InvokerLocator.SERIALIZATIONTYPE + "=jboss";
else
return baseLocatorURI + "&" + InvokerLocator.SERIALIZATIONTYPE + "=jboss";
}
}
././@LongLink 0000000 0000000 0000000 00000000226 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/jbossSerialization/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000003744 10513327267 033375 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.callbackstore.jbossSerialization;
import org.jboss.remoting.InvokerLocator;
/**
* @author Tom Elrod
* @author Ron Sigal
*/
public class CallbackTestServer
extends org.jboss.test.remoting.callback.pull.memory.callbackstore.CallbackTestServer
{
protected String getInvokerLocatorURI()
{
String baseLocatorURI = super.getInvokerLocatorURI();
if (baseLocatorURI.indexOf("/?") == -1)
return baseLocatorURI + "/?" + InvokerLocator.SERIALIZATIONTYPE + "=jboss";
else
return baseLocatorURI + "&" + InvokerLocator.SERIALIZATIONTYPE + "=jboss";
}
public static void main(String[] args)
{
CallbackTestServer server = new CallbackTestServer();
try
{
server.setUp();
Thread.sleep(600000);
server.tearDown();
}
catch(Exception e)
{
e.printStackTrace();
}
}
} ././@LongLink 0000000 0000000 0000000 00000000216 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/CallbackStoreCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000005223 10535452155 033366 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.callbackstore;
import org.apache.log4j.Level;
import org.jboss.jrunit.harness.TestDriver;
/**
* This should be used as the main test case for the invoker client/server.
* It will start one instance of the client and one of the server and will
* gather the test results and report them in standard JUnit format. When
* wanting to run JUnit test for invoker, this is the class to use.
*
* @author Tom Elrod
*/
public class CallbackStoreCallbackTestCase extends TestDriver
{
public void declareTestClasses()
{
addTestClasses(CallbackTestClient.class.getName(),
1,
CallbackTestServer.class.getName());
}
protected Level getTestLogLevel()
{
return Level.DEBUG;
}
/**
* How long to wait for test results to be returned from the client(s). If goes longer than the
* specified limit, will throw an exception and kill the running test cases. Default value is
* RESULTS_TIMEOUT.
*
* @return
*/
protected long getResultsTimeout()
{
return 600000;
}
/**
* How long for the server test case to wait for tear down message. If exceeds timeout,
* will throw exception. The default value is TEARDOWN_TIMEOUT.
*
* @return
*/
protected long getTearDownTimeout()
{
return 600000;
}
/**
* How long to allow each of the test cases to run their tests. If exceeds this timeout
* will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
*
* @return
*/
protected long getRunTestTimeout()
{
return 600000;
}
} ././@LongLink 0000000 0000000 0000000 00000000203 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000017363 10513327042 033366 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.callbackstore;
import junit.framework.TestCase;
import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import java.util.List;
/**
* @author Tom Elrod
*/
public class CallbackTestClient extends TestCase
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5412;
private String locatorURI = transport + "://" + host + ":" + port;
private Client remotingClient;
private CallbackHandler pullCallbackHandler;
private boolean isCallbackDone = false;
private int numberOfCallbacks = 520;
private static final Logger log = Logger.getLogger(CallbackTestClient.class);
public void createRemotingClient() throws Exception
{
InvokerLocator locator = new InvokerLocator(getInvokerLocatorURI());
System.out.println("Calling remoting server with locator uri of: " + getInvokerLocatorURI());
// This could have been new Client(locator), but want to show that subsystem param is null
// Could have also been new Client(locator, "sample");
remotingClient = new Client(locator);
remotingClient.connect();
}
protected String getInvokerLocatorURI()
{
return locatorURI;
}
public void makeInvocation(String param) throws Throwable
{
Object response = remotingClient.invoke(param, null);
System.out.println("Invocation response: " + response);
}
public void setUp() throws Exception
{
createRemotingClient();
}
public void tearDown() throws Exception
{
if(remotingClient != null)
{
if(pullCallbackHandler != null)
{
try
{
remotingClient.removeListener(pullCallbackHandler);
}
catch(Throwable throwable)
{
throw new Exception(throwable);
}
}
remotingClient.disconnect();
}
}
public void testPullCallback() throws Throwable
{
numberOfCallbacks = calculateNumberOfCallbacks();
System.out.println("Number of callbacks need to activate persitence: " + numberOfCallbacks);
pullCallbackHandler = new CallbackHandler();
// by passing only the callback handler, will indicate pull callbacks
remotingClient.addListener(pullCallbackHandler);
// need to tell server handler how many
makeInvocation("" + numberOfCallbacks);
// now make invocation on server, which should cause a callback to happen
makeInvocation("Do something");
boolean didItWork = checkForCallback();
System.out.println("Did it work = " + didItWork);
log.debug("Did it work = " + didItWork);
int totalCallbacks = 0;
if(didItWork)
{
// now need to go get the callbacks until none left.
int callbacksReceived = getAllCallbacks(pullCallbackHandler);
System.out.println("callbacks received = " + callbacksReceived);
log.debug("callbacks received = " + callbacksReceived);
totalCallbacks = totalCallbacks + callbacksReceived;
}
System.out.println("total callbacks received: " + totalCallbacks);
log.debug("total callbacks received: " + totalCallbacks);
System.out.println("total callbacks expected: " + numberOfCallbacks);
log.debug("total callbacks expected: " + numberOfCallbacks);
assertEquals(numberOfCallbacks, totalCallbacks);
}
/**
* calculate how many 102400 byte callback messages it will take to consume 30%
* of the vm's memory. The CallbackInvocationHandler will take care of consuming 70%
* so need to make sure we have enough callbacks to trigger persistence.
*/
private int calculateNumberOfCallbacks()
{
long max = Runtime.getRuntime().maxMemory();
int targetMem = (int) (max * 0.1);
int num = targetMem / 102400;
return num;
}
private int getAllCallbacks(CallbackHandler pullCallbackHandler) throws Throwable
{
int counter = 0;
List callbacks = null;
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
while(callbacks.size() > 0)
{
System.out.println("callbacks.size() = " + callbacks.size());
counter = counter + callbacks.size();
for(int i = 0; i < callbacks.size(); i++)
{
((Callback) callbacks.get(i)).getCallbackObject();
}
// need to give time for server to clean up mem
Thread.currentThread().sleep(2000);
callbacks = remotingClient.getCallbacks(pullCallbackHandler);
}
return counter;
}
private boolean checkForCallback() throws Throwable
{
boolean isComplete = false;
int waitPeriod = 1000;
int numOfWaits = 600000;
for(int x = 0; x < numOfWaits; x++)
{
//isComplete = pushCallbackHandler.isComplete();
isComplete = ((Boolean) remotingClient.invoke("getdone")).booleanValue();
if(!isComplete)
{
try
{
Thread.currentThread().sleep(waitPeriod);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
}
else
{
break;
}
}
return isComplete;
}
public static void main(String[] args)
{
CallbackTestClient client = new CallbackTestClient();
try
{
client.setUp();
client.testPullCallback();
client.tearDown();
}
catch(Throwable throwable)
{
throwable.printStackTrace();
}
}
public class PushCallbackHandler extends CallbackHandler
{
}
public class CallbackHandler implements InvokerCallbackHandler
{
boolean isComplete = false;
/**
* Will take the callback message and send back to client.
* If client locator is null, will store them till client polls to get them.
*
* @param callback
* @throws org.jboss.remoting.callback.HandleCallbackException
*
*/
public void handleCallback(Callback callback) throws HandleCallbackException
{
System.out.println("Received callback value of: " + callback.getCallbackObject());
System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject());
System.out.println("Received callback server invoker of: " + callback.getServerLocator());
isComplete = true;
}
public boolean isComplete()
{
return isComplete;
}
}
} ././@LongLink 0000000 0000000 0000000 00000000203 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000006573 10513327042 033367 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.callbackstore;
import org.jboss.jrunit.extensions.ServerTestCase;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.callback.CallbackStore;
import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
import org.jboss.remoting.transport.Connector;
import org.jboss.test.remoting.callback.pull.memory.CallbackInvocationHandler;
/**
* Simple remoting server. Uses inner class SampleInvocationHandler
* as the invocation target handler class.
*
* @author Tom Elrod
*/
public class CallbackTestServer extends ServerTestCase
{
// Default locator values
private static String transport = "socket";
private static String host = "localhost";
private static int port = 5412;
private String locatorURI = transport + "://" + host + ":" + port + "/?" + ServerInvokerCallbackHandler.CALLBACK_STORE_KEY +
"=" + CallbackStore.class.getName();
private Connector connector;
// String to be returned from invocation handler upon client invocation calls.
private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation";
public void setupServer() throws Exception
{
InvokerLocator locator = new InvokerLocator(getInvokerLocatorURI());
System.out.println("Starting remoting server with locator uri of: " + getInvokerLocatorURI());
connector = new Connector();
connector.setInvokerLocator(locator.getLocatorURI());
connector.create();
CallbackInvocationHandler invocationHandler = new CallbackInvocationHandler();
// first parameter is sub-system name. can be any String value.
connector.addInvocationHandler("sample", invocationHandler);
connector.start();
}
protected String getInvokerLocatorURI()
{
return locatorURI;
}
public void setUp() throws Exception
{
setupServer();
}
public void tearDown() throws Exception
{
if(connector != null)
{
connector.stop();
connector.destroy();
}
}
public static void main(String[] args)
{
CallbackTestServer server = new CallbackTestServer();
try
{
server.setUp();
Thread.currentThread().sleep(600000);
server.tearDown();
}
catch(Exception e)
{
e.printStackTrace();
}
}
} ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/nonserializable/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000755 0001750 0001750 00000000000 11632407042 033354 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000240 00000000000 011561 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/nonserializable/NonserializableCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000010316 10513326455 033364 0 ustar twerner twerner /*
* 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.remoting.callback.pull.memory.callbackstore.nonserializable;
import java.io.NotSerializableException;
import java.util.HashMap;
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.CallbackStore;
import junit.framework.TestCase;
/**
* @author Ron Sigal
* @version $Revision: 1483 $
* * Copyright Oct 11, 2006 *
*/ public class NonserializableCallbackTestCase extends TestCase { private static Logger log = Logger.getLogger(NonserializableCallbackTestCase.class); private boolean passes = false; public void testNonserializableCallbackJavaSerialization() { log.info("entering " + getName()); CallbackStore store = null; try { store = new CallbackStore(); HashMap config = new HashMap(); String path = getClass().getResource(".").getPath(); config.put(CallbackStore.FILE_PATH_KEY, path); store.setConfig(config); store.start(); Callback callback = new Callback(new NonserializablePayload(7)); try { store.add(callback); fail(); } catch (NotSerializableException e) { log.info("got expected exception"); } catch (Exception e) { log.error(e); e.printStackTrace(); fail(); } passes = true; } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } finally { store.purgeFiles(); store.stop(); if (passes) log.info(getName() + " PASSES"); else log.info(getName() + " FAILS"); } } public void testNonserializableCallbackJBossSerialization() { log.info("entering " + getName()); CallbackStore store = null; try { store = new CallbackStore(); HashMap config = new HashMap(); String path = getClass().getResource(".").getPath(); config.put(CallbackStore.FILE_PATH_KEY, path); config.put(InvokerLocator.SERIALIZATIONTYPE, "jboss"); store.setConfig(config); store.start(); Object payload = new NonserializablePayload(11); Callback callback = new Callback(payload); try { store.add(callback); } catch (Exception e) { log.error(e); e.printStackTrace(); fail(); } Callback retrievedCallback = (Callback) store.getNext(); Object retrievedPayload = retrievedCallback.getParameter(); assertTrue(payload.equals(retrievedPayload)); passes = true; } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } finally { store.purgeFiles(); store.stop(); if (passes) log.info(getName() + " PASSES"); else log.info(getName() + " FAILS"); } } } ././@LongLink 0000000 0000000 0000000 00000000227 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/nonserializable/NonserializablePayload.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644 0001750 0001750 00000003154 10513326455 033366 0 ustar twerner twerner /* * 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.remoting.callback.pull.memory.callbackstore.nonserializable; /** * @author Ron Sigal * @version $Revision: 1483 $ ** Copyright Oct 11, 2006 *
*/ public class NonserializablePayload { private int secret; public NonserializablePayload() { } public NonserializablePayload(int secret) { this.secret = secret; } public boolean equals(Object o) { if (o == null) return false; if (!(o instanceof NonserializablePayload)) return false; return this.secret == ((NonserializablePayload)o).secret; } } ././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackTestCl0000644 0001750 0001750 00000007726 10445574363 033330 0 ustar twerner twerner package org.jboss.test.remoting.callback.pull; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import java.util.List; /** * Tests that two separate clients with separate callback listeners * can be distinguished on the server and given different callback messages. * * @author Tom Elrod */ public class CallbackTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5411; private String locatorURI = transport + "://" + host + ":" + port; private Client remotingClient; private CallbackHandler pullCallbackHandler; private Client remotingClient2; private CallbackHandler pullCallbackHandler2; public void createRemotingClient() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); remotingClient2 = new Client(locator); remotingClient2.connect(); } public void setUp() throws Exception { createRemotingClient(); } public void tearDown() throws Exception { if(remotingClient != null) { if(pullCallbackHandler != null) { try { remotingClient.removeListener(pullCallbackHandler); } catch(Throwable throwable) { throw new Exception(throwable); } } remotingClient.disconnect(); } if(remotingClient2 != null) { if(pullCallbackHandler2 != null) { try { remotingClient2.removeListener(pullCallbackHandler2); } catch(Throwable throwable) { throw new Exception(throwable); } } remotingClient2.disconnect(); } } public void testPullCallback() throws Throwable { pullCallbackHandler = new CallbackHandler(); pullCallbackHandler2 = new CallbackHandler(); // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(pullCallbackHandler); remotingClient2.addListener(pullCallbackHandler2); // now make invocation on server, which should cause a callback to happen remotingClient.invoke("Do something"); remotingClient2.invoke("Do something"); Thread.sleep(5000); List callbacks = remotingClient.getCallbacks(pullCallbackHandler); List callbacks2 = remotingClient2.getCallbacks(pullCallbackHandler2); boolean callbackWorked = false; if(callbacks != null && callbacks.size() > 0) { for(int x = 0; x < callbacks.size(); x++) { Callback c = (Callback)callbacks.get(x); callbackWorked = c.getCallbackObject().equals(remotingClient.getSessionId()); if(!callbackWorked) { break; } } } assertTrue(callbackWorked); boolean callbackWorked2 = false; if(callbacks2 != null && callbacks2.size() > 0) { for(int x = 0; x < callbacks2.size(); x++) { Callback c = (Callback)callbacks2.get(x); callbackWorked2 = c.getCallbackObject().equals(remotingClient2.getSessionId()); if(!callbackWorked2) { break; } } } assertTrue(callbackWorked2); } public class CallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { } } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackPollerShutdownTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackPoller0000644 0001750 0001750 00000033454 10713023462 033347 0 ustar twerner twerner /* * 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.remoting.callback.pull; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.CallbackListener; import org.jboss.remoting.callback.CallbackPoller; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.util.id.GUID; /** * Verifies that CallbackPoller shuts down when max error count is exceeded. * * @author Ron Sigal * @version $Revision: 2903 $ ** Copyright June 18, 2007 *
*/ public class CallbackPollerShutdownTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(CallbackPollerShutdownTestCase.class); private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private SampleInvocationHandler invocationHandler; /** * Sets up target remoting server. */ public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } /** * Shuts down the server */ public void tearDown() { if (connector != null) { connector.stop(); connector.destroy(); } } /** * Verifies that CallbackPoller in blocking mode shuts down after max error * count has been exceeded. */ public void testBlockingCallbackPoller() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Add callback handler. SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(client); Map metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); metadata.put(ServerInvoker.BLOCKING_TIMEOUT, "500"); metadata.put(CallbackPoller.MAX_ERROR_COUNT, "4"); client.addListener(callbackHandler, metadata); log.info("client added callback handler for pull callbacks"); // Test for good connection. assertEquals("abc", client.invoke("abc")); // Give time for CallbackPoller$AcknowledgeThread to start. Thread.sleep(2000); // Get necessary fields. Field field = Client.class.getDeclaredField("callbackPollers"); field.setAccessible(true); Map callbackPollers = (Map) field.get(client); assertEquals(1, callbackPollers.size()); CallbackPoller poller = (CallbackPoller) callbackPollers.values().iterator().next(); field.setAccessible(true); Class[] classes = CallbackPoller.class.getDeclaredClasses(); Class handleThreadClass = null; Class acknowledgeThreadClass = null; for (int i = 0; i < classes.length; i++) { Class c = classes[i]; log.info(c.getName()); String fqn = c.getName(); String name = fqn.substring(fqn.indexOf('$') + 1); log.info(name); if ("HandleThread".equals(name)) handleThreadClass = c; else if ("AcknowledgeThread".equals(name)) acknowledgeThreadClass = c; } assertNotNull(handleThreadClass); assertNotNull(acknowledgeThreadClass); field = CallbackPoller.class.getDeclaredField("handleThread"); field.setAccessible(true); Thread handleThread = (Thread) field.get(poller); log.info("handleThread: " + handleThread); field = CallbackPoller.class.getDeclaredField("acknowledgeThread"); field.setAccessible(true); Thread acknowledgeThread = (Thread) field.get(poller); log.info("acknowledgeThread: " + handleThread); connector.stop(); // Wait for CallbackPoller to shut down. Thread.sleep(6000); field = handleThreadClass.getDeclaredField("done"); field.setAccessible(true); boolean handleThreadDone = ((Boolean) field.get(handleThread)).booleanValue(); field = acknowledgeThreadClass.getDeclaredField("done"); field.setAccessible(true); boolean acknowledgeThreadDone = ((Boolean) field.get(acknowledgeThread)).booleanValue(); field = CallbackPoller.class.getDeclaredField("running"); field.setAccessible(true); boolean pollerRunning = ((Boolean) field.get(poller)).booleanValue(); assertTrue(handleThreadDone); assertTrue(acknowledgeThreadDone); assertFalse(pollerRunning); client.setDisconnectTimeout(0); client.removeListener(callbackHandler); client.disconnect(); } /** * Verifies that CallbackPoller in nonblocking mode shuts down after max error * count has been exceeded. */ public void testNonBlockingCallbackPoller() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Add callback handler. SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(client); Map metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "500"); metadata.put(ServerInvoker.BLOCKING_TIMEOUT, "500"); metadata.put(CallbackPoller.MAX_ERROR_COUNT, "4"); client.addListener(callbackHandler, metadata); log.info("client added callback handler for pull callbacks"); // Test for good connection. assertEquals("abc", client.invoke("abc")); // Give time for CallbackPoller$AcknowledgeThread to start. Thread.sleep(2000); // Get necessary fields. Field field = Client.class.getDeclaredField("callbackPollers"); field.setAccessible(true); Map callbackPollers = (Map) field.get(client); assertEquals(1, callbackPollers.size()); CallbackPoller poller = (CallbackPoller) callbackPollers.values().iterator().next(); field.setAccessible(true); Class[] classes = CallbackPoller.class.getDeclaredClasses(); Class handleThreadClass = null; Class acknowledgeThreadClass = null; for (int i = 0; i < classes.length; i++) { Class c = classes[i]; log.info(c.getName()); String fqn = c.getName(); String name = fqn.substring(fqn.indexOf('$') + 1); log.info(name); if ("HandleThread".equals(name)) handleThreadClass = c; else if ("AcknowledgeThread".equals(name)) acknowledgeThreadClass = c; } assertNotNull(handleThreadClass); assertNotNull(acknowledgeThreadClass); field = CallbackPoller.class.getDeclaredField("handleThread"); field.setAccessible(true); Thread handleThread = (Thread) field.get(poller); log.info("handleThread: " + handleThread); field = CallbackPoller.class.getDeclaredField("acknowledgeThread"); field.setAccessible(true); Thread acknowledgeThread = (Thread) field.get(poller); log.info("acknowledgeThread: " + handleThread); connector.stop(); // Wait for CallbackPoller to shut down. Thread.sleep(4000); field = handleThreadClass.getDeclaredField("done"); field.setAccessible(true); boolean handleThreadDone = ((Boolean) field.get(handleThread)).booleanValue(); field = acknowledgeThreadClass.getDeclaredField("done"); field.setAccessible(true); boolean acknowledgeThreadDone = ((Boolean) field.get(acknowledgeThread)).booleanValue(); field = CallbackPoller.class.getDeclaredField("running"); field.setAccessible(true); boolean pollerRunning = ((Boolean) field.get(poller)).booleanValue(); assertTrue(handleThreadDone); assertTrue(acknowledgeThreadDone); assertFalse(pollerRunning); client.setDisconnectTimeout(0); client.removeListener(callbackHandler); client.disconnect(); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class SampleInvocationHandler implements ServerInvocationHandler, CallbackListener { public void addListener(InvokerCallbackHandler callbackHandler) { log.info("sending callback with request for acknowledgement"); HashMap returnPayload = new HashMap(); returnPayload.put(ServerInvokerCallbackHandler.CALLBACK_LISTENER, this); returnPayload.put(ServerInvokerCallbackHandler.CALLBACK_ID, new GUID()); returnPayload.put(ServerInvokerCallbackHandler.REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS, "true"); Callback callback = new Callback("callback"); callback.setReturnPayload(returnPayload); try { callbackHandler.handleCallback(callback); } catch (HandleCallbackException e) { e.printStackTrace(); } } public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public void acknowledgeCallback(InvokerCallbackHandler callbackHandler, Object callbackId, Object response) { log.info(callbackId + " acknowledged"); } } static class SimpleCallbackHandler implements InvokerCallbackHandler { List callbacks = new ArrayList(); Client client; public SimpleCallbackHandler(Client client) { this.client = client; } public void handleCallback(Callback callback) throws HandleCallbackException { try { callbacks.add(callback); log.info("received callback"); } catch (Throwable t) { t.printStackTrace(); } } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/blocking/ 0000755 0001750 0001750 00000000000 11632407042 032332 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000201 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/blocking/BlockingPullCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/blocking/Block0000644 0001750 0001750 00000077223 10723066337 033332 0 ustar twerner twerner /* * 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.remoting.callback.pull.blocking; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.CallbackPoller; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Tests the blocking mode for pull callbacks. * * See JBREM-641. * * @author Ron Sigal * @version $Revision: 3015 $ ** Copyright May 2, 2007 *
*/ public class BlockingPullCallbackTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(BlockingPullCallbackTestCase.class); private static final String INVOCATION_TEST = "invocationTest"; private static final String CALLBACK_TEST = "callbackTest"; private static final String COUNTER = "counter"; private static final String CALLBACK_DELAY_KEY = "callbackDelay"; private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private SampleInvocationHandler invocationHandler; /** * Sets up target remoting server. */ public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } /** * Shuts down the server */ public void tearDown() { if (connector != null) { connector.stop(); connector.destroy(); } } /** * Tests blocking and nonblocking direct calls to Client.getCallbacks(). */ public void testBlockingPullCallback() throws Throwable { log.info("entering " + getName()); int CALLBACK_DELAY = 5000; // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler); log.info("client added callback handler for pull callbacks"); // Test for good connection. Integer count = new Integer(17); HashMap metadata = new HashMap(); metadata.put(COUNTER, count); Integer response = (Integer) client.invoke(INVOCATION_TEST, metadata); assertEquals(17, response.intValue()); log.info("client.invoke(INVOCATION_TEST, metadata) successful"); // Test nonblocking callbacks. HashMap pullerMetadata = new HashMap(); pullerMetadata.put(CALLBACK_DELAY_KEY, Integer.toString(CALLBACK_DELAY)); pullerMetadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); CallbackPuller puller = new CallbackPuller(client, callbackHandler, pullerMetadata); puller.start(); Thread.sleep(2000); // Should have received empty list of callbacks. assertTrue(puller.done); assertNotNull(puller.callbacks); assertTrue(puller.callbacks.isEmpty()); // Drain stored callback. Thread.sleep(CALLBACK_DELAY); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); List callbacks = client.getCallbacks(callbackHandler, metadata); assertNotNull(callbacks); assertEquals(1, callbacks.size()); // Test blocking callbacks. pullerMetadata.clear(); pullerMetadata.put(CALLBACK_DELAY_KEY, Integer.toString(CALLBACK_DELAY)); pullerMetadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); pullerMetadata.put(ServerInvoker.BLOCKING_TIMEOUT, Integer.toString(CALLBACK_DELAY * 2)); puller = new CallbackPuller(client, callbackHandler, pullerMetadata); puller.start(); Thread.sleep(2000); assertFalse(puller.done); // Should not have returned from getCallbacks() yet. assertNull(puller.callbacks); Thread.sleep(CALLBACK_DELAY); assertTrue(puller.done); assertNotNull(puller.callbacks); assertEquals(1, puller.callbacks.size()); client.removeListener(callbackHandler); client.disconnect(); } /** * Tests configuration of blocking timeout in server configuration map. */ public void testBlockingPullCallbackServerConfiguration() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); int blockingTimeout = ServerInvoker.DEFAULT_BLOCKING_TIMEOUT + 2000; config.put(ServerInvoker.BLOCKING_TIMEOUT, Integer.toString(blockingTimeout)); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler); log.info("client added callback handler for pull callbacks"); // Test for good connection. Integer count = new Integer(17); HashMap metadata = new HashMap(); metadata.put(COUNTER, count); Integer response = (Integer) client.invoke(INVOCATION_TEST, metadata); assertEquals(17, response.intValue()); log.info("client.invoke(INVOCATION_TEST, metadata) successful"); // Test blocking callbacks. // // Set CALLBACK_DELAY == default blocking timeout + 1000. If the default blocking // timeout were in effect, Client.getCallbacks() would time out and return without // getting a callback. int CALLBACK_DELAY = blockingTimeout - 1000; Map pullerMetadata = new HashMap(); pullerMetadata.put(CALLBACK_DELAY_KEY, Integer.toString(CALLBACK_DELAY)); pullerMetadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); CallbackPuller puller = new CallbackPuller(client, callbackHandler, pullerMetadata); puller.start(); Thread.sleep(CALLBACK_DELAY - 1000); // Callback has not been created yet, so should not have returned from getCallbacks(). assertFalse(puller.done); assertNull(puller.callbacks); Thread.sleep(2000); // Callback has been created, so should have returned from getCallbacks(). assertTrue(puller.done); assertNotNull(puller.callbacks); assertEquals(1, puller.callbacks.size()); client.removeListener(callbackHandler); client.disconnect(); } /** * Tests configuration of blocking timeout by Client.addListener() metadata. * In this case, a CallbackPoller is created. */ public void testBlockingCallbackPollerInitialMetadataConfiguration() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); int serverBlockingTimeout = ServerInvoker.DEFAULT_BLOCKING_TIMEOUT + 2000; config.put(ServerInvoker.BLOCKING_TIMEOUT, Integer.toString(serverBlockingTimeout)); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test for good connection. Integer count = new Integer(17); HashMap metadata = new HashMap(); metadata.put(COUNTER, count); Integer response = (Integer) client.invoke(INVOCATION_TEST, metadata); assertEquals(17, response.intValue()); log.info("client.invoke(INVOCATION_TEST, metadata) successful"); // Test blocking callbacks. // // Reset blocking timeout to server blocking timeout + 2000, and set // CALLBACK_DELAY to server blocking timeout + 1000. If the server's blocking // timeout were in effect, Client.getCallbacks() would time out and return without // getting a callback. int clientBlockingTimeout = serverBlockingTimeout + 2000; int CALLBACK_DELAY = serverBlockingTimeout + 1000; metadata.clear(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); metadata.put(ServerInvoker.BLOCKING_TIMEOUT, Integer.toString(clientBlockingTimeout)); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, metadata); log.info("client added callback handler for pull callbacks"); // Create callback. CallbackCreator creator = new CallbackCreator(client, CALLBACK_DELAY); creator.start(); Thread.sleep(CALLBACK_DELAY - 1000); // Callback has not been created yet, so should not have returned from getCallbacks(). assertEquals(0, callbackHandler.callbacks.size()); Thread.sleep(2000); // Callback has been created, so should have returned from getCallbacks(). assertEquals(1, callbackHandler.callbacks.size()); client.removeListener(callbackHandler); client.disconnect(); } /** * Tests configuration of blocking timeout by Client.getCallbacks() metadata. */ public void testBlockingPullCallbackInvocationMetadataConfiguration() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); int serverBlockingTimeout = ServerInvoker.DEFAULT_BLOCKING_TIMEOUT + 2000; config.put(ServerInvoker.BLOCKING_TIMEOUT, Integer.toString(serverBlockingTimeout)); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler); log.info("client added callback handler for pull callbacks"); // Test for good connection. Integer count = new Integer(17); HashMap metadata = new HashMap(); metadata.put(COUNTER, count); Integer response = (Integer) client.invoke(INVOCATION_TEST, metadata); assertEquals(17, response.intValue()); log.info("client.invoke(INVOCATION_TEST, metadata) successful"); // Test blocking callbacks. // // Reset blocking timeout to server blocking timeout + 2000, and set // CALLBACK_DELAY to server blocking timeout + 1000. If the server's blocking // timeout were in effect, Client.getCallbacks() would time out and return without // getting a callback. int clientBlockingTimeout = serverBlockingTimeout + 2000; int CALLBACK_DELAY = serverBlockingTimeout + 1000; Map pullerMetadata = new HashMap(); pullerMetadata.put(CALLBACK_DELAY_KEY, Integer.toString(CALLBACK_DELAY)); pullerMetadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); pullerMetadata.put(ServerInvoker.BLOCKING_TIMEOUT, Integer.toString(clientBlockingTimeout)); CallbackPuller puller = new CallbackPuller(client, callbackHandler, pullerMetadata); puller.start(); Thread.sleep(CALLBACK_DELAY - 1000); // Callback has not been created yet, so should not have returned from getCallbacks(). assertFalse(puller.done); assertNull(puller.callbacks); Thread.sleep(2000); // Callback has been created, so should have returned from getCallbacks(). assertTrue(puller.done); assertNotNull(puller.callbacks); assertEquals(1, puller.callbacks.size()); client.removeListener(callbackHandler); client.disconnect(); } /** * Tests CallbackPoller in nonblocking mode. */ public void testNonBlockingCallbackPoller() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); int CALLBACK_DELAY = 5000; SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); Map metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, Integer.toString(CALLBACK_DELAY)); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); client.addListener(callbackHandler, metadata); log.info("client added callback handler for pull callbacks"); // Test for good connection. Integer count = new Integer(17); metadata.clear(); metadata = new HashMap(); metadata.put(COUNTER, count); Integer response = (Integer) client.invoke(INVOCATION_TEST, metadata); assertEquals(17, response.intValue()); log.info("client.invoke(INVOCATION_TEST, metadata) successful"); // Test nonblocking behavior. Thread.sleep(1000); // Callback will be created after CallbackPoller's first poll. CallbackCreator creator = new CallbackCreator(client, CALLBACK_DELAY); creator.start(); Thread.sleep(CALLBACK_DELAY); assertEquals(0, callbackHandler.callbacks.size()); Thread.sleep(2000); // CallbackPoller hasn't made second poll yet. assertEquals(0, callbackHandler.callbacks.size()); Thread.sleep(CALLBACK_DELAY); assertEquals(1, callbackHandler.callbacks.size()); client.removeListener(callbackHandler); client.disconnect(); } /** * Tests CallbackPoller in blocking mode. */ public void testBlockingCallbackPoller() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); int CALLBACK_DELAY = 5000; SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); Map metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, Integer.toString(CALLBACK_DELAY)); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); client.addListener(callbackHandler, metadata); log.info("client added callback handler for pull callbacks"); // Test for good connection. Integer count = new Integer(17); metadata.clear(); metadata = new HashMap(); metadata.put(COUNTER, count); Integer response = (Integer) client.invoke(INVOCATION_TEST, metadata); assertEquals(17, response.intValue()); log.info("client.invoke(INVOCATION_TEST, metadata) successful"); // Test blocking behavior. CallbackCreator creator = new CallbackCreator(client, CALLBACK_DELAY); creator.start(); assertEquals(0, callbackHandler.callbacks.size()); Thread.sleep(CALLBACK_DELAY + 1000); assertEquals(1, callbackHandler.callbacks.size()); client.removeListener(callbackHandler); client.disconnect(); } /** * Tests blocking timeout set on server. */ public void testBlockingCallbackPollerShutdownServerConfig() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.BLOCKING_TIMEOUT, "4000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test for good connection. Integer count = new Integer(17); Map metadata = new HashMap(); metadata.clear(); metadata = new HashMap(); metadata.put(COUNTER, count); Integer response = (Integer) client.invoke(INVOCATION_TEST, metadata); assertEquals(17, response.intValue()); log.info("client.invoke(INVOCATION_TEST, metadata) successful"); // Register callback handler. Field field = Client.class.getDeclaredField("callbackPollers"); field.setAccessible(true); Map callbackPollers = (Map) field.get(client); final SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); client.addListener(callbackHandler, metadata); assertEquals(1, callbackPollers.size()); CallbackPoller callbackPoller = (CallbackPoller) callbackPollers.values().iterator().next(); field = CallbackPoller.class.getDeclaredField("blockingPollerThread"); field.setAccessible(true); Thread blockingPollerThread = (Thread) field.get(callbackPoller); assertNotNull(blockingPollerThread); log.info("client added callback handler for pull callbacks"); // Test blocking timeout. new Thread() { public void run() { try { client.removeListener(callbackHandler); } catch (Throwable e) { e.printStackTrace(); } } }.start(); Thread.sleep(6000); assertFalse(blockingPollerThread.isAlive()); client.removeListener(callbackHandler); client.disconnect(); } /** * Tests blocking timeout set on client. */ public void testBlockingCallbackPollerShutdownClientConfig() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.BLOCKING_TIMEOUT, "4000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test for good connection. Integer count = new Integer(17); Map metadata = new HashMap(); metadata.clear(); metadata = new HashMap(); metadata.put(COUNTER, count); Integer response = (Integer) client.invoke(INVOCATION_TEST, metadata); assertEquals(17, response.intValue()); log.info("client.invoke(INVOCATION_TEST, metadata) successful"); // Register callback handler. Field field = Client.class.getDeclaredField("callbackPollers"); field.setAccessible(true); Map callbackPollers = (Map) field.get(client); final SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); metadata.put(ServerInvoker.BLOCKING_TIMEOUT, "10000"); client.addListener(callbackHandler, metadata); assertEquals(1, callbackPollers.size()); CallbackPoller callbackPoller = (CallbackPoller) callbackPollers.values().iterator().next(); field = CallbackPoller.class.getDeclaredField("blockingPollerThread"); field.setAccessible(true); Thread blockingPollerThread = (Thread) field.get(callbackPoller); assertNotNull(blockingPollerThread); log.info("client added callback handler for pull callbacks"); // Test blocking timeout. new Thread() { public void run() { try { client.removeListener(callbackHandler); } catch (Throwable e) { e.printStackTrace(); } } }.start(); Thread.sleep(2000); assertTrue(blockingPollerThread.isAlive()); Thread.sleep(4000); assertTrue(blockingPollerThread.isAlive()); Thread.sleep(15000); assertFalse(blockingPollerThread.isAlive()); client.removeListener(callbackHandler); client.disconnect(); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class SampleInvocationHandler implements ServerInvocationHandler { public Set callbackHandlers = new HashSet(); private int counter = 0; public void addListener(InvokerCallbackHandler callbackHandler) { log.info("Adding callback listener."); callbackHandlers.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { Object payload = invocation.getParameter(); if (INVOCATION_TEST.equals(payload)) { Map requestMap = invocation.getRequestPayload(); Integer counter = (Integer) requestMap.get(COUNTER); return counter; } else if (CALLBACK_TEST.equals(payload)) { new Thread() { public void run() { try { Map requestMap = invocation.getRequestPayload(); int delay = Integer.parseInt((String) requestMap.get(CALLBACK_DELAY_KEY)); Thread.sleep(delay); Iterator it = callbackHandlers.iterator(); while (it.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) it.next(); log.info("sending callback: " + ++counter); callbackHandler.handleCallback(new Callback("callback")); } log.info("sent callback"); } catch (HandleCallbackException e) { log.error("Unable to send callback"); } catch (InterruptedException e) { e.printStackTrace(); } } }.start(); return null; } else { throw new Exception("unrecognized invocation: " + payload); } } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class SimpleCallbackHandler implements InvokerCallbackHandler { List callbacks = new ArrayList(); public void handleCallback(Callback callback) throws HandleCallbackException { callbacks.add(callback); log.info("received callback"); } } static class CallbackPuller extends Thread { Client client; InvokerCallbackHandler callbackHandler; Map metadata; List callbacks; boolean done; public CallbackPuller(Client client, InvokerCallbackHandler callbackHandler, Map metadata) { this.client = client; this.callbackHandler = callbackHandler; this.metadata = metadata; } public void run() { try { client.invoke(CALLBACK_TEST, metadata); log.info("back from client.invoke(CALLBACK_TEST, metadata)"); callbacks = client.getCallbacks(callbackHandler, metadata); log.info("callbacks count: " + callbacks.size()); done = true; } catch (Throwable e) { e.printStackTrace(); } } } static class CallbackCreator extends Thread { Client client; int delay; boolean done; public CallbackCreator(Client client,int delay) { this.client = client; this.delay = delay; } public void run() { try { HashMap metadata = new HashMap(); metadata.put(CALLBACK_DELAY_KEY, Integer.toString(delay)); client.invoke(CALLBACK_TEST, metadata); log.info("back from client.invoke(CALLBACK_TEST)"); done = true; } catch (Throwable e) { e.printStackTrace(); } } } } ././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackTestSe0000644 0001750 0001750 00000003661 10445574363 033333 0 ustar twerner twerner package org.jboss.test.remoting.callback.pull; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class CallbackTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5411; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector; // String to be returned from invocation handler upon client invocation calls. private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public void setupServer() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); CallbackInvocationHandler invocationHandler = new CallbackInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); connector.start(); } public void setUp() throws Exception { setupServer(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { CallbackTestServer server = new CallbackTestServer(); try { server.setUp(); Thread.sleep(6000000); } catch (Exception e) { e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/leak/ 0000755 0001750 0001750 00000000000 11632407042 030502 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000204 00000000000 011561 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/leak/ServerInvokerCallbackHandlerLeakTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/leak/ServerInvokerC0000644 0001750 0001750 00000021762 11413660476 033355 0 ustar twerner twerner /* * JBoss, Home of Professional Open Source. * Copyright 2009, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file 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.remoting.callback.leak; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.TimerTask; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionNotifier; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.LeasePinger; import org.jboss.remoting.MicroRemoteClientInvoker; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit tests for JBREM-1113. * * @author Ron Sigal * @version $Rev$ ** Copyright Apr 13, 2009 *
*/ public class ServerInvokerCallbackHandlerLeakTestCase extends TestCase { private static Logger log = Logger.getLogger(ServerInvokerCallbackHandlerLeakTestCase.class); private static boolean firstTime = true; private static int COUNT = 10; private static Object lock = new Object(); protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } TestConnectionListener.count = 0; } public void tearDown() { } public void testLeakWithCallbackHandlersListening() throws Throwable { doLeakTest(true); } public void testLeakWithoutCallbackHandlersListening() throws Throwable { doLeakTest(false); } public void doLeakTest(boolean registerCallbackListener) throws Throwable { log.info("entering " + getName()); setupServer(registerCallbackListener); // Get fields. ServerInvoker serverInvoker = connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("connectionNotifier"); field.setAccessible(true); ConnectionNotifier connectionNotifier = (ConnectionNotifier) field.get(serverInvoker); field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = null; for (int i = 0; i < COUNT; i++) { client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, null, null, true); } field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(client.getInvoker()); field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(pinger); timerTask.cancel(); synchronized(lock) { lock.wait(); } Thread.sleep(2000); assertEquals(COUNT, TestConnectionListener.count); assertEquals(1, connectionNotifier.size()); assertTrue(callbackHandlers.isEmpty()); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean registerCallbackListener) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?leasing=true"; if (registerCallbackListener) { locatorURI += "&" + ServerInvoker.REGISTER_CALLBACK_LISTENER + "=true"; } else { locatorURI += "&" + ServerInvoker.REGISTER_CALLBACK_LISTENER + "=false"; } serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); connector.setLeasePeriod(2000); TestConnectionListener listener = new TestConnectionListener(!registerCallbackListener); connector.addConnectionListener(listener); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { static public Set callbackHandlers = new HashSet(); public void addListener(InvokerCallbackHandler callbackHandler) { callbackHandlers.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); } } static class TestConnectionListener implements ConnectionListener { static public int count; boolean shutdownCallbackHandlers; public TestConnectionListener(boolean shutdownCallbackHandlers) { this.shutdownCallbackHandlers = shutdownCallbackHandlers; } public synchronized void handleConnectionException(Throwable throwable, Client client) { log.info("got connection exception"); if(++count == COUNT) { if (shutdownCallbackHandlers) { Iterator it = TestInvocationHandler.callbackHandlers.iterator(); while (it.hasNext()) { ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) it.next(); callbackHandler.shutdown(); log.info("shut down: " + callbackHandler); } TestInvocationHandler.callbackHandlers.clear(); } synchronized(lock) { lock.notify(); } } } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/ 0000755 0001750 0001750 00000000000 11632407041 031420 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/ 0000755 0001750 0001750 00000000000 11632407041 032676 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/CallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/Cal0000644 0001750 0001750 00000004510 10535452155 033327 0 ustar twerner twerner /* * JBoss, a division of Red Hat * Copyright 2006, Red Hat Middleware, LLC, 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.remoting.callback.multiple.client; import org.jboss.jrunit.harness.TestDriver; import org.apache.log4j.Level; /** * @author Tom Elrod */ public class CallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(CallbackTestClient.class.getName(), 1, CallbackTestServer.class.getName()); } protected Level getTestLogLevel() { return Level.DEBUG; } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/Cal0000644 0001750 0001750 00000025121 10537423164 033330 0 ustar twerner twerner package org.jboss.test.remoting.callback.multiple.client; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.transport.Connector; import org.jboss.logging.Logger; import javax.management.MBeanServer; import java.util.List; import java.util.Iterator; import java.util.ArrayList; /** * @author Tom Elrod */ public class CallbackTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector; private static final Logger log = Logger.getLogger(CallbackTestClient.class); public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void testPullCallback() throws Throwable { InvokerLocator locator = new InvokerLocator(locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); Client remotingClient2 = new Client(locator); remotingClient2.connect(); CallbackHandler callbackHandler = new CallbackHandler(); try { // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler); remotingClient2.addListener(callbackHandler); // now make invocation on server, which should cause a callback to happen Object response = remotingClient.invoke("Do something", null); response = remotingClient2.invoke("Do something", null); Thread.currentThread().sleep(1000); List callbacks = remotingClient.getCallbacks(callbackHandler); assertEquals(2, callbacks.size()); Iterator itr = callbacks.iterator(); while(itr.hasNext()) { Object obj = itr.next(); log.info("testPullCallback - Callback object should have been " + org.jboss.test.remoting.callback.CallbackTestServer.CALLBACK_VALUE + " and was " + (obj == null ? null : ((Callback) obj).getCallbackObject())); if(obj instanceof Callback) { assertEquals("Callback object is NOT same.", CallbackTestServer.CALLBACK_VALUE, ((Callback) obj).getCallbackObject()); } else { assertTrue("Callback object is NOT of type Callback.", false); } } callbacks = remotingClient2.getCallbacks(callbackHandler); assertEquals(2, callbacks.size()); itr = callbacks.iterator(); while(itr.hasNext()) { Object obj = itr.next(); log.info("testPullCallback - Callback object should have been " + org.jboss.test.remoting.callback.CallbackTestServer.CALLBACK_VALUE + " and was " + (obj == null ? null : ((Callback) obj).getCallbackObject())); if(obj instanceof Callback) { assertEquals("Callback object is NOT same.", CallbackTestServer.CALLBACK_VALUE, ((Callback) obj).getCallbackObject()); } else { assertTrue("Callback object is NOT of type Callback.", false); } } } catch(Throwable thr) { thr.printStackTrace(); throw thr; } finally { if(remotingClient != null) { // remove callback handler from server remotingClient.removeListener(callbackHandler); remotingClient.disconnect(); } if(remotingClient2 != null) { remotingClient2.removeListener(callbackHandler); remotingClient2.disconnect(); } } } public void testPushCallback() throws Throwable { CallbackTestClient.CallbackHandler callbackHandler = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); Client remotingClient2 = new Client(locator); remotingClient2.connect(); try { // Using loctor with port value one higher than the target server String callbackLocatorURI = transport + "://" + host + ":" + (port + 5); InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); log.info("testPushCallback - Setting up server."); // call to create remoting server to // receive client callbacks. setupServer(callbackLocator); // Callback handle object will be passed back as part of the callback object String callbackHandleObject = "myCallbackHandleObject"; log.info("testPushCallback - adding listener."); // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler, callbackLocator, callbackHandleObject); remotingClient2.addListener(callbackHandler, callbackLocator, callbackHandleObject); log.info("testPushCallback - make invocation"); // now make invocation on server, which should cause a callback to happen Object response = remotingClient.invoke("Do something", null); response = remotingClient2.invoke("Do something", null); // need to wait for brief moment so server can callback Thread.sleep(5000); int count = callbackHandler.getCallbackCount(); System.out.println("callback count = " + count); assertEquals(2, count); } finally { if(remotingClient != null) { // remove callback handler from server remotingClient.removeListener(callbackHandler); remotingClient.disconnect(); } if(remotingClient2 != null) { try { remotingClient2.removeListener(callbackHandler); } catch (Throwable throwable) { throwable.printStackTrace(); } remotingClient2.disconnect(); } } } public void setupServer(InvokerLocator locator) throws Exception { log.info("Starting remoting server with locator uri of: " + locator); try { connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); CallbackTestClient.SampleInvocationHandler invocationHandler = new CallbackTestClient.SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); } catch(Exception e) { log.error("Error starting callback server", e); throw e; } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback("This is the payload of callback invocation."); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } public class CallbackHandler implements InvokerCallbackHandler { private Callback callback; private int callbackNumber = 0; /** * Will take the callback message and send back to client. * If client locator is null, will store them till client polls to get them. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { callbackNumber++; this.callback = callback; System.out.println("Received callback value of: " + callback.getCallbackObject()); System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject()); System.out.println("Received callback server invoker of: " + callback.getServerLocator()); } public Callback getCallback() { return callback; } public int getCallbackCount() { return callbackNumber; } } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/Cal0000644 0001750 0001750 00000011353 10524710267 033331 0 ustar twerner twerner package org.jboss.test.remoting.callback.multiple.client; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.apache.log4j.Level; import javax.management.MBeanServer; import java.util.List; import java.util.ArrayList; import java.util.Iterator; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class CallbackTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector; // String to be returned from invocation handler upon client invocation calls. public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public static final String CALLBACK_VALUE = "This is the payload of callback invocation."; public void setupServer() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); CallbackTestServer.SampleInvocationHandler invocationHandler = new CallbackTestServer.SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); } protected void setUp() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { CallbackTestServer server = new CallbackTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback(CALLBACK_VALUE); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); callbackHandler.handleCallback(callback); } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } } ././@LongLink 0000000 0000000 0000000 00000000160 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTe0000644 0001750 0001750 00000004330 10535704450 033335 0 ustar twerner twerner /* * JBoss, a division of Red Hat * Copyright 2006, Red Hat Middleware, LLC, 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.remoting.callback.multiple; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class CallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(CallbackTestClient.class.getName(), 1, CallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/ 0000755 0001750 0001750 00000000000 11632407041 032726 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/CallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/Cal0000644 0001750 0001750 00000004510 10535452155 033357 0 ustar twerner twerner /* * JBoss, a division of Red Hat * Copyright 2006, Red Hat Middleware, LLC, 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.remoting.callback.multiple.server; import org.jboss.jrunit.harness.TestDriver; import org.apache.log4j.Level; /** * @author Tom Elrod */ public class CallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(CallbackTestClient.class.getName(), 1, CallbackTestServer.class.getName()); } protected Level getTestLogLevel() { return Level.DEBUG; } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/Cal0000644 0001750 0001750 00000016463 10524710267 033370 0 ustar twerner twerner package org.jboss.test.remoting.callback.multiple.server; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * @author Tom Elrod */ public class CallbackTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector; private Connector connector2; private static final Logger log = Logger.getLogger(CallbackTestClient.class); public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } if (connector2 != null) { connector2.stop(); connector2.destroy(); } } public void testPushCallback() throws Throwable { CallbackTestClient.CallbackHandler callbackHandler = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); try { // Using loctor with port value one higher than the target server String callbackLocatorURI = transport + "://" + host + ":" + (port + 5); InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); String callbackLocatorURI2 = transport + "://" + host + ":" + (port + 10); InvokerLocator callbackLocator2 = new InvokerLocator(callbackLocatorURI2); log.info("testPushCallback - Setting up server."); // call to create remoting server to // receive client callbacks. connector = new Connector(); connector.setInvokerLocator(callbackLocator.getLocatorURI()); connector.start(); CallbackTestClient.SampleInvocationHandler invocationHandler = new CallbackTestClient.SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector2 = new Connector(); connector2.setInvokerLocator(callbackLocator2.getLocatorURI()); connector2.start(); connector.addInvocationHandler("sample", invocationHandler); // Callback handle object will be passed back as part of the callback object String callbackHandleObject = "myCallbackHandleObject"; log.info("testPushCallback - adding listener."); // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler, callbackLocator, callbackHandleObject); remotingClient.addListener(callbackHandler, callbackLocator2, callbackHandleObject); log.info("testPushCallback - make invocation"); // now make invocation on server, which should cause a callback to happen Object response = remotingClient.invoke("Do something", null); // need to wait for brief moment so server can callback Thread.sleep(5000); int count = callbackHandler.getCallbackCount(); System.out.println("callback count = " + count); assertEquals(2, count); } finally { if (remotingClient != null) { // remove callback handler from server remotingClient.removeListener(callbackHandler); remotingClient.disconnect(); } } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback("This is the payload of callback invocation."); Iterator itr = listeners.iterator(); while (itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); try { callbackHandler.handleCallback(callback); } catch (HandleCallbackException e) { e.printStackTrace(); } } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } public class CallbackHandler implements InvokerCallbackHandler { private Callback callback; private int callbackNumber = 0; /** * Will take the callback message and send back to client. * If client locator is null, will store them till client polls to get them. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { callbackNumber++; this.callback = callback; System.out.println("Received callback value of: " + callback.getCallbackObject()); System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject()); System.out.println("Received callback server invoker of: " + callback.getServerLocator()); } public Callback getCallback() { return callback; } public int getCallbackCount() { return callbackNumber; } } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/Cal0000644 0001750 0001750 00000011353 10524710267 033361 0 ustar twerner twerner package org.jboss.test.remoting.callback.multiple.server; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.apache.log4j.Level; import javax.management.MBeanServer; import java.util.List; import java.util.ArrayList; import java.util.Iterator; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class CallbackTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector; // String to be returned from invocation handler upon client invocation calls. public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public static final String CALLBACK_VALUE = "This is the payload of callback invocation."; public void setupServer() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); CallbackTestServer.SampleInvocationHandler invocationHandler = new CallbackTestServer.SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); } protected void setUp() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { CallbackTestServer server = new CallbackTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback(CALLBACK_VALUE); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); callbackHandler.handleCallback(callback); } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } } ././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTe0000644 0001750 0001750 00000047157 10535704450 033353 0 ustar twerner twerner package org.jboss.test.remoting.callback.multiple; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.AbstractInvoker; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; /** * These tests supplement the tests in org.jboss.test.remoting.callback.multiple.client * and org.jboss.test.remoting.callback.multiple.server. * * @author Ron Sigal * @version $Revision: 1663 $ ** Copyright Dec 6, 2006 *
*/ public class CallbackTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5530; private static int nextPort = port + 10; private String locatorURI = transport + "://" + host + ":" + port; private static final Logger log = Logger.getLogger(CallbackTestClient.class); public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public void testPush1Client1Connector2Handlers() throws Throwable { log.info("entering " + getName()); CallbackTestClient.CallbackHandler callbackHandler1 = new CallbackTestClient.CallbackHandler(); CallbackTestClient.CallbackHandler callbackHandler2 = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); Connector connector = null; try { String callbackLocatorURI = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); connector = setupServer(callbackLocator); client.addListener(callbackHandler1, callbackLocator); client.addListener(callbackHandler2, callbackLocator); client.invoke("Do something", null); client.invoke("Do something else", null); // need to wait for brief moment so server can callback Thread.sleep(5000); int count = callbackHandler1.getCallbackCount(); assertEquals(2, count); count = callbackHandler2.getCallbackCount(); assertEquals(2, count); } finally { if(client != null) { // remove callback handler from server client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); client.disconnect(); } teardownServer(connector); } } public void testPush1Client2Connectors1Handler() throws Throwable { log.info("entering " + getName()); CallbackTestClient.CallbackHandler callbackHandler = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); Connector connector1 = null; Connector connector2 = null; try { String callbackLocatorURI1 = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator1 = new InvokerLocator(callbackLocatorURI1); connector1 = setupServer(callbackLocator1); client.addListener(callbackHandler, callbackLocator1); String callbackLocatorURI2 = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator2 = new InvokerLocator(callbackLocatorURI2); connector2 = setupServer(callbackLocator2); client.addListener(callbackHandler, callbackLocator2); client.invoke("Do something", null); client.invoke("Do something else", null); // need to wait for brief moment so server can callback Thread.sleep(5000); int count = callbackHandler.getCallbackCount(); assertEquals(4, count); } finally { if(client != null) { // remove callback handler from server client.removeListener(callbackHandler); client.disconnect(); } teardownServer(connector1); teardownServer(connector2); } } public void testPush1Client2Connectors2Handlers() throws Throwable { log.info("entering " + getName()); CallbackTestClient.CallbackHandler callbackHandler1 = new CallbackTestClient.CallbackHandler(); CallbackTestClient.CallbackHandler callbackHandler2 = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); Connector connector1 = null; Connector connector2 = null; try { String callbackLocatorURI1 = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator1 = new InvokerLocator(callbackLocatorURI1); connector1 = setupServer(callbackLocator1); client.addListener(callbackHandler1, callbackLocator1); String callbackLocatorURI2 = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator2 = new InvokerLocator(callbackLocatorURI2); connector2 = setupServer(callbackLocator2); client.addListener(callbackHandler2, callbackLocator2); client.invoke("Do something", null); client.invoke("Do something else", null); // need to wait for brief moment so server can callback Thread.sleep(5000); int count = callbackHandler1.getCallbackCount(); assertEquals(2, count); count = callbackHandler2.getCallbackCount(); assertEquals(2, count); } finally { if(client != null) { // remove callback handler from server client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); client.disconnect(); } teardownServer(connector1); teardownServer(connector2); } } public void testPush2Clients1Connector1Handler() throws Throwable { log.info("entering " + getName()); CallbackTestClient.CallbackHandler callbackHandler = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client client1 = new Client(locator); client1.connect(); Client client2 = new Client(locator); client2.connect(); Connector connector = null; try { String callbackLocatorURI = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); connector = setupServer(callbackLocator); log.info("created callback server: " + connector.getLocator()); client1.addListener(callbackHandler, callbackLocator); client2.addListener(callbackHandler, callbackLocator); client1.invoke("Do something", null); client2.invoke("Do something else", null); // need to wait for brief moment so server can callback Thread.sleep(5000); // The CallbackHandler should be registered just once. int count = callbackHandler.getCallbackCount(); assertEquals(2, count); } finally { if(client1 != null) { // remove callback handler from server client1.removeListener(callbackHandler); client1.disconnect(); } teardownServer(connector); } } public void testPush2Clients1Connector2Handlers() throws Throwable { log.info("entering " + getName()); CallbackTestClient.CallbackHandler callbackHandler1 = new CallbackTestClient.CallbackHandler(); CallbackTestClient.CallbackHandler callbackHandler2 = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client client1 = new Client(locator); client1.connect(); Client client2 = new Client(locator); client2.connect(); Connector connector = null; try { String callbackLocatorURI = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); connector = setupServer(callbackLocator); client1.addListener(callbackHandler1, callbackLocator); client2.addListener(callbackHandler2, callbackLocator); client1.invoke("Do something", null); client2.invoke("Do something else", null); // need to wait for brief moment so server can callback Thread.sleep(5000); int count = callbackHandler1.getCallbackCount(); assertEquals(2, count); count = callbackHandler1.getCallbackCount(); assertEquals(2, count); } finally { Field field = AbstractInvoker.class.getDeclaredField("localServerLocators"); field.setAccessible(true); if(client1 != null) { ClientInvoker invoker = client1.getInvoker(); Map localServerLocators = (Map) field.get(invoker); assertEquals(2, localServerLocators.size()); client1.removeListener(callbackHandler1); assertEquals(1, localServerLocators.size()); client1.removeListener(callbackHandler2); // client1 shouldn't be able to remove callbackHandler2. assertEquals(1, localServerLocators.size()); client1.disconnect(); } if (client2 != null) { ClientInvoker invoker = client2.getInvoker(); Map localServerLocators = (Map) field.get(invoker); assertEquals(1, localServerLocators.size()); client2.removeListener(callbackHandler2); assertEquals(0, localServerLocators.size()); client2.disconnect(); } teardownServer(connector); } } public void testPush2Clients2Connectors1Handler() throws Throwable { log.info("entering " + getName()); CallbackTestClient.CallbackHandler callbackHandler = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client client1 = new Client(locator); client1.connect(); Client client2 = new Client(locator); client2.connect(); Connector connector1 = null; Connector connector2 = null; try { String callbackLocatorURI1 = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator1 = new InvokerLocator(callbackLocatorURI1); connector1 = setupServer(callbackLocator1); String callbackLocatorURI2 = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator2 = new InvokerLocator(callbackLocatorURI2); connector2 = setupServer(callbackLocator2); client1.addListener(callbackHandler, callbackLocator1); client2.addListener(callbackHandler, callbackLocator2); client1.invoke("Do something", null); client2.invoke("Do something else", null); // need to wait for brief moment so server can callback Thread.sleep(5000); int count = callbackHandler.getCallbackCount(); assertEquals(4, count); } finally { Field field = AbstractInvoker.class.getDeclaredField("localServerLocators"); field.setAccessible(true); if(client1 != null) { ClientInvoker invoker = client1.getInvoker(); Map localServerLocators = (Map) field.get(invoker); assertEquals(2, localServerLocators.size()); client1.removeListener(callbackHandler); // callbackHandler should still be registered with connector2. assertEquals(1, localServerLocators.size()); client1.disconnect(); } if (client2 != null) { ClientInvoker invoker = client2.getInvoker(); Map localServerLocators = (Map) field.get(invoker); assertEquals(1, localServerLocators.size()); client2.removeListener(callbackHandler); assertEquals(0, localServerLocators.size()); client2.disconnect(); } teardownServer(connector1); teardownServer(connector2); } } public void testPush2Clients2Connectors2Handlers() throws Throwable { log.info("entering " + getName()); CallbackTestClient.CallbackHandler callbackHandler1 = new CallbackTestClient.CallbackHandler(); CallbackTestClient.CallbackHandler callbackHandler2 = new CallbackTestClient.CallbackHandler(); InvokerLocator locator = new InvokerLocator(locatorURI); Client client1 = new Client(locator); client1.connect(); Client client2 = new Client(locator); client2.connect(); Connector connector1 = null; Connector connector2 = null; try { String callbackLocatorURI1 = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator1 = new InvokerLocator(callbackLocatorURI1); connector1 = setupServer(callbackLocator1); String callbackLocatorURI2 = transport + "://" + host + ":" + nextPort++; InvokerLocator callbackLocator2 = new InvokerLocator(callbackLocatorURI2); connector2 = setupServer(callbackLocator2); client1.addListener(callbackHandler1, callbackLocator1); client2.addListener(callbackHandler2, callbackLocator2); client1.invoke("Do something", null); client2.invoke("Do something else", null); // need to wait for brief moment so server can callback Thread.sleep(5000); int count = callbackHandler1.getCallbackCount(); assertEquals(2, count); count = callbackHandler1.getCallbackCount(); assertEquals(2, count); } finally { Field field = AbstractInvoker.class.getDeclaredField("localServerLocators"); field.setAccessible(true); if(client1 != null) { ClientInvoker invoker = client1.getInvoker(); Map localServerLocators = (Map) field.get(invoker); assertEquals(2, localServerLocators.size()); client1.removeListener(callbackHandler1); assertEquals(1, localServerLocators.size()); client1.removeListener(callbackHandler2); // client1 shouldn't be able to remove callbackHandler2. assertEquals(1, localServerLocators.size()); client1.disconnect(); } if (client2 != null) { ClientInvoker invoker = client2.getInvoker(); Map localServerLocators = (Map) field.get(invoker); assertEquals(1, localServerLocators.size()); client2.removeListener(callbackHandler2); assertEquals(0, localServerLocators.size()); client2.disconnect(); } teardownServer(connector1); teardownServer(connector2); } } public Connector setupServer(InvokerLocator locator) throws Exception { log.info("Starting remoting server with locator uri of: " + locator); try { Connector connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); log.info("started callback Connector: " + connector.getLocator()); CallbackTestClient.SampleInvocationHandler invocationHandler = new CallbackTestClient.SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); return connector; } catch(Exception e) { log.error("Error starting callback server", e); throw e; } } public void teardownServer(Connector connector) { if(connector != null) { connector.stop(); connector.destroy(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback("This is the payload of callback invocation."); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } public class CallbackHandler implements InvokerCallbackHandler { private Callback callback; private int callbackNumber = 0; /** * Will take the callback message and send back to client. * If client locator is null, will store them till client polls to get them. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { callbackNumber++; this.callback = callback; System.out.println("Received callback value of: " + callback.getCallbackObject()); System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject()); System.out.println("Received callback server invoker of: " + callback.getServerLocator()); } public Callback getCallback() { return callback; } public int getCallbackCount() { return callbackNumber; } } } ././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTe0000644 0001750 0001750 00000010643 10535704450 033341 0 ustar twerner twerner package org.jboss.test.remoting.callback.multiple; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class CallbackTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5530; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector; // String to be returned from invocation handler upon client invocation calls. public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public static final String CALLBACK_VALUE = "This is the payload of callback invocation."; public void setupServer() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); CallbackTestServer.SampleInvocationHandler invocationHandler = new CallbackTestServer.SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); } protected void setUp() throws Exception { setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { CallbackTestServer server = new CallbackTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback(CALLBACK_VALUE); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); callbackHandler.handleCallback(callback); } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } } ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestCase.ja0000644 0001750 0001750 00000005276 11015165767 033256 0 ustar twerner twerner /* * 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.remoting.callback; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * This should be used as the main test case for the invoker client/server. * It will start one instance of the client and one of the server and will * gather the test results and report them in standard JUnit format. When * wanting to run JUnit test for invoker, this is the class to use. * * @author Tom Elrod */ public class CallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(CallbackTestClient.class.getName(), 1, CallbackTestServer.class.getName()); } protected Level getTestLogLevel() { return Level.INFO; } protected Level getTestHarnessLogLevel() { return Level.INFO; } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/acknowledge/ 0000755 0001750 0001750 00000000000 11632407041 032050 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/acknowledge/CallbackAcknowledgeTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/acknowledge/Callbac0000644 0001750 0001750 00000166555 11015172241 033332 0 ustar twerner twerner /* * 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. */ /** * Tests Callback acknowledgements. * * @author Ron Sigal * * Copyright (c) 2006 * */ package org.jboss.test.remoting.callback.acknowledge; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.CallbackListener; import org.jboss.remoting.callback.CallbackPoller; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; public class CallbackAcknowledgeTestCase extends TestCase { private static String APPLICATION_ACKNOWLEDGEMENT_TEST = "AppAckTest"; private static String REMOTING_ACKNOWLEDGEMENT_TEST = "remotingAckTest"; private static Logger log = Logger.getLogger(CallbackAcknowledgeTestCase.class); private Connector connector; private InvokerLocator serverLocator; private String transport = "socket"; private Client client; public void setUp() throws Exception { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); serverLocator = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); connector = new Connector(serverLocator, config); connector.start(); connector.addInvocationHandler("test", new TestInvocationHandler()); client = new Client(serverLocator, config); client.connect(); TestInvocationHandler.callbacksAcknowledged = 0; TestInvocationHandler.callbackResponses.clear(); } public void tearDown() { if (connector != null) connector.stop(); if (client != null) client.disconnect(); } /** * In this test, the connection is configured for pull callbacks, and the * acknowledgements should be made by an explicit call to Client.acknowledgeCallback() * after the callbacks have been retrieved and (presumably) processed. Two * InvokerCallbackHandlers are registered. */ public void testNonblockingPullApplicationAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); client.addListener(callbackHandler1); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); client.addListener(callbackHandler2); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); List callbacks1 = client.getCallbacks(callbackHandler1); assertEquals(2, callbacks1.size()); List callbacks2 = client.getCallbacks(callbackHandler2); assertEquals(2, callbacks2.size()); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler1, callbacks1)); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler2, callbacks2)); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); Thread.sleep(1000); assertEquals(0, callbackHandler1.callbacksReceived); assertEquals(0, callbackHandler2.callbacksReceived); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test, the connection is configured for pull callbacks, and the * acknowledgements should be made by an explicit call to Client.acknowledgeCallback() * after the callbacks have been retrieved and (presumably) processed. Two * InvokerCallbackHandlers are registered. */ public void testBlockingPullApplicationAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); client.addListener(callbackHandler1); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); client.addListener(callbackHandler2); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); List callbacks1 = client.getCallbacks(callbackHandler1, metadata); assertEquals(2, callbacks1.size()); List callbacks2 = client.getCallbacks(callbackHandler2, metadata); assertEquals(2, callbacks2.size()); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler1, callbacks1)); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler2, callbacks2)); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); Thread.sleep(1000); assertEquals(0, callbackHandler1.callbacksReceived); assertEquals(0, callbackHandler2.callbacksReceived); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test, the connection is configured for pull callbacks, and the * acknowledgements should be made by an explicit call to Client.acknowledgeCallback() * after the callbacks have been retrieved and (presumably) processed. A single * InvokerCallbackHandler is registered twice but treated as a single instance. */ public void testNonblockingPullApplicationAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler); client.addListener(callbackHandler); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); List callbacks = client.getCallbacks(callbackHandler); assertEquals(2, callbacks.size()); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler, callbacks)); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); Thread.sleep(1000); assertEquals(0, callbackHandler.callbacksReceived); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test, the connection is configured for pull callbacks, and the * acknowledgements should be made by an explicit call to Client.acknowledgeCallback() * after the callbacks have been retrieved and (presumably) processed. A single * InvokerCallbackHandler is registered twice but treated as a single instance. */ public void testBlockingPullApplicationAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler); client.addListener(callbackHandler); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); List callbacks = client.getCallbacks(callbackHandler, metadata); assertEquals(2, callbacks.size()); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler, callbacks)); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); Thread.sleep(1000); assertEquals(0, callbackHandler.callbacksReceived); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test, the connection is configured for pull callbacks. The * server requests that Remoting handle push callback acknowledgements, * but that should have no effect. Instead, callback acknowledgements * should be made by an explicit call to Client.acknowledgeCallback() after * the callback has been retrieved and (presumably) processed. * Two distinct InvokerCallbackHandlers are used. */ public void testNonblockingPullRemotingAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); client.addListener(callbackHandler1); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); client.addListener(callbackHandler2); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); List callbacks1 = client.getCallbacks(callbackHandler1); assertEquals(2, callbacks1.size()); List callbacks2 = client.getCallbacks(callbackHandler2); assertEquals(2, callbacks2.size()); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler1, callbacks1)); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler2, callbacks2)); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); Thread.sleep(1000); assertEquals(0, callbackHandler1.callbacksReceived); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test, the connection is configured for pull callbacks. The * server requests that Remoting handle push callback acknowledgements, * but that should have no effect. Instead, callback acknowledgements * should be made by an explicit call to Client.acknowledgeCallback() after * the callback has been retrieved and (presumably) processed. * Two distinct InvokerCallbackHandlers are used. */ public void testPullRemotingAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); client.addListener(callbackHandler1); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); client.addListener(callbackHandler2); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); List callbacks1 = client.getCallbacks(callbackHandler1, metadata); assertEquals(2, callbacks1.size()); List callbacks2 = client.getCallbacks(callbackHandler2, metadata); assertEquals(2, callbacks2.size()); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler1, callbacks1)); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler2, callbacks2)); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); Thread.sleep(1000); assertEquals(0, callbackHandler1.callbacksReceived); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test, the connection is configured pull callbacks. The * server requests that Remoting handle push callback acknowledgements, * but that should have no effect. Instead, acknowledgements should be made * by an explicit call to Client.acknowledgeCallback() after the callback * has been retrieved and (presumably) processed. A single InvokerCallbackHandler * is registered twice but treated as a single instance. */ public void testNonblockingPullRemotingAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler); client.addListener(callbackHandler); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); List callbacks = client.getCallbacks(callbackHandler); assertEquals(2, callbacks.size()); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler, callbacks)); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); Thread.sleep(1000); assertEquals(0, callbackHandler.callbacksReceived); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test, the connection is configured pull callbacks. The * server requests that Remoting handle push callback acknowledgements, * but that should have no effect. Instead, acknowledgements should be made * by an explicit call to Client.acknowledgeCallback() after the callback * has been retrieved and (presumably) processed. A single InvokerCallbackHandler * is registered twice but treated as a single instance. */ public void testBlockingPullRemotingAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler); client.addListener(callbackHandler); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); List callbacks = client.getCallbacks(callbackHandler, metadata); assertEquals(2, callbacks.size()); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); assertEquals(2, client.acknowledgeCallbacks(callbackHandler, callbacks)); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); Thread.sleep(1000); assertEquals(0, callbackHandler.callbacksReceived); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. The acknowledgements should be made * explicitly by the InvokerCallbackHandler. Two distinct InvokerCallbackHandlers * are registered. */ public void testNonblockingPollApplicationAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "100"); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); client.addListener(callbackHandler1, metadata); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2); client.addListener(callbackHandler2, metadata); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response111 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 1: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response111)); String response212 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 1: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response212)); String response121 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 2: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response121)); String response222 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 2: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response222)); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. The acknowledgements should be made * explicitly by the InvokerCallbackHandler. Two distinct InvokerCallbackHandlers * are registered. */ public void testBlockingPollApplicationAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); client.addListener(callbackHandler1, metadata); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2); client.addListener(callbackHandler2, metadata); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); Thread.sleep(3000); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response111 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 1: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response111)); String response212 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 1: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response212)); String response121 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 2: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response121)); String response222 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 2: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response222)); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. A single InvokerCallbackHandler is * registered twice but the Client treats it as a single instance. The * acknowledgements should be made explicitly by the InvokerCallbackHandler. */ public void testNonblockingPollApplicationAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(client); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "100"); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); client.addListener(callbackHandler, metadata); client.addListener(callbackHandler, metadata); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); Thread.sleep(1000); assertEquals(2, callbackHandler.callbacksReceived); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response101 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 0: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response101)); String response202 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response202)); client.removeListener(callbackHandler); Thread.sleep(4000); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. A single InvokerCallbackHandler is * registered twice but the Client treats it as a single instance. The * acknowledgements should be made explicitly by the InvokerCallbackHandler. */ public void testBlockingPollApplicationAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(client); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); client.addListener(callbackHandler, metadata); client.addListener(callbackHandler, metadata); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); Thread.sleep(1000); assertEquals(2, callbackHandler.callbacksReceived); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response101 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 0: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response101)); String response202 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response202)); client.removeListener(callbackHandler); Thread.sleep(4000); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. The acknowledgement should be made * implicitly by CallbackPoller, which it does by calling Client.acknowledgeCallback() * after it has pushed the callback to the InvokerCallbackHandler. Two * distinct InvokerCallbackHandlers are registered. */ public void testNonblockingPollRemotingAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "100"); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); client.addListener(callbackHandler1, metadata); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); client.addListener(callbackHandler2, metadata); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. The acknowledgement should be made * implicitly by CallbackPoller, which it does by calling Client.acknowledgeCallback() * after it has pushed the callback to the InvokerCallbackHandler. Two * distinct InvokerCallbackHandlers are registered. */ public void testBlockingPollRemotingAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); client.addListener(callbackHandler1, metadata); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); client.addListener(callbackHandler2, metadata); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); Thread.sleep(1000); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. The acknowledgement should be made * implicitly by CallbackPoller, which it does by calling Client.acknowledgeCallback() * after it has pushed the callback to the InvokerCallbackHandler. A single * InvokerCallbackHandler is registered twice, but the Client recognizes only a * single instance. */ public void testNonblockingPollRemotingAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "100"); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); client.addListener(callbackHandler, metadata); client.addListener(callbackHandler, metadata); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); Thread.sleep(1000); assertEquals(2, callbackHandler.callbacksReceived); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for push callbacks implemented in * Remoting by polling the server for callbacks and pushing them (on the client * side) to the InvokerCallbackHandler. The acknowledgement should be made * implicitly by CallbackPoller, which it does by calling Client.acknowledgeCallback() * after it has pushed the callback to the InvokerCallbackHandler. A single * InvokerCallbackHandler is registered twice, but the Client recognizes only a * single instance. */ public void testBlockingPollRemotingAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); client.addListener(callbackHandler, metadata); client.addListener(callbackHandler, metadata); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); Thread.sleep(1000); assertEquals(2, callbackHandler.callbacksReceived); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks, and the * acknowledgements should be made on the client side by the InvokerCallbackHandler. * Two distinct InvokerCallbackHandlers are registered. */ public void testPushApplicationAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1); client.addListener(callbackHandler1, null, null, true); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2); client.addListener(callbackHandler2, null, null, true); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response111 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 1: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response111)); String response212 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 1: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response212)); String response121 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 2: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response121)); String response222 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 2: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response222)); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks, and the * acknowledgement should be made on the client side by the InvokerCallbackHandler. * A single InvokerCallbackHandler is shared by two callback Connectors. */ public void testPushApplicationAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(client); client.addListener(callbackHandler, null, null, true); client.addListener(callbackHandler, null, null, true); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); assertEquals(4, callbackHandler.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response101 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 0: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response101)); String response202 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response202)); String response103 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 0: 3"; assertTrue(TestInvocationHandler.callbackResponses.contains(response103)); String response204 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 4"; assertTrue(TestInvocationHandler.callbackResponses.contains(response204)); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks, and the * acknowledgements should be made by ServerInvokerCallbackHandler.handleCallback() * after it has pushed the Callback to the client. Two distinct * InvokerCallbackHandlers are registered. */ public void testPushRemotingAckDifferentHandlers() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); client.addListener(callbackHandler1, null, null, true); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); client.addListener(callbackHandler2, null, null, true); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks, and the * acknowledgements should be made by ServerInvokerCallbackHandler.handleCallback() * after it has pushed the Callback to the client. A single InvokerCallbackHandler * is registered twice, and each is treated as a distinct instance. */ public void testPushRemotingAckSameHandler() { log.info("entering " + getName()); try { TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, null, null, true); client.addListener(callbackHandler, null, null, true); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); assertEquals(4, callbackHandler.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks by creating a * Connector and passing its InvokerLocator when the InvokerCallbackHandlers are * registered. Acknowledgements should be made on the client side by the * InvokerCallbackHandler. Two distinct InvokerCallbackHandlers are registered with * a single Connector. */ public void testPushApplicationAckDifferentHandlersPassLocator() { log.info("entering " + getName()); try { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector = new Connector(callbackLocator, config); connector.start(); TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1); client.addListener(callbackHandler1, callbackLocator); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2); client.addListener(callbackHandler2, callbackLocator); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response111 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 1: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response111)); String response212 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 1: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response212)); String response121 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 2: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response121)); String response222 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 2: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response222)); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks by creating a * Connector and passing its InvokerLocator when the InvokerCallbackHandlers are * registered. Acknowledgements should be made on the client side by the * InvokerCallbackHandler. A InvokerCallbackHandler is registered twice with * a single Connector and treated as a single instance. */ public void testPushApplicationAckSameHandlerPassLocator() { log.info("entering " + getName()); try { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector = new Connector(callbackLocator, config); connector.start(); TestCallbackHandler callbackHandler = new TestCallbackHandler(client); client.addListener(callbackHandler, callbackLocator); client.addListener(callbackHandler, callbackLocator); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); assertEquals(2, callbackHandler.callbacksReceived); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response101 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 0: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response101)); String response202 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response202)); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks by creating * two Connectors and passing their InvokerLocator when the InvokerCallbackHandlers * are registered. Acknowledgements should be made on the client side by the * InvokerCallbackHandler. Each of two distinct InvokerCallbackHandlers is * registered with a distinct Connector */ public void testPushApplicationAckDifferentHandlersPassTwoLocators() { log.info("entering " + getName()); try { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator1 = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector1 = new Connector(callbackLocator1, config); connector1.start(); TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1); client.addListener(callbackHandler1, callbackLocator1); freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator2 = new InvokerLocator(transport + "://" + host + ":" + freePort); Connector connector2 = new Connector(callbackLocator2, config); connector2.start(); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2); client.addListener(callbackHandler2, callbackLocator2); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response111 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 1: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response111)); String response212 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 1: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response212)); String response121 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 2: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response121)); String response222 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 2: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response222)); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks by creating * two Connectors and passing their InvokerLocator when the InvokerCallbackHandlers * are registered. Acknowledgements should be made on the client side by the * InvokerCallbackHandler. A single InvokerCallbackHandlers is registered with * two distinct Connectors. */ public void testPushApplicationAckSameHandlerPassTwoLocators() { log.info("entering " + getName()); try { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator1 = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector1 = new Connector(callbackLocator1, config); connector1.start(); TestCallbackHandler callbackHandler = new TestCallbackHandler(client); client.addListener(callbackHandler, callbackLocator1); freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator2 = new InvokerLocator(transport + "://" + host + ":" + freePort); Connector connector2 = new Connector(callbackLocator2, config); connector2.start(); client.addListener(callbackHandler, callbackLocator2); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(APPLICATION_ACKNOWLEDGEMENT_TEST); assertEquals(4, callbackHandler.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); //key: message #: handler id: callbacks received String response101 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 0: 1"; assertTrue(TestInvocationHandler.callbackResponses.contains(response101)); String response202 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 2"; assertTrue(TestInvocationHandler.callbackResponses.contains(response202)); String response103 = APPLICATION_ACKNOWLEDGEMENT_TEST + "1: 0: 3"; assertTrue(TestInvocationHandler.callbackResponses.contains(response103)); String response204 = APPLICATION_ACKNOWLEDGEMENT_TEST + "2: 0: 4"; assertTrue(TestInvocationHandler.callbackResponses.contains(response204)); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks by creating a * Connector and passing its InvokerLocator when the InvokerCallbackHandlers are * registered. Acknowledgements should be made implicitly on the server side by the * ServerInvokerCallbackHandler. Two distinct InvokerCallbackHandlers are registered * with a single Connector. */ public void testPushRemotingAckDifferentHandlersPassLocator() { log.info("entering " + getName()); try { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector = new Connector(callbackLocator, config); connector.start(); TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1); client.addListener(callbackHandler1, callbackLocator); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2); client.addListener(callbackHandler2, callbackLocator); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks by creating a * Connector and passing its InvokerLocator when the InvokerCallbackHandlers are * registered. Acknowledgements should be made implicitly on the server side by the * ServerInvokerCallbackHandler. A InvokerCallbackHandler is registered twice with * a single Connector and treated as a single instance. */ public void testPushRemotingAckSameHandlerPassLocator() { log.info("entering " + getName()); try { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector = new Connector(callbackLocator, config); connector.start(); TestCallbackHandler callbackHandler = new TestCallbackHandler(client); client.addListener(callbackHandler, callbackLocator); client.addListener(callbackHandler, callbackLocator); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); assertEquals(2, callbackHandler.callbacksReceived); assertEquals(2, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks by creating * two Connectors and passing their InvokerLocator when the InvokerCallbackHandlers * are registered. Acknowledgements should be made implicitly on the server side by the * ServerInvokerCallbackHandler. Each of two distinct InvokerCallbackHandlers is * registered with a distinct Connector */ public void testPushRemotingAckDifferentHandlersPassTwoLocators() { log.info("entering " + getName()); try { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator1 = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector1 = new Connector(callbackLocator1, config); connector1.start(); TestCallbackHandler callbackHandler1 = new TestCallbackHandler(client, 1); client.addListener(callbackHandler1, callbackLocator1); freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator2 = new InvokerLocator(transport + "://" + host + ":" + freePort); Connector connector2 = new Connector(callbackLocator2, config); connector2.start(); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(client, 2); client.addListener(callbackHandler2, callbackLocator2); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); assertEquals(2, callbackHandler1.callbacksReceived); assertEquals(2, callbackHandler2.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } /** * In this test the connection is configured for true push callbacks by creating * two Connectors and passing their InvokerLocator when the InvokerCallbackHandlers * are registered. Acknowledgements should be made implicitly on the server side by the * ServerInvokerCallbackHandler. A single InvokerCallbackHandlers is registered with * two distinct Connectors. */ public void testPushRemotingAckSameHandlerPassTwoLocators() { log.info("entering " + getName()); try { String host = InetAddress.getLocalHost().getHostAddress(); int freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator1 = new InvokerLocator(transport + "://" + host + ":" + freePort); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector1 = new Connector(callbackLocator1, config); connector1.start(); TestCallbackHandler callbackHandler = new TestCallbackHandler(client); client.addListener(callbackHandler, callbackLocator1); freePort = PortUtil.findFreePort(host); InvokerLocator callbackLocator2 = new InvokerLocator(transport + "://" + host + ":" + freePort); Connector connector2 = new Connector(callbackLocator2, config); connector2.start(); client.addListener(callbackHandler, callbackLocator2); assertEquals(0, TestInvocationHandler.callbacksAcknowledged); client.invoke(REMOTING_ACKNOWLEDGEMENT_TEST); assertEquals(4, callbackHandler.callbacksReceived); assertEquals(4, TestInvocationHandler.callbacksAcknowledged); assertTrue(TestInvocationHandler.callbackResponses.isEmpty()); client.removeListener(callbackHandler); log.info(getName() + " PASSES"); } catch (Throwable e) { log.info(getName() + " FAILS"); e.printStackTrace(); fail(); } } static class TestInvocationHandler implements ServerInvocationHandler, CallbackListener { static int callbacksAcknowledged; static HashSet callbackResponses = new HashSet(); HashSet callbackHandlers = new HashSet(); public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { String command = (String) invocation.getParameter(); System.out.println("command: " + command); for (Iterator it = callbackHandlers.iterator(); it.hasNext(); ) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) it.next(); Callback cb1 = new Callback(command + "1"); HashMap returnPayload1 = new HashMap(); returnPayload1.put(ServerInvokerCallbackHandler.CALLBACK_ID, command + "1"); returnPayload1.put(ServerInvokerCallbackHandler.CALLBACK_LISTENER, this); cb1.setReturnPayload(returnPayload1); if (REMOTING_ACKNOWLEDGEMENT_TEST.equals(command)) { returnPayload1.put(ServerInvokerCallbackHandler.REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS, "true"); } else { returnPayload1.put(APPLICATION_ACKNOWLEDGEMENT_TEST, "true"); } callbackHandler.handleCallback(cb1); Callback cb2 = new Callback(command + "2"); HashMap returnPayload2 = new HashMap(); returnPayload2.put(ServerInvokerCallbackHandler.CALLBACK_ID, command + "2"); returnPayload2.put(ServerInvokerCallbackHandler.CALLBACK_LISTENER, this); cb2.setReturnPayload(returnPayload2); if (REMOTING_ACKNOWLEDGEMENT_TEST.equals(command)) { returnPayload2.put(ServerInvokerCallbackHandler.REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS, "true"); } else { returnPayload2.put(APPLICATION_ACKNOWLEDGEMENT_TEST, "true"); } callbackHandler.handleCallback(cb2); } return null; } public void addListener(InvokerCallbackHandler callbackHandler) { callbackHandlers.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void acknowledgeCallback(InvokerCallbackHandler callbackHandler, Object callbackId, Object response) { callbacksAcknowledged++; if (response != null) callbackResponses.add(response); } } static class TestCallbackHandler implements InvokerCallbackHandler { public int callbacksReceived; private Client client; private int id; public TestCallbackHandler() { this(null); } public TestCallbackHandler(Client client) { this(client, 0); } public TestCallbackHandler(Client client, int id) { this.client = client; this.id = id; } public void handleCallback(Callback callback) throws HandleCallbackException { log.info("entering handleCallback()"); callbacksReceived++; Map returnMap = callback.getReturnPayload(); if (returnMap.get(APPLICATION_ACKNOWLEDGEMENT_TEST) == null) return; String test = (String) callback.getParameter(); try { client.acknowledgeCallback(this, callback, test + ": " + id + ": " + callbacksReceived); } catch (Throwable e) { log.error(e); e.printStackTrace(); throw new HandleCallbackException(e.getMessage()); } } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/ 0000755 0001750 0001750 00000000000 11632407041 030544 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/ 0000755 0001750 0001750 00000000000 11632407041 032675 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/CallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/Cal0000644 0001750 0001750 00000005174 10535452155 033335 0 ustar twerner twerner /* * 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.remoting.callback.push.disconnect; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * This should be used as the main test case for the invoker client/server. * It will start one instance of the client and one of the server and will * gather the test results and report them in standard JUnit format. When * wanting to run JUnit test for invoker, this is the class to use. * * @author Tom Elrod */ public class CallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(CallbackTestClient.class.getName(), 1, CallbackTestServer.class.getName()); } protected Level getTestLogLevel() { return Level.DEBUG; } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/Cal0000644 0001750 0001750 00000021315 10370737135 033331 0 ustar twerner twerner /* * 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.remoting.callback.push.disconnect; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import junit.framework.TestCase; /** * @author Tom Elrod */ public class CallbackTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private static String callbackHost = "localhost"; private static int callbackPort = 5501; private String locatorURI = transport + "://" + host + ":" + port; // public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public void testPullCallbackDisconnect() throws Throwable { String callbackServerURI = "socket://" + callbackHost + ":" + callbackPort; Connector callbackServer = new Connector(); callbackServer.setInvokerLocator(callbackServerURI); callbackServer.start(); // SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // callbackServer.getServerInvoker().addInvocationHandler("callbackTest", invocationHandler); Client client = new Client(new InvokerLocator(locatorURI), "test"); client.connect(); CallbackHandler callbackHandler = new CallbackHandler(); client.addListener(callbackHandler, new InvokerLocator(callbackServerURI)); // send invocation that will trigger sending of callbacks. client.invoke("foo"); // wait to get some callbacks. System.out.println("Waiting three seconds for callbacks."); Thread.currentThread().sleep(3000); System.out.println("Done waiting for callbacks, will shutdown callback server and client."); // shutdown client and callback server // callbackServer.getServerInvoker().removeInvocationHandler( // callbackServer.getServerInvoker().getInvocationHandlers()[0].toString() // ); client.removeListener(callbackHandler); client.disconnect(); callbackServer.stop(); callbackServer.destroy(); System.out.println("Callback total number after shutdown is " + callbackHandler.getCallbackNumber()); int callbackNumber = callbackHandler.getCallbackNumber(); // sleep to allow server to send more callbacks if is going to System.out.println("Waiting ten seconds to make sure no more callbacks are delivered by server."); Thread.currentThread().sleep(10000); // check to make sure no more callbacks have been delivered. System.out.println("Callback total number after waiting ten seconds is " + callbackHandler.getCallbackNumber()); assertEquals(callbackNumber, callbackHandler.getCallbackNumber()); } /** * Simple invocation handler implementation. */ // public static class SampleInvocationHandler implements ServerInvocationHandler // { // // private List listeners = new ArrayList(); // private boolean sendCallbacks = false; // private int callbackCounter = 1; // // public SampleInvocationHandler() // { // sendCallbacks(); // } // // /** // * called to handle a specific invocation // * // * @param invocation // * @return // * @throws Throwable // */ // public Object invoke(InvocationRequest invocation) throws Throwable // { // // Just going to return static string as this is just simple example code. // // sendCallbacks = true; // return RESPONSE_VALUE; // // } // // private void sendCallbacks() // { // new Thread(new Runnable() // { // public void run() // { // while(true) // { // // try // { // Thread.currentThread().sleep(1000); // } // catch(InterruptedException e) // { // e.printStackTrace(); // } // // while(sendCallbacks) // { // // // Will also fire callback to listeners if they were to exist using // // simple invocation request. // Callback callback = new Callback(new Integer(callbackCounter)); // Iterator itr = listeners.iterator(); // while(itr.hasNext()) // { // InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); // try // { // callbackHandler.handleCallback(callback); // } // catch(HandleCallbackException e) // { // e.printStackTrace(); // } // } // } // } // // } // }).start(); // } // // /** // * Adds a callback handler that will listen for callbacks from // * the server invoker handler. // * // * @param callbackHandler // */ // public void addListener(InvokerCallbackHandler callbackHandler) // { // listeners.add(callbackHandler); // } // // /** // * Removes the callback handler that was listening for callbacks // * from the server invoker handler. // * // * @param callbackHandler // */ // public void removeListener(InvokerCallbackHandler callbackHandler) // { // listeners.remove(callbackHandler); // } // // /** // * set the mbean server that the handler can reference // * // * @param server // */ // public void setMBeanServer(MBeanServer server) // { // // NO OP as do not need reference to MBeanServer for this handler // } // // /** // * set the invoker that owns this handler // * // * @param invoker // */ // public void setInvoker(ServerInvoker invoker) // { // // NO OP as do not need reference back to the server invoker // } // // } public class CallbackHandler implements InvokerCallbackHandler { private Callback callback; private Integer callbackNumber; /** * Will take the callback message and send back to client. * If client locator is null, will store them till client polls to get them. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { this.callback = callback; System.out.println("Received callback value of: " + callback.getCallbackObject()); System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject()); System.out.println("Received callback server invoker of: " + callback.getServerLocator()); callbackNumber = (Integer) callback.getCallbackObject(); } public int getCallbackNumber() { if(callbackNumber != null) { return callbackNumber.intValue(); } else { return 0; } } public Callback getCallback() { return callback; } } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/Cal0000644 0001750 0001750 00000015552 10370737135 033337 0 ustar twerner twerner /* * 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.remoting.callback.push.disconnect; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.transport.Connector; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class CallbackTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector; // String to be returned from invocation handler upon client invocation calls. public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public static final String CALLBACK_VALUE = "This is the payload of callback invocation."; public void setupServer() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("test", invocationHandler); } protected void setUp() throws Exception { setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { CallbackTestServer server = new CallbackTestServer(); try { server.setUp(); while(true) { Thread.currentThread().sleep(5000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); private boolean sendCallbacks = false; private int callbackCounter = 1; public SampleInvocationHandler() { sendCallbacks(); } /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. sendCallbacks = true; return RESPONSE_VALUE; } private void sendCallbacks() { new Thread(new Runnable() { public void run() { while(true) { try { Thread.currentThread().sleep(1000); } catch(InterruptedException e) { e.printStackTrace(); } while(sendCallbacks) { // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback(new Integer(callbackCounter++)); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } try { Thread.currentThread().sleep(1000); } catch(InterruptedException e) { e.printStackTrace(); } } } } }).start(); } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } } ././@LongLink 0000000 0000000 0000000 00000000146 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000755 0001750 0001750 00000000000 11632407041 033476 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000152 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000755 0001750 0001750 00000000000 11632407041 033476 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000210 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPollTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000000546 10433024164 033504 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.rmi; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPollTestClient; /** * @author Tom Elrod */ public class RMICallbackPollTestClient extends CallbackPollTestClient { public String getTransport() { return "rmi"; } } ././@LongLink 0000000 0000000 0000000 00000000210 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPushTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000001201 10433024164 033471 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.rmi; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPushTestServer; /** * @author Tom Elrod */ public class RMICallbackPushTestServer extends CallbackPushTestServer { public String getTransport() { return "rmi"; } public static void main(String[] args) { RMICallbackPushTestServer server = new RMICallbackPushTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink 0000000 0000000 0000000 00000000210 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPushTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000000546 10433024164 033504 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.rmi; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPushTestClient; /** * @author Tom Elrod */ public class RMICallbackPushTestClient extends CallbackPushTestClient { public String getTransport() { return "rmi"; } } ././@LongLink 0000000 0000000 0000000 00000000210 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPollTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000001202 10433024164 033472 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.rmi; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPollTestServer; /** * @author Tom Elrod */ public class RMICallbackPollTestServer extends CallbackPollTestServer { public String getTransport() { return "rmi"; } public static void main(String[] args) { RMICallbackPollTestServer server = new RMICallbackPollTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink 0000000 0000000 0000000 00000000206 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPushTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000000671 10433024164 033503 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.rmi; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class RMICallbackPushTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMICallbackPushTestClient.class.getName(), 1, RMICallbackPushTestServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000206 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPollTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000000671 10433024164 033503 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.rmi; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class RMICallbackPollTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMICallbackPollTestClient.class.getName(), 1, RMICallbackPollTestServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000201 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPollTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000003702 10666163153 033513 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.CallbackPoller; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public abstract class CallbackPollTestClient extends TestCase { private boolean gotCallback = false; public void testCallback() throws Throwable { Client client = new Client(new InvokerLocator(getLocatorUri())); client.connect(); InvokerCallbackHandler testCallbackHandler = new TestCallbackHandler(); Map metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "1000"); client.addListener(testCallbackHandler, metadata, "foobar"); client.invoke("foobar"); Thread.sleep(4000); //Thread.sleep(600000); client.removeListener(testCallbackHandler); client.disconnect(); assertTrue(gotCallback); } private String getLocatorUri() { return getTransport() + "://" + getHost() + ":" + getPort(); } public abstract String getTransport(); public String getHost() { return "localhost"; } public int getPort() { return 6999; } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("callback = " + callback); Object o = callback.getCallbackHandleObject(); if ("foobar".equals(o)) { gotCallback = true; } else { System.out.println("CallbackHandleObject was " + o + " and not 'foobar'"); } } } } ././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000755 0001750 0001750 00000000000 11632407041 033476 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000214 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPollTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000002646 10433024164 033507 0 ustar twerner twerner /* * 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.remoting.callback.push.unidirectional.socket; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class SocketCallbackPollTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SocketCallbackPollTestClient.class.getName(), 1, SocketCallbackPollTestServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000216 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPollTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000002520 10433024164 033476 0 ustar twerner twerner /* * 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.remoting.callback.push.unidirectional.socket; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPollTestClient; /** * @author Tom Elrod */ public class SocketCallbackPollTestClient extends CallbackPollTestClient { public String getTransport() { return "socket"; } } ././@LongLink 0000000 0000000 0000000 00000000216 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPollTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000003162 10433024164 033501 0 ustar twerner twerner /* * 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.remoting.callback.push.unidirectional.socket; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPollTestServer; /** * @author Tom Elrod */ public class SocketCallbackPollTestServer extends CallbackPollTestServer { public String getTransport() { return "socket"; } public static void main(String[] args) { SocketCallbackPollTestServer server = new SocketCallbackPollTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink 0000000 0000000 0000000 00000000216 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPushTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000003161 10433024164 033500 0 ustar twerner twerner /* * 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.remoting.callback.push.unidirectional.socket; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPushTestServer; /** * @author Tom Elrod */ public class SocketCallbackPushTestServer extends CallbackPushTestServer { public String getTransport() { return "socket"; } public static void main(String[] args) { SocketCallbackPushTestServer server = new SocketCallbackPushTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink 0000000 0000000 0000000 00000000216 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPushTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000002520 10433024164 033476 0 ustar twerner twerner /* * 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.remoting.callback.push.unidirectional.socket; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPushTestClient; /** * @author Tom Elrod */ public class SocketCallbackPushTestClient extends CallbackPushTestClient { public String getTransport() { return "socket"; } } ././@LongLink 0000000 0000000 0000000 00000000214 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPushTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000002646 10433024164 033507 0 ustar twerner twerner /* * 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.remoting.callback.push.unidirectional.socket; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class SocketCallbackPushTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SocketCallbackPushTestClient.class.getName(), 1, SocketCallbackPushTestServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000755 0001750 0001750 00000000000 11632407041 033476 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000210 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPushTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000000675 10433024164 033507 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.http; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class HTTPCallbackPushTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPCallbackPushTestClient.class.getName(), 1, HTTPCallbackPushTestServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000212 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPollTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000000551 10433024164 033500 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.http; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPollTestClient; /** * @author Tom Elrod */ public class HTTPCallbackPollTestClient extends CallbackPollTestClient { public String getTransport() { return "http"; } } ././@LongLink 0000000 0000000 0000000 00000000212 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPushTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000001206 10433024164 033476 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.http; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPushTestServer; /** * @author Tom Elrod */ public class HTTPCallbackPushTestServer extends CallbackPushTestServer { public String getTransport() { return "http"; } public static void main(String[] args) { HTTPCallbackPushTestServer server = new HTTPCallbackPushTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink 0000000 0000000 0000000 00000000210 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPollTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000000675 10433024164 033507 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.http; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class HTTPCallbackPollTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPCallbackPollTestClient.class.getName(), 1, HTTPCallbackPollTestServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000212 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPushTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000000551 10433024164 033500 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.http; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPushTestClient; /** * @author Tom Elrod */ public class HTTPCallbackPushTestClient extends CallbackPushTestClient { public String getTransport() { return "http"; } } ././@LongLink 0000000 0000000 0000000 00000000212 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPollTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000001207 10433024164 033477 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional.http; import org.jboss.test.remoting.callback.push.unidirectional.CallbackPollTestServer; /** * @author Tom Elrod */ public class HTTPCallbackPollTestServer extends CallbackPollTestServer { public String getTransport() { return "http"; } public static void main(String[] args) { HTTPCallbackPollTestServer server = new HTTPCallbackPollTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink 0000000 0000000 0000000 00000000201 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPushTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000004375 10433024164 033510 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.List; /** * @author Tom Elrod */ public abstract class CallbackPushTestServer extends ServerTestCase { private Connector connector = null; public void setUp() throws Exception { connector = new Connector(getLocatorUri()); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); } public void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } private String getLocatorUri() { return getTransport() + "://" + getHost() + ":" + getPort(); } public abstract String getTransport(); public String getHost() { return "localhost"; } public int getPort() { return 6999; } public class TestInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } public Object invoke(InvocationRequest invocation) throws Throwable { for (int x = 0; x < listeners.size(); x++) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) listeners.get(x); callbackHandler.handleCallback(new Callback("This is callback payload")); } return "barfoo"; } public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } } } ././@LongLink 0000000 0000000 0000000 00000000201 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPollTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000004376 10433024164 033511 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.List; /** * @author Tom Elrod */ public abstract class CallbackPollTestServer extends ServerTestCase { private Connector connector = null; public void setUp() throws Exception { connector = new Connector(getLocatorUri()); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); } public void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } private String getLocatorUri() { return getTransport() + "://" + getHost() + ":" + getPort(); } public abstract String getTransport(); public String getHost() { return "localhost"; } public int getPort() { return 6999; } public class TestInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } public Object invoke(InvocationRequest invocation) throws Throwable { for (int x = 0; x < listeners.size(); x++) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) listeners.get(x); callbackHandler.handleCallback(new Callback("This is callback payload")); } return "barfoo"; } public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } } } ././@LongLink 0000000 0000000 0000000 00000000201 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPushTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644 0001750 0001750 00000003020 10433024164 033472 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.unidirectional; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import java.util.HashMap; /** * @author Tom Elrod */ public abstract class CallbackPushTestClient extends TestCase { private boolean gotCallback = false; public void testCallback() throws Throwable { Client client = new Client(new InvokerLocator(getLocatorUri())); client.connect(); InvokerCallbackHandler testCallbackHandler = new TestCallbackHandler(); client.addListener(testCallbackHandler, new HashMap(), null, true); client.invoke("foobar"); Thread.sleep(5000); client.removeListener(testCallbackHandler); client.disconnect(); assertTrue(gotCallback); } private String getLocatorUri() { return getTransport() + "://" + getHost() + ":" + getPort(); } public abstract String getTransport(); public String getHost() { return "localhost"; } public int getPort() { return 6999; } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("callback = " + callback); gotCallback = true; } } } ././@LongLink 0000000 0000000 0000000 00000000145 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000755 0001750 0001750 00000000000 11632407041 033354 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/local/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000755 0001750 0001750 00000000000 11632407041 033354 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000205 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/local/LocalCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000644 0001750 0001750 00000007770 10433024164 033370 0 ustar twerner twerner /* * 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.remoting.callback.push.bidirectional.local; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * @author Tom Elrod */ public class LocalCallbackTestCase extends TestCase { private Connector connector = null; private boolean gotCallback = false; private String locatorUri = "socket://localhost:8888"; public void setUp() throws Exception { connector = new Connector(locatorUri); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); } public void testCallback() throws Throwable { Client client = new Client(new InvokerLocator(locatorUri)); client.connect(); InvokerCallbackHandler testCallbackHandler = new TestCallbackHandler(); client.addListener(testCallbackHandler, new HashMap(), "foobar"); client.invoke("foobar"); Thread.sleep(5000); client.removeListener(testCallbackHandler); client.disconnect(); assertTrue(gotCallback); } public void tearDown() { if (connector != null) { connector.stop(); connector.destroy(); } } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("callback = " + callback); Object handle = callback.getCallbackHandleObject(); if ("foobar".equals(handle)) { gotCallback = true; } } } public class TestInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } public Object invoke(InvocationRequest invocation) throws Throwable { for (int x = 0; x < listeners.size(); x++) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) listeners.get(x); callbackHandler.handleCallback(new Callback("This is callback payload")); } return "barfoo"; } public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } } } ././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/multiplex/ libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000755 0001750 0001750 00000000000 11632407041 033354 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000215 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/multiplex/MultiplexCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000644 0001750 0001750 00000002645 10433024164 033364 0 ustar twerner twerner /* * 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.remoting.callback.push.bidirectional.multiplex; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class MultiplexCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(MultiplexCallbackTestClient.class.getName(), 1, MultiplexCallbackTestServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000217 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/multiplex/MultiplexCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000644 0001750 0001750 00000012700 10576343612 033367 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.bidirectional.multiplex; import junit.framework.TestCase; import org.jboss.remoting.Client; 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.Connector; import org.jboss.remoting.transport.multiplex.MultiplexClientInvoker; import org.jboss.remoting.transport.multiplex.MultiplexServerInvoker; import org.jboss.remoting.transport.multiplex.MultiplexingManager; import org.jboss.remoting.transport.multiplex.VirtualServerSocket; import org.jboss.remoting.transport.multiplex.VirtualSocket; import org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.SocketGroupInfo; import org.jboss.remoting.transport.socket.SocketServerInvoker; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; import java.util.Set; /** * @author Tom Elrod */ public class MultiplexCallbackTestClient extends TestCase { private String locatorUri = "multiplex://localhost:8999"; private boolean gotCallback = false; public void testCallback() throws Throwable { Client client = new Client(new InvokerLocator(locatorUri)); client.connect(); InvokerCallbackHandler testCallbackHandler = new MultiplexCallbackTestClient.TestCallbackHandler(); client.addListener(testCallbackHandler, new HashMap(), "foobar"); client.invoke("foobar"); Thread.sleep(5000); client.removeListener(testCallbackHandler); client.disconnect(); assertTrue(gotCallback); } /** * This test verifies that when Client creates an anonymous callback Connector, * the callback connection from server to client uses the same underlying * socket as the client to server connection. * * @throws Throwable */ public void testSharedCallbackConnection() throws Throwable { // Wait for any existing MultiplexingManagers to close. Thread.sleep(5000); // There should be 0 MultiplexingManagers before Client is connected. Field field = MultiplexingManager.class.getDeclaredField("allManagers"); field.setAccessible(true); Set allManagers = (Set) field.get(null); assertNotNull(allManagers); assertEquals(0, allManagers.size()); // Create and connect Client. Client client = new Client(new InvokerLocator(locatorUri)); client.connect(); // There should be 1 MultiplexingManager now that Client is connected. assertEquals(1, allManagers.size()); // Add a push CallbackHandler. InvokerCallbackHandler testCallbackHandler = new TestCallbackHandler(); client.addListener(testCallbackHandler, new HashMap(), "foobar"); // There should still be 1 MultiplexingManager, since client invoker and // server invoker should be using the same connection. assertEquals(1, allManagers.size()); // Show connection works. client.invoke("foobar"); Thread.sleep(5000); assertTrue(gotCallback); // Get client invoker's MultiplexingManager. MultiplexClientInvoker clientInvoker = (MultiplexClientInvoker) client.getInvoker(); field = MultiplexClientInvoker.class.getDeclaredField("socketGroupInfo"); field.setAccessible(true); SocketGroupInfo sgi = (SocketGroupInfo) field.get(clientInvoker); VirtualSocket socket = sgi.getPrimingSocket(); field = VirtualSocket.class.getDeclaredField("manager"); field.setAccessible(true); MultiplexingManager clientManager = (MultiplexingManager) field.get(socket); assertNotNull(clientManager); // Get server invoker's MultiplexingManager. field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectors = (Map) field.get(client); assertEquals(1, callbackConnectors.size()); Set callbackConnectorSet = (Set) callbackConnectors.values().iterator().next(); assertEquals(1, callbackConnectorSet.size()); Connector connector = (Connector) callbackConnectorSet.iterator().next(); MultiplexServerInvoker serverInvoker = (MultiplexServerInvoker) connector.getServerInvoker(); field = SocketServerInvoker.class.getDeclaredField("serverSocket"); field.setAccessible(true); VirtualServerSocket serverSocket = (VirtualServerSocket) field.get(serverInvoker); field = VirtualServerSocket.class.getDeclaredField("manager"); field.setAccessible(true); MultiplexingManager serverManager = (MultiplexingManager) field.get(serverSocket); // Show client and server invokers are using the same MultiplexingManager. assertEquals(clientManager, serverManager); client.removeListener(testCallbackHandler); client.disconnect(); Thread.sleep(5000); // The connection should be closed and there should be 0 MultiplexingManagers. assertEquals(0, allManagers.size()); } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("callback = " + callback); Object handle = callback.getCallbackHandleObject(); if ("foobar".equals(handle)) { gotCallback = true; } } } } ././@LongLink 0000000 0000000 0000000 00000000217 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/multiplex/MultiplexCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000644 0001750 0001750 00000004543 10433024164 033363 0 ustar twerner twerner package org.jboss.test.remoting.callback.push.bidirectional.multiplex; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.List; /** * @author Tom Elrod */ public class MultiplexCallbackTestServer extends ServerTestCase { private String locatorUri = "multiplex://localhost:8999"; private Connector connector = null; public void setUp() throws Exception { connector = new Connector(locatorUri); connector.create(); connector.addInvocationHandler("test", new MultiplexCallbackTestServer.TestInvocationHandler()); connector.start(); } public void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { MultiplexCallbackTestServer server = new MultiplexCallbackTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } public class TestInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } public Object invoke(InvocationRequest invocation) throws Throwable { for (int x = 0; x < listeners.size(); x++) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) listeners.get(x); callbackHandler.handleCallback(new Callback("This is callback payload")); } return "barfoo"; } public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } } } ././@LongLink 0000000 0000000 0000000 00000000173 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/MultipleCallbackServersTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/MultipleCallba0000644 0001750 0001750 00000015337 10433770344 033401 0 ustar twerner twerner /* * 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.remoting.callback.push; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * @author Ovidiu Feodorov * @version $Revision: 1036 $ * * $Id: MultipleCallbackServersTestCase.java 1036 2006-05-21 04:47:32Z telrod $ */ public class MultipleCallbackServersTestCase extends TestCase { // Constants ----------------------------------------------------- private static final Logger log = Logger.getLogger(MultipleCallbackServersTestCase.class); // Static -------------------------------------------------------- // Attributes ---------------------------------------------------- // Constructors -------------------------------------------------- public MultipleCallbackServersTestCase(String name) { super(name); } // Public -------------------------------------------------------- public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } public void testIfDisconnectClearsInvokerRegistry() throws Throwable { String serverlocatorURI = "socket://localhost:5555"; Connector server = new Connector(); ServerInvocationHandlerImpl serverHandler = new ServerInvocationHandlerImpl(); server.setInvokerLocator(serverlocatorURI); server.start(); server.addInvocationHandler("TEST", serverHandler); String callbackServer1URI = "socket://localhost:1111"; Connector callbackServer1 = new Connector(); callbackServer1.setInvokerLocator(callbackServer1URI); callbackServer1.start(); String callbackServer2URI = "socket://localhost:2222"; Connector callbackServer2 = new Connector(); callbackServer2.setInvokerLocator(callbackServer2URI); callbackServer2.start(); Client client = new Client(new InvokerLocator(serverlocatorURI), "TEST"); client.connect(); // add a listener that uses callbackServer1 InvokerCallbackHandlerImpl listener1 = new InvokerCallbackHandlerImpl("ONE"); client.addListener(listener1, new InvokerLocator(callbackServer1URI)); assertEquals(1, serverHandler.size()); // add a listener that uses callbackServer2 InvokerCallbackHandlerImpl listener2 = new InvokerCallbackHandlerImpl("TWO"); client.addListener(listener2, new InvokerLocator(callbackServer2URI)); assertEquals(2, serverHandler.size()); // remove them /** * Note, if uncomment the following, the test will fail. * This is because each Client has its own session id which * is used as part of the key for each callback listener regsitered * on the server. Therefore a new Client, means the callback listener * key used for the remove will be different than the original one. */ // client = new Client(new InvokerLocator(serverlocatorURI), "TEST"); client.removeListener(listener1); assertEquals(1, serverHandler.size()); try { client.removeListener(listener1); assertTrue("Expected to get exception for removing same listener twice.", false); } catch(Throwable thr) { assertTrue("Expected to get exception for removing same listener twice.", true); } client.removeListener(listener2); assertEquals(0, serverHandler.size()); try { client.removeListener(listener2); assertTrue("Excpected to get exception from removing second listener twice.", false); } catch(Throwable thr) { assertTrue("Expected to get exception from removing second listener twice.", true); } } // Package protected --------------------------------------------- // Protected ----------------------------------------------------- // Private ------------------------------------------------------- // Inner classes ------------------------------------------------- private class InvokerCallbackHandlerImpl implements InvokerCallbackHandler { private String name; public InvokerCallbackHandlerImpl(String name) { this.name = name; } public void handleCallback(Callback c) { } public String getName() { return name; } } private class ServerInvocationHandlerImpl implements ServerInvocationHandler { private List listeners = Collections.synchronizedList(new ArrayList()); public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public Object invoke(InvocationRequest invocation) throws Throwable { return null; } public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { log.info("Trying to remove listener: " + callbackHandler); boolean removed = listeners.remove(callbackHandler); if(removed) { log.info("Listener removed"); } else { log.info("Listener NOT removed"); } } public int size() { return listeners.size(); } } } ././@LongLink 0000000 0000000 0000000 00000000175 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/ImplicitCallbackConnectorTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/ImplicitCallba0000644 0001750 0001750 00000033546 10576176321 033365 0 ustar twerner twerner /* * 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.remoting.callback.push; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit tests for JBREM-727. * * @author Ron Sigal * @version $Revision: 2312 $ ** Copyright Mar 15, 2007 *
*/ public class ImplicitCallbackConnectorTestCase extends TestCase { private static final String CALLBACK_TEST = "callbackTest"; private static Logger log = Logger.getLogger(ImplicitCallbackConnectorTestCase.class); private static boolean firstTime = true; // remoting server connector private Connector connector; private SampleInvocationHandler invocationHandler; private Client client; /** * Sets up target remoting server and client. */ public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(serverConfig); connector = new Connector(serverLocator, serverConfig); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); log.info("Started remoting server with locator uri of: " + locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(clientConfig); client = new Client(serverLocator, clientConfig); client.connect(); log.info("Client is connected to " + serverLocator); } /** * Shuts down the server and client */ public void tearDown() { if (client != null) { client.disconnect(); } if (connector != null) { connector.stop(); connector.destroy(); } } public void testMultipleCallbackConnectors() throws Throwable { log.info("entering " + getName()); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); int COUNT = 5; for (int i = 0; i < COUNT; i++) { client.addListener(callbackHandler, new HashMap(), null, true); } log.info("client added callback handlers"); Set callbackConnectors = client.getCallbackConnectors(callbackHandler); assertNotNull(callbackConnectors); assertEquals(5, callbackConnectors.size()); Class[] classes = ServerInvoker.class.getDeclaredClasses(); Class callbackContainerClass = null; for (int i = 0; i < classes.length; i++) { log.info(classes[i]); String fqn = classes[i].getName(); String className = fqn.substring(fqn.lastIndexOf('.') + 1); log.info(className); if ("ServerInvoker$CallbackContainer".equals(className)) { callbackContainerClass = classes[i]; break; } } assertTrue(callbackContainerClass != null); Method method = callbackContainerClass.getDeclaredMethod("getCallbackHandler", new Class[] {}); method.setAccessible(true); Field field = ServerInvoker.class.getDeclaredField("clientCallbackListener"); field.setAccessible(true); Iterator it = callbackConnectors.iterator(); while (it.hasNext()) { Connector callbackConnector = (Connector) it.next(); ServerInvoker serverInvoker = callbackConnector.getServerInvoker(); Map clientCallbackListener = (Map) field.get(serverInvoker); assertEquals(1, clientCallbackListener.size()); Object callbackContainer = clientCallbackListener.values().iterator().next(); assertEquals(callbackHandler, method.invoke(callbackContainer, new Object[]{})); } client.invoke(CALLBACK_TEST); assertEquals(COUNT, callbackHandler.callbackCounter); client.removeListener(callbackHandler); callbackConnectors = client.getCallbackConnectors(callbackHandler); assertNull(callbackConnectors); } public void testReusedCallbackConnectorsSameHandler() throws Throwable { log.info("entering " + getName()); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); log.info("client added callback handler first time"); Set callbackConnectors = client.getCallbackConnectors(callbackHandler); assertNotNull(callbackConnectors); assertEquals(1, callbackConnectors.size()); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); client.addListener(callbackHandler, callbackConnector.getLocator()); log.info("client added callback handler second time"); callbackConnectors = client.getCallbackConnectors(callbackHandler); assertNotNull(callbackConnectors); assertEquals(1, callbackConnectors.size()); Class[] classes = ServerInvoker.class.getDeclaredClasses(); Class callbackContainerClass = null; for (int i = 0; i < classes.length; i++) { log.info(classes[i]); String fqn = classes[i].getName(); String className = fqn.substring(fqn.lastIndexOf('.') + 1); log.info(className); if ("ServerInvoker$CallbackContainer".equals(className)) { callbackContainerClass = classes[i]; break; } } assertTrue(callbackContainerClass != null); Method method = callbackContainerClass.getDeclaredMethod("getCallbackHandler", new Class[] {}); method.setAccessible(true); Field field = ServerInvoker.class.getDeclaredField("clientCallbackListener"); field.setAccessible(true); ServerInvoker serverInvoker = callbackConnector.getServerInvoker(); Map clientCallbackListener = (Map) field.get(serverInvoker); assertEquals(1, clientCallbackListener.size()); Object callbackContainer = clientCallbackListener.values().iterator().next(); assertEquals(callbackHandler, method.invoke(callbackContainer, new Object[]{})); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.callbackCounter); client.removeListener(callbackHandler); callbackConnectors = client.getCallbackConnectors(callbackHandler); assertNull(callbackConnectors); } public void testReusedCallbackConnectorsDifferentHandlers() throws Throwable { log.info("entering " + getName()); SimpleCallbackHandler callbackHandler1 = new SimpleCallbackHandler(); client.addListener(callbackHandler1, new HashMap(), null, true); log.info("client added first callback handler"); Set callbackConnectors = client.getCallbackConnectors(callbackHandler1); assertNotNull(callbackConnectors); assertEquals(1, callbackConnectors.size()); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); SimpleCallbackHandler callbackHandler2 = new SimpleCallbackHandler(); client.addListener(callbackHandler2, callbackConnector.getLocator()); callbackConnectors = client.getCallbackConnectors(callbackHandler1); assertNotNull(callbackConnectors); assertEquals(1, callbackConnectors.size()); assertNull(client.getCallbackConnectors(callbackHandler2)); Class[] classes = ServerInvoker.class.getDeclaredClasses(); Class callbackContainerClass = null; for (int i = 0; i < classes.length; i++) { log.info(classes[i]); String fqn = classes[i].getName(); String className = fqn.substring(fqn.lastIndexOf('.') + 1); log.info(className); if ("ServerInvoker$CallbackContainer".equals(className)) { callbackContainerClass = classes[i]; break; } } assertTrue(callbackContainerClass != null); Method method = callbackContainerClass.getDeclaredMethod("getCallbackHandler", new Class[] {}); method.setAccessible(true); Field field = ServerInvoker.class.getDeclaredField("clientCallbackListener"); field.setAccessible(true); ServerInvoker serverInvoker = callbackConnector.getServerInvoker(); Map clientCallbackListener = (Map) field.get(serverInvoker); assertEquals(2, clientCallbackListener.size()); Iterator it = clientCallbackListener.values().iterator(); Object callbackContainer1 = it.next(); Object callbackContainer2 = it.next(); assertTrue( callbackHandler1.equals(method.invoke(callbackContainer1, new Object[]{})) && callbackHandler2.equals(method.invoke(callbackContainer2, new Object[]{})) || callbackHandler1.equals(method.invoke(callbackContainer2, new Object[]{})) && callbackHandler2.equals(method.invoke(callbackContainer1, new Object[]{}))); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler1.callbackCounter); assertEquals(1, callbackHandler2.callbackCounter); client.removeListener(callbackHandler1); callbackConnectors = client.getCallbackConnectors(callbackHandler1); assertNull(callbackConnectors); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) { } protected void addExtraServerConfig(Map config) { } /** * Simple invocation handler implementation. When callback client's are registered, will * generate callbacks periodically. */ static class SampleInvocationHandler implements ServerInvocationHandler { public Set callbackHandlers = new HashSet(); private int counter = 0; public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("Adding callback listener."); callbackHandlers.add(callbackHandler); } public Object invoke(InvocationRequest invocation) throws Throwable { Object payload = invocation.getParameter(); if (CALLBACK_TEST.equals(payload)) { try { Iterator it = callbackHandlers.iterator(); while (it.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) it.next(); log.info("sending callback: " + ++counter); callbackHandler.handleCallback(new Callback("callback")); } log.info("sent callback"); } catch (HandleCallbackException e) { log.error("Unable to send callback"); } return null; } else { throw new Exception("unrecognized invocation: " + payload); } } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class SimpleCallbackHandler implements InvokerCallbackHandler { public int callbackCounter; private Object lock = new Object(); public void handleCallback(Callback callback) throws HandleCallbackException { log.debug("received callback: " + callback.getParameter()); synchronized (lock) { callbackCounter++; } } } } ././@LongLink 0000000 0000000 0000000 00000000164 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/InVMPushCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/InVMPushCallba0000644 0001750 0001750 00000014210 10433770344 033244 0 ustar twerner twerner /* * 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.remoting.callback.push; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.Random; /** * Tests a push callback in the situation when the client, target server and callback server are in * the same VM. No need for DistributedTestCase. * * @author Ovidiu Feodorov * @version $Revision: 1036 $ */ public class InVMPushCallbackTestCase extends TestCase { // Constants ----------------------------------------------------- // Static -------------------------------------------------------- // Attributes ---------------------------------------------------- protected InvokerLocator targetServerLocator; protected InvokerLocator callbackServerLocator; protected Connector targetServerConnector; protected Connector callbackServerConnector; protected ServerInvocationHandlerImpl targetServerInvocationHandler; protected Client client; protected InvokerCallbackHandlerImpl callbackHandler; // Constructors -------------------------------------------------- public InVMPushCallbackTestCase(String name) { super(name); } // TestCase override --------------------------------------------- public void setUp() throws Exception { super.setUp(); targetServerLocator = new InvokerLocator("socket://localhost:2323"); callbackServerLocator = new InvokerLocator("socket://localhost:3434"); targetServerConnector = new Connector(); targetServerConnector.setInvokerLocator(targetServerLocator.getLocatorURI()); targetServerConnector.start(); targetServerInvocationHandler = new ServerInvocationHandlerImpl(); targetServerConnector.addInvocationHandler("TARGET", targetServerInvocationHandler); callbackServerConnector = new Connector(); callbackServerConnector.setInvokerLocator(callbackServerLocator.getLocatorURI()); callbackServerConnector.start(); callbackServerConnector.addInvocationHandler("IRRELEVANT", new ServerInvocationHandlerImpl()); client = new Client(targetServerLocator); client.connect(); callbackHandler = new InvokerCallbackHandlerImpl(); try { client.addListener(callbackHandler, callbackServerLocator); } catch(Throwable t) { throw new Exception(t); } client.connect(); } public void tearDown() throws Exception { callbackServerConnector.stop(); targetServerConnector.stop(); client.disconnect(); super.tearDown(); } // Public -------------------------------------------------------- public void testPushCallback() throws Exception { // send callback, the callback handler must receive it Long arg = new Long(new Random().nextLong()); targetServerInvocationHandler.sendCallback(arg); assertEquals(arg, callbackHandler.getReceivedArgument()); } // Package protected --------------------------------------------- // Protected ----------------------------------------------------- // Private ------------------------------------------------------- // Inner classes ------------------------------------------------- private class ServerInvocationHandlerImpl implements ServerInvocationHandler { private MBeanServer server; private ServerInvoker invoker; private InvokerCallbackHandler theOnlyHandler; // ServerInocationHandler implementation --------------------- public void setMBeanServer(MBeanServer server) { this.server = server; } public void setInvoker(ServerInvoker invoker) { this.invoker = invoker; } public Object invoke(InvocationRequest invocation) throws Throwable { return null; } public void addListener(InvokerCallbackHandler callbackHandler) { theOnlyHandler = callbackHandler; } public void removeListener(InvokerCallbackHandler callbackHandler) { // noop } // Public --------------------------------------------------- public void sendCallback(Object arg) throws Exception { Callback callback = new Callback(arg); theOnlyHandler.handleCallback(callback); } } private class InvokerCallbackHandlerImpl implements InvokerCallbackHandler { Object receivedArg; // InvokerCallbackHandler implementation --------------------- public synchronized void handleCallback(Callback callback) throws HandleCallbackException { receivedArg = callback.getParameter(); } // Public ---------------------------------------------------- public synchronized Object getReceivedArgument() { return receivedArg; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/ 0000755 0001750 0001750 00000000000 11632407041 031253 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/RMICallbackTimeoutTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/RMICallback0000644 0001750 0001750 00000002513 11413660476 033255 0 ustar twerner twerner /* * 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.remoting.callback.timeout; /** * Unit test for JBREM-799. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Jan 26, 2008 *
*/ public class RMICallbackTimeoutTestCase extends CallbackTimeoutTestParent { protected String getTransport() { return "rmi"; } } ././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/BisocketCallbackTimeoutTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/BisocketCal0000644 0001750 0001750 00000053764 10666622655 033420 0 ustar twerner twerner /* * 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.remoting.callback.timeout; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.ClientSocketWrapper; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.ServerSocketWrapper; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-765. * * @author Ron Sigal * @version $Revision: 2751 $ ** Copyright Aug 5, 2007 *
*/ public class BisocketCallbackTimeoutTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(BisocketCallbackTimeoutTestCase.class); private static final String CALLBACK_TEST = "callbackTest"; private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private TestInvocationHandler invocationHandler; /** * Sets up target remoting server. */ public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } /** * Verifies that "timeout" value is used in absence of "callbackTimeout" value. */ public void testNoCallbackTimeout() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "3000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap()); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. assertTrue(connector.getServerInvoker() instanceof SocketServerInvoker); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); Set threads = clientpool.getContents(); assertEquals(1, threads.size()); ServerThread serverThread = (ServerThread) threads.iterator().next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); assertTrue(field.get(serverThread) instanceof ServerSocketWrapper); ServerSocketWrapper serverWrapper = (ServerSocketWrapper) field.get(serverThread); assertEquals(3000, serverWrapper.getTimeout()); // Verify that "timeout" is used in the absence of "callbackTimeout". field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(3000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * Values are specified in configuration map. */ public void testDistinctCallbackTimeoutConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "3000"); config.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap()); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. assertTrue(connector.getServerInvoker() instanceof SocketServerInvoker); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); Set threads = clientpool.getContents(); assertEquals(1, threads.size()); ServerThread serverThread = (ServerThread) threads.iterator().next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); assertTrue(field.get(serverThread) instanceof ServerSocketWrapper); ServerSocketWrapper serverWrapper = (ServerSocketWrapper) field.get(serverThread); assertEquals(3000, serverWrapper.getTimeout()); // Verify that "callbackTimeout" is used correctly. field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(7000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * Values are specified in InvokerLocator. */ public void testDistinctCallbackTimeoutLocator() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?timeout=3000&callbackTimeout=7000"; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap()); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. assertTrue(connector.getServerInvoker() instanceof SocketServerInvoker); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); Set threads = clientpool.getContents(); assertEquals(1, threads.size()); ServerThread serverThread = (ServerThread) threads.iterator().next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); assertTrue(field.get(serverThread) instanceof ServerSocketWrapper); ServerSocketWrapper serverWrapper = (ServerSocketWrapper) field.get(serverThread); assertEquals(3000, serverWrapper.getTimeout()); // Verify that "callbackTimeout" is used correctly. field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(7000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "timeout" value is used in absense of "callbackTimeout". * "timeout" value is specified in Client.addListener() metadata map. */ public void testNoCallbackTimeoutMetadata() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); Map metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "3000"); client.addListener(callbackHandler, metadata); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(3000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * "callbackTimeout" is specified in Client.addListener() metadata map. */ public void testDistinctCallbackTimeoutMetadata() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); Map metadata = new HashMap(); metadata.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); client.addListener(callbackHandler, metadata); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "callbackTimeout" is used correctly. SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(7000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class TestInvocationHandler implements ServerInvocationHandler { public Set listeners = new HashSet(); public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { if (CALLBACK_TEST.equals(invocation.getParameter())) { Iterator it = listeners.iterator(); while (it.hasNext()) { InvokerCallbackHandler handler = (InvokerCallbackHandler) it.next(); handler.handleCallback(new Callback("test")); } } return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestInvokerCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; } } } ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/SocketCallbackTimeoutTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/SocketCallb0000644 0001750 0001750 00000070527 10666622655 033417 0 ustar twerner twerner /* * 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.remoting.callback.timeout; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.ClientSocketWrapper; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.ServerSocketWrapper; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-765. * * @author Ron Sigal * @version $Revision: 2751 $ ** Copyright Aug 5, 2007 *
*/ public class SocketCallbackTimeoutTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(SocketCallbackTimeoutTestCase.class); private static final String CALLBACK_TEST = "callbackTest"; private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private TestInvocationHandler invocationHandler; /** * Sets up target remoting server. */ public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } /** * Verifies that "timeout" value is used in absence of "callbackTimeout" value. */ public void testNoCallbackTimeout() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "3000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. assertTrue(connector.getServerInvoker() instanceof SocketServerInvoker); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); Set threads = clientpool.getContents(); assertEquals(1, threads.size()); ServerThread serverThread = (ServerThread) threads.iterator().next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); assertTrue(field.get(serverThread) instanceof ServerSocketWrapper); ServerSocketWrapper serverWrapper = (ServerSocketWrapper) field.get(serverThread); assertEquals(3000, serverWrapper.getTimeout()); // Verify that "timeout" is used in the absence of "callbackTimeout". field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(3000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * Values are specified in configuration map. */ public void testDistinctCallbackTimeoutConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "3000"); config.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. assertTrue(connector.getServerInvoker() instanceof SocketServerInvoker); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); Set threads = clientpool.getContents(); assertEquals(1, threads.size()); ServerThread serverThread = (ServerThread) threads.iterator().next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); assertTrue(field.get(serverThread) instanceof ServerSocketWrapper); ServerSocketWrapper serverWrapper = (ServerSocketWrapper) field.get(serverThread); assertEquals(3000, serverWrapper.getTimeout()); // Verify that "callbackTimeout" is used correctly. field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(7000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * Values are specified in InvokerLocator. */ public void testDistinctCallbackTimeoutLocator() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?timeout=3000&callbackTimeout=7000"; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. assertTrue(connector.getServerInvoker() instanceof SocketServerInvoker); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); Set threads = clientpool.getContents(); assertEquals(1, threads.size()); ServerThread serverThread = (ServerThread) threads.iterator().next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); assertTrue(field.get(serverThread) instanceof ServerSocketWrapper); ServerSocketWrapper serverWrapper = (ServerSocketWrapper) field.get(serverThread); assertEquals(3000, serverWrapper.getTimeout()); // Verify that "callbackTimeout" is used correctly. field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(7000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "timeout" value is used in absense of "callbackTimeout". * "timeout" value is specified in Client.addListener() metadata map. */ public void testNoCallbackTimeoutMetadata() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); Map metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "3000"); client.addListener(callbackHandler, metadata, null, true); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(3000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * "callbackTimeout" is specified in Client.addListener() metadata map. */ public void testDistinctCallbackTimeoutMetadata() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); Map metadata = new HashMap(); metadata.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); client.addListener(callbackHandler, metadata, null, true); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "callbackTimeout" is used correctly. SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(7000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" specified in Client.addListener() metadata * map overrides values in server InvokerLocator and server configuration map. */ public void testMetadataOverridesLocatorAndConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?callbackTimeout=3000"; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); Map metadata = new HashMap(); metadata.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "11000"); client.addListener(callbackHandler, metadata, null, true); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "callbackTimeout" from Client.addListener() metadata // has precedence. SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(11000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" specified in server InvokerLocator * overrides value specified in server configuration map. */ public void testLocatorOverridesConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?callbackTimeout=3000"; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.counter); log.info("callback handler is installed"); // Verify that "callbackTimeout" from InvokerLocator overrides value // in configuration map. SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.values().iterator().next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker callbackClientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(callbackClientInvoker); assertEquals(1, pool.size()); Object o = pool.iterator().next(); assertTrue(o instanceof ClientSocketWrapper); ClientSocketWrapper clientWrapper = (ClientSocketWrapper) o; assertEquals(3000, clientWrapper.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class TestInvocationHandler implements ServerInvocationHandler { public Set listeners = new HashSet(); public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { if (CALLBACK_TEST.equals(invocation.getParameter())) { Iterator it = listeners.iterator(); while (it.hasNext()) { InvokerCallbackHandler handler = (InvokerCallbackHandler) it.next(); handler.handleCallback(new Callback("test")); } } return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestInvokerCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; } } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/HttpCallbackTimeoutTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/HttpCallbac0000644 0001750 0001750 00000002515 11413660476 033374 0 ustar twerner twerner /* * 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.remoting.callback.timeout; /** * Unit test for JBREM-799. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Jan 26, 2008 *
*/ public class HttpCallbackTimeoutTestCase extends CallbackTimeoutTestParent { protected String getTransport() { return "http"; } } ././@LongLink 0000000 0000000 0000000 00000000170 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/CallbackTimeoutTestParent.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/CallbackTim0000644 0001750 0001750 00000056522 11413660476 033370 0 ustar twerner twerner /* * 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.remoting.callback.timeout; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-799. * * @author Ron Sigal * @version $Revision: 1.1.2.2 $ ** Copyright Jan 25, 2008 *
*/ abstract public class CallbackTimeoutTestParent extends TestCase { public static int port; private static Logger log = Logger.getLogger(CallbackTimeoutTestParent.class); private static final String CALLBACK_TEST = "callbackTest"; private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private TestInvocationHandler invocationHandler; /** * Sets up target remoting server. */ public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } /** * Verifies that "timeout" value is used in absence of "callbackTimeout" value. */ public void testNoCallbackTimeout() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "3000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler testCallbackHandler = new TestInvokerCallbackHandler(); client.addListener(testCallbackHandler, new HashMap(), null, true); client.invoke(CALLBACK_TEST); assertEquals(1, testCallbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); Map configuration = serverInvoker.getConfiguration(); assertEquals("3000", configuration.get(ServerInvoker.TIMEOUT)); // Verify that "timeout" is used in the absence of "callbackTimeout". Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) o; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callBackClient = (Client) field.get(callbackHandler); configuration = callBackClient.getConfiguration(); assertEquals("3000", configuration.get(ServerInvoker.TIMEOUT)); client.removeListener(testCallbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * Values are specified in configuration map. */ public void testDistinctCallbackTimeoutConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "3000"); config.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler testCallbackHandler = new TestInvokerCallbackHandler(); client.addListener(testCallbackHandler, new HashMap(), null, true); client.invoke(CALLBACK_TEST); assertEquals(1, testCallbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); Map configuration = serverInvoker.getConfiguration(); assertEquals("3000", configuration.get(ServerInvoker.TIMEOUT)); // Verify that "callbackTimeout" is used correctly. Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) o; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callBackClient = (Client) field.get(callbackHandler); configuration = callBackClient.getConfiguration(); assertEquals("7000", configuration.get(ServerInvoker.TIMEOUT)); client.removeListener(testCallbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * Values are specified in InvokerLocator. */ public void testDistinctCallbackTimeoutLocator() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?timeout=3000&callbackTimeout=7000"; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler testCallbackHandler = new TestInvokerCallbackHandler(); client.addListener(testCallbackHandler, new HashMap(), null, true); client.invoke(CALLBACK_TEST); assertEquals(1, testCallbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); Map configuration = serverInvoker.getConfiguration(); assertEquals("3000", configuration.get(ServerInvoker.TIMEOUT)); // Verify that "callbackTimeout" is used correctly. Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) o; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callBackClient = (Client) field.get(callbackHandler); configuration = callBackClient.getConfiguration(); assertEquals("7000", configuration.get(ServerInvoker.TIMEOUT)); client.removeListener(testCallbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "timeout" value is used in absense of "callbackTimeout". * "timeout" value is specified in Client.addListener() metadata map. */ public void testNoCallbackTimeoutMetadata() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler testCallbackHandler = new TestInvokerCallbackHandler(); Map metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "3000"); client.addListener(testCallbackHandler, metadata, null, true); client.invoke(CALLBACK_TEST); assertEquals(1, testCallbackHandler.counter); log.info("callback handler is installed"); // Verify that "timeout" is used in the absence of "callbackTimeout". ServerInvoker serverInvoker = connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) o; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callBackClient = (Client) field.get(callbackHandler); Map configuration = callBackClient.getConfiguration(); assertEquals("3000", configuration.get(ServerInvoker.TIMEOUT)); client.removeListener(testCallbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" value overrides "timeout" value. * "callbackTimeout" is specified in Client.addListener() metadata map. */ public void testDistinctCallbackTimeoutMetadata() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler testCallbackHandler = new TestInvokerCallbackHandler(); Map metadata = new HashMap(); metadata.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); client.addListener(testCallbackHandler, metadata, null, true); client.invoke(CALLBACK_TEST); assertEquals(1, testCallbackHandler.counter); log.info("callback handler is installed"); // Verify that "callbackTimeout" is used correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) o; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callBackClient = (Client) field.get(callbackHandler); Map configuration = callBackClient.getConfiguration(); assertEquals("7000", configuration.get(ServerInvoker.TIMEOUT)); client.removeListener(testCallbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" specified in Client.addListener() metadata * map overrides values in server InvokerLocator and server configuration map. */ public void testMetadataOverridesLocatorAndConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?callbackTimeout=3000"; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler testCallbackHandler = new TestInvokerCallbackHandler(); Map metadata = new HashMap(); metadata.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "11000"); client.addListener(testCallbackHandler, metadata, null, true); client.invoke(CALLBACK_TEST); assertEquals(1, testCallbackHandler.counter); log.info("callback handler is installed"); // Verify that "callbackTimeout" from Client.addListener() metadata // has precedence. ServerInvoker serverInvoker = connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) o; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callBackClient = (Client) field.get(callbackHandler); Map configuration = callBackClient.getConfiguration(); assertEquals("11000", configuration.get(ServerInvoker.TIMEOUT)); client.removeListener(testCallbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that "callbackTimeout" specified in server InvokerLocator * overrides value specified in server configuration map. */ public void testLocatorOverridesConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?callbackTimeout=3000"; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvokerCallbackHandler.CALLBACK_TIMEOUT, "7000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(serverLocator, clientConfig); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("client is connected"); // Add callback handler. TestInvokerCallbackHandler testCallbackHandler = new TestInvokerCallbackHandler(); client.addListener(testCallbackHandler, new HashMap(), null, true); client.invoke(CALLBACK_TEST); assertEquals(1, testCallbackHandler.counter); log.info("callback handler is installed"); // Verify that "callbackTimeout" from InvokerLocator overrides value // in configuration map. ServerInvoker serverInvoker = connector.getServerInvoker(); Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler) o; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callBackClient = (Client) field.get(callbackHandler); Map configuration = callBackClient.getConfiguration(); assertEquals("3000", configuration.get(ServerInvoker.TIMEOUT)); client.removeListener(testCallbackHandler); client.disconnect(); connector.stop(); } abstract protected String getTransport(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class TestInvocationHandler implements ServerInvocationHandler { public Set listeners = new HashSet(); public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { if (CALLBACK_TEST.equals(invocation.getParameter())) { Iterator it = listeners.iterator(); while (it.hasNext()) { InvokerCallbackHandler handler = (InvokerCallbackHandler) it.next(); handler.handleCallback(new Callback("test")); } } return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestInvokerCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; } } } ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestClient.0000644 0001750 0001750 00000026145 10433770344 033300 0 ustar twerner twerner /* * 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.remoting.callback; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * @author Tom Elrod */ public class CallbackTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; private String locatorURI = transport + "://" + host + ":" + port; private Client remotingClient; private Connector connector; private static final Logger log = Logger.getLogger(CallbackTestClient.class); public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; private void init() throws Exception { createRemotingClient(); } public void createRemotingClient() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); // This could have been new Client(locator), but want to show that subsystem param is null // Could have also been new Client(locator, "sample"); remotingClient = new Client(locator); remotingClient.connect(); } public void makeInvocation() throws Throwable { Object response = remotingClient.invoke("Do something", null); System.out.println("Invocation response: " + response); } public void setUp() throws Exception { init(); } public void tearDown() throws Exception { if(remotingClient != null) { remotingClient.disconnect(); } if(connector != null) { connector.stop(); connector.destroy(); } } public void testPullCallback() throws Throwable { CallbackHandler callbackHandler = new CallbackHandler(); try { // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler); // now make invocation on server, which should cause a callback to happen makeInvocation(); List callbacks = remotingClient.getCallbacks(callbackHandler); Iterator itr = callbacks.iterator(); while(itr.hasNext()) { Object obj = itr.next(); log.info("testPullCallback - Callback object should have been " + CallbackTestServer.CALLBACK_VALUE + " and was " + (obj == null ? null : ((Callback) obj).getCallbackObject())); if(obj instanceof Callback) { assertEquals("Callback object is NOT same.", CallbackTestServer.CALLBACK_VALUE, ((Callback) obj).getCallbackObject()); } else { assertTrue("Callback object is NOT of type Callback.", false); } } } finally { if(remotingClient != null) { // remove callback handler from server remotingClient.removeListener(callbackHandler); } } } public void testPushCallback() throws Throwable { CallbackHandler callbackHandler = new CallbackHandler(); try { // Using loctor with port value one higher than the target server String callbackLocatorURI = transport + "://" + host + ":" + (port + 5); InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); log.info("testPushCallback - Setting up server."); // call to create remoting server to // receive client callbacks. setupServer(callbackLocator); // Callback handle object will be passed back as part of the callback object String callbackHandleObject = "myCallbackHandleObject"; log.info("testPushCallback - adding listener."); // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler, callbackLocator, callbackHandleObject); log.info("testPushCallback - make invocation"); // now make invocation on server, which should cause a callback to happen makeInvocation(); // need to wait for brief moment so server can callback Thread.sleep(5000); Callback callback = callbackHandler.getCallback(); log.info("testPushCallback - Callback returned was " + callback); assertNotNull("Callback returned was null.", callback); Object callbackObj = callback.getCallbackObject(); log.info("testPushCallback - Callback value should have been " + CallbackTestServer.CALLBACK_VALUE + ", and was " + callbackObj); assertEquals("Callback value should have been " + CallbackTestServer.CALLBACK_VALUE + ", but was " + callbackObj, CallbackTestServer.CALLBACK_VALUE, callbackObj); Object callbackHandleObj = callback.getCallbackHandleObject(); log.info("testPushCallback - Callback handle object should have been " + callbackHandleObject + ", and was " + callbackHandleObj); assertEquals("Callback handle object should have been " + callbackHandleObject + ", but was " + callbackHandleObj, callbackHandleObject, callbackHandleObj); InvokerLocator serverLoc = callback.getServerLocator(); log.info("testPushCallback - Callback server locator should have been " + remotingClient.getInvoker().getLocator() + ", and was " + serverLoc); assertEquals("Callback server locator should have been " + remotingClient.getInvoker().getLocator() + ", but was " + serverLoc, remotingClient.getInvoker().getLocator(), serverLoc); } finally { if(remotingClient != null) { // remove callback handler from server remotingClient.removeListener(callbackHandler); } } } public void setupServer(InvokerLocator locator) throws Exception { log.info("Starting remoting server with locator uri of: " + locator); try { connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); } catch(Exception e) { log.error("Error starting callback server", e); throw e; } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback("This is the payload of callback invocation."); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } public class CallbackHandler implements InvokerCallbackHandler { private Callback callback; /** * Will take the callback message and send back to client. * If client locator is null, will store them till client polls to get them. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { this.callback = callback; System.out.println("Received callback value of: " + callback.getCallbackObject()); System.out.println("Received callback handle object of: " + callback.getCallbackHandleObject()); System.out.println("Received callback server invoker of: " + callback.getServerLocator()); } public Callback getCallback() { return callback; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/ 0000755 0001750 0001750 00000000000 11632407041 031052 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000173 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchC0000644 0001750 0001750 00000003607 10561454004 033157 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import java.util.Map; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; /** * @author Ron Sigal * @version $Revision: 2110 $ ** Copyright Feb 3, 2007 *
*/ public class HTTPSAsynchCallbackTestServer extends SSLAsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new HTTPSAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "https"; } protected void addTransportSpecificConfig(Map config) { super.addTransportSpecificConfig(config); config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); } } ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynch0000644 0001750 0001750 00000003173 10561311235 033157 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SSLRMIAsynchCallbackTestServer extends SSLAsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new SSLRMIAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "sslrmi"; } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCa0000644 0001750 0001750 00000003162 10561311235 033167 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class HTTPAsynchCallbackTestServer extends AsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new HTTPAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "http"; } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynch0000644 0001750 0001750 00000004555 10561311235 033164 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class SSLRMIAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLRMIAsynchCallbackTestClient.class.getName(), 1, SSLRMIAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000202 00000000000 011557 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplexAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplex0000644 0001750 0001750 00000003215 10561311235 033342 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SSLMultiplexAsynchCallbackTestServer extends SSLAsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new SSLMultiplexAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "sslmultiplex"; } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCal0000644 0001750 0001750 00000003157 10561311235 033217 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class RMIAsynchCallbackTestServer extends AsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new RMIAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "rmi"; } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCa0000644 0001750 0001750 00000002457 10561311235 033175 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class HTTPAsynchCallbackTestClient extends AsynchCallbackTestClientRoot { protected String getTransport() { return "http"; } } ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsy0000644 0001750 0001750 00000003204 10561311235 033262 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SSLSocketAsynchCallbackTestServer extends SSLAsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new SSLSocketAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "sslsocket"; } } ././@LongLink 0000000 0000000 0000000 00000000201 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketA0000644 0001750 0001750 00000003212 10561311235 033220 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SSLBisocketAsynchCallbackTestServer extends SSLAsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new SSLBisocketAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "sslbisocket"; } } ././@LongLink 0000000 0000000 0000000 00000000200 00000000000 011555 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplexAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplex0000644 0001750 0001750 00000004577 10561311235 033356 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class SSLMultiplexAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLMultiplexAsynchCallbackTestClient.class.getName(), 1, SSLMultiplexAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000201 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketA0000644 0001750 0001750 00000003076 10561311235 033230 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SSLBisocketAsynchCallbackTestClient extends SSLAsynchCallbackTestClientRoot { protected void addTransportSpecificConfig(Map config) { super.addTransportSpecificConfig(config); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); } protected String getTransport() { return "sslbisocket"; } } ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsy0000644 0001750 0001750 00000003201 10561311235 033430 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class MultiplexAsynchCallbackTestServer extends AsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new MultiplexAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "multiplex"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/keystore 0000644 0001750 0001750 00000013761 10561311235 032651 0 ustar twerner twerner þíþí unit-tests-client xþ»õ X.509 ¶0‚²0‚ 0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205439Z 321218205439Z0h10 UUS10U Washington10U JBoss Inc.10U JBoss Inc.10Uunit-tests-client0‚·0‚,*†HÎ80‚ ýSu)RßJœ.ìäçö·R<ïD Ã?€¶Q&iE]@"QûY=Xú¿Åõº0öË›Ul×;€4oòf`·k™P¥¤ŸŸè{"ÂO»©×þ·Æø;WçÆ¨¦ûƒöÓÅÃ5TZ‘2öuó®+a×*ïò"ÑHÇ —`P#̲’¹‚¢ë„ðXõ ÷á …Ö›=Þ˼«\6¸W¹y”¯»ú:ê‚ùWL=‚gQYWŽºÔYOæq€´Iq#èL(·Ï 2ŒÈ¦á<z‹T|(࣮+³¦u‘n£ú!5bñûbz$;̤ñ¾¨Q‰¨ƒßáZ埒‹f^€{U%dL;þÏI*„ €?w=1y+¨Òølön%)êëµ UOu§òä†k4µïŽÚ3X©yƒ¨³„ÃT‰ªÁ@ótYíiC¦Þš¢àȦ6$Gmp MxÌýDešhUÌ¥LHFC–M¬w´è½Ñ+;}®ï”æTW©ÙÈÀÙþ"×ÒÐËÕN†v£‚&0‚"0 U0 0, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0 *†H†÷ …23&TÚÒ üap?½w3ôzk°‡kU1ì253.+àUܯÒllûc ~ÏÁ-øUî ‚$»O9¿ÇæÎ[Þ¶>,‰‡³×™¥ Ö¦;þ¯2·NŒà¬u¤¶ž}³ÒŽ›TÊ€ÍaeH©å¾º)vþäqUçgJ¨®Æ unit-tests-server xül‡ 0‚‹0 +* ‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZrIãð¬; 7L Ño§-ÿEŸzÀJ…Y÷DãµpñU†DMeÍ™È%fçO½“»„µÐÊß%–MD¾håÇc@uƬsIAˆ”/§Øÿ«`iW!np’Ç̦áç*ý°·mÙ\‹ñÞŽ²ÐyEŒâ¼ukÏ鱯‹M{‡4»loô¤-üv•ªåBv>=z£W¢÷Š©M…í¼UxÂ.íP´M³âˆu RyIÅœ“œº“Â;+±û¤;~äk…¦Œö»AÞEyDïÆÆ’Ì‹ÑOFLšœ8òÆ´á+±µ’P‰¨ >—;ä¬lnSäÄ›$562Y[l©+¦ äžY#¹#}Mïëîå(”Ç@bnœÁm05k‰õ$ý£²ÿ^™…þÙ+wN@ý¬ëî¦cçQ=‚βVÐÞ¤÷¿x°ŸŽšƒ)W„•@ÏU¼ X.509 §0‚£0‚ 0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205414Z 321218205414Z0X10 UUS10U Washington10U JBoss Inc.10 UQA10U localhost0‚¸0‚,*†HÎ80‚ ýSu)RßJœ.ìäçö·R<ïD Ã?€¶Q&iE]@"QûY=Xú¿Åõº0öË›Ul×;€4oòf`·k™P¥¤ŸŸè{"ÂO»©×þ·Æø;WçÆ¨¦ûƒöÓÅÃ5TZ‘2öuó®+a×*ïò"ÑHÇ —`P#̲’¹‚¢ë„ðXõ ÷á …Ö›=Þ˼«\6¸W¹y”¯»ú:ê‚ùWL=‚gQYWŽºÔYOæq€´Iq#èL(·Ï 2ŒÈ¦á<z‹T|(࣮+³¦u‘n£ú!5bñûbz$;̤ñ¾¨Q‰¨ƒßáZ埒‹f^€{U%dL;þÏI*… Ò3å¬Û— OªºŒôÿ麟¶½Ë€åßÝr‹}òÕbÖÐÊs±ù&ßlª`ÌgÒË‹3ØQ¶^ÅzCÒK¡ó0X*™V†ãÑX™F&éúãÉÀ• 'Ýwu%º™ùå±×£˜ç4\ºò‚”rp÷ƒ_1makÝûN£‚&0‚"0 U0 0, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0 *†H†÷ z±VyC3¤šQ€ŒÝÏì\ S©B® m¿´Â}‰Ôr3~ïOô”zà´vÆäë£=)g'„8x¿YO¸j²[qò‹ßÔî—B‰z¹óqTqé{ ¿/öÅ®ß^3Dç{Š%d¤ôâr×MZU«s€PÅ…ß*/žáÌûCN X.509 £0‚Ÿ0‚ «õRÿdMï0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205208Z 321218205208Z0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0Ÿ0 *†H†÷ 0‰ ÄÓ)haC^q~à¥ôáë#ïPá ˆ¯]ûJ“×-ÈjIGÇq©QÎD,~Hð—ÆßPI'׊ p¥*¯z“PÁ$å$S% 'ÝÞ•³å[SÆŒW£ž¡#I¦ˆ”Å-ãÈpXòS_î,ѹ ±lT¾-w„ˆ5ù‰ £ú0÷0UK•Øbì:ÕÙô’+óJú~0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0U0ÿ0 *†H†÷ éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ Ji ϽØmŠ=OÙˆ} ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8 openssl-ca xûxï X.509 £0‚Ÿ0‚ «õRÿdMï0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205208Z 321218205208Z0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0Ÿ0 *†H†÷ 0‰ ÄÓ)haC^q~à¥ôáë#ïPá ˆ¯]ûJ“×-ÈjIGÇq©QÎD,~Hð—ÆßPI'׊ p¥*¯z“PÁ$å$S% 'ÝÞ•³å[SÆŒW£ž¡#I¦ˆ”Å-ãÈpXòS_î,ѹ ±lT¾-w„ˆ5ù‰ £ú0÷0UK•Øbì:ÕÙô’+óJú~0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0U0ÿ0 *†H†÷ éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ Ji ϽØmŠ=OÙˆ} ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8 Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=us y5^¶ X.509 ¶0‚²0‚ 0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205439Z 321218205439Z0h10 UUS10U Washington10U JBoss Inc.10U JBoss Inc.10Uunit-tests-client0‚·0‚,*†HÎ80‚ ýSu)RßJœ.ìäçö·R<ïD Ã?€¶Q&iE]@"QûY=Xú¿Åõº0öË›Ul×;€4oòf`·k™P¥¤ŸŸè{"ÂO»©×þ·Æø;WçÆ¨¦ûƒöÓÅÃ5TZ‘2öuó®+a×*ïò"ÑHÇ —`P#̲’¹‚¢ë„ðXõ ÷á …Ö›=Þ˼«\6¸W¹y”¯»ú:ê‚ùWL=‚gQYWŽºÔYOæq€´Iq#èL(·Ï 2ŒÈ¦á<z‹T|(࣮+³¦u‘n£ú!5bñûbz$;̤ñ¾¨Q‰¨ƒßáZ埒‹f^€{U%dL;þÏI*„ €?w=1y+¨Òølön%)êëµ UOu§òä†k4µïŽÚ3X©yƒ¨³„ÃT‰ªÁ@ótYíiC¦Þš¢àȦ6$Gmp MxÌýDešhUÌ¥LHFC–M¬w´è½Ñ+;}®ï”æTW©ÙÈÀÙþ"×ÒÐËÕN†v£‚&0‚"0 U0 0, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0 *†H†÷ …23&TÚÒ üap?½w3ôzk°‡kU1ì253.+àUܯÒllûc ~ÏÁ-øUî ‚$»O9¿ÇæÎ[Þ¶>,‰‡³×™¥ Ö¦;þ¯2·NŒà¬u¤¶ž}³ÒŽ›TÊ€ÍaeH©å¾º)vþäqUçgJ¨®Æüü·Æ£Ì5qÔcn›†äö÷Ö ././@LongLink 0000000 0000000 0000000 00000000202 00000000000 011557 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplexAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplex0000644 0001750 0001750 00000002503 10561311235 033341 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SSLMultiplexAsynchCallbackTestClient extends SSLAsynchCallbackTestClientRoot { protected String getTransport() { return "sslmultiplex"; } } ././@LongLink 0000000 0000000 0000000 00000000175 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsy0000644 0001750 0001750 00000004566 10561311235 033276 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class SSLSocketAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLSocketAsynchCallbackTestClient.class.getName(), 1, SSLSocketAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsyn0000644 0001750 0001750 00000004563 10561311235 033402 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class BisocketAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(BisocketAsynchCallbackTestClient.class.getName(), 1, BisocketAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/truststore 0000644 0001750 0001750 00000007013 10561311235 033233 0 ustar twerner twerner þíþí unit-tests-client xüïS 0‚‹0 +* ‚wÜ'²†Ž:yüàO áõˆœ¯±ÕMÅ2sù#HÞ")È…ÆmˆHÝÕÇnøgi£¥è^¶\Ã4þ=PÅxך©ëÁÜ>ÌÍóÊíìPÇ37ÆÌ,–R#šBÍpçÞ–<ù5Û–©ô‡°C㵯3‚‘’'Ë3&¢žÔþâ1èÞM6X¶˜~–æ|EMYïúZ´ãq RýÞp„úøî´´»Èhz]Þš² 2â"_ˆZ`›Yô[a±åŠíTšÄÁ6D¥oDiùøÓõŸxè¯W[ŸiQyÌXew&e[Jët˜Ë=T}µ-¤ŠBÝ Jˆ:´d8©å_úmj±+¶Ç…»È‚K+s-7u§væJàŠ[À^4ÊÐ(Nïšé×þ«~®7àhoñ¥s½-ðl}ͰîrYäþ†ÆÉt÷;þTòÃßvʹ;%O íž*ÚTër˜J-]¢Âލb`OYJ X.509 ¶0‚²0‚ 0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205439Z 321218205439Z0h10 UUS10U Washington10U JBoss Inc.10U JBoss Inc.10Uunit-tests-client0‚·0‚,*†HÎ80‚ ýSu)RßJœ.ìäçö·R<ïD Ã?€¶Q&iE]@"QûY=Xú¿Åõº0öË›Ul×;€4oòf`·k™P¥¤ŸŸè{"ÂO»©×þ·Æø;WçÆ¨¦ûƒöÓÅÃ5TZ‘2öuó®+a×*ïò"ÑHÇ —`P#̲’¹‚¢ë„ðXõ ÷á …Ö›=Þ˼«\6¸W¹y”¯»ú:ê‚ùWL=‚gQYWŽºÔYOæq€´Iq#èL(·Ï 2ŒÈ¦á<z‹T|(࣮+³¦u‘n£ú!5bñûbz$;̤ñ¾¨Q‰¨ƒßáZ埒‹f^€{U%dL;þÏI*„ €?w=1y+¨Òølön%)êëµ UOu§òä†k4µïŽÚ3X©yƒ¨³„ÃT‰ªÁ@ótYíiC¦Þš¢àȦ6$Gmp MxÌýDešhUÌ¥LHFC–M¬w´è½Ñ+;}®ï”æTW©ÙÈÀÙþ"×ÒÐËÕN†v£‚&0‚"0 U0 0, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0 *†H†÷ …23&TÚÒ üap?½w3ôzk°‡kU1ì253.+àUܯÒllûc ~ÏÁ-øUî ‚$»O9¿ÇæÎ[Þ¶>,‰‡³×™¥ Ö¦;þ¯2·NŒà¬u¤¶ž}³ÒŽ›TÊ€ÍaeH©å¾º)vþäqUçgJ¨®Æ X.509 £0‚Ÿ0‚ «õRÿdMï0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205208Z 321218205208Z0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0Ÿ0 *†H†÷ 0‰ ÄÓ)haC^q~à¥ôáë#ïPá ˆ¯]ûJ“×-ÈjIGÇq©QÎD,~Hð—ÆßPI'׊ p¥*¯z“PÁ$å$S% 'ÝÞ•³å[SÆŒW£ž¡#I¦ˆ”Å-ãÈpXòS_î,ѹ ±lT¾-w„ˆ5ù‰ £ú0÷0UK•Øbì:ÕÙô’+óJú~0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0U0ÿ0 *†H†÷ éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ Ji ϽØmŠ=OÙˆ} ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8 openssl-ca xüJ X.509 £0‚Ÿ0‚ «õRÿdMï0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205208Z 321218205208Z0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0Ÿ0 *†H†÷ 0‰ ÄÓ)haC^q~à¥ôáë#ïPá ˆ¯]ûJ“×-ÈjIGÇq©QÎD,~Hð—ÆßPI'׊ p¥*¯z“PÁ$å$S% 'ÝÞ•³å[SÆŒW£ž¡#I¦ˆ”Å-ãÈpXòS_î,ѹ ±lT¾-w„ˆ5ù‰ £ú0÷0UK•Øbì:ÕÙô’+óJú~0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0U0ÿ0 *†H†÷ éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ Ji ϽØmŠ=OÙˆ} ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Þ¦±Ðü8‰N¬dŒÄMržç ././@LongLink 0000000 0000000 0000000 00000000170 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCa0000644 0001750 0001750 00000004547 10561311235 033177 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class HTTPAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPAsynchCallbackTestClient.class.getName(), 1, HTTPAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000173 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchC0000644 0001750 0001750 00000003101 10561311235 033142 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import java.util.Map; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class HTTPSAsynchCallbackTestClient extends SSLAsynchCallbackTestClientRoot { protected String getTransport() { return "https"; } protected void addTransportSpecificConfig(Map config) { super.addTransportSpecificConfig(config); config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); } } ././@LongLink 0000000 0000000 0000000 00000000175 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLAsynchCallbackTestClientRoot.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLAsynchCal0000644 0001750 0001750 00000004303 10561311235 033223 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public abstract class SSLAsynchCallbackTestClientRoot extends AsynchCallbackTestClientRoot { protected void addTransportSpecificConfig(Map config) { config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = this.getClass().getResource("truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = this.getClass().getResource("keystore").getFile(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); config.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); } } ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketA0000644 0001750 0001750 00000004562 10561311235 033231 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class SSLBisocketAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SocketAsynchCallbackTestClient.class.getName(), 1, SocketAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000167 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCal0000644 0001750 0001750 00000004544 10561311235 033220 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class RMIAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMIAsynchCallbackTestClient.class.getName(), 1, RMIAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchC0000644 0001750 0001750 00000004552 10561311235 033155 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class HTTPSAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPSAsynchCallbackTestClient.class.getName(), 1, HTTPSAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000171 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCal0000644 0001750 0001750 00000002455 10561311235 033217 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class RMIAsynchCallbackTestClient extends AsynchCallbackTestClientRoot { protected String getTransport() { return "rmi"; } } ././@LongLink 0000000 0000000 0000000 00000000175 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsy0000644 0001750 0001750 00000004566 10561311235 033447 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class MultiplexAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(MultiplexAsynchCallbackTestClient.class.getName(), 1, MultiplexAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/AsynchCallbackTestClientRoot.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/AsynchCallba0000644 0001750 0001750 00000015550 10714270664 033340 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * AsynchCallbackTestClientRoot and AsynchCallbackTestServerRoot are the parent classes * for a set of transport specific tests of the asynchronous callback facility. * * @author Ron Sigal * @version $Revision: 2920 $ ** Copyright Nov 25, 2006 *
*/ public abstract class AsynchCallbackTestClientRoot extends TestCase { private static Logger log = Logger.getLogger(AsynchCallbackTestClientRoot.class); public void testSynchronousCallback() throws Throwable { String transport = getTransport(); String host = InetAddress.getLocalHost().getHostName(); int port = AsynchCallbackTestServerRoot.port; String locatorURI = transport + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); addTransportSpecificConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); SampleCallbackHandler callbackHandler = new SampleCallbackHandler(); client.addListener(callbackHandler, null, null, true); log.info("client added callback handler"); client.invokeOneway(AsynchCallbackTestServerRoot.SYNCHRONOUS_TEST); Thread.sleep(1000); // Should still be waiting on client. Boolean done = (Boolean) client.invoke(AsynchCallbackTestServerRoot.GET_STATUS); log.info("done 1: " + done); assertFalse(done.booleanValue()); Thread.sleep(8000); done = (Boolean) client.invoke(AsynchCallbackTestServerRoot.GET_STATUS); log.info("done 2: " + done); assertTrue(done.booleanValue()); assertTrue(callbackHandler.receivedCallback); client.invoke(AsynchCallbackTestServerRoot.RESET); client.removeListener(callbackHandler); log.info("disconnecting"); client.disconnect(); log.info("disconnected"); } public void testASynchronousCallbackClientSide() throws Throwable { String transport = getTransport(); String host = InetAddress.getLocalHost().getHostName(); int port = AsynchCallbackTestServerRoot.port; String locatorURI = transport + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); addTransportSpecificConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); SampleCallbackHandler callbackHandler = new SampleCallbackHandler(); client.addListener(callbackHandler, null, null, true); log.info("client added callback handler"); client.invokeOneway(AsynchCallbackTestServerRoot.ASYNCHRONOUS_CLIENT_SIDE_TEST); Thread.sleep(4000); // Should have returned. Boolean done = (Boolean) client.invoke(AsynchCallbackTestServerRoot.GET_STATUS); assertTrue(done.booleanValue()); assertTrue(callbackHandler.receivedCallback); client.invoke(AsynchCallbackTestServerRoot.RESET); client.removeListener(callbackHandler); client.disconnect(); } public void testASynchronousCallbackServerSide() throws Throwable { String transport = getTransport(); String host = InetAddress.getLocalHost().getHostName(); int port = AsynchCallbackTestServerRoot.port; String locatorURI = transport + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); addTransportSpecificConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); SampleCallbackHandler callbackHandler = new SampleCallbackHandler(); client.addListener(callbackHandler, null, null, true); log.info("client added callback handler"); client.invokeOneway(AsynchCallbackTestServerRoot.ASYNCHRONOUS_SERVER_SIDE_TEST); Thread.sleep(4000); // Should have returned. Boolean done = (Boolean) client.invoke(AsynchCallbackTestServerRoot.GET_STATUS); assertTrue(done.booleanValue()); assertTrue(callbackHandler.receivedCallback); Thread.sleep(5000); // Callback should be handled. assertTrue(callbackHandler.done); String threadCount = (String) client.invoke(AsynchCallbackTestServerRoot.GET_THREAD_COUNT); assertEquals(AsynchCallbackTestServerRoot.THREAD_COUNT, threadCount); String queueSize = (String) client.invoke(AsynchCallbackTestServerRoot.GET_QUEUE_SIZE); assertEquals(AsynchCallbackTestServerRoot.QUEUE_SIZE, queueSize); client.invoke(AsynchCallbackTestServerRoot.RESET); client.removeListener(callbackHandler); client.disconnect(); } protected abstract String getTransport(); protected void addTransportSpecificConfig(Map config) { } static class SampleCallbackHandler implements InvokerCallbackHandler { boolean receivedCallback; boolean done; public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); receivedCallback = true; try { Thread.sleep(5000); } catch (InterruptedException e) { } done = true; } } } ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynch0000644 0001750 0001750 00000002463 10561311235 033377 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SocketAsynchCallbackTestClient extends AsynchCallbackTestClientRoot { protected String getTransport() { return "socket"; } } ././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsyn0000644 0001750 0001750 00000003176 10561311235 033401 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class BisocketAsynchCallbackTestServer extends AsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new BisocketAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "bisocket"; } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/AsynchCallbackTestServerRoot.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/AsynchCallba0000644 0001750 0001750 00000017150 10561311235 033324 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.AsynchInvokerCallbackHandler; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.util.threadpool.BasicThreadPool; /** * AsynchCallbackTestClientRoot and AsynchCallbackTestServerRoot are the parent classes * for a set of transport specific tests of the asynchronous callback facility. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 25, 2006 *
*/ public abstract class AsynchCallbackTestServerRoot extends ServerTestCase { public static int port = 5413; public static String SYNCHRONOUS_TEST = "synchronousTest"; public static String ASYNCHRONOUS_SERVER_SIDE_TEST = "asynchronousServerSideTest"; public static String ASYNCHRONOUS_CLIENT_SIDE_TEST = "asynchronousClientSideTest"; public static String GET_STATUS = "getStatus"; public static String RESET = "reset"; public static String GET_THREAD_COUNT = "getThreadCount"; public static String GET_QUEUE_SIZE = "getQueueSize"; public static String THREAD_COUNT = "17"; public static String QUEUE_SIZE = "19"; private static Logger log = Logger.getLogger(AsynchCallbackTestServerRoot.class); // remoting server connector static private Connector connector; String serverLocatorURI; /** * Sets up target remoting server. */ public void setUp() throws Exception { log.info("entering setUp()"); String locatorURI = getTransport() + "://" + InetAddress.getLocalHost().getHostAddress() + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); Map config = new HashMap(); config.put(Client.MAX_NUM_ONEWAY_THREADS, THREAD_COUNT); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, QUEUE_SIZE); addTransportSpecificConfig(config); connector = new Connector(serverLocator, config); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } /** * Shuts down the server */ public void tearDown() { connector.stop(); connector.destroy(); } protected abstract String getTransport(); protected void addTransportSpecificConfig(Map config) { } /** * Simple invocation handler implementation. When callback client's are registered, will * generate callbacks periodically. */ static class SampleInvocationHandler implements ServerInvocationHandler { boolean done; AsynchInvokerCallbackHandler callbackHandler; public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("Adding callback listener."); assertTrue(callbackHandler instanceof AsynchInvokerCallbackHandler); this.callbackHandler = (AsynchInvokerCallbackHandler) callbackHandler; } public Object invoke(InvocationRequest invocation) throws Throwable { try { String test = (String) invocation.getParameter(); if (test.equals(SYNCHRONOUS_TEST)) { log.info("making synchronous callback"); callbackHandler.handleCallback(new Callback(test)); log.info("made synchronous callback"); } else if (test.equals(ASYNCHRONOUS_SERVER_SIDE_TEST)) { log.info("making asynchronous callback - server side"); callbackHandler.handleCallbackOneway(new Callback("callback"), true); } else if (test.equals(ASYNCHRONOUS_CLIENT_SIDE_TEST)) { log.info("making asynchronous callback - client side"); callbackHandler.handleCallbackOneway(new Callback("callback")); } else if (test.equals(GET_STATUS)) { synchronized (this) { log.info("returning status: " + done); return new Boolean(done); } } else if (test.equals(RESET)) { synchronized (this) { done = false; } } else if (test.equals(GET_THREAD_COUNT)) { ServerInvokerCallbackHandler sich = (ServerInvokerCallbackHandler) callbackHandler; Client callbackClient = sich.getCallbackClient(); Field field = Client.class.getDeclaredField("onewayThreadPool"); field.setAccessible(true); BasicThreadPool threadPool = (BasicThreadPool) field.get(callbackClient); int size = threadPool.getMaximumPoolSize(); return Integer.toString(size); } else if (test.equals(GET_QUEUE_SIZE)) { ServerInvokerCallbackHandler sich = (ServerInvokerCallbackHandler) callbackHandler; Client callbackClient = sich.getCallbackClient(); Field field = Client.class.getDeclaredField("onewayThreadPool"); field.setAccessible(true); BasicThreadPool threadPool = (BasicThreadPool) field.get(callbackClient); int size = threadPool.getMaximumQueueSize(); return Integer.toString(size); } else { log.error("unrecognized test: " + test); } } catch (HandleCallbackException e) { log.error("Unable to send callback"); } synchronized (this) { done = true; log.info("done"); } return null; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } } ././@LongLink 0000000 0000000 0000000 00000000176 00000000000 011571 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsyn0000644 0001750 0001750 00000003064 10561311235 033375 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class BisocketAsynchCallbackTestClient extends AsynchCallbackTestClientRoot { protected void addTransportSpecificConfig(Map config) { super.addTransportSpecificConfig(config); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); } protected String getTransport() { return "bisocket"; } } ././@LongLink 0000000 0000000 0000000 00000000175 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLAsynchCallbackTestServerRoot.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLAsynchCal0000644 0001750 0001750 00000004031 10561311235 033221 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public abstract class SSLAsynchCallbackTestServerRoot extends AsynchCallbackTestServerRoot { protected void addTransportSpecificConfig(Map config) { config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = this.getClass().getResource("truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = this.getClass().getResource("keystore").getFile(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynchCallbackTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynch0000644 0001750 0001750 00000004563 10561311235 033402 0 ustar twerner twerner /* * 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.remoting.callback.asynch; import org.jboss.jrunit.harness.TestDriver; /** * Tests asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Nov 28, 2006 *
*/ public class SocketAsynchCallbackTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLSocketAsynchCallbackTestClient.class.getName(), 1, SSLSocketAsynchCallbackTestServer.class.getName()); } /** * How long to wait for test results to be returned from the client(s). If goes longer than the * specified limit, will throw an exception and kill the running test cases. Default value is * RESULTS_TIMEOUT. * * @return */ protected long getResultsTimeout() { return 600000; } /** * How long for the server test case to wait for tear down message. If exceeds timeout, * will throw exception. The default value is TEARDOWN_TIMEOUT. * * @return */ protected long getTearDownTimeout() { return 600000; } /** * How long to allow each of the test cases to run their tests. If exceeds this timeout * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT. * * @return */ protected long getRunTestTimeout() { return 600000; } } ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsy0000644 0001750 0001750 00000002475 10561311235 033273 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SSLSocketAsynchCallbackTestClient extends SSLAsynchCallbackTestClientRoot { protected String getTransport() { return "sslsocket"; } } ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynch0000644 0001750 0001750 00000002467 10561311235 033164 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SSLRMIAsynchCallbackTestClient extends SSLAsynchCallbackTestClientRoot { protected String getTransport() { return "sslrmi"; } } ././@LongLink 0000000 0000000 0000000 00000000174 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynchCallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynch0000644 0001750 0001750 00000003171 10561311235 033374 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class SocketAsynchCallbackTestServer extends AsynchCallbackTestServerRoot { public static void main(String[] args) { AsynchCallbackTestServerRoot testCase = new SocketAsynchCallbackTestServer(); try { testCase.setUp(); Thread.sleep(60000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "socket"; } } ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsynchCallbackTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsy0000644 0001750 0001750 00000002471 10561311235 033440 0 ustar twerner twerner /* * 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.remoting.callback.asynch; /** * @author Ron Sigal * @version $Revision: 2103 $ ** Copyright Feb 3, 2007 *
*/ public class MultiplexAsynchCallbackTestClient extends AsynchCallbackTestClientRoot { protected String getTransport() { return "multiplex"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/connectionfailure/ 0000755 0001750 0001750 00000000000 11632407042 033275 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000214 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/connectionfailure/CallbackConnectionFailureTestParent.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/connectionfailure/C0000644 0001750 0001750 00000032524 11413660476 033421 0 ustar twerner twerner /* * 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.remoting.callback.connectionfailure; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import java.util.TimerTask; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.LeasePinger; import org.jboss.remoting.MicroRemoteClientInvoker; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * * Parent of unit tests for JBREM-873. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Dec 10, 2007 *
*/ abstract public class CallbackConnectionFailureTestParent extends TestCase { private static Logger log = Logger.getLogger(CallbackConnectionFailureTestParent.class); private static boolean firstTime = true; private static String CALLBACK = "callback"; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected TestConnectionListener connectionListener; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testCallbackConnectionFailureWithListener() throws Throwable { log.info("entering " + getName()); doTest(true); log.info(getName() + " PASSES"); } public void testCallbackConnectionFailureWithoutListener() throws Throwable { log.info("entering " + getName()); doTest(false); log.info(getName() + " PASSES"); } public void testCallbackConnectionFailureTwoClients() throws Throwable { // Start server. setupServer(true, 2); // Create clients. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("enableLease", "true"); addExtraClientConfig(clientConfig); Client client1 = new Client(clientLocator1, clientConfig); client1.connect(); log.info("client1 is connected: " + client1.getSessionId()); // Force the Clients to use distinct invokers. InvokerLocator clientLocator2 = new InvokerLocator(locatorURI + "/?a=b"); Client client2 = new Client(clientLocator2, clientConfig); client2.connect(); log.info("client2 is connected: " + client2.getSessionId()); assertNotSame(client1.getInvoker(), client2.getInvoker()); // Test connections. assertEquals("abc", client1.invoke("abc")); assertEquals("xyz", client1.invoke("xyz")); log.info("connections are good"); // Add callback handlers. TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); Map metadata = new HashMap(); addExtraCallbackMetadata(metadata); int callbackPort = PortUtil.findFreePort(host); metadata.put(Client.CALLBACK_SERVER_PORT, Integer.toString(callbackPort)); client1.addListener(callbackHandler1, metadata, null, true); client1.invoke(CALLBACK); assertEquals(1, callbackHandler1.count); log.info("first callback handler is installed"); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); callbackPort = PortUtil.findFreePort(host); metadata.put(Client.CALLBACK_SERVER_PORT, Integer.toString(callbackPort)); client2.addListener(callbackHandler2, metadata, null, true); client2.invoke(CALLBACK); assertEquals(2, callbackHandler1.count); assertEquals(1, callbackHandler2.count); log.info("second callback handler is installed"); // Verify that first callback Client is disconnected when lease fails, // but second callback Client is not disconnected. // 1. Kill LeasePinger for Client 1. ClientInvoker invoker = client1.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(invoker); field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(pinger); timerTask.cancel(); log.info("stopped LeasePinger"); // 2. Verify that first callback Client is disconnected. TestInvocationHandler2 tih = (TestInvocationHandler2) invocationHandler; ServerInvokerCallbackHandler sich1 = tih.callbackHandlers[0]; Client callbackClient1 = sich1.getCallbackClient(); Thread.sleep(12000); assertFalse(callbackClient1.isConnected()); log.info("first callback Client is disconnected"); // 2. Verify that second callback Client is not disconnected. ServerInvokerCallbackHandler sich2 = tih.callbackHandlers[1]; Client callbackClient2 = sich2.getCallbackClient(); assertTrue(callbackClient2.isConnected()); log.info("second callback Client is connected"); client1.removeListener(callbackHandler1); client1.disconnect(); client2.removeListener(callbackHandler1); client2.disconnect(); shutdownServer(); } protected void doTest(boolean registerAsListener) throws Throwable { // Start server. setupServer(registerAsListener, 1); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("enableLease", "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Add callback handler. TestCallbackHandler callbackHandler = new TestCallbackHandler(); Map metadata = new HashMap(); addExtraCallbackMetadata(metadata); client.addListener(callbackHandler, metadata, null, true); client.invoke(CALLBACK); assertEquals(1, callbackHandler.count); log.info("callback handler is installed"); // Verify that callback Client is disconnected when lease fails. // 1. Kill LeasePinger. ClientInvoker invoker = client.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(invoker); field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(pinger); timerTask.cancel(); log.info("stopped LeasePinger"); // 2. Verify that callback Client is disconnected. ServerInvokerCallbackHandler sich = invocationHandler.callbackHandler; Client callbackClient = sich.getCallbackClient(); Thread.sleep(12000); assertEquals(registerAsListener, !callbackClient.isConnected()); log.info("callback Client is disconnected"); // 3. Verify that testConnectionListener gets called. Thread.sleep(20000); assertTrue(connectionListener.ok); client.removeListener(callbackHandler); client.disconnect(); shutdownServer(); } abstract protected String getTransport(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void addExtraCallbackMetadata(Map metadata) {} protected String extendInvokerLocator(String locatorURI) {return locatorURI;} protected void setupServer(boolean registerAsListener, int handlerVersion) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI = extendInvokerLocator(locatorURI); serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put("clientLeasePeriod", "2000"); config.put(ServerInvoker.REGISTER_CALLBACK_LISTENER, Boolean.toString(registerAsListener)); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); if (handlerVersion == 1) invocationHandler = new TestInvocationHandler(); else invocationHandler = new TestInvocationHandler2(); connector.addInvocationHandler("test", invocationHandler); connector.start(); connectionListener = new TestConnectionListener(); connector.addConnectionListener(connectionListener); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public ServerInvokerCallbackHandler callbackHandler; public void addListener(InvokerCallbackHandler callbackHandler) { this.callbackHandler = (ServerInvokerCallbackHandler) callbackHandler; } public Object invoke(final InvocationRequest invocation) throws Throwable { if (CALLBACK.equals(invocation.getParameter())) { callbackHandler.handleCallback(new Callback(CALLBACK)); } return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestInvocationHandler2 extends TestInvocationHandler { public ServerInvokerCallbackHandler[] callbackHandlers = new ServerInvokerCallbackHandler[2]; private int i = 0; public void addListener(InvokerCallbackHandler callbackHandler) { callbackHandlers[i++] = (ServerInvokerCallbackHandler) callbackHandler; log.info("callback handlers registered: " + i); } public Object invoke(final InvocationRequest invocation) throws Throwable { if (CALLBACK.equals(invocation.getParameter())) { if (i > 0) callbackHandlers[0].handleCallback(new Callback(CALLBACK)); if (i > 1) callbackHandlers[1].handleCallback(new Callback(CALLBACK)); } return invocation.getParameter(); } } static class TestCallbackHandler implements InvokerCallbackHandler { public int count; public void handleCallback(Callback callback) throws HandleCallbackException { count++; log.info(this + " received callback"); } } static class TestConnectionListener implements ConnectionListener { public boolean ok; public void handleConnectionException(Throwable throwable, Client client) { try {Thread.sleep(20000);} catch (InterruptedException e) {} ok = true; log.info("connection failed: " + client.getSessionId()); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/ 0000755 0001750 0001750 00000000000 11632407042 033170 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000206 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SSLRMISSLSocketFactoryTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SS0000644 0001750 0001750 00000002534 11413660476 033455 0 ustar twerner twerner /* * 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.remoting.callback.sslsocketfactory; /** * Unit test for JBREM-522. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Feb 27, 2008 *
*/ public class SSLRMISSLSocketFactoryTestCase extends SSLSocketFactoryTestParent { protected String getTransport() { return "sslrmi"; } } ././@LongLink 0000000 0000000 0000000 00000000211 00000000000 011557 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SSLSocketSSLSocketFactoryTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SS0000644 0001750 0001750 00000002542 11413660476 033454 0 ustar twerner twerner /* * 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.remoting.callback.sslsocketfactory; /** * Unit test for JBREM-522. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Feb 27, 2008 *
*/ public class SSLSocketSSLSocketFactoryTestCase extends SSLSocketFactoryTestParent { protected String getTransport() { return "sslsocket"; } } ././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/keystore libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/ke0000644 0001750 0001750 00000013761 10761450663 033533 0 ustar twerner twerner þíþí unit-tests-client xþ»õ X.509 ¶0‚²0‚ 0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205439Z 321218205439Z0h10 UUS10U Washington10U JBoss Inc.10U JBoss Inc.10Uunit-tests-client0‚·0‚,*†HÎ80‚ ýSu)RßJœ.ìäçö·R<ïD Ã?€¶Q&iE]@"QûY=Xú¿Åõº0öË›Ul×;€4oòf`·k™P¥¤ŸŸè{"ÂO»©×þ·Æø;WçÆ¨¦ûƒöÓÅÃ5TZ‘2öuó®+a×*ïò"ÑHÇ —`P#̲’¹‚¢ë„ðXõ ÷á …Ö›=Þ˼«\6¸W¹y”¯»ú:ê‚ùWL=‚gQYWŽºÔYOæq€´Iq#èL(·Ï 2ŒÈ¦á<z‹T|(࣮+³¦u‘n£ú!5bñûbz$;̤ñ¾¨Q‰¨ƒßáZ埒‹f^€{U%dL;þÏI*„ €?w=1y+¨Òølön%)êëµ UOu§òä†k4µïŽÚ3X©yƒ¨³„ÃT‰ªÁ@ótYíiC¦Þš¢àȦ6$Gmp MxÌýDešhUÌ¥LHFC–M¬w´è½Ñ+;}®ï”æTW©ÙÈÀÙþ"×ÒÐËÕN†v£‚&0‚"0 U0 0, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0 *†H†÷ …23&TÚÒ üap?½w3ôzk°‡kU1ì253.+àUܯÒllûc ~ÏÁ-øUî ‚$»O9¿ÇæÎ[Þ¶>,‰‡³×™¥ Ö¦;þ¯2·NŒà¬u¤¶ž}³ÒŽ›TÊ€ÍaeH©å¾º)vþäqUçgJ¨®Æ unit-tests-server xül‡ 0‚‹0 +* ‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZrIãð¬; 7L Ño§-ÿEŸzÀJ…Y÷DãµpñU†DMeÍ™È%fçO½“»„µÐÊß%–MD¾håÇc@uƬsIAˆ”/§Øÿ«`iW!np’Ç̦áç*ý°·mÙ\‹ñÞŽ²ÐyEŒâ¼ukÏ鱯‹M{‡4»loô¤-üv•ªåBv>=z£W¢÷Š©M…í¼UxÂ.íP´M³âˆu RyIÅœ“œº“Â;+±û¤;~äk…¦Œö»AÞEyDïÆÆ’Ì‹ÑOFLšœ8òÆ´á+±µ’P‰¨ >—;ä¬lnSäÄ›$562Y[l©+¦ äžY#¹#}Mïëîå(”Ç@bnœÁm05k‰õ$ý£²ÿ^™…þÙ+wN@ý¬ëî¦cçQ=‚βVÐÞ¤÷¿x°ŸŽšƒ)W„•@ÏU¼ X.509 §0‚£0‚ 0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205414Z 321218205414Z0X10 UUS10U Washington10U JBoss Inc.10 UQA10U localhost0‚¸0‚,*†HÎ80‚ ýSu)RßJœ.ìäçö·R<ïD Ã?€¶Q&iE]@"QûY=Xú¿Åõº0öË›Ul×;€4oòf`·k™P¥¤ŸŸè{"ÂO»©×þ·Æø;WçÆ¨¦ûƒöÓÅÃ5TZ‘2öuó®+a×*ïò"ÑHÇ —`P#̲’¹‚¢ë„ðXõ ÷á …Ö›=Þ˼«\6¸W¹y”¯»ú:ê‚ùWL=‚gQYWŽºÔYOæq€´Iq#èL(·Ï 2ŒÈ¦á<z‹T|(࣮+³¦u‘n£ú!5bñûbz$;̤ñ¾¨Q‰¨ƒßáZ埒‹f^€{U%dL;þÏI*… Ò3å¬Û— OªºŒôÿ麟¶½Ë€åßÝr‹}òÕbÖÐÊs±ù&ßlª`ÌgÒË‹3ØQ¶^ÅzCÒK¡ó0X*™V†ãÑX™F&éúãÉÀ• 'Ýwu%º™ùå±×£˜ç4\ºò‚”rp÷ƒ_1makÝûN£‚&0‚"0 U0 0, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0 *†H†÷ z±VyC3¤šQ€ŒÝÏì\ S©B® m¿´Â}‰Ôr3~ïOô”zà´vÆäë£=)g'„8x¿YO¸j²[qò‹ßÔî—B‰z¹óqTqé{ ¿/öÅ®ß^3Dç{Š%d¤ôâr×MZU«s€PÅ…ß*/žáÌûCN X.509 £0‚Ÿ0‚ «õRÿdMï0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205208Z 321218205208Z0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0Ÿ0 *†H†÷ 0‰ ÄÓ)haC^q~à¥ôáë#ïPá ˆ¯]ûJ“×-ÈjIGÇq©QÎD,~Hð—ÆßPI'׊ p¥*¯z“PÁ$å$S% 'ÝÞ•³å[SÆŒW£ž¡#I¦ˆ”Å-ãÈpXòS_î,ѹ ±lT¾-w„ˆ5ù‰ £ú0÷0UK•Øbì:ÕÙô’+óJú~0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0U0ÿ0 *†H†÷ éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ Ji ϽØmŠ=OÙˆ} ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8 openssl-ca xûxï X.509 £0‚Ÿ0‚ «õRÿdMï0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205208Z 321218205208Z0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0Ÿ0 *†H†÷ 0‰ ÄÓ)haC^q~à¥ôáë#ïPá ˆ¯]ûJ“×-ÈjIGÇq©QÎD,~Hð—ÆßPI'׊ p¥*¯z“PÁ$å$S% 'ÝÞ•³å[SÆŒW£ž¡#I¦ˆ”Å-ãÈpXòS_î,ѹ ±lT¾-w„ˆ5ù‰ £ú0÷0UK•Øbì:ÕÙô’+óJú~0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0U0ÿ0 *†H†÷ éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ Ji ϽØmŠ=OÙˆ} ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8 Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=us y5^¶ X.509 ¶0‚²0‚ 0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205439Z 321218205439Z0h10 UUS10U Washington10U JBoss Inc.10U JBoss Inc.10Uunit-tests-client0‚·0‚,*†HÎ80‚ ýSu)RßJœ.ìäçö·R<ïD Ã?€¶Q&iE]@"QûY=Xú¿Åõº0öË›Ul×;€4oòf`·k™P¥¤ŸŸè{"ÂO»©×þ·Æø;WçÆ¨¦ûƒöÓÅÃ5TZ‘2öuó®+a×*ïò"ÑHÇ —`P#̲’¹‚¢ë„ðXõ ÷á …Ö›=Þ˼«\6¸W¹y”¯»ú:ê‚ùWL=‚gQYWŽºÔYOæq€´Iq#èL(·Ï 2ŒÈ¦á<z‹T|(࣮+³¦u‘n£ú!5bñûbz$;̤ñ¾¨Q‰¨ƒßáZ埒‹f^€{U%dL;þÏI*„ €?w=1y+¨Òølön%)êëµ UOu§òä†k4µïŽÚ3X©yƒ¨³„ÃT‰ªÁ@ótYíiC¦Þš¢àȦ6$Gmp MxÌýDešhUÌ¥LHFC–M¬w´è½Ñ+;}®ï”æTW©ÙÈÀÙþ"×ÒÐËÕN†v£‚&0‚"0 U0 0, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0 *†H†÷ …23&TÚÒ üap?½w3ôzk°‡kU1ì253.+àUܯÒllûc ~ÏÁ-øUî ‚$»O9¿ÇæÎ[Þ¶>,‰‡³×™¥ Ö¦;þ¯2·NŒà¬u¤¶ž}³ÒŽ›TÊ€ÍaeH©å¾º)vþäqUçgJ¨®Æüü·Æ£Ì5qÔcn›†äö÷Ö ././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/truststore libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/tr0000644 0001750 0001750 00000007013 10761450663 033552 0 ustar twerner twerner þíþí unit-tests-client xüïS 0‚‹0 +* ‚wÜ'²†Ž:yüàO áõˆœ¯±ÕMÅ2sù#HÞ")È…ÆmˆHÝÕÇnøgi£¥è^¶\Ã4þ=PÅxך©ëÁÜ>ÌÍóÊíìPÇ37ÆÌ,–R#šBÍpçÞ–<ù5Û–©ô‡°C㵯3‚‘’'Ë3&¢žÔþâ1èÞM6X¶˜~–æ|EMYïúZ´ãq RýÞp„úøî´´»Èhz]Þš² 2â"_ˆZ`›Yô[a±åŠíTšÄÁ6D¥oDiùøÓõŸxè¯W[ŸiQyÌXew&e[Jët˜Ë=T}µ-¤ŠBÝ Jˆ:´d8©å_úmj±+¶Ç…»È‚K+s-7u§væJàŠ[À^4ÊÐ(Nïšé×þ«~®7àhoñ¥s½-ðl}ͰîrYäþ†ÆÉt÷;þTòÃßvʹ;%O íž*ÚTër˜J-]¢Âލb`OYJ X.509 ¶0‚²0‚ 0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205439Z 321218205439Z0h10 UUS10U Washington10U JBoss Inc.10U JBoss Inc.10Uunit-tests-client0‚·0‚,*†HÎ80‚ ýSu)RßJœ.ìäçö·R<ïD Ã?€¶Q&iE]@"QûY=Xú¿Åõº0öË›Ul×;€4oòf`·k™P¥¤ŸŸè{"ÂO»©×þ·Æø;WçÆ¨¦ûƒöÓÅÃ5TZ‘2öuó®+a×*ïò"ÑHÇ —`P#̲’¹‚¢ë„ðXõ ÷á …Ö›=Þ˼«\6¸W¹y”¯»ú:ê‚ùWL=‚gQYWŽºÔYOæq€´Iq#èL(·Ï 2ŒÈ¦á<z‹T|(࣮+³¦u‘n£ú!5bñûbz$;̤ñ¾¨Q‰¨ƒßáZ埒‹f^€{U%dL;þÏI*„ €?w=1y+¨Òølön%)êëµ UOu§òä†k4µïŽÚ3X©yƒ¨³„ÃT‰ªÁ@ótYíiC¦Þš¢àȦ6$Gmp MxÌýDešhUÌ¥LHFC–M¬w´è½Ñ+;}®ï”æTW©ÙÈÀÙþ"×ÒÐËÕN†v£‚&0‚"0 U0 0, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0 *†H†÷ …23&TÚÒ üap?½w3ôzk°‡kU1ì253.+àUܯÒllûc ~ÏÁ-øUî ‚$»O9¿ÇæÎ[Þ¶>,‰‡³×™¥ Ö¦;þ¯2·NŒà¬u¤¶ž}³ÒŽ›TÊ€ÍaeH©å¾º)vþäqUçgJ¨®Æ X.509 £0‚Ÿ0‚ «õRÿdMï0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205208Z 321218205208Z0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0Ÿ0 *†H†÷ 0‰ ÄÓ)haC^q~à¥ôáë#ïPá ˆ¯]ûJ“×-ÈjIGÇq©QÎD,~Hð—ÆßPI'׊ p¥*¯z“PÁ$å$S% 'ÝÞ•³å[SÆŒW£ž¡#I¦ˆ”Å-ãÈpXòS_î,ѹ ±lT¾-w„ˆ5ù‰ £ú0÷0UK•Øbì:ÕÙô’+óJú~0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0U0ÿ0 *†H†÷ éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ Ji ϽØmŠ=OÙˆ} ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8 openssl-ca xüJ X.509 £0‚Ÿ0‚ «õRÿdMï0 *†H†÷ 0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0 050802205208Z 321218205208Z0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com0Ÿ0 *†H†÷ 0‰ ÄÓ)haC^q~à¥ôáë#ïPá ˆ¯]ûJ“×-ÈjIGÇq©QÎD,~Hð—ÆßPI'׊ p¥*¯z“PÁ$å$S% 'ÝÞ•³å[SÆŒW£ž¡#I¦ˆ”Å-ãÈpXòS_î,ѹ ±lT¾-w„ˆ5ù‰ £ú0÷0UK•Øbì:ÕÙô’+óJú~0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’10 UUS10U Washington10USnoqualmie Pass10U JBoss Inc.10 UQA10U jboss.com10 *†H†÷ admin@jboss.com‚ «õRÿdMï0U0ÿ0 *†H†÷ éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ Ji ϽØmŠ=OÙˆ} ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Þ¦±Ðü8‰N¬dŒÄMržç ././@LongLink 0000000 0000000 0000000 00000000202 00000000000 011557 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SSLSocketFactoryTestParent.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SS0000644 0001750 0001750 00000016207 11413660476 033457 0 ustar twerner twerner /* * 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.remoting.callback.sslsocketfactory; import java.net.InetAddress; import java.net.ServerSocket; import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; abstract public class SSLSocketFactoryTestParent extends TestCase { private static Logger log = Logger.getLogger(SSLSocketFactoryTestParent.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testSSLServerSocketFactory() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = this.getClass().getResource("truststore").getFile(); clientConfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); clientConfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Add callback listener. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, null, null, true); // Test callback SSLServerSocketFactory. Set callbackConnectors = client.getCallbackConnectors(callbackHandler); assertEquals(1, callbackConnectors.size()); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); ServerInvoker callbackServerInvoker = callbackConnector.getServerInvoker(); ServerSocketFactory serverSocketFactory = callbackServerInvoker.getServerSocketFactory(); assertTrue(serverSocketFactory instanceof SSLServerSocketFactory); InetAddress address = InetAddress.getLocalHost(); int port = PortUtil.findFreePort(address.getHostAddress()); ServerSocket serverSocket = serverSocketFactory.createServerSocket(port, 100, address); SSLServerSocket sslServerSocket = (SSLServerSocket) serverSocket; assertTrue(sslServerSocket.getUseClientMode()); client.removeListener(callbackHandler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } abstract protected String getTransport(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = this.getClass().getResource("keystore").getFile(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); } } } ././@LongLink 0000000 0000000 0000000 00000000205 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/HttpsSSLSocketFactoryTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/Ht0000644 0001750 0001750 00000003064 11413660476 033502 0 ustar twerner twerner /* * 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.remoting.callback.sslsocketfactory; import java.util.Map; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; /** * Unit test for JBREM-522. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Feb 27, 2008 *
*/ public class HttpsSSLSocketFactoryTestCase extends SSLSocketFactoryTestParent { protected String getTransport() { return "https"; } protected void addExtraClientConfig(Map config) { config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/params/ 0000755 0001750 0001750 00000000000 11632407041 031050 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/params/UseAllParams0000644 0001750 0001750 00000040050 11413660476 033335 0 ustar twerner twerner /* * JBoss, Home of Professional Open Source. * Copyright 2009, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file 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.remoting.callback.params; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.CallbackPoller; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1084. * * @author Ron Sigal * @version ** Copyright Jan 17, 2009 *
*/ public class UseAllParamsTestCase extends TestCase { private static Logger log = Logger.getLogger(UseAllParamsTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testUseAllParamsDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("callbackPollPeriod", "333"); clientConfig.put("maxErrorCount", "444"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure callback polling. TestCallbackHandler handler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put("maxErrorCount", "555"); client.addListener(handler, metadata); // Test setting of parameters in CallbackPoller. testParameters(client, false, CallbackPoller.DEFAULT_POLL_PERIOD, 555); client.removeListener(handler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllParamsFalseinLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222&useAllParams=false"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("callbackPollPeriod", "333"); clientConfig.put("maxErrorCount", "444"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure callback polling. TestCallbackHandler handler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put("maxErrorCount", "555"); client.addListener(handler, metadata); // Test setting of parameters in CallbackPoller. testParameters(client, false, CallbackPoller.DEFAULT_POLL_PERIOD, 555); client.removeListener(handler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllParamsFalseinConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("callbackPollPeriod", "333"); clientConfig.put("maxErrorCount", "444"); clientConfig.put(Client.USE_ALL_PARAMS, "false"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure callback polling. TestCallbackHandler handler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put("maxErrorCount", "555"); client.addListener(handler, metadata); // Test setting of parameters in CallbackPoller. testParameters(client, false, CallbackPoller.DEFAULT_POLL_PERIOD, 555); client.removeListener(handler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllParamsFalseinMetadata() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("callbackPollPeriod", "333"); clientConfig.put("maxErrorCount", "444"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure callback polling. TestCallbackHandler handler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put("maxErrorCount", "555"); metadata.put(Client.USE_ALL_PARAMS, "false"); client.addListener(handler, metadata); // Test setting of parameters in CallbackPoller. testParameters(client, false, CallbackPoller.DEFAULT_POLL_PERIOD, 555); client.removeListener(handler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllParamsTrueInLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222&useAllParams=true"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("callbackPollPeriod", "333"); clientConfig.put("maxErrorCount", "444"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure callback polling. TestCallbackHandler handler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put("maxErrorCount", "555"); client.addListener(handler, metadata); // Test setting of parameters in CallbackPoller. testParameters(client, true, 333, 555); client.removeListener(handler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllParamsTrueInConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("callbackPollPeriod", "333"); clientConfig.put("maxErrorCount", "444"); clientConfig.put(Client.USE_ALL_PARAMS, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure callback polling. TestCallbackHandler handler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put("maxErrorCount", "555"); client.addListener(handler, metadata); // Test setting of parameters in CallbackPoller. testParameters(client, true, 333, 555); client.removeListener(handler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllParamsTrueInMetadata() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("callbackPollPeriod", "333"); clientConfig.put("maxErrorCount", "444"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure callback polling. TestCallbackHandler handler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put("maxErrorCount", "555"); metadata.put(Client.USE_ALL_PARAMS, "true"); client.addListener(handler, metadata); // Test setting of parameters in CallbackPoller. testParameters(client, true, 333, 555); client.removeListener(handler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected void testParameters(Client client, boolean blockingExpected, long callbackPollPeriodExpected, int maxErrorCountExpected) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Field field = Client.class.getDeclaredField("callbackPollers"); field.setAccessible(true); Map pollers = (Map) field.get(client); assertEquals(1, pollers.size()); CallbackPoller poller = (CallbackPoller) pollers.values().iterator().next(); field = CallbackPoller.class.getDeclaredField("blocking"); field.setAccessible(true); boolean blocking = ((Boolean)field.get(poller)).booleanValue(); field = CallbackPoller.class.getDeclaredField("pollPeriod"); field.setAccessible(true); long callbackPollPeriod = ((Long) field.get(poller)).longValue(); field = CallbackPoller.class.getDeclaredField("maxErrorCount"); field.setAccessible(true); int maxErrorCount = ((Integer) field.get(poller)).intValue(); log.info("blocking: " + blocking); log.info("callbackPollPeriod: " + callbackPollPeriod); log.info("maxErrorCount: " + maxErrorCount); assertEquals(blockingExpected, blocking); assertEquals(callbackPollPeriodExpected, callbackPollPeriod); assertEquals(maxErrorCountExpected, maxErrorCount); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "/?" + metadata; } else { locatorURI += "/?" + "x=y"; } serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); } } } ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestServer.0000644 0001750 0001750 00000013235 10540121711 033307 0 ustar twerner twerner /* * 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.remoting.callback; import org.apache.log4j.Level; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class CallbackTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5500; protected String locatorURI = transport + "://" + host + ":" + port; protected Connector connector; // String to be returned from invocation handler upon client invocation calls. public static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public static final String CALLBACK_VALUE = "This is the payload of callback invocation."; public void setupServer() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); } protected void setUp() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { CallbackTestServer server = new CallbackTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { protected List listeners = new ArrayList(); /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Just going to return static string as this is just simple example code. // Will also fire callback to listeners if they were to exist using // simple invocation request. Callback callback = new Callback(CALLBACK_VALUE); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); callbackHandler.handleCallback(callback); } return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } } ././@LongLink 0000000 0000000 0000000 00000000151 00000000000 011562 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/DestroyNPETestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/DestroyNPETestCase.0000644 0001750 0001750 00000015464 11413660476 033242 0 ustar twerner twerner /* * JBoss, Home of Professional Open Source * Copyright 2009, 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.remoting.callback; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1081. * * @author Ron Sigal * @version $Rev$ ** Copyright Mar 19, 2009 *
*/ public class DestroyNPETestCase extends TestCase { private static Logger log = Logger.getLogger(DestroyNPETestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testForNPE() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Add CallbackHandler. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); // Shut down ServerInvokerCallbackHandler and verify there's no NullPointerException. invocationHandler.serverInvokerCallbackHandler.destroy(); invocationHandler.serverInvokerCallbackHandler.setShouldPersist(true); try { invocationHandler.serverInvokerCallbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { Throwable cause = e.getCause(); if (cause != null && cause.getMessage().startsWith("Can not make remoting client invocation")) { log.info("Got expected HandleCallbackException"); } else { fail("Got unexpected Exception"); } } catch (NullPointerException e) { fail("Shouldn't get NullPointerException"); } catch (Exception e) { fail("Got unexpected Exception"); } client.removeListener(callbackHandler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "/?" + metadata; } serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public ServerInvokerCallbackHandler serverInvokerCallbackHandler; public void addListener(InvokerCallbackHandler callbackHandler) { serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) callbackHandler; } public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/ 0000755 0001750 0001750 00000000000 11632407042 031576 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000170 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/ListenerRemovedTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/ListenerR0000644 0001750 0001750 00000013441 10355142433 033434 0 ustar twerner twerner /* * 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.remoting.callback.listeners; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import junit.framework.TestCase; /** * This is a test to make sure multiple callback listeners can be added * from the same client and the each gets their callbacks, as well * as making sure they are removed correctly. * * This test really only works the way it is coded because know that * everything will be run locally, meaning that I can check the * callback values after making in invoke call because the same * thread will make the callbacks before the thread returns from * invoke method. * * @author Ovidiu Feodorov * @author Ton Elrod * @version $Revision: 566 $ */ public class ListenerRemovedTestCase extends TestCase { private static List callbacks = new ArrayList(); public void testCallbacks() throws Throwable { // Start the callback server InvokerLocator callbackServerLocator = new InvokerLocator("socket://localhost:2222"); Connector callbackConnector = new Connector(); callbackConnector.setInvokerLocator(callbackServerLocator.getLocatorURI()); callbackConnector.start(); // Start the target server InvokerLocator targetServerLocator = new InvokerLocator("socket://localhost:3456"); Connector connector = new Connector(); connector.setInvokerLocator(targetServerLocator.getLocatorURI()); connector.create(); connector.addInvocationHandler("MySubsystem", new ServerInvocationHandlerImpl()); connector.start(); Client client = new Client(targetServerLocator); client.connect(); InvokerCallbackHandler callbackHandler1 = new InvokerCallbackHandlerImpl("ONE"); client.addListener(callbackHandler1, callbackServerLocator); client.removeListener(callbackHandler1); try { client.removeListener(callbackHandler1); assertTrue("Should throw an exception if remove a callback handler that has already been removed.", false); } catch(Throwable t) { assertTrue("Got exception from server as expected.", true); } finally { connector.stop(); callbackConnector.stop(); connector.destroy(); callbackConnector.destroy(); } } private static class InvokerCallbackHandlerImpl implements InvokerCallbackHandler { private String id; public InvokerCallbackHandlerImpl(String id) { this.id = id; } public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("Handler " + id + " got callback: " + callback.getParameter()); callbacks.add(callback.getParameter()); //throw new CustomListenerException("This is the custom listener exception that I want to know about."); } } private static class ServerInvocationHandlerImpl implements ServerInvocationHandler { protected ServerInvoker serverInvoker; protected ArrayList callbackHandlers = new ArrayList(); public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { serverInvoker = invoker; } public Object invoke(InvocationRequest invocation) throws Throwable { String param = (String) invocation.getParameter(); System.out.println(param); if(param.startsWith("call back")) { String arg = param.substring("call back".length()).trim(); for(Iterator i = callbackHandlers.iterator(); i.hasNext();) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) i.next(); callbackHandler.handleCallback(new Callback(arg)); } } return null; } public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("adding listener " + callbackHandler); callbackHandlers.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { callbackHandlers.remove(callbackHandler); } } private static class CustomListenerException extends RuntimeException { public CustomListenerException(String e) { super(e); } } } ././@LongLink 0000000 0000000 0000000 00000000172 00000000000 011565 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/MultipleListenersTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/MultipleL0000644 0001750 0001750 00000014367 10527123156 033446 0 ustar twerner twerner /* * 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.remoting.callback.listeners; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import junit.framework.TestCase; /** * This is a test to make sure multiple callback listeners can be added * from the same client and the each gets their callbacks, as well * as making sure they are removed correctly. * * This test really only works the way it is coded because know that * everything will be run locally, meaning that I can check the * callback values after making in invoke call because the same * thread will make the callbacks before the thread returns from * invoke method. * * @author Ovidiu Feodorov * @author Ton Elrod * @version $Revision: 1610 $ */ public class MultipleListenersTestCase extends TestCase { private static List callbacks = new ArrayList(); private static String value1 = "FOO"; private static String value2 = "BAR"; private static String value3 = "FOOBAR"; public void testCallbacks() throws Throwable { // Start the callback server InvokerLocator callbackServerLocator = new InvokerLocator("socket://localhost:2222"); Connector callbackConnector = new Connector(); callbackConnector.setInvokerLocator(callbackServerLocator.getLocatorURI()); callbackConnector.start(); // Start the target server InvokerLocator targetServerLocator = new InvokerLocator("socket://localhost:3456"); Connector connector = new Connector(); connector.setInvokerLocator(targetServerLocator.getLocatorURI()); connector.create(); connector.addInvocationHandler("MySubsystem", new ServerInvocationHandlerImpl()); connector.start(); Client client = new Client(targetServerLocator); client.connect(); InvokerCallbackHandler callbackHandler1 = new InvokerCallbackHandlerImpl("ONE"); InvokerCallbackHandler callbackHandler2 = new InvokerCallbackHandlerImpl("TWO"); client.addListener(callbackHandler1, callbackServerLocator); client.invoke("call back " + value1); assertEquals(1, callbacks.size()); callbacks.clear(); client.addListener(callbackHandler2, callbackServerLocator); client.invoke("call back " + value2); assertEquals(2, callbacks.size()); callbacks.clear(); client.removeListener(callbackHandler1); client.invoke("call back " + value3); assertEquals(1, callbacks.size()); callbacks.clear(); client.removeListener(callbackHandler2); connector.stop(); callbackConnector.stop(); connector.destroy(); callbackConnector.destroy(); } private static class InvokerCallbackHandlerImpl implements InvokerCallbackHandler { private String id; public InvokerCallbackHandlerImpl(String id) { this.id = id; } public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("Handler " + id + " got callback: " + callback.getParameter()); callbacks.add(callback.getParameter()); //throw new CustomListenerException("This is the custom listener exception that I want to know about."); } } private static class ServerInvocationHandlerImpl implements ServerInvocationHandler { protected ServerInvoker serverInvoker; protected ArrayList callbackHandlers = new ArrayList(); public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { serverInvoker = invoker; } public Object invoke(InvocationRequest invocation) throws Throwable { String param = (String) invocation.getParameter(); System.out.println(param); if(param.startsWith("call back")) { String arg = param.substring("call back".length()).trim(); for(Iterator i = callbackHandlers.iterator(); i.hasNext();) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) i.next(); System.out.println("sending callback to " + callbackHandler); callbackHandler.handleCallback(new Callback(arg)); } } return null; } public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("adding listener " + callbackHandler); callbackHandlers.add(callbackHandler); } public void removeListener(InvokerCallbackHandler callbackHandler) { System.out.println("removing listener " + callbackHandler); callbackHandlers.remove(callbackHandler); } } private static class CustomListenerException extends RuntimeException { public CustomListenerException(String e) { super(e); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/configuration/ 0000755 0001750 0001750 00000000000 11632407042 032435 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000210 00000000000 011556 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/configuration/CallbackServerConfigurationTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/configuration/Callb0000644 0001750 0001750 00000014476 10607110427 033410 0 ustar twerner twerner /* * 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.remoting.callback.configuration; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * This unit test verifies that InvokerLocator parameters are passed to callback * server invokers created by Client.addListener(). * * See JBREM-733. * * @author Ron Sigal * @version $Revision: 2343 $ ** Copyright Apr 11, 2007 *
*/ public class CallbackServerConfigurationTestCase extends TestCase { private static Logger log = Logger.getLogger(CallbackServerConfigurationTestCase.class); private static boolean firstTime = true; // remoting server connector private Connector connector; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void testCallbackConfiguration() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port + "/?timeout=12345"; InvokerLocator serverLocator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(serverConfig); connector = new Connector(serverLocator, serverConfig); connector.create(); ServerInvocationHandler invocationHandler = new SimpleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); System.out.println("Started remoting server with locator uri of: " + locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); log.info("client added callback handler"); // Test connection. Integer response = (Integer) client.invoke(new Integer(17)); assertEquals(18, response.intValue()); // Test callback server invoker configuration. Field field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectorsMap = (Map) field.get(client); assertEquals(1, callbackConnectorsMap.size()); Set callbackConnectorsSet = (Set) callbackConnectorsMap.values().iterator().next(); assertEquals(1, callbackConnectorsSet.size()); Connector callbackConnector = (Connector) callbackConnectorsSet.iterator().next(); ServerInvoker callbackServerInvoker = callbackConnector.getServerInvoker(); assertEquals(12345, callbackServerInvoker.getTimeout()); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); connector.destroy(); } public void tearDown() { } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) { } protected void addExtraServerConfig(Map config) { } /** * Simple invocation handler implementation. When callback client's are registered, will * generate callbacks periodically. */ static class SimpleInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(InvocationRequest invocation) throws Throwable { Integer i = (Integer) invocation.getParameter(); return new Integer(i.intValue() + 1); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class SimpleCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.debug("received callback: " + callback.getParameter()); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/ 0000755 0001750 0001750 00000000000 11632407041 030721 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/ 0000755 0001750 0001750 00000000000 11632407041 032511 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000203 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/BlockingStoreDeadlockTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/Bloc0000644 0001750 0001750 00000015366 11413660476 033340 0 ustar twerner twerner package org.jboss.test.remoting.callback.store.blocking; import java.net.InetAddress; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; public class BlockingStoreDeadlockTestCase extends TestCase { private static Logger log = Logger.getLogger(BlockingStoreDeadlockTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testForDeadlock() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Add callback handler. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler); log.info("callback handler added"); // Get callback. log.info("client getting callback"); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); List callbacks = client.getCallbacks(callbackHandler, metadata); assertEquals(1, callbacks.size()); log.info("got callback"); client.removeListener(callbackHandler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "/?" + metadata; } serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvokerCallbackHandler.CALLBACK_MEM_CEILING, "100"); config.put(ServerInvokerCallbackHandler.CALLBACK_STORE_KEY, "org.jboss.remoting.callback.BlockingCallbackStore"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { InvokerCallbackHandler handler; public void addListener(InvokerCallbackHandler callbackHandler) { handler = callbackHandler; Runtime runtime = Runtime.getRuntime(); long max = 0; long total = 0; // long free = runtime.freeMemory(); // float percentage = 100 * free / total; // if(max == total && memPercentCeiling >= percentage) ArrayList list = new ArrayList(); do { try { list.add(new Byte[1000000]); max = runtime.maxMemory(); total = runtime.totalMemory(); log.info("max = " + max + ", total = " + total); } catch (OutOfMemoryError e) { log.info("heap space is full"); break; } } while (max != total); log.info("heap is full"); log.info("thread: " + Thread.currentThread().getName()); new Thread() { public void run() { try { log.info("thread: " + Thread.currentThread().getName()); log.info("adding callback"); handler.handleCallback(new Callback("callback")); log.info("added callback"); } catch (HandleCallbackException e) { log.error("Error", e); } } }.start(); log.info("server added callback handler"); } public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler){} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); } } } ././@LongLink 0000000 0000000 0000000 00000000203 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/BlockingCallbackStoreTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/Bloc0000644 0001750 0001750 00000006311 10433414054 033314 0 ustar twerner twerner /* * 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.remoting.callback.store.blocking; import junit.framework.TestCase; import org.jboss.remoting.callback.BlockingCallbackStore; import java.io.IOException; import java.io.Serializable; /** * @author Tom Elrod */ public class BlockingCallbackStoreTestCase extends TestCase { private boolean failure = false; private static int lowCounter = 0; private static int highCounter = 500; public void testBlockingStore() throws Exception { final BlockingCallbackStore store = new BlockingCallbackStore(); new Thread(new Runnable() { public void run() { for(int x = 0; x < 100; x++) { try { store.add(new Holder(x)); } catch (IOException e) { failure = true; e.printStackTrace(); } } } }).start(); new Thread(new Runnable() { public void run() { for(int i = 500; i < 600; i++) { try { store.add(new Holder(i)); } catch (IOException e) { failure = true; e.printStackTrace(); } } } }).start(); Thread.sleep(1000); Holder holder = (Holder)store.getNext(); while(holder != null) { int num = holder.getNum(); if(num <= 100) { System.out.println("lowCounter = " + lowCounter + ", num = " + num); assertEquals(lowCounter, num); lowCounter++; } else { System.out.println("highCounter = " + highCounter + ", num = " + num); assertEquals(highCounter, num); highCounter++; } Thread.sleep(100); holder = (Holder)store.getNext(); } assertFalse(failure); } public class Holder implements Serializable { private int num = 0; public Holder(int num) { this.num = num; } public int getNum() { return num; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/ 0000755 0001750 0001750 00000000000 11632407044 027704 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRaceTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRace0000644 0001750 0001750 00000022221 11413704324 033565 0 ustar twerner twerner package org.jboss.test.remoting.registry; import java.net.InetAddress; import java.net.MalformedURLException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.bisocket.Bisocket; import EDU.oswego.cs.dl.util.concurrent.Rendezvous; /** * Unit test for JBREM-1056. * * @author Ron Sigal * @version $Revision: 1.1 $ * ** Copyright Nov 8, 2008 *
*/ public class InvokerRegistryRaceTestCase extends TestCase { private static Logger log = Logger.getLogger(InvokerRegistryRaceTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); } } public void tearDown() { } public void testRaceCondition() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); int THREADS = 20; int LOOPS = 1000; Rendezvous barrier = new Rendezvous(THREADS * 2 + 1); CreateCallbackThread[] createCallbackThreads = new CreateCallbackThread[THREADS]; InvokerLocatorUpdateThread[] invokerLocatorUpdateThreads = new InvokerLocatorUpdateThread[THREADS]; for (int i = 0; i < THREADS; i++) { createCallbackThreads[i] = new CreateCallbackThread(i, client, barrier, LOOPS); invokerLocatorUpdateThreads[i] = new InvokerLocatorUpdateThread(i, barrier, LOOPS * 100); createCallbackThreads[i].start(); invokerLocatorUpdateThreads[i].start(); } log.info("main thread going to rendezvous"); barrier.rendezvous(null); barrier.rendezvous(null); log.info("main thread leaving second rendezvous"); client.disconnect(); shutdownServer(); for (int i = 0; i < THREADS; i++) { assertTrue(createCallbackThreads[i].ok); assertTrue(invokerLocatorUpdateThreads[i].ok); } log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "/?" + metadata; } serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); } } static class CreateCallbackThread extends Thread { int id; Client client; Rendezvous barrier; int counter; public boolean ok = true; public CreateCallbackThread(int id, Client client, Rendezvous barrier, int counter) { this.id = id; this.client = client; this.barrier = barrier; this.counter = counter; setName("CreateCallbackThread:" + id); } public void run() { HashMap metadata = new HashMap(); metadata.put(Client.CALLBACK_SERVER_PORT, "8888888" + id); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); TestCallbackHandler callbackHandler = new TestCallbackHandler(); rendezvous(); log.info(this + " passed barrier"); for (int i = 0; i < counter; i++) { try { if ((i + 1) % (counter / 5) == 0) { log.info(this + " adding listener: " + (i + 1)); } client.addListener(callbackHandler, metadata, null, true); if ((i + 1) % (counter / 5) == 0) { log.info(this + " added listener: " + (i + 1)); } client.removeListener(callbackHandler); if ((i + 1) % (counter / 5) == 0) { log.info(this + " removed listener: " + (i + 1)); } } catch (Throwable t) { log.error("unable to register callback handler", t); ok = false; } } log.info(this + " entering final rendezvous"); rendezvous(); } private void rendezvous() { try { barrier.rendezvous(null); } catch (Exception e) { log.error("error in rendezvous", e); } } } static class InvokerLocatorUpdateThread extends Thread { int id; InvokerLocator locator; Rendezvous barrier; int counter; boolean ok = true; public InvokerLocatorUpdateThread(int id, Rendezvous barrier, int counter) throws MalformedURLException { this.id = id; this.barrier = barrier; this.counter = counter; setName("InvokerLocatorUpdateThread:" + id); locator = new InvokerLocator("socket://localhost:8888"); } public void run() { rendezvous(); log.info(this + " passed barrier"); for (int i = 0; i < counter; i++) { try { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.updateServerInvokerLocator(locator, locator); return null; } }); if ((i + 1) % (counter / 5) == 0) { log.info(this + " updated locator: " + (i + 1)); } } catch (Exception e) { ok = false; log.error("error updated locator", e); } } log.info(this + " entering final rendezvous"); rendezvous(); } private void rendezvous() { try { barrier.rendezvous(null); } catch (Exception e) { log.error("error in rendezvous", e); } } } } ././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011567 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryTest0000644 0001750 0001750 00000010215 10433770344 033640 0 ustar twerner twerner /* * 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.remoting.registry; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.local.LocalClientInvoker; import javax.management.MBeanServer; /** * @author Ovidiu Feodorov * @version $Revision: 1036 $ * * $Id: InvokerRegistryTestCase.java 1036 2006-05-21 04:47:32Z telrod $ */ public class InvokerRegistryTestCase extends TestCase { // Constants ----------------------------------------------------- // Static -------------------------------------------------------- // Attributes ---------------------------------------------------- // Constructors -------------------------------------------------- public InvokerRegistryTestCase(String name) { super(name); } // Public -------------------------------------------------------- public void setUp() throws Exception { super.setUp(); } public void tearDown() throws Exception { super.tearDown(); } public void testEmptyInvokerRegistry() throws Throwable { ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers(); assertEquals(0, clientInvokers.length); } public void testInvokerRegistry() throws Throwable { String serverlocatorURI = "socket://127.0.0.1:5555"; Connector server = new Connector(); server.setInvokerLocator(serverlocatorURI); server.start(); server.addInvocationHandler("TEST", new ServerInvocationHandlerImpl()); new Client(new InvokerLocator(serverlocatorURI), "TEST").connect(); ClientInvoker[] clientInvokers = InvokerRegistry.getClientInvokers(); assertEquals(1, clientInvokers.length); LocalClientInvoker clientInvoker = (LocalClientInvoker) clientInvokers[0]; InvokerLocator locator = clientInvoker.getLocator(); assertEquals("socket", locator.getProtocol()); assertEquals("127.0.0.1", locator.getHost()); assertEquals(5555, locator.getPort()); } // Package protected --------------------------------------------- // Protected ----------------------------------------------------- // Private ------------------------------------------------------- // Inner classes ------------------------------------------------- private class ServerInvocationHandlerImpl implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public Object invoke(InvocationRequest invocation) throws Throwable { return null; } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } } } ././@LongLink 0000000 0000000 0000000 00000000164 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryUpdateTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryUpda0000644 0001750 0001750 00000004215 10355142433 033610 0 ustar twerner twerner /* * 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.remoting.registry; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.Connector; import junit.framework.TestCase; /** * @author Tom Elrod */ public class InvokerRegistryUpdateTestCase extends TestCase { private Connector connector; private String locatorURI = "socket://localhost"; public void setUp() throws Exception { connector = new Connector(); connector.setInvokerLocator(locatorURI); connector.create(); connector.stop(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void testRegistryUpdate() { ServerInvoker[] serverInvokers = InvokerRegistry.getServerInvokers(); ServerInvoker serverInvoker = serverInvokers[0]; InvokerLocator locator = serverInvoker.getLocator(); String locatorURI = locator.getLocatorURI(); assertTrue("Invoker locator uri should have changed.", !this.locatorURI.equals(locatorURI)); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/ 0000755 0001750 0001750 00000000000 11632407030 030211 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/local/ 0000755 0001750 0001750 00000000000 11632407030 031303 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/local/ConcurrentTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/local/ConcurrentT0000644 0001750 0001750 00000007172 10434116515 033507 0 ustar twerner twerner package org.jboss.test.remoting.concurrent.local; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; /** * @author Tom Elrod */ public class ConcurrentTestCase extends TestCase { private String locatorUri = "socket://localhost:8777"; private boolean failure = false; private Client client = null; private Connector connector = null; private int numOfThreads = 100; private int numOfIterations = 100; private int[][] results = null; public void setUp() throws Exception { connector = new Connector(locatorUri); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); client = new Client(new InvokerLocator(locatorUri)); client.connect(); results = new int[numOfThreads][numOfIterations]; } public void testConcurrentInvocations() throws Exception { for(int x = 0; x < numOfThreads; x++) { final int num = x; new Thread(new Runnable() { public void run() { try { runInvocations(num); } catch (Throwable throwable) { throwable.printStackTrace(); } } }, "" + x).start(); } Thread.sleep(20000); assertFalse(failure); assertTrue(validateResults()); } private boolean validateResults() { boolean failed = true; for(int z = 0; z < numOfThreads; z++) { for(int q = 1; q < numOfIterations; q++) { int a = results[z][q -1]; int b = results[z][q]; //System.out.println("a = " + a + ", b = " + b + ((b -1 != a) ? " - FAILED" : "")); if(b - 1 != a) { failed = false; } } } return failed; } private void runInvocations(int num) throws Throwable { for(int i = 0; i < numOfIterations; i++) { String param = num + "-" + i; Object result = client.invoke(param); //System.out.println(Thread.currentThread() + " - " + result); assertEquals(param, result); String subResult = ((String)result).substring(String.valueOf(num).length() + 1); //System.out.println(Thread.currentThread() + " - " + subResult); results[num][i] = Integer.parseInt(subResult); } } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } if(client != null) { client.disconnect(); } } public class TestInvocationHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } public Object invoke(InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/ 0000755 0001750 0001750 00000000000 11632407031 031505 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000164 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/ConcurrentTestClient.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/Concurrent0000644 0001750 0001750 00000006565 10434116515 033571 0 ustar twerner twerner /* * 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.remoting.concurrent.remote; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ConcurrentTestClient extends TestCase { private String locatorUri = "socket://localhost:8777"; private boolean failure = false; private Client client = null; private int numOfThreads = 100; private int numOfIterations = 100; private int[][] results = null; public void setUp() throws Exception { client = new Client(new InvokerLocator(locatorUri)); client.connect(); results = new int[numOfThreads][numOfIterations]; } public void testConcurrentInvocations() throws Exception { for(int x = 0; x < numOfThreads; x++) { final int num = x; new Thread(new Runnable() { public void run() { try { runInvocations(num); } catch (Throwable throwable) { throwable.printStackTrace(); } } }, "" + x).start(); } Thread.sleep(20000); assertFalse(failure); assertTrue(validateResults()); } private boolean validateResults() { boolean failed = true; for(int z = 0; z < numOfThreads; z++) { for(int q = 1; q < numOfIterations; q++) { int a = results[z][q -1]; int b = results[z][q]; //System.out.println("a = " + a + ", b = " + b + ((b -1 != a) ? " - FAILED" : "")); if(b - 1 != a) { failed = false; } } } return failed; } private void runInvocations(int num) throws Throwable { for(int i = 0; i < numOfIterations; i++) { String param = num + "-" + i; Object result = client.invoke(param); //System.out.println(Thread.currentThread() + " - " + result); assertEquals(param, result); String subResult = ((String)result).substring(String.valueOf(num).length() + 1); //System.out.println(Thread.currentThread() + " - " + subResult); results[num][i] = Integer.parseInt(subResult); } } public void tearDown() { if(client != null) { client.disconnect(); } } } ././@LongLink 0000000 0000000 0000000 00000000162 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/ConcurrentTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/Concurrent0000644 0001750 0001750 00000002574 10434116515 033565 0 ustar twerner twerner /* * 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.remoting.concurrent.remote; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class ConcurrentTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ConcurrentTestClient.class.getName(), 1, ConcurrentTestServer.class.getName()); } } ././@LongLink 0000000 0000000 0000000 00000000164 00000000000 011566 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/ConcurrentTestServer.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/Concurrent0000644 0001750 0001750 00000005526 10434116515 033565 0 ustar twerner twerner /* * 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.remoting.concurrent.remote; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; /** * @author Tom Elrod */ public class ConcurrentTestServer extends ServerTestCase { private String locatorUri = "socket://localhost:8777"; private Connector connector = null; public void setUp() throws Exception { connector = new Connector(locatorUri); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { ConcurrentTestServer server = new ConcurrentTestServer(); try { server.setUp(); Thread.sleep(1200000); } catch (Exception e) { e.printStackTrace(); } } public class TestInvocationHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } public Object invoke(InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/regression/ 0000755 0001750 0001750 00000000000 11632407030 030207 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/regression/jbrem418/ 0000755 0001750 0001750 00000000000 11632407030 031543 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000212 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/regression/jbrem418/ObjectInputStreamWithClassLoaderTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/regression/jbrem418/ObjectIn0000644 0001750 0001750 00000004501 10774615546 033206 0 ustar twerner twerner /* * 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.remoting.regression.jbrem418; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; import java.security.AccessController; import java.security.PrivilegedAction; import junit.framework.TestCase; import org.jboss.remoting.loading.ObjectInputStreamWithClassLoader; /** * @author Carlo de Wolf * @version $Revision: 3872 $ */ public class ObjectInputStreamWithClassLoaderTestCase extends TestCase { public static void main(String[] args) { junit.textui.TestRunner.run(ObjectInputStreamWithClassLoaderTestCase.class); } public void testIntPrimitive() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(int.class); out.flush(); out.close(); byte data[] = baos.toByteArray(); ClassLoader cl = (ClassLoader)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new ClassLoader() {}; } }); ByteArrayInputStream bais = new ByteArrayInputStream(data); ObjectInputStreamWithClassLoader in = new ObjectInputStreamWithClassLoader(bais, cl); in.readObject(); in.close(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/TestUtil.java 0000644 0001750 0001750 00000005073 10355142433 030460 0 ustar twerner twerner /* * 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.remoting; import java.io.IOException; import java.net.ServerSocket; import java.security.SecureRandom; import org.jboss.logging.Logger; /** * @author Tom Elrod */ public class TestUtil { private static final Logger log = Logger.getLogger(TestUtil.class); public static int getRandomPort() { Integer port = null; while(port == null) { port = getFreePort(); if(port != null) { // validate port again, just in case two instances start on the port at same time. port = validatePort(port.intValue()); } } return port.intValue(); } private static Integer getFreePort() { Object o = new Object(); String os = o.toString(); os = os.substring(17); int n = Integer.parseInt(os, 16); int p = Math.abs(new SecureRandom(String.valueOf(System.currentTimeMillis() + n).getBytes()).nextInt(2000)) + 2000; return validatePort(p); } private static Integer validatePort(int p) { Integer port = null; ServerSocket socket = null; try { socket = new ServerSocket(p); port = new Integer(p); } catch(IOException e) { log.debug("port " + p + " already in use. Will try another."); port = null; } finally { if(socket != null) { try { socket.close(); } catch(IOException e) { } } } return port; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/ 0000755 0001750 0001750 00000000000 11632407041 030325 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/ 0000755 0001750 0001750 00000000000 11632407041 031237 5 ustar twerner twerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/rmi/ 0000755 0001750 0001750 00000000000 11632407041 032026 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000175 00000000000 011570 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/rmi/RMIClassloaderRaceTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/rmi/RMIClas0000644 0001750 0001750 00000002673 11413660476 033225 0 ustar twerner twerner /* * 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.remoting.classloader.race.rmi; import org.jboss.test.remoting.classloader.race.ClassloaderRaceTestParent; /** * Unit tests for JBREM-900. See parent class for details. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Feb 22, 2008 *
*/ public class RMIClassloaderRaceTestCase extends ClassloaderRaceTestParent { protected String getTransport() { return "rmi"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/socket/ 0000755 0001750 0001750 00000000000 11632407041 032527 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000203 00000000000 011560 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/socket/SocketClassloaderRaceTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/socket/Sock0000644 0001750 0001750 00000002704 11413660476 033366 0 ustar twerner twerner /* * 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.remoting.classloader.race.socket; import org.jboss.test.remoting.classloader.race.ClassloaderRaceTestParent; /** * Unit tests for JBREM-900. See parent class for details. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Feb 22, 2008 *
*/ public class SocketClassloaderRaceTestCase extends ClassloaderRaceTestParent { protected String getTransport() { return "socket"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/http/ 0000755 0001750 0001750 00000000000 11632407041 032216 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000177 00000000000 011572 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/http/HttpClassloaderRaceTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/http/HttpCl0000644 0001750 0001750 00000002676 11413660476 033364 0 ustar twerner twerner /* * 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.remoting.classloader.race.http; import org.jboss.test.remoting.classloader.race.ClassloaderRaceTestParent; /** * Unit tests for JBREM-900. See parent class for details. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Feb 22, 2008 *
*/ public class HttpClassloaderRaceTestCase extends ClassloaderRaceTestParent { protected String getTransport() { return "http"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/bisocket/ 0000755 0001750 0001750 00000000000 11632407041 033042 5 ustar twerner twerner ././@LongLink 0000000 0000000 0000000 00000000207 00000000000 011564 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/bisocket/BisocketClassloaderRaceTestCase.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/bisocket/Bi0000644 0001750 0001750 00000003354 11413660476 033336 0 ustar twerner twerner /* * 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.remoting.classloader.race.bisocket; import org.jboss.test.remoting.classloader.race.ClassloaderRaceTestParent; /** * Unit tests for JBREM-900. See parent class for details. * * @author Ron Sigal * @version $Revision: 1.1 $ ** Copyright Feb 22, 2008 *
*/ public class BisocketClassloaderRaceTestCase extends ClassloaderRaceTestParent { protected String getTransport() { return "bisocket"; } public static void main(String[] args) { try { BisocketClassloaderRaceTestCase tc = new BisocketClassloaderRaceTestCase(); tc.setUp(); tc.testSequential(); } catch (Throwable t) { t.printStackTrace(); } } } ././@LongLink 0000000 0000000 0000000 00000000170 00000000000 011563 L ustar root root libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/ClassloaderRaceTestParent.java libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/Classloader0000644 0001750 0001750 00000030253 11413660476 033433 0 ustar twerner twerner /* * 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.remoting.classloader.race; import java.lang.ref.WeakReference; import java.net.InetAddress; import java.net.URL; import java.net.URLClassLoader; import java.util.HashMap; import java.util.Map; import java.util.WeakHashMap; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * * Unit tests for JBREM-900. * * Note: The class org.jboss.test.remoting.classloader.race.TestObject mentioned * in the tests below is found in * ** Copyright Feb 19, 2008 *
*/ public abstract class ClassloaderRaceTestParent extends TestCase { private static Logger log = Logger.getLogger(ClassloaderRaceTestParent.class); private static boolean firstTime = true; protected static String metadata; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); metadata = System.getProperty("remoting.metadata", "serializationtype=java"); } } public void tearDown() { } public void testDirectClassloading() throws Throwable { log.info("entering " + getName()); URL url = ClassloaderRaceTestParent.class.getResource("test.jar"); ClassLoader cl1 = new TestClassLoader(new URL[]{url}); Class c1 = cl1.loadClass("org.jboss.test.remoting.classloader.race.TestObject"); Object testObject1 = c1.newInstance(); log.info("classloader1: " + testObject1.getClass().getClassLoader()); ClassLoader cl2 = new TestClassLoader(new URL[]{url}); Class c2 = cl2.loadClass("org.jboss.test.remoting.classloader.race.TestObject"); Object testObject2 = c2.newInstance(); log.info("classloader2: " + testObject2.getClass().getClassLoader()); assertFalse(testObject1.getClass().isAssignableFrom(testObject2.getClass())); log.info(getName() + " PASSES"); } public void testSequential() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected to: " + locatorURI); SimpleInvocationThread t1 = new SimpleInvocationThread(client, "InvocationThread:1"); t1.start(); t1.join(); SimpleInvocationThread t2 = new SimpleInvocationThread(client, "InvocationThread:2"); t2.start(); t2.join(); assertEquals(t1.getContextClassLoader(), t1.getResponseClassLoader()); assertEquals(t2.getContextClassLoader(), t2.getResponseClassLoader()); assertNotSame(t1.getResponseClassLoader(), t2.getResponseClassLoader()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testSimultaneous() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected to: " + locatorURI); int COUNT = 100; log.info("COUNT: " + COUNT); SynchronizedInvocationThread[] threads = new SynchronizedInvocationThread[COUNT]; Object lock = new Object(); URL url = ClassloaderRaceTestParent.class.getResource("test.jar"); ClassLoader cl1 = new TestClassLoader(new URL[]{url}); ClassLoader cl2 = new TestClassLoader(new URL[]{url}); log.info("classloader1: " + cl1); log.info("classloader2: " + cl2); // Create threads that use cl1. for (int i = 0; i < COUNT / 2; i++) { threads[i] = new SynchronizedInvocationThread(client, cl1, i, lock); threads[i].start(); } // Create threads that use cl2. for (int i = COUNT/2; i < COUNT; i++) { threads[i] = new SynchronizedInvocationThread(client, cl2, i, lock); threads[i].start(); } // Start threads. Thread.sleep(2000); synchronized (lock) { lock.notifyAll(); } // Wait for all threads to complete. for (int i = 0; i < COUNT; i++) { threads[i].join(); } // Checks threads that use cl1. for (int i = 0; i < COUNT / 2; i++) { assertEquals("error in thread " + i, cl1, threads[i].responseClassLoader); } // Check threads that use cl2. for (int i = COUNT / 2; i < COUNT; i++) { assertEquals("error in thread " + i, cl2, threads[i].responseClassLoader); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected abstract String getTransport(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?" + metadata; serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { URL url = ClassloaderRaceTestParent.class.getResource("test.jar"); ClassLoader cl1 = new TestClassLoader(new URL[]{url}); Class c = cl1.loadClass("org.jboss.test.remoting.classloader.race.TestObject"); Object o = c.newInstance(); return o; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestClassLoader extends URLClassLoader { public TestClassLoader(URL[] urls) { super(urls, null); } public Class findClass(String fqn) throws ClassNotFoundException { log.debug(this + " loading class: " + fqn); Class c = super.findClass(fqn); log.debug(this + " loaded class: " + fqn); return c; } } static class SimpleInvocationThread extends Thread { Client client; String name; ClassLoader contextClassLoader; ClassLoader responseClassLoader; public SimpleInvocationThread(Client client, String name) { this.client = client; this.name = name; } public void run() { try { URL url = getClass().getResource("test.jar"); contextClassLoader = new TestClassLoader(new URL[]{url}); Thread.currentThread().setContextClassLoader(contextClassLoader); log.info(this + " context classloader: " + contextClassLoader); Object response = client.invoke(name); responseClassLoader = response.getClass().getClassLoader(); log.info(this + " response classloader: " + responseClassLoader); } catch (Throwable t) { log.error("unable to complete invocation", t); } } public ClassLoader getContextClassLoader() { return contextClassLoader; } public ClassLoader getResponseClassLoader() { return responseClassLoader; } public String toString() { return name; } } static class SynchronizedInvocationThread extends Thread { Client client; String name; ClassLoader contextClassLoader; ClassLoader responseClassLoader; Object lock; public SynchronizedInvocationThread(Client client, ClassLoader classLoader, int id, Object lock) { this.client = client; this.contextClassLoader = classLoader; this.name = "SynchronizedInvocationThread:" + id; this.lock = lock; } public void run() { try { Thread.currentThread().setContextClassLoader(contextClassLoader); synchronized (lock) { log.debug(this + " waiting"); lock.wait(); } log.debug(this + " making invocation"); Object response = client.invoke(name); responseClassLoader = response.getClass().getClassLoader(); log.debug(this + " done"); } catch (Throwable t) { log.error(this + " unable to complete invocation", t); } } public String toString() { return name; } } static class Counter { public int count; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/test.jar 0000644 0001750 0001750 00000001305 10757515317 032730 0 ustar twerner twerner PK š³S8 META-INF/PK š³S8¸-ma, , META-INF/MANIFEST.MFManifest-Version: 1.0 Created-By: 0.92-gcc PK `³S8‘Èf3ó m 9 org/jboss/test/remoting/classloader/race/TestObject.classP±NÃ0}nÓB ¥â0ÔbuAbŠÊЪ»ãžŠ#7–l—¿bBbàø(Ä5±W'?ù½{wzº¯ïO cŒ2ônœ_ɦv!ÈH!JOkM»’Úª¬SKòÒ+MrÎí§º!3$ÃF½(i[ÿÔTà¬S“3òFYóªjKé½iMœô/¯Éƒ[RŽ>Ž d8(+ÓÒt³®ÉÏw£ÊieŠ·0ÿ“øl‚ÀmµGè;|æ6^Ó£Ùî*ÿ[ãmhœƒãñðuc