libjboss-remoting-java-2.5.3.SP1.orig/0000755000175000017500000000000011632407223017370 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/lib/0000755000175000017500000000000011632407207020140 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/0000755000175000017500000000000011632407052020157 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/0000755000175000017500000000000011632407030021315 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/0000755000175000017500000000000011632407030022104 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/0000755000175000017500000000000011632407044023231 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ant/0000755000175000017500000000000011632407044024013 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ant/taskdefs/0000755000175000017500000000000011632407044025617 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatter.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/ant/taskdefs/XMLJUnitMultipleResultFormatt0000644000175000017500000000532611004016503033417 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407044024210 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/0000755000175000017500000000000011632407044026034 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/0000755000175000017500000000000011632407031030026 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/0000755000175000017500000000000011632407031031334 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/ServerExceptionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/ServerExcep0000644000175000017500000001401510355142433033516 0ustar twernertwerner/* * 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 } } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/SerializedTestException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/SerializedT0000644000175000017500000000243010355142433033500 0ustar twernertwerner/* * 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); } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/NonSerializeTestException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/server/NonSerializ0000644000175000017500000000234710355142433033525 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407031032662 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-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/0000755000175000017500000000000011632407031033451 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/rmi/CannotConnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/rmi/0000644000175000017500000000466510355142433033471 0ustar twernertwerner/* * 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); } } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-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/sock0000755000175000017500000000000011632407031033542 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/socket/CannotConnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/sock0000644000175000017500000000467310355142433033561 0ustar twernertwerner/* * 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); } } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-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/http0000755000175000017500000000000011632407031033562 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/http/CannotConnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/exception/cannotconnect/http0000644000175000017500000000466710355142433033604 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407032027644 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/datatype/DataTypeRaceTestCas0000644000175000017500000001677111413660476033412 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407044027011 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilTestCase.java0000644000175000017500000000657511003477354033112 0ustar twernertwerner/* * 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); } } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWithXMLTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWi0000644000175000017500000001532611413660476033475 0ustar twernertwerner/* * 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("\n"); buf.append(" \n"); buf.append(" " + host + "\n"); if (minPort > -1) { buf.append(" " + minPort + "\n"); } if (maxPort > -1) { buf.append(" " + maxPort + "\n"); } buf.append(" \n"); buf.append(" \n"); buf.append(" " + TestInvocationHandler.class.getName() + "\n"); buf.append(" \n"); buf.append("\n"); log.info("\n\n" + buf.toString()); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); return xml.getDocumentElement(); } public 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) {} } }././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWithServerConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerWi0000644000175000017500000002143011413660476033466 0ustar twernertwerner/* * 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.net.UnknownHostException; 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.InvocationRequest; import org.jboss.remoting.ServerConfiguration; 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 test for JBREM-1139. * * @author Ron Sigal * @version $Revision: 2320 $ *

* 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("\n"); // buf.append(" \n"); // buf.append(" " + host + "\n"); // if (minPort > -1) // { // buf.append(" " + minPort + "\n"); // } // if (maxPort > -1) // { // buf.append(" " + maxPort + "\n"); // } // buf.append(" \n"); // buf.append(" \n"); // buf.append(" " + TestInvocationHandler.class.getName() + "\n"); // buf.append(" \n"); // buf.append("\n"); // log.info("\n\n" + buf.toString()); // ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); // Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); // return xml.getDocumentElement(); // } ServerConfiguration getServerConfiguration(int minPort, int maxPort) throws UnknownHostException { ServerConfiguration serverConfiguration = new ServerConfiguration("socket"); Map invokerLocatorParameters = new HashMap(); invokerLocatorParameters.put("serverBindAddress", InetAddress.getLocalHost().getHostAddress()); serverConfiguration.setInvokerLocatorParameters(invokerLocatorParameters); Map serverParameters = new HashMap(); if (minPort > -1) { serverParameters.put(PortUtil.MIN_PORT, Integer.toString(minPort)); } if (maxPort > -1) { serverParameters.put(PortUtil.MAX_PORT, Integer.toString(maxPort)); } serverConfiguration.setServerParameters(serverParameters); Map invocationHandlers = new HashMap(); invocationHandlers.put("test", TestInvocationHandler.class.getName()); serverConfiguration.setInvocationHandlers(invocationHandlers); return serverConfiguration; } public 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/util/TimerUtilTestCase.java0000644000175000017500000001161310747572265033246 0ustar twernertwerner/* * 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 java.util.TimerTask; import org.apache.log4j.Logger; import org.jboss.remoting.util.StoppableTimerTask; import org.jboss.remoting.util.TimerUtil; import junit.framework.TestCase; /** * @author Ron Sigal * @version $Revision: 3391 $ *

* 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(); } } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnServerTe0000644000175000017500000001416211413660476033463 0ustar twernertwerner/* * 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"); } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/util/PortUtilRangeOnClientTe0000644000175000017500000001247711413660476033442 0ustar twernertwerner/* * 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.java0000644000175000017500000000311310355142433031503 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407044027312 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/client/ClientSerializationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/client/ClientSerializationTe0000644000175000017500000001474310567670756033535 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407044027511 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/DisconnectInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/DisconnectInvokerTes0000644000175000017500000001206710410561272033542 0ustar twernertwerner/* * 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 } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/LocalInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/LocalInvokerTestCase0000644000175000017500000003205611004446567033474 0ustar twernertwerner/* * 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 an org.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: *

*

    *
  1. creates an org.jboss.remoting.transport.Connector for socket://127.0.0.1:9090; *
  2. registers an org.jboss.remoting.ServerInvocationHandler that holds secret value 3; *
  3. creates an org.jboss.remoting.Client for socket://127.0.0.1:9090; *
  4. verifies that org.jboss.remoting.InvokerRegistry created an * org.jboss.remoting.transport.local.LocalClientInvoker on behalf of the Client; *
  5. retrieves the secret value from the ServerInvocationHandler; *
  6. stops the Connector; *
  7. creates a new Connector for socket://127.0.0.1:9090; *
  8. registers a new ServerInvocationHandler that holds a secret value of 7; *
  9. creates a new Client for socket://127.0.0.1:9090; *
  10. verifies that org.jboss.remoting.InvokerRegistry created a * LocalClientInvoker on behalf of the new Client; *
  11. retrieves the secret value from the new ServerInvocationHandler and verifies that it is 7. *
*

* If the second retrieved secret value is 7, then the first 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: *

*

    *
  1. creates an org.jboss.remoting.transport.Connector for socket://127.0.0.1:9090; *
  2. registers an org.jboss.remoting.ServerInvocationHandler that holds secret value 3; *
  3. creates an org.jboss.remoting.Client for socket://127.0.0.1:9090; *
  4. verifies that org.jboss.remoting.InvokerRegistry created an * org.jboss.remoting.transport.local.LocalClientInvoker on behalf of the Client; *
  5. retrieves the secret value from the ServerInvocationHandler; *
  6. stops the Connector *
  7. creates a new Connector for socket://127.0.0.1:9090; *
  8. registers a new ServerInvocationHandler that holds a secret value of 7; *
  9. retrieves the secret value from the new ServerInvocationHandler and verifies that it is 7. *
*

* If the second retrieved secret value is 7, then the old 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: *

*

    *
  1. creates a Connector according to parameter invokerLocator *
  2. registers a ServerInvocationHandler that holds secret value given by parameter secret; *
  3. creates a org.jboss.remoting.Client according to parameter invokerLocator *
  4. verifies that InvokerRegistry created a * LocalClientInvoker on behalf of the Client *
  5. retrieves the secret value from the ServerInvocationHandler *
  6. stops the Connector *
* * @param invokerLocator URI for both 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: *

*

    *
  1. creates a Connector according to parameter invokerLocator *
  2. registers a ServerInvocationHandler that holds secret value given by parameter secret. *
* * @param invokerLocator 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 } } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDisconnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDisconn0000644000175000017500000001064310744605201033530 0ustar twernertwerner/* * 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 ------------------------------------------------- } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayedDestructionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/ClientInvokerDelayed0000644000175000017500000003366211413660476033521 0ustar twernertwerner/* * 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"); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/InvokerDestructionTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invoker/InvokerDestructionTe0000644000175000017500000001214011413660476033573 0ustar twernertwernerpackage 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/0000755000175000017500000000000011632407044027446 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/binding/BindingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/binding/BindingTestCase.java0000644000175000017500000002745211005535325033327 0ustar twernertwerner/* * 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("\n") .append(" \n") .append(" \n") .append(" \n") .append(" 0.0.0.0\n") .append(" " + bindPort + "\n") .append(" \n") .append(" \n") .append(" " + SampleInvocationHandler.class.getName() + "\n") .append(" \n") .append(" \n") .append(" \n") .append("\n").toString(); Connector connector = new Connector(); ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes()); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); Element element = doc.getDocumentElement(); connector.setConfiguration(element); 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 XML document with host == 0.0.0.0, where * InvokerLocator is reconstructed with host as localhost address. */ public void testBindingsWithXMLConfigByAddress() throws Exception { System.setProperty(InvokerLocator.BIND_BY_HOST, "false"); int bindPort = PortUtil.findFreePort("0.0.0.0"); String xml = new StringBuffer() .append("\n") .append(" \n") .append(" \n") .append(" \n") .append(" 0.0.0.0\n") .append(" " + bindPort + "\n") .append(" \n") .append(" \n") .append(" " + SampleInvocationHandler.class.getName() + "\n") .append(" \n") .append(" \n") .append(" \n") .append("\n").toString(); Connector connector = new Connector(); ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes()); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); Element element = doc.getDocumentElement(); connector.setConfiguration(element); 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); } public static class SampleInvocationHandler implements ServerInvocationHandler { public Object invoke(InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void addListener(InvokerCallbackHandler callbackHandler) {} 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/version/0000755000175000017500000000000011632407033027517 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/RMIConfigurableVersionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/RMIConfigurableVersi0000644000175000017500000000251111413660476033433 0ustar twernertwerner/* * 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 RMIConfigurableVersionTestCase extends ConfigurableVersionTestParent { protected String getTransport() { return "rmi"; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/BisocketConfigurableVersionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/BisocketConfigurable0000644000175000017500000000252311413660476033541 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/HttpConfigurableVersionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/HttpConfigurableVers0000644000175000017500000000251311413660476033554 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/SocketConfigurableVersionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/SocketConfigurableVe0000644000175000017500000000251711413660476033524 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/ConfigurableVersionTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/version/ConfigurableVersionT0000644000175000017500000001414211413660476033547 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407043027335 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerServer.j0000644000175000017500000000724310506110050033471 0ustar twernertwerner/* * 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(); } } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayThreadPoolTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayThreadPoolTestC0000644000175000017500000007053011015170526033452 0ustar twernertwerner/* * 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) {} } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerClientTe0000644000175000017500000001314710716142475033525 0ustar twernertwerner/* * 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; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayInvokerTestCase0000644000175000017500000000326410535452155033526 0ustar twernertwerner/* * 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()); } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayServerInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/oneway/OnewayServerInvocatio0000644000175000017500000000714010355142433033567 0ustar twernertwerner/* * 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.java0000644000175000017500000000224710355142433032224 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407042027566 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/0000755000175000017500000000000011632407041031563 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackT0000644000175000017500000000507111012356344033332 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackT0000644000175000017500000002410410556015500033326 0ustar twernertwerner/* * 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; } } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/exception/CallbackT0000644000175000017500000001431710556015500033333 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407042030542 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/UniqueCallbackPollerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/UniqueCallback0000644000175000017500000001445510665733321033370 0ustar twernertwerner/* * 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++; } } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackInvoca0000644000175000017500000000421010445574363033332 0ustar twernertwernerpackage 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/0000755000175000017500000000000011632407042032052 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/TestCallback.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/TestCal0000644000175000017500000000262110433414054033334 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/CallbackInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/Callbac0000644000175000017500000002113010355142433033314 0ustar twernertwerner/* * 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 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(); } } } } 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; } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-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/nullsto0000755000175000017500000000000011632407042033473 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/JBossASCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000644000175000017500000002100410433770344033500 0ustar twernertwerner/* * 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; } } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/NullStoreCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000644000175000017500000000510110535452155033500 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000644000175000017500000001704410433770344033511 0ustar twernertwerner/* * 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; } } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullstore/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/nullsto0000644000175000017500000000534610355142433033506 0ustar twernertwerner/* * 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(); } } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-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/blockin0000755000175000017500000000000011632407042033414 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/CallbackInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000644000175000017500000002052510433414054033421 0ustar twernertwernerpackage 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; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/BlockingStoreCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000644000175000017500000000314210535452155033424 0ustar twernertwernerpackage 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; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000644000175000017500000001640710433770344033434 0ustar twernertwernerpackage 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; } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blocking/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/blockin0000644000175000017500000000430410433414054033416 0ustar twernertwernerpackage 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(); } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-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/callbac0000755000175000017500000000000011632407042033354 5ustar twernertwerner././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/JBossASCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000001766410433770344033402 0ustar twernertwerner/* * 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; } } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-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/callbac0000755000175000017500000000000011632407042033354 5ustar twernertwerner././@LongLink0000000000000000000000000000024100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/jbossSerialization/CallbackStoreCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000000476510535452155033400 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/jbossSerialization/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000000330110513327267033362 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/jbossSerialization/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000000374410513327267033375 0ustar twernertwerner/* * 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(); } } }././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/CallbackStoreCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000000522310535452155033366 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000001736310513327042033366 0ustar twernertwerner/* * 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; } } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000000657310513327042033367 0ustar twernertwerner/* * 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(); } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-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/callbac0000755000175000017500000000000011632407042033354 5ustar twernertwerner././@LongLink0000000000000000000000000000024000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/nonserializable/NonserializableCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000001031610513326455033364 0ustar twernertwerner/* * 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"); } } } ././@LongLink0000000000000000000000000000022700000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbackstore/nonserializable/NonserializablePayload.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/memory/callbac0000644000175000017500000000315410513326455033366 0ustar twernertwerner/* * 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; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackTestCl0000644000175000017500000000772610445574363033330 0ustar twernertwernerpackage 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 { } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackPollerShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackPoller0000644000175000017500000003345410713023462033347 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407042032332 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/blocking/BlockingPullCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/blocking/Block0000644000175000017500000007722310723066337033332 0ustar twernertwerner/* * 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(); } } } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/pull/CallbackTestSe0000644000175000017500000000366110445574363033333 0ustar twernertwernerpackage 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/0000755000175000017500000000000011632407042030502 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/leak/ServerInvokerCallbackHandlerLeakTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/leak/ServerInvokerC0000644000175000017500000002176211413660476033355 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041031420 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/0000755000175000017500000000000011632407041032676 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/CallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/Cal0000644000175000017500000000451010535452155033327 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/Cal0000644000175000017500000002512110537423164033330 0ustar twernertwernerpackage 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; } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/client/Cal0000644000175000017500000001135310524710267033331 0ustar twernertwernerpackage 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 } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTe0000644000175000017500000000433010535704450033335 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041032726 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/CallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/Cal0000644000175000017500000000451010535452155033357 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/Cal0000644000175000017500000001646310524710267033370 0ustar twernertwernerpackage 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; } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/server/Cal0000644000175000017500000001135310524710267033361 0ustar twernertwernerpackage 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 } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTe0000644000175000017500000004715710535704450033353 0ustar twernertwernerpackage 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; } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/multiple/CallbackTe0000644000175000017500000001064310535704450033341 0ustar twernertwernerpackage 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 } } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestCase.ja0000644000175000017500000000527611015165767033256 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041032050 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/acknowledge/CallbackAcknowledgeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/acknowledge/Callbac0000644000175000017500000016655511015172241033332 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041030544 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/0000755000175000017500000000000011632407041032675 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/CallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/Cal0000644000175000017500000000517410535452155033335 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/Cal0000644000175000017500000002131510370737135033331 0ustar twernertwerner/* * 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; } } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/disconnect/Cal0000644000175000017500000001555210370737135033337 0ustar twernertwerner/* * 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 } } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-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/unidirectional0000755000175000017500000000000011632407041033476 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-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/unidirectional0000755000175000017500000000000011632407041033476 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPollTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000054610433024164033504 0ustar twernertwernerpackage 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"; } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPushTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000120110433024164033471 0ustar twernertwernerpackage 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(); } } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPushTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000054610433024164033504 0ustar twernertwernerpackage 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"; } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPollTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000120210433024164033472 0ustar twernertwernerpackage 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(); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPushTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000067110433024164033503 0ustar twernertwernerpackage 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()); } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/rmi/RMICallbackPollTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000067110433024164033503 0ustar twernertwernerpackage 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()); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPollTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000370210666163153033513 0ustar twernertwernerpackage 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'"); } } } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-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/unidirectional0000755000175000017500000000000011632407041033476 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPollTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000264610433024164033507 0ustar twernertwerner/* * 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()); } }././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPollTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000252010433024164033476 0ustar twernertwerner/* * 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"; } }././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPollTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000316210433024164033501 0ustar twernertwerner/* * 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(); } } }././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPushTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000316110433024164033500 0ustar twernertwerner/* * 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(); } } }././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPushTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000252010433024164033476 0ustar twernertwerner/* * 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"; } }././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/socket/SocketCallbackPushTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000264610433024164033507 0ustar twernertwerner/* * 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()); } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-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/unidirectional0000755000175000017500000000000011632407041033476 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPushTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000067510433024164033507 0ustar twernertwernerpackage 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()); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPollTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000055110433024164033500 0ustar twernertwernerpackage 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"; } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPushTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000120610433024164033476 0ustar twernertwernerpackage 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(); } } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPollTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000067510433024164033507 0ustar twernertwernerpackage 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()); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPushTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000055110433024164033500 0ustar twernertwernerpackage 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"; } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/http/HTTPCallbackPollTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000120710433024164033477 0ustar twernertwernerpackage 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(); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPushTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000437510433024164033510 0ustar twernertwernerpackage 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); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPollTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000437610433024164033511 0ustar twernertwernerpackage 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); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional/CallbackPushTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/unidirectional0000644000175000017500000000302010433024164033472 0ustar twernertwernerpackage 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; } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-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/0000755000175000017500000000000011632407041033354 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-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/0000755000175000017500000000000011632407041033354 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/local/LocalCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000644000175000017500000000777010433024164033370 0ustar twernertwerner/* * 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); } } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-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/0000755000175000017500000000000011632407041033354 5ustar twernertwerner././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/multiplex/MultiplexCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000644000175000017500000000264510433024164033364 0ustar twernertwerner/* * 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()); } }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/multiplex/MultiplexCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000644000175000017500000001270010576343612033367 0ustar twernertwernerpackage 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; } } } } ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/multiplex/MultiplexCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/bidirectional/0000644000175000017500000000454310433024164033363 0ustar twernertwernerpackage 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); } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/MultipleCallbackServersTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/MultipleCallba0000644000175000017500000001533710433770344033401 0ustar twernertwerner/* * 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(); } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/ImplicitCallbackConnectorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/ImplicitCallba0000644000175000017500000003354610576176321033365 0ustar twernertwerner/* * 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++; } } } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/InVMPushCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/push/InVMPushCallba0000644000175000017500000001421010433770344033244 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041031253 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/RMICallbackTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/RMICallback0000644000175000017500000000251311413660476033255 0ustar twernertwerner /* * 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"; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/BisocketCallbackTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/BisocketCal0000644000175000017500000005376410666622655033420 0ustar twernertwerner/* * 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++; } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/SocketCallbackTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/SocketCallb0000644000175000017500000007052710666622655033417 0ustar twernertwerner/* * 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++; } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/HttpCallbackTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/HttpCallbac0000644000175000017500000000251511413660476033374 0ustar twernertwerner /* * 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"; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/CallbackTimeoutTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/timeout/CallbackTim0000644000175000017500000005652211413660476033370 0ustar twernertwerner/* * 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++; } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestClient.0000644000175000017500000002614510433770344033300 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041031052 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchC0000644000175000017500000000360710561454004033157 0ustar twernertwerner/* * 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"); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynch0000644000175000017500000000317310561311235033157 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCa0000644000175000017500000000316210561311235033167 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynch0000644000175000017500000000455510561311235033164 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplexAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplex0000644000175000017500000000321510561311235033342 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCal0000644000175000017500000000315710561311235033217 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCa0000644000175000017500000000245710561311235033175 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsy0000644000175000017500000000320410561311235033262 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketA0000644000175000017500000000321210561311235033220 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplexAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplex0000644000175000017500000000457710561311235033356 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketA0000644000175000017500000000307610561311235033230 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsy0000644000175000017500000000320110561311235033430 0ustar twernertwerner/* * 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/keystore0000644000175000017500000001376110561311235032651 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplexAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLMultiplex0000644000175000017500000000250310561311235033341 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsy0000644000175000017500000000456610561311235033276 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsyn0000644000175000017500000000456310561311235033402 0ustar twernertwerner/* * 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/truststore0000644000175000017500000000701310561311235033233 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPAsynchCa0000644000175000017500000000454710561311235033177 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchC0000644000175000017500000000310110561311235033142 0ustar twernertwerner/* * 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"); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLAsynchCallbackTestClientRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLAsynchCal0000644000175000017500000000430310561311235033223 0ustar twernertwerner/* * 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"); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLBisocketA0000644000175000017500000000456210561311235033231 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCal0000644000175000017500000000454410561311235033220 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/HTTPSAsynchC0000644000175000017500000000455210561311235033155 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/RMIAsynchCal0000644000175000017500000000245510561311235033217 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsy0000644000175000017500000000456610561311235033447 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/AsynchCallbackTestClientRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/AsynchCallba0000644000175000017500000001555010714270664033340 0ustar twernertwerner/* * 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; } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynch0000644000175000017500000000246310561311235033377 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsyn0000644000175000017500000000317610561311235033401 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/AsynchCallbackTestServerRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/AsynchCallba0000644000175000017500000001715010561311235033324 0ustar twernertwerner/* * 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) {} } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/BisocketAsyn0000644000175000017500000000306410561311235033375 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLAsynchCallbackTestServerRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLAsynchCal0000644000175000017500000000403110561311235033221 0ustar twernertwerner/* * 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"); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynchCallbackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynch0000644000175000017500000000456310561311235033402 0ustar twernertwerner/* * 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; } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLSocketAsy0000644000175000017500000000247510561311235033273 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SSLRMIAsynch0000644000175000017500000000246710561311235033164 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynchCallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/SocketAsynch0000644000175000017500000000317110561311235033374 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsynchCallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/asynch/MultiplexAsy0000644000175000017500000000247110561311235033440 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407042033275 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/connectionfailure/CallbackConnectionFailureTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/connectionfailure/C0000644000175000017500000003252411413660476033421 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407042033170 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SSLRMISSLSocketFactoryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SS0000644000175000017500000000253411413660476033455 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SSLSocketSSLSocketFactoryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SS0000644000175000017500000000254211413660476033454 0ustar twernertwerner/* * 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"; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/keystorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/ke0000644000175000017500000001376110761450663033533 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/tr0000644000175000017500000000701310761450663033552 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SSLSocketFactoryTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/SS0000644000175000017500000001620711413660476033457 0ustar twernertwerner/* * 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"); } } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/HttpsSSLSocketFactoryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/sslsocketfactory/Ht0000644000175000017500000000306411413660476033502 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041031050 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/params/UseAllParams0000644000175000017500000004005011413660476033335 0ustar twernertwerner/* * 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"); } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/CallbackTestServer.0000644000175000017500000001323510540121711033307 0ustar twernertwerner/* * 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 } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/DestroyNPETestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/DestroyNPETestCase.0000644000175000017500000001546411413660476033242 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407042031576 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/ListenerRemovedTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/ListenerR0000644000175000017500000001344110355142433033434 0ustar twernertwerner/* * 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); } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/MultipleListenersTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/listeners/MultipleL0000644000175000017500000001436710527123156033446 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407042032435 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/configuration/CallbackServerConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/configuration/Callb0000644000175000017500000001447610607110427033410 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041030721 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/0000755000175000017500000000000011632407041032511 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/BlockingStoreDeadlockTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/Bloc0000644000175000017500000001536611413660476033340 0ustar twernertwernerpackage 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"); } } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/BlockingCallbackStoreTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/callback/store/blocking/Bloc0000644000175000017500000000631110433414054033314 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407044027704 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRaceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRace0000644000175000017500000002222111413704324033565 0ustar twernertwernerpackage 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); } } } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryTest0000644000175000017500000001021510433770344033640 0ustar twernertwerner/* * 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) { } } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryUpdateTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/registry/InvokerRegistryUpda0000644000175000017500000000421510355142433033610 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407030030211 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/local/0000755000175000017500000000000011632407030031303 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/local/ConcurrentTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/local/ConcurrentT0000644000175000017500000000717210434116515033507 0ustar twernertwernerpackage 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/0000755000175000017500000000000011632407031031505 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/ConcurrentTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/Concurrent0000644000175000017500000000656510434116515033571 0ustar twernertwerner/* * 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(); } } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/ConcurrentTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/Concurrent0000644000175000017500000000257410434116515033565 0ustar twernertwerner/* * 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()); } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/ConcurrentTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/concurrent/remote/Concurrent0000644000175000017500000000552610434116515033565 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407030030207 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/regression/jbrem418/0000755000175000017500000000000011632407030031543 5ustar twernertwerner././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/regression/jbrem418/ObjectInputStreamWithClassLoaderTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/regression/jbrem418/ObjectIn0000644000175000017500000000450110774615546033206 0ustar twernertwerner/* * 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.java0000644000175000017500000000507310355142433030460 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041030325 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/0000755000175000017500000000000011632407041031237 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/rmi/0000755000175000017500000000000011632407041032026 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/rmi/RMIClassloaderRaceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/rmi/RMIClas0000644000175000017500000000267311413660476033225 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041032527 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/socket/SocketClassloaderRaceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/socket/Sock0000644000175000017500000000270411413660476033366 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041032216 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/http/HttpClassloaderRaceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/http/HttpCl0000644000175000017500000000267611413660476033364 0ustar twernertwerner/* * 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/0000755000175000017500000000000011632407041033042 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/bisocket/BisocketClassloaderRaceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/bisocket/Bi0000644000175000017500000000335411413660476033336 0ustar twernertwerner/* * 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(); } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/ClassloaderRaceTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/race/Classloader0000644000175000017500000003025311413660476033433 0ustar twernertwerner/* * 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 * * /src/etc/org/jboss/test/remoting/classloader/race. * * It is loaded from * * /output/tests/classes/org/jboss/test/remoting/classloader/race/test.jar. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* 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.jar0000644000175000017500000000130510757515317032730 0ustar twernertwernerPK š³S8 META-INF/PK š³S8¸-ma,,META-INF/MANIFEST.MFManifest-Version: 1.0 Created-By: 0.92-gcc PK `³S8‘Èf3óm9org/jboss/test/remoting/classloader/race/TestObject.classP±NÃ0}nÓB ¥â 0ÔbuAbŠÊЪ»ãžŠ#7–l—¿bBbàø(Ä5±W'?ù½{wzº¯ïOcŒ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œƒãñðucTom Elrod */ public class Dummy implements Serializable { private int id = 0; public Dummy(int i) { this.id = i; } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/arrays/ClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/arrays/ClientTes0000644000175000017500000000360510433770344033456 0ustar twernertwerner/* * 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.arrays; import junit.framework.TestCase; import org.apache.log4j.Level; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ClientTest extends TestCase { public void setUp() { 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); } public void testClientCall() throws Throwable { InvokerLocator locator = new InvokerLocator("socket://localhost:8899"); Client client = new Client(locator); client.connect(); Object obj = client.invoke("getArray"); System.out.println("Response: " + obj); } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/arrays/ServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/arrays/ServerTes0000644000175000017500000000633510430241374033502 0ustar twernertwerner/* * 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.arrays; import org.apache.log4j.Level; 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 ServerTest extends ServerTestCase { private Connector connector = null; public 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); String locator = "socket://localhost:8899"; connector = new Connector(locator); 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) { ServerTest server = new ServerTest(); try { server.setUp(); Thread.sleep(300000); } 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 { Dummy[] dummyArray = new Dummy[2]; dummyArray[0] = new Dummy(0); dummyArray[1] = new Dummy(1); return dummyArray; } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/arrays/ArrayClassloadingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/arrays/ArrayClas0000644000175000017500000000256010430241374033435 0ustar twernertwerner/* * 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.arrays; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class ArrayClassloadingTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ClientTest.class.getName(), 1, ServerTest.class.getName()); } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/InvokerServerTes0000644000175000017500000000710110355142433033531 0ustar twernertwerner/* * 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; import java.util.Iterator; import java.util.Map; import java.util.Set; 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 org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class InvokerServerTest extends ServerTestCase { private String transport = "socket"; private int serverPort = 8081; private Connector connector = null; private static final Logger log = Logger.getLogger(InvokerServerTest.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(); 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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { init(null); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { InvokerServerTest server = new InvokerServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/RemoteClassloaderTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/RemoteClassloade0000644000175000017500000002006111413660476033507 0ustar twernertwerner/* * 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.classloader; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.lang.reflect.Field; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; 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.InvokerCallbackHandler; import org.jboss.remoting.loading.ClassByteClassLoader; import org.jboss.remoting.loading.ClassBytes; import org.jboss.remoting.marshal.MarshallLoaderFactory; import org.jboss.remoting.marshal.MarshallerLoaderConstants; import org.jboss.remoting.marshal.MarshallerLoaderHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.util.SecurityUtility; /** * Unit test for JBREM-1184. * * Note that testClassNotFound() passes even in the presence of the NullPointerException * described in JBREM-1184, so it's not really a regression test. However, I'm committing * the test for its documentation value. The NPE should not be seen in the log file. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 15, 2010 */ public class RemoteClassloaderTestCase extends TestCase { private ByteArrayOutputStream baos; private PrintStream originalPrintStream; private Logger log; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; public void setUp() throws Exception { originalPrintStream = System.out; baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); setOut(ps); 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); log = Logger.getLogger(RemoteClassloaderTestCase.class); } public void tearDown() { } public void testClassNotFound() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); TestClassLoader tcl = new TestClassLoader(); InvokerLocator loaderLocator = MarshallLoaderFactory.convertLocator(serverLocator); tcl.setClientInvoker(new Client(loaderLocator)); try { tcl.findClass("a.b.c"); fail("expected ClassNotFoundException"); } catch (ClassNotFoundException e) { log.info("got expected ClassNotFoundException"); } catch (Throwable t) { fail("expected ClassNotFoundException: got " + t); } setOut(originalPrintStream); String s = new String(baos.toByteArray()); System.out.println(s); assertTrue(s.indexOf("java.lang.NullPointerException") == -1); assertTrue(s.indexOf("Can not load remote class bytes: server returned null class") >= 0); 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; locatorURI += "/?loaderport=4873"; 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(); // Install TestMarshallerLoaderHandler. Field field = Connector.class.getDeclaredField("marshallerLoaderConnector"); field.setAccessible(true); Connector marshallerLoaderConnector = (Connector) field.get(connector); MarshallerLoaderHandler loader = new TestMarshallerLoaderHandler(null); marshallerLoaderConnector.addInvocationHandler("loader", loader); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static private void setOut(final PrintStream ps) { if (SecurityUtility.skipAccessControl()) { System.setOut(ps); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { System.setOut(ps); return null; } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } 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 TestMarshallerLoaderHandler extends MarshallerLoaderHandler { public TestMarshallerLoaderHandler(List repositories) { super(repositories); } public Object invoke(InvocationRequest invocation) throws Throwable { Map metadMap = invocation.getRequestPayload(); String className = (String) metadMap.get(MarshallerLoaderConstants.CLASSNAME); return new ClassBytes(className, null); } } static class TestClassLoader extends ClassByteClassLoader { public Class findClass(String name) throws ClassNotFoundException { return super.findClass(name); } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/InvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/InvokerTestCase.0000644000175000017500000000515510535452155033414 0ustar twernertwerner/* * 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; 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 InvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InvokerClientTest.class.getName(), 1, InvokerServerTest.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; } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/InvokerClientTes0000644000175000017500000002341411061036376033511 0ustar twernertwerner/* * 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; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.util.Map; import org.jboss.logging.Logger; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.test.remoting.ComplexReturn; import org.jboss.test.remoting.transport.mock.MockTest; import junit.framework.TestCase; /** * This is a copy of org.jboss.test.remoting.transport.socket.InvokerClientTest but * uses custom classloader (and reflection) to load and make the remoting calls. * * @author Tom Elrod */ public class InvokerClientTest extends TestCase { private int port = 8081; private String transport = "socket"; private static final Logger log = Logger.getLogger(InvokerClientTest.class); public void testArrayReturn() throws Throwable { String[] classUrls = new String[]{"org.jboss.util.threadpool.ThreadPool", "javax.servlet.ServletInputStream", "org.apache.coyote.Adapter", "org.jboss.serial.io.JBossObjectOutputStream", "EDU.oswego.cs.dl.util.concurrent.SynchronizedLong", "org.jboss.logging.Logger"}; URL[] urls = getLibUrls(classUrls); URLClassLoader urlclassloader = new URLClassLoader(urls, null); TestClassLoader classloader = new TestClassLoader(urlclassloader); /* Class invokerLocator = loadClass("org.jboss.remoting.InvokerLocator", classloader); Constructor invokerLocatorConstructor = invokerLocator.getConstructor(new Class[] { String.class}); Object invokerLocatorInstance = invokerLocatorConstructor.newInstance(new Object[] { transport + "://localhost:" + port}); loadClass("org.jboss.remoting.Invoker", classloader); loadClass("org.jboss.remoting.loading.ClassByteClassLoader", classloader); loadClass("org.jboss.remoting.transport.ClientInvoker", classloader); loadClass("org.jboss.remoting.AbstractInvoker", classloader); loadClass("org.jboss.remoting.transport.local.LocalClientInvoker", classloader); loadClass("org.jboss.remoting.InvokerRegistry", classloader); loadClass("org.jboss.remoting.InvalidConfigurationException", classloader); loadClass("org.jboss.remoting.RemoteClientInvoker", classloader); loadClass("org.jboss.remoting.transport.socket.SocketClientInvoker", classloader); Class clientClz = loadClass("org.jboss.remoting.Client", classloader); Constructor clientConstructor = clientClz.getConstructor(new Class[] {invokerLocator, String.class}); Object clientInstance = clientConstructor.newInstance(new Object[] {invokerLocatorInstance, "mock"}); */ Class invokerLocator = Class.forName("org.jboss.remoting.InvokerLocator", false, classloader); Constructor invokerLocatorConstructor = invokerLocator.getConstructor(new Class[]{String.class}); Object invokerLocatorInstance = invokerLocatorConstructor.newInstance(new Object[]{transport + "://localhost:" + port}); Class clientClz = Class.forName("org.jboss.remoting.Client", false, classloader); Constructor clientConstructor = clientClz.getConstructor(new Class[]{invokerLocator, String.class}); Object clientInstance = clientConstructor.newInstance(new Object[]{invokerLocatorInstance, "mock"}); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); System.out.println("context classloader: " + contextClassLoader); System.out.println("test classloader: " + classloader); Class.forName("org.jboss.test.remoting.ComplexReturn", false, contextClassLoader); Method connectMethod = clientClz.getMethod("connect", new Class[]{}); connectMethod.invoke(clientInstance, null); // simple invoke, should return bar Object ret = null; NameBasedInvocation nbinv = new NameBasedInvocation("testComplexReturn", new Object[]{null}, new String[]{String.class.getName()}); Method invokeMethod = clientClz.getMethod("invoke", new Class[]{Object.class, Map.class}); ret = invokeMethod.invoke(clientInstance, new Object[]{nbinv, null}); ComplexReturn complexRet = (ComplexReturn) ret; MockTest[] mockTests = complexRet.getMockTests(); assertTrue("ComplexReturn's array should contain 2 items", 2 == mockTests.length); if(2 == mockTests.length) { log.debug("PASS"); } else { log.debug("FAILED - testArrayReturn1"); } for(int x = 0; x < mockTests.length; x++) { System.err.println(mockTests[x]); MockTest test = mockTests[x]; assertNotNull("MockTest should not be null", test); if(test != null) { log.debug("PASS"); } else { log.debug("FAILED - testArrayReturn2"); } } nbinv = new NameBasedInvocation("testThrowException", new Object[]{null}, new String[]{String.class.getName()}); invokeMethod = clientClz.getMethod("invoke", new Class[]{Object.class, Map.class}); try { ret = invokeMethod.invoke(clientInstance, new Object[]{nbinv, null}); assertTrue("Should have thrown exception and not reached this assert.", false); } catch(Exception e) { assertTrue("Got exception thrown as expected", true); } invokeMethod = clientClz.getMethod("disconnect", new Class[]{}); invokeMethod.invoke(clientInstance, new Object[]{}); } private URL[] getLibUrls(String[] classNames) throws Exception { URL[] urls = new URL[classNames.length + 1]; String url = null; int i = -1; int x = 0; for(; x < classNames.length; x++) { String className = classNames[x]; int index = className.lastIndexOf('.'); String fileName = className.substring(index + 1); Class clz = log.getClass().forName(className); URL fileURL = clz.getResource(fileName + ".class"); if(fileURL == null) { throw new Exception(fileName + ".class file not found"); } String fullURL = fileURL.getPath(); i = fullURL.indexOf("!"); url = fullURL.substring(0, i); urls[x] = new URL(url); } String fileSep = System.getProperty("file.separator"); i = url.indexOf("lib"); String remotingJarPath = url.substring(0, i); remotingJarPath = remotingJarPath + "output" + fileSep + "lib" + fileSep + "jboss-remoting.jar"; urls[x] = new URL(remotingJarPath); return urls; } private static Class loadClass(String className, TestClassLoader classLoader) throws Exception { int index = className.lastIndexOf('.'); String fileName = className.substring(index + 1); Class clz = log.getClass().forName(className); URL fileURL = clz.getResource(fileName + ".class"); if(fileURL == null) { throw new Exception(fileName + ".class file not found"); } File testFile = new File(fileURL.getFile()); FileInputStream fileInput = new FileInputStream(testFile); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte buf[] = new byte[4096]; while(true) { int c = fileInput.read(buf); if(c < 0) { break; } out.write(buf, 0, c); } byte[] bytes = out.toByteArray(); return classLoader.loadClass(className, bytes); } public static class TestClassLoader extends ClassLoader { /** * Creates a new class loader using the specified parent class loader for * delegation. *

*

If there is a security manager, its {@link * SecurityManager#checkCreateClassLoader() * checkCreateClassLoader} method is invoked. This may result in * a security exception.

* * @param parent The parent class loader * @throws SecurityException If a security manager exists and its * checkCreateClassLoader method doesn't allow creation * of a new class loader. * @since 1.2 */ protected TestClassLoader(ClassLoader parent) { super(parent); } protected Class loadClass(String className, byte[] classBytes) throws ClassNotFoundException { Class c = defineClass(className, classBytes, 0, classBytes.length); resolveClass(c); return Class.forName(className, false, this); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/parentfirst/0000755000175000017500000000000011632407041032666 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/parentfirst/ParentFirstClassloaderTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/classloader/parentfirst/Pare0000644000175000017500000002402411413660476033514 0ustar twernertwerner/* * 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.parentfirst; import java.io.Serializable; import java.net.InetAddress; 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.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.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1019. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Aug 3, 2008 *

*/ public class ParentFirstClassloaderTestCase extends TestCase { private static Logger log = Logger.getLogger(ParentFirstClassloaderTestCase.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() { } /** * Verify that by default the context classloader is not called first. */ public void testDefaultConfig() 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"); TestClassLoader tcl = new TestClassLoader(); Thread.currentThread().setContextClassLoader(tcl); // Test connection. client.invoke("abc"); log.info("connection is good"); // Verify that TestClassLoader has not been queried. assertFalse(tcl.visited); log.info("context classloader has not been queried"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verify that by the context classloader is called first if * org.jboss.remoting.Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION is set to "true" * in the InvokerLocator. */ public void testByInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "/?" + Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION + "=false"; 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(); log.info("client is connected"); TestClassLoader tcl = new TestClassLoader(); setContextClassLoader(tcl); // Test connection. client.invoke("abc"); log.info("connection is good"); // Verify that TestClassLoader has been queried. assertTrue(tcl.visited); log.info("context classloader has been queried"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verify that by the context classloader is called first if * org.jboss.remoting.Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION is set to "true" * in the config map. */ public void testByConfigMap() 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(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION, "false"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); TestClassLoader tcl = new TestClassLoader(); setContextClassLoader(tcl); // Test connection. client.invoke("abc"); log.info("connection is good"); // Verify that TestClassLoader has been queried. assertTrue(tcl.visited); log.info("context classloader has been queried"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verify that by the context classloader is called first if the system property * org.jboss.remoting.Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PROP is set to "true" * in the config map. */ public void testBySystemProperty() 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); System.setProperty(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PROP, "false"); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); TestClassLoader tcl = new TestClassLoader(); setContextClassLoader(tcl); // Test connection. client.invoke("abc"); log.info("connection is good"); // Verify that TestClassLoader has been queried. assertTrue(tcl.visited); log.info("context classloader has been queried"); 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(); } protected void setContextClassLoader(final ClassLoader classLoader) { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { Thread.currentThread().setContextClassLoader(classLoader); return null; } }); } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return new TestClass(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestClassLoader extends ClassLoader { boolean visited; public Class loadClass(String name) throws ClassNotFoundException { visited = true; log.info("TestClassLoader.loadClass(): " + name); throw new ClassNotFoundException(name); } } static class TestClass implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = 1L; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/0000755000175000017500000000000011632407042026767 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java0000644000175000017500000002245011413660476032546 0ustar twernertwerner/* * 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.soak; import java.net.InetAddress; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.Timer; import java.util.TimerTask; 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; /** * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 13, 2008 *

*/ public class ClientLauncher extends SoakConstants { private static Logger log = Logger.getLogger(ClientLauncher.class); private static Set mockEJBClientsInUse = Collections.synchronizedSet(new HashSet()); private static Set mockJBMClientsInUse = Collections.synchronizedSet(new HashSet()); private static Set heavyComputeClientsInUse = Collections.synchronizedSet(new HashSet()); private static Counter mockEJBClientCounter = new Counter(); private static Counter mockJBMClientCounter = new Counter(); private static Counter heavyComputeClientCounter = new Counter(); private static Counter mockEJBClientFailureCounter = new Counter(); private static Counter mockJBMClientFailureCounter = new Counter(); private static Counter heavyComputeClientFailureCounter = new Counter(); private static Random random; private static String[] transports = {"bisocket", "http", "rmi", "socket"}; private static int[] ports = {6666, 6667, 6668, 6669}; private static int[] transportCounters = new int[4]; private static String host; private static boolean creationDone; // Configuration parameters. private static int MAX_CLIENTS = 30; private static int NUMBER_OF_EJB_CALLS = 4000; private static int NUMBER_OF_JBM_CALLS = 2000; private static int NUMBER_OF_JBM_CALLBACKS = 4; private static int NUMBER_OF_HEAVY_COMPUTE_CALLS = 5; private static String HEAVY_COMPUTE_SPIN_TIME = "4000"; public static void main(String[] args) { try { 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); host = InetAddress.getLocalHost().getHostAddress(); random = new Random(System.currentTimeMillis()); Timer timer = new Timer(false); timer.schedule(new DisplayTimerTask(), 30000, 30000); long start = System.currentTimeMillis(); while (System.currentTimeMillis() - start < DURATION) { if (mockEJBClientsInUse.size() + mockJBMClientsInUse.size() + heavyComputeClientsInUse.size() < MAX_CLIENTS) { createClient(); } int n = random.nextInt(40) * 100; log.debug("waiting " + n + " ms"); Thread.sleep(n); } creationDone = true; log.info("Client creation phase complete."); } catch (Throwable t) { log.error("Error", t); } } protected static void createClient() throws Throwable { int k = random.nextInt(4); String transport = transports[k]; int port = ports[k]; transportCounters[k]++; int clientType = random.nextInt(25); if (clientType < 10) { createMockEJBClient(transport, port); } else if (clientType < 20) { createMockJBMClient(transport, port); } else { createHeavyComputeClient(transport, port); } } protected static void createMockEJBClient(String transport, int port) throws Throwable { String locatorURI = transport + "://" + host + ":" + port + "/?timeout=0"; Map metadata = new HashMap(); metadata.put(NAME, "MockEJBClient" + mockEJBClientCounter.increment() + "[" + transport + "]"); metadata.put(IN_USE_SET, mockEJBClientsInUse); metadata.put(FAILURE_COUNTER, mockEJBClientFailureCounter); metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(NUMBER_OF_EJB_CALLS))); MockEJBClient c = new MockEJBClient(locatorURI, metadata); Thread t = new Thread(c); t.start(); } protected static void createMockJBMClient(String transport, int port) throws Throwable { String locatorURI = transport + "://" + host + ":" + port + "/?timeout=0"; Map metadata = new HashMap(); metadata.put(NAME, "MockJBMClient" + mockJBMClientCounter.increment() + "[" + transport + "]"); metadata.put(IN_USE_SET, mockJBMClientsInUse); metadata.put(FAILURE_COUNTER, mockJBMClientFailureCounter); metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(NUMBER_OF_JBM_CALLS))); metadata.put(NUMBER_OF_CALLBACKS, Integer.toString(random.nextInt(NUMBER_OF_JBM_CALLBACKS))); MockJBMClient c = new MockJBMClient(locatorURI, metadata); Thread t = new Thread(c); t.start(); } protected static void createHeavyComputeClient(String transport, int port) throws Throwable { String locatorURI = transport + "://" + host + ":" + port + "/?timeout=0"; Map metadata = new HashMap(); metadata.put(NAME, "HeavyComputeClient" + heavyComputeClientCounter.increment() + "[" + transport + "]"); metadata.put(IN_USE_SET, heavyComputeClientsInUse); metadata.put(FAILURE_COUNTER, heavyComputeClientFailureCounter); metadata.put(NUMBER_OF_CALLS, Integer.toString(random.nextInt(NUMBER_OF_HEAVY_COMPUTE_CALLS))); metadata.put(SPIN_TIME, HEAVY_COMPUTE_SPIN_TIME); HeavyComputeClient c = new HeavyComputeClient(locatorURI, metadata); heavyComputeClientCounter.increment(); Thread t = new Thread(c); t.start(); } static class Counter { int count; public synchronized int getCount() { return count; } public synchronized int increment() { return count++; } public synchronized int decrement() { return --count; } } static class DisplayTimerTask extends TimerTask { public void run() { System.out.println(""); System.out.println("========================================="); System.out.println("current MockEJBCLients: " + mockEJBClientsInUse.size()); System.out.println("current MockJBMClients: " + mockJBMClientsInUse.size()); System.out.println("current HeavyComputeClients: " + heavyComputeClientsInUse.size()); System.out.println("-----------------------------------------"); System.out.println("bisocket clients: " + transportCounters[0]); System.out.println("http clients: " + transportCounters[1]); System.out.println("rmi clients: " + transportCounters[2]); System.out.println("socket clients: " + transportCounters[3]); System.out.println("-----------------------------------------"); System.out.println("failed MockEJBCLients: " + mockEJBClientFailureCounter.getCount()); System.out.println("failed MockJBMClients: " + mockJBMClientFailureCounter.getCount()); System.out.println("failed HeavyComputeClients: " + heavyComputeClientFailureCounter.getCount()); System.out.println("-----------------------------------------"); printSet(mockEJBClientsInUse); printSet(mockJBMClientsInUse); printSet(heavyComputeClientsInUse); System.out.println("========================================="); System.out.println(""); if (creationDone && mockEJBClientsInUse.size() == 0 && mockJBMClientsInUse.size() == 0 && heavyComputeClientsInUse.size() == 0) cancel(); } private void printSet(Set set) { synchronized (set) { Iterator it = set.iterator(); while(it.hasNext()) { System.out.println(it.next().toString()); } } } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/MockJBMClient.java0000644000175000017500000001014411413660476032224 0ustar twernertwerner/* * 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.soak; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.apache.log4j.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 org.jboss.remoting.transport.bisocket.Bisocket; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 13, 2008 *

*/ public class MockJBMClient extends SoakConstants implements Runnable { protected static Logger log = Logger.getLogger(MockJBMClient.class); protected InvokerLocator locator; protected Map metadata; protected String name; protected boolean ok = true; protected Client client; protected Set inUseSet; protected ClientLauncher.Counter failureCounter; public MockJBMClient(String locator, Map metadata) throws Exception { this.locator = new InvokerLocator(locator); this.metadata = metadata; this.name = (String) metadata.get(NAME); this.inUseSet = (Set) metadata.remove(IN_USE_SET); inUseSet.add(this); failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER); log.info("created " + name); } public void run() { try { client = new Client(locator); client.connect(); TestCallbackHandler callbackHandler = new TestCallbackHandler(); Map callbackMetadata = new HashMap(); if ("bisocket".equals(locator.getProtocol())) { callbackMetadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); } client.addListener(callbackHandler, callbackMetadata, null, true); log.debug(client.getSessionId() + ": added callback listener"); String s = (String) metadata.get(NUMBER_OF_CALLS); int calls = Integer.valueOf(s).intValue(); for (int i = 0; i < calls; i++) { makeCall(i); } client.removeListener(callbackHandler); client.disconnect(); s = (String) metadata.get(NUMBER_OF_CALLBACKS); int i = Integer.parseInt(s); boolean ok = callbackHandler.counter == i * calls; if (!ok) { log.info("expected: " + (i * calls) + ", received: " + callbackHandler.counter); } } catch (Throwable t) { log.error(name, t); ok = false; } finally { client.disconnect(); log.info(name + ": " + (ok ? "PASS" : "FAIL")); inUseSet.remove(this); if (!ok) failureCounter.increment(); } } protected void makeCall(int i) throws Throwable { client.invoke(CALLBACK, metadata); } static class TestCallbackHandler implements InvokerCallbackHandler { int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; log.debug("received callback"); } } public String toString() { return name; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/HeavyComputeClient.java0000644000175000017500000000630111413660476033413 0ustar twernertwerner/* * 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.soak; import java.util.Map; import java.util.Set; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 13, 2008 *

*/ public class HeavyComputeClient extends SoakConstants implements Runnable { protected static Logger log = Logger.getLogger(HeavyComputeClient.class); protected InvokerLocator locator; protected Map metadata; protected String name; protected boolean ok = true; protected Set inUseSet; protected ClientLauncher.Counter failureCounter; public HeavyComputeClient(String locator, Map metadata) throws Exception { this.locator = new InvokerLocator(locator); this.metadata = metadata; this.name = (String) metadata.get(SoakConstants.NAME); this.inUseSet = (Set) metadata.remove(IN_USE_SET); inUseSet.add(this); failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER); log.info("created " + name); } public void run() { try { String s = (String) metadata.get(SoakConstants.NUMBER_OF_CALLS); int calls = Integer.valueOf(s).intValue(); for (int i = 0; i < calls; i++) { makeCall(i); } } catch (Throwable t) { log.error(name, t); } finally { log.info(name + ": " + (ok ? "PASS" : "FAIL")); inUseSet.remove(this); if (!ok) failureCounter.increment(); } } protected void makeCall(int i) throws Throwable { Client client = null; try { client = new Client(locator); client.connect(); Object response = client.invoke(SPIN, metadata); if (!"done".equals(response)) { ok = false; log.info(name + ": failure on call " + i); } } catch (Throwable t) { ok = false; log.info(name + ": failure on call " + i); throw t; } finally { client.disconnect(); } } public String toString() { return name; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/bisocket/0000755000175000017500000000000011632407042030572 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/bisocket/BisocketProducerConsumerSoakTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/bisocket/BisocketProduc0000644000175000017500000000301411413660476033444 0ustar twernertwerner /* * 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.soak.bisocket; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.soak.ProducerConsumerSoakTestParent; public class BisocketProducerConsumerSoakTest extends ProducerConsumerSoakTestParent { int counter; protected String getTransport() { return "bisocket"; } protected void addExtraCallbackConfig(Map config) { config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put("dummy", Integer.toString(counter++)); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/MockEJBClient.java0000644000175000017500000000642611413660476032224 0ustar twernertwerner/* * 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.soak; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 13, 2008 *

*/ public class MockEJBClient extends SoakConstants implements Runnable { protected static Logger log = Logger.getLogger(MockEJBClient.class); protected InvokerLocator locator; protected Map metadata; protected String name; protected boolean ok = true; protected Set inUseSet; protected ClientLauncher.Counter failureCounter; public MockEJBClient(String locator, Map metadata) throws Exception { this.locator = new InvokerLocator(locator); this.metadata = metadata; this.name = (String) metadata.get(SoakConstants.NAME); this.inUseSet = (Set) metadata.remove(IN_USE_SET); inUseSet.add(this); failureCounter = (ClientLauncher.Counter) metadata.remove(FAILURE_COUNTER); log.info("created " + name); } public void run() { try { String s = (String) metadata.get(SoakConstants.NUMBER_OF_CALLS); int calls = Integer.valueOf(s).intValue(); for (int i = 0; i < calls; i++) { makeCall(i); } } catch (Throwable t) { log.error(name, t); } finally { inUseSet.remove(this); log.info(name + ": " + (ok ? "PASS" : "FAIL")); if (!ok) failureCounter.increment(); } } protected void makeCall(int i) throws Throwable { Client client = null; try { client = new Client(locator); client.connect(); Map metadata = new HashMap(); metadata.put(PAYLOAD, "abc"); Object response = client.invoke(COPY, metadata); if (!"abc".equals(response)) { ok = false; log.info(name + ": failure on call " + i); } } catch (Throwable t) { ok = false; log.info(name + ": failure on call " + i); throw t; } finally { client.disconnect(); } } public String toString() { return name; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/ProducerConsumerSoakTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/ProducerConsumerSoakTes0000644000175000017500000002215611413660476033522 0ustar twernertwerner/* * 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.soak; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Timer; 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.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.bisocket.Bisocket; public abstract class ProducerConsumerSoakTestParent extends TestCase { private static Logger log = Logger.getLogger(ProducerConsumerSoakTestParent.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 testSoak() throws Throwable { log.info("entering " + getName()); System.gc(); log.info("free space: " + Runtime.getRuntime().freeMemory()); // Start server. setupServer(); // Create clients. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client clients[] = new Client[SoakConstants.SENDERS]; TestCallbackHandler callbackHandler = new TestCallbackHandler(); Sender senders[] = new Sender[SoakConstants.SENDERS]; for (int i = 0; i < SoakConstants.SENDERS; i++) { clients[i] = new Client(clientLocator, clientConfig); clients[i].connect(); log.info("client " + i + " is connected"); HashMap callbackMetadata = new HashMap(); for (int j = 0; j < SoakConstants.CALLBACK_LISTENERS; j++) { callbackMetadata.clear(); addExtraCallbackConfig(callbackMetadata); clients[i].addListener(callbackHandler, callbackMetadata, null, true); } log.info("callback handlers installed for client " + i); senders[i] = new Sender(i, clients[i]); } Timer timer = new Timer(true); timer.schedule(new IntervalTimerTask(), 60000, 60000); for (int i = 0; i < SoakConstants.SENDERS; i++) { senders[i].start(); } log.info("senders atarted"); int invocations = 0; for (int i = 0; i < SoakConstants.SENDERS; i++) { senders[i].join(); invocations += senders[i].counter; } log.info("senders done"); log.info("invocations made: " + invocations); log.info("invocations received: " + invocationHandler.counter); log.info("callbacks received: " + callbackHandler.counter); assertEquals(invocations, invocationHandler.counter); assertEquals(invocations * SoakConstants.SENDERS * SoakConstants.CALLBACK_LISTENERS, callbackHandler.counter); for (int i = 0; i < SoakConstants.SENDERS; i++) { clients[i].removeListener(callbackHandler); clients[i].disconnect(); } shutdownServer(); System.gc(); log.info("free space: " + Runtime.getRuntime().freeMemory()); log.info(getName() + " PASSES"); } protected abstract String getTransport(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void addExtraCallbackConfig(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 { HashSet listeners = new HashSet(); int counter; Object lock = new Object(); public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { synchronized (lock) { counter++; if ((counter + 1) % SoakConstants.INTERVAL == 0) log.info("invocations received: " + (counter + 1)); } Object o = invocation.getParameter(); Callback c = new Callback(o); Iterator it = listeners.iterator(); while(it.hasNext()) { ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) it.next(); handler.handleCallbackOneway(c); handler.handleCallback(c); } return o; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { int counter; Object lock = new Object(); public void handleCallback(Callback callback) throws HandleCallbackException { synchronized (lock) { counter++; if ((counter + 1) % SoakConstants.INTERVAL == 0) log.info("callbacks received: " + (counter + 1)); } } } static class Sender extends Thread { String name; Client client; int counter; Object lock = new Object(); long start; public Sender(int id, Client client) { name = "sender:" + id; this.client = client; } public void run() { try { start = System.currentTimeMillis(); while (System.currentTimeMillis() - start <= SoakConstants.DURATION) { counter++; if ((counter + 1) % SoakConstants.INTERVAL == 0) log.info(name + " invcations made: : " + (counter + 1)); client.invoke(name + ":" + counter); } } catch (Throwable t) { log.error(this, t); } } } static class IntervalTimerTask extends TimerTask { int counter; public void run() { log.info("MINUTES ELAPSED: " + ++counter); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/SoakConstants.java0000644000175000017500000000411411413660476032435 0ustar twernertwerner/* * 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.soak; /** * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 24, 2008 *

*/ public class SoakConstants { public static final int SENDERS = 5; public static final int CALLBACK_LISTENERS = 5; public static final int DURATION = 12 * 60 * 60 * 1000; public static final int INTERVAL = 1000000; public static final String locator = "://localhost:5678"; public static final String NUMBER_OF_CALLS = "numberOfCalls"; public static final String NAME = "name"; public static final String COPY = "copy"; public static final String SPIN = "spin"; public static final String CALLBACK = "callback"; public static final String NUMBER_OF_CALLBACKS = "numberOfCallbacks"; public static final String PAYLOAD = "payload"; public static final String SPIN_TIME = "spinTime"; public static final String COUNTER = "counter"; public static final String FAILURE_COUNTER = "failureCounter"; public static final String IN_USE_SET = "inUseSet"; } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java0000644000175000017500000001712611413660476032602 0ustar twernertwerner/* * 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.soak; 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 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.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.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; /** * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 13, 2008 *

*/ public class ServerLauncher extends SoakConstants { private static Logger log = Logger.getLogger(ServerLauncher.class); private static Map locators = new HashMap(); private static Connector[] connectors = new Connector[4]; public static Map getLocators() { return locators; } public static void main(String[] args) { try { 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); String host = InetAddress.getLocalHost().getHostAddress(); connectors[0] = setupServer(host, 6666, "bisocket"); locators.put("bisocket", connectors[0].getLocator().getLocatorURI()); connectors[1] = setupServer(host, 6667, "http"); locators.put("http", connectors[1].getLocator().getLocatorURI()); connectors[2] = setupServer(host, 6668, "rmi"); locators.put("rmi", connectors[2].getLocator().getLocatorURI()); connectors[3] = setupServer(host, 6669, "socket"); locators.put("socket", connectors[3].getLocator().getLocatorURI()); log.info("SERVERS CREATED: " + locators); System.in.read(); System.in.read(); System.in.read(); log.info("SHUTTING DOWN SERVERS"); for (int i = 0; i < connectors.length; i++) { connectors[i].stop(); } log.info("SERVERS SHUT DOWN"); } catch (Exception e) { log.error("Error", e); } } protected static Connector setupServer(String host, int port, String transport) throws Exception { String locatorURI = transport + "://" + host + ":" + port + "/?timeout=0"; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Connector connector = new Connector(serverLocator, config); connector.create(); TestInvocationHandler invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); return connector; } static class TestInvocationHandler implements ServerInvocationHandler { Map listeners = new HashMap(); Object lock = new Object(); public void addListener(InvokerCallbackHandler callbackHandler) { log.debug("entering addListener()"); synchronized (lock) { String id = ((ServerInvokerCallbackHandler)callbackHandler).getClientSessionId(); listeners.put(id, callbackHandler); } log.debug("added InvokerCallbackHandler: " + listeners); } public Object invoke(final InvocationRequest invocation) throws Throwable { String command = (String) invocation.getParameter(); log.debug("command: " + command); if (COPY.equals(command)) { Object o = invocation.getRequestPayload().get(PAYLOAD); return o; } else if (SPIN.equals(command)) { String s = (String) invocation.getRequestPayload().get(SPIN_TIME); int spinTime = Integer.parseInt(s); SpinThread t = new SpinThread(); t.start(); Thread.sleep(spinTime); t.setStop(); return "done"; } else if (CALLBACK.equals(command)) { String id = invocation.getSessionId(); Map requestPayload = invocation.getRequestPayload(); String s = (String) requestPayload.get(NUMBER_OF_CALLBACKS); int callbacks = Integer.parseInt(s); InvokerCallbackHandler callbackHandler = null; synchronized (lock) { callbackHandler = (InvokerCallbackHandler) listeners.get(id); } if (callbackHandler == null) { log.debug("sessionId: " + id); log.debug("listeners: " + listeners); } Callback callback = new Callback("callback"); for (int i = 0; i < callbacks; i++) { callbackHandler.handleCallback(callback); } } return command; } public void removeListener(InvokerCallbackHandler callbackHandler) { synchronized (lock) { String id = ((ServerInvokerCallbackHandler) callbackHandler).getClientSessionId(); listeners.remove(id); } } public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class SpinThread extends Thread { boolean stop; static int counter; static Object lock = new Object(); public SpinThread() { synchronized (lock) { setName("spinThread:" + counter++); } } public void setStop() { stop = true; log.debug(this + " stop = " + stop); } public void run() { int n = 0; while (!stop) { n++; if ((n + 1) % 10000 == 0) log.debug(this + "stop = " + stop); } log.debug("SpinThread done"); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/0000755000175000017500000000000011632407033030010 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/metadata/0000755000175000017500000000000011632407032031567 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/metadata/MetadataTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/metadata/MetadataT0000644000175000017500000002326211006266121033360 0ustar twernertwerner/* * 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.detection.metadata; import junit.framework.TestCase; import org.apache.log4j.Level; 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.detection.ServerInvokerMetadata; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashSet; import java.util.List; import java.util.Random; /** * Just tests that detector A sees detector B when B comes online then off. * Also checks to make sure the detection message contains the proper data. * * @author Tom Elrod */ public class MetadataTestCase extends TestCase implements NotificationListener { private static int secret = Math.abs(new Random().nextInt(2000)); private HashSet subSystems = new HashSet(); public MetadataTestCase(String name) { super(name); } public void testDetectors() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); MulticastDetector detector1 = new MulticastDetector(); MulticastDetector detector2 = new MulticastDetector(); Connector connector1 = new Connector(); Connector connector2 = new Connector(); try { NetworkRegistry reg1 = setupServers(detector1, connector1); // need to register with the mbean server for notifications List mbeanServers = (List) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return MBeanServerFactory.findMBeanServer(null); } }); MBeanServer mbeanSvr = (MBeanServer) mbeanServers.get(0); mbeanSvr.addNotificationListener(new ObjectName("remoting:type=NetworkRegistry"), this, null, null); NetworkRegistry reg2 = setupServers(detector2, connector2); // Need to allow heartbeat so have detection Thread.currentThread().sleep(2000); //Should now have an entry for both of the registries int reg1Count = reg1.getServers().length; int reg2Count = reg2.getServers().length; System.out.println("registry 1: " + reg1Count); System.out.println("registry 2: " + reg2Count); if(reg1Count >= 1 && reg2Count >= 1) { System.out.println("PASSED - both registries have found detectors."); } else { System.out.println("FAILED - registries not populated with remote detectors."); } // Actual junit test assertTrue(reg1Count >= 1 && reg2Count >= 1); // Verify the Connectors created by this test have been detected. checkForConnector(reg1); checkForConnector(reg2); // now check to make sure got the subsystem as expected assertTrue(subSystems.contains("MOCK")); } finally { // stop the 2nd detector, so see if 1st one detects it is missing if (connector1 != null) { connector1.stop(); connector1.destroy(); connector1 = null; } if (connector2 != null) { connector2.stop(); connector2.destroy(); connector2 = null; } if (detector1 != null) detector1.stop(); if (detector2 != null) detector2.stop(); } //connector2.stop(); //connector2.destroy(); } private synchronized NetworkRegistry setupServers(MulticastDetector detector, Connector connector) { NetworkRegistry registry = null; System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); try { MBeanServer server = MBeanServerFactory.createMBeanServer(); //registry = NetworkRegistry.getInstance(); registry = TestNetworkRegistry.createNetworkRegistry(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); //int port = Math.abs(new Random().nextInt(2000)); int port = TestUtil.getRandomPort(); System.out.println("port = " + port); String host = InetAddress.getLocalHost().getHostAddress(); String bindAddr = System.getProperty("jrunit.bind_addr", host); InvokerLocator locator = new InvokerLocator("socket://" + bindAddr + ":" + port); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append("\n"); buf.append(" " + TestInvocationHandler.class.getName() + "\n"); buf.append("\n"); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(connector, obj); //connector.create(); connector.start(); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); // set config info for detector and start it. detector.start(); } catch(Exception e) { e.printStackTrace(); } return registry; } public void handleNotification(Notification notification, Object o) { System.out.println("Received notification: " + notification); if(notification instanceof NetworkNotification) { NetworkNotification netNot = (NetworkNotification) notification; ServerInvokerMetadata[] serverMetadata = netNot.getServerInvokers(); for (int i = 0; i < serverMetadata.length; i++) { String[] ss = serverMetadata[i].getSubSystems(); for (int j = 0; j < ss.length; j++) { subSystems.add(ss[j]); } } } } private boolean checkForConnector(NetworkRegistry registry) { boolean found = false; NetworkInstance[] servers1 = registry.getServers(); for (int i = 0; i < servers1.length; i++) { InvokerLocator[] locators = servers1[i].getLocators(); for (int j = 0; j < locators.length; j++) { try { Client client = new Client(locators[j]); client.connect(); if (secret == ((Integer) client.invoke("abc")).intValue()) { found = true; System.out.println("FOUND: " + locators[j]); break; } } catch (Throwable t) { continue; } } } return found; } private static class TestNetworkRegistry extends NetworkRegistry { public static NetworkRegistry createNetworkRegistry() { return new TestNetworkRegistry(); } } public static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return new Integer(secret); } 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/detection/registry/0000755000175000017500000000000011632407033031660 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/registry/NetworkRegistryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/registry/NetworkRe0000644000175000017500000002243211006470505033525 0ustar twernertwerner/* * 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.detection.registry; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.ServerInvokerMetadata; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; /** * @author Tom Elrod */ public class NetworkRegistryTestCase extends TestCase implements NotificationListener { private static Logger log = Logger.getLogger(NetworkRegistryTestCase.class); private String subSystem = null; private int numOfAdded = 0; private int numOfUpdated = 0; private InvokerLocator locator1; private InvokerLocator locator2; public void testRegistration() throws Exception { // org.apache.log4j.BasicConfigurator.configure(); // org.apache.log4j.Category.getRoot().setLevel(Level.INFO); // org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.INFO); // org.apache.log4j.Category.getInstance("org.jboss.remoting.detection").setLevel(XLevel.TRACE); // org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); MBeanServer server1 = null; try { server1 = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } NetworkRegistry networkRegistry = new NetworkRegistry(); registerMBean(server1, networkRegistry, new ObjectName("remoting:type=NetworkRegistry")); addNotificationListener(server1, new ObjectName("remoting:type=NetworkRegistry"), this); int port = TestUtil.getRandomPort(); String host = InetAddress.getLocalHost().getHostAddress(); String bindAddr = System.getProperty("jrunit.bind_addr", host); locator1 = new InvokerLocator("socket://" + bindAddr + ":" + port); log.info("InvokerLocator1: " + locator1); Connector connector1 = new Connector(locator1); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator1.getProtocol()); registerMBean(server1, connector1, obj); //connector1.create(); connector1.start(); MulticastDetector detector1 = new MulticastDetector(); registerMBean(server1, detector1, new ObjectName("remoting:type=MulticastDetector")); // set config info for detector and start it. detector1.start(); log.info("First set started."); Thread.sleep(3000); log.info("Starting second set."); MBeanServer server2 = null; try { server2 = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } registerMBean(server2, networkRegistry, new ObjectName("remoting:type=NetworkRegistry")); addNotificationListener(server2, new ObjectName("remoting:type=NetworkRegistry"), this); port = TestUtil.getRandomPort(); locator2 = new InvokerLocator("socket://" + bindAddr + ":" + port); log.info("InvokerLocator2: " + locator2); Connector connector2 = new Connector(locator2); ObjectName obj2 = new ObjectName("jboss.remoting:type=Connector,transport=" + locator2.getProtocol()); registerMBean(server2, connector2, obj2); //connector2.create(); connector2.start(); MulticastDetector detector2 = new MulticastDetector(); registerMBean(server2, detector2, new ObjectName("remoting:type=MultiplexDetector")); // set config info for detector and start it. detector2.start(); log.info("Second set started."); Thread.sleep(5000); // should have detected both new locators assertEquals(2, numOfAdded); log.info("Stopping first set."); connector1.stop(); connector1.destroy(); detector1.stop(); log.info("First set stopped."); //DEBUG // Thread.sleep(6000000); Thread.sleep(15000); // should have detected first set stopped // thus leaving only one valid locator assertEquals(1, numOfUpdated); log.info("Stopping second set."); connector2.stop(); connector2.destroy(); detector2.stop(); log.info("Stopped second set."); Thread.sleep(15000); // number of update locators should remain 1 // as no detector left to tell network registry // of a change. assertEquals(1, numOfUpdated); } public synchronized void handleNotification(Notification notification, Object o) { log.info("Received notification: " + notification); if (notification instanceof NetworkNotification) { int tempAdded = 0; NetworkNotification netNot = (NetworkNotification) notification; if(NetworkNotification.SERVER_ADDED.equals(netNot.getType())) { InvokerLocator[] locators = netNot.getLocator(); for (int i = 0; i < locators.length; i++) { if (locators[i].isSameEndpoint(locator1) || locators[i].isSameEndpoint(locator2)) tempAdded++; } if (tempAdded > 0) { numOfAdded = tempAdded; log.info("server added. num of locators added = " + numOfAdded); } } else if(NetworkNotification.SERVER_UPDATED.equals(netNot.getType())) { int tempUpdated = 0; InvokerLocator[] locators = netNot.getLocator(); for (int i = 0; i < locators.length; i++) { if (locators[i].isSameEndpoint(locator1) || locators[i].isSameEndpoint(locator2)) tempUpdated++; } if (tempUpdated > 0) { numOfUpdated = tempUpdated; log.info("server updated. num of locators in update = " + numOfUpdated); } } ServerInvokerMetadata[] serverMetadata = netNot.getServerInvokers(); log.info(netNot.getIdentity()); log.info(serverMetadata); InvokerLocator[] locators = netNot.getLocator(); if (locators != null) { for (int x = 0; x < locators.length; x++) { log.info(locators[x]); } } subSystem = serverMetadata[0].getSubSystems()[0]; } } private void registerMBean(final MBeanServer server, final Object obj, final ObjectName name) throws Exception { try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { server.registerMBean(obj, name); return null; } }); } catch (PrivilegedActionException e) { log.info(e.getCause()); throw (Exception) e.getCause(); } } private void addNotificationListener(final MBeanServer server, final ObjectName name, final NotificationListener listener) throws Exception { try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { server.addNotificationListener(name, listener, null, null); return null; } }); } catch (PrivilegedActionException e) { log.info(e.getCause()); throw (Exception) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/0000755000175000017500000000000011632407033030734 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectio0000644000175000017500000000627310602152123033363 0ustar twernertwerner/* * 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.detection.jndi; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * In this JNDIDetector test case, the server will * *
    *
  1. start a Connector and a JNDIDetector *
  2. stop the Connector and disable the JNDIDetector, leaving a stale reference to the * Connector in the JNDI server *
  3. start a new Connector and JNDIDetector *
* * The client will get the JNDI bindings after the first Connector has been started, then * get the JNDI bindings shortly after the second Connector has been started. The JNDIConnector * should have done a clean detection when the heartbeat started and registered the new * Connector with the JNDI server. * * See JIRA issue JBREM-730. * * @author Tom Elrod * @author Ron Sigal */ public class CleanDetectionTestCase extends TestDriver { /** * This method should call the addTestClasses() method with the client class to run, number of clients to run * and the server class to run. */ public void declareTestClasses() { addTestClasses(CleanDetectionTestClient.class.getName(), 1, CleanDetectionTestServer.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. * * @return */ protected long getResultsTimeout() { return 300000; } /** * 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 300000; } /** * 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 300000; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestSe0000644000175000017500000002570011171062720033435 0ustar twernertwerner/* * 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.detection.jndi; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; 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.detection.jndi.JNDIDetector; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.util.SecurityUtility; import org.jnp.server.Main; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod * @author John Mazzitelli * @author Ron Sigal */ public class RestartTestServer extends ServerTestCase { public static int syncPort = 6402; protected static Logger log = Logger.getLogger(RestartTestServer.class); protected static String transport; protected static String host; protected static int port = 5402; protected static Thread serverThread; protected int detectorPort = 1099; protected String contextFactory = "org.jnp.interfaces.NamingContextFactory"; protected String urlPackage = "org.jboss.naming:org.jnp.interfaces"; protected Main jserver; protected JNDIDetector detector; protected Connector connector; public void setUp() throws Exception { host = InetAddress.getLocalHost().getHostName(); final String locatorURI = getTransport() + "://" + host + ":" + port; log.info("This server's endpoint will be: " + locatorURI); serverThread = new Thread() { public void run() { try { setupJNDI(); setupDetector(); setupServer(locatorURI); ServerSocket ss = new ServerSocket(syncPort, 0, InetAddress.getLocalHost()); log.info("bound to: " + InetAddress.getLocalHost()); Socket s = ss.accept(); InputStream is = s.getInputStream(); OutputStream os = s.getOutputStream(); // Indicate server is started. os.write(3); log.info("indicated server started"); is.read(); log.info("got request to shut down server"); shutdownServer(locatorURI); log.info("shut down server"); is.read(); log.info("got request to restart server"); setupServer(locatorURI); os.write(7); log.info("restarted server"); is.read(); log.info("got request to shut down server"); shutdownServer(locatorURI); shutdownDetector(); shutdownJNDI(); log.info("shut down server"); } catch (Exception e) { log.error(e); e.printStackTrace(); } } }; serverThread.start(); } protected void setupJNDI() throws Exception { Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); }; String host = InetAddress.getLocalHost().getHostAddress(); jserver = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(jserver, new Object[] {namingBean}); } jserver.setPort(detectorPort); jserver.setBindAddress(host); jserver.setRmiPort(31000); jserver.start(); System.out.println("Started JNDI server on " + host + ":" + port); } protected void shutdownJNDI() { jserver.stop(); } protected void setupDetector() throws Exception { // we need an MBeanServer to store our network registry and multicast detector services MBeanServer server = MBeanServerFactory.createMBeanServer(); String detectorHost = InetAddress.getLocalHost().getHostName(); detector = new JNDIDetector(getConfiguration()); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); detector.start(); log.info("JNDIDetector has been created and is listening for new NetworkRegistries to come online"); } protected void shutdownDetector() throws Exception { detector.stop(); } /** * Sets up our JBoss/Remoting server by creating our Connector on the given locator URI * and installing our invocation handler that will handle incoming messages. * * @param locatorURI defines our server endpoing * @throws Exception */ protected void setupServer(String locatorURI) throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(locator, getConfiguration()); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } protected void shutdownServer(String locatorURI) { connector.stop(); log.info("Stopped remoting server with locator uri of: " + locatorURI); } protected String getTransport() { return "socket"; } /** * @return configuration map for Connector and JNDIDetector */ protected Map getConfiguration() { return new HashMap(); } public static void main(String[] args) { try { RestartTestServer server = new RestartTestServer(); server.setUp(); serverThread.join(); } catch (Exception e) { log.error(e); e.printStackTrace(); } } /** * Simple invocation handler implementation. This is the handler that processes incoming messages from clients. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * This is the method that is called when a new message comes in from a client. * * @param invocation the incoming client invocation, encapsulates the message object * @return the response object we send back to the client. * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request String msg = invocation.getParameter().toString(); log.info("RECEIVED A CLIENT MESSAGE: " + msg); String response = "Server received your message that said [" + msg + "]"; if(msg.indexOf("Welcome") > -1) { response = "Received your welcome message. Thank you!"; } log.info("Returning the following message back to the client: " + response); return response; } /** * Adds a callback handler that will listen for callbacks from the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { // NO OP as we do not handle 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 we do not handle callback listeners in this example } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as we do not need a reference to the MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as we do not need a reference back to the server invoker } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTest2.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorT0000644000175000017500000001344210766634030033233 0ustar twernertwerner/* * 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.detection.jndi; import java.net.InetAddress; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import org.apache.log4j.Level; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; /** * Just tests that detector A sees detector B when B comes online then off. * * @author Tom Elrod */ public class JNDIDetectorTest2 extends ServerTestCase { private int detectorPort = 1099; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; private JNDIDetector detector; private Connector connector; private NetworkRegistry registry; private static final Logger log = Logger.getLogger(JNDIDetectorTest2.class); public void setUp() throws Exception { String detectorHost = InetAddress.getLocalHost().getHostName(); detector = new JNDIDetector(); detector.setCleanDetectionNumber(2); System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); MBeanServer server = MBeanServerFactory.createMBeanServer(); //registry = NetworkRegistry.getInstance(); registry = JNDIDetectorTest2.TestNetworkRegistry.createNetworkRegistry(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); int port = TestUtil.getRandomPort(); System.out.println("port = " + port); String host = InetAddress.getLocalHost().getHostAddress(); String bindAddr = System.getProperty("jrunit.bind_addr", host); InvokerLocator locator = new InvokerLocator("socket://" + bindAddr + ":" + port); System.out.println("Starting remoting server with locator uri of: " + locator.getLocatorURI()); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); MockServerInvocationHandler handler = new MockServerInvocationHandler(); connector.addInvocationHandler("mock", handler); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(connector, obj); //connector.create(); connector.start(); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); detector.start(); } public void testDetector2() throws Exception { Thread.currentThread().sleep(10000); NetworkInstance[] server = registry.getServers(); if(server != null && server.length > 0) { System.out.println("PASS - got more than zero servers detected."); log.info("PASS - got more than zero servers detected."); assertTrue("Detected server.", true); } else { System.out.println("FAIL - did not detect any other server."); log.info("FAIL - did not detect any other server."); assertTrue("Did not detect any servers.", false); } if(connector != null) { connector.stop(); connector.destroy(); connector = null; } if(detector != null) { detector.stop(); detector = null; } } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); connector = null; } if(detector != null) { detector.stop(); detector = null; } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); try { JNDIDetectorTest2 test = new JNDIDetectorTest2(); test.setUp(); test.testDetector2(); test.tearDown(); } catch(Exception e) { e.printStackTrace(); } } private static class TestNetworkRegistry extends NetworkRegistry { public static NetworkRegistry createNetworkRegistry() { return new JNDIDetectorTest2.TestNetworkRegistry(); } } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestCl0000644000175000017500000002311611004005737033423 0ustar twernertwerner/* * 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.detection.jndi; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.util.Map; import java.util.HashMap; import junit.framework.TestCase; /** * @author Tom Elrod * @author John Mazzitelli * @author Ron Sigal */ public class RestartTestClient extends TestCase implements NotificationListener { private static Logger log = Logger.getLogger(RestartTestClient.class); private int detectorPort = 1099; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; protected JNDIDetector detector; protected int serversDetected; protected boolean invocationSucceeded; protected Object lock = new Object(); protected boolean notified; /** * Sets up NetworkRegistry and JNDIDetector so we can listen for any additions * or removals of remoting servers on the network. * * @throws Exception */ public void setUp() throws Exception { // we need an MBeanServer to store our network registry and jndi detector services MBeanServer server = MBeanServerFactory.createMBeanServer(); // the registry will house all remoting servers discovered NetworkRegistry registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); log.info("NetworkRegistry has been created"); // register class as listener, so know when new server found registry.addNotificationListener(this, null, null); log.info("NetworkRegistry has added the client as a listener"); String detectorHost = InetAddress.getLocalHost().getHostName(); // jndi detector will detect new network registries that come online detector = new JNDIDetector(getConfiguration()); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); for (int i = 0; i < 5; i++) { try { detector.start(); log.info("JNDIDetector has been created and is listening for new NetworkRegistries to come online"); break; } catch (Exception e) { log.info("unable to connect to JDNI: will try again"); Thread.sleep(2000); } } } public void tearDown() throws Exception { detector.stop(); } public void testDetections() { try { String host = InetAddress.getLocalHost().getHostName(); Socket s = null; for (int i = 0; i < 5; i++) { try { s = new Socket(host, RestartTestServer.syncPort); break; } catch (Exception e) { log.info("Unable to connect to " + host + ":" + RestartTestServer.syncPort); log.info("Will try again"); try { Thread.sleep(2000); } catch (InterruptedException ignored) {} } } InputStream is = s.getInputStream(); OutputStream os = s.getOutputStream(); // Wait until server has been started. is.read(); waitOnDetection(); assertEquals(1, serversDetected); assertTrue(invocationSucceeded); log.info("PASSED first detection test"); invocationSucceeded = false; // Tell server to shut down. os.write(5); waitOnDetection(); assertEquals(0, serversDetected); log.info("PASSED second detection test"); // Tell server to restart. os.write(7); waitOnDetection(); assertEquals(1, serversDetected); assertTrue(invocationSucceeded); log.info("PASSED third detection test"); // Tell server test is over. os.write(9); } catch (Exception e) { log.error(e); e.printStackTrace(); fail(); } } /** * Callback method from the broadcaster MBean this listener implementation is registered to. When a new server * is detected, a welcome message will immediately be sent to the newly discovered server. * * @param notification the notification object * @param handback the handback object given to the broadcaster upon listener registration */ public void handleNotification(Notification notification, Object handback) { try { // check to see if network notification if(notification instanceof NetworkNotification) { log.info("GOT A NETWORK-REGISTRY NOTIFICATION: " + notification.getType()); NetworkNotification networkNotification = (NetworkNotification) notification; if(NetworkNotification.SERVER_ADDED.equals(networkNotification.getType())) { // notification is for new servers being added log.info("New server(s) have been detected - getting locators and sending welcome messages"); InvokerLocator[] locators = networkNotification.getLocator(); for(int x = 0; x < locators.length; x++) { try { serversDetected++; // get the new found server's locator and invoke a call InvokerLocator newServerLocator = locators[x]; log.info("detected: " + newServerLocator); invocationSucceeded = false; makeInvocation(newServerLocator.getLocatorURI()); invocationSucceeded = true; } catch(Throwable throwable) { throwable.printStackTrace(); } } } else if(NetworkNotification.SERVER_REMOVED.equals(networkNotification.getType())) { // notification is for old servers that have gone down InvokerLocator[] locators = networkNotification.getLocator(); for(int x = 0; x < locators.length; x++) { serversDetected--; log.info("It has been detected that a server has gone down with a locator of: " + locators[x]); } } } return; } finally { notifyDetection(); } } protected void waitOnDetection() throws InterruptedException { synchronized (lock) { try { if (notified) return; lock.wait(); } finally { notified = false; } } } protected void notifyDetection() { synchronized (lock) { notified = true; lock.notify(); } } /** * Make call on remoting server based on locator uri provided. * * @param locatorURI the URI of the remote server we want to send the message to * @throws Throwable */ public void makeInvocation(String locatorURI) throws Throwable { InvokerLocator locator = new InvokerLocator(locatorURI); log.info("Sending welcome message to remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator, getConfiguration()); remotingClient.connect(); Object response = remotingClient.invoke("Welcome Aboard!", null); log.info("The newly discovered server sent this response to our welcome message: " + response); remotingClient.disconnect(); return; } /** * @return configuration map for JNDIDetector */ protected Map getConfiguration() { return new HashMap(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock2/0000755000175000017500000000000011632407032032563 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock2/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock2/Cli0000644000175000017500000000475210433161021033216 0ustar twernertwerner/* * 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.detection.jndi.deadlock2; import junit.framework.TestCase; import org.jboss.remoting.InvokerLocator; import java.io.IOException; import java.net.Socket; /** * @author Tom Elrod */ public class Client extends TestCase { private String locatorUri = "socket://localhost:8765"; // private org.jboss.remoting.Client client = null; // public void setUp() throws Exception // { // client = new org.jboss.remoting.Client(new InvokerLocator(locatorUri)); // client.connect(); // } public void testDeadlock() throws Throwable { org.jboss.remoting.Client client = new org.jboss.remoting.Client(new InvokerLocator(locatorUri)); client.connect(); Object ret = client.invoke("foobar"); System.out.println("first response: " + ret); try { Socket socket = new Socket("localhost", 8765); socket.close(); } catch (IOException e) { e.printStackTrace(); } Object ret2 = client.invoke("barfoo"); System.out.println("second response: " + ret2); client.disconnect(); org.jboss.remoting.Client client2 = new org.jboss.remoting.Client(new InvokerLocator(locatorUri)); client2.connect(); Object ret3 = client2.invoke("foo"); System.out.println("third response: " + ret3); client2.disconnect(); } // public void tearDown() // { // if(client != null) // { // client.disconnect(); // } // } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock2/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock2/Ser0000644000175000017500000000535610433161021033241 0ustar twernertwerner/* * 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.detection.jndi.deadlock2; 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 Server { private String locatorUri = "socket://localhost:8765"; 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) { Server server = new Server(); try { server.setUp(); Thread.sleep(600000); } 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 "rocky"; //TODO: -TME Implement } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/RestartTestCa0000644000175000017500000000544510535452155033425 0ustar twernertwerner/* * 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.detection.jndi; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * This JNDIDetector test case will start two JNDIDetectors in separate instances. * The client will *
    *
  1. detect that the server has started *
  2. detect that the server has shut down *
  3. detect that the server has restarted *
* * @author Tom Elrod * @author Ron Sigal */ public class RestartTestCase extends TestDriver { /** * This method should call the addTestClasses() method with the client class to run, number of clients to run * and the server class to run. */ public void declareTestClasses() { addTestClasses(RestartTestClient.class.getName(), 1, RestartTestServer.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 300000; } /** * 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 300000; } /** * 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 300000; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTest1.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorT0000644000175000017500000002104111171062720033215 0ustar twernertwerner/* * 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.detection.jndi; import java.lang.reflect.Method; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import org.apache.log4j.Level; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.util.SecurityUtility; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jnp.server.Main; import junit.framework.TestCase; /** * Just tests that detector A sees detector B when B comes online then off. * This is a JUnit test, but will need to run JNDIDetectorTest2 at same time * in order to work properly. Can also just run JNDIDetectorTestCase as * test harness to run both JNDIDetectorTest1 and JNDIDetectorTest2 (as regular JUnit test). * See the main for the arguments required (based on DistributedTestCase confines). * * @author Tom Elrod */ public class JNDIDetectorTest1 extends TestCase { private int detectorPort = 1099; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; private JNDIDetector detector; private Connector connector; private NetworkRegistry registry; private static final Logger log = Logger.getLogger(JNDIDetectorTest1.class); public void testDetector() throws Exception { Thread.currentThread().sleep(5000); NetworkInstance[] server = registry.getServers(); if(server != null && server.length > 0) { System.out.println("PASS - more than zero servers detected."); log.info("PASS - more than zero servers detected."); assertTrue("Got detection.", true); } else { System.out.println("FAIL - no servers detected"); log.info("FAIL - no servers detected"); assertTrue("Did not detect servers.", false); } Thread.currentThread().sleep(60000); server = registry.getServers(); if(server == null || server.length == 0) { System.out.println("PASS - no servers detected."); log.info("PASS - no servers detected."); assertTrue("No servers detected.", true); } else { System.out.println("FAIL - all servers should have been removed."); log.info("FAIL - all servers should have been removed."); assertTrue("Found a server, but should have been removed.", false); } } public void setUp() throws Exception { String detectorHost = InetAddress.getLocalHost().getHostName(); detector = new JNDIDetector(); detector.setCleanDetectionNumber(2); System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); MBeanServer server = MBeanServerFactory.createMBeanServer(); //registry = NetworkRegistry.getInstance(); registry = JNDIDetectorTest1.TestNetworkRegistry.createNetworkRegistry(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); int port = TestUtil.getRandomPort(); System.out.println("port = " + port); String host = InetAddress.getLocalHost().getHostAddress(); String bindAddr = System.getProperty("jrunit.bind_addr", host); InvokerLocator locator = new InvokerLocator("socket://" + bindAddr + ":" + port); System.out.println("Starting remoting server with locator uri of: " + locator.getLocatorURI()); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); MockServerInvocationHandler handler = new MockServerInvocationHandler(); connector.addInvocationHandler("mock", handler); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(connector, obj); //connector.create(); connector.start(); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); detector.start(); } public void tearDown() throws Exception { if(detector != null) { detector.stop(); } if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); try { // start JNDI server Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } int port = 1099; //String host = "localhost"; String host = InetAddress.getLocalHost().getHostName(); Main JNDIServer = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = JNDIServer.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean}); } JNDIServer.setPort(port); JNDIServer.setBindAddress(host); JNDIServer.start(); System.out.println("Started JNDI server on " + host + ":" + port); JNDIDetectorTest1 test = new JNDIDetectorTest1(); test.setUp(); test.testDetector(); test.tearDown(); } catch(Exception e) { e.printStackTrace(); } } private static class TestNetworkRegistry extends NetworkRegistry { public static NetworkRegistry createNetworkRegistry() { return new JNDIDetectorTest1.TestNetworkRegistry(); } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/startup/0000755000175000017500000000000011632407032032435 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDIDetectorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDID0000644000175000017500000000301211005534645033211 0ustar twernertwerner/* * 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.detection.jndi.startup; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; import org.jboss.logging.XLevel; /** * @author Tom Elrod */ public class JNDIDetectorTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(JNDIDetectorClient.class.getName(), 1, JNDIDetectorServer.class.getName()); } protected Level getTestLogLevel() { return XLevel.TRACE; } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDIDetectorClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDID0000644000175000017500000000641211006436303033211 0ustar twernertwerner/* * 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.detection.jndi.startup; import junit.framework.TestCase; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkRegistry; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.net.InetAddress; /** * @author Tom Elrod */ public class JNDIDetectorClient extends TestCase { private int detectorPort = 1099; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; private JNDIDetector detector; private NetworkRegistry registry; public void setUp() throws Exception { String detectorHost = InetAddress.getLocalHost().getHostName(); detector = new JNDIDetector(); detector.setCleanDetectionNumber(2); System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); MBeanServer server = MBeanServerFactory.createMBeanServer(); registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); } public void testDetection() throws Exception { detector.start(); Thread.sleep(4000); long start = System.currentTimeMillis(); NetworkInstance[] instances = detector.forceDetection(); long end = System.currentTimeMillis(); System.out.println("instance = " + instances); System.out.println("instances.length: " + instances.length); System.out.println("force detection took " + (end - start) + " milliseconds."); assertEquals(1, instances.length); } public void tearDown() throws Exception { if (detector != null) { detector.stop(); } } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDIDetectorServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/startup/JNDID0000644000175000017500000001460211171063031033206 0ustar twernertwerner/* * 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.detection.jndi.startup; import org.apache.log4j.Level; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.util.SecurityUtility; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jnp.server.Main; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.lang.reflect.Method; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * @author Tom Elrod */ public class JNDIDetectorServer extends ServerTestCase { private int detectorPort = 1099; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; private JNDIDetector detector; private Connector connector; private NetworkRegistry registry; public void setUp() throws Exception { // start JNDI server Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } int port = 1099; String host = InetAddress.getLocalHost().getHostName(); Main JNDIServer = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = JNDIServer.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean}); } JNDIServer.setPort(port); JNDIServer.setBindAddress(host); JNDIServer.start(); System.out.println("Started JNDI server on " + host + ":" + port); String detectorHost = InetAddress.getLocalHost().getHostName(); detector = new JNDIDetector(); detector.setCleanDetectionNumber(2); System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); MBeanServer server = MBeanServerFactory.createMBeanServer(); registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); port = TestUtil.getRandomPort(); System.out.println("port = " + port); String bindAddr = System.getProperty("jrunit.bind_addr", host); InvokerLocator locator = new InvokerLocator("socket://" + bindAddr + ":" + port); System.out.println("Starting remoting server with locator uri of: " + locator.getLocatorURI()); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); MockServerInvocationHandler handler = new MockServerInvocationHandler(); connector.addInvocationHandler("mock", handler); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(connector, obj); //connector.create(); connector.start(); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); detector.start(); Thread.sleep(10000); } public void tearDown() throws Exception { if (detector != null) { detector.stop(); } if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); try { JNDIDetectorServer test = new JNDIDetectorServer(); test.setUp(); } catch (Exception e) { e.printStackTrace(); } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetectorT0000644000175000017500000001233511171062720033223 0ustar twernertwerner/* * 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.detection.jndi; import java.lang.reflect.Method; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.util.SecurityUtility; import org.jnp.server.Main; /** * This should be used as the main test case for JNDI detector. * It will start two JNDIDetectors in seperate instances. The first * will detect the second and then the second will shutdown and the first * will detect that the second is no longer present. This also requires * this class to start an instance of the JNP * * @author Tom Elrod */ public class JNDIDetectorTestCase extends TestDriver { /** * This method should call the addTestClasses() method with the client class to run, number of clients to run * and the server class to run. */ public void declareTestClasses() { try { // start JNDI server Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } int port = 1099; //String host = "localhost"; String host = InetAddress.getLocalHost().getHostName(); Main JNDIServer = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = JNDIServer.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean}); } JNDIServer.setPort(port); JNDIServer.setBindAddress(host); JNDIServer.start(); System.out.println("Started JNDI server on " + host + ":" + port); addTestClasses(JNDIDetectorTest1.class.getName(), 1, JNDIDetectorTest2.class.getName()); } catch(Exception e) { System.out.println("Error starting JNDI server."); e.printStackTrace(); } } 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 300000; } /** * 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 300000; } /** * 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 300000; } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectionTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectio0000644000175000017500000002110711204577737033401 0ustar twernertwerner/* * 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.detection.jndi; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Properties; import javax.naming.Binding; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NameAlreadyBoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.Detection; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.util.SecurityUtility; /** * @author Tom Elrod * @author John Mazzitelli * @author Ron Sigal */ public class CleanDetectionTestClient extends TestCase //implements NotificationListener { private static Logger log = Logger.getLogger(CleanDetectionTestClient.class); private String detectorHost; private int detectorPort = 1099; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; protected JNDIDetector detector; protected int serversDetected; protected boolean invocationSucceeded; protected Object lock = new Object(); protected boolean notified; private Context context; public void testCleanDetect() { try { String host = InetAddress.getLocalHost().getHostName(); Socket s = null; for (int i = 0; i < 5; i++) { try { s = new Socket(host, CleanDetectionTestServer.syncPort); break; } catch (Exception e) { log.info("Unable to connect to " + host + ":" + CleanDetectionTestServer.syncPort); log.info("Will try again"); try { Thread.sleep(2000); } catch (InterruptedException ignored) {} } } InputStream is = s.getInputStream(); OutputStream os = s.getOutputStream(); // Wait until server has been started. is.read(); // Get detection message from JNDI server. createContext(); NamingEnumeration enumeration = listBindings(context, ""); assertTrue(enumeration.hasMore()); Binding binding = (Binding) enumeration.next(); assertFalse(enumeration.hasMore()); log.info(binding); assertTrue(binding.getObject() instanceof Detection); Detection detection = (Detection) binding.getObject(); assertEquals(1, detection.getLocators().length); InvokerLocator locator = detection.getLocators()[0]; log.info("locator: " + locator); // Tell server to shut down. os.write(5); // Tell server to restart. os.write(7); Thread.sleep(4000); // Get new detection message from JNDI server. enumeration = listBindings(context, ""); assertTrue(enumeration.hasMore()); binding = (Binding) enumeration.next(); log.info(binding); assertFalse(enumeration.hasMore()); assertTrue(binding.getObject() instanceof Detection); detection = (Detection) binding.getObject(); assertEquals(1, detection.getLocators().length); InvokerLocator newLocator = detection.getLocators()[0]; log.info("new locator: " + newLocator); // Verify that JNDIDetector has already discovered that old server is dead and // has registered new server. assertFalse(locator.equals(newLocator)); // Tell server test is over. os.write(9); } catch (Exception e) { log.error(e); e.printStackTrace(); fail(); } } private void createContext() throws Exception { detectorHost = InetAddress.getLocalHost().getHostName(); Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory); env.put(Context.PROVIDER_URL, detectorHost + ":" + detectorPort); env.put(Context.URL_PKG_PREFIXES, urlPackage); InitialContext initialContext = createContext(env); String subContextName = JNDIDetector.DETECTION_SUBCONTEXT_NAME; try { context = initialContextLookup(initialContext, subContextName); } catch(NamingException e) { try { context = createSubcontext(initialContext, subContextName); } catch(NameAlreadyBoundException e1) { log.debug("The sub context " + subContextName + " was created before we could."); context = initialContextLookup(initialContext, subContextName); } } } static private Context createSubcontext(final InitialContext initialContext, final String subContextName) throws NamingException { if (SecurityUtility.skipAccessControl()) { return initialContext.createSubcontext(subContextName); } try { return (Context) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NamingException { return initialContext.createSubcontext(subContextName); } }); } catch (PrivilegedActionException e) { throw (NamingException) e.getCause(); } } static private Context initialContextLookup(final InitialContext initialContext, final String subContextName) throws NamingException { if (SecurityUtility.skipAccessControl()) { return (Context) initialContext.lookup(subContextName); } try { return (Context) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NamingException { return initialContext.lookup(subContextName); } }); } catch (PrivilegedActionException e) { throw (NamingException) e.getCause(); } } static private NamingEnumeration listBindings(final Context context, final String bindName) throws NamingException { if (SecurityUtility.skipAccessControl()) { return context.listBindings(bindName); } try { return (NamingEnumeration) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NamingException { return context.listBindings(bindName); } }); } catch (PrivilegedActionException e) { throw (NamingException) e.getCause(); } } static private InitialContext createContext(final Properties env) throws NamingException { if (SecurityUtility.skipAccessControl()) { return new InitialContext(env); } try { return (InitialContext) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new InitialContext(env); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/Client.java0000644000175000017500000002341510463437202033024 0ustar twernertwerner/* * 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.detection.jndi; import junit.framework.TestCase; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.multiplex.Multiplex; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod * @author Michael Voss */ public class Client extends TestCase implements NotificationListener { private static Logger logger; private String localHost = ""; private String localPort; private static NetworkRegistry registry; private MBeanServer server; private ObjectName objConnector = null; private JNDIDetector jdet = null; private Connector initialConnector = null; private Connector connector; private org.jboss.remoting.Client client = null; private String jndiAddress = null; private int jndiPort = 2410; private int detectionCount = 0; private int detectionFailureCount = 0; private void setLocalHost(String host) { jndiAddress = localHost = host; } public void setUp() throws Exception { String host = InetAddress.getLocalHost().getHostAddress(); setLocalHost(host); registry = NetworkRegistry.getInstance(); try { server = MBeanServerFactory.createMBeanServer(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); } catch (Exception e) { e.printStackTrace(); } try { localPort = FindFreePort(); InvokerLocator locator = new InvokerLocator("multiplex://" + localHost + ":" + localPort); //used until a server is found initialConnector = new Connector(locator.getLocatorURI()); try { objConnector = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(initialConnector, objConnector); } catch (Exception e) { e.printStackTrace(); } initialConnector.create(); initialConnector.start(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } jdet = new JNDIDetector(); jdet.setPort(jndiPort); jdet.setHost(jndiAddress); jdet.setContextFactory("org.jnp.interfaces.NamingContextFactory"); jdet.setURLPackage("org.jboss.naming:org.jnp.interfaces"); //jdet.setCleanDetectionNumber(2147483647);//avoids that the server is detected as gone //but it's no use if there are two or more servers try { server.registerMBean(jdet, new ObjectName("remoting:type=Detector,transport=jndi")); } catch (Exception e) { e.printStackTrace(); } try { jdet.start(); registry.addNotificationListener(this, null, null); } catch (Exception ex) { ex.printStackTrace(); System.exit(1); } } public void handleNotification(Notification notification, Object handback) { if (notification instanceof NetworkNotification) { NetworkNotification networkNotification = (NetworkNotification) notification; if (NetworkNotification.SERVER_ADDED.equals(networkNotification.getType())) { // notification is for new servers being added InvokerLocator[] locators = networkNotification.getLocator(); for (int x = 0; x < locators.length; x++) { try { //for this test make sure it's not a client if (networkNotification.getLocator()[x].getPort() == 3001) { System.out.println("-+-Discovered server '" + locators[x].getLocatorURI() + "'-+-"); init(locators[x]); detectionCount++; } } catch (Exception ignored) { } } } else if (NetworkNotification.SERVER_REMOVED.equals(networkNotification.getType())) { // notification InvokerLocator[] locators = networkNotification.getLocator(); for (int x = 0; x < locators.length; x++) { try { //for this test make sure it's not a client if (networkNotification.getLocator()[x].getPort() == 3001) { System.out.println("-!-Server '" + locators[x].getLocatorURI() + "' has gone-!-"); detectionFailureCount++; } } catch (Throwable throwable) { throwable.printStackTrace(); } } } } } public void testDetection() throws InterruptedException { Thread.sleep(60000); assertEquals(1, detectionCount); assertEquals(0, detectionFailureCount); } private static String FindFreePort() { ServerSocket socket = null; try { socket = new ServerSocket(0); return new Integer(socket.getLocalPort()).toString(); } catch (IOException e) { e.printStackTrace(); } finally { if (socket != null) { try { socket.close(); } catch (IOException e) { } } } return null; } private synchronized void init(InvokerLocator locator) { localPort = FindFreePort(); initServer(locator); try { Map configuration = new HashMap(); configuration.put(Multiplex.MULTIPLEX_BIND_HOST, localHost); configuration.put(Multiplex.MULTIPLEX_BIND_PORT, localPort); client = new org.jboss.remoting.Client(locator, "sample", configuration); client.connect(); } catch (Exception e) { e.printStackTrace(); } } private void initServer(InvokerLocator remoteLocator) { //building connector for found server Map configuration = new HashMap(); String addr = remoteLocator.getHost(); String port = new Integer(remoteLocator.getPort()).toString(); configuration.put(Multiplex.MULTIPLEX_CONNECT_HOST, addr); configuration.put(Multiplex.MULTIPLEX_CONNECT_PORT, port); try { connector = new Connector("multiplex://" + localHost + ":" + localPort, configuration); connector.create(); connector.start(); if (initialConnector != null) { // don't need the initial connector any longer initialConnector.stop(); try { server.unregisterMBean(objConnector); } catch (Exception e) { e.printStackTrace(); } initialConnector = null; } } catch (Exception e) { e.printStackTrace(); } } public void tearDown() { try { jdet.stop(); server.unregisterMBean(new ObjectName("remoting:type=Detector,transport=jndi")); registry.removeNotificationListener(this); registry = null; server.unregisterMBean(new ObjectName("remoting:type=NetworkRegistry")); } catch (Exception e) { } try { if (initialConnector != null) { initialConnector.stop(); server.unregisterMBean(objConnector); initialConnector = null; } if (connector != null) { connector.stop(); connector = null; } if (client != null) { client.disconnect(); client = null; } } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { try { Client test = new Client(); logger = Logger.getLogger(test.getClass()); logger.setLevel((Level) Level.DEBUG); test.setUp(); while (true) { Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/0000755000175000017500000000000011632407032032564 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/SSL.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/SSL0000644000175000017500000001117110442364762033163 0ustar twernertwerner/* * 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.detection.jndi.deadlock3; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import java.io.FileInputStream; import java.security.KeyStore; /** * @author Tom Elrod */ public class SSL { public static SSLServerSocketFactory createServerSocketFactory(String keyStorePassword, String trustStorePassword, String keyStorePath, String trustStorePath) throws Exception { // create an SSLContext SSLContext context = null; context = SSLContext.getInstance("TLS"); // define password char[] keyPassphrase = keyStorePassword.toCharArray(); char[] trustPassphrase = trustStorePassword.toCharArray(); // load the server key store KeyStore server_keystore = KeyStore.getInstance("JKS"); server_keystore.load(new FileInputStream(keyStorePath), keyPassphrase); // load the server trust store KeyStore server_truststore = KeyStore.getInstance("JKS"); server_truststore.load(new FileInputStream(trustStorePath), trustPassphrase); // initialize a KeyManagerFactory with the KeyStore KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(server_keystore, keyPassphrase); // KeyManagers from the KeyManagerFactory KeyManager[] keyManagers = kmf.getKeyManagers(); // initialize a TrustManagerFactory with the TrustStore TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(server_truststore); // TrustManagers from the TrustManagerFactory TrustManager[] trustManagers = tmf.getTrustManagers(); // initialize context with Keystore and Truststore information context.init(keyManagers, trustManagers, null); // get ServerSocketFactory from context SSLServerSocketFactory ssf = context.getServerSocketFactory(); return new ClientAuthSocketFactory(ssf); } public static SSLSocketFactory createSocketFactory(String keyStorePassword, String trustStorePassword, String keyStorePath, String trustStorePath) throws Exception { // create an SSLContext SSLContext context = null; context = SSLContext.getInstance("TLS"); // define password char[] keyPassphrase = keyStorePassword.toCharArray(); char[] trustPassphrase = trustStorePassword.toCharArray(); // load the server key store KeyStore server_keystore = KeyStore.getInstance("JKS"); server_keystore.load(new FileInputStream(keyStorePath), keyPassphrase); // load the server trust store KeyStore server_truststore = KeyStore.getInstance("JKS"); server_truststore.load(new FileInputStream(trustStorePath), trustPassphrase); // initialize a KeyManagerFactory with the KeyStore KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(server_keystore, keyPassphrase); // KeyManagers from the KeyManagerFactory KeyManager[] keyManagers = kmf.getKeyManagers(); // initialize a TrustManagerFactory with the TrustStore TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(server_truststore); // TrustManagers from the TrustManagerFactory TrustManager[] trustManagers = tmf.getTrustManagers(); // initialize context with Keystore and Truststore information context.init(keyManagers, trustManagers, null); // get ServerSocketFactory from context return context.getSocketFactory(); } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/ClientAuthSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Cli0000644000175000017500000000565410442364762033242 0ustar twernertwerner/* * 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.detection.jndi.deadlock3; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; /** * @author Tom Elrod */ public class ClientAuthSocketFactory extends SSLServerSocketFactory { SSLServerSocketFactory serverSocketFactory; public ClientAuthSocketFactory(SSLServerSocketFactory serverSocketFactory) { this.serverSocketFactory = serverSocketFactory; } public ServerSocket createServerSocket() throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0, arg1); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0, arg1, arg2); ss.setNeedClientAuth(true); return ss; } public boolean equals(Object obj) { return serverSocketFactory.equals(obj); } public String[] getDefaultCipherSuites() { return serverSocketFactory.getDefaultCipherSuites(); } public String[] getSupportedCipherSuites() { return serverSocketFactory.getSupportedCipherSuites(); } public int hashCode() { return serverSocketFactory.hashCode(); } public String toString() { return serverSocketFactory.toString(); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Cli0000644000175000017500000002731010455077561033235 0ustar twernertwernerpackage org.jboss.test.remoting.detection.jndi.deadlock3; import org.apache.log4j.Level; import org.apache.log4j.Logger; 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.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.multiplex.MultiplexInvokerConstants; import org.jboss.remoting.transport.sslmultiplex.SSLMultiplexServerInvoker; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class Client implements NotificationListener, Runnable { private static Logger logger; private String localHost = ""; private String localPort; private static NetworkRegistry registry; private MBeanServer server; private ObjectName objConnector = null; private JNDIDetector jdet = null; private Connector initialConnector = null; private Connector connector; private org.jboss.remoting.Client client = null; private String jndiAddress = null; private int jndiPort = 2410; private void setLocalHost(String host) { jndiAddress = localHost = host; } private void setUp() { try { Thread s = new Thread(this); Runtime.getRuntime().addShutdownHook(s); } catch (Exception e) { e.printStackTrace(); System.exit(1); } registry = NetworkRegistry.getInstance(); try { server = MBeanServerFactory.createMBeanServer(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); } catch (Exception e) { e.printStackTrace(); } try { localPort = FindFreePort(); InvokerLocator locator = new InvokerLocator("multiplex://" + localHost + ":" + localPort); //used until a server is found initialConnector = new Connector(locator.getLocatorURI()); try { objConnector = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(initialConnector, objConnector); } catch (Exception e) { e.printStackTrace(); } initialConnector.create(); initialConnector.start(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } jdet = new JNDIDetector(); jdet.setPort(jndiPort); jdet.setHost(jndiAddress); jdet.setContextFactory("org.jnp.interfaces.NamingContextFactory"); jdet.setURLPackage("org.jboss.naming:org.jnp.interfaces"); jdet.setCleanDetectionNumber(2147483647);//avoids that the server is detected as gone //but it's no use if there are two or more servers try { server.registerMBean(jdet, new ObjectName("remoting:type=Detector,transport=jndi")); } catch (Exception e) { e.printStackTrace(); } try { jdet.start(); registry.addNotificationListener(this, null, null); } catch (Exception ex) { ex.printStackTrace(); System.exit(1); } //a third person tries to connect to the server try { Socket s = new Socket(localHost, 1001); s.close(); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void handleNotification(Notification notification, Object handback) { if (notification instanceof NetworkNotification) { NetworkNotification networkNotification = (NetworkNotification) notification; if (NetworkNotification.SERVER_ADDED.equals(networkNotification.getType())) { // notification is for new servers being added InvokerLocator[] locators = networkNotification.getLocator(); for (int x = 0; x < locators.length; x++) { try { //for this test make sure it's not a client if (networkNotification.getLocator()[x].getPort() == 1001) { System.out.println("-+-Discovered server '" + locators[x].getLocatorURI() + "'-+-"); init(locators[x]); } } catch (Exception ignored) { } } } else if (NetworkNotification.SERVER_REMOVED.equals(networkNotification.getType())) { // notification InvokerLocator[] locators = networkNotification.getLocator(); for (int x = 0; x < locators.length; x++) { try { //for this test make sure it's not a client if (networkNotification.getLocator()[x].getPort() == 1001) { System.out.println("-!-Server '" + locators[x].getLocatorURI() + "' has gone-!-"); } } catch (Throwable throwable) { throwable.printStackTrace(); } } } } } private static String FindFreePort() { ServerSocket socket = null; try { socket = new ServerSocket(0); return new Integer(socket.getLocalPort()).toString(); } catch (IOException e) { e.printStackTrace(); } finally { if (socket != null) { try { socket.close(); } catch (IOException e) { } } } return null; } private synchronized void init(InvokerLocator locator) { localPort = FindFreePort(); initServer(locator);//Test#1: commented out; Test#2: not commented out try { Map configuration = new HashMap(); configuration.put(MultiplexInvokerConstants.MULTIPLEX_BIND_HOST_KEY, localHost); configuration.put(MultiplexInvokerConstants.MULTIPLEX_BIND_PORT_KEY, localPort); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, "certificate/clientKeyStore"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, "certificate/clientTrustStore"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); client = new org.jboss.remoting.Client(locator, "sample", configuration); client.connect(); //initServer(locator);//Test#1: not commented out; Test#2: commented out InvokerLocator clientLocator = new InvokerLocator("sslmultiplex://" + localHost + ":" + localPort); ClientCallbackHandler handler = new ClientCallbackHandler(); client.addListener(handler, clientLocator); System.out.println("successful"); } catch (Throwable e) { e.printStackTrace(); } } private void initServer(InvokerLocator remoteLocator) { //building connector for found server Map configuration = new HashMap(); String addr = remoteLocator.getHost(); int port = remoteLocator.getPort(); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, "certificate/clientKeyStore"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, "certificate/clientTrustStore"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); try { connector = new Connector("sslmultiplex://" + localHost + ":" + localPort, configuration); connector.create(); try { SSLMultiplexServerInvoker invoker = (SSLMultiplexServerInvoker) connector.getServerInvoker(); ServerSocketFactory svrSocketFactory = SSL.createServerSocketFactory("testpw", "testpw", "certificate/clientKeyStore", "certificate/clientTrustStore"); invoker.setServerSocketFactory(svrSocketFactory); invoker.setClientConnectAddress(addr); invoker.setClientConnectPort(port); } catch (Exception e) { e.printStackTrace(); } connector.start(); if (initialConnector != null) { // don't need the initial connector any longer initialConnector.stop(); try { server.unregisterMBean(objConnector); } catch (Exception e) { e.printStackTrace(); } initialConnector = null; } } catch (Exception e) { e.printStackTrace(); } } public void run() { try { jdet.stop(); server.unregisterMBean(new ObjectName("remoting:type=Detector,transport=jndi")); registry.removeNotificationListener(this); registry = null; server.unregisterMBean(new ObjectName("remoting:type=NetworkRegistry")); } catch (Exception e) { } try { if (initialConnector != null) { initialConnector.stop(); server.unregisterMBean(objConnector); initialConnector = null; } if (connector != null) { connector.stop(); connector = null; } if (client != null) { client.disconnect(); client = null; } } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { try { Client test = new Client(); logger = Logger.getLogger(test.getClass()); logger.setLevel((Level) Level.DEBUG); String host = InetAddress.getLocalHost().getHostAddress(); test.setLocalHost(host); test.setUp(); while (true) { Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } } public static class ClientCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/certificate/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/cer0000755000175000017500000000000011632407032033256 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/certificate/serverTrustStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/cer0000644000175000017500000000067310442364762033300 0ustar twernertwernerþíþí clientcert  áàX.50960‚20‚›D_=E0  *†H†÷ 0`1 0 UDE1 0 Utest1 0 Utest1 0 U test1 0 U test10U Michael Voss0 060508124453Z 060806124453Z0`1 0 UDE1 0 Utest1 0 Utest1 0 U test1 0 U test10U Michael Voss0Ÿ0  *†H†÷ 0‰³`’_é-„‰xYÃÂ_ž/¸‡µ»°WH±ë}?ñl0¢s¤6c{åÞèm£TÕñz‡’ËÙ¨ß=‚Zý™LʆY餛ZËÑþü}Ò¾ä!SÜlu¾ê÷E+uwu.‹©3û¼8 ¦ÞQíæ ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/certificate/server.cerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/cer0000644000175000017500000000106610442364762033275 0ustar twernertwerner0‚20‚›D_=z0  *†H†÷ 0`1 0 UDE1 0 Utest1 0 Utest1 0 U test1 0 U test10U Michael Voss0 060508124546Z 060806124546Z0`1 0 UDE1 0 Utest1 0 Utest1 0 U test1 0 U test10U Michael Voss0Ÿ0  *†H†÷ 0‰§|dC±Ñ ~W®’³·)aðÞ†íq×ûkmÐ[Ÿ2ö•î¢ÆØGM›ö;à—{]pw¼ó½¹Z¹ñ„HÔìãÕnÁ,‰ª´|\yºg#؃Q #ý5]É'Cν^ø¹ÉóÆx¶¿•­=>Íh9«É :í¢G0  *†H†÷ _–½¸±T=&žÔ‹÷t &Kwyüþiƒ¨i4¸Û2KÿÚ¶áãz¬)*?>7ïš)ninAÓA¬3„/.½3‰žÆ¯GÃyü“Ú©Bù5T›2’S,¥íÈÖ!&Ú¹ø˜œÙ®D¦‰%>l…¢¾a\Eðû§rÍS¬y¿././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/certificate/client.cerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/cer0000644000175000017500000000106610442364762033275 0ustar twernertwerner0‚20‚›D_=E0  *†H†÷ 0`1 0 UDE1 0 Utest1 0 Utest1 0 U test1 0 U test10U Michael Voss0 060508124453Z 060806124453Z0`1 0 UDE1 0 Utest1 0 Utest1 0 U test1 0 U test10U Michael Voss0Ÿ0  *†H†÷ 0‰³`’_é-„‰xYÃÂ_ž/¸‡µ»°WH±ë}?ñl0¢s¤6c{åÞèm£TÕñz‡’ËÙ¨ß=‚Zý™LʆY餛ZËÑþü}Ò¾ä!SÜlu¾ê÷E+uwu.‹©3û¼8 ¦ÞQíæ ¤1œÍv‚PþfÝïâUi•|g0  *†H†÷ GÍsºŸ6±¹ Ê¢¶æ„C3ÔýJ$¸Y ´XÌ*@²éœ÷Œñ.~+ˆnán‡çÚGŸ\2ž™"OÊÑc¨ø#èÖê¸;ï:~Ô±w‰€AT‘bÜÏšpurïd9ß·¿BV¢Â‚/EïLZ¥ ¹Ç1©CÌÉ¢÷Öß7././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/certificate/serverKeyStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/cer0000644000175000017500000000113110442364762033266 0ustar twernertwernerþíþímykey , ¼0‚¸0 +*‚¤jª7i†ˆaæbûËk5& ]„O ªÙÈ;ïº l‡8]“}¦`•ôpQ몫3,*Æ8ºÊÎd°Lu 2¨ñþnH³‚ˆKšä9~Æ…Ú>(,AÐÞLBêò|8? ž¼8hã”Ï¥¼4®Z)F ½•¿—zNe·7 ;äIyv¨Ú:±û£¿ø¦‚6thäÇCõ•œX@8"Éý¨Sý'<sè5j­@ .Ö\a5sÈdQ* åQahãâB¹ç—–Io?ã¡¡‹À&½2Ì5/‚fŠ)sÆ£…™z¶ŠýŒ'Ø\å³®0.?ÏœøUrZ»´{†Ç0DJB•Â#›ì¦.Ã~TÓ´6W¶ÂË3•ªÍ“k‡¡ÁPp€ž^€3Øzxd¿DO @¢ÏÙE¶:ÌT¨ÂŠBr\ÆôØÔŠUÚ6hJmÔ“>Œ “PµE®É1Làçf/>¡›@ÕH¾4† ੇ¿Üïxæ¿d‰þ¡(¥u'Pñ›}^¸2fNƃÙùR”JiÈà09ó`Qí‡n±t¾kÂ^}ÐüC\H¦°cDŸŸÔÚä­ŠqzÛãO…ˆœˆZú‹+þ*æÕ¸{/VÍrz#ù¯¯Þ[5 ÜЄ^3Q7OjºIF¥¼ºËÀ²¼[\½ˆ¸|˜Úšƒ]¤›í±w¿†âvDxæÕ7_I'ù(C›ÜÐÖ–'} ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/certificate/clientTrustStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/cer0000644000175000017500000000117110442364762033272 0ustar twernertwernerþíþí servercert  „X.50960‚20‚›D_=z0  *†H†÷ 0`1 0 UDE1 0 Utest1 0 Utest1 0 U test1 0 U test10U Michael Voss0 060508124546Z 060806124546Z0`1 0 UDE1 0 Utest1 0 Utest1 0 U test1 0 U test10U Michael Voss0Ÿ0  *†H†÷ 0‰§|dC±Ñ ~W®’³·)aðÞ†íq×ûkmÐ[Ÿ2ö•î¢ÆØGM›ö;à—{]pw¼ó½¹Z¹ñ„HÔìãÕnÁ,‰ª´|\yºg#؃Q #ý5]É'Cν^ø¹ÉóÆx¶¿•­=>Íh9«É :í¢G0  *†H†÷ _–½¸±T=&žÔ‹÷t &Kwyüþiƒ¨i4¸Û2KÿÚ¶áãz¬)*?>7ïš)ninAÓA¬3„/.½3‰žÆ¯GÃyü“Ú©Bù5T›2’S,¥íÈÖ!&Ú¹ø˜œÙ®D¦‰%>l…¢¾a\Eðû§rÍS¬y¿â–ãQp:‚£>>sŸ:§gïl././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/certificate/clientKeyStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/cer0000644000175000017500000000132210442364762033270 0ustar twernertwernerþíþímykey dT»0‚·0 +*‚£ÇKM\ÓÙYôÞj£Dùб'A.$Ó!+ÁO© Û_*Ìü~¡Ó»76Õ]mÿ‚‘µÖ¶³1è4‡ä;Ð$„K™¾`0õùóKcs¸qºf0HÏŽ[þ/E0(QqB6ÎV &Ÿ÷°iÊþ6íï@,¸ ª4Æx!]é`à)ñµæ¯£á}eÑÞXôCX?ÍÞñô¹Q…Lg‡.Þ–hjP–f’ÄIýkMÅæ×>Û›,°¸´Õ^ùþÖŸÖC”xvæS­ÁÞG臧õïqƒn„s±ÒÇ‹1©~Wgxÿ^Tõú«ç1Éõ!¼ü{óÓBô [·žêºs¯1Ù96‡¹ØÐH<‹Nj¶¼¤ð]בâ}8w ñ3÷;;r¼•‘ø|(æÃEhd3 ”E¯4Ö—Ú6‰ØäŠs€”†jcH&ÔȉF3JDù¤/ì~楉¥¢ŠwÅ21±`žuÅ` ½ÓG_džÒfêcŸ‚:zìì ¯ùN¬QªÌC#Õ€ ,†|KE匬HÏ]j Ä830!H¨‘2õN,Btµž½›©[O–«Lz¶"ë‡ vËr³ ¶d[<ÁF§ît7Où¥{ñ eá(òÖÎ@K\ú%3‹ÛÖ/ŽŽÃ.‹ÍŠð­»’»û4뱩Þ·=aÍ×Á"ø0íKsʂ˕Ë×:Û,û,v:¤S|1<°êÉŽöãtqíþ¨ùcû1ÑÐР­lÕFF³Š•°¼×Œr4bve³˜ˆã6î3îK 2ð+..|¢¶”á}£ï»ˆ4ÍŸ.Â.æ-ñèJ€¡Á¨Öt¢ydˆÕƒDÞFr?ÄÏÒkÍ·F>/2Àš™AOˆa‚ ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock3/Ser0000644000175000017500000002254211171063002033236 0ustar twernertwerner/* * 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.detection.jndi.deadlock3; import org.apache.log4j.Level; import org.apache.log4j.Logger; 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.detection.jndi.JNDIDetector; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.sslmultiplex.SSLMultiplexServerInvoker; import org.jboss.remoting.util.SecurityUtility; import org.jnp.server.Main; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class Server implements Runnable { private static Connector connector = null; private MBeanServer server; private JNDIDetector detector; private Logger logger; private String jndiAddress = null; private int jndiPort = 2410; private String port = "1001"; private void init() { String localHost = ""; try { jndiAddress = localHost = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException uhe) { uhe.printStackTrace(); System.exit(1); } try { Map configuration = new HashMap(); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, "certificate/serverKeyStore"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, "certificate/serverTrustStore"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "false"); connector = new Connector(configuration); InvokerLocator locator = new InvokerLocator("sslmultiplex://" + localHost + ":" + port); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); try { ServerSocketFactory svrSocketFactory = SSL.createServerSocketFactory("testpw", "testpw", "certificate/serverKeyStore", "certificate/serverTrustStore"); SSLMultiplexServerInvoker socketSvrInvoker = (SSLMultiplexServerInvoker) connector.getServerInvoker(); socketSvrInvoker.setServerSocketFactory(svrSocketFactory); } catch (Exception e) { e.printStackTrace(); } /*connector = new Connector(); InvokerLocator locator = new InvokerLocator("multiplex://"+localHost+":"+port); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); */ try { connector.addInvocationHandler("sample", new SampleInvocationHandler()); } catch (Exception e) { e.printStackTrace(); System.exit(1); } connector.start(); server.registerMBean(connector, new ObjectName("jboss.remoting:type=Connector")); } catch (Exception e) { e.printStackTrace(); } } private void registerJNDI() { detector = new JNDIDetector(); try { server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); } catch (Exception ignored) { } detector.setPort(jndiPort); detector.setHost(jndiAddress); try { detector.start(); } catch (Exception e) { e.printStackTrace(); } } private 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); try { Thread t = new Thread(this); Runtime.getRuntime().addShutdownHook(t); } catch (Exception ignored) { } logger = Logger.getLogger(getClass()); logger.setLevel((Level) Level.DEBUG); server = MBeanServerFactory.createMBeanServer(); startJNDIServer(); init(); registerJNDI(); } private void startJNDIServer() throws Exception { Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } String host = InetAddress.getLocalHost().getHostAddress(); Main jserver = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(jserver, new Object[] {namingBean}); } jserver.setPort(2410); jserver.setBindAddress(host); jserver.setRmiPort(31000); jserver.start(); } public void run() { try { server.unregisterMBean(new ObjectName("remoting:type=JNDIDetector")); if (detector != null) { try { detector.stop(); } catch (Exception ignored) { } } if (connector != null) { try { connector.stop(); } catch (Exception ignored) { } connector = null; server.unregisterMBean(new ObjectName("jboss.remoting:type=Connector")); Thread.sleep(1000); } } catch (Exception e) { } } public static void main(String[] args) { Server server = new Server(); try { server.setUp(); while (true) { Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); } } public static class SampleInvocationHandler implements ServerInvocationHandler { public Object invoke(InvocationRequest invocation) throws Throwable { return null; } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/0000755000175000017500000000000011632407033032502 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/SSL.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/SSL.0000644000175000017500000001177110433161021033143 0ustar twernertwerner/* * 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.detection.jndi.deadlock; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import java.io.FileInputStream; import java.security.KeyStore; /** * @author Tom Elrod * @author Michael Voss */ public class SSL { public static SSLServerSocketFactory createServerSocketFactory(String keyStorePassword, String trustStorePassword, String keyStorePath, String trustStorePath) throws Exception { // create an SSLContext SSLContext context = null; context = SSLContext.getInstance("TLS"); // define password char[] keyPassphrase = keyStorePassword.toCharArray(); char[] trustPassphrase = trustStorePassword.toCharArray(); // load the server key store KeyStore server_keystore = KeyStore.getInstance("JKS"); server_keystore.load(new FileInputStream(keyStorePath), keyPassphrase); // load the server trust store KeyStore server_truststore = KeyStore.getInstance("JKS"); server_truststore.load(new FileInputStream(trustStorePath), trustPassphrase); // initialize a KeyManagerFactory with the KeyStore KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(server_keystore, keyPassphrase); // KeyManagers from the KeyManagerFactory KeyManager[] keyManagers = kmf.getKeyManagers(); // initialize a TrustManagerFactory with the TrustStore TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(server_truststore); // TrustManagers from the TrustManagerFactory TrustManager[] trustManagers = tmf.getTrustManagers(); // initialize context with Keystore and Truststore information context.init(keyManagers, trustManagers, null); // get ServerSocketFactory from context SSLServerSocketFactory ssf = context.getServerSocketFactory(); return new ClientAuthSocketFactory(ssf); } public static SSLSocketFactory createSocketFactory(String keyStorePassword, String trustStorePassword, String keyStorePath, String trustStorePath) throws Exception { // create an SSLContext SSLContext context = null; context = SSLContext.getInstance("TLS"); // define password char[] keyPassphrase = keyStorePassword.toCharArray(); char[] trustPassphrase = trustStorePassword.toCharArray(); // load the server key store KeyStore server_keystore = KeyStore.getInstance("JKS"); server_keystore.load(new FileInputStream(keyStorePath), keyPassphrase); // load the server trust store KeyStore server_truststore = KeyStore.getInstance("JKS"); server_truststore.load(new FileInputStream(trustStorePath), trustPassphrase); // initialize a KeyManagerFactory with the KeyStore KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(server_keystore, keyPassphrase); // KeyManagers from the KeyManagerFactory KeyManager[] keyManagers = kmf.getKeyManagers(); // initialize a TrustManagerFactory with the TrustStore TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(server_truststore); // TrustManagers from the TrustManagerFactory TrustManager[] trustManagers = tmf.getTrustManagers(); // initialize context with Keystore and Truststore information context.init(keyManagers, trustManagers, null); // get ServerSocketFactory from context return context.getSocketFactory(); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/ClientAuthSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Clie0000644000175000017500000000570310433161021033276 0ustar twernertwerner/* * 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.detection.jndi.deadlock; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; /** * @author Tom Elrod * @author Michael Voss */ public class ClientAuthSocketFactory extends SSLServerSocketFactory { SSLServerSocketFactory serverSocketFactory; public ClientAuthSocketFactory(SSLServerSocketFactory serverSocketFactory) { this.serverSocketFactory = serverSocketFactory; } public ServerSocket createServerSocket() throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0, arg1); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0, arg1, arg2); ss.setNeedClientAuth(true); return ss; } public boolean equals(Object obj) { return serverSocketFactory.equals(obj); } public String[] getDefaultCipherSuites() { return serverSocketFactory.getDefaultCipherSuites(); } public String[] getSupportedCipherSuites() { return serverSocketFactory.getSupportedCipherSuites(); } public int hashCode() { return serverSocketFactory.hashCode(); } public String toString() { return serverSocketFactory.toString(); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Clie0000644000175000017500000004323110455077561033317 0ustar twernertwerner/* * 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.detection.jndi.deadlock; import org.apache.log4j.Level; import org.apache.log4j.Logger; 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.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.sslmultiplex.SSLMultiplexServerInvoker; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod * @author Michael Voss */ public class Client implements NotificationListener, Runnable { private static Logger logger; private String localHost = ""; private String localPort; private static NetworkRegistry registry; private MBeanServer server; private ObjectName objConnector = null; private JNDIDetector jdet = null; private Connector initialConnector = null; private Connector connector; private org.jboss.remoting.Client client = null; private String jndiAddress = null; private int jndiPort = 2410; private void setLocalHost(String host) { jndiAddress = localHost = host; } private void setUp() { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.OFF); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.OFF); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.OFF); /* 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); */ try { Thread s = new Thread(this); Runtime.getRuntime().addShutdownHook(s); } catch (Exception e) { e.printStackTrace(); System.exit(1); } registry = NetworkRegistry.getInstance(); try { server = MBeanServerFactory.createMBeanServer(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); } catch (Exception e) { e.printStackTrace(); } try { localPort = FindFreePort(); InvokerLocator locator = new InvokerLocator("multiplex://" + localHost + ":" + localPort); //used until a server is found initialConnector = new Connector(locator.getLocatorURI()); try { objConnector = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(initialConnector, objConnector); } catch (Exception e) { e.printStackTrace(); } initialConnector.create(); initialConnector.start(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } jdet = new JNDIDetector(); jdet.setPort(jndiPort); jdet.setHost(jndiAddress); jdet.setContextFactory("org.jnp.interfaces.NamingContextFactory"); jdet.setURLPackage("org.jboss.naming:org.jnp.interfaces"); jdet.setCleanDetectionNumber(2147483647);//avoids that the server is detected as gone //but it's no use if there are two or more servers try { server.registerMBean(jdet, new ObjectName("remoting:type=Detector,transport=jndi")); } catch (Exception e) { e.printStackTrace(); } try { jdet.start(); registry.addNotificationListener(this, null, null); } catch (Exception ex) { ex.printStackTrace(); System.exit(1); } //a third person tries to connect to the server try { Socket s = new Socket(localHost, 1001); s.close(); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public void handleNotification(Notification notification, Object handback) { if (notification instanceof NetworkNotification) { NetworkNotification networkNotification = (NetworkNotification) notification; if (NetworkNotification.SERVER_ADDED.equals(networkNotification.getType())) { // notification is for new servers being added InvokerLocator[] locators = networkNotification.getLocator(); for (int x = 0; x < locators.length; x++) { try { //for this test make sure it's not a client if (networkNotification.getLocator()[x].getPort() == 1001) { System.out.println("-+-Discovered server '" + locators[x].getLocatorURI() + "'-+-"); init(locators[x]); } } catch (Exception ignored) { } } } else if (NetworkNotification.SERVER_REMOVED.equals(networkNotification.getType())) { // notification InvokerLocator[] locators = networkNotification.getLocator(); for (int x = 0; x < locators.length; x++) { try { //for this test make sure it's not a client if (networkNotification.getLocator()[x].getPort() == 1001) { System.out.println("-!-Server '" + locators[x].getLocatorURI() + "' has gone-!-"); } } catch (Throwable throwable) { throwable.printStackTrace(); } } } } } private static String FindFreePort() { ServerSocket socket = null; try { socket = new ServerSocket(0); return new Integer(socket.getLocalPort()).toString(); } catch (IOException e) { e.printStackTrace(); } finally { if (socket != null) { try { socket.close(); } catch (IOException e) { } } } return null; } private synchronized void init(InvokerLocator locator) { localPort = FindFreePort(); InvokerLocator newLocator = initServer(locator);//Test#1: commented out; Test#2: not commented out try { // String clientKeyStorePath = this.getClass().getResource("certificate/clientKeyStore").getFile(); // String clientTrustStorePath = this.getClass().getResource("certificate/clientTrustStore").getFile(); String clientKeyStorePath = this.getClass().getResource("../../../transport/socket/ssl/.keystore").getFile(); String clientTrustStorePath = this.getClass().getResource("../../../transport/socket/ssl/.trustStore").getFile(); Map configuration = new HashMap(); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, clientKeyStorePath); // configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, "certificate/clientKeyStore"); // configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, clientTrustStorePath); // configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, "certificate/clientTrustStore"); // configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); /* configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_FILE_PATH, clientKeyStorePath); // configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_FILE_PATH, "certificate/clientKeyStore"); configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(RemotingSSLSocketFactory.REMOTING_ALGORITHM, "SunX509"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_FILE_PATH, clientTrustStorePath); // configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_FILE_PATH, "certificate/clientTrustStore"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_ALGORITHM, "SunX509"); */ if (client != null) { System.out.println("answer: " + client.invoke("abc")); client.disconnect(); } client = new org.jboss.remoting.Client(locator, "sample", configuration); client.connect(); System.out.println("answer: " + client.invoke("def")); client.disconnect(); client = new org.jboss.remoting.Client(locator, "sample", configuration); client.connect(); System.out.println("answer: " + client.invoke("ghi")); client.disconnect(); client = new org.jboss.remoting.Client(newLocator, "sample", configuration); client.connect(); System.out.println("answer: " + client.invoke("jkl")); //initServer(locator);//Test#1: not commented out; Test#2: commented out InvokerLocator clientLocator = new InvokerLocator("sslmultiplex://" + localHost + ":" + localPort); ClientCallbackHandler handler = new ClientCallbackHandler(); client.addListener(handler, clientLocator); System.out.println("successful"); } catch (Throwable e) { e.printStackTrace(); } } private InvokerLocator initServer(InvokerLocator remoteLocator) { //building connector for found server Map configuration = new HashMap(); String addr = remoteLocator.getHost(); int port = remoteLocator.getPort(); // String clientKeyStorePath = this.getClass().getResource("certificate/clientKeyStore").getFile(); // String clientTrustStorePath = this.getClass().getResource("certificate/clientTrustStore").getFile(); String clientKeyStorePath = this.getClass().getResource("../../../transport/socket/ssl/.keystore").getFile(); String clientTrustStorePath = this.getClass().getResource("../../../transport/socket/ssl/.trustStore").getFile(); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, clientKeyStorePath); // configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, "certificate/clientKeyStore"); // configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // configuration.put(SSLSocketBuilder.REMOTING_KEY_PASSWORD, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, clientTrustStorePath); // configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, "certificate/clientTrustStore"); // configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); /* configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_FILE_PATH, clientKeyStorePath); // configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_FILE_PATH, "certificate/clientKeyStore"); configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(RemotingSSLSocketFactory.REMOTING_ALGORITHM, "SunX509"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_FILE_PATH, clientTrustStorePath); // configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_FILE_PATH, "certificate/clientTrustStore"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_ALGORITHM, "SunX509"); */ InvokerLocator newLocator = null; try { newLocator = new InvokerLocator("sslmultiplex://" + localHost + ":" + localPort); connector = new Connector(newLocator.getLocatorURI(), configuration); connector.create(); try { SSLMultiplexServerInvoker invoker = (SSLMultiplexServerInvoker) connector.getServerInvoker(); // ServerSocketFactory svrSocketFactory = SSL.createServerSocketFactory("testpw", "testpw", "certificate/clientKeyStore", "certificate/clientTrustStore"); ServerSocketFactory svrSocketFactory = SSL.createServerSocketFactory("unit-tests-server", "unit-tests-client", clientKeyStorePath, clientTrustStorePath); invoker.setServerSocketFactory(svrSocketFactory); invoker.setClientConnectAddress(addr); invoker.setClientConnectPort(port); } catch (Exception e) { e.printStackTrace(); } connector.addInvocationHandler("sample", new MockServerInvocationHandler()); connector.start(); if (initialConnector != null) { // don't need the initial connector any longer initialConnector.stop(); try { server.unregisterMBean(objConnector); } catch (Exception e) { e.printStackTrace(); } initialConnector = null; } } catch (Exception e) { e.printStackTrace(); } return newLocator; } public void run() { try { jdet.stop(); server.unregisterMBean(new ObjectName("remoting:type=Detector,transport=jndi")); registry.removeNotificationListener(this); registry = null; server.unregisterMBean(new ObjectName("remoting:type=NetworkRegistry")); } catch (Exception e) { } try { if (initialConnector != null) { initialConnector.stop(); server.unregisterMBean(objConnector); initialConnector = null; } if (connector != null) { connector.stop(); connector = null; } if (client != null) { client.disconnect(); client = null; } } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { try { Client test = new Client(); logger = Logger.getLogger(test.getClass()); logger.setLevel((Level) Level.DEBUG); String host = InetAddress.getLocalHost().getHostAddress(); test.setLocalHost(host); test.setUp(); while (true) { Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); System.exit(1); } } public static class ClientCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { } } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/certificate/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/cert0000755000175000017500000000000011632407032033357 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/certificate/serverTrustStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/cert0000644000175000017500000000121110447712502033360 0ustar twernertwernerþíþí clientcert \AŠX.509F0‚B0‚«DŸ”0  *†H†÷ 0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0 060626080025Z 070626080025Z0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0Ÿ0  *†H†÷ 0‰£Ëœ÷<#îàÅnë I.ã’dUAÔ³áàl=>ù¼¤ípqMé²qJÌ(]2‰ö÷4ÏÁ¶‹ŒZD•ÑN1l­êz(;n±<ÓéÁàY†–t T­ëR¾zm½‹%¡Ìˆä™ƒõ—,õXµÈ²ã„4Ÿ;ÿ›ÐQ­0  *†H†÷ ‘ÁV`f?ÌŸêò¦}ªÞ®W[3Ý?IBL®½ÝÉ™ ]›& Z,ƒ)çjÇjR9CRú‹k»°Åšûâ4ÉN>œ-“t¸*ô”ˆ‡q™7Õ–A×7ë{@âª'Áî¨,x.“C†‘꽎I†+ÞͦÑh[ÆzHÅX$µû¹Ÿ85œ¦ `‘ ÑZ^ððúëÁòL«á././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/certificate/server.cerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/cert0000644000175000017500000000110610447712502033363 0ustar twernertwerner0‚B0‚«DŸ”0  *†H†÷ 0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0 060626080001Z 070626080001Z0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0Ÿ0  *†H†÷ 0‰¨/æÇ݈fEGЂuÆ$eg™"®ªæú Òç›mæ\-ßô‘³Ÿpk¢!ÒÑwù“íZ«À8„Üׯa^ŠR‰ªæ2¹ùë,”WB5¦£Vî6“0›mÌwjÈ$Ýåt8É˧“Ö†¢´»ûŽ—89VnD‡3I”Ü:œ¨†úÇÙ´ >!yõ¡Ó‹O`ÕªœÓàöÔY²Z`Ó(ú  ÇÍIÎF½UÛäÆ~ÄdDN1‡¶NŸÜ·¿JêòAW¤rô˜gZIE˜p8ø fZÂz»åó•É././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/certificate/client.cerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/cert0000644000175000017500000000110610447712502033363 0ustar twernertwerner0‚B0‚«DŸ”0  *†H†÷ 0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0 060626080025Z 070626080025Z0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0Ÿ0  *†H†÷ 0‰£Ëœ÷<#îàÅnë I.ã’dUAÔ³áàl=>ù¼¤ípqMé²qJÌ(]2‰ö÷4ÏÁ¶‹ŒZD•ÑN1l­êz(;n±<ÓéÁàY†–t T­ëR¾zm½‹%¡Ìˆä™ƒõ—,õXµÈ²ã„4Ÿ;ÿ›ÐQ­0  *†H†÷ ‘ÁV`f?ÌŸêò¦}ªÞ®W[3Ý?IBL®½ÝÉ™ ]›& Z,ƒ)çjÇjR9CRú‹k»°Åšûâ4ÉN>œ-“t¸*ô”ˆ‡q™7Õ–A×7ë{@âª'Áî¨,x.“C†‘꽎I†+ÞͦÑh[ÆzHÅX$µû¹Ÿ8././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/certificate/serverKeyStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/cert0000644000175000017500000000250610447712502033370 0ustar twernertwernerþíþímykey Z)`º0‚¶0 +*‚¢ËZHì+Y¡¦fÓ7&‚Žéˆ6¥±lA›ÂÑ÷£Nãq$š¾j:E‚þ{uÚ]F9Ó¦\Q€4F)Tuʦó0‡ÓúË2&:%•yTºe$Ý´óàWOã4|3i ÑÆ¸y)šTAõÈGÌ}lîaÊÆUxïô´¥¾°«mL"jî‰óBöŠs*;ÖÞ7‰GŒjÚ¦wËQ›Põ'‚ñù'û»åJ›qˆÃ]0>||D­òM pŠ_´ÇîÌ}íÚýfüuýãÉ ™:•uÓ×`$&løzgAÁܾ¸yªàhªU`<½F“‰:¼‚aŽ‘=¶™k«ubuš”©Žöß—¼¨« 8½e®/ I3H‡ff¦Ü6–ËŠ$–œpF°Õpy9eÐ8Øya”Ÿ LM;Û6.pd^\OYýü: wT‹®6–7Ü.aW°‡ùÚ]ï"© Éå9Lý—تˆ*sµÌE2^Ñiz²w€¼Æ0¾Ö÷Ç<£‘²ӣ ŠS§.´ï[%\cµË 0 8zrû­!4-Í;0ÔÄí«Æ½qäóÎ}ˆT> èŽfRG¸lù¿ðnæ’ÌíîR¥LÿìZ1e'ÓËçÀœ‰(/jAæpÛhB¡KÚnŽëª0™¿£‚·~[f (“aMØ›O¬È•3½è77Eg­âµNÂâ©ºî¯ø½g¡#ø¾‘+¨‡/Ÿ6ä æŽDÖU6l¤™¦àÒsʨ—*ŸFœûcÒ4 ”ã}Ö™7zxžÖZïpå®WMÁ=… 'Gós°ø”iª9I)˘"÷ø»)Z1=t=upi¡X.509F0‚B0‚«DŸ”0  *†H†÷ 0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0 060626080001Z 070626080001Z0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0Ÿ0  *†H†÷ 0‰¨/æÇ݈fEGЂuÆ$eg™"®ªæú Òç›mæ\-ßô‘³Ÿpk¢!ÒÑwù“íZ«À8„Üׯa^ŠR‰ªæ2¹ùë,”WB5¦£Vî6“0›mÌwjÈ$Ýåt8É˧“Ö†¢´»ûŽ—89VnD‡3I”Ü:œ¨†úÇÙ´ >!yõ¡Ó‹O`ÕªœÓàöÔY²Z`Ó(ú  ÇÍIÎF½UÛäÆ~ÄdDN1‡¶NŸÜ·¿JêòAW¤rô˜gZIE˜p8ø fZÂz»åó•É«ªi”›>í¬–hgy«°EÇ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/certificate/clientTrustStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/cert0000644000175000017500000000121110447712502033360 0ustar twernertwernerþíþí servercert \’UX.509F0‚B0‚«DŸ”0  *†H†÷ 0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0 060626080001Z 070626080001Z0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0Ÿ0  *†H†÷ 0‰¨/æÇ݈fEGЂuÆ$eg™"®ªæú Òç›mæ\-ßô‘³Ÿpk¢!ÒÑwù“íZ«À8„Üׯa^ŠR‰ªæ2¹ùë,”WB5¦£Vî6“0›mÌwjÈ$Ýåt8É˧“Ö†¢´»ûŽ—89VnD‡3I”Ü:œ¨†úÇÙ´ >!yõ¡Ó‹O`ÕªœÓàöÔY²Z`Ó(ú  ÇÍIÎF½UÛäÆ~ÄdDN1‡¶NŸÜ·¿JêòAW¤rô˜gZIE˜p8ø fZÂz»åó•Éïf—ÒSئŽiÍ9mEƒ=Xœ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/certificate/clientKeyStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/cert0000644000175000017500000000250510447712502033367 0ustar twernertwernerþíþímykey Z†¹0‚µ0 +*‚¡T„'Bª¦Ê #ú‚W±è’Ë m86™ôÊû†– àšC_«V$é.ã ô™G"¡»‹}}q ±˜‘ÆRx‘Ô…`n_ÿ˜!ŽˆØ´L\"ëât`µk€‚úa÷Ÿ¤ñx_˜öÖ,ufžVž—È×Ùà8» 2µ-w5˱Oþ¥´nf¨à 5·~Ò8·.f2[ )K摤æ1‰+¥7ïV?Øñ‹Ëmˆ[Rv`ŽÊ:@Ëãìp_ry„Q|í÷«ÒîèøPıRµ­%Ç)è ãb:ùvÒ|¦w¾ÙõNæö—9×B „§ŸÿÉo[´æ0@¼J¤OôEM ï+Ÿ©šRâþéw€³#U"~Aïå÷µ )aŸ¤Æ¤¢;ôámÝO¯ãwºej ¥)IÒ‡<ÿ¤%›<ÊÖX5SÀ“X.509F0‚B0‚«DŸ”0  *†H†÷ 0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0 060626080025Z 070626080025Z0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0Ÿ0  *†H†÷ 0‰£Ëœ÷<#îàÅnë I.ã’dUAÔ³áàl=>ù¼¤ípqMé²qJÌ(]2‰ö÷4ÏÁ¶‹ŒZD•ÑN1l­êz(;n±<ÓéÁàY†–t T­ëR¾zm½‹%¡Ìˆä™ƒõ—,õXµÈ²ã„4Ÿ;ÿ›ÐQ­0  *†H†÷ ‘ÁV`f?ÌŸêò¦}ªÞ®W[3Ý?IBL®½ÝÉ™ ]›& Z,ƒ)çjÇjR9CRú‹k»°Åšûâ4ÉN>œ-“t¸*ô”ˆ‡q™7Õ–A×7ë{@âª'Áî¨,x.“C†‘꽎I†+ÞͦÑh[ÆzHÅX$µû¹Ÿ8bÅͧc ö„h(KÍnƒ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/deadlock/Serv0000644000175000017500000002712511171062752033356 0ustar twernertwerner/* * 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.detection.jndi.deadlock; import org.apache.log4j.Level; import org.apache.log4j.Logger; 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.detection.jndi.JNDIDetector; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.sslmultiplex.SSLMultiplexServerInvoker; import org.jboss.remoting.util.SecurityUtility; import org.jnp.server.Main; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod * @author Michael Voss */ public class Server implements Runnable { private static Connector connector = null; private static Logger logger; private MBeanServer server; private JNDIDetector detector; private String jndiAddress = null; private int jndiPort = 2410; private String port = "1001"; private void init() { String localHost = ""; try { jndiAddress = localHost = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException uhe) { uhe.printStackTrace(); System.exit(1); } try { // String serverKeyStorePath = this.getClass().getResource("certificate/serverKeyStore").getFile(); // String serverTrustStorePath = this.getClass().getResource("certificate/serverTrustStore").getFile(); String serverKeyStorePath = this.getClass().getResource("../../../transport/socket/ssl/.keystore").getFile(); String serverTrustStorePath = this.getClass().getResource("../../../transport/socket/ssl/.trustStore").getFile(); Map configuration = new HashMap(); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, serverKeyStorePath); // configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, "certificate/serverKeyStore"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, serverTrustStorePath); // configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, "certificate/serverTrustStore"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); /* configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_FILE_PATH, serverKeyStorePath); // configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_FILE_PATH, "certificate/serverKeyStore"); configuration.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_PASSWORD, "testpw"); configuration.put(RemotingSSLSocketFactory.REMOTING_ALGORITHM, "SunX509"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_FILE_PATH, serverTrustStorePath); // configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_FILE_PATH, "certificate/serverTrustStore"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_STORE_PASSWORD, "testpw"); configuration.put(RemotingSSLSocketFactory.REMOTING_TRUST_ALGORITHM, "SunX509"); configuration.put(RemotingSSLSocketFactory.REMOTING_USE_CLIENT_MODE, "false"); */ connector = new Connector(configuration); InvokerLocator locator = new InvokerLocator("sslmultiplex://" + localHost + ":" + port); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); try { // ServerSocketFactory svrSocketFactory = SSL.createServerSocketFactory("testpw", "testpw", "certificate/serverKeyStore", "certificate/serverTrustStore"); ServerSocketFactory svrSocketFactory = SSL.createServerSocketFactory("unit-tests-server", "unit-tests-client", serverKeyStorePath, serverTrustStorePath); SSLMultiplexServerInvoker socketSvrInvoker = (SSLMultiplexServerInvoker) connector.getServerInvoker(); socketSvrInvoker.setServerSocketFactory(svrSocketFactory); } catch (Exception e) { e.printStackTrace(); } /*connector = new Connector(); InvokerLocator locator = new InvokerLocator("multiplex://"+localHost+":"+port); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); */ try { connector.addInvocationHandler("sample", new SampleInvocationHandler()); } catch (Exception e) { e.printStackTrace(); System.exit(1); } connector.start(); server.registerMBean(connector, new ObjectName("jboss.remoting:type=Connector")); } catch (Exception e) { e.printStackTrace(); } } private void registerJNDI() { detector = new JNDIDetector(); try { server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); } catch (Exception ignored) { } detector.setPort(jndiPort); detector.setHost(jndiAddress); try { detector.start(); } catch (Exception e) { e.printStackTrace(); } } private 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); try { Thread t = new Thread(this); Runtime.getRuntime().addShutdownHook(t); } catch (Exception ignored) { } logger = Logger.getLogger(getClass()); logger.setLevel((Level) Level.DEBUG); server = MBeanServerFactory.createMBeanServer(); startJNDIServer(); init(); registerJNDI(); } private void startJNDIServer() throws Exception { Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } String host = InetAddress.getLocalHost().getHostAddress(); Main jserver = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(jserver, new Object[] {namingBean}); } jserver.setPort(2410); jserver.setBindAddress(host); jserver.setRmiPort(31000); jserver.start(); } public void run() { try { server.unregisterMBean(new ObjectName("remoting:type=JNDIDetector")); if (detector != null) { try { detector.stop(); } catch (Exception ignored) { } } if (connector != null) { try { connector.stop(); } catch (Exception ignored) { } connector = null; server.unregisterMBean(new ObjectName("jboss.remoting:type=Connector")); Thread.sleep(1000); } } catch (Exception e) { } } public static void main(String[] args) { Server server = new Server(); try { server.setUp(); while (true) { Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); } } public static class SampleInvocationHandler implements ServerInvocationHandler { public Object invoke(InvocationRequest invocation) throws Throwable { System.out.println("invoke(): " + invocation.getParameter()); logger.info("invoke(): " + invocation.getParameter()); return invocation.getParameter(); // return null; } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetector2TestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/JNDIDetector20000644000175000017500000001027011171062720033155 0ustar twernertwernerpackage org.jboss.test.remoting.detection.jndi; import org.jboss.jrunit.harness.TestDriver; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.util.SecurityUtility; import org.jnp.server.Main; import org.apache.log4j.Level; import java.lang.reflect.Method; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * This should be used as the main test case for JNDI detector. * It will start two JNDIDetectors in seperate instances. The first * will detect the second and then the second will shutdown and the first * will detect that the second is no longer present. This also requires * this class to start an instance of the JNP * * @author Tom Elrod */ public class JNDIDetector2TestCase extends TestDriver { /** * This method should call the addTestClasses() method with the client class to run, number of clients to run * and the server class to run. */ public void declareTestClasses() { try { Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } String host = InetAddress.getLocalHost().getHostAddress(); Main jserver = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(jserver, new Object[] {namingBean}); } int port = 2410; jserver.setPort(port); jserver.setBindAddress(host); jserver.setRmiPort(31000); jserver.start(); System.out.println("Started JNDI server on " + host + ":" + port); addTestClasses(Client.class.getName(), 1, Server.class.getName()); } catch(Exception e) { System.out.println("Error starting JNDI server."); e.printStackTrace(); } } 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 300000; } /** * 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 300000; } /** * 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 300000; } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectionTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/CleanDetectio0000644000175000017500000003071611171062720033367 0ustar twernertwerner/* * 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.detection.jndi; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; 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.detection.AbstractDetector; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.util.SecurityUtility; import org.jnp.server.Main; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; import java.util.Timer; /** * @author Tom Elrod * @author John Mazzitelli * @author Ron Sigal */ public class CleanDetectionTestServer extends ServerTestCase { public static int syncPort = 6502; protected static Logger log = Logger.getLogger(CleanDetectionTestServer.class); protected static String transport; protected static int port = 5402; protected static Thread serverThread; protected int detectorPort = 1099; protected String contextFactory = "org.jnp.interfaces.NamingContextFactory"; protected String urlPackage = "org.jboss.naming:org.jnp.interfaces"; protected Main jserver; protected JNDIDetector detector; protected Connector connector; public void setUp() throws Exception { final String host = InetAddress.getLocalHost().getHostName(); serverThread = new Thread() { public void run() { try { setupJNDI(); setupServer(host); setupDetector(); ServerSocket ss = new ServerSocket(syncPort, 0, InetAddress.getLocalHost()); log.info("bound to: " + InetAddress.getLocalHost() + ":" + syncPort); Socket s = ss.accept(); InputStream is = s.getInputStream(); OutputStream os = s.getOutputStream(); // Indicate server is started. os.write(3); log.info("indicated server started"); is.read(); log.info("got request to shut down server"); shutdownServer(); disableDetector(); log.info("shut down server"); is.read(); log.info("got request to restart server"); setupServer(host); setupDetector(); os.write(7); log.info("restarted server"); is.read(); log.info("got request to shut down server"); shutdownServer(); shutdownDetector(); shutdownJNDI(); log.info("shut down server"); } catch (Exception e) { log.error(e); e.printStackTrace(); } } }; serverThread.start(); } protected void setupJNDI() throws Exception { Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); namingBeanImplStart(namingBean, startMethod); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } String host = InetAddress.getLocalHost().getHostAddress(); jserver = new Main(); jserver.setPort(detectorPort); jserver.setBindAddress(host); jserver.setRmiPort(31000); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(jserver, new Object[] {namingBean}); } jserver.start(); System.out.println("Started JNDI server on " + host + ":" + port); } protected void shutdownJNDI() { jserver.stop(); } protected void setupDetector() throws Exception { // we need an MBeanServer to store our network registry and multicast detector services MBeanServer server = MBeanServerFactory.createMBeanServer(); String detectorHost = InetAddress.getLocalHost().getHostName(); detector = new JNDIDetector(getConfiguration()); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); detector.setCleanDetectionNumber(detector.getCleanDetectionNumber() * 2); detector.start(); log.info("JNDIDetector has been created and is listening for new NetworkRegistries to come online"); } protected void shutdownDetector() throws Exception { detector.stop(); } protected void disableDetector() throws Exception { Field field = AbstractDetector.class.getDeclaredField("heartbeatTimer"); field.setAccessible(true); Timer heartbeatTimer = (Timer) field.get(detector); heartbeatTimer.cancel(); } /** * Sets up our JBoss/Remoting server by creating our Connector on the given locator URI * and installing our invocation handler that will handle incoming messages. * * @param locatorURI defines our server endpoing * @throws Exception */ protected void setupServer(String host) throws Exception { int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(locator, getConfiguration()); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } protected void shutdownServer() { String locatorURI = connector.getLocator().getLocatorURI(); connector.stop(); log.info("Stopped remoting server with locator uri of: " + locatorURI); } protected String getTransport() { return "socket"; } /** * @return configuration map for Connector and JNDIDetector */ protected Map getConfiguration() { return new HashMap(); } public static void main(String[] args) { try { CleanDetectionTestServer server = new CleanDetectionTestServer(); server.setUp(); serverThread.join(); } catch (Exception e) { log.error(e); e.printStackTrace(); } } /** * Simple invocation handler implementation. This is the handler that processes incoming messages from clients. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * This is the method that is called when a new message comes in from a client. * * @param invocation the incoming client invocation, encapsulates the message object * @return the response object we send back to the client. * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request String msg = invocation.getParameter().toString(); log.info("RECEIVED A CLIENT MESSAGE: " + msg); String response = "Server received your message that said [" + msg + "]"; if(msg.indexOf("Welcome") > -1) { response = "Received your welcome message. Thank you!"; } log.info("Returning the following message back to the client: " + response); return response; } /** * Adds a callback handler that will listen for callbacks from the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { // NO OP as we do not handle 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 we do not handle callback listeners in this example } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as we do not need a reference to the MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as we do not need a reference back to the server invoker } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } static private void namingBeanImplStart(final Object namingBean, final Method startMethod) throws IllegalAccessException, InvocationTargetException { if (SecurityUtility.skipAccessControl()) { startMethod.invoke(namingBean, new Object[] {}); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IllegalAccessException, InvocationTargetException { startMethod.invoke(namingBean, new Object[] {}); return null; } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof IllegalAccessException) throw (IllegalAccessException) cause; else throw (InvocationTargetException) cause; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/Server.java0000644000175000017500000001216510463437202033054 0ustar twernertwerner/* * 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.detection.jndi; import org.apache.log4j.Level; import org.apache.log4j.Logger; 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.InvokerCallbackHandler; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.net.InetAddress; import java.net.UnknownHostException; /** * @author Tom Elrod * @author Michael Voss */ public class Server extends ServerTestCase { private static Connector connector = null; private MBeanServer server; private JNDIDetector detector; private Logger logger; private String jndiAddress = null; private int jndiPort = 2410; private String port = "3001"; private void init() { String localHost = ""; try { jndiAddress = localHost = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException uhe) { uhe.printStackTrace(); System.exit(1); } try { connector = new Connector(); InvokerLocator locator = new InvokerLocator("multiplex://" + localHost + ":" + port); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); try { connector.addInvocationHandler("sample", new SampleInvocationHandler()); } catch (Exception e) { e.printStackTrace(); System.exit(1); } connector.start(); server.registerMBean(connector, new ObjectName("jboss.remoting:type=Connector")); } catch (Exception e) { e.printStackTrace(); } } private void registerJNDI() { detector = new JNDIDetector(); try { server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); } catch (Exception ignored) { } detector.setPort(jndiPort); detector.setHost(jndiAddress); try { detector.start(); } catch (Exception e) { e.printStackTrace(); } } public void setUp() { logger = Logger.getLogger(getClass()); logger.setLevel((Level) Level.DEBUG); server = MBeanServerFactory.createMBeanServer(); init(); registerJNDI(); } public void tearDown() { try { server.unregisterMBean(new ObjectName("remoting:type=JNDIDetector")); if (detector != null) { try { detector.stop(); } catch (Exception ignored) { } } if (connector != null) { try { connector.stop(); } catch (Exception ignored) { } connector = null; server.unregisterMBean(new ObjectName("jboss.remoting:type=Connector")); Thread.sleep(1000); } } catch (Exception e) { } } public static void main(String[] args) { Server server = new Server(); try { server.setUp(); while (true) { Thread.sleep(1000); } } catch (Exception e) { e.printStackTrace(); } } public static class SampleInvocationHandler implements ServerInvocationHandler { public Object invoke(InvocationRequest invocation) throws Throwable { return null; } public void addListener(InvokerCallbackHandler callbackHandler) { } 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/detection/jndi/ssl/0000755000175000017500000000000011632407032031534 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/SSLRestartTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/SSLRestar0000644000175000017500000000374710513241635033316 0ustar twernertwerner/* * 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.detection.jndi.ssl; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.detection.jndi.RestartTestClient; /** * See SSLRestartTestCase for a description. * * @author Tom Elrod * @author John Mazzitelli * @author Ron Sigal */ public class SSLRestartTestClient extends RestartTestClient { /** * @return configuration map for JNDIDetector */ protected Map getConfiguration() { Map config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource("truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); return config; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/SSLRestartTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/SSLRestar0000644000175000017500000000606110513241635033306 0ustar twernertwerner/* * 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.detection.jndi.ssl; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; 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.detection.jndi.JNDIDetector; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.detection.jndi.RestartTestServer; import org.jnp.server.Main; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.HashMap; import java.util.Map; /** * See SSLRestartTestCase for a description. * * @author Tom Elrod * @author John Mazzitelli * @author Ron Sigal */ public class SSLRestartTestServer extends RestartTestServer { protected String getTransport() { return "sslsocket"; } /** * @return configuration map for Connector and JNDIDetector */ protected Map getConfiguration() { Map 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"); return config; } public static void main(String[] args) { try { SSLRestartTestServer server = new SSLRestartTestServer(); server.setUp(); serverThread.join(); } catch (Exception e) { log.error(e); e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/keystore0000644000175000017500000001376110513241635033336 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/truststor0000644000175000017500000000701310513241635033553 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/SSLRestartTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/jndi/ssl/SSLRestar0000644000175000017500000000526310535452155033316 0ustar twernertwerner/* * 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.detection.jndi.ssl; import org.apache.log4j.Level; import org.jboss.test.remoting.detection.jndi.RestartTestCase; /** * This test runs org.jboss.test.remoting.detection.jndi.RestartTestCase with * an SSL transport. * * @author Tom Elrod * @author Ron Sigal */ public class SSLRestartTestCase extends RestartTestCase { /** * This method should call the addTestClasses() method with the client class to run, number of clients to run * and the server class to run. */ public void declareTestClasses() { addTestClasses(SSLRestartTestClient.class.getName(), 1, SSLRestartTestServer.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 300000; } /** * 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 300000; } /** * 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 300000; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/0000755000175000017500000000000011632407033032015 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/startup/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/startup/0000755000175000017500000000000011632407033033517 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/startup/0000644000175000017500000000262410452264045033530 0ustar twernertwerner/* * 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.detection.multicast.startup; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class MulticastDetectorTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(MulticastDetectorClient.class.getName(), 1, MulticastDetectorServer.class.getName()); } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/startup/0000644000175000017500000001067411004016141033516 0ustar twernertwerner/* * 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.detection.multicast.startup; import java.net.InetAddress; 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.InvokerCallbackHandler; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; /** * @author Tom Elrod */ public class MulticastDetectorServer extends ServerTestCase { private MulticastDetector detector; private Connector connector; private NetworkRegistry registry; public void setUp() throws Exception { detector = new MulticastDetector(); System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); MBeanServer server = MBeanServerFactory.createMBeanServer(); registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); int port = TestUtil.getRandomPort(); System.out.println("port = " + port); String host = InetAddress.getLocalHost().getHostAddress(); String bindAddr = System.getProperty("jrunit.bind_addr", host); InvokerLocator locator = new InvokerLocator("socket://" + bindAddr + ":" + port); System.out.println("Starting remoting server with locator uri of: " + locator.getLocatorURI()); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); TestInvocationHandler handler = new TestInvocationHandler(); connector.addInvocationHandler("mock", handler); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(connector, obj); //connector.create(); connector.start(); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector")); detector.start(); } public void tearDown() throws Exception { if (detector != null) { detector.stop(); } if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); try { MulticastDetectorServer test = new MulticastDetectorServer(); test.setUp(); } catch (Exception e) { e.printStackTrace(); } } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return "MulticastDetectorServer"; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/startup/0000644000175000017500000000706511004016141033516 0ustar twernertwerner/* * 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.detection.multicast.startup; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkRegistry; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; /** * @author Tom Elrod */ public class MulticastDetectorClient extends TestCase { private MulticastDetector detector; private NetworkRegistry registry; public void setUp() throws Exception { detector = new MulticastDetector(); System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); MBeanServer server = MBeanServerFactory.createMBeanServer(); registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); } public void testDetection() throws Exception { detector.start(); long start = System.currentTimeMillis(); NetworkInstance[] instances = detector.forceDetection(); long end = System.currentTimeMillis(); System.out.println("instances"); for (int i = 0; i < instances.length; i++) { System.out.println(" " + instances[i]); } System.out.println("force detection took " + (end - start) + " milliseconds."); boolean foundServer = false; mainLoop: for (int i = 0; i < instances.length; i++) { InvokerLocator[] locators = instances[i].getLocators(); for (int j = 0; j < locators.length; j++) { Client client = new Client(locators[j]); client.connect(); try { if ("MulticastDetectorServer".equals(client.invoke("abc"))) { foundServer = true; break mainLoop; } } catch (Throwable t) { t.printStackTrace(); } finally { client.disconnect(); } } } assertTrue(foundServer); } public void tearDown() throws Exception { if (detector != null) { detector.stop(); } } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/MulticastDetectorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/Multicas0000644000175000017500000000347210774614572033545 0ustar twernertwernerpackage org.jboss.test.remoting.detection.multicast; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import junit.framework.TestCase; import org.jboss.remoting.detection.multicast.MulticastDetector; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; /** * @author Tom Elrod */ public class MulticastDetectorTestCase extends TestCase { private MBeanServer server; private ObjectName objectName; protected void setUp() throws Exception { super.setUp(); try { server = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } objectName = new ObjectName("remoting:type=MulticastDetector"); } protected void tearDown() throws Exception { super.tearDown(); } public void testStopWithoutStart() throws Exception { MulticastDetector detector = new MulticastDetector(); server.registerMBean(detector, objectName); // don't call detector.start(); Thread.sleep(1000); server.unregisterMBean(objectName); detector.stop(); } public void testCallingStopTwice() throws Exception { MulticastDetector detector = new MulticastDetector(); server.registerMBean(detector, objectName); detector.start(); Thread.sleep(1000); server.unregisterMBean(objectName); detector.stop(); detector.stop(); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock0000755000175000017500000000000011632407033033504 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/MulticastDetectorServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock0000644000175000017500000001450111006520633033504 0ustar twernertwernerpackage org.jboss.test.remoting.detection.multicast.deadlock; import org.apache.log4j.Level; import org.jboss.jrunit.extensions.ServerTestCase; 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.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; /** * Test for JBREM-553 * * @author Tom Elrod */ public class MulticastDetectorServer extends ServerTestCase { private MulticastDetector detector; private Connector connector; private NetworkRegistry registry; private Map config = new HashMap(); public void setUp() throws Exception { detector = new MulticastDetector(); System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); MBeanServer server = null; try { server = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); int port = TestUtil.getRandomPort(); System.out.println("port = " + port); String host = InetAddress.getLocalHost().getHostAddress(); String bindAddr = System.getProperty("jrunit.bind_addr", host); InvokerLocator locator = new InvokerLocator("sslsocket://" + bindAddr + ":" + port); System.out.println("Starting remoting server with locator uri of: " + locator.getLocatorURI()); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = this.getClass().getResource("ssl/.truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); String keyStoreFilePath = this.getClass().getResource("ssl/.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_CLIENT_AUTH_MODE, SSLSocketBuilder.CLIENT_AUTH_MODE_WANT); connector = new Connector(config); connector.setInvokerLocator(locator.getLocatorURI()); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(connector, obj); connector.create(); TestHandler handler = new TestHandler(); connector.addInvocationHandler("mock", handler); connector.start(); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector")); detector.start(); } public void tearDown() throws Exception { if (detector != null) { detector.stop(); } if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); try { MulticastDetectorServer test = new MulticastDetectorServer(); test.setUp(); Thread.currentThread().sleep(10000); test.tearDown(); } catch (Exception e) { e.printStackTrace(); } } public class TestHandler 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 { Object obj = invocation.getParameter(); if (obj instanceof String) { String locator = (String) obj; ServerClient client = new ServerClient(locator); Thread t = new Thread(client, "server_client_thread"); //t.setDaemon(false); t.setDaemon(true); t.start(); } return "foobar"; } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } public class ServerClient implements Runnable { private String locatorUrl = null; public ServerClient(String locator) { this.locatorUrl = locator; } public void run() { try { Client remotingClient = null; for (int x = 0; x < 2; x++) { remotingClient = new Client(new InvokerLocator(locatorUrl), config); remotingClient.connect(); Object ret = remotingClient.invoke("bar"); System.out.println("client returned " + ret); Thread.currentThread().sleep(3000); } remotingClient.disconnect(); System.out.println("server client disconnected."); } catch (Exception e) { e.printStackTrace(); } catch (Throwable throwable) { throwable.printStackTrace(); } } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/DeadlockTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock0000644000175000017500000000415710461025574033522 0ustar twernertwerner/* * 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.detection.multicast.deadlock; import junit.framework.TestCase; import org.apache.log4j.Level; /** * Test for JBREM-553 * @author Tom Elrod */ public class DeadlockTestCase extends TestCase { public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); DeadlockTestCase test = new DeadlockTestCase(); try { test.testForDeadlock(); } catch (Exception e) { e.printStackTrace(); } } public void testForDeadlock() throws Exception { MulticastDetectorServer server = new MulticastDetectorServer(); MulticastDetectorClient client = new MulticastDetectorClient(); try { server.setUp(); client.setUp(); client.testDetection(); server.tearDown(); client.disconnect(); Thread.sleep(5000); System.out.println("done testing."); } finally { client.tearDown(); // server.tearDown(); } } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/ssl/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock0000755000175000017500000000000011632407033033504 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/ssl/.truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock0000644000175000017500000000701310460745221033511 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/ssl/.keystorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock0000644000175000017500000001376110460745221033520 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/MulticastDetectorClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/deadlock0000644000175000017500000001401411006520571033504 0ustar twernertwernerpackage org.jboss.test.remoting.detection.multicast.deadlock; 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.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; /** * Test for JBREM-553 * @author Tom Elrod */ public class MulticastDetectorClient extends TestCase { private MulticastDetector detector; private NetworkRegistry registry; private Connector connector; private Client remotingClient = null; public void setUp() throws Exception { detector = new MulticastDetector(); System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); MBeanServer server = MBeanServerFactory.createMBeanServer(); registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); } public void testDetection() throws Exception { detector.start(); long start = System.currentTimeMillis(); NetworkInstance[] instances = detector.forceDetection(); long end = System.currentTimeMillis(); System.out.println("instance = " + instances); System.out.println("force detection took " + (end - start) + " milliseconds."); String host = InetAddress.getLocalHost().getHostAddress(); String bindAddr = System.getProperty("jrunit.bind_addr", host); // assertEquals(1, instances.length); // now create a client InvokerLocator serverLocator = null; for (int i = 0; i < instances.length; i++) { NetworkInstance ni = instances[i]; InvokerLocator[] locator = ni.getLocators(); for (int j = 0; j < locator.length; j++) { if (locator[j].getHost().equals(bindAddr)) { serverLocator = locator[j]; break; } } } System.out.println("client connecting to " + serverLocator); Map config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = this.getClass().getResource("ssl/.truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); String keyStoreFilePath = this.getClass().getResource("ssl/.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_CLIENT_AUTH_MODE, SSLSocketBuilder.CLIENT_AUTH_MODE_WANT); remotingClient = new Client(serverLocator, config); remotingClient.connect(); String invokerLocatorurl = "sslsocket://" + bindAddr + ":8700"; connector = new Connector(invokerLocatorurl, config); connector.create(); connector.addInvocationHandler("test", new LocalHandler()); connector.start(); try { Object ret = remotingClient.invoke(invokerLocatorurl); System.out.println("return from calling server is " + ret); } catch (Throwable throwable) { throwable.printStackTrace(); throw new Exception(throwable.getMessage()); } // Thread.currentThread().sleep(20000); // // System.out.println("Disconnecting."); // // remotingClient.disconnect(); // // System.out.println("Disconnected."); } public void disconnect() throws InterruptedException { Thread.currentThread().sleep(30000); System.out.println("Disconnecting."); remotingClient.disconnect(); System.out.println("Disconnected."); remotingClient = null; } public void tearDown() throws Exception { if (remotingClient != null) { remotingClient.disconnect(); } if (detector != null) { detector.stop(); } if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { MulticastDetectorClient client = new MulticastDetectorClient(); try { client.setUp(); client.testDetection(); client.disconnect(); Thread.sleep(5000); System.out.println("done testing."); } catch(Throwable t) { t.printStackTrace(); } finally { try { client.tearDown(); } catch (Exception e) { e.printStackTrace(); } } } public class LocalHandler 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 "foo"; } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/MulticastUnitTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/detection/multicast/Multicas0000644000175000017500000002550010766635310033533 0ustar twernertwerner/* * 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.detection.multicast; import junit.framework.TestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.net.InetAddress; import java.util.ArrayList; /** * Just tests that detector A sees detector B when B comes online then off. * * @author Tom Elrod */ public class MulticastUnitTestCase extends TestCase { public MulticastUnitTestCase(String name) { super(name); } public void testNotifications() throws Exception { MulticastDetector detector1 = new MulticastDetector(); MulticastDetector detector2 = new MulticastDetector(); Connector connector1 = new Connector(); Connector connector2 = new Connector(); NetworkRegistry reg1 = setupServers(detector1, connector1); TestNotificationListener notif1 = new TestNotificationListener(); reg1.addNotificationListener(notif1, null, null); NetworkRegistry reg2 = setupServers(detector2, connector2); TestNotificationListener notif2 = new TestNotificationListener(); reg2.addNotificationListener(notif2, null, null); // Need to allow heartbeat so have detection Thread.currentThread().sleep(5000); //Should now have an entry for both of the registries int reg1Count = reg1.getServers().length; int reg2Count = reg2.getServers().length; // Actual junit test assertTrue(reg1Count == 1 && reg2Count == 1); if(reg1Count == 1 && reg2Count == 1) { System.out.println("PASSED - both registries have found the detectors."); } else { System.out.println("FAILED - registries not populated with remote detectors."); } assertTrue(((String)notif1.notifLog.get(0)).startsWith("ADDED")); assertTrue(((String)notif1.notifLog.get(1)).startsWith("ADDED")); System.out.println("Notifications from Registry #1--->" + notif1.notifLog); assertTrue(((String)notif2.notifLog.get(0)).startsWith("ADDED")); assertTrue(((String)notif2.notifLog.get(1)).startsWith("ADDED")); System.out.println("Notifications from Registry #2--->" + notif2.notifLog); // stop the 2nd detector, so see if 1st one detects it is missing connector1.stop(); connector1.destroy(); connector1 = null; connector2.stop(); connector2.destroy(); connector2 = null; detector1.stop(); // sleep for a few seconds so the 1st detector can discover 2nd one down Thread.sleep(60000); // 1st one should be empty reg1Count = reg2.getServers().length; // Actual junit test assertTrue(reg1Count == 0); if(reg1Count == 0) { System.out.println("PASSED - 2nd detector stopped and no longer in registry."); } else { System.out.println("FAILED - 2nd detector stopped but still in registry."); } assertTrue(((String)notif2.notifLog.get(0)).startsWith("ADDED")); assertTrue(((String)notif2.notifLog.get(1)).startsWith("ADDED")); assertTrue(((String)notif2.notifLog.get(2)).startsWith("REMOVED")); assertTrue(((String)notif2.notifLog.get(3)).startsWith("REMOVED")); System.out.println("Notifications from Registry #2-->" + notif2.notifLog); // cleanup detector2.stop(); //connector2.stop(); //connector2.destroy(); } public void testDetectors() throws Exception { MulticastDetector detector1 = new MulticastDetector(); MulticastDetector detector2 = new MulticastDetector(); Connector connector1 = new Connector(); Connector connector2 = new Connector(); NetworkRegistry reg1 = setupServers(detector1, connector1); NetworkRegistry reg2 = setupServers(detector2, connector2); // Need to allow heartbeat so have detection Thread.currentThread().sleep(2000); //Should now have an entry for both of the registries int reg1Count = reg1.getServers().length; int reg2Count = reg2.getServers().length; // Actual junit test assertTrue(reg1Count == 1 && reg2Count == 1); if(reg1Count == 1 && reg2Count == 1) { System.out.println("PASSED - both registries have found the detectors."); } else { System.out.println("FAILED - registries not populated with remote detectors."); } // stop the 2nd detector, so see if 1st one detects it is missing connector1.stop(); connector1.destroy(); connector1 = null; connector2.stop(); connector2.destroy(); connector2 = null; detector1.stop(); // sleep for a few seconds so the 1st detector can discover 2nd one down Thread.currentThread().sleep(60000); // 1st one should be empty reg1Count = reg2.getServers().length; // Actual junit test assertTrue(reg1Count == 0); if(reg1Count == 0) { System.out.println("PASSED - 2nd detector stopped and no longer in registry."); } else { System.out.println("FAILED - 2nd detector stopped but still in registry."); } // cleanup detector2.stop(); //connector2.stop(); //connector2.destroy(); } private synchronized NetworkRegistry setupServers(MulticastDetector detector, Connector connector) { NetworkRegistry registry = null; System.setProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); System.out.println("jboss.identity = " + System.getProperty("jboss.identity")); try { MBeanServer server = MBeanServerFactory.createMBeanServer(); //registry = NetworkRegistry.getInstance(); registry = TestNetworkRegistry.createNetworkRegistry(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); //int port = Math.abs(new Random().nextInt(2000)); int port = TestUtil.getRandomPort(); System.out.println("port = " + port); String host = InetAddress.getLocalHost().getHostAddress(); String bindAddr = System.getProperty("jrunit.bind_addr", host); InvokerLocator locator = new InvokerLocator("socket://" + bindAddr + ":" + port); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append("\n"); buf.append(" org.jboss.test.remoting.transport.mock.MockServerInvocationHandler\n"); buf.append("\n"); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); server.registerMBean(connector, obj); //connector.create(); connector.start(); //Need to set new domain for identity server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); // set config info for detector and start it. detector.start(); } catch(Exception e) { e.printStackTrace(); } return registry; } private static class TestNetworkRegistry extends NetworkRegistry { public static NetworkRegistry createNetworkRegistry() { return new TestNetworkRegistry(); } } private static class TestNotificationListener implements NotificationListener { public ArrayList notifLog = new ArrayList(); public void handleNotification( Notification notification, Object o ) { System.out.println("TestNotificationListner.handleNotification() called."); if ( notification instanceof NetworkNotification ) { NetworkNotification networkNotification = (NetworkNotification) notification; if ( NetworkNotification.SERVER_ADDED.equals( networkNotification.getType() ) ) { System.out.println("SERVER_ADDED notification."); for (int i = 0; i < networkNotification.getLocator().length; i++) { System.out.println("ADDED: " + networkNotification.getLocator()[i]); notifLog.add("ADDED: " + networkNotification.getLocator()[i]); } } else if ( NetworkNotification.SERVER_REMOVED.equals( networkNotification.getType() ) ) { System.out.println("SERVER_REMOVED notification."); for (int i = 0; i < networkNotification.getLocator().length; i++) { System.out.println("REMOVED: " + networkNotification.getLocator()[i]); notifLog.add("REMOVED: " + networkNotification.getLocator()[i]); } } else if ( NetworkNotification.SERVER_UPDATED.equals( networkNotification.getType() ) ) { System.out.println("SERVER_UPDATED notification."); for (int i = 0; i < networkNotification.getLocator().length; i++) { System.out.println("UPDATED: " + networkNotification.getLocator()[i]); notifLog.add("UPDATED: " + networkNotification.getLocator()[i]); } } } } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/0000755000175000017500000000000011632407034027521 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/QuickDisconnectClientParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/QuickDisconnectClien0000644000175000017500000007630010714274431033516 0ustar twernertwerner/* * 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.timeout; 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.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; 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.BidirectionalClientInvoker; import org.jboss.remoting.transport.ClientInvoker; /** * QuickDisconnectTestParent verifies that LeasePinger can set its * own short timeout value when it is called during Client.disconnect(), so that, * even if the server is unavailable, Client.disconnect() can finish quickly. * * It also tests that Client can set its own short timeout value when in * removeListener(). * * @author Ron Sigal * @version $Revision: 2922 $ *

* Copyright Jan 24, 2007 *

*/ public abstract class QuickDisconnectClientParent extends TestCase { protected static Logger log = Logger.getLogger(QuickDisconnectClientParent.class); protected boolean receivedConnectionException; protected int port; public void setUp() throws Exception { System.out.println("*******************************************************"); System.out.println("***** EXCEPTIONS ARE EXPECTED *****"); System.out.println("*******************************************************"); log.info("entering setUp() for " + getName()); Client client = null; // Ask server to create a Connector. try { String host = InetAddress.getLocalHost().getHostAddress(); int mainPort = QuickDisconnectServerParent.port; String locatorURI = getTransport() + "://" + host + ":" + mainPort; InvokerLocator locator = new InvokerLocator(locatorURI); client = new Client(locator); client.connect(); Object response = client.invoke(QuickDisconnectServerParent.START_SERVER); port = ((Integer) response).intValue(); Thread.sleep(1000); log.info("leaving setUp() for " + getName()); } catch (Throwable e) { e.printStackTrace(); } } /** * This test starts a server, connects a client to it, disables the server, * and sets the client's disconnectTimeout to 0. The client should be * able to terminate the lease and disconnect quickly even though it cannot * complete an invocation on the server. */ public void testQuickDisconnectZeroTimeout() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "60000"); config.put(Client.ENABLE_LEASE, "true"); addClientConfig(config); final Client client = new Client(locator, config); try { client.connect(); } catch (Exception e) { e.printStackTrace(); } log.info("making first invocation"); Object response = client.invoke("test"); assertEquals("test", response); log.info("first invocation succeeds"); new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(15000); try { // This invocation may use up a listening connection, // depending on transport. HashMap metadata = new HashMap(); metadata.put("timeout", shortTimeoutString()); log.info("making invocation"); client.invoke("test", metadata); log.info("made invocation"); } catch (Exception e) { log.info("client.invoke(\"test\") failed (that's OK)"); } // Set disconnectTimeout to 0. log.info("calling client.disconnect()"); client.setDisconnectTimeout(0); client.disconnect(); log.info("returned from client.disconnect()"); } catch (Throwable e) { log.info("error in client.disconnect()", e); } } }.start(); // It should take the Client a little while for LeasePinger's attempts to contact // the server to time out. Wait for about 4 seconds after the call to // Client.disconnect() and then verify that the Client has successfully // disconnected even though the server is disabled. Thread.sleep(21000); assertFalse(client.isConnected()); log.info(getName() + " PASSES"); } /** * This test starts a server, connects a client to it, disables the server, * and sets the client's disconnectTimeout to 1 second. The client should be * able to terminate the lease and disconnect quickly even though it cannot * complete an invocation on the server. */ public void testQuickDisconnect() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "60000"); config.put(Client.ENABLE_LEASE, "true"); addClientConfig(config); final Client client = new Client(locator, config); try { client.connect(); } catch (Exception e) { e.printStackTrace(); } log.info("making first invocation"); Object response = client.invoke("test"); assertEquals("test", response); log.info("first invocation succeeds"); new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(15000); try { // This invocation may use up a listening connection, // depending on transport. HashMap metadata = new HashMap(); metadata.put("timeout", shortTimeoutString()); log.info("making invocation"); client.invoke("test", metadata); log.info("made invocation"); } catch (Exception e) { log.info("client.invoke(\"test\") failed (that's OK)"); } // Set disconnectTimeout to 1 second. log.info("calling client.disconnect()"); client.setDisconnectTimeout(shortTimeout()); client.disconnect(); log.info("returned from client.disconnect()"); } catch (Throwable e) { log.info("error in client.disconnect()", e); } } }.start(); // It should take the Client a little while for LeasePinger's attempts to contact // the server to time out. Wait for about 4 seconds after the call to // Client.disconnect() and then verify that the Client has successfully // disconnected even though the server is disabled. Thread.sleep(21000); assertFalse(client.isConnected()); log.info(getName() + " PASSES"); } /** * This test is identical to testQuickDisconnectTimeout() except that the * disconnectTimeout value is not set on the client. Therefore, the client * will not be able to disconnect as quickly as it does in * testQuickDisconnectTimeout(). * * This test fails in linux - apparently the connection gets feedback from a * failed i/o operation more quickly, and the call to Client.disconnect() is * able to conclude. * * Therefore, the test has been disabled. That's OK, since it doesn't verify * any functionality. It was intended only to verify the design of * testQuickDisconnect(), and it passes in Windows. */ public void xtestSlowDisconnect() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "60000"); config.put(Client.ENABLE_LEASE, "true"); addClientConfig(config); final Client client = new Client(locator, config); try { client.connect(); } catch (Exception e) { e.printStackTrace(); } log.info("making first invocation"); Object response = client.invoke("test"); assertEquals("test", response); log.info("first invocation succeeds"); Thread t = new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(15000); try { // This invocation may use up a listening connection, // depending on transport. HashMap metadata = new HashMap(); metadata.put("timeout", shortTimeoutString()); log.info("making invocation"); client.invoke("test", metadata); log.info("made invocation"); } catch (Exception e) { log.info("client.invoke(\"test\") failed (that's OK)"); } log.info("calling client.disconnect()"); client.disconnect(); log.info("returned from client.disconnect()"); } catch (Throwable e) { log.info("error in client.disconnect()", e); } } }; t.setDaemon(true); t.start(); // Since no disconnectTimeout has been specified, timeout value specified // when the Client was created, 60 seconds, will apply. The client should // not be disconnected after rougly 8 seconds. Thread.sleep(20000); assertTrue(client.isConnected()); log.info(getName() + " PASSES"); } /** * This test starts a server, connects a client to it, disables the server, * and sets the client's disconnectTimeout to 0. The client should be * able to remove the callback handler quickly even though it cannot * complete an invocation on the server. * * Push callbacks are used. */ public void testQuickRemovePushListenerZeroTimeout() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "60000"); config.put(Client.ENABLE_LEASE, "true"); addClientConfig(config); final Client client = new Client(locator, config); try { client.connect(); } catch (Exception e) { e.printStackTrace(); } log.info("making first invocation"); Object response = client.invoke("test"); assertEquals("test", response); log.info("first invocation succeeds"); final InvokerCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); final Holder removeListener = new Holder(); new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(15000); try { // This invocation may use up a listening connection, // depending on transport. HashMap metadata = new HashMap(); metadata.put("timeout", shortTimeoutString()); log.info("making invocation"); client.invoke("test", metadata); log.info("made invocation"); } catch (Exception e) { log.info("client.invoke(\"test\") failed (that's OK)"); } // Set disconnectTimeout to 0. client.setDisconnectTimeout(0); client.removeListener(callbackHandler); removeListener.done = true; log.info("returned from client.removeListener()"); } catch (Throwable e) { log.info("error in client.removeListener()", e); } } }.start(); // Verify that a callback Connector has been created. Field field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectors = (Map) field.get(client); assertEquals(1, callbackConnectors.size()); // Wait for about 4 seconds after the call to Client.removeListener() and then // verify that the Client has successfully removed the callback handler even // though the server is disabled. Thread.sleep(21000); assertEquals(0, callbackConnectors.size()); // Verify that attempt to remove callback handler on server has timed out and // client was able to complete call to removeListener(). assertTrue(removeListener.done); log.info(getName() + " PASSES"); } /** * This test starts a server, connects a client to it, disables the server, * and sets the client's disconnectTimeout to 0. The client should be * able to remove the callback handler quickly even though it cannot * complete an invocation on the server. * * If the transport is not bidirectional, pull callbacks are used. */ public void testQuickRemovePullListenerZeroTimeout() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "60000"); config.put(Client.ENABLE_LEASE, "true"); addClientConfig(config); final Client client = new Client(locator, config); try { client.connect(); } catch (Exception e) { e.printStackTrace(); } // Client won't set up pull callbacks for bidirectional transport. ClientInvoker invoker = client.getInvoker(); if (invoker instanceof BidirectionalClientInvoker) { log.info(getTransport() + " is bidirectional"); log.info(getName() + " PASSES"); return; } log.info("making first invocation"); Object response = client.invoke("test"); assertEquals("test", response); log.info("first invocation succeeds"); final InvokerCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, false); final Holder removeListener = new Holder(); new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(15000); try { // This invocation may use up a listening connection, // depending on transport. HashMap metadata = new HashMap(); metadata.put("timeout", shortTimeoutString()); log.info("making invocation"); client.invoke("test", metadata); log.info("made invocation"); } catch (Exception e) { log.info("client.invoke(\"test\") failed (that's OK)"); } // Set disconnectTimeout to 0. client.setDisconnectTimeout(0); client.removeListener(callbackHandler); removeListener.done = true; log.info("returned from client.removeListener()"); } catch (Throwable e) { log.info("error in client.removeListener()", e); } } }.start(); // Verify that a callback Connector has been created. Field field = Client.class.getDeclaredField("callbackPollers"); field.setAccessible(true); Map callbackPollers = (Map) field.get(client); assertEquals(1, callbackPollers.size()); // Wait for about 4 seconds after the call to Client.removeListener() and then // verify that the Client has successfully removed the callback handler even // though the server is disabled. Thread.sleep(21000); assertEquals(0, callbackPollers.size()); // Verify that attempt to remove callback handler on server has timed out and // client was able to complete call to removeListener(). assertTrue(removeListener.done); log.info(getName() + " PASSES"); } /** * This test starts a server, connects a client to it, disables the server, * and sets the client's disconnectTimeout to 1 second. The client should be * able to remove the callback handler quickly even though it cannot * complete an invocation on the server. * * Push callbacks are used. */ public void testQuickRemovePushListener() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "60000"); config.put(Client.ENABLE_LEASE, "true"); addClientConfig(config); final Client client = new Client(locator, config); try { client.connect(); } catch (Exception e) { e.printStackTrace(); } log.info("making first invocation"); Object response = client.invoke("test"); assertEquals("test", response); log.info("first invocation succeeds"); final InvokerCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); final Holder removeListener = new Holder(); new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(15000); try { // This invocation may use up a listening connection, // depending on transport. HashMap metadata = new HashMap(); metadata.put("timeout", shortTimeoutString()); log.info("making invocation"); client.invoke("test", metadata); log.info("made invocation"); } catch (Exception e) { log.info("client.invoke(\"test\") failed (that's OK)"); } // Set disconnectTimeout to 1 second. client.setDisconnectTimeout(shortTimeout()); log.info("calling client.removeListener()"); client.removeListener(callbackHandler); removeListener.done = true; log.info("returned from client.removeListener()"); } catch (Throwable e) { log.info("error in client.removeListener()", e); } } }.start(); // Verify that a callback Connector has been created. Field field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectors = (Map) field.get(client); assertEquals(1, callbackConnectors.size()); // Wait for about 4 seconds after the call to Client.removeListener() and then // verify that the Client has successfully removed the callback handler even // though the server is disabled. Thread.sleep(21000); assertEquals(0, callbackConnectors.size()); // Verify that attempt to remove callback handler on server has timed out and // client was able to complete call to removeListener(). assertTrue(removeListener.done); log.info(getName() + " PASSES"); } /** * This test starts a server, connects a client to it, disables the server, * and sets the client's disconnectTimeout to 1 second. The client should be * able to remove the callback handler quickly even though it cannot * complete an invocation on the server. * * If the transport is not bidirectional, pull callbacks are used. */ public void testQuickRemovePullListener() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "60000"); config.put(Client.ENABLE_LEASE, "true"); addClientConfig(config); final Client client = new Client(locator, config); try { client.connect(); } catch (Exception e) { e.printStackTrace(); } // Client won't set up pull callbacks for bidirectional transport. ClientInvoker invoker = client.getInvoker(); if (invoker instanceof BidirectionalClientInvoker) { log.info(getTransport() + " is bidirectional"); log.info(getName() + " PASSES"); return; } log.info("making first invocation"); Object response = client.invoke("test"); assertEquals("test", response); log.info("first invocation succeeds"); final InvokerCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, false); final Holder removeListener = new Holder(); new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(15000); try { // This invocation may use up a listening connection, // depending on transport. HashMap metadata = new HashMap(); metadata.put("timeout", shortTimeoutString()); log.info("making invocation"); client.invoke("test", metadata); log.info("made invocation"); } catch (Exception e) { log.info("client.invoke(\"test\") failed (that's OK)"); } // Set disconnectTimeout to 1 second. client.setDisconnectTimeout(shortTimeout()); log.info("calling client.removeListener()"); client.removeListener(callbackHandler); removeListener.done = true; log.info("returned from client.removeListener()"); } catch (Throwable e) { log.info("error in client.removeListener()", e); } } }.start(); // Verify that a CallbackPoller has been created. Field field = Client.class.getDeclaredField("callbackPollers"); field.setAccessible(true); Map callbackPollers = (Map) field.get(client); assertEquals(1, callbackPollers.size()); // Wait for about 4 seconds after the call to Client.removeListener() and then // verify that the Client has successfully removed the callback handler even // though the server is disabled. Thread.sleep(21000); assertEquals(0, callbackPollers.size()); // Verify that attempt to remove callback handler on server has timed out and // client was able to complete call to removeListener(). assertTrue(removeListener.done); log.info(getName() + " PASSES"); } /** * This test is identical to testQuickRemoveListener() except that the * disconnectTimeout value is not set on the client. Therefore, the client * will not be able to remove the callback handler as quickly as it does in * testQuickRemoveListener(). * * This test fails in linux - apparently the connection gets feedback from a * failed i/o operation more quickly, and the call to Client.removeListener() * is able to conclude. * * Therefore, the test has been disabled. That's OK, since it doesn't verify * any functionality. It was intended only to verify the design of * testQuickRemoveListener(), and it passes in Windows. */ public void xtestSlowRemoveListener() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "60000"); config.put(Client.ENABLE_LEASE, "true"); addClientConfig(config); final Client client = new Client(locator, config); try { client.connect(); } catch (Exception e) { e.printStackTrace(); } log.info("making first invocation"); Object response = client.invoke("test"); assertEquals("test", response); final InvokerCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); final Holder removeListener = new Holder(); new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(15000); try { // This invocation may use up a listening connection, // depending on transport. log.info("making invocation"); client.invoke("test"); log.info("made invocation"); } catch (Exception e) { log.info("client.invoke(\"test\") failed (that's OK)"); } log.info("calling client.removeListener()"); client.removeListener(callbackHandler); removeListener.done = true; log.info("returned from client.removeListener()"); } catch (Throwable e) { log.info("error in client.removeListener()", e); } } }.start(); // Verify that a callback Connector has been created. Field field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectors = (Map) field.get(client); assertEquals(1, callbackConnectors.size()); // Wait for about 4 seconds after the call to Client.removeListener() and then // verify that the Client has not been able to complete the call to removeListener(). Thread.sleep(21000); assertEquals(1, callbackConnectors.size()); // Verify that attempt to remove callback handler from server has not timed out // and client was not able to shut down callback Connector. assertFalse(removeListener.done); log.info(getName() + " PASSES"); } public void handleConnectionException(Throwable throwable, Client client) { receivedConnectionException = true; } protected abstract String getTransport(); protected void addClientConfig(Map config) { } protected int shortTimeout() { return 1000; } protected String shortTimeoutString() { return "1000"; } public class Holder {public boolean done;} public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } public class TestListener implements ConnectionListener { public boolean notified; public void handleConnectionException(Throwable throwable, Client client) { notified = true; } } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/SSLPerInvocationTimeoutTestRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/SSLPerInvocationTime0000644000175000017500000000417210567444714033445 0ustar twernertwerner/* * 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.timeout; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; /** * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 2209 $ *

* Copyright Jan 24, 2007 *

*/ public abstract class SSLPerInvocationTimeoutTestRoot extends PerInvocationTimeoutTestRoot { protected void addServerConfig(Map config) { 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"); } protected void addClientConfig(Map config) { config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/QuickDisconnectServerParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/QuickDisconnectServe0000644000175000017500000001255310714274431033550 0ustar twernertwerner/* * 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.timeout; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.jrunit.extensions.ServerTestCase; 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.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * QuickDisconnectTestParent verifies that LeasePinger can set its * own short timeout value when it is called during Client.disconnect(), so that, * even if the server is unavailable, Client.disconnect() can finish quickly. * * It also tests that Client can set its own short timeout value when in * removeListener(). * * @author Ron Sigal * @version $Revision: 2922 $ *

* Copyright Jan 24, 2007 *

*/ public abstract class QuickDisconnectServerParent extends ServerTestCase { public static final String START_SERVER = "startServer"; public static final int port = 3999; protected static Logger log = Logger.getLogger(QuickDisconnectServerParent.class); protected static boolean firstTime = true; protected Connector connector; protected boolean receivedConnectionException; public void setUp() throws Exception { String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); addServerConfig(serverConfig); connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.addConnectionListener(new TestListener()); connector.start(); } public void tearDown() { connector.stop(); } protected abstract String getTransport(); protected void addServerConfig(Map config) { } public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { if (START_SERVER.equals(invocation.getParameter())) { int port = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName()); new ServerStarter(port).start(); return new Integer(port); } else { return invocation.getParameter(); } } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } public class TestListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { log.info("received connection exception"); } } public class ServerStarter extends Thread { int port; public ServerStarter(int port) { this.port = port; } public void run() { try { String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); addServerConfig(serverConfig); final Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.addConnectionListener(new TestListener()); connector.start(); log.info("Connector started: " + connector.getInvokerLocator()); Thread.sleep(10000); connector.stop(); log.info("Connector stopped: " + connector.getInvokerLocator()); } catch (Exception e) { } } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/PerInvocationTimeoutTestRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/timeout/PerInvocationTimeout0000644000175000017500000001661110572210664033603 0ustar twernertwerner/* * 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.timeout; import java.net.InetAddress; import java.net.SocketTimeoutException; 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; /** * PerInvocationTimeoutTestRoot is the abstract parent of a set of per-transport * unit tests that verify the correctness of the facility for setting the socket * timeout value with each invocation. * * See JIRA issue JBREM-598: http://jira.jboss.com/jira/browse/JBREM-598 * * @author Ron Sigal * @version $Revision: 2255 $ *

* Copyright Jan 24, 2007 *

*/ public abstract class PerInvocationTimeoutTestRoot extends TestCase { protected static final String NO_WAIT = "nowait"; protected static final String SHORT_WAIT = "shortwait"; protected static final String LONG_WAIT = "longwait"; protected static final String CONFIGURED_TIMEOUT_STRING = "8000"; protected static final int CONFIGURED_TIMEOUT = 8000; protected static Logger log = Logger.getLogger(PerInvocationTimeoutTestRoot.class); protected static boolean firstTime = true; protected Connector connector; protected Client 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 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"); clientConfig.put(ServerInvoker.TIMEOUT, CONFIGURED_TIMEOUT_STRING); addClientConfig(clientConfig); client = new Client(locator, clientConfig); client.connect(); } public void testTimeout() throws Throwable { log.info("entering " + getName()); Object response = client.invoke(SHORT_WAIT); assertEquals(SHORT_WAIT, response); log.info("invocation successful"); try { log.info("================ EXPECTING EXCEPTION ================"); client.invoke(LONG_WAIT); log.info("========= DIDN'T GET EXPECTED EXCEPTION ==========="); fail("didn't get expected timeout: initial timeout"); } catch (SocketTimeoutException e) { log.info("================ GOT EXPECTED EXCEPTION ============="); } catch (Exception e) { if (e.getCause() instanceof SocketTimeoutException) { log.info("================ GOT EXPECTED EXCEPTION ============="); } else { log.info(e); log.info("================ GOT UNEXPECTED EXCEPTION ============="); fail(); } } try { log.info("================ EXPECTING EXCEPTION ================"); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "1000"); client.invoke(SHORT_WAIT, metadata); log.info("========= DIDN'T GET UNEXPECTED EXCEPTION ==========="); fail("didn't get expected timeout: initial timeout"); } catch (SocketTimeoutException e) { log.info("================ GOT EXPECTED EXCEPTION ============="); } catch (Exception e) { if (e.getCause() instanceof SocketTimeoutException) { log.info("================ GOT EXPECTED EXCEPTION ============="); } else { log.info(e); e.printStackTrace(); log.info("================ GOT UNEXPECTED EXCEPTION ============="); fail(); } } // Make sure timeout was reset after previous invocation. (Actually, this // test is transport dependent, but it's included here for completeness. A // version of this test could be supplied for each transport.) response = client.invoke(SHORT_WAIT); assertEquals(SHORT_WAIT, response); log.info("invocation successful"); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } abstract protected String getTransport(); 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 (NO_WAIT.equals(command)) { return command; } else if (SHORT_WAIT.equals(command)) { Thread.sleep(4000); return command; } else if (LONG_WAIT.equals(command)) { Thread.sleep(12000); return command; } else { return 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/invocation/0000755000175000017500000000000011632407032030202 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invocation/internal/0000755000175000017500000000000011632407032032016 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invocation/internal/EchoInternalInvocationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/invocation/internal/EchoInte0000644000175000017500000002014110642111503033430 0ustar twernertwerner/* * 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.invocation.internal; 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.invocation.InternalInvocation; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Tests ECHO internal invocation facility. * * @author Ron Sigal * @version $Revision: 2515 $ *

* Copyright Jun 25, 2007 *

*/ public class EchoInternalInvocationTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(EchoInternalInvocationTestCase.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() { } /** * Sends nothing to echo. */ public void testEchoNull() 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(); log.info("client is connected"); InternalInvocation invocation = new InternalInvocation(InternalInvocation.ECHO, null); Object response = client.invoke(invocation); assertNull(response); client.disconnect(); connector.stop(); } /** * Sends an array of one Object to echo. */ public void testEchoNonNull() 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(); log.info("client is connected"); Object[] params = new Object[1]; params[0] = "abc"; InternalInvocation invocation = new InternalInvocation(InternalInvocation.ECHO, params); Object response = client.invoke(invocation); assertEquals("abc", response); client.disconnect(); connector.stop(); } /** * Sends an array of two Objects, the first of which should be echoed. */ public void testEchoMultipleNonNull() 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(); log.info("client is connected"); Object[] params = new Object[2]; params[0] = "def"; params[1] = "xyz"; InternalInvocation invocation = new InternalInvocation(InternalInvocation.ECHO, params); Object response = client.invoke(invocation); assertEquals("def", response); 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 void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable {return null;} public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestInvokerCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException {} } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/restart/0000755000175000017500000000000011632407033027516 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/restart/ServerRestartTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/restart/ServerRestartTestPar0000644000175000017500000001342711015171616033566 0ustar twernertwerner/* * 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.restart; 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; /** * Root class for JBREM-745 unit tests. * * @author Ron Sigal * @version $Revision: 4222 $ *

* Copyright November 27, 2007 *

*/ public abstract class ServerRestartTestParent extends TestCase { private static Logger log = Logger.getLogger(ServerRestartTestParent.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 testServerRestart() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // Create client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI + "/?timeout=10000"); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator1, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); log.info("first connection is good"); // Restart server. shutdownServer(); // Retry if port remains unavailable. for (int i = 0; i < 5; i++) { try { setupServer(false); break; } catch (Exception e) { if (i < 4) { log.info("unable to restart server: will try again in 60 seconds: " + e.getMessage()); Thread.sleep(60000); } else { fail("unable to restart server: " + e.getMessage()); } } } // Test connection. assertEquals("xyz", client.invoke("xyz")); log.info("second connection is good"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } abstract protected String getTransport(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean initial) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); if (initial) 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) {} } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/0000755000175000017500000000000011632407033030415 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/TestClient.java0000644000175000017500000000554710470003230033337 0ustar twernertwerner/* * 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.transporter; import junit.framework.TestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transporter.TransporterClient; import java.io.IOException; /** * @author Tom Elrod */ public class TestClient extends TestCase { public void testClientCall() throws Exception { String locatorURI = "socket://localhost:5400"; InvokerLocator locator = new InvokerLocator(locatorURI); TestServer test = (TestServer) TransporterClient.createTransporterClient(locator, TestServer.class); Object response = test.processTestMessage("Hello"); System.out.println("response is: " + response); assertEquals("response should be 'Hello - has been processed'", "Hello - has been processed", response); int intresp = test.processInt(123); System.out.println("int response is: " + intresp); assertEquals("response should be '456'", 456, intresp); // now make call that should throw exception try { test.throwException(); assertTrue("Should have received IOException thrown by server.", false); } catch(IOException ioex) { assertTrue("Should have received IOException thrown by server.", true); } TransporterClient.destroyTransporterClient(test); } public static void main(String[] args) { try { String locatorURI = "socket://localhost:5400"; InvokerLocator locator = new InvokerLocator(locatorURI); TestServer test = (TestServer) TransporterClient.createTransporterClient(locator, TestServer.class); Object response = test.processTestMessage("Hello"); System.out.println("response is: " + response); TransporterClient.destroyTransporterClient(test); } catch(Exception e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/0000755000175000017500000000000011632407033033370 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/TestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/T0000644000175000017500000000303710456740327033532 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.multiInterface; import junit.framework.TestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transporter.TransporterClient; import java.io.IOException; /** * @author Tom Elrod */ public class TestClient extends TestCase { public void testClientCall() throws Exception { String locatorURI = "socket://localhost:5400"; InvokerLocator locator = new InvokerLocator(locatorURI); TestServer test = (TestServer) TransporterClient.createTransporterClient(locator, TestServer.class); Object response = test.processTestMessage("Hello"); System.out.println("response is: " + response); assertEquals("response should be 'Hello - has been processed'", "Hello - has been processed", response); // now make call that should throw exception try { test.throwException(); assertTrue("Should have received IOException thrown by server.", false); } catch(IOException ioex) { assertTrue("Should have received IOException thrown by server.", true); } TransporterClient.destroyTransporterClient(test); TestServer2 test2 = (TestServer2) TransporterClient.createTransporterClient(locator, TestServer2.class); Object response2 = test2.doIt("foobar"); System.out.println("response2 is: " + response2); assertEquals("response should be 'foobar'", "foobar", response2); TransporterClient.destroyTransporterClient(test2); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/TransporterTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/T0000644000175000017500000000062510535452155033527 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.multiInterface; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TransporterTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(TestClient.class.getName(), 1, TestServerImpl.class.getName()); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/TestServer2.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/T0000644000175000017500000000225010456740327033526 0ustar twernertwerner/* * 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.transporter.multiInterface; /** * @author Tom Elrod */ public interface TestServer2 { public String doIt(String msg); }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/TestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/T0000644000175000017500000000044610456740327033533 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.multiInterface; import java.io.IOException; /** * @author Tom Elrod */ public interface TestServer { public String processTestMessage(String msg); public void throwException() throws IOException; } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/TestServerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/multiInterface/T0000644000175000017500000000272310456740327033533 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.multiInterface; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.transporter.TransporterServer; import java.io.IOException; /** * @author Tom Elrod */ public class TestServerImpl extends ServerTestCase implements TestServer, TestServer2 { private String locatorURI = "socket://localhost:5400"; private TransporterServer server = null; public String processTestMessage(String msg) { return msg + " - has been processed"; } public void throwException() throws IOException { throw new IOException("This is an expected exception thrown by impl on purpose."); } public void setUp() throws Exception { server = TransporterServer.createTransporterServer(locatorURI, new TestServerImpl()); } public void tearDown() { if(server != null) { server.stop(); } } /** * Just here so can run from a few line within a main * * @param args */ public static void main(String[] args) { String locatorURI = "socket://localhost:5400"; try { TestServerImpl testServer = new TestServerImpl(); testServer.setUp(); Thread.currentThread().sleep(60000); testServer.tearDown(); } catch(Exception e) { e.printStackTrace(); } } public String doIt(String msg) { return msg; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/0000755000175000017500000000000011632407033031576 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Auditor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Auditor.ja0000644000175000017500000000223210426316673033531 0ustar twernertwerner/* * 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.transporter.proxy; /** * @author Tom Elrod */ public interface Auditor { public int getNumberOfCalls(); }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Address.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Address.ja0000644000175000017500000000157010426307310033477 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.proxy; import java.io.Serializable; /** * Simple data object for mailing address. * * @author Tom Elrod */ public class Address implements Serializable { private String street = null; private String city = null; private String state = null; private int zip = -1; public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getState() { return state; } public void setState(String state) { this.state = state; } public int getZip() { return zip; } public void setZip(int zip) { this.zip = zip; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/CustomerProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/CustomerPr0000644000175000017500000000115010426316673033632 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.proxy; /** * Interface to be implemented for classes that process * a customer object (which means basically setting customer * number). * * @author Tom Elrod */ public interface CustomerProcessor extends CompanyProcessor { /** * Process a customer object. Implementors * should ensure that the customer object * passed as parameter should have its internal * state changed somehow and returned. * * @param customer * @return */ public ICustomer processCustomer(Customer customer); } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/0000755000175000017500000000000011632407033032670 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Clie0000644000175000017500000000373510467164421033505 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transporter.proxy.local; import junit.framework.TestCase; import org.jboss.remoting.transporter.TransporterClient; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Client extends TestCase { private TransporterServer server; private DateProcessor dateProcessor; public void setUp() throws Exception { server = TransporterServer.createTransporterServer("socket://localhost:5400", new DateProcessorImpl(), DateProcessor.class.getName()); dateProcessor = (DateProcessor) TransporterClient.createTransporterClient("socket://localhost:5400", DateProcessor.class); } public void testDateFormatting() throws Exception { DateConsumer consumer = (DateConsumer) TransporterClient.createTransporterClient("socket://localhost:5401", DateConsumer.class); String response = consumer.consumeDate(dateProcessor); System.out.println("Response from date consumer is " + response); assertTrue("The DateProcessor within this jvm should have been called to format date and was not.", DateProcessorImpl.formatDateCalled); } public void tearDown() { if (dateProcessor != null) { TransporterClient.destroyTransporterClient(dateProcessor); } if (server != null) { server.stop(); } } public static void main(String[] args) { try { Client client = new Client(); client.setUp(); client.testDateFormatting(); client.tearDown(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/DateProcessorImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Date0000644000175000017500000000156710467164421033507 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transporter.proxy.local; import java.text.DateFormat; import java.util.Date; /** * @author Tom Elrod */ public class DateProcessorImpl { public static boolean formatDateCalled = false; public String formatDate(Date dateToConvert) { DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM); System.out.println("Sending back to caller formated date of " + dateFormat); formatDateCalled = true; return dateFormat.format(dateToConvert); } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/DateConsumerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Date0000644000175000017500000000150110467164421033473 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transporter.proxy.local; import java.util.Date; /** * @author Tom Elrod */ public class DateConsumerImpl implements DateConsumer { public String consumeDate(DateProcessor dateProcessor) { Date currentDate = new Date(); String formattedDate = dateProcessor.formatDate(currentDate); System.out.println("called on date processor to format date. response is " + formattedDate); return formattedDate; } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Serv0000644000175000017500000000227710467164421033550 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transporter.proxy.local; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Server extends ServerTestCase { private TransporterServer server; public void setUp() throws Exception { server = TransporterServer.createTransporterServer("socket://localhost:5401", new DateConsumerImpl(), DateConsumer.class.getName()); } public void tearDown() { if (server != null) { server.stop(); } } public static void main(String[] args) { Server svr = new Server(); try { svr.setUp(); Thread.currentThread().sleep(6000000); svr.tearDown(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/TransporterProxyLocalTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Tran0000644000175000017500000000132310467164421033524 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transporter.proxy.local; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TransporterProxyLocalTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(Client.class.getName(), 1, Server.class.getName()); } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/DateConsumer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Date0000644000175000017500000000103710467164421033477 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transporter.proxy.local; /** * @author Tom Elrod */ public interface DateConsumer { public String consumeDate(DateProcessor dateProcessor); }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/DateProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/local/Date0000644000175000017500000000107210467164421033476 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transporter.proxy.local; import java.util.Date; /** * @author Tom Elrod */ public interface DateProcessor { public String formatDate(Date dateToConvert); }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Customer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Customer.j0000644000175000017500000000316210426307310033551 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.proxy; import java.io.Serializable; /** * Simple data object to represent customer data, to include * Address object. * * @author Tom Elrod */ public class Customer implements Serializable, ICustomer { private String firstName = null; private String lastName = null; private Address addr = null; private int customerId = -1; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Address getAddr() { return addr; } public void setAddr(Address addr) { this.addr = addr; } public int getCustomerId() { return customerId; } public void setCustomerId(int customerId) { this.customerId = customerId; } public String toString() { System.out.println("Customer.toString() being called."); StringBuffer buffer = new StringBuffer(); buffer.append("\nCustomer:\n"); buffer.append("customer id: " + customerId + "\n"); buffer.append("first name: " + firstName + "\n"); buffer.append("last name: " + lastName + "\n"); buffer.append("street: " + addr.getStreet() + "\n"); buffer.append("city: " + addr.getCity() + "\n"); buffer.append("state: " + addr.getState() + "\n"); buffer.append("zip: " + addr.getZip() + "\n"); return buffer.toString(); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Client.jav0000644000175000017500000000552510426316673033536 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.proxy; import junit.framework.TestCase; import org.apache.log4j.Level; import org.jboss.remoting.transporter.TransporterClient; /** * @author Tom Elrod */ public class Client extends TestCase { private String locatorURI = "socket://localhost:5400"; public void testClientCall() throws Exception { Customer customer = createCustomer(); CustomerProcessor customerProcessor = (CustomerProcessor) TransporterClient.createTransporterClient(locatorURI, CustomerProcessor.class); System.out.println("Customer to be processed: " + customer); ICustomer processedCustomer = customerProcessor.processCustomer(customer); assertNotNull(processedCustomer); // processedCustomer returned is actually a proxy to the Customer instnace // that lives on the server. So when print it out below, will actually // be calling back to the server to get the string (vi toString() call). // Notice the output of 'Customer.toString() being called.' on the server side. System.out.println("Customer is now: " + processedCustomer); TransporterClient.destroyTransporterClient(customerProcessor); CompanyProcessor companyProcessor = (CompanyProcessor) TransporterClient.createTransporterClient(locatorURI, CompanyProcessor.class); String companyName = companyProcessor.getCompanyName(); System.out.println("company name = " + companyName); assertEquals(CustomerProcessorImpl.COMPANYNAME, companyName); TransporterClient.destroyTransporterClient(companyProcessor); Auditor audit = (Auditor) TransporterClient.createTransporterClient(locatorURI, Auditor.class); int numOfCalls = audit.getNumberOfCalls(); System.out.println("number of calls = " + numOfCalls); assertEquals(1, numOfCalls); TransporterClient.destroyTransporterClient(audit); } private Customer createCustomer() { Customer cust = new Customer(); cust.setFirstName("Bob"); cust.setLastName("Smith"); Address addr = new Address(); addr.setStreet("101 Oak Street"); addr.setCity("Atlanta"); addr.setState("GA"); addr.setZip(30249); cust.setAddr(addr); return cust; } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); Client client = new Client(); try { client.testClientCall(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/CompanyProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/CompanyPro0000644000175000017500000000031110426316673033614 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.proxy; /** * @author Tom Elrod */ public interface CompanyProcessor { public String getCompanyName(); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/TransporterProxyTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Transporte0000644000175000017500000000254610535452155033677 0ustar twernertwerner/* * 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.transporter.proxy; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TransporterProxyTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(Client.class.getName(), 1, Server.class.getName()); } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/ICustomer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/ICustomer.0000644000175000017500000000063310426307310033510 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.proxy; /** * @author Tom Elrod */ public interface ICustomer { String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); Address getAddr(); void setAddr(Address addr); int getCustomerId(); void setCustomerId(int customerId); } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/Server.jav0000644000175000017500000000250210426316673033556 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.proxy; import org.apache.log4j.Level; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Server extends ServerTestCase { private String locatorURI = "socket://localhost:5400"; private TransporterServer server = null; public void setUp() throws Exception { server = TransporterServer.createTransporterServer(locatorURI, new CustomerProcessorImpl()); } public void tearDown() { if (server != null) { server.stop(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); Server server = new Server(); try { server.setUp(); Thread.currentThread().sleep(60000); } catch (Exception e) { e.printStackTrace(); } finally { server.tearDown(); } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/CustomerProcessorImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/proxy/CustomerPr0000644000175000017500000000312510426316673033636 0ustar twernertwernerpackage org.jboss.test.remoting.transporter.proxy; import org.jboss.remoting.transporter.TransporterClient; import org.jboss.remoting.transporter.TransporterServer; import java.util.Random; /** * @author Tom Elrod */ public class CustomerProcessorImpl implements CustomerProcessor, Auditor { private String locatorURI = "socket://localhost:5401"; private int callCounter = 0; public static final String COMPANYNAME = "acme co."; /** * Takes the customer passed, and if not null and customer id * is less than 0, will create a new random id and set it. * The customer object returned will be the modified customer * object passed. * * @param customer * @return */ public ICustomer processCustomer(Customer customer) { if (customer != null && customer.getCustomerId() < 0) { customer.setCustomerId(new Random().nextInt(1000)); } ICustomer customerProxy = null; try { TransporterServer server = TransporterServer.createTransporterServer(locatorURI, customer, ICustomer.class.getName()); customerProxy = (ICustomer) TransporterClient.createTransporterClient(locatorURI, ICustomer.class); } catch (Exception e) { e.printStackTrace(); } callCounter++; System.out.println("processed customer with new id of " + customerProxy.getCustomerId()); return customerProxy; } public String getCompanyName() { return COMPANYNAME; } public int getNumberOfCalls() { return callCounter; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/TransporterTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/TransporterTestC0000644000175000017500000000255010535452155033636 0ustar twernertwerner/* * 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.transporter; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TransporterTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(TestClient.class.getName(), 1, TestServerImpl.class.getName()); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/TestServer.java0000644000175000017500000000243510470003230033360 0ustar twernertwerner/* * 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.transporter; import java.io.IOException; /** * @author Tom Elrod */ public interface TestServer { public String processTestMessage(String msg); public int processInt(int msg); public void throwException() throws IOException; }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/TestServerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transporter/TestServerImpl.j0000644000175000017500000000502510470003230033510 0ustar twernertwerner/* * 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.transporter; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.transporter.TransporterServer; import java.io.IOException; /** * @author Tom Elrod */ public class TestServerImpl extends ServerTestCase implements TestServer { private String locatorURI = "socket://localhost:5400"; private TransporterServer server = null; public String processTestMessage(String msg) { return msg + " - has been processed"; } public int processInt(int msg) { System.out.println("processing int " + msg); return 456; } public void throwException() throws IOException { throw new IOException("This is an expected exception thrown by impl on purpose."); } public void setUp() throws Exception { server = TransporterServer.createTransporterServer(locatorURI, new TestServerImpl(), TestServer.class.getName()); } public void tearDown() { if(server != null) { server.stop(); } } /** * Just here so can run from a few line within a main * * @param args */ public static void main(String[] args) { String locatorURI = "socket://localhost:5400"; try { TransporterServer server = TransporterServer.createTransporterServer(locatorURI, new TestServerImpl(), TestServer.class.getName()); Thread.currentThread().sleep(60000); server.stop(); } catch(Exception e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/0000755000175000017500000000000011632407032030706 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/0000755000175000017500000000000011632407032033242 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000755000175000017500000000000011632407032033556 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/JBossSerializationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000644000175000017500000000275110535452155033574 0ustar twernertwerner/* * 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.serialization.invocations.jboss; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class JBossSerializationTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ClientTest.class.getName(), 1, ServerTest.class.getName()); } protected Level getTestLogLevel() { return Level.DEBUG; } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/ClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000644000175000017500000000312110355142433033557 0ustar twernertwerner/* * 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.serialization.invocations.jboss; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.InvokerClientTest; /** * @author Tom Elrod */ public class ClientTest extends InvokerClientTest { public String getTransport() { return "socket"; } public void setUp() throws Exception { System.setProperty(PerformanceTestCase.REMOTING_METADATA, InvokerLocator.SERIALIZATIONTYPE + "=" + "jboss"); super.setUp(); } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/ServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000644000175000017500000000341010355142433033560 0ustar twernertwerner/* * 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.serialization.invocations.jboss; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.transport.InvokerServerTest; /** * @author Tom Elrod */ public class ServerTest extends InvokerServerTest { public String getTransport() { return "socket"; } public void setUp() throws Exception { Map metadata = new HashMap(); metadata.put(InvokerLocator.SERIALIZATIONTYPE, "jboss"); init(metadata); } public static void main(String[] args) { InvokerServerTest server = new ServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/nonserializable/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000755000175000017500000000000011632407032033556 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/nonserializable/ClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000644000175000017500000000427010433770344033572 0ustar twernertwerner/* * 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.serialization.invocations.jboss.nonserializable; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.util.Random; /** * @author Tom Elrod */ public class ClientTest extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = null; public void testMakeInvocation() throws Throwable { if(locatorURI == null) { locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.SERIALIZATIONTYPE + "=" + "jboss"; } InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); NonSerializableObject object = new NonSerializableObject("foo", new Random().nextInt(100)); Object response = remotingClient.invoke(object); assertEquals(response, ServerTest.RESPONSE_VALUE); remotingClient.disconnect(); } }././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/nonserializable/NonSerializableTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000644000175000017500000000276610535452155033602 0ustar twernertwerner/* * 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.serialization.invocations.jboss.nonserializable; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class NonSerializableTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ClientTest.class.getName(), 1, ServerTest.class.getName()); } protected Level getTestLogLevel() { return Level.DEBUG; } }././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/nonserializable/ServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000644000175000017500000001130710355142433033564 0ustar twernertwerner/* * 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.serialization.invocations.jboss.nonserializable; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class ServerTest extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.SERIALIZATIONTYPE + "=" + "jboss"; private Connector connector; // The non-serializable object to be returned from invocation handler upon client invocation calls. public static final NonSerializableObject RESPONSE_VALUE = new NonSerializableObject("This is the return from the TestServer invocation", 5); 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(); ServerInvocationHandler handler = new SampleInvocationHandler(); connector.addInvocationHandler("test", handler); connector.start(); } public void setUp() throws Exception { setupServer(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { System.out.println("Server received invocation request param of:" + invocation.getParameter()); return RESPONSE_VALUE; } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { //NOOP } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { //NOOP } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //NOOP } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //NOOP } } /** * Can pass transport and port to be used as parameters. * Valid transports are 'rmi' and 'socket'. * * @param args */ public static void main(String[] args) { ServerTest serverTest = new ServerTest(); try { serverTest.setUp(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jboss/nonserializable/NonSerializableObject.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/jb0000644000175000017500000000412410355142433033563 0ustar twernertwerner/* * 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.serialization.invocations.jboss.nonserializable; /** * @author Tom Elrod */ public class NonSerializableObject { private String name = null; private int number = -1; /** * To allow serialization over JBossSerialization */ private NonSerializableObject() { } public NonSerializableObject(String name, int number) { this.name = name; this.number = number; } public String getName() { return name; } public int getNumber() { return number; } public String toString() { return "NonSerializableObject: name=" + name + ", number=" + number; } public boolean equals(Object obj) { if(obj instanceof NonSerializableObject) { NonSerializableObject otherObj = (NonSerializableObject) obj; if(name.equals(otherObj.getName()) && number == otherObj.getNumber()) { return true; } else { return false; } } else { return false; } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/java/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/ja0000755000175000017500000000000011632407032033555 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/java/JavaSerializationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/ja0000644000175000017500000000274710535452155033600 0ustar twernertwerner/* * 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.serialization.invocations.java; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class JavaSerializationTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ClientTest.class.getName(), 1, ServerTest.class.getName()); } protected Level getTestLogLevel() { return Level.DEBUG; } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/java/ClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/ja0000644000175000017500000000311710355142433033563 0ustar twernertwerner/* * 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.serialization.invocations.java; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.InvokerClientTest; /** * @author Tom Elrod */ public class ClientTest extends InvokerClientTest { public String getTransport() { return "socket"; } public void setUp() throws Exception { System.setProperty(PerformanceTestCase.REMOTING_METADATA, InvokerLocator.SERIALIZATIONTYPE + "=" + "java"); super.setUp(); } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/java/ServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/invocations/ja0000644000175000017500000000340610355142433033564 0ustar twernertwerner/* * 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.serialization.invocations.java; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.transport.InvokerServerTest; /** * @author Tom Elrod */ public class ServerTest extends InvokerServerTest { public String getTransport() { return "socket"; } public void setUp() throws Exception { Map metadata = new HashMap(); metadata.put(InvokerLocator.SERIALIZATIONTYPE, "java"); init(metadata); } public static void main(String[] args) { InvokerServerTest server = new ServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/jboss/0000755000175000017500000000000011632407032032026 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/jboss/JBossSerializationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/jboss/JBossSer0000644000175000017500000000262710535452155033461 0ustar twernertwerner/* * 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.serialization.jboss; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class JBossSerializationTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(JBossSerializationClientTest.class.getName(), 1, JBossSerializationServerTest.class.getName()); } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/jboss/JBossSerializationServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/jboss/JBossSer0000644000175000017500000000342110355142433033445 0ustar twernertwerner/* * 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.serialization.jboss; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.serialization.impl.jboss.JBossSerializationManager; import org.jboss.test.remoting.serialization.FactoryServer; /** * @author Tom Elrod */ public class JBossSerializationServerTest extends FactoryServer { protected void configureStream() throws Exception { SerializationStreamFactory.setManagerClassName(JBossSerializationManager.class.getName()); } public static void main(String[] args) { JBossSerializationServerTest server = new JBossSerializationServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/jboss/JBossSerializationClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/jboss/JBossSer0000644000175000017500000000302110355142433033441 0ustar twernertwerner/* * 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.serialization.jboss; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.serialization.impl.jboss.JBossSerializationManager; import org.jboss.test.remoting.serialization.FactoryClient; /** * @author Tom Elrod */ public class JBossSerializationClientTest extends FactoryClient { protected void configureStream() throws Exception { SerializationStreamFactory.setManagerClassName(JBossSerializationManager.class.getName()); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/java/0000755000175000017500000000000011632407032031627 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/java/JavaSerializationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/java/JavaSeria0000644000175000017500000000262310535452155033431 0ustar twernertwerner/* * 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.serialization.java; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class JavaSerializationTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(JavaSerializationClientTest.class.getName(), 1, JavaSerializationServerTest.class.getName()); } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/java/JavaSerializationClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/java/JavaSeria0000644000175000017500000000301410355142433033417 0ustar twernertwerner/* * 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.serialization.java; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.serialization.impl.java.JavaSerializationManager; import org.jboss.test.remoting.serialization.FactoryClient; /** * @author Tom Elrod */ public class JavaSerializationClientTest extends FactoryClient { protected void configureStream() throws Exception { SerializationStreamFactory.setManagerClassName(JavaSerializationManager.class.getName()); } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/java/JavaSerializationServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/java/JavaSeria0000644000175000017500000000341210355142433033421 0ustar twernertwerner/* * 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.serialization.java; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.serialization.impl.java.JavaSerializationManager; import org.jboss.test.remoting.serialization.FactoryServer; /** * @author Tom Elrod */ public class JavaSerializationServerTest extends FactoryServer { protected void configureStream() throws Exception { SerializationStreamFactory.setManagerClassName(JavaSerializationManager.class.getName()); } public static void main(String[] args) { JavaSerializationServerTest server = new JavaSerializationServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/FactoryServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/FactoryServer.0000644000175000017500000000703310355142433033512 0ustar twernertwerner/* * 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.serialization; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.serialization.SerializationStreamFactory; /** * @author Tom Elrod */ public abstract class FactoryServer extends ServerTestCase { private int serverBindPort = 6700; private int backlog = 200; private ServerSocket serverSocket; private InetAddress bindAddress; private String serverBindAddress = "localhost"; private int timeout = 60000; // 60 seconds. public static final String RESPONSE = "This is the response"; private boolean keepRunning = true; public void setUp() throws Exception { bindAddress = InetAddress.getByName(serverBindAddress); serverSocket = new ServerSocket(serverBindPort, backlog, bindAddress); new Thread(new ServerThread()).start(); } public void tearDown() throws Exception { keepRunning = false; serverSocket.close(); } private class ServerThread implements Runnable { public void run() { try { configureStream(); while(keepRunning) { try { Socket socket = serverSocket.accept(); socket.setSoTimeout(timeout); try { ObjectOutput output = SerializationStreamFactory.getManagerInstance().createOutput(socket.getOutputStream()); ObjectInput input = SerializationStreamFactory.getManagerInstance().createRegularInput(socket.getInputStream()); processRequest(input, output); } catch(Exception e) { e.printStackTrace(); } } catch(Exception e) { e.printStackTrace(); } } } catch(Exception e) { e.printStackTrace(); } } private void processRequest(ObjectInput objInputStream, ObjectOutput oos) throws IOException, ClassNotFoundException { Object obj = objInputStream.readObject(); System.out.println("Object read: " + obj); oos.writeObject(RESPONSE); oos.flush(); } } protected abstract void configureStream() throws Exception; }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/FactoryClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/serialization/FactoryClient.0000644000175000017500000000465110355142433033465 0ustar twernertwerner/* * 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.serialization; import java.io.ObjectInput; import java.io.ObjectOutput; import java.net.Socket; import org.jboss.remoting.serialization.SerializationStreamFactory; import junit.framework.TestCase; /** * @author Tom Elrod */ public abstract class FactoryClient extends TestCase { protected String address = "localhost"; protected int port = 6700; private boolean enableTcpNoDelay = false; private int timeout = 60000; private Socket socket = null; public void setUp() throws Exception { socket = new Socket(address, port); socket.setSoTimeout(timeout); socket.setTcpNoDelay(enableTcpNoDelay); } public void tearDown() throws Exception { if(socket != null) { socket.close(); } } public void testClientCall() throws Exception { configureStream(); ObjectOutput output = SerializationStreamFactory.getManagerInstance().createOutput(socket.getOutputStream()); ObjectInput input = SerializationStreamFactory.getManagerInstance().createRegularInput(socket.getInputStream()); output.writeObject("This is the request"); output.flush(); Object obj = input.readObject(); System.out.println("response: " + obj); assertEquals("Response value is not what was expected.", FactoryServer.RESPONSE, obj); } protected abstract void configureStream() throws Exception; }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/0000755000175000017500000000000011632407032030170 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000000450311413660476033533 0ustar twernertwernerpackage org.jboss.test.remoting.connection; import java.io.IOException; import java.net.MalformedURLException; import java.util.HashMap; import java.util.Map; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.ConnectionValidator; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.MicroRemoteClientInvoker; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.transport.ClientInvoker; public class ConnectionValidatorTestCase extends TestCase { public void testShouldDisallowDirectRun() { ConnectionValidator cv = new ConnectionValidator(new Client() { public Map getConfiguration() { return new HashMap(); } public ClientInvoker getInvoker() { try { return new MicroRemoteClientInvoker( new InvokerLocator("http://dummy:65535/dummy/")) { public String getSessionId() { return "dummyId"; } protected String getDefaultDataType() { throw new UnsupportedOperationException(); } protected void handleConnect() throws ConnectionFailedException { throw new UnsupportedOperationException(); } protected void handleDisconnect() { throw new UnsupportedOperationException(); } protected Object transport(String sessionId, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller) throws IOException, ConnectionFailedException, ClassNotFoundException { throw new UnsupportedOperationException(); } }; } catch (MalformedURLException e) { throw new RuntimeException(e); } } }); try { cv.run(); fail("Should throw IllegalStateException"); } catch (IllegalStateException e) { // Expected } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorRemoteClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000001027311413660476033534 0ustar twernertwerner/* * 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.connection; import java.util.HashMap; 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.ConnectionValidator; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ConnectionValidatorRemoteClient extends TestCase implements ConnectionListener { private static Logger log = Logger.getLogger(ConnectionValidatorRemoteClient.class); // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; String locatorURI = transport + "://" + host + ":" + port; private Throwable validatorResp = null; private int counter = 0; private Client remotingClient = null; public void testValidator() throws Throwable { HashMap config = new HashMap(); config.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "1000"); config.put("timeout", "20000"); remotingClient.addConnectionListener(this, config); Object response = remotingClient.invoke("Do something"); log.info("Invocation response: " + response); assertNull(validatorResp); Thread.currentThread().sleep(30000); log.info("validatorResp = " + validatorResp); assertNotNull("Connection listener was not called as expected.", validatorResp); assertEquals(1, counter); } public void setUp() throws Exception { 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); InvokerLocator locator = new InvokerLocator(locatorURI); log.info("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); } public void tearDown() throws Exception { if(remotingClient != null) { remotingClient.disconnect(); } } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } ConnectionValidatorRemoteClient client = new ConnectionValidatorRemoteClient(); try { client.setUp(); client.testValidator(); client.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } public void handleConnectionException(Throwable throwable, Client client) { log.info("Got connection exception."); validatorResp = throwable; counter++; } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorTiedToLeaseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000004774411413660476033551 0ustar twernertwerner/* * 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.connection; 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.ConnectionValidator; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit tests for JBREM-891. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jan 19, 2008 *

*/ public class ConnectionValidatorTiedToLeaseTestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionValidatorTiedToLeaseTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected TestConnectionListener serverListener; 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 testTiedToLeaseDefaultConfigurationLocalInvoker() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // 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"); // Register client side listener. Object lock = new Object(); TestConnectionListener clientListener = new TestConnectionListener(lock); client.addConnectionListener(clientListener); log.info("connection listener added on client side"); // Verify ConnectionValidator is running. assertTrue(client.getPingPeriod() > -1); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify LeasePinger is running. assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker); ClientInvoker clientInvoker = client.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(clientInvoker); assertNotNull(pinger); field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(pinger); assertNotNull(timerTask); // Shut down lease on server side. connector.removeConnectionListener(serverListener); // Wait for client side listener to be notified. synchronized (lock) { lock.wait(30000); } // Verify ConnectionValidator has stopped. Thread.sleep(4000); assertTrue(clientListener.notified); assertEquals(-1, client.getPingPeriod()); // Verfiy LeasePinger has stopped. timerTask = (TimerTask) field.get(pinger); assertNull(timerTask); client.removeConnectionListener(clientListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testTiedToLeaseDefaultConfigurationRemoteInvoker() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // 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"); // Register client side listener. Object lock = new Object(); TestConnectionListener clientListener = new TestConnectionListener(lock); Map metadata = new HashMap(); metadata.put(InvokerLocator.FORCE_REMOTE, "true"); client.addConnectionListener(clientListener, metadata); log.info("connection listener added on client side"); // Verify ConnectionValidator is running. assertTrue(client.getPingPeriod() > -1); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify LeasePinger is running. assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker); ClientInvoker clientInvoker = client.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(clientInvoker); assertNotNull(pinger); field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(pinger); assertNotNull(timerTask); // Shut down lease on server side. connector.removeConnectionListener(serverListener); // Wait for client side listener to be notified. synchronized (lock) { lock.wait(30000); } // Verify ConnectionValidator has stopped. Thread.sleep(4000); assertTrue(clientListener.notified); assertEquals(-1, client.getPingPeriod()); // Verfiy LeasePinger has stopped. timerTask = (TimerTask) field.get(pinger); assertNull(timerTask); client.removeConnectionListener(clientListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testTiedToLeaseDontStopLease() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // 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"); // Register client side listener. Object lock = new Object(); TestConnectionListener clientListener = new TestConnectionListener(lock); Map metadata = new HashMap(); metadata.put(InvokerLocator.FORCE_REMOTE, "true"); metadata.put(ConnectionValidator.TIE_TO_LEASE, "true"); metadata.put(ConnectionValidator.STOP_LEASE_ON_FAILURE, "false"); client.addConnectionListener(clientListener, metadata); log.info("connection listener added on client side"); // Verify ConnectionValidator is running. assertTrue(client.getPingPeriod() > -1); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify LeasePinger is running. assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker); ClientInvoker clientInvoker = client.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(clientInvoker); assertNotNull(pinger); field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(pinger); assertNotNull(timerTask); // Shut down lease on server side. connector.removeConnectionListener(serverListener); // Wait for client side listener to be notified. synchronized (lock) { lock.wait(30000); } // Verify ConnectionValidator has stopped. Thread.sleep(4000); assertTrue(clientListener.notified); assertEquals(-1, client.getPingPeriod()); // Verfiy LeasePinger has not stopped. timerTask = (TimerTask) field.get(pinger); assertNotNull(timerTask); client.removeConnectionListener(clientListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNotTiedToLeaseDontStopLease() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // 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"); // Register client side listener. Object lock = new Object(); TestConnectionListener clientListener = new TestConnectionListener(lock); Map metadata = new HashMap(); metadata.put(InvokerLocator.FORCE_REMOTE, "true"); metadata.put(ConnectionValidator.TIE_TO_LEASE, "false"); metadata.put(ConnectionValidator.STOP_LEASE_ON_FAILURE, "false"); client.addConnectionListener(clientListener, metadata); log.info("connection listener added on client side"); // Verify ConnectionValidator is running. assertTrue(client.getPingPeriod() > -1); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify LeasePinger is running. assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker); ClientInvoker clientInvoker = client.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(clientInvoker); assertNotNull(pinger); field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(pinger); assertNotNull(timerTask); // Shut down lease on server side. connector.removeConnectionListener(serverListener); // Wait for client side listener to be notified. synchronized (lock) { lock.wait(30000); } // Verify ConnectionValidator has not stopped. Thread.sleep(4000); assertFalse(clientListener.notified); assertTrue(client.getPingPeriod() > -1); // Verfiy LeasePinger has not stopped. timerTask = (TimerTask) field.get(pinger); assertNotNull(timerTask); client.removeConnectionListener(clientListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNotTiedToLeaseStopLease() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // 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"); // Register client side listener. Object lock = new Object(); TestConnectionListener clientListener = new TestConnectionListener(lock); Map metadata = new HashMap(); metadata.put(InvokerLocator.FORCE_REMOTE, "true"); metadata.put(ConnectionValidator.TIE_TO_LEASE, "false"); metadata.put(ConnectionValidator.STOP_LEASE_ON_FAILURE, "true"); client.addConnectionListener(clientListener, metadata); log.info("connection listener added on client side"); // Verify ConnectionValidator is running. assertTrue(client.getPingPeriod() > -1); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify LeasePinger is running. assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker); ClientInvoker clientInvoker = client.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(clientInvoker); assertNotNull(pinger); field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(pinger); assertNotNull(timerTask); // Prevent server from responding to ConnectionValidator pings. ServerInvoker serverInvoker = connector.getServerInvoker(); field = ServerInvoker.class.getDeclaredField("started"); field.setAccessible(true); field.set(serverInvoker, new Boolean(false)); assertFalse(field.getBoolean(serverInvoker)); log.info("Stopped server invoker"); // Wait for client side listener to be notified. synchronized (lock) { lock.wait(30000); } // Verify ConnectionValidator has stopped. Thread.sleep(4000); assertTrue(clientListener.notified); assertEquals(-1, client.getPingPeriod()); // Verfiy LeasePinger has stopped. field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); timerTask = (TimerTask) field.get(pinger); assertNull(timerTask); client.removeConnectionListener(clientListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testTiedToLeaseServerLeasingTurnedOff() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false); // 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"); // Register client side listener. Object lock = new Object(); TestConnectionListener clientListener = new TestConnectionListener(lock); Map metadata = new HashMap(); metadata.put(InvokerLocator.FORCE_REMOTE, "true"); client.addConnectionListener(clientListener, metadata); log.info("connection listener added on client side"); // Verify ConnectionValidator is running. assertTrue(client.getPingPeriod() > -1); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Wait for client side listener to be notified. synchronized (lock) { lock.wait(30000); } // Verify ConnectionValidator has not stopped. Thread.sleep(4000); assertFalse(clientListener.notified); assertTrue(client.getPingPeriod() > -1); client.removeConnectionListener(clientListener); 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(boolean startLeasing) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?" + InvokerLocator.CLIENT_LEASE + "=true"; locatorURI += "&" + InvokerLocator.CLIENT_LEASE_PERIOD + "=4000"; 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.CLIENT_LEASE_PERIOD, "4000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); if (startLeasing) { serverListener = new TestConnectionListener(); connector.addConnectionListener(serverListener); } connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) { connector.removeConnectionListener(serverListener); 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 TestConnectionListener implements ConnectionListener { public boolean notified; private Object lock; TestConnectionListener() { this(new Object()); } TestConnectionListener(Object lock) { this.lock = lock; } public void handleConnectionException(Throwable throwable, Client client) { notified = true; synchronized (lock) { try { // Give listener a chance to wait on lock. Thread.sleep(4000); } catch (InterruptedException e) { log.info("Unexpected interrupt in TestConnectionListener"); } lock.notifyAll(); } } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000000317310634675726033545 0ustar twernertwerner/* * 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.connection; import org.jboss.jrunit.harness.TestDriver; /** * ConnectionValidatorConfigTestCase verifies that parameters are correctly set * on org.jboss.remoting.ConnectionValidator. * * See JBREM-755. * * @author Ron Sigal * @version $Revision: 2473 $ *

* Copyright Jun 16, 2007 *

*/ public class ConnectionValidatorConfigTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ConnectionValidatorConfigTestClient.class.getName(), 1, ConnectionValidatorConfigTestServer.class.getName()); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/local/0000755000175000017500000000000011632407031031261 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/local/LocalConnectionValidationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/local/LocalConnec0000644000175000017500000000474310433103353033372 0ustar twernertwerner/* * 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.connection.local; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class LocalConnectionValidationTestCase extends TestCase implements ConnectionListener { private Client client = null; private Connector connector = null; private boolean connectionFailure = false; public void setUp() throws Exception { String locatorUri = "socket://localhost:8888"; connector = new Connector(); connector.setInvokerLocator(locatorUri); connector.start(); client = new Client(new InvokerLocator(locatorUri)); client.connect(); client.addConnectionListener(this); } public void testConnection() throws Exception { Thread.sleep(5000); connector.stop(); connector.destroy(); connector = null; Thread.sleep(10000); assertFalse(connectionFailure); client.removeConnectionListener(this); } public void tearDown() { if(client != null) { client.disconnect(); } if(connector != null) { connector.stop(); connector.destroy(); } } public void handleConnectionException(Throwable throwable, Client client) { System.out.println("got connection exception."); connectionFailure = true; } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/local/LocalServerDisconnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/local/LocalServer0000644000175000017500000000664710433112705033441 0ustar twernertwerner/* * 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.connection.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 LocalServerDisconnectTestCase extends TestCase { private Client client = null; private Connector connector = null; public void setUp() throws Exception { String locatorUri = "socket://localhost:8888"; connector = new Connector(); connector.setInvokerLocator(locatorUri); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); client = new Client(new InvokerLocator(locatorUri)); client.connect(); } public void testConnection() throws Throwable { Object r = client.invoke("foobar"); assertEquals("tadpole", r); connector.stop(); connector.destroy(); connector = null; // should now get an exception thrown due to connector being gone try { client.invoke("barfoo"); } catch (Throwable throwable) { System.out.println("Got exception as expected. " + throwable.getMessage()); assertTrue(true); return; } assertTrue("Should have caught exception and returned.", false); } public void tearDown() { if (client != null) { client.disconnect(); } if (connector != null) { connector.stop(); connector.destroy(); } } 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 "tadpole"; } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorNPETestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000001624311413660476033537 0ustar twernertwerner/* * 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.connection; 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.ConnectionListener; import org.jboss.remoting.ConnectionValidator; 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 EDU.oswego.cs.dl.util.concurrent.Rendezvous; import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt; /** * Unit test for JBREM-1166. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 13, 2009 */ public class ConnectionValidatorNPETestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionValidatorNPETestCase.class); private static boolean firstTime = true; private static int COUNT = 2000; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected SynchronizedInt errors = new SynchronizedInt(0); 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 testNPE() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); // Start busy thread. new Thread() { public void run() { int i = 0; while (true) { i++; } } }.start(); // Create ConnectionValidator multiiple times. HashMap metadata = new HashMap(); metadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "1"); TestConnectionValidator[] validators = new TestConnectionValidator[COUNT]; for (int i = 0; i < COUNT; i++) { validators[i] = new TestConnectionValidator(i, errors, client, metadata); validators[i].addConnectionListener(client, new TestConnectionListener()); } Thread.sleep(5000); assertEquals(0, errors.get()); 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 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 TestConnectionListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { } } static class TestConnectionValidator extends ConnectionValidator { public volatile boolean timerWasNull; int id; Rendezvous rendezvous; boolean[] flags; SynchronizedInt errors; Field field; public TestConnectionValidator(int id, SynchronizedInt errors, Client client, Map metadata) throws SecurityException, NoSuchFieldException { super(client, metadata); this.id = id; this.errors = errors; field = ConnectionValidator.class.getDeclaredField("timer"); field.setAccessible(true); } public void run() { try { // log.info(id + ": starting"); timerWasNull = (field.get(this) == null); if (timerWasNull) { log.info("timer was null: " + id); errors.increment(); } } catch (Exception e) { log.info("exception", e); } } } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorCachedInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000001554710554102573033537 0ustar twernertwerner/* * 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.connection; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionValidator; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.Remoting; 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.util.TimerUtil; import org.jboss.test.remoting.socketfactory.TestListener; import org.jboss.test.remoting.socketfactory.CreationListenerTestRoot.TestHandler; import junit.framework.TestCase; /** * @author Ron Sigal * @version $Revision: 1917 $ *

* Copyright Jan 17, 2007 *

*/ public class ConnectionValidatorCachedInvokerTestCase extends TestCase implements ConnectionListener { private static Logger log = Logger.getLogger(ConnectionValidatorCachedInvokerTestCase.class); private String locatorURI; private Connector connector; private Client client; public void setUp() throws Exception { String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); locatorURI = "socket://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); client = new Client(locator, clientConfig); client.connect(); } public void tearDown() throws Exception { if (connector != null) { connector.stop(); } if(client != null) { client.disconnect(); } } public void testTimerUtilDestroy() throws Throwable { log.info("entering " + getName()); Integer i = (Integer) client.invoke(new Integer(7)); assertEquals(8, i.intValue()); client.addConnectionListener(this); Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator cv = (ConnectionValidator) field.get(client); assertNotNull(cv); field = ConnectionValidator.class.getDeclaredField("stopped"); field.setAccessible(true); boolean stopped = ((Boolean) field.get(cv)).booleanValue(); assertFalse(stopped); TimerUtil.destroy(); stopped = ((Boolean) field.get(cv)).booleanValue(); assertTrue(stopped); log.info(getName() + " PASSES"); } public void testConnectionValidatorStop() throws Throwable { log.info("entering " + getName()); Integer i = (Integer) client.invoke(new Integer(7)); assertEquals(8, i.intValue()); client.addConnectionListener(this); Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator cv = (ConnectionValidator) field.get(client); assertNotNull(cv); field = ConnectionValidator.class.getDeclaredField("stopped"); field.setAccessible(true); boolean stopped = ((Boolean) field.get(cv)).booleanValue(); assertFalse(stopped); cv.stop(); stopped = ((Boolean) field.get(cv)).booleanValue(); assertTrue(stopped); log.info(getName() + " PASSES"); } public void testConnectionValidatorCancel() throws Throwable { log.info("entering " + getName()); Integer i = (Integer) client.invoke(new Integer(7)); assertEquals(8, i.intValue()); client.addConnectionListener(this); Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator cv = (ConnectionValidator) field.get(client); assertNotNull(cv); field = ConnectionValidator.class.getDeclaredField("stopped"); field.setAccessible(true); boolean stopped = ((Boolean) field.get(cv)).booleanValue(); assertFalse(stopped); cv.cancel(); stopped = ((Boolean) field.get(cv)).booleanValue(); assertTrue(stopped); log.info(getName() + " PASSES"); } public void testDistinctClientInvoker() throws Throwable { client.addConnectionListener(this); Thread.sleep(3000); Field field = InvokerRegistry.class.getDeclaredField("clientLocators"); field.setAccessible(true); Map clientLocators = (Map) field.get(null); List holderList = (List) clientLocators.get(new InvokerLocator(locatorURI)); assertEquals(2, holderList.size()); } public void handleConnectionException(Throwable throwable, Client client) { System.out.println("Got connection exception."); } public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { Integer i = (Integer) invocation.getParameter(); return new Integer(i.intValue() + 1); } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000000652110433770344033532 0ustar twernertwerner/* * 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.connection; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ConnectionValidatorClient extends TestCase implements ConnectionListener { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; String locatorURI = transport + "://" + host + ":" + port; private Throwable validatorResp = null; private int counter = 0; private Client remotingClient = null; public void testValidator() throws Throwable { remotingClient.addConnectionListener(this); Object response = remotingClient.invoke("Do something"); System.out.println("Invocation response: " + response); assertNull(validatorResp); Thread.currentThread().sleep(30000); System.out.println("validatorResp = " + validatorResp); assertNotNull("Connection listener was not called as expected.", validatorResp); assertEquals(1, counter); } public void setUp() throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); } public void tearDown() throws Exception { if(remotingClient != null) { remotingClient.disconnect(); } } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } ConnectionValidatorClient client = new ConnectionValidatorClient(); try { client.setUp(); client.testValidator(); client.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } public void handleConnectionException(Throwable throwable, Client client) { System.out.println("Got connection exception."); validatorResp = throwable; counter++; } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidationServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000001263410412706674033536 0ustar twernertwerner/* * 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.connection; 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.InvokerCallbackHandler; import org.jboss.remoting.samples.simple.SimpleServer; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class ConnectionValidationServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector = null; // 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(); SimpleServer.SampleInvocationHandler invocationHandler = new SimpleServer.SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); connector.start(); } public void testShutdown() throws Exception { // sleep the thread for 10 seconds while waiting for client to call Thread.currentThread().sleep(10000); connector.stop(); connector.destroy(); connector = null; } public void setUp() throws Exception { setupServer(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } ConnectionValidationServer server = new ConnectionValidationServer(); try { server.setupServer(); server.testShutdown(); } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } /** * 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 } } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000000265210535452155033533 0ustar twernertwerner/* * 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.connection; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class ConnectionValidationTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ConnectionValidatorClient.class.getName(), 1, ConnectionValidationServer.class.getName()); } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorDisconnectTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000005271611413700457033536 0ustar twernertwerner/* * 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.connection; import java.io.IOException; import java.net.InetAddress; 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.ClientDisconnectedException; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionValidator; 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.ServerFactory; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-1112. * * @author Ron Sigal * @version *

* Copyright Apr 3, 2009 *

*/ public class ConnectionValidatorDisconnectTimeoutTestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionValidatorDisconnectTimeoutTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected TestConnectionListener serverConnectionListener; 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 testDefaultUnary() 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.ENABLE_LEASE, "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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); client.addConnectionListener(clientConnectionListener); // Wait for broken connection and test. Thread.sleep(4000); assertTrue(serverConnectionListener.notified); assertTrue(serverConnectionListener.throwable instanceof ClientDisconnectedException); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); client.removeConnectionListener(clientConnectionListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testDefaultFirstBinary() 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.ENABLE_LEASE, "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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); client.addConnectionListener(clientConnectionListener, 500); // Wait for broken connection and test. Thread.sleep(4000); assertTrue(serverConnectionListener.notified); assertTrue(serverConnectionListener.throwable instanceof ClientDisconnectedException); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); client.removeConnectionListener(clientConnectionListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testDefaultSecondBinary() 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.ENABLE_LEASE, "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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); client.addConnectionListener(clientConnectionListener, new HashMap()); // Wait for broken connection and test. Thread.sleep(4000); assertTrue(serverConnectionListener.notified); assertTrue(serverConnectionListener.throwable instanceof ClientDisconnectedException); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); client.removeConnectionListener(clientConnectionListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testZeroInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&" + Client.USE_ALL_PARAMS + "=true"; clientLocatorURI += "&" + ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT + "=0"; log.info("clientLocatorURI: " + clientLocatorURI); InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); client.addConnectionListener(clientConnectionListener, new HashMap()); // Wait for broken connection and test. Thread.sleep(12000); assertTrue(serverConnectionListener.notified); assertNull(serverConnectionListener.throwable); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); client.removeConnectionListener(clientConnectionListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNonZeroInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&" + Client.USE_ALL_PARAMS + "=true"; clientLocatorURI += "&" + ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT + "=10000"; log.info("clientLocatorURI: " + clientLocatorURI); InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); client.addConnectionListener(clientConnectionListener, new HashMap()); // Wait for broken connection and test. Thread.sleep(4000); assertTrue(serverConnectionListener.notified); assertTrue(serverConnectionListener.throwable instanceof ClientDisconnectedException); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testZeroConfig() 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.ENABLE_LEASE, "true"); clientConfig.put(ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT, "0"); 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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); client.addConnectionListener(clientConnectionListener, new HashMap()); // Wait for broken connection and test. Thread.sleep(12000); assertTrue(serverConnectionListener.notified); assertNull(serverConnectionListener.throwable); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNonZeroConfig() 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.ENABLE_LEASE, "true"); clientConfig.put(ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT, "10000"); 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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); client.addConnectionListener(clientConnectionListener, new HashMap()); // Wait for broken connection and test. Thread.sleep(4000); assertTrue(serverConnectionListener.notified); assertTrue(serverConnectionListener.throwable instanceof ClientDisconnectedException); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testZeroMetadata() 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.ENABLE_LEASE, "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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); HashMap metadata = new HashMap(); metadata.put(ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT, "0"); client.addConnectionListener(clientConnectionListener, metadata); // Wait for broken connection and test. Thread.sleep(10000); assertTrue(serverConnectionListener.notified); assertNull(serverConnectionListener.throwable); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNonZeroMetadata() 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.ENABLE_LEASE, "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"); // Install ConnectionListener. TestConnectionListener clientConnectionListener = new TestConnectionListener("CLIENT"); HashMap metadata = new HashMap(); metadata.put(ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT, "10000"); client.addConnectionListener(clientConnectionListener, metadata); // Wait for broken connection and test. Thread.sleep(4000); assertTrue(serverConnectionListener.notified); assertTrue(serverConnectionListener.throwable instanceof ClientDisconnectedException); assertTrue(clientConnectionListener.notified); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", ((Exception)clientConnectionListener.throwable).getMessage()); 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 { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.registerInvokerFactories("socket", org.jboss.remoting.transport.socket.TransportClientFactory.class, TestServerInvokerFactory.class); return null; } }); host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port + "/?x=x"; 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("leasePeriod", "2000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); serverConnectionListener = new TestConnectionListener("SERVER"); connector.addConnectionListener(serverConnectionListener); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestServerInvoker extends SocketServerInvoker { public TestServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public Object invoke(InvocationRequest invocation) throws Throwable { Object param = invocation.getParameter(); // check to see if this is a is alive ping if ("$PING$".equals(param)) { Map metadata = invocation.getRequestPayload(); if (metadata != null) { String invokerSessionId = (String) metadata.get(INVOKER_SESSION_ID); if (invokerSessionId != null) { // Comes from ConnectionValidator configured to tie validation with lease. log.info(this + " responding FALSE to $PING$ for invoker sessionId " + invokerSessionId); return Boolean.FALSE; } } } return super.invoke(invocation); } } public static class TestServerInvokerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException { return new TestServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } 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 TestConnectionListener implements ConnectionListener { public boolean notified; public Throwable throwable; String name; TestConnectionListener(String name) { this.name = name; } public void handleConnectionException(Throwable throwable, Client client) { notified = true; this.throwable = throwable; log.info(this + " NOTIFIED, throwable = " + throwable); } public String toString() { return "TestConnectionListener[" + name + "]"; } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/deadlock/0000755000175000017500000000000011632407031031735 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/deadlock/DeadlockTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/deadlock/Deadlock0000644000175000017500000001075311413660476033407 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, 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.connection.deadlock; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; 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.ConnectionValidator; import org.jboss.remoting.InvokerLocator; /** * Unit test for JBREM-1070. * * @author Ron Sigal * @version *

* Copyright Nov 29, 2008 *

*/ public class DeadlockTestClient extends TestCase { private static Logger log = Logger.getLogger(DeadlockTestClient.class); private static boolean firstTime = true; protected String host; protected int port = 7777; protected String locatorURI; protected InvokerLocator serverLocator; 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 testForDeadlock() throws Throwable { log.info("entering " + getName()); for (int i = 0; i < 10; i++) { assertTrue("failed execution: " + i, doTest()); log.info("execution " + i + " PASSES\n"); } log.info(getName() + " PASSES"); } public boolean doTest() throws Throwable { // Create client. host = InetAddress.getLocalHost().getHostAddress(); locatorURI = getTransport() + "://" + host + ":" + port; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "/?" + metadata; } InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "5000"); clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "1000"); 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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener); // Wait for notification. for (int i = 0; i < 20; i++) { if (listener.ok) { break; } Thread.sleep(1000); } client.disconnect(); return listener.ok; } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} static class TestConnectionListener implements ConnectionListener { public boolean ok; public void handleConnectionException(Throwable throwable, Client client) { ok = true; log.info("handleConnectionException() called"); } } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/deadlock/DeadlockTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/deadlock/Deadlock0000644000175000017500000000307011413660476033401 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, 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.connection.deadlock; import org.jboss.jrunit.harness.TestDriver; /** * Unit test for JBREM-1070. * * @author Ron Sigal * @version *

* Copyright Nov 29, 2008 *

*/ public class DeadlockTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(DeadlockTestClient.class.getName(), 1, DeadlockTestServer.class.getName()); } protected long getResultsTimeout() { return 240000; } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/deadlock/DeadlockTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/deadlock/Deadlock0000644000175000017500000001350011413660476033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, 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.connection.deadlock; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; 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.socket.SocketServerInvoker; /** * Unit test for JBREM-1070. * * @author Ron Sigal * @version *

* Copyright Nov 29, 2008 *

*/ public class DeadlockTestServer extends ServerTestCase { private static Logger log = Logger.getLogger(DeadlockTestServer.class); private static boolean firstTime = true; protected String host; protected int port = 7777; protected String locatorURI; protected InvokerLocator serverLocator; protected TestServerInvoker serverInvoker; protected TestInvocationHandler invocationHandler; public static void main(String[] args) { try { DeadlockTestServer server = new DeadlockTestServer(); server.setUp(); Thread.sleep(600000); server.shutdownServer(); } catch (Throwable t) { log.error("error", t); } } 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); } setupServer(); } public void tearDown() throws Exception { shutdownServer(); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); 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); serverInvoker = new TestServerInvoker(serverLocator, config); serverInvoker.create(); invocationHandler = new TestInvocationHandler(); serverInvoker.addInvocationHandler("test", invocationHandler); serverInvoker.start(); log.info("TestServerInvoker(" + locatorURI + ") started"); } protected void shutdownServer() throws Exception { if (serverInvoker != null) serverInvoker.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 TestServerInvoker extends SocketServerInvoker { public TestServerInvoker(InvokerLocator locator, Map config) { super(locator, config); log.info("TestServerInvoker: " + locator); } public Object invoke(InvocationRequest invocation) throws Throwable { if ("$PING$".equals(invocation.getParameter())) { log.info("TestServerInvoker received $PING$"); Thread.sleep(10000); throw new Exception("got $PING$"); } else { return super.invoke(invocation); } } } static class TestConnectionListener implements ConnectionListener { public boolean ok; public void handleConnectionException(Throwable throwable, Client client) { ok = true; log.info("handleConnectionException() called"); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/identity/0000755000175000017500000000000011632407031032020 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/identity/LeaseIdentityTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/identity/LeaseIde0000644000175000017500000002420511413660476033434 0ustar twernertwerner/* * 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.connection.identity; 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.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.Remoting; 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 org.jboss.util.id.GUID; /** * Unit test for JBREM-1133. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 08, 2009 *

*/ public class LeaseIdentityTestCase extends TestCase { private static Logger log = Logger.getLogger(LeaseIdentityTestCase.class); protected static long LEASE_PERIOD = 2000; protected static String LEASE_PERIOD_STRING = "2000"; private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected TestConnectionListener listener; 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 testDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, null); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "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"); // Test lease behavior. MicroRemoteClientInvoker clientInvoker = (MicroRemoteClientInvoker) client.getInvoker(); clientInvoker.terminateLease(client.getSessionId(), 0); TestLeasePinger leasePinger = new TestLeasePinger(clientInvoker, clientInvoker.getSessionId(), LEASE_PERIOD); leasePinger.setLeasePingerId(new GUID().toString()); leasePinger.addClient(client.getSessionId(), client.getConfiguration(), LEASE_PERIOD); leasePinger.startPing(); Thread.sleep(LEASE_PERIOD * 4); assertFalse(listener.called); leasePinger.stopPing(); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testClientConnectionIdentityFalse() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "false"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "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"); // Test lease behavior. MicroRemoteClientInvoker clientInvoker = (MicroRemoteClientInvoker) client.getInvoker(); clientInvoker.terminateLease(client.getSessionId(), 0); TestLeasePinger leasePinger = new TestLeasePinger(clientInvoker, clientInvoker.getSessionId(), LEASE_PERIOD); leasePinger.setLeasePingerId(new GUID().toString()); leasePinger.addClient(client.getSessionId(), client.getConfiguration(), LEASE_PERIOD); leasePinger.startPing(); Thread.sleep(LEASE_PERIOD * 4); assertFalse(listener.called); leasePinger.stopPing(); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testClientConnectionIdentityTrue() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "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"); // Test lease behavior. MicroRemoteClientInvoker clientInvoker = (MicroRemoteClientInvoker) client.getInvoker(); clientInvoker.terminateLease(client.getSessionId(), 0); TestLeasePinger leasePinger = new TestLeasePinger(clientInvoker, clientInvoker.getSessionId(), LEASE_PERIOD); leasePinger.setLeasePingerId(new GUID().toString()); leasePinger.addClient(client.getSessionId(), client.getConfiguration(), LEASE_PERIOD); leasePinger.startPing(); Thread.sleep(LEASE_PERIOD * 4); assertTrue(listener.called); assertNull(listener.throwable); leasePinger.stopPing(); 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(boolean setUseClientIdentity, String useClientIdentity) 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("leasePeriod", LEASE_PERIOD_STRING); if (setUseClientIdentity) { config.put(Remoting.USE_CLIENT_CONNECTION_IDENTITY, useClientIdentity); } addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); listener = new TestConnectionListener(); connector.addConnectionListener(listener); } 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 TestConnectionListener implements ConnectionListener { public boolean called; public Throwable throwable; public void handleConnectionException(Throwable throwable, Client client) { called = true; this.throwable = throwable; log.info("called: throwable = " + throwable); } } static class TestLeasePinger extends LeasePinger { public TestLeasePinger(ClientInvoker invoker, String invokerSessionID, long defaultLeasePeriod) { super(invoker, invokerSessionID, defaultLeasePeriod); } public void setLeasePingerId(String leasePingerId) { super.setLeasePingerId(leasePingerId); } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/identity/ConnectionIdentityTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/identity/Connecti0000644000175000017500000005203711413660476033527 0ustar twernertwerner/* * 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.connection.identity; import java.io.IOException; 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.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionValidator; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.LeasePinger; import org.jboss.remoting.MicroRemoteClientInvoker; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.socket.SocketClientInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** /** * Unit test for JBREM-1132. * * @author Ron Sigal * @version *

* Copyright May 08, 2009 *

*/ public class ConnectionIdentityTestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionIdentityTestCase.class); private static boolean firstTime = true; protected static final int LEASE_PERIOD = 2000; protected static final int VALIDATOR_PING_TIMEOUT = 1000; protected static final int VALIDATOR_PING_PERIOD = 2000; protected static final int PING_PERIODS_TO_WAIT = 2; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected TestConnectionListener serverConnectionListener; 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); } InvokerRegistry.registerInvokerFactories(getTransport(), TestClientFactory.class, TestServerFactory.class); } public void tearDown() { } public void testIdentityTrueOneClientRestarts() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "true"); clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, Integer.toString(VALIDATOR_PING_PERIOD)); clientConfig.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, Integer.toString(VALIDATOR_PING_TIMEOUT)); clientConfig.put(ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT, "0"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); TestConnectionListener clientConnectionListener = new TestConnectionListener("clientConnectionListener"); client.connect(clientConnectionListener, null); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger leasePinger1 = (LeasePinger) field.get(client.getInvoker()); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Test client side connection failure notifications. int wait = (PING_PERIODS_TO_WAIT + 1) * VALIDATOR_PING_PERIOD + VALIDATOR_PING_TIMEOUT + 2000; log.info(getName() + " going to sleep for " + wait + " ms"); Thread.sleep(wait); log.info("checking connection failure notifications"); assertEquals(1, clientConnectionListener.calledCounter); assertTrue(clientConnectionListener.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener.throwable.getMessage()); // Test server side connection failure notifications. wait = 2 * LEASE_PERIOD; log.info(getName() + " going to sleep for " + wait + " ms"); Thread.sleep(wait); assertEquals(1, serverConnectionListener.calledCounter); assertNull(serverConnectionListener.throwable); // Verify new LeasePinger is created if Client reconnects. client.connect(clientConnectionListener, null); assertNotSame(leasePinger1, field.get(client.getInvoker())); client.removeConnectionListener(clientConnectionListener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testIdentityTrueTwoClientsOneConnectionValidator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "true"); clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, Integer.toString(VALIDATOR_PING_PERIOD)); clientConfig.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, Integer.toString(VALIDATOR_PING_TIMEOUT)); clientConfig.put(ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT, "0"); addExtraClientConfig(clientConfig); Client client1 = new Client(clientLocator, clientConfig); TestConnectionListener clientConnectionListener1 = new TestConnectionListener("clientConnectionListener1"); client1.connect(clientConnectionListener1, null); Client client2 = new Client(clientLocator, clientConfig); TestConnectionListener clientConnectionListener2 = new TestConnectionListener("clientConnectionListener2"); client2.connect(clientConnectionListener2, null); log.info("clients are connected"); // Test connection. assertEquals("abc", client1.invoke("abc")); assertEquals("abc", client2.invoke("abc")); log.info("connections are good"); // Verify Clients share ConnectionValidator. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator connectionValidator1 = (ConnectionValidator) field.get(client1); ConnectionValidator connectionValidator2 = (ConnectionValidator) field.get(client2); assertSame(connectionValidator1, connectionValidator2); // Test client side connection failure notifications. int wait = (PING_PERIODS_TO_WAIT + 1) * VALIDATOR_PING_PERIOD + VALIDATOR_PING_TIMEOUT + 2000; log.info(getName() + " going to sleep for " + wait + " ms"); Thread.sleep(wait); log.info("checking connection failure notifications"); assertEquals(1, clientConnectionListener1.calledCounter); assertTrue(clientConnectionListener1.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener1.throwable.getMessage()); assertEquals(1, clientConnectionListener2.calledCounter); assertTrue(clientConnectionListener2.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener2.throwable.getMessage()); client1.removeConnectionListener(clientConnectionListener1); client1.disconnect(); client2.removeConnectionListener(clientConnectionListener2); client2.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testIdentityTrueTwoClientsTwoConnectionValidators() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "true"); clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, Integer.toString(VALIDATOR_PING_PERIOD)); clientConfig.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, Integer.toString(VALIDATOR_PING_TIMEOUT)); clientConfig.put(ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT, "0"); addExtraClientConfig(clientConfig); Client client1 = new Client(clientLocator, clientConfig); TestConnectionListener clientConnectionListener1 = new TestConnectionListener("clientConnectionListener1"); Map metadata = new HashMap(); metadata.put("abc", "xyz"); client1.connect(clientConnectionListener1, metadata); Client client2 = new Client(clientLocator, clientConfig); TestConnectionListener clientConnectionListener2 = new TestConnectionListener("clientConnectionListener2"); metadata.put("abc", "123"); client2.connect(clientConnectionListener2, metadata); log.info("clients are connected"); // Test connection. assertEquals("abc", client1.invoke("abc")); assertEquals("abc", client2.invoke("abc")); log.info("connections are good"); // Verify Clients have distinct ConnectionValidators. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator connectionValidator1 = (ConnectionValidator) field.get(client1); ConnectionValidator connectionValidator2 = (ConnectionValidator) field.get(client2); assertNotSame(connectionValidator1, connectionValidator2); // Test client side connection failure notifications. int wait = (PING_PERIODS_TO_WAIT + 1) * VALIDATOR_PING_PERIOD + VALIDATOR_PING_TIMEOUT + 2000; log.info(getName() + " going to sleep for " + wait + " ms"); Thread.sleep(wait); log.info("checking connection failure notifications"); assertEquals(1, clientConnectionListener1.calledCounter); assertTrue(clientConnectionListener1.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener1.throwable.getMessage()); assertEquals(1, clientConnectionListener2.calledCounter); assertTrue(clientConnectionListener2.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener2.throwable.getMessage()); client1.removeConnectionListener(clientConnectionListener1); client1.disconnect(); client2.removeConnectionListener(clientConnectionListener2); client2.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testIdentityTrueTwoClientsTwoConnectionValidatorsFourConnectionListeners() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "true"); clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, Integer.toString(VALIDATOR_PING_PERIOD)); clientConfig.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, Integer.toString(VALIDATOR_PING_TIMEOUT)); clientConfig.put(ConnectionValidator.FAILURE_DISCONNECT_TIMEOUT, "0"); addExtraClientConfig(clientConfig); Client client1 = new Client(clientLocator, clientConfig); TestConnectionListener clientConnectionListener1a = new TestConnectionListener("clientConnectionListener1a"); TestConnectionListener clientConnectionListener1b = new TestConnectionListener("clientConnectionListener1b"); Map metadata = new HashMap(); metadata.put("abc", "xyz"); client1.connect(clientConnectionListener1a, metadata); client1.addConnectionListener(clientConnectionListener1b); Client client2 = new Client(clientLocator, clientConfig); TestConnectionListener clientConnectionListener2a = new TestConnectionListener("clientConnectionListener2a"); TestConnectionListener clientConnectionListener2b = new TestConnectionListener("clientConnectionListener2b"); metadata.put("abc", "123"); client2.connect(clientConnectionListener2a, metadata); client2.addConnectionListener(clientConnectionListener2b); log.info("clients are connected"); // Test connection. assertEquals("abc", client1.invoke("abc")); assertEquals("abc", client2.invoke("abc")); log.info("connections are good"); // Verify Clients have distinct ConnectionValidators. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator connectionValidator1 = (ConnectionValidator) field.get(client1); ConnectionValidator connectionValidator2 = (ConnectionValidator) field.get(client2); assertNotSame(connectionValidator1, connectionValidator2); // Test client side connection failure notifications. int wait = (PING_PERIODS_TO_WAIT + 1) * VALIDATOR_PING_PERIOD + VALIDATOR_PING_TIMEOUT + 2000; log.info(getName() + " going to sleep for " + wait + " ms"); Thread.sleep(wait); log.info("checking connection failure notifications"); assertEquals(1, clientConnectionListener1a.calledCounter); assertTrue(clientConnectionListener1a.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener1a.throwable.getMessage()); assertEquals(1, clientConnectionListener1b.calledCounter); assertTrue(clientConnectionListener1b.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener1b.throwable.getMessage()); assertEquals(1, clientConnectionListener2a.calledCounter); assertTrue(clientConnectionListener2a.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener2a.throwable.getMessage()); assertEquals(1, clientConnectionListener2b.calledCounter); assertTrue(clientConnectionListener2b.throwable instanceof Exception); assertEquals("Could not connect to server!", clientConnectionListener2b.throwable.getMessage()); client1.removeConnectionListener(clientConnectionListener1a); client1.removeConnectionListener(clientConnectionListener1b); client1.disconnect(); client2.removeConnectionListener(clientConnectionListener2a); client2.removeConnectionListener(clientConnectionListener2b); client2.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "test"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean addUseClientConnectionIdentity, String useClientConnectionIdentity) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port + "/?x=x"; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "&" + metadata; } if (addUseClientConnectionIdentity) { locatorURI += "&" + Remoting.USE_CLIENT_CONNECTION_IDENTITY + "=" + useClientConnectionIdentity; } 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.setLeasePeriod(LEASE_PERIOD); serverConnectionListener = new TestConnectionListener("serverConnectionListener"); connector.addConnectionListener(serverConnectionListener); 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 TestConnectionListener implements ConnectionListener { String name; Throwable throwable; int calledCounter; public TestConnectionListener(String name) { this.name = name; } public void handleConnectionException(Throwable throwable, Client client) { calledCounter++; this.throwable = throwable; log.info(name + " notified: throwable = " + throwable); } } static class TestServerInvoker extends SocketServerInvoker { int counter; public TestServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public TestServerInvoker(InvokerLocator locator) { super(locator); } public Object invoke(InvocationRequest invocation) throws Throwable { Object param = invocation.getParameter(); // log.info("TestServerInvoker.invoke() entered: " + param); if ("$PING$".equals(param)) { Map metadata = invocation.getRequestPayload(); if (metadata != null) { // log.info("metadata: " + metadata); String invokerSessionId = (String) metadata.get(INVOKER_SESSION_ID); if (invokerSessionId != null) { log.info(this + " got a ConnectionValidator $PING$"); if (++counter > PING_PERIODS_TO_WAIT) { int wait = 2 * VALIDATOR_PING_TIMEOUT; log.info(this + " going to sleep for " + wait + " ms"); Thread.sleep(wait); } } } } return super.invoke(invocation); } public String toString() { String s = super.toString(); int i = s.indexOf('['); return "TestServerInvoker" + s.substring(i); } } public static class TestClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { log.info("TestClientFaotory.createClientInvoker() called"); return new SocketClientInvoker(locator, config); } public boolean supportsSSL() { return false; } } public static class TestServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException { log.info("TestServerFactory.createServerInvoker() called"); return new TestServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/params/0000755000175000017500000000000011632407031031452 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/params/ConnectionValidatorConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/params/Connection0000644000175000017500000005742111413660476033520 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, 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.connection.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.logging.XLevel; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionValidator; 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 test for JBREM-1082. * * @author Ron Sigal * @version *

* Copyright Jan 17, 2009 *

*/ public class ConnectionValidatorConfigurationTestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionValidatorConfigurationTestCase.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 testUseLocatorParamsDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("validatorPingPeriod", "333"); clientConfig.put("validatorPingTimeout", "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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); HashMap metadata = new HashMap(); metadata.put("validatorPingTimeout", "555"); client.addConnectionListener(listener, metadata); // Test setting of parameters in ConnectionListener. doTestParameters(client, 333, 555, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseLocatorParamsFalseInLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false"; clientLocatorURI += "&" + Client.USE_ALL_PARAMS + "=false"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("validatorPingPeriod", "333"); clientConfig.put("validatorPingTimeout", "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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); HashMap metadata = new HashMap(); metadata.put("validatorPingTimeout", "555"); client.addConnectionListener(listener, metadata); // Test setting of parameters in ConnectionListener. doTestParameters(client, 333, 555, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseLocatorParamsFalseInConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("validatorPingPeriod", "333"); clientConfig.put("validatorPingTimeout", "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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); HashMap metadata = new HashMap(); metadata.put("validatorPingTimeout", "555"); client.addConnectionListener(listener, metadata); // Test setting of parameters in ConnectionListener. doTestParameters(client, 333, 555, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseLocatorParamsFalseInMetadata() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("validatorPingPeriod", "333"); clientConfig.put("validatorPingTimeout", "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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); HashMap metadata = new HashMap(); metadata.put("validatorPingTimeout", "555"); metadata.put(Client.USE_ALL_PARAMS, "false"); client.addConnectionListener(listener, metadata); // Test setting of parameters in ConnectionListener. doTestParameters(client, 333, 555, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseLocatorParamsTrueInLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false"; clientLocatorURI += "&" + Client.USE_ALL_PARAMS + "=true"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("validatorPingPeriod", "333"); clientConfig.put("validatorPingTimeout", "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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); HashMap metadata = new HashMap(); metadata.put("validatorPingTimeout", "555"); client.addConnectionListener(listener, metadata); // Test setting of parameters in ConnectionListener. doTestParameters(client, 333, 555, false); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseLocatorParamsTrueInConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("validatorPingPeriod", "333"); clientConfig.put("validatorPingTimeout", "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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); HashMap metadata = new HashMap(); metadata.put("validatorPingTimeout", "555"); client.addConnectionListener(listener, metadata); // Test setting of parameters in ConnectionListener. doTestParameters(client, 333, 555, false); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseLocatorParamsTrueInMetadata() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("validatorPingPeriod", "333"); clientConfig.put("validatorPingTimeout", "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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); HashMap metadata = new HashMap(); metadata.put("validatorPingTimeout", "555"); metadata.put(Client.USE_ALL_PARAMS, "true"); client.addConnectionListener(listener, metadata); // Test setting of parameters in ConnectionListener. doTestParameters(client, 333, 555, false); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseLocatorParamsTrueInLocatorAllParamsInLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false"; clientLocatorURI += "&" + Client.USE_ALL_PARAMS + "=true"; 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(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); HashMap metadata = new HashMap(); client.addConnectionListener(listener, metadata); // Test setting of parameters in ConnectionListener. doTestParameters(client, 111, 222, false); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testExplicitPingPeriodOverridesLocatorAndConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.USE_ALL_PARAMS, "true"); clientConfig.put("validatorPingPeriod", "222"); 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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, 333); // Test setting of parameters in ConnectionListener. doTestParameters(client, 333, 1000, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUnaryLocatorOverridesWithUseAllParams() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); 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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener); // Test setting of parameters in ConnectionListener. doTestParameters(client, 111, 1000, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUnaryLocatorDoesntOverrideWithoutUseAllParams() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&validatorPingPeriod=111"; 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(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener); // Test setting of parameters in ConnectionListener. doTestParameters(client, 2000, 1000, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUnaryConfigOverrides() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("validatorPingPeriod", "111"); 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 ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener); // Test setting of parameters in ConnectionListener. doTestParameters(client, 111, 1000, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUnaryDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; 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(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Configure ConnectionListener. TestConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener); // Test setting of parameters in ConnectionListener. doTestParameters(client, 2000, 1000, true); client.removeConnectionListener(listener); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected void doTestParameters(Client client, int pingPeriodExpected, int pingTimeoutExpected, boolean tieToLeaseExpected) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long)field.get(validator)).longValue(); field = ConnectionValidator.class.getDeclaredField("pingTimeout"); field.setAccessible(true); int pingTimeout = ((Integer) field.get(validator)).intValue(); field = ConnectionValidator.class.getDeclaredField("tieToLease"); field.setAccessible(true); boolean tieToLease = ((Boolean) field.get(validator)).booleanValue(); log.info("pingPeriod: " + pingPeriod); log.info("pingTimeout: " + pingTimeout); log.info("tieToLease: " + tieToLease); assertEquals(pingPeriodExpected, pingPeriod); assertEquals(pingTimeoutExpected, pingTimeout); assertEquals(tieToLeaseExpected, tieToLease); } 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 TestConnectionListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorConfigTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000000732610634675726033551 0ustar twernertwerner/* * 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.connection; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import org.apache.log4j.Logger; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; 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; /** * * @author Ron Sigal * @version $Revision: 2473 $ *

* Copyright Jun 15, 2007 *

*/ public class ConnectionValidatorConfigTestServer extends ServerTestCase { public static String serverLocatorURI = "socket://localhost:7887"; private static Logger log = Logger.getLogger(ConnectionValidatorConfigTestServer.class); // remoting server connector private Connector connector; /** * Sets up target remoting server. */ public void setUp() throws Exception { // Start server. InvokerLocator serverLocator = new InvokerLocator(serverLocatorURI); log.info("Starting remoting server with locator uri of: " + serverLocator); HashMap config = new HashMap(); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); ServerInvocationHandler invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } public void tearDown() { if (connector != null) connector.stop(); } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} public static void main(String[] args) { try { ConnectionValidatorConfigTestServer server = new ConnectionValidatorConfigTestServer(); server.setUp(); Thread.sleep(60000); server.shutdown(); } catch (Throwable t) { t.printStackTrace(); } } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) {return invocation.getParameter();} public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestConnectionListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) {} } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorConfigTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/connection/ConnectionValidat0000644000175000017500000011627611114114066033531 0ustar twernertwerner/* * 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.connection; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.AbstractInvoker; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionValidator; 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.socket.MicroSocketClientInvoker; /** * * @author Ron Sigal * @version $Revision: 4742 $ *

* Copyright Jun 15, 2007 *

*/ public class ConnectionValidatorConfigTestClient extends TestCase { public static int port; private static Logger log = Logger.getLogger(ConnectionValidatorConfigTestClient.class); private static boolean firstTime = true; private static InvokerLocator serverLocator; /** * Sets up target remoting server. */ public void setUp() throws Exception { if (firstTime) { firstTime = false; serverLocator = new InvokerLocator(ConnectionValidatorConfigTestServer.serverLocatorURI); } } public void tearDown() { } /** * Verifies that the default values are set correctly if a call is made to * Client.addConnectionListener(ConnectionListener listener). */ public void testDefaultConfig() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that pingPeriod is set correctly if a call is made to * Client.addConnectionListener(ConnectionListener listener, int pingPeriod). */ public void testSetPingPeriod() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, 3456); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(3456, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that pingPeriod is set correctly if it appears in Client * configuration map but Client.addConnectionListener(ConnectionListener listener) * puts default value in metadata map. */ public void testSetPingPeriodByClientConfigUsingSingleArgMethod() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "3468"); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(3468, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that pingPeriod is set correctly if it appears in Client * configuration map. */ public void testSetPingPeriodByClientConfig() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "3468"); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(3468, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that pingPeriod is set correctly if a call is made to * Client.addConnectionListener(ConnectionListener listener, Map metadata). */ public void testSetPingPeriodByMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "3467"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(3467, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that pingPeriod is set correctly if it appears in both Client * configuration map and metadata map. */ public void testSetPingPeriodByClientConfigAndMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "3413"); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "3414"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(3414, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that timeout is set correctly if it is set in Client * configuration map. */ public void testSetTimeoutByClientConfig() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); clientConfig.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "3546"); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals("3546", o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that "timeout" in Client configuration map and metadata is ignored. */ public void testDefaultTimeoutWithStandardTimeoutInClientConfig() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); clientConfig.put(ServerInvoker.TIMEOUT, ConnectionValidator.DEFAULT_PING_TIMEOUT + "0"); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, ConnectionValidator.DEFAULT_PING_TIMEOUT + "1"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that timeout is set correctly if a call is made to * Client.addConnectionListener(ConnectionListener listener, Map metadata). */ public void testSetTimeoutByMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "3478"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals("3478", o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that timeout is set correctly if "validatorPingTimeout" appears in * both Client configuration map and metadata map. */ public void testSetTimeoutByClientConfigAndMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); clientConfig.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "3167"); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "3168"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals("3168", o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that number of ping retries is set correctly if it appears in * Client configuratin map. */ public void testSetPingRetriesClientConfig() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put("NumberOfCallRetries", "13"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; assertEquals(13, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that number of ping retries is set correctly if a call is made to * Client.addConnectionListener(ConnectionListener listener, Map metadata). */ public void testSetPingRetriesByMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put("NumberOfCallRetries", "7"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; assertEquals(7, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that number of ping retries is set correctly if it appears in both * Client configuration map and metadata. */ public void testSetPingRetriesByClientConfigAndMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put("NumberOfCallRetries", "17"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put("NumberOfCallRetries", "19"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; assertEquals(19, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that number of connection retries is set correctly if it appears * in Client configuration map. */ public void testSetConnectionRetriesByClientConfig() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put("NumberOfRetries", "21"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that number of connection retries is set correctly if a call is made to * Client.addConnectionListener(ConnectionListener listener, Map metadata). */ public void testSetConnectionRetriesByMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put("NumberOfRetries", "27"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that number of connection retries is set correctly if it appears * in Client configuration map. */ public void testSetConnectionRetriesByClientConfigAndMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put("NumberOfRetries", "31"); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put("NumberOfRetries", "33"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); client.disconnect(); } /** * Verifies that other parameters may be set by passing in metadata map. */ public void testOtherParamsByMetadata() throws Throwable { log.info("entering " + getName()); // Create client. HashMap clientConfig = new HashMap(); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); // Add connection listener. Map metadata = new HashMap(); metadata.put("ReuseAddress", "false"); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener, metadata); // Test pingPeriod. Field field = Client.class.getDeclaredField("connectionValidator"); field.setAccessible(true); ConnectionValidator validator = (ConnectionValidator) field.get(client); field = ConnectionValidator.class.getDeclaredField("pingPeriod"); field.setAccessible(true); long pingPeriod = ((Long) field.get(validator)).longValue(); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, pingPeriod); // Test timeout. field = ConnectionValidator.class.getDeclaredField("clientInvoker"); field.setAccessible(true); AbstractInvoker invoker = (AbstractInvoker) field.get(validator); field = AbstractInvoker.class.getDeclaredField("configuration"); field.setAccessible(true); Map config = (Map) field.get(invoker); Object o = config.get(ServerInvoker.TIMEOUT); assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o); // Test ping retries. assertTrue(invoker instanceof MicroSocketClientInvoker); MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker; int defaultPingRetries = Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES); assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries()); // Test ReuseAddress. assertFalse(socketInvoker.getReuseAddress()); client.disconnect(); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) {return invocation.getParameter();} public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestConnectionListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) {} } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/multihome/0000755000175000017500000000000011632407032030034 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/multihome/XmlMultihomeConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/multihome/XmlMultihomeConfig0000644000175000017500000002763711413660476033562 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.multihome; import java.io.ByteArrayInputStream; import javax.xml.parsers.DocumentBuilderFactory; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.transport.Connector; import org.w3c.dom.Document; /** * Unit tests for JBREM-983. * * @author Ron Sigal * @version $Revision: 3873 $ *

* Copyright (c) Jun 13, 2006 *

*/ public class XmlMultihomeConfigTestCase extends TestCase { protected static Logger log = Logger.getLogger(XmlMultihomeConfigTestCase.class); protected static boolean firstTime = true; protected String getTransport() { return "socket"; } public void setUp() { } public void testXmlConfigOneHome() throws Throwable { Connector connector = new Connector(); // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" "); buf.append(" host2:2222"); buf.append(" "); buf.append(" a/b"); buf.append(" 1000"); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); String createdURI = connector.getInvokerLocator(); log.info("created InvokerLocator: " + createdURI); String expectedURI = "socket://multihome/a/b/?"; expectedURI += "homes=host2:2222&"; expectedURI += "timeout=1000"; log.info("expected InvokerLocator: " + expectedURI); assertEquals(expectedURI, createdURI); log.info(getName() + " PASSES"); } public void testXmlConfigThreeHomes() throws Throwable { Connector connector = new Connector(); // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" "); buf.append(" host2:2222"); buf.append(" host3:3333"); buf.append(" host4:4444"); buf.append(" "); buf.append(" a/b"); buf.append(" 1000"); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); String createdURI = connector.getInvokerLocator(); log.info("created InvokerLocator: " + createdURI); String expectedURI = "socket://multihome/a/b/?"; expectedURI += "homes=host2:2222!host3:3333!host4:4444&"; expectedURI += "timeout=1000"; log.info("expected InvokerLocator: " + expectedURI); assertEquals(expectedURI, createdURI); log.info(getName() + " PASSES"); } public void testXmlConfigWithConnectHomes() throws Throwable { Connector connector = new Connector(); // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" "); buf.append(" host2:2222"); buf.append(" host3:3333"); buf.append(" "); buf.append(" "); buf.append(" host4:4444"); buf.append(" host5:5555"); buf.append(" "); buf.append(" a/b"); buf.append(" 1000"); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); String createdURI = connector.getInvokerLocator(); log.info("created InvokerLocator: " + createdURI); String expectedURI = "socket://multihome/a/b/?"; expectedURI += "connecthomes=host4:4444!host5:5555&"; expectedURI += "homes=host2:2222!host3:3333&"; expectedURI += "timeout=1000"; log.info("expected InvokerLocator: " + expectedURI); assertEquals(expectedURI, createdURI); log.info(getName() + " PASSES"); } public void testXmlConfigWithServerBindPort() throws Throwable { Connector connector = new Connector(); // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" host1"); buf.append(" 1111"); buf.append(" "); buf.append(" host2:2222"); buf.append(" host3"); buf.append(" "); buf.append(" "); buf.append(" host4"); buf.append(" host5:5555"); buf.append(" "); buf.append(" a/b"); buf.append(" 1000"); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); String createdURI = connector.getInvokerLocator(); log.info("created InvokerLocator: " + createdURI); String expectedURI = "socket://multihome:1111/a/b/?"; expectedURI += "connecthomes=host4:1111!host5:5555&"; expectedURI += "homes=host2:2222!host3:1111&"; expectedURI += "timeout=1000"; log.info("expected InvokerLocator: " + expectedURI); assertEquals(expectedURI, createdURI); log.info(getName() + " PASSES"); } public void testXmlConfigWithClientConnectPort() throws Throwable { Connector connector = new Connector(); // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" host1"); buf.append(" 1111"); buf.append(" host2"); buf.append(" 2222"); buf.append(" "); buf.append(" host3:3333"); buf.append(" host4"); buf.append(" "); buf.append(" "); buf.append(" host5"); buf.append(" host6:6666"); buf.append(" "); buf.append(" a/b"); buf.append(" 1000"); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); String createdURI = connector.getInvokerLocator(); log.info("created InvokerLocator: " + createdURI); String expectedURI = "socket://multihome:2222/a/b/?"; expectedURI += "connecthomes=host5:2222!host6:6666&"; expectedURI += "homes=host3:3333!host4:2222&"; expectedURI += "timeout=1000"; log.info("expected InvokerLocator: " + expectedURI); assertEquals(expectedURI, createdURI); log.info(getName() + " PASSES"); } public void testXmlConfigWithConnectHomesAndNoHomes() throws Throwable { Connector connector = new Connector(); // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" "); buf.append(" host5"); buf.append(" host6:6666"); buf.append(" "); buf.append(" a/b"); buf.append(" 1000"); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); try { log.info("================= EXCEPTION EXPECTED ================"); connector.create(); fail("Should have gotten IllegalStateException"); } catch (IllegalStateException e) { String msg = "Error configuring invoker for connector. Can not continue without invoker."; assertEquals("unexpected message", msg, e.getMessage()); log.info("got expected IllegalStateException"); log.info("======================================================"); } log.info(getName() + " PASSES"); } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/multihome/MultihomeTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/multihome/MultihomeTestParen0000644000175000017500000002363411413660476033572 0ustar twernertwerner/* * 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.multihome; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Enumeration; 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.Home; 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.AddressUtil; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; public abstract class MultihomeTestParent extends TestCase { protected static Logger log = Logger.getLogger(MultihomeTestParent.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 testConnectToEachHome() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); Iterator it = serverLocator.getConnectHomeList().iterator(); while (it.hasNext()) { // Create client. Home h = (Home) it.next(); String path = serverLocator.getPath(); Map parameters = serverLocator.getParameters(); InvokerLocator clientLocator = new InvokerLocator(getTransport(), h.host, h.port, path, parameters); log.info("locator: " + clientLocator); 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 " + clientLocator); // Test invocations. assertEquals("abc", client.invoke("abc")); log.info("invocation successful"); // Test callbacks. Map metadata = new HashMap(); addExtraCallbackConfig(metadata); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, metadata, null, true); assertTrue(callbackHandler.ok); log.info("callback successful"); client.removeListener(callbackHandler); client.disconnect(); } shutdownServer(); log.info(getName() + " PASSES"); } public void testConnectToAnyHome() 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 " + clientLocator); // Test ivocations. assertEquals("abc", client.invoke("abc")); log.info("invocation successful"); // Test callbacks. Map metadata = new HashMap(); addExtraCallbackConfig(metadata); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, metadata, null, true); assertTrue(callbackHandler.ok); log.info("callback successful"); client.removeListener(callbackHandler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testInvocationHandlersAreShared() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); List homes = serverLocator.getConnectHomeList(); for (int i = 0; i < homes.size(); i++) { // Create client. Home h = (Home) homes.get(i); String path = serverLocator.getPath(); Map parameters = serverLocator.getParameters(); InvokerLocator clientLocator = new InvokerLocator(getTransport(), h.host, h.port, path, parameters); log.info("locator: " + clientLocator); 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 " + clientLocator); if (i == 0) client.invoke("reset"); // Test invocations. assertEquals("count", client.invoke("count")); log.info("invocation successful"); // Test callbacks. Map metadata = new HashMap(); addExtraCallbackConfig(metadata); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, metadata, null, true); assertTrue(callbackHandler.ok); log.info("callback successful"); // Verify that a single ServerInvocationHandler handles invocation // for all interfaces. Integer counter = (Integer) client.invoke("getCounter"); assertEquals(i + 1, counter.intValue()); client.removeListener(callbackHandler); client.disconnect(); } shutdownServer(); log.info(getName() + " PASSES"); } protected abstract String getTransport(); protected String getPath() {return "";} protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void addExtraCallbackConfig(Map config) {} protected void setupServer() throws Exception { StringBuffer sb = new StringBuffer(); Enumeration e1 = NetworkInterface.getNetworkInterfaces(); boolean first = true; int counter = 0; loop: while (e1.hasMoreElements()) { NetworkInterface iface = (NetworkInterface) e1.nextElement(); Enumeration e2 = iface.getInetAddresses(); while (e2.hasMoreElements()) { InetAddress address = (InetAddress) e2.nextElement(); String host = address.getHostAddress(); if (host.indexOf(':') != host.lastIndexOf(':')) host = "[" + host + "]"; if (AddressUtil.checkAddress(host)) { log.info("host is functional: " + host); int port = PortUtil.findFreePort(host); if (first) first = false; else sb.append('!'); sb.append(host).append(':').append(port); if (++counter > 10) break loop; } else { log.info("skipping host: " + host); } } } locatorURI = getTransport() + "://" + InvokerLocator.MULTIHOME + getPath() + "/?"; locatorURI += InvokerLocator.HOMES_KEY + "=" + sb.toString() + "&"; locatorURI += InvokerLocator.CONNECT_HOMES_KEY + "=" + sb.toString(); 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 TestCallbackHandler implements InvokerCallbackHandler { boolean ok; public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); ok = true; } } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/multihome/TestInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/multihome/TestInvocationHand0000644000175000017500000000500611413660476033536 0ustar twernertwerner /* * 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.multihome; import javax.management.MBeanServer; 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.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jan 14, 2008 *

*/ public class TestInvocationHandler implements ServerInvocationHandler { private Logger log = Logger.getLogger(TestInvocationHandler.class); private int counter; public void addListener(InvokerCallbackHandler callbackHandler) { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("Error in handleCallback()", e); } } public Object invoke(final InvocationRequest invocation) throws Throwable { if ("reset".equals(invocation.getParameter())) counter = 0; if ("count".equals(invocation.getParameter())) counter++; if ("getCounter".equals(invocation.getParameter())) return new Integer(counter); 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/security/0000755000175000017500000000000011632407044027703 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/CallbackStoreProxyTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/CallbackStoreProxyT0000644000175000017500000002213711413660476033541 0ustar twernertwerner/* * 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.security; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; 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; /** * Unit test for JBREM-977. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 4, 2008 *

*/ public class CallbackStoreProxyTestCase extends TestCase { private static Logger log = Logger.getLogger(CallbackStoreProxyTestCase.class); private static boolean firstTime = true; private static boolean done; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected TestCallbackStore callbackStore; protected MBeanServer server; protected ObjectName callbackStoreObjectName; 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 testCallbackStoreProxy() 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"); // Setup pull callbacks. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler); if (!done) { synchronized (CallbackStoreProxyTestCase.class) { long start = System.currentTimeMillis(); while (true) { try { log.info("testCallbackStoreProxy() waiting for notification"); CallbackStoreProxyTestCase.class.wait(60000 - (System.currentTimeMillis() - start)); log.info("testCallbackStoreProxy() received notification"); break; } catch (InterruptedException e) { log.info("interrupted", e); } } } } // Verify TestCallbackStore got one callback. // assertEquals(1, client.getCallbacks(callbackHandler).size()); int count = ((Integer)server.invoke(callbackStoreObjectName, "size", new Object[]{}, new String[]{})).intValue(); assertEquals(1, count); 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; 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("callbackMemCeiling", "80"); // Create CallbackStore. server = MBeanServerFactory.createMBeanServer(); TestCallbackStore callbackStore = new TestCallbackStore(); String objectNameString = "test:type=Callbackstore"; callbackStoreObjectName = new ObjectName(objectNameString); server.registerMBean(callbackStore, callbackStoreObjectName); config.put(ServerInvokerCallbackHandler.CALLBACK_STORE_KEY, objectNameString); addExtraServerConfig(config); connector = new Connector(serverLocator, config); server.registerMBean(connector, new ObjectName("test:type=Connector")); 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) { ((ServerInvokerCallbackHandler) callbackHandler).setShouldPersist(true); TestCallbackThread callbackThread = new TestCallbackThread(callbackHandler); callbackThread.start(); synchronized (TestCallbackStore.class) { long start = System.currentTimeMillis(); while (true) { try { TestCallbackStore.class.wait(60000 - (System.currentTimeMillis() - start)); break; } catch (InterruptedException e) { log.info("interrupted", e); } } } callbackThread.shutdown(); log.info("addListener() received notification"); done = true; synchronized (CallbackStoreProxyTestCase.class) { CallbackStoreProxyTestCase.class.notifyAll(); } } 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 TestCallbackThread extends Thread { private boolean running = true; private InvokerCallbackHandler callbackHandler; private Callback callback = new Callback(new byte[100]); public TestCallbackThread(InvokerCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } public void shutdown() { running = false; } public void run() { while (running) { try { callbackHandler.handleCallback(callback); } catch (Exception e) { log.error("Error", e); return; } } log.info("shutting down"); } } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/ServerSocketFactoryProxyTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/ServerSocketFactory0000644000175000017500000001617111413660476033612 0ustar twernertwerner/* * 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.security; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; 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.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; /** * Unit test for JBREM-977. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 4, 2008 *

*/ public class ServerSocketFactoryProxyTestCase extends TestCase { private static Logger log = Logger.getLogger(ServerSocketFactoryProxyTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected MBeanServer server; protected ObjectName factoryObjectName; protected TestServerSocketFactory ssf; 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 testServerSocketFactoryProxy() 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(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(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "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"); // Verify handler proxy gets used. log.info("ssf counter: " + ssf.counter); assertTrue(ssf.counter > 0); int counter = ((Integer) server.getAttribute(factoryObjectName, "Counter")).intValue(); assertEquals(ssf.counter, counter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "https"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { // Set up SSLServerSocketFactory MBean. HashMap sslConfig = new HashMap(); sslConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getClass().getResource("keystore").getFile(); sslConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sslConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); sslConfig.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SSLSocketBuilder(sslConfig); builder.setUseSSLServerSocketFactory(false); ssf = new TestServerSocketFactory(); ssf.setSSLSocketBuilder(builder); ssf.start(); server = MBeanServerFactory.createMBeanServer(); String objectNameString = "test:type=SSLServerSocketFactoryService"; factoryObjectName = new ObjectName(objectNameString); server.registerMBean(ssf, factoryObjectName); // Create Connector. 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"); config.put(ServerInvoker.SERVER_SOCKET_FACTORY, objectNameString); addExtraServerConfig(config); connector = new Connector(serverLocator, config); server.registerMBean(connector, new ObjectName("test:type=Connector")); connector.create(); TestServerInvocationHandler invocationHandler = new TestServerInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } public static class TestServerInvocationHandler 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) {} } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/NetworkRegistryProxyTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/NetworkRegistryProx0000644000175000017500000001404411413660476033673 0ustar twernertwerner/* * 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.security; import java.io.ByteArrayInputStream; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; 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.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.detection.multicast.MulticastDetector; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.w3c.dom.Document; /** * Unit test for JBREM-977. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 4, 2008 *

*/ public class NetworkRegistryProxyTestCase extends TestCase { private static Logger log = Logger.getLogger(NetworkRegistryProxyTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected MBeanServer server; protected int numAdded; protected int numUpdated; 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 testNetworkRegistryProxy() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Start registry. MBeanServer server = MBeanServerFactory.createMBeanServer(); InvokerLocator locator = new InvokerLocator(locatorURI); TestNetworkRegistry networkRegistry = new TestNetworkRegistry(locator); ObjectName name = new ObjectName("test:type=TestNetworkRegistry"); server.registerMBean(networkRegistry, name); // Create detector and tell it to register local Connectors. MulticastDetector detector = new MulticastDetector(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); detector.setConfiguration(xml.getDocumentElement()); server.registerMBean(detector, new ObjectName("test:type=MulticastDetector")); detector.start(); // Verify that TestNetworkRegistry proxy gets used. detector.forceDetection(); assertEquals(1, networkRegistry.counter); int counter = ((Integer) server.getAttribute(name, "Counter")).intValue(); assertEquals(networkRegistry.counter, counter); detector.stop(); server.unregisterMBean(name); 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(); connector.addInvocationHandler("test", new TestServerInvocationHandler()); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } public static class TestServerInvocationHandler 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) {} } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestCallbackStoreMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestCallbackStoreMB0000644000175000017500000000221711413660476033427 0ustar twernertwerner /* * 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.security; import org.jboss.remoting.callback.CallbackStoreMBean; public interface TestCallbackStoreMBean extends CallbackStoreMBean { } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestServerSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestServerSocketFac0000644000175000017500000000513511413660476033532 0ustar twernertwerner /* * 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.security; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import org.apache.log4j.Logger; import org.jboss.remoting.security.SSLServerSocketFactoryService; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 7, 2008 *

*/ public class TestServerSocketFactory extends SSLServerSocketFactoryService implements TestServerSocketFactoryMBean { private static Logger log = Logger.getLogger(TestServerSocketFactory.class); int counter; public ServerSocket createServerSocket() throws IOException { counter++; log.info("createServerSocket()"); return super.createServerSocket(); } public ServerSocket createServerSocket( int port ) throws IOException { counter++; log.info("createServerSocket(port)"); return super.createServerSocket(port); } public ServerSocket createServerSocket( int port, int backlog ) throws IOException { counter++; log.info("createServerSocket(port, backlog)"); return super.createServerSocket(port, backlog); } public ServerSocket createServerSocket( int port, int backlog, InetAddress ifAddress ) throws IOException { counter++; log.info("createServerSocket(port, backlog, ifAddress)"); return super.createServerSocket(port, backlog, ifAddress); } public int getCounter() { return counter; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/InvokerRegistryCaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/InvokerRegistryCall0000644000175000017500000000670011413671134033573 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * * Copyright 2010, Red Hat Middleware LLC, and individual contributors * by the @author tags. 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.security; import java.util.Map; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; /** * Used by InvokerRegistrySecurityTestCase. * * @author Ron Sigal * @version $Rev$ *

* Copyright Jul 1, 2010 *

*/ public class InvokerRegistryCaller { public static void registerInvokerFactories(String transport, Class clientFactory, Class serverFactory) { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.registerInvokerFactories(transport, clientFactory, serverFactory); } public static void unregisterInvokerFactories(String transport) { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.unregisterInvokerFactories(transport); } public static void unregisterLocator(InvokerLocator locator) { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.unregisterLocator(locator); } public static void destroyClientInvoker(InvokerLocator locator, Map map) { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.destroyClientInvoker(locator, map); } public static void createClientInvoker(InvokerLocator locator, Map map) throws Exception { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.createClientInvoker(locator, map); } public static void createServerInvoker(InvokerLocator locator, Map map) throws Exception { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.createServerInvoker(locator, map); } public static void destroyServerInvoker(ServerInvoker invoker) throws Exception { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.destroyServerInvoker(invoker); } public static void updateServerInvokerLocator(InvokerLocator locator, InvokerLocator newLocator) { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.updateServerInvokerLocator(locator, newLocator); } public static void isSSLSupported(String transport) throws Exception { new Exception("InvokerRegistryCaller stacktrace").printStackTrace(); InvokerRegistry.isSSLSupported(transport); } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestServerInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestServerInvocatio0000644000175000017500000000365511413660476033630 0ustar twernertwerner /* * 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.security; import javax.management.MBeanServer; import org.apache.log4j.Logger; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; public class TestServerInvocationHandler implements TestServerInvocationHandlerMBean { static Logger log = Logger.getLogger(TestServerInvocationHandler.class); int counter; public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { counter++; log.info("ServerInvocationHandler processing invocation"); return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public int getCounter() { return counter; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestNetworkRegistryMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestNetworkRegistry0000644000175000017500000000246311413660476033664 0ustar twernertwerner /* * 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.security; import org.jboss.remoting.network.NetworkRegistryMBean; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 6, 2008 *

*/ public interface TestNetworkRegistryMBean extends NetworkRegistryMBean { public int getCounter(); } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/InvokerRegistrySecurityTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/InvokerRegistrySecu0000755000175000017500000002717511413671134033633 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2010, 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.security; import java.io.IOException; import java.util.HashMap; import java.util.Map; 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.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.socket.SocketClientInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; public class InvokerRegistrySecurityTestCase extends TestCase { private static Logger log = Logger.getLogger(InvokerRegistrySecurityTestCase.class); private static boolean firstTime = true; 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 testRegisterUnregisterInvokerFactories() throws Throwable { log.info("entering " + getName()); // Call from code with proper privileges. InvokerRegistry.registerInvokerFactories("test", TestClientFactory.class, TestServerFactory.class); InvokerRegistry.unregisterInvokerFactories("test"); // Call from code without proper privileges. if (System.getSecurityManager() == null) { InvokerRegistryCaller.registerInvokerFactories("test", TestClientFactory.class, TestServerFactory.class); InvokerRegistryCaller.unregisterInvokerFactories("test"); } else { try { InvokerRegistryCaller.registerInvokerFactories("test", TestClientFactory.class, TestServerFactory.class); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } try { InvokerRegistryCaller.unregisterInvokerFactories("test"); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } } log.info(getName() + " PASSES"); } public void testUnregisterLocator() throws Throwable { log.info("entering " + getName()); Connector connector = null; try { // Create server, which stores InvokerLocator in InvokerRegistry. InvokerLocator locator = new InvokerLocator("socket://localhost"); connector = new Connector(locator); connector.start(); InvokerLocator updatedLocator = connector.getLocator(); // Call from code with proper privileges. InvokerRegistry.unregisterLocator(updatedLocator); // Call from code without proper privileges. if (System.getSecurityManager() == null) { InvokerRegistryCaller.unregisterLocator(updatedLocator); } else { try { InvokerRegistryCaller.unregisterLocator(updatedLocator); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } } } finally { if (connector != null) { connector.stop(); } } log.info(getName() + " PASSES"); } public void testDestroyClientInvoker() throws Throwable { log.info("entering " + getName()); Client client = null; try { // Create client. InvokerLocator locator = new InvokerLocator("socket://localhost"); client = new Client(locator); client.connect(); // Call from code with proper privileges. InvokerRegistry.destroyClientInvoker(locator, new HashMap()); // Call from code without proper privileges. if (System.getSecurityManager() == null) { InvokerRegistryCaller.destroyClientInvoker(locator, new HashMap()); } else { try { InvokerRegistryCaller.destroyClientInvoker(locator, new HashMap()); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } } } finally { if (client != null) { client.disconnect(); } } log.info(getName() + " PASSES"); } public void testCreateClientInvoker() throws Throwable { log.info("entering " + getName()); InvokerLocator locator = new InvokerLocator("socket://localhost"); // Call from code with proper privileges. ClientInvoker invoker = InvokerRegistry.createClientInvoker(locator, new HashMap());; try { // Call from code without proper privileges. if (System.getSecurityManager() == null) { InvokerRegistryCaller.createClientInvoker(locator, new HashMap()); } else { try { InvokerRegistryCaller.createClientInvoker(locator, new HashMap()); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } } } finally { if (invoker != null) { InvokerRegistry.destroyClientInvoker(locator, new HashMap()); } } log.info(getName() + " PASSES"); } public void testCreateServerInvoker() throws Throwable { log.info("entering " + getName()); InvokerLocator locator = new InvokerLocator("socket://localhost"); // Call from code with proper privileges. ServerInvoker invoker = InvokerRegistry.createServerInvoker(locator, new HashMap());; try { // Call from code without proper privileges. if (System.getSecurityManager() == null) { InvokerRegistryCaller.createServerInvoker(locator, new HashMap()); } else { try { InvokerRegistryCaller.createServerInvoker(locator, new HashMap()); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } } } finally { if (invoker != null) { InvokerRegistry.destroyServerInvoker(invoker); } } log.info(getName() + " PASSES"); } public void testDestroyServerInvoker() throws Throwable { log.info("entering " + getName()); InvokerLocator locator = new InvokerLocator("socket://localhost"); ServerInvoker invoker = InvokerRegistry.createServerInvoker(locator, new HashMap());; // Call from code with proper privileges. InvokerRegistry.destroyServerInvoker(invoker); // Call from code without proper privileges. if (System.getSecurityManager() == null) { InvokerRegistryCaller.destroyServerInvoker(invoker); } else { try { InvokerRegistryCaller.destroyServerInvoker(invoker); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } } log.info(getName() + " PASSES"); } public void testUpdateServerInvokerLocator() throws Throwable { log.info("entering " + getName()); InvokerLocator oldLocator = new InvokerLocator("socket://localhost"); InvokerLocator newLocator = new InvokerLocator("socket://localhost"); ServerInvoker invoker = InvokerRegistry.createServerInvoker(oldLocator, new HashMap());; try { // Call from code with proper privileges. InvokerRegistry.updateServerInvokerLocator(oldLocator, newLocator); // Call from code without proper privileges. if (System.getSecurityManager() == null) { InvokerRegistryCaller.updateServerInvokerLocator(oldLocator, newLocator); } else { try { InvokerRegistryCaller.updateServerInvokerLocator(oldLocator, newLocator); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } } } finally { if (invoker != null) { InvokerRegistry.destroyServerInvoker(invoker); } } log.info(getName() + " PASSES"); } public void testIsSSLSupported() throws Throwable { log.info("entering " + getName()); // Call from code with proper privileges. InvokerRegistry.isSSLSupported("bisocket"); // Call from code without proper privileges. if (System.getSecurityManager() == null) { InvokerRegistryCaller.isSSLSupported("http"); } else { try { InvokerRegistryCaller.isSSLSupported("http"); fail("expected SecurityException"); } catch (SecurityException e) { log.info("got expected SecurityException"); } } log.info(getName() + " PASSES"); } static class TestServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new SocketServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } static class TestClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new SocketClientInvoker(locator, config); } public boolean supportsSSL() { return false; } } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestCallbackStore.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestCallbackStore.j0000644000175000017500000000536211413660476033444 0ustar twernertwerner /* * 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.security; import java.io.IOException; import java.io.Serializable; import java.util.Map; import org.apache.log4j.Logger; public class TestCallbackStore implements TestCallbackStoreMBean { private static Logger log = Logger.getLogger(TestCallbackStore.class); // private static byte[] memHolder; // static // { // long max = Runtime.getRuntime().maxMemory(); // log.info("max mem: " + max); // int memSize = (int) (max * 0.6); // memHolder = new byte[memSize]; // log.info("memHolder.length: " + memHolder.length); // } private int size; public String getStoreFilePath() {return null;} public String getStoreFileSuffix() {return null;} public void setStoreFilePath(String filePath) {} public void setStoreFileSuffix(String fileSuffix) {} public void add(Serializable object) throws IOException { if (size > 0) return; size++; log.info("TestCallbackStore received callback"); synchronized (TestCallbackStore.class) { TestCallbackStore.class.notifyAll(); } } public void create() throws Exception {log.info("create()");} public void destroy() {log.info("destroy()");} public Object getNext() throws IOException {log.info("getNext()"); return null;} public boolean getPurgeOnShutdown() {log.info("getPurgeOnShutdown()"); return false;} public void purgeFiles() {log.info("purgeFiles()");} public void setConfig(Map config) {log.info("setConfig()");} public void setPurgeOnShutdown(boolean purgeOnShutdown) {log.info("setPurgeOnShutdown()");} public int size() {log.info("size()"); return size;} public void start() throws Exception {log.info("start()");} public void stop() {log.info("stop()");} } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/keystore0000644000175000017500000001376111010437120031467 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestCallbackErrorHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestCallbackErrorHa0000644000175000017500000000364011413660476033457 0ustar twernertwerner /* * 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.security; import java.util.Map; import org.apache.log4j.Logger; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 5, 2008 *

*/ public class TestCallbackErrorHandler implements TestCallbackErrorHandlerMBean { private static Logger log = Logger.getLogger(TestCallbackErrorHandler.class); int counter = 0; public void handleError(Throwable ex) throws Throwable { counter++; log.info("handling exception: " + ex.getMessage()); throw ex; } public void setCallbackHandler(ServerInvokerCallbackHandler serverInvokerCallbackHandler) {} public void setConfig(Map errorHandlerConfig) {} public void setServerInvoker(ServerInvoker owner) {} public int getCounter() { return counter; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/truststore0000644000175000017500000000701311010437120032051 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/ServerInvokerHandlerProxyTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/ServerInvokerHandle0000644000175000017500000001230011413660476033551 0ustar twernertwerner/* * 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.security; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; 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.InvokerLocator; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-977. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 4, 2008 *

*/ public class ServerInvokerHandlerProxyTestCase extends TestCase { private static Logger log = Logger.getLogger(ServerInvokerHandlerProxyTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestServerInvocationHandler handler; protected MBeanServer server; protected ObjectName handlerObjectName; 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 testServerInvokerHandlerProxy() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); log.info("ServerInvocationHandler: " + handler); // 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"); // Verify handler proxy gets used. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); assertEquals(1, handler.counter); int counter = ((Integer) server.getAttribute(handlerObjectName, "Counter")).intValue(); assertEquals(handler.counter, counter); 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); // Create ServerInvocationHandler. server = MBeanServerFactory.createMBeanServer(); handler = new TestServerInvocationHandler(); String objectNameString = "test:type=TestServerInvocationHandler"; handlerObjectName = new ObjectName(objectNameString); server.registerMBean(handler, handlerObjectName); // Create Connector and pass in handler ObjectName. connector = new Connector(serverLocator, config); server.registerMBean(connector, new ObjectName("test:type=Connector")); connector.create(); connector.addInvocationHandler("test", handlerObjectName); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestNetworkRegistry.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestNetworkRegistry0000644000175000017500000000413211413660476033657 0ustar twernertwerner /* * 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.security; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.ServerInvokerMetadata; import org.jboss.remoting.ident.Identity; import org.jboss.remoting.network.NetworkRegistry; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 6, 2008 *

*/ public class TestNetworkRegistry extends NetworkRegistry implements TestNetworkRegistryMBean { static Logger log = Logger.getLogger(TestNetworkRegistry.class); int counter; InvokerLocator locator; public TestNetworkRegistry(InvokerLocator locator) { this.locator = locator; } public void addServer(Identity identity, ServerInvokerMetadata[] invokers) { log.info("addServer() called"); for (int i = 0; i < invokers.length; i++) { if (locator.isSameEndpoint(invokers[i].getInvokerLocator())) { counter++; log.info("addServer(): counter incremented"); } } } public int getCounter() { return counter; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestServerSocketFactoryMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestServerSocketFac0000644000175000017500000000250011413660476033523 0ustar twernertwerner /* * 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.security; import org.jboss.remoting.security.ServerSocketFactoryMBean; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 7, 2008 *

*/ public interface TestServerSocketFactoryMBean extends ServerSocketFactoryMBean { public int getCounter(); } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestCallbackErrorHandlerMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestCallbackErrorHa0000644000175000017500000000247111413660476033460 0ustar twernertwerner /* * 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.security; import org.jboss.remoting.callback.CallbackErrorHandler; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 5, 2008 *

*/ public interface TestCallbackErrorHandlerMBean extends CallbackErrorHandler { public int getCounter(); } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/CallbackErrorHandlerProxyTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/CallbackErrorHandle0000644000175000017500000001722111413660476033462 0ustar twernertwerner/* * 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.security; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; 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; /** * Unit test for JBREM-977. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 4, 2008 *

*/ public class CallbackErrorHandlerProxyTestCase extends TestCase { private static Logger log = Logger.getLogger(CallbackErrorHandlerProxyTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestCallbackErrorHandler errorHandler; protected MBeanServer server; protected ObjectName errorHandlerObjectName; 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 testCallbackErrorHandlerProxy() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); log.info("ServerInvocationHandler: " + errorHandler); // 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"); // Check connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify callbacks work. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, null, null, true); assertEquals(1, callbackHandler.counter); // Verify CallbackErrorHandler proxy gets used. client.addListener(callbackHandler, null, null, true); assertEquals(1, callbackHandler.counter); assertEquals(1, errorHandler.counter); int counter = ((Integer) server.getAttribute(errorHandlerObjectName, "Counter")).intValue(); assertEquals(errorHandler.counter, counter); 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); // Create CallbackErrorHandler. server = MBeanServerFactory.createMBeanServer(); errorHandler = new TestCallbackErrorHandler(); String objectNameString = "test:type=TestCallbackErrorHandler"; errorHandlerObjectName = new ObjectName(objectNameString); server.registerMBean(errorHandler, errorHandlerObjectName); config.put(ServerInvokerCallbackHandler.CALLBACK_ERROR_HANDLER_KEY, objectNameString); // Create Connector.. connector = new Connector(serverLocator, config); server.registerMBean(connector, new ObjectName("test:type=Connector")); connector.create(); connector.addInvocationHandler("test", new TestServerInvocationHandler()); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } public static class TestServerInvocationHandler implements ServerInvocationHandler { static Logger log = Logger.getLogger(TestServerInvocationHandler.class); private int counter; public void addListener(InvokerCallbackHandler callbackHandler) { try { if (counter++ == 0) { // First time, send callback. callbackHandler.handleCallback(new Callback("callback")); } else { // Next, generate callback exception. callbackHandler.handleCallback(new Callback(new NotSerializable())); } } catch (HandleCallbackException e) { if (counter == 0) log.error("Unexpected exception", e); else log.info("Expected exception: " + e.getMessage()); } } 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 int getCounter() { return counter; } } static class TestCallbackHandler implements InvokerCallbackHandler { int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; log.info("received callback"); } } static class NotSerializable {} }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestServerInvocationHandlerMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/security/TestServerInvocatio0000644000175000017500000000247111413660476033623 0ustar twernertwerner /* * 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.security; import org.jboss.remoting.ServerInvocationHandler; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 5, 2008 *

*/ public interface TestServerInvocationHandlerMBean extends ServerInvocationHandler { public int getCounter(); } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lifecycle/0000755000175000017500000000000011632407031027767 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lifecycle/InvokerLifecycleTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lifecycle/InvokerLifecycleTe0000644000175000017500000001170311005557503033446 0ustar twernertwerner/* * 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.lifecycle; import junit.framework.TestCase; import org.jboss.remoting.InvalidConfigurationException; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import java.net.InetAddress; import java.net.ServerSocket; /** * @author Tom Elrod */ public class InvokerLifecycleTestCase extends TestCase { public InvokerLifecycleTestCase(String name) { super(name); } public void testMultipleConnectors() throws Exception { InvokerLocator serverLocator = new InvokerLocator("socket://localhost:2222"); Connector connector1 = new Connector(); connector1.setInvokerLocator(serverLocator.getLocatorURI()); connector1.start(); Connector connector2 = new Connector(); connector2.setInvokerLocator(serverLocator.getLocatorURI()); try { connector2.start(); } catch(InvalidConfigurationException ice) { assertTrue("Got InvalidConfigurationException as expected.", true); return; } finally { connector1.stop(); connector2.stop(); } assertTrue("Did not get InvalidConfiguration which was NOT expected.", false); } public void testNonConcurrentConnectors() throws Exception { String defaultHost = InetAddress.getLocalHost().getHostName(); String host = System.getProperty("jrunit.bind_addr", defaultHost); int port = PortUtil.findFreePort(host); InvokerLocator serverLocator = new InvokerLocator("socket://" + host + ":" + port); Connector connector1 = new Connector(); connector1.setInvokerLocator(serverLocator.getLocatorURI()); connector1.start(); connector1.stop(); Connector connector2 = new Connector(); connector2.setInvokerLocator(serverLocator.getLocatorURI()); try { connector2.start(); } catch(InvalidConfigurationException ice) { assertTrue("Got InvalidConfigurationException which was unexpected.", false); return; } finally { connector2.stop(); } assertTrue("Did not get InvalidConfiguration which is as expected.", true); } public void testStopConnector() throws Exception { // secure a server port to ensure is not available to connector InetAddress inetAddress = InetAddress.getByName("localhost"); ServerSocket socket = new ServerSocket(3333, 0, inetAddress); String locatorURI = "socket://localhost:3333/?reuseAddress=false"; InvokerLocator serverLocator = new InvokerLocator(locatorURI); Connector connector = new Connector(serverLocator); try { connector.start(); assertTrue("Should not have been able to start connector. Should have gotten bind exception.", false); } catch (Exception e) { System.out.println("Got exception as expected."); } connector.stop(); // have stopped, so free up port and restart socket.close(); // should not be able to start connector.start(); // startup must have been ok, now need to take down connector.stop(); connector.destroy(); // start the whole process over socket = new ServerSocket(3333, 0, inetAddress); connector = new Connector(serverLocator); try { connector.start(); assertTrue("Should not have been able to start connector. Should have gotten bind exception.", false); } catch (Exception e) { System.out.println("Got exception as expected."); } connector.stop(); // this time, are also going to explicitly call destroy connector.destroy(); // now close socket to release hold on port socket.close(); Connector connector2 = new Connector(serverLocator); connector2.start(); assertTrue("Able to start second connector.", true); } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lifecycle/ConnectorStartStopTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lifecycle/ConnectorStartStop0000644000175000017500000000332310355142433033534 0ustar twernertwerner/* * 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.lifecycle; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; import junit.framework.TestCase; /** * @author Tom Elrod */ public class ConnectorStartStopTestCase extends TestCase { public void testStartStop() throws Exception { InvokerLocator serverLocator = new InvokerLocator("socket://localhost:2222"); Connector connector = new Connector(); connector.setInvokerLocator(serverLocator.getLocatorURI()); connector.start(); connector.stop(); connector = new Connector(); connector.setInvokerLocator(serverLocator.getLocatorURI()); connector.start(); connector.stop(); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/0000755000175000017500000000000011632407033030215 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/0000755000175000017500000000000011632407033032251 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/0000755000175000017500000000000011632407033033040 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/VersionRMINativeMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/Ver0000644000175000017500000000367511413660476033543 0ustar twernertwerner/* * 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.versioning.transport.rmi; import org.jboss.test.remoting.transport.rmi.RMIInvokerNativeMarshallerClientTest; import org.jboss.test.remoting.transport.rmi.RMIInvokerNativeMarshallerServerTest; import org.jboss.test.remoting.versioning.transport.VersionInvokerTestCaseBase; /** * 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 VersionRMINativeMarshallerTestCase extends VersionInvokerTestCaseBase { public void declareTestClasses() { addTestClasses(RMIInvokerNativeMarshallerClientTest.class.getName(), 1, RMIInvokerNativeMarshallerServerTest.class.getName()); } }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/VersionRMISerializableMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/Ver0000644000175000017500000000402711413660476033533 0ustar twernertwerner/* * 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.versioning.transport.rmi; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.rmi.RMIInvokerSerializableMarshallerClientTest; import org.jboss.test.remoting.transport.rmi.RMIInvokerSerializableMarshallerServerTest; import org.jboss.test.remoting.versioning.transport.VersionInvokerTestCaseBase; /** * 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 VersionRMISerializableMarshallerTestCase extends VersionInvokerTestCaseBase { public void declareTestClasses() { addTestClasses(RMIInvokerSerializableMarshallerClientTest.class.getName(), 1, RMIInvokerSerializableMarshallerServerTest.class.getName()); } }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/VersionRMIOnewayNativeMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/Ver0000644000175000017500000000341311413660476033531 0ustar twernertwerner/* * 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.versioning.transport.rmi; import org.jboss.test.remoting.transport.rmi.RMIInvokerOnewayNativeMarshallerClientTest; import org.jboss.test.remoting.transport.rmi.RMIInvokerOnewayNativeMarshallerServerTest; import org.jboss.test.remoting.versioning.transport.VersionInvokerTestCaseBase; /** * Unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class VersionRMIOnewayNativeMarshallerTestCase extends VersionInvokerTestCaseBase { public void declareTestClasses() { addTestClasses(RMIInvokerOnewayNativeMarshallerClientTest.class.getName(), 1, RMIInvokerOnewayNativeMarshallerServerTest.class.getName()); } }././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/VersionRMIOnewaySerializableMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/rmi/Ver0000644000175000017500000000345111413660476033533 0ustar twernertwerner/* * 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.versioning.transport.rmi; import org.jboss.test.remoting.transport.rmi.RMIInvokerOnewaySerializableMarshallerClientTest; import org.jboss.test.remoting.transport.rmi.RMIInvokerOnewaySerializableMarshallerServerTest; import org.jboss.test.remoting.versioning.transport.VersionInvokerTestCaseBase; /** * Unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class VersionRMIOnewaySerializableMarshallerTestCase extends VersionInvokerTestCaseBase { public void declareTestClasses() { addTestClasses(RMIInvokerOnewaySerializableMarshallerClientTest.class.getName(), 1, RMIInvokerOnewaySerializableMarshallerServerTest.class.getName()); } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/socket/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/socket/0000755000175000017500000000000011632407033033541 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/socket/VersionSocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/socket/0000644000175000017500000000333610461473166033561 0ustar twernertwerner/* * 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.versioning.transport.socket; import org.jboss.test.remoting.versioning.transport.VersionInvokerTestCaseBase; /** * @author Tom Elrod */ public class VersionSocketInvokerTestCase extends VersionInvokerTestCaseBase { // protected String getJVMArguments() // { // String vmArgs = super.getJVMArguments(); // vmArgs = vmArgs + " -D" + Version.PRE_2_0_COMPATIBLE + "=" + Boolean.TRUE.toString(); // return vmArgs; // } public void declareTestClasses() { addTestClasses("org.jboss.test.remoting.transport.socket.SocketInvokerClientTest", 1, "org.jboss.test.remoting.transport.socket.SocketInvokerServerTest"); } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/VersionInvokerTestCaseBase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/Version0000644000175000017500000000645210624450051033626 0ustar twernertwernerpackage org.jboss.test.remoting.versioning.transport; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * @author Tom Elrod */ public abstract class VersionInvokerTestCaseBase extends InvokerTestDriver { /** * Returns the classpath to be added to the classpath used to start the client tests. * Default return is null, which means no extra classpath will be added. * * @return */ protected String getExtendedServerClasspath() { return System.getProperty("server.path"); } /** * Returns the classpath to be added to the classpath used to start the client tests. * Default return is null, which means no extra classpath will be added. * * @return */ protected String getExtendedClientClasspath() { return System.getProperty("client.path"); } protected String getClientJVMArguments() { String prop = System.getProperty("client.pre_2_0_compatible"); String args = ""; if (prop != null && !"".equals(prop)) { args = "-Djboss.remoting.pre_2_0_compatible=" + prop; } else { prop = System.getProperty("client.version"); if (prop != null && !"".equals(prop)) args = "-Djboss.remoting.version=" + prop; } prop = System.getProperty("client.check_connection"); if (prop != null && !"".equals(prop)) { args += " -Dremoting.metadata=socket.check_connection=" + prop; } System.out.println("client arg: " + args); return args; } protected String getServerJVMArguments() { String prop = System.getProperty("server.pre_2_0_compatible"); String args = ""; if (prop != null && !"".equals(prop)) { args = "-Djboss.remoting.pre_2_0_compatible=" + prop; } else { prop = System.getProperty("server.version"); if (prop != null && !"".equals(prop)) args = "-Djboss.remoting.version=" + prop; } prop = System.getProperty("server.check_connection"); if (prop != null && !"".equals(prop)) { args += " -Dremoting.metadata=socket.check_connection=" + prop; } System.out.println("server arg: " + args); return args; } protected Level getTestHarnessLogLevel() { return Level.DEBUG; } 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 60000; } /** * 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 60000; } /** * 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 60000; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/http/0000755000175000017500000000000011632407033033230 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/http/VersionHTTPInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/http/Ve0000644000175000017500000000160410750531244033530 0ustar twernertwernerpackage org.jboss.test.remoting.versioning.transport.http; import org.jboss.test.remoting.versioning.transport.VersionInvokerTestCaseBase; /** * @author Tom Elrod */ public class VersionHTTPInvokerTestCase extends VersionInvokerTestCaseBase { public void declareTestClasses() { addTestClasses("org.jboss.test.remoting.versioning.transport.http.VersionHTTPInvokerTestClient", 1, "org.jboss.test.remoting.transport.http.HTTPInvokerTestServer"); } protected String getClientJVMArguments() { String args = super.getClientJVMArguments(); String prop = System.getProperty("check_content_type"); if (prop != null && !"".equals(prop)) { args += " -Dcheck_content_type=" + prop; } System.out.println("client arg: " + args); return args; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/http/VersionHTTPInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/http/Ve0000644000175000017500000000545310750531317033537 0ustar twernertwerner/* * 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.versioning.transport.http; import org.jboss.remoting.Client; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.test.remoting.transport.http.HTTPInvokerTestClient; import org.jboss.test.remoting.transport.web.WebInvocationHandler; import java.util.Map; /** * @author Tom Elrod */ public class VersionHTTPInvokerTestClient extends HTTPInvokerTestClient { protected void makeExceptionInvocation(Client remotingClient, Map metadata) throws Throwable { try { // as of 2.0.0.CR1, would throw exception by default from the client if did not have // following metadata property. Since would not be present in older versions, will only // test when response is the exception (in older versions the property set will just be ignored metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); Object response = remotingClient.invoke(WebInvocationHandler.THROW_EXCEPTION_PARAM, metadata); if (response instanceof Exception) { System.out.println("Return from invocation is of type Exception as expected."); assertTrue("Received exception return as expected.", true); } else { System.out.println("Did not get Exception type returned as expected."); assertTrue("Should have received Exception as return.", false); } } catch (Exception e) { log.info("makeExceptionInvocation() caught exception: " + e.getMessage()); } } protected void checkUserAgent(Client remotingClient, Map metadata) throws Throwable { // this is going to be no-op since in 1.4.x version, just returned // java version as the agent and not jboss remoting. } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/bisocket/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/bisocke0000755000175000017500000000000011632407033033611 5ustar twernertwerner././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/bisocket/VersionBisocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/bisocke0000644000175000017500000000335211413660476033627 0ustar twernertwerner/* * 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.versioning.transport.bisocket; import org.jboss.test.remoting.versioning.transport.VersionInvokerTestCaseBase; /** * @author Tom Elrod */ public class VersionBisocketInvokerTestCase extends VersionInvokerTestCaseBase { // protected String getJVMArguments() // { // String vmArgs = super.getJVMArguments(); // vmArgs = vmArgs + " -D" + Version.PRE_2_0_COMPATIBLE + "=" + Boolean.TRUE.toString(); // return vmArgs; // } public void declareTestClasses() { addTestClasses("org.jboss.test.remoting.transport.bisocket.BisocketInvokerClientTest", 1, "org.jboss.test.remoting.transport.bisocket.BisocketInvokerServerTest"); } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/multiplex/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/multipl0000755000175000017500000000000011632407033033660 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/multiplex/VersionMultiplexInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/transport/multipl0000644000175000017500000000143710461473166033700 0ustar twernertwernerpackage org.jboss.test.remoting.versioning.transport.multiplex; import org.jboss.test.remoting.versioning.transport.VersionInvokerTestCaseBase; /** * @author Tom Elrod */ public class VersionMultiplexInvokerTestCase extends VersionInvokerTestCaseBase { // protected String getJVMArguments() // { // String vmArgs = super.getJVMArguments(); // vmArgs = vmArgs + " -D" + Version.PRE_2_0_COMPATIBLE + "=" + Boolean.TRUE.toString(); // return vmArgs; // } public void declareTestClasses() { addTestClasses("org.jboss.test.remoting.transport.multiplex.invoker.MultiplexInvokerClientTest", 1, "org.jboss.test.remoting.transport.multiplex.invoker.MultiplexInvokerServerTest"); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/VersionConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/VersionConfigTest0000644000175000017500000000265410412065547033567 0ustar twernertwerner/* * 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.versioning; import junit.framework.TestCase; import org.jboss.remoting.Version; /** * @author Tom Elrod */ public class VersionConfigTestCase extends TestCase { public void testNoVersionConfiguration() { System.setProperty(Version.PRE_2_0_COMPATIBLE, "True"); boolean performVersioning = Version.performVersioning(); assertFalse(performVersioning); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/lease/0000755000175000017500000000000011632407033031306 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersio0000644000175000017500000001411411413660476033464 0ustar twernertwerner/* * 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.versioning.lease; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.PatternLayout; import org.jboss.jrunit.extensions.ServerTestCase; 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.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 08, 2009 *

*/ public class LeaseVersionTestServer extends ServerTestCase { public static final String REMOTING_METADATA = "remoting.metadata"; public static final String JVM_MAX_HEAP_SIZE = "jvm.mx"; public static final String GET_LISTENER_INFO = "getListenerCount"; public static final String LISTENER_COUNT = "listenerCount"; public static final String THROWABLE = "throwable"; public static final String PORT = "9091"; private static Logger log = Logger.getLogger(LeaseVersionTestServer.class); protected static long LEASE_PERIOD = 2000; protected static String LEASE_PERIOD_STRING = "2000"; protected Connector connector; protected TestConnectionListener listener; public static void main(String[] args) { try { LeaseVersionTestServer p = new LeaseVersionTestServer(); p.setUp(); Thread.sleep(3000000); p.tearDown(); } catch (Exception e) { log.error("Error", e); } } public void setUp() throws Exception { 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); setupServer(); } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } protected String getTransport() { return "socket"; } protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { String locatorURI = createLocatorURI(); String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "/?" + metadata; } InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put("leasePeriod", LEASE_PERIOD_STRING); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); ServerInvocationHandler invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); listener = new TestConnectionListener(); connector.addConnectionListener(listener); } protected String createLocatorURI() throws UnknownHostException { String locatorURI = getTransport() + "://" + InetAddress.getLocalHost().getHostAddress() + ":" + PORT; locatorURI += "/?useClientConnectionIdentity=true"; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "&" + metadata; } return locatorURI; } class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { Object o = invocation.getParameter(); if (GET_LISTENER_INFO.equals(o)) { HashMap map = new HashMap(); map.put(LISTENER_COUNT, new Integer(listener.counter)); map.put(THROWABLE, listener.throwable); listener.counter = 0; listener.throwable = null; return map; } return o; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestConnectionListener implements ConnectionListener { public int counter; public Throwable throwable; public void handleConnectionException(Throwable throwable, Client client) { counter++; this.throwable = throwable; log.info("called: throwable = " + throwable); } } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersio0000644000175000017500000000702011413660476033462 0ustar twernertwernerpackage org.jboss.test.remoting.versioning.lease; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * @author Tom Elrod */ public class LeaseVersionTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses("org.jboss.test.remoting.versioning.lease.LeaseVersionTestClient", 1, "org.jboss.test.remoting.versioning.lease.LeaseVersionTestServer"); } /** * Returns the classpath to be added to the classpath used to start the client tests. * Default return is null, which means no extra classpath will be added. * * @return */ protected String getExtendedServerClasspath() { return System.getProperty("server.path"); } /** * Returns the classpath to be added to the classpath used to start the client tests. * Default return is null, which means no extra classpath will be added. * * @return */ protected String getExtendedClientClasspath() { return System.getProperty("client.path"); } protected String getClientJVMArguments() { String prop = System.getProperty("client.pre_2_0_compatible"); String args = ""; if (prop != null && !"".equals(prop)) { args = "-Djboss.remoting.pre_2_0_compatible=" + prop; } else { prop = System.getProperty("client.version"); if (prop != null && !"".equals(prop)) args = "-Djboss.remoting.version=" + prop; } prop = System.getProperty("client.check_connection"); if (prop != null && !"".equals(prop)) { args += " -Dremoting.metadata=socket.check_connection=" + prop; } System.out.println("client arg: " + args); return args; } protected String getServerJVMArguments() { String prop = System.getProperty("server.pre_2_0_compatible"); String args = ""; if (prop != null && !"".equals(prop)) { args = "-Djboss.remoting.pre_2_0_compatible=" + prop; } else { prop = System.getProperty("server.version"); if (prop != null && !"".equals(prop)) args = "-Djboss.remoting.version=" + prop; } prop = System.getProperty("server.check_connection"); if (prop != null && !"".equals(prop)) { args += " -Dremoting.metadata=socket.check_connection=" + prop; } System.out.println("server arg: " + args); return args; } protected Level getTestHarnessLogLevel() { return Level.INFO; } 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. * * @return */ protected long getResultsTimeout() { return 60000; } /** * 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 60000; } /** * 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 60000; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersionTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/versioning/lease/LeaseVersio0000644000175000017500000001014511413660476033464 0ustar twernertwerner/* * 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.versioning.lease; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; 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.ClientDisconnectedException; import org.jboss.remoting.InvokerLocator; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 08, 2009 *

*/ public class LeaseVersionTestClient extends TestCase { private static Logger log = Logger.getLogger(LeaseVersionTestClient.class); protected static long LEASE_PERIOD = 2000; protected static String LEASE_PERIOD_STRING = "2000"; private static boolean firstTime = true; 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 testLease() throws Throwable { log.info("entering " + getName()); // Create client. InvokerLocator clientLocator = new InvokerLocator(createLocatorURI()); HashMap clientConfig = new HashMap(); clientConfig.put(Client.ENABLE_LEASE, "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"); // Test lease behavior. client.disconnect(); client.connect(); Map info = (Map) client.invoke(LeaseVersionTestServer.GET_LISTENER_INFO); log.info("listener info: " + info); assertEquals(1, ((Integer)info.get(LeaseVersionTestServer.LISTENER_COUNT)).intValue()); assertTrue(info.get(LeaseVersionTestServer.THROWABLE) instanceof ClientDisconnectedException); client.disconnect(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected String createLocatorURI() throws UnknownHostException { String locatorURI = getTransport() + "://" + InetAddress.getLocalHost().getHostAddress() + ":" + LeaseVersionTestServer.PORT; locatorURI += "/?useClientConnectionIdentity=true"; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "&" + metadata; } return locatorURI; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/0000755000175000017500000000000011632407040030064 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/0000755000175000017500000000000011632407037030661 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerSerializableMarshallerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerSeri0000644000175000017500000000302411413660476033420 0ustar twernertwerner/* * 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.transport.rmi; import java.util.Map; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; /** * This is the actual concrete test for the invoker client. * * @author Tom Elrod */ public class RMIInvokerSerializableMarshallerClientTest extends RMIInvokerNativeMarshallerClientTest { protected void addMetadata(Map metadata) { metadata.put(InvokerLocator.DATATYPE, SerializableMarshaller.DATATYPE); } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnewayNativeMarshallerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnew0000644000175000017500000000371511413660476033435 0ustar twernertwerner/* * 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.transport.rmi; import java.util.Map; import org.jboss.remoting.transport.rmi.RMIServerInvoker; /** * Unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class RMIInvokerOnewayNativeMarshallerServerTest extends RMIInvokerNativeMarshallerServerTest { protected void addMetadata(Map metadata) { try { metadata.put(RMIServerInvoker.RMI_ONEWAY_MARSHALLING, "true"); } catch (NoSuchFieldError e) { // For versioning tests. System.out.println(e); } } public static void main(String[] args) { RMIInvokerOnewayNativeMarshallerServerTest server = new RMIInvokerOnewayNativeMarshallerServerTest(); try { server.setUp(); Thread.currentThread().sleep(6000000); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerDecoratorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerDeco0000644000175000017500000001251311413660476033373 0ustar twernertwerner/* * 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.transport.rmi; 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.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class RMIInvokerDecoratorTestCase extends TestCase { private static Logger log = Logger.getLogger(RMIInvokerDecoratorTestCase.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); MarshalFactory.addMarshaller("decorated", new TestDecorator(), new TestUnDecorator()); } } public void tearDown() { } public void testDecoration() 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(new Integer(17), client.invoke(new Integer(17))); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "rmi"; } 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 += "/?" + InvokerLocator.DATATYPE + "=decorated"; 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) {} } }././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnewaySerializableMarshallerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnew0000644000175000017500000000322311413660476033427 0ustar twernertwerner/* * 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.transport.rmi; import java.util.Map; import org.jboss.remoting.transport.rmi.RMIServerInvoker; /** * This is the actual concrete test for the invoker client. * * @author Tom Elrod */ public class RMIInvokerOnewaySerializableMarshallerClientTest extends RMIInvokerSerializableMarshallerClientTest { protected void addMetadata(Map metadata) { super.addMetadata(metadata); try { metadata.put(RMIServerInvoker.RMI_ONEWAY_MARSHALLING, "true"); } catch (NoSuchFieldError e) { // For versioning tests. System.out.println(e); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/config/0000755000175000017500000000000011632407037032126 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/config/FactoryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/config/Factory0000644000175000017500000000503110446027031033451 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.rmi.config; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import javax.net.SocketFactory; import org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent; /** * * @author Ron Sigal *

* Copyright (c) May 20, 2006 *

*/ public class FactoryConfigTestCase extends FactoryConfigTestCaseParent { protected String getTransport() { return "rmi"; } protected SocketFactory getDefaultSocketFactory() { return new SerializableSocketFactory(); } protected SocketFactory getDefaultCallbackSocketFactory() { return new SerializableSocketFactory(); } static class SerializableSocketFactory extends SocketFactory implements Serializable { public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { return new Socket(arg0, arg1); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { return new Socket(arg0, arg1, arg2, arg3); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { return new Socket(arg0, arg1); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { return new Socket(arg0, arg1, arg2, arg3); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/0000755000175000017500000000000011632407036032346 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/TimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/Timeou0000644000175000017500000000062610404171322033527 0ustar twernertwernerpackage org.jboss.test.remoting.transport.rmi.timeout; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(TimeoutClientTest.class.getName(), 1, TimeoutServerTest.class.getName()); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/RMIQuickDisconnectClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/RMIQui0000644000175000017500000000271211413660476033407 0ustar twernertwerner/* * 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.transport.rmi.timeout; import org.jboss.test.remoting.timeout.QuickDisconnectClientParent; /** * Unit test for JBREM-798. * * See javadoc for QuickDisconnectClientParent. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 8, 2007 *

*/ public class RMIQuickDisconnectClient extends QuickDisconnectClientParent { protected String getTransport() { return "rmi"; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/TimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/Timeou0000644000175000017500000000300010433770344033527 0ustar twernertwernerpackage org.jboss.test.remoting.transport.rmi.timeout; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class TimeoutClientTest extends TestCase { private String locatorURI = "rmi://localhost:8899/?timeout=3000"; public void testTimeout() throws Exception { Client client = new Client(new InvokerLocator(locatorURI)); client.connect(); //test for client timeout try { client.invoke("foo"); Thread.currentThread().sleep(5000); client.invoke("bar"); System.out.println("Done making all calls after sleeping."); } catch(Throwable throwable) { if(throwable instanceof Exception) { throw (Exception) throwable; } else { throw new Exception(throwable); } } long start = System.currentTimeMillis(); long end = 0; try { client.invoke("timeout"); end = System.currentTimeMillis(); } catch(Throwable t) { System.out.println("Caught exception: " + t.getMessage()); end = System.currentTimeMillis(); } long executionTime = end - start; System.out.println("execution time was " + executionTime); boolean timedOut = (executionTime < 10000); assertTrue("Socket did not timeout within expected time", timedOut); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/TimeoutServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/Timeou0000644000175000017500000000623710404171322033533 0ustar twernertwernerpackage org.jboss.test.remoting.transport.rmi.timeout; import javax.management.MBeanServer; 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.ServerInvoker; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * @author Tom Elrod */ public class TimeoutServerTest extends ServerTestCase { private String locatorURI = "rmi://localhost:8899/?timeout=3000"; private Connector connector = null; public void setUp() throws Exception { connector = new Connector(); InvokerLocator locator = new InvokerLocator(locatorURI); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler("test", new org.jboss.test.remoting.transport.rmi.timeout.TimeoutServerTest.TimeoutHandler()); connector.start(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.jboss.test.remoting.transport.rmi.timeout.TimeoutServerTest server = new org.jboss.test.remoting.transport.rmi.timeout.TimeoutServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } private class TimeoutHandler implements ServerInvocationHandler { /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { Object obj = invocation.getParameter(); if(obj instanceof String && "timeout".equals(obj)) { Thread.currentThread().sleep(30000); } return null; //TODO: -TME Implement } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/RMIQuickDisconnectServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/RMIQui0000644000175000017500000000334111413660476033406 0ustar twernertwerner/* * 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.transport.rmi.timeout; import org.jboss.test.remoting.timeout.QuickDisconnectServerParent; /** * Unit test for JBREM-798. * * See javadoc for QuickDisconnectServerParent. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 8, 2007 *

*/ public class RMIQuickDisconnectServer extends QuickDisconnectServerParent { public static void main(String[] args) { try { RMIQuickDisconnectServer server = new RMIQuickDisconnectServer(); server.setUp(); Thread.sleep(100000); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "rmi"; } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/RMIPerInvocationTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/RMIPer0000644000175000017500000000272411413660476033402 0ustar twernertwerner/* * 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.transport.rmi.timeout; import org.jboss.test.remoting.timeout.PerInvocationTimeoutTestRoot; /** * Unit test for JBREM-701. * * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 8, 2007 *

*/ public class RMIPerInvocationTimeoutTestCase extends PerInvocationTimeoutTestRoot { protected String getTransport() { return "rmi"; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/RMIQuickDisconnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/timeout/RMIQui0000644000175000017500000000315011413660476033404 0ustar twernertwerner/* * 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.transport.rmi.timeout; import org.jboss.jrunit.harness.TestDriver; /** * Unit test for JBREM-798. * * See javadoc for QuickDisconnectClientParent. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 8, 2007 *

*/ public class RMIQuickDisconnectTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMIQuickDisconnectClient.class.getName(), 1, RMIQuickDisconnectServer.class.getName()); } protected long getResultsTimeout() { return 200000; } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ComparableHolderTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ComparableHold0000644000175000017500000000541510561310005033451 0ustar twernertwerner/* * 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.transport.rmi; import java.lang.reflect.Constructor; import java.net.InetAddress; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory; /** * ComparableHolderTestCase verifies that the error documented in JBREM-697 * has been fixed. * * @author Ron Sigal * @version $Revision: 2064 $ *

* Copyright Feb 4, 2007 *

*/ public class ComparableHolderTestCase extends TestCase { private Logger log = Logger.getLogger(ComparableHolderTestCase.class); public void testComparableHolderEquals() throws Exception { log.info("entering " + getName()); String localHostName = InetAddress.getLocalHost().getHostName(); String localHostAddress = InetAddress.getLocalHost().getHostAddress(); log.info("local host name: " + localHostName); log.info("local host address: " + localHostAddress); InvokerLocator locator1 = new InvokerLocator("socket://" + localHostName + ":2345"); InvokerLocator locator2 = new InvokerLocator("socket://" + localHostAddress + ":2345"); log.info("locator1: " + locator1); log.info("locator2: " + locator2); Class[] classes = RemotingRMIClientSocketFactory.class.getDeclaredClasses(); assertEquals(1, classes.length); Class ComparableHolder = classes[0]; Constructor cons = ComparableHolder.getConstructor(new Class[] {InvokerLocator.class}); Object holder1 = cons.newInstance(new Object[] {locator1}); Object holder2 = cons.newInstance(new Object[] {locator2}); assertEquals(holder1, holder2); assertEquals(holder1.hashCode(), holder2.hashCode()); log.info(getName() + " PASSES"); } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnewaySerializableMarshallerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnew0000644000175000017500000000401011413660476033422 0ustar twernertwerner/* * 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.transport.rmi; import java.util.Map; import org.jboss.remoting.transport.rmi.RMIServerInvoker; /** * Unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class RMIInvokerOnewaySerializableMarshallerServerTest extends RMIInvokerSerializableMarshallerServerTest { protected void addMetadata(Map metadata) { super.addMetadata(metadata); try { metadata.put(RMIServerInvoker.RMI_ONEWAY_MARSHALLING, "true"); } catch (NoSuchFieldError e) { // For versioning tests. System.out.println(e); } } public static void main(String[] args) { RMIInvokerOnewaySerializableMarshallerServerTest server = new RMIInvokerOnewaySerializableMarshallerServerTest(); try { server.setUp(); Thread.currentThread().sleep(6000000); } catch(Exception e) { e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/0000755000175000017500000000000011632407036033017 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000755000175000017500000000000011632407037033525 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_classname/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000755000175000017500000000000011632407037033525 5ustar twernertwerner././@LongLink0000000000000000000000000000024200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_classname/SocketFactoryByClassnameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000644000175000017500000000305010535452155033527 0ustar twernertwerner/* * 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.transport.rmi.connection.socketfactory.by_classname; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.rmi.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByClassnameTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000023100000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_classname/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000644000175000017500000002156710437330157033542 0ustar twernertwerner/* * 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.transport.rmi.connection.socketfactory.by_classname; 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.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.SocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "rmi"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void setupServerWithClassname() throws Exception { String serverSocketFactoryValue = ServerSocketFactoryMock.class.getName(); String socketFactoryValue = SocketFactoryMock.class.getName(); connector = new Connector(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + serverSocketFactoryValue + ""); buf.append("" + socketFactoryValue + ""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setConfiguration(xml.getDocumentElement()); connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } public void setUp() throws Exception { setupServerWithClassname(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } public static class SocketFactoryMock extends SocketFactory implements SocketFactoryMockMBean, Serializable { private SocketFactory factory = null; public SocketFactoryMock() { } private void init() { System.out.println("SocketFactoryMock - init() called"); this.factory = SocketFactory.getDefault(); } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port, localHost, localPort); } public Socket createSocket(InetAddress host, int port) throws IOException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { if(factory == null) { init(); } return factory.createSocket(address, port, localAddress, localPort); } } public interface SocketFactoryMockMBean extends SocketFactoryMBean { } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_instance/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000755000175000017500000000000011632407037033525 5ustar twernertwerner././@LongLink0000000000000000000000000000024000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_instance/SocketFactoryByInstanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000644000175000017500000000304610535452155033534 0ustar twernertwerner/* * 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.transport.rmi.connection.socketfactory.by_instance; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.rmi.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByInstanceTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_instance/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000644000175000017500000002132110437330157033526 0ustar twernertwerner/* * 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.transport.rmi.connection.socketfactory.by_instance; 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.InvokerCallbackHandler; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.SocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.rmi.RMIServerInvoker; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "rmi"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setUp() throws Exception { setupServerWithInstance(); } private void setupServerWithInstance() throws Exception { String locatorURI = transport + "://" + host + ":" + port; // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(locator); connector.setServerSocketFactory(ServerSocketFactory.getDefault()); // creates all the connector's needed resources, such as the server invoker connector.create(); RMIServerInvoker invoker = (RMIServerInvoker) connector.getServerInvoker(); invoker.setSocketFactory(new SocketFactoryMock()); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } public static class SocketFactoryMock extends SocketFactory implements SocketFactoryMockMBean, Serializable { private SocketFactory factory = null; public SocketFactoryMock() { } private void init() { System.out.println("SocketFactoryMock - init() called"); this.factory = SocketFactory.getDefault(); } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port, localHost, localPort); } public Socket createSocket(InetAddress host, int port) throws IOException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { if(factory == null) { init(); } return factory.createSocket(address, port, localAddress, localPort); } } public interface SocketFactoryMockMBean extends SocketFactoryMBean { } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_mbean/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000755000175000017500000000000011632407037033525 5ustar twernertwerner././@LongLink0000000000000000000000000000023200000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_mbean/SocketFactoryByMBeanTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000644000175000017500000000304010535452155033526 0ustar twernertwerner/* * 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.transport.rmi.connection.socketfactory.by_mbean; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.rmi.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByMBeanTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/by_mbean/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000644000175000017500000002367310437330157033542 0ustar twernertwerner/* * 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.transport.rmi.connection.socketfactory.by_mbean; 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.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.SocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "rmi"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void setupServerWithMBeanServer() throws Exception { String serverSocketFactoryValue = "jboss:type=serversocketfactory"; //setup mbean server socket factory MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); ServerSocketFactoryMock service = new ServerSocketFactoryMock(); ObjectName objName = new ObjectName(serverSocketFactoryValue); mbeanServer.registerMBean(service, objName); /** * Can not have the socket factory be an mbean as will later * try to export the socket factory to the client and requires * it to be serializable, which is not possible with an mbean proxy * since no way to call back to the implementation on the server side. */ // String socketFactoryValue = "jboss:type=socketfactory"; // SocketFactoryMock service2= new SocketFactoryMock(); // ObjectName objName2 = new ObjectName(socketFactoryValue); // mbeanServer.registerMBean(service2, objName2); connector = new Connector(); mbeanServer.registerMBean(connector, new ObjectName("jboss:type=connector")); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + serverSocketFactoryValue + ""); // buf.append("" + socketFactoryValue + ""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setConfiguration(xml.getDocumentElement()); connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setUp() throws Exception { setupServerWithMBeanServer(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } public static class SocketFactoryMock extends SocketFactory implements SocketFactoryMockMBean, Serializable { private SocketFactory factory = null; public SocketFactoryMock() { } private void init() { System.out.println("SocketFactoryMock - init() called"); this.factory = SocketFactory.getDefault(); } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port, localHost, localPort); } public Socket createSocket(InetAddress host, int port) throws IOException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { if(factory == null) { init(); } return factory.createSocket(address, port, localAddress, localPort); } } public interface SocketFactoryMockMBean extends SocketFactoryMBean { } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/socketfactory/SocketFactoryTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connection/soc0000644000175000017500000000404610433770344033535 0ustar twernertwernerpackage org.jboss.test.remoting.transport.rmi.connection.socketfactory; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class SocketFactoryTestClient extends TestCase { // Default locator values private static String transport = "rmi"; private static String host = "localhost"; private static int port = 5400; public void testInvocations() throws Throwable { Client remotingClient = null; try { String locatorURI = transport + "://" + host + ":" + port; //String locatorURI = transport + "://" + host + ":" + port; // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); String request = "Do something"; System.out.println("Invoking server with request of '" + request + "'"); long startTime = System.currentTimeMillis(); Object response = remotingClient.invoke(request); System.out.println("Invocation response: " + response); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestClient client = new SocketFactoryTestClient(); try { client.testInvocations(); } catch(Throwable e) { e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/multihome/0000755000175000017500000000000011632407037032664 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/multihome/RMIMultihomeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/multihome/RMIM0000644000175000017500000000407611413660476033367 0ustar twernertwerner /* * 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.transport.rmi.multihome; 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.test.remoting.multihome.MultihomeTestParent; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jan 8, 2008 *

*/ public class RMIMultihomeTestCase extends MultihomeTestParent { protected String getTransport() { return "rmi"; } boolean firstTime = true; 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); } } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connectionfailure/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connectionfail0000755000175000017500000000000011632407037033575 5ustar twernertwerner././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connectionfailure/RMICallbackConnectionFailureTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/connectionfail0000644000175000017500000000305511413660476033607 0ustar twernertwerner /* * 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.transport.rmi.connectionfailure; import org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent; /** * Unit test for JBREM-875. * * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 10, 2007 *

*/ public class RMICallbackConnectionFailureTestCase extends CallbackConnectionFailureTestParent { protected String getTransport() { return "rmi"; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerNativeMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerNati0000644000175000017500000000335711413660476033422 0ustar twernertwerner/* * 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.transport.rmi; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * 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 RMIInvokerNativeMarshallerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(RMIInvokerNativeMarshallerClientTest.class.getName(), 1, RMIInvokerNativeMarshallerServerTest.class.getName()); } }././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerSerializableMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerSeri0000644000175000017500000000340111413660476033417 0ustar twernertwerner/* * 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.transport.rmi; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * 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 RMIInvokerSerializableMarshallerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(RMIInvokerSerializableMarshallerClientTest.class.getName(), 1, RMIInvokerSerializableMarshallerServerTest.class.getName()); } }././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnewaySerializableMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnew0000644000175000017500000000310311413660476033424 0ustar twernertwerner/* * 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.transport.rmi; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * Unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class RMIInvokerOnewaySerializableMarshallerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(RMIInvokerOnewaySerializableMarshallerClientTest.class.getName(), 1, RMIInvokerOnewaySerializableMarshallerServerTest.class.getName()); } }././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerNativeMarshallerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerNati0000644000175000017500000001073511413660476033420 0ustar twernertwerner/* * 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.transport.rmi; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; 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.remoting.transport.rmi.RMIServerInvoker; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class RMIInvokerNativeMarshallerServerTest extends ServerTestCase { private int port = RMIServerInvoker.DEFAULT_REGISTRY_PORT - 1; protected String transport = "rmi"; private Connector connector; private static final Logger log = Logger.getLogger(RMIInvokerNativeMarshallerServerTest.class); public void init(Map metatdata) throws Exception { if(port < 0) { port = TestUtil.getRandomPort(); } log.debug("port = " + port); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); System.out.println("server locator: " + locator); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); } private String buildLocatorURI(Map metadata) { if(metadata == null || metadata.size() == 0) { return transport + "://localhost:" + port; } else { StringBuffer uriBuffer = new StringBuffer(transport + "://localhost:" + port); 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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } public void setUp() throws Exception { Map metadata = new HashMap(); String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(newMetadata != null && newMetadata.length() > 0) { metadata.putAll(PerformanceServerTest.parseMetadataString(newMetadata)); } metadata.put(RMIServerInvoker.REGISTRY_PORT_KEY, String.valueOf(port + 1)); addMetadata(metadata); init(metadata); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } protected void addMetadata(Map metadata) { } public static void main(String[] args) { RMIInvokerNativeMarshallerServerTest server = new RMIInvokerNativeMarshallerServerTest(); try { server.setUp(); Thread.currentThread().sleep(6000000); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerNativeMarshallerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerNati0000644000175000017500000003423511413660476033421 0ustar twernertwerner/* * 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.transport.rmi; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.rmi.RMIServerInvoker; import org.jboss.test.remoting.ComplexReturn; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.mock.MockInvokerCallbackHandler; import org.jboss.test.remoting.transport.mock.MockTest; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.rmi.MarshalledObject; import java.rmi.server.UID; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * This is the actual concrete test for the invoker client. * * @author Tom Elrod */ public class RMIInvokerNativeMarshallerClientTest extends TestCase { private String sessionId = new UID().toString(); private Client client; private Connector connector; private InvokerLocator locator; private int port = RMIServerInvoker.DEFAULT_REGISTRY_PORT - 1; protected String transport = "rmi"; private static final Logger log = Logger.getLogger(RMIInvokerNativeMarshallerClientTest.class); public void init(Map metadata) { try { InvokerLocator locator = new InvokerLocator(buildLocatorURI(metadata, this.port)); //InvokerLocator locator = new InvokerLocator(getTransport() + "://localhost:" + port); System.out.println("client locator: " + locator); client = new Client(locator, "mock"); client.connect(); } catch(Exception e) { log.error(e.getMessage(), e); } } private String buildLocatorURI(Map metadata, int port) { if(metadata == null || metadata.size() == 0) { return transport + "://localhost:" + port; } else { StringBuffer uriBuffer = new StringBuffer(transport + "://localhost:" + port); 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); } } private InvokerLocator initServer(Map metadata, int serverPort) throws Exception { if(serverPort < 0) { serverPort = TestUtil.getRandomPort(); } log.debug("port = " + serverPort); // InvokerRegistry.registerInvoker("mock", MockClientInvoker.class, MockServerInvoker.class); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metadata, serverPort)); System.out.println("Callback locator: " + locator); //InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append("\n"); buf.append(" org.jboss.test.remoting.transport.mock.MockServerInvocationHandler\n"); buf.append("\n"); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); //connector.create(); connector.start(); return locator; } public void setUp() throws Exception { Map metadata = new HashMap(); String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(newMetadata != null && newMetadata.length() > 0) { metadata.putAll(PerformanceServerTest.parseMetadataString(newMetadata)); } metadata.put(RMIServerInvoker.REGISTRY_PORT_KEY, String.valueOf(port + 1)); addMetadata(metadata); locator = initServer(metadata, -1); init(metadata); log.info("Using metadata: " + metadata); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } /** * Test simple invocation and adding of listener with push callback (meaning server * will send callback message when it gets it) to a local callback server * * @throws Throwable */ public void testLocalPushCallback() throws Throwable { log.debug("running testLocalPushCallback()"); sessionId = new UID().toString(); sessionId = client.getSessionId(); MockInvokerCallbackHandler handler = new MockInvokerCallbackHandler(sessionId); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testLocalPushCallback() invocation of foo.", "bar".equals(ret)); client.addListener(handler, locator); // invoke which should cause callback ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(3000); log.debug("done sleeping."); int callbacksPerformed = handler.isCallbackReceived(); log.debug("callbacksPerformed after adding listener is " + callbacksPerformed); assertTrue("Result of testLocalPushCallback() failed since did not get callback.", (callbacksPerformed == 1)); // Can now call direct on client client.removeListener(handler); // shouldn't get callback now since removed listener ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(2000); log.debug("done sleeping."); callbacksPerformed = handler.isCallbackReceived(); log.debug("callbackPerformed after removing listener is " + callbacksPerformed); assertTrue("Result of testLocalPushCallback() failed since did get callback " + "but have been removed as listener.", (callbacksPerformed == 1)); } /** * Test simple invocation and adding of listener with push callback (meaning server * will send callback message when it gets it) to a remote callback server * * @throws Throwable */ public void testRemotePushCallback() throws Throwable { log.debug("running testRemotePushCallback()"); sessionId = new UID().toString(); //InvokerLocator locator = client.getInvoker().getLocator(); sessionId = client.getSessionId(); MockInvokerCallbackHandler handler = new MockInvokerCallbackHandler(sessionId); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testRemotePushCallback() invocation of foo.", "bar".equals(ret)); client.addListener(handler, locator); // invoke which should cause callback ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(3000); log.debug("done sleeping."); // TODO: No way to currently check the remote callback handler // to see if it got callback -TME /* int callbacksPerformed = handler.isCallbackReceived(); log.debug("callbacksPerformed after adding listener is " + callbacksPerformed); assertTrue("Result of testRemotePushCallback() failed since did not get callback.", (callbacksPerformed == 1)); */ // Can now call direct on client client.removeListener(handler); // shouldn't get callback now since removed listener ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(2000); log.debug("done sleeping."); /* callbacksPerformed = handler.isCallbackReceived(); log.debug("callbackPerformed after removing listener is " + callbacksPerformed); assertTrue("Result of testRemotePushCallback() failed since did get callback " + "but have been removed as listener.", (callbacksPerformed == 1)); */ } /** * Tests simple invocation and pull callbacks. Meaning will add a listener and * will then have to get the callbacks from the server. * * @throws Throwable */ public void testPullCallback() throws Throwable { log.debug("running testPullCallback()"); // should be null by default, since don't have connector started, but setting anyway //client.setClientLocator(null); MockInvokerCallbackHandler handler = new MockInvokerCallbackHandler(sessionId); // simple invoke, should return bar Object ret = makeInvocation("bar", "foo"); assertTrue("Result of runPullCallbackTest() invocation of bar.", "foo".equals(ret)); client.addListener(handler); // invoke which should cause callback on server side ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(2000); ret = client.getCallbacks(handler); log.debug("getCallbacks returned " + ret); log.debug("should have something."); assertTrue("Result of runPullCallbackTest() getCallbacks() after add listener.", ret != null); // can now call directly on client //ret = makeInvocation("removeListener", null); client.removeListener(handler); ret = makeInvocation("getCallbacks", null); log.debug("getCallbacks returned " + ret); log.debug("should have been empty."); assertTrue("Result of runPullCallbackTest() getCallbacks() after remove listener.", ret == null); } /** * Tests complex invocation to get object containing array of complex objects. * * @throws Throwable */ public void testArrayReturn() throws Throwable { // simple invoke, should return bar Object ret = makeInvocation("testComplexReturn", null); ComplexReturn complexRet = (ComplexReturn) ret; MockTest[] mockTests = complexRet.getMockTests(); assertTrue("ComplexReturn's array should contain 2 items", 2 == mockTests.length); for(int x = 0; x < mockTests.length; x++) { System.err.println(mockTests[x]); MockTest test = mockTests[x]; assertNotNull("MockTest should not be null", test); } // assertTrue("Result of runPullCallbackTest() invocation of bar.", // "foo".equals(ret)); } /** * Tests complex invocation to get marshalled object. * * @throws Throwable */ public void testMarshalledObjectReturn() throws Throwable { // simple invoke, should return bar Object ret = makeInvocation("testMarshalledObject", null); ret = ((MarshalledObject) ret).get(); ComplexReturn complexRet = (ComplexReturn) ret; MockTest[] mockTests = complexRet.getMockTests(); assertTrue("ComplexReturn's array should contain 2 items", 2 == mockTests.length); for(int x = 0; x < mockTests.length; x++) { System.err.println(mockTests[x]); MockTest test = mockTests[x]; assertNotNull("MockTest should not be null", test); } // assertTrue("Result of runPullCallbackTest() invocation of bar.", // "foo".equals(ret)); } protected void addMetadata(Map metadata) { } private 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; } // public static void main(String[] args) // { // RMIInvokerClientTest client = new RMIInvokerClientTest(); // try // { // client.setUp(); // client.testArrayReturn(); // client.testArrayReturnWithDataType(); // client.testLocalPushCallback(); // client.testLocalPushCallbackWithDatatype(); // client.testMarshalledObjectReturn(); // client.testMarshalledObjectReturnWithDataType(); // client.testPullCallback(); // client.testPullCallbackWithDataType(); // client.testRemotePushCallback(); // client.testRemotePushCallbackWithDataType(); // } // catch (Throwable throwable) // { // throwable.printStackTrace(); // } // finally // { // try // { // client.tearDown(); // } // catch (Exception e) // { // e.printStackTrace(); // } // } // // } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnewayNativeMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnew0000644000175000017500000000306111413660476033427 0ustar twernertwerner/* * 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.transport.rmi; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * Unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class RMIInvokerOnewayNativeMarshallerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(RMIInvokerOnewayNativeMarshallerClientTest.class.getName(), 1, RMIInvokerOnewayNativeMarshallerServerTest.class.getName()); } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/socketfactory/0000755000175000017500000000000011632407036033540 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/socketfactory/RMICreationListenerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/socketfactory/0000644000175000017500000000257610553067761033564 0ustar twernertwerner/* * 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.transport.rmi.socketfactory; import org.jboss.test.remoting.socketfactory.CreationListenerTestRoot; /** * @author Ron Sigal * @version $Revision: 1846 $ *

* Copyright Jan 11, 2007 *

*/ public class RMICreationListenerTestCase extends CreationListenerTestRoot { protected String getTransport() { return "rmi"; } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/socketfactory/RMIClientSocketFactoryMemoryLeakTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/socketfactory/0000644000175000017500000001374311413660476033560 0ustar twernertwerner/* * 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.transport.rmi.socketfactory; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory; /** * @author Ron Sigal * @version $Revision: 1846 $ *

* Copyright March 16, 2008 *

*/ public class RMIClientSocketFactoryMemoryLeakTestCase extends TestCase { private static Logger log = Logger.getLogger(RMIClientSocketFactoryMemoryLeakTestCase.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); log.info("java.version: " + System.getProperty("java.version")); } } public void tearDown() { } public void testMemoryLeak() throws Throwable { log.info("entering " + getName()); setupServer(); // 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"); // Verify configuration map has been stored in RemotingRMIClientSocketFactory. Field field = RemotingRMIClientSocketFactory.class.getDeclaredField("configMaps"); field.setAccessible(true); Map configMaps = (Map) field.get(null); assertEquals(1, configMaps.size()); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify that a SocketFactory has been created and saved. field = RemotingRMIClientSocketFactory.class.getDeclaredField("socketFactories"); field.setAccessible(true); Map socketFactories = (Map) field.get(null); assertEquals(1, configMaps.size()); // Verify configuration map is removed from RemotingRMIClientSocketFactory.configMaps // and SocketFactory is removed from RemotingRMIClientSocketFactory.socketFactories // after client invoker is disconnected. client.disconnect(); assertEquals(0, configMaps.size()); assertEquals(0, configMaps.size()); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "rmi"; } 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) {} } }././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/socketfactory/SocketFactoryClassNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/socketfactory/0000644000175000017500000000071611413660476033554 0ustar twernertwernerpackage org.jboss.test.remoting.transport.rmi.socketfactory; import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot; /** * * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jul 18, 2008 *

*/ public class SocketFactoryClassNameTestCase extends SocketFactoryClassNameTestRoot { protected String getTransport() { return "rmi"; } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/TestUnDecorator.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/TestUnDecorato0000644000175000017500000000447311413660476033524 0ustar twernertwerner /* * 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.transport.rmi; import java.io.IOException; import java.io.InputStream; import java.util.Map; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.UnMarshallerDecorator; /** * Part of unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class TestUnDecorator implements UnMarshallerDecorator, UnMarshaller { /** The serialVersionUID */ private static final long serialVersionUID = 6808291060065002247L; public Object removeDecoration(Object obj) throws IOException { if (obj instanceof InvocationRequest) { InvocationRequest ir = (InvocationRequest) obj; if (ir.getParameter() instanceof Integer) { int i = ((Integer) ir.getParameter()).intValue(); ir.setParameter(new Integer(i - 1)); } } return obj; } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { return new TestUnDecorator(); } public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException { return null; } public void setClassLoader(ClassLoader classloader) { // no-op } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/shutdown/0000755000175000017500000000000011632407037032534 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/shutdown/RMIShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/shutdown/RMISh0000644000175000017500000000254110555056447033413 0ustar twernertwerner/* * 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.transport.rmi.shutdown; import org.jboss.test.remoting.shutdown.ShutdownTestParent; /** * @author Ron Sigal * @version $Revision: 1961 $ *

* Copyright Jan 20, 2007 *

*/ public class RMIShutdownTestCase extends ShutdownTestParent { protected String getTransport() { return "rmi"; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/TestDecorator.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/TestDecorator.0000644000175000017500000000425011413660476033452 0ustar twernertwerner /* * 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.transport.rmi; import java.io.IOException; import java.io.OutputStream; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.MarshallerDecorator; /** * Part of unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class TestDecorator implements MarshallerDecorator, Marshaller { /** The serialVersionUID */ private static final long serialVersionUID = -3285464065838923918L; public Object addDecoration(Object obj) throws IOException { if (obj instanceof InvocationRequest) { InvocationRequest ir = (InvocationRequest) obj; if (ir.getParameter() instanceof Integer) { int i = ((Integer) ir.getParameter()).intValue(); ir.setParameter(new Integer(i + 1)); } } return obj; } public Marshaller cloneMarshaller() throws CloneNotSupportedException { return new TestDecorator(); } public void write(Object dataObject, OutputStream output) throws IOException { // no-op } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/clientaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/clientaddress/0000755000175000017500000000000011632407036033504 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/clientaddress/RMIClientAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/clientaddress/0000644000175000017500000000042010720523423033476 0ustar twernertwernerpackage org.jboss.test.remoting.transport.rmi.clientaddress; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class RMIClientAddressTestCase extends ClientAddressTestParent { protected String getTransport() { return "rmi"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/0000755000175000017500000000000011632407037031462 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/.truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/.truststor0000644000175000017500000000701310446030512033545 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žçlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/builder/0000755000175000017500000000000011632407037033110 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/builder/RMIInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/builder/RM0000644000175000017500000000275010446026613033354 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.rmi.ssl.builder; import org.jboss.jrunit.harness.TestDriver; /** * * @author Ron Sigal * @version $Revision: 1154 $ *

* Copyright (c) Jun 8, 2006 *

*/ public class RMIInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMIInvokerTestClient.class.getName(), 1, RMIInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/builder/RMIInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/builder/RM0000644000175000017500000000327710446026613033361 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.rmi.ssl.builder; import org.jboss.test.remoting.transport.socket.ssl.builder.SSLSocketInvokerTestServer; /** * * @author Ron Sigal * @version $Revision: 1154 $ *

* Copyright (c) Jun 8, 2006 *

*/ public class RMIInvokerTestServer extends SSLSocketInvokerTestServer { public String getTransport() { return "sslrmi"; } public static void main(String[] args) { RMIInvokerTestServer server = new RMIInvokerTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/builder/RMIInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/builder/RM0000644000175000017500000000265310446026613033356 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.rmi.ssl.builder; import org.jboss.test.remoting.transport.socket.ssl.builder.SSLSocketInvokerTestClient; /** * * @author Ron Sigal * @version $Revision: 1154 $ *

* Copyright (c) Jun 8, 2006 *

*/ public class RMIInvokerTestClient extends SSLSocketInvokerTestClient { public String getTransport() { return "sslrmi"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/config/0000755000175000017500000000000011632407037032727 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/config/SerializableServerSocketFactoryMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/config/Ser0000644000175000017500000000074210446027031033400 0ustar twernertwernerpackage org.jboss.test.remoting.transport.rmi.ssl.config; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; interface SerializableServerSocketFactoryMBean { public abstract ServerSocket createServerSocket(int arg0) throws IOException; public abstract ServerSocket createServerSocket(int arg0, int arg1) throws IOException; public abstract ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException; }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/config/FactoryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/config/Fac0000644000175000017500000002275210446027031033345 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.rmi.ssl.config; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import org.jboss.remoting.security.SSLServerSocketFactoryServiceMBean; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.SSLSocketBuilderMBean; import org.jboss.test.remoting.transport.config.FactoryConfigTestCaseSSLParent; /** * * @author Ron Sigal *

* Copyright (c) May 20, 2006 *

*/ public class FactoryConfigTestCase extends FactoryConfigTestCaseSSLParent { protected String getTransport() { return "sslrmi"; } // Note. // RMI ServerSocketFactorys aren't required to be Serializable, but for the // tests we put them in config maps that get serialized. protected ServerSocketFactory getDefaultServerSocketFactory() throws IOException { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); return new SerializableServerSocketFactory(config); } protected ServerSocketFactory getDefaultCallbackServerSocketFactory() throws IOException { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); return new SerializableServerSocketFactory(config); } protected SocketFactory getDefaultSocketFactory() throws IOException { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); return new SerializableSocketFactory(config); } protected SocketFactory getDefaultCallbackSocketFactory() throws IOException { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); return new SerializableSocketFactory(config); } public interface SerializableServerSocketFactoryMBean extends SSLServerSocketFactoryServiceMBean { public abstract ServerSocket createServerSocket(int arg0) throws IOException; public abstract ServerSocket createServerSocket(int arg0, int arg1) throws IOException; public abstract ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException; } public static class SerializableServerSocketFactory extends ServerSocketFactory implements Serializable, SerializableServerSocketFactoryMBean { Map config; public SerializableServerSocketFactory(Map config) { this.config = config; } /* (non-Javadoc) * @see org.jboss.test.remoting.transport.rmi.ssl.config.SerializableServerSocketFactoryMBean#createServerSocket(int) */ public ServerSocket createServerSocket(int arg0) throws IOException { int identity = FactoryConfigTestCaseSSLParent.secret; SelfIdentifyingSSLSocketBuilder builder = new SelfIdentifyingSSLSocketBuilder(config, identity); if (config.containsKey(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE)) builder.setServerSocketUseClientMode(true); builder.setUseSSLServerSocketFactory(false); return builder.createSSLServerSocketFactory().createServerSocket(arg0); } /* (non-Javadoc) * @see org.jboss.test.remoting.transport.rmi.ssl.config.SerializableServerSocketFactoryMBean#createServerSocket(int, int) */ public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { int identity = FactoryConfigTestCaseSSLParent.secret; SelfIdentifyingSSLSocketBuilder builder = new SelfIdentifyingSSLSocketBuilder(config, identity); if (config.containsKey(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE)) builder.setServerSocketUseClientMode(true); builder.setUseSSLServerSocketFactory(false); return builder.createSSLServerSocketFactory().createServerSocket(arg0, arg1); } /* (non-Javadoc) * @see org.jboss.test.remoting.transport.rmi.ssl.config.SerializableServerSocketFactoryMBean#createServerSocket(int, int, java.net.InetAddress) */ public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { int identity = FactoryConfigTestCaseSSLParent.secret; SelfIdentifyingSSLSocketBuilder builder = new SelfIdentifyingSSLSocketBuilder(config, identity); if (config.containsKey(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE)) builder.setServerSocketUseClientMode(true); builder.setUseSSLServerSocketFactory(false); return builder.createSSLServerSocketFactory().createServerSocket(arg0, arg1, arg2); } public void create() throws Exception { } public void start() throws Exception { } public void stop() { } public void destroy() { } public void setSSLSocketBuilder(SSLSocketBuilderMBean sslSocketBuilder) { } public SSLSocketBuilderMBean getSSLSocketBuilder() { int identity = FactoryConfigTestCaseSSLParent.secret; SelfIdentifyingSSLSocketBuilder builder = new SelfIdentifyingSSLSocketBuilder(config, identity); builder.setUseSSLServerSocketFactory(false); return builder; } } static class SerializableSocketFactory extends SocketFactory implements Serializable { Map config; public SerializableSocketFactory(Map config) { this.config = config; } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { SSLSocketBuilder builder = new SSLSocketBuilder(config); if (config.containsKey(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE)) builder.setSocketUseClientMode(false); builder.setUseSSLSocketFactory(false); return builder.createSSLSocketFactory().createSocket(arg0, arg1); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { SSLSocketBuilder builder = new SSLSocketBuilder(config); if (config.containsKey(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE)) builder.setSocketUseClientMode(false); builder.setUseSSLSocketFactory(false); return builder.createSSLSocketFactory().createSocket(arg0, arg1, arg2, arg3); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { SSLSocketBuilder builder = new SSLSocketBuilder(config); if (config.containsKey(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE)) builder.setSocketUseClientMode(false); builder.setUseSSLSocketFactory(false); return builder.createSSLSocketFactory().createSocket(arg0, arg1); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { SSLSocketBuilder builder = new SSLSocketBuilder(config); if (config.containsKey(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE)) builder.setSocketUseClientMode(false); builder.setUseSSLSocketFactory(false); return builder.createSSLSocketFactory().createSocket(arg0, arg1, arg2, arg3); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/timeout/0000755000175000017500000000000011632407037033150 5ustar twernertwerner././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/timeout/SSLRMIPerInvocationTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/timeout/SS0000644000175000017500000000274311413660476033433 0ustar twernertwerner/* * 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.transport.rmi.ssl.timeout; import org.jboss.test.remoting.timeout.SSLPerInvocationTimeoutTestRoot; /** * Unit test for JBREM-701. * * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 8, 2007 *

*/ public class SSLRMIPerInvocationTimeoutTestCase extends SSLPerInvocationTimeoutTestRoot { protected String getTransport() { return "sslrmi"; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/handshake/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/handshake/0000755000175000017500000000000011632407037033410 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/handshake/RMIInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/handshake/0000644000175000017500000000523010535452155033414 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.rmi.ssl.handshake; 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 RMIInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMIInvokerClientTest.class.getName(), 1, RMIInvokerServerTest.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; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/handshake/RMIInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/handshake/0000644000175000017500000000255010446026613033413 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.rmi.ssl.handshake; /** * * @author Ron Sigal *

* Copyright (c) May 20, 2006 *

*/ public class RMIInvokerClientTest extends org.jboss.test.remoting.transport.socket.ssl.handshake.InvokerClientTest { protected String getTransport() { return "sslrmi"; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/handshake/RMIInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/handshake/0000644000175000017500000000322510446026613033413 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.rmi.ssl.handshake; /** * * @author Ron Sigal *

* Copyright (c) May 20, 2006 *

*/ public class RMIInvokerServerTest extends org.jboss.test.remoting.transport.socket.ssl.handshake.InvokerServerTest { protected String getTransport() { return "sslrmi"; } public static void main(String[] args) { RMIInvokerServerTest server = new RMIInvokerServerTest(); try { server.setUp(); Thread.sleep(20000); server.tearDown(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/SSLRMIInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/SSLRMIInvo0000644000175000017500000000616510455077561033271 0ustar twernertwerner/* * 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.transport.rmi.ssl; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.InvokerClientTest; import java.util.HashMap; /** * @author Tom Elrod */ public class SSLRMIInvokerClientTest extends InvokerClientTest { public String getTransport() { return "sslrmi"; } protected InvokerLocator initServer(int port) throws Exception { if(port < 0) { port = TestUtil.getRandomPort(); } log.debug("port = " + port); // InvokerRegistry.registerInvoker("mock", MockClientInvoker.class, MockServerInvoker.class); HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); connector = new Connector(config); String locatorURI = getTransport() + "://localhost:" + port; if(metadata != null) { locatorURI = locatorURI + "/?" + metadata; } InvokerLocator locator = new InvokerLocator(locatorURI); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); return locator; } public void setUp() throws Exception { System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getClass().getResource(".keystore").getFile(); System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_FILE_PATH, keyStoreFilePath); System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_PASSWORD, "unit-tests-server"); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource(".truststore").getFile(); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_FILE_PATH, trustStoreFilePath); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_PASSWORD, "unit-tests-client"); super.setUp(); } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/multihome/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/multihome/0000755000175000017500000000000011632407037033465 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/multihome/SSLRMIMultihomeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/multihome/0000644000175000017500000000560211413660476033477 0ustar twernertwerner /* * 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.transport.rmi.ssl.multihome; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.jboss.test.remoting.transport.rmi.multihome.RMIMultihomeTestCase; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jan 8, 2008 *

*/ public class SSLRMIMultihomeTestCase extends RMIMultihomeTestCase { protected String getTransport() { return "sslrmi"; } protected void addExtraServerConfig(Map config) { super.addExtraServerConfig(config); 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"); } protected void addExtraClientConfig(Map config) { super.addExtraClientConfig(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"); } protected void addExtraCallbackConfig(Map config) { super.addExtraCallbackConfig(config); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); 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"); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/.keystore0000644000175000017500000001376110446030512033330 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/SSLRMIInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/SSLRMIInvo0000644000175000017500000000521010446604517033254 0ustar twernertwerner/* * 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.transport.rmi.ssl; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.transport.InvokerServerTest; import org.apache.log4j.Level; /** * @author Tom Elrod */ public class SSLRMIInvokerServerTest extends InvokerServerTest { public String getTransport() { return "sslrmi"; } public void setUp() throws Exception { System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getClass().getResource(".keystore").getFile(); System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_FILE_PATH, keyStoreFilePath); System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_PASSWORD, "unit-tests-server"); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource(".truststore").getFile(); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_FILE_PATH, trustStoreFilePath); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_PASSWORD, "unit-tests-client"); super.setUp(); } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); InvokerServerTest server = new SSLRMIInvokerServerTest(); try { server.setUp(); Thread.currentThread().sleep(30000); server.tearDown(); System.out.println("Have torn down test."); Thread.currentThread().sleep(30000); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/SSLRMiInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/SSLRMiInvo0000644000175000017500000000523310535452155033317 0ustar twernertwerner/* * 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.transport.rmi.ssl; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * 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 SSLRMiInvokerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SSLRMIInvokerClientTest.class.getName(), 1, SSLRMIInvokerServerTest.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; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/basic/0000755000175000017500000000000011632407037032543 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/basic/RMIInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/basic/RMII0000644000175000017500000000520210535452155033227 0ustar twernertwerner/* * 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.transport.rmi.ssl.basic; 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 RMIInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMIInvokerClientTest.class.getName(), 1, RMIInvokerServerTest.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; } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/basic/RMIInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/basic/RMII0000644000175000017500000000302310446026613033223 0ustar twernertwerner/* * 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.transport.rmi.ssl.basic; import org.jboss.logging.Logger; import org.jboss.test.remoting.transport.socket.ssl.basic.InvokerClientTest; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public class RMIInvokerClientTest extends InvokerClientTest { private static final Logger log = Logger.getLogger(RMIInvokerClientTest.class); protected String getTransport() { return "sslrmi"; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/basic/RMIInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/basic/RMII0000644000175000017500000000410110446026613033221 0ustar twernertwerner/* * 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.transport.rmi.ssl.basic; import java.util.Map; import org.jboss.logging.Logger; import org.jboss.test.remoting.transport.socket.ssl.basic.InvokerServerTest; ; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class RMIInvokerServerTest extends InvokerServerTest { private static final Logger log = Logger.getLogger(RMIInvokerServerTest.class); protected String getTransport() { return "sslrmi"; } public void init(Map metadata) throws Exception { String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); super.init(metadata); } public static void main(String[] args) { RMIInvokerServerTest server = new RMIInvokerServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/custom/0000755000175000017500000000000011632407037032774 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/custom/RMIInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/custom/RMI0000644000175000017500000000520310535452155033350 0ustar twernertwerner/* * 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.transport.rmi.ssl.custom; 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 RMIInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMIInvokerClientTest.class.getName(), 1, RMIInvokerServerTest.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; } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/custom/RMIInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/custom/RMI0000644000175000017500000000734110446026613033352 0ustar twernertwerner/* * 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.transport.rmi.ssl.custom; import java.util.HashMap; import java.util.List; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.transport.socket.ssl.custom.InvokerClientTest; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public class RMIInvokerClientTest extends InvokerClientTest { private static final Logger log = Logger.getLogger(RMIInvokerClientTest.class); protected String getTransport() { return "sslrmi"; } public void testCallbacks() { log.info("entering " + getName()); try { InvokerLocator locator = new InvokerLocator(getTransport() + "://localhost:" + callbackPort); HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); 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_SOCKET_USE_CLIENT_MODE, "false"); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); Connector callbackConnector = new Connector(locator.getLocatorURI(), config); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; log.info("calling addListener()"); client.addListener(callbackHandler, locator, callbackHandleObject); log.info("back from addListener()"); solicitCallback("abc"); // need to wait for brief moment so server can callback Thread.sleep(2000); // remove callback handler from server client.removeListener(callbackHandler); // shut down callback server callbackConnector.stop(); callbackConnector.destroy(); callbackConnector = null; List callbacks = callbackHandler.getCallbacks(); assertEquals(callbacks.size(), 1); // assertEquals(callbacks.get(0), "abc"); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/custom/RMIInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/custom/RMI0000644000175000017500000000557310446026613033357 0ustar twernertwerner/* * 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.transport.rmi.ssl.custom; import java.util.HashMap; import java.util.Map; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.socket.ssl.custom.InvokerServerTest; ; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class RMIInvokerServerTest extends InvokerServerTest { private static final Logger log = Logger.getLogger(RMIInvokerServerTest.class); protected String getTransport() { return "sslrmi"; } public void init(Map metatdata) throws Exception { if(serverPort < 0) { serverPort = TestUtil.getRandomPort(); } log.debug("port = " + serverPort); Map config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); 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"); Connector connector = new Connector(config); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } public static void main(String[] args) { RMIInvokerServerTest server = new RMIInvokerServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/socketfact0000755000175000017500000000000011632407037033531 5ustar twernertwerner././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/socketfact0000644000175000017500000000270211413660476033541 0ustar twernertwerner /* * 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.transport.rmi.ssl.socketfactory; import org.jboss.test.remoting.socketfactory.SSLSocketFactoryClassNameTestRoot; /** * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jul 18, 2008 *

*/ public class SSLSocketFactoryClassNameTestCase extends SSLSocketFactoryClassNameTestRoot { protected String getTransport() { return "sslrmi"; } } ././@LongLink0000000000000000000000000000023100000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/socketfactory/SSLRMIClientSocketFactoryMemoryLeakTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/socketfact0000644000175000017500000000463111413660476033544 0ustar twernertwerner/* * 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.transport.rmi.ssl.socketfactory; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.transport.rmi.socketfactory.RMIClientSocketFactoryMemoryLeakTestCase; import junit.framework.TestCase; /** * @author Ron Sigal * @version $Revision: 1846 $ *

* Copyright March 16, 2008 *

*/ public class SSLRMIClientSocketFactoryMemoryLeakTestCase extends RMIClientSocketFactoryMemoryLeakTestCase { protected String getTransport() { return "sslrmi"; } protected void addExtraServerConfig(Map config) { super.addExtraServerConfig(config); 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"); } protected void addExtraClientConfig(Map config) { super.addExtraClientConfig(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"); } }././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/socketfactory/SSLRMICreationListenerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/socketfact0000644000175000017500000000261610553067761033547 0ustar twernertwerner/* * 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.transport.rmi.ssl.socketfactory; import org.jboss.test.remoting.socketfactory.SSLCreationListenerTestRoot; /** * @author Ron Sigal * @version $Revision: 1846 $ *

* Copyright Jan 11, 2007 *

*/ public class SSLRMICreationListenerTestCase extends SSLCreationListenerTestRoot { protected String getTransport() { return "sslrmi"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/shutdown/0000755000175000017500000000000011632407037033335 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/shutdown/SSLRMIShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/shutdown/S0000644000175000017500000000361210555056447033474 0ustar twernertwerner/* * 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.transport.rmi.ssl.shutdown; import org.jboss.test.remoting.shutdown.ShutdownTestParent; /** * @author Ron Sigal * @version $Revision: 1961 $ *

* Copyright Jan 20, 2007 *

*/ public class SSLRMIShutdownTestCase extends ShutdownTestParent { protected String getTransport() { return "sslrmi"; } protected String getJVMArguments() { String args = ""; String keyStoreFilePath = getClass().getResource("../.keystore").getFile(); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); args += "-Djavax.net.ssl.keyStore=" + keyStoreFilePath + " "; args += "-Djavax.net.ssl.keyStorePassword=unit-tests-server "; args += "-Djavax.net.ssl.trustStore=" + trustStoreFilePath + " "; args += "-Djavax.net.ssl.trustStorePassword=unit-tests-client "; return args; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/clientaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/clientaddr0000755000175000017500000000000011632407037033514 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/clientaddress/SSLRMIClientAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/ssl/clientaddr0000644000175000017500000000246210720753477033533 0ustar twernertwernerpackage org.jboss.test.remoting.transport.rmi.ssl.clientaddress; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class SSLRMIClientAddressTestCase extends ClientAddressTestParent { protected String getTransport() { return "sslrmi"; } protected void addExtraServerConfig(Map config) { 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"); } protected void addExtraClientConfig(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"); } protected void addExtraCallbackConfig(Map config) { addExtraClientConfig(config); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnewayNativeMarshallerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerOnew0000644000175000017500000000317611413660476033436 0ustar twernertwerner/* * 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.transport.rmi; import java.util.Map; import org.jboss.remoting.transport.rmi.RMIServerInvoker; /** * Unit test for JBREM-167. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Mar 12, 2008 *

*/ public class RMIInvokerOnewayNativeMarshallerClientTest extends RMIInvokerNativeMarshallerClientTest { protected void addMetadata(Map metadata) { try { metadata.put(RMIServerInvoker.RMI_ONEWAY_MARSHALLING, "true"); } catch (NoSuchFieldError e) { // For versioning tests. System.out.println(e); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerSerializableMarshallerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/rmi/RMIInvokerSeri0000644000175000017500000000353111413660476033423 0ustar twernertwerner/* * 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.transport.rmi; import java.util.Map; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class RMIInvokerSerializableMarshallerServerTest extends RMIInvokerNativeMarshallerServerTest { protected void addMetadata(Map metadata) { metadata.put(InvokerLocator.DATATYPE, SerializableMarshaller.DATATYPE); } public static void main(String[] args) { RMIInvokerSerializableMarshallerServerTest server = new RMIInvokerSerializableMarshallerServerTest(); try { server.setUp(); Thread.currentThread().sleep(6000000); } catch(Exception e) { e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/0000755000175000017500000000000011632407040031354 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/SocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/SocketInvok0000644000175000017500000000442210552151674033551 0ustar twernertwerner/* * 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.transport.socket; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerServerTest; /** * @author Tom Elrod */ public class SocketInvokerServerTest extends InvokerServerTest { public String getTransport() { return "socket"; } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting.transport.socket").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jboss.test.remoting").setLevel(Level.DEBUG); // org.apache.log4j.Category.getInstance("org.jboss.remoting.marshall.dynamic.local").setLevel(Level.DEBUG); // org.apache.log4j.Category.getInstance("org.jboss.dtf").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); InvokerServerTest server = new SocketInvokerServerTest(); try { server.setUp(); Thread.sleep(300000); server.tearDown(); System.out.println("Have torn down test."); Thread.sleep(30000); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlockup/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlocku0000755000175000017500000000000011632407037033647 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlockup/ServerLockupTestDriver.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlocku0000644000175000017500000000701110552151674033653 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.transport.socket.serverlockup; import org.jboss.jrunit.harness.TestDriver; import org.jboss.logging.XLevel; import org.apache.log4j.Level; /** * @author Ovidiu Feodorov */ public class ServerLockupTestDriver extends TestDriver { // Constants ------------------------------------------------------------------------------------ public static final String REMOTING_METADATA = "remoting.metadata"; public static final String JVM_MAX_HEAP_SIZE = "jvm.mx"; // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- // Constructors --------------------------------------------------------------------------------- // TestDriver overrides ------------------------------------------------------------------------- public void declareTestClasses() { addTestClasses(ServerLockupClientTest.class.getName(), 1, ServerLockupServerTest.class.getName()); } protected Level getTestLogLevel() { return XLevel.TRACE; } 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. */ 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; } protected String getClientJVMArguments() { String clientJVMArguments = ""; if (Boolean.getBoolean("clientdebug")) { clientJVMArguments += "-Xdebug -Xnoagent -Djava.compiler=NONE " + "-Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=client"; } return clientJVMArguments; } /** * Returns the VM arguments to be passed to the VM when creating the server test cases (actually * their harness). The default value is null. */ protected String getServerJVMArguments() { String serverJVMArguments = ""; if (Boolean.getBoolean("serverdebug")) { serverJVMArguments += "-Xdebug -Xnoagent -Djava.compiler=NONE " + "-Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=server"; } return serverJVMArguments; } // Public --------------------------------------------------------------------------------------- // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlockup/ServerLockupClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlocku0000644000175000017500000001154310553016151033647 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.transport.socket.serverlockup; import junit.framework.TestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.Client; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.logging.Logger; import java.net.BindException; /** * @author Ovidiu Feodorov */ public class ServerLockupClientTest extends TestCase { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(ServerLockupClientTest.class); // Static --------------------------------------------------------------------------------------- public static void main(String[] args) { ServerLockupClientTest client = new ServerLockupClientTest(); try { client.setUp(); client.testSimplePing(); client.testRogueClient(); client.tearDown(); } catch (Throwable throwable) { throwable.printStackTrace(); } } // Attributes ----------------------------------------------------------------------------------- private int port = 9091; private int callbackPort = -1; private Client client; // Constructors --------------------------------------------------------------------------------- // Public --------------------------------------------------------------------------------------- public void testSimplePing() throws Throwable { log.debug("test simple ping"); Object ret = client.invoke(new NameBasedInvocation("ping", new Object[] {"hello"}, new String[] {"java.lang.String"})); assertEquals("pong.hello", ret); } /** * Invoking the server with a specially crafted client that is trying to lock up the server. */ public void testRogueClient() throws Throwable { log.debug("testRogueClient()"); RogueClientInvoker rogueInvoker = new RogueClientInvoker(new InvokerLocator(getTransport() + "://localhost:" + port)); rogueInvoker.connect(); rogueInvoker.openConnectionButDontSendAnything(); } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected String getTransport() { return "socket"; } protected String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { // This is a retry hack because in some cases, can get duplicate callback server ports when // trying to find a free one. int retryLimit = 3; for(int x = 0; x < retryLimit; x++) { try { initServer(callbackPort); } catch(BindException e) { if(x + 1 == retryLimit) { throw e; } else { continue; } } break; } initClient(); } protected void tearDown() throws Exception { } // Private -------------------------------------------------------------------------------------- private InvokerLocator initServer(int port) throws Exception { if(port < 0) { port = TestUtil.getRandomPort(); } log.debug("server port " + port); Connector connector = new Connector(); String locatorString = getTransport() + "://localhost:" + port + "/?serializationType=jboss"; InvokerLocator locator = new InvokerLocator(locatorString); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); return locator; } private void initClient() { try { String locatorURI = getTransport() + "://localhost:" + port + "/?serializationType=jboss"; InvokerLocator locator = new InvokerLocator(locatorURI); client = new Client(locator, "mock"); client.connect(); } catch(Exception e) { log.error(e.getMessage(), e); } } // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlockup/ServerLockupServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlocku0000644000175000017500000000670210553016151033650 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.transport.socket.serverlockup; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.test.remoting.TestUtil; import org.jboss.logging.Logger; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.apache.log4j.Level; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Category; /** * @author Ovidiu Feodorov */ public class ServerLockupServerTest extends ServerTestCase { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(ServerLockupServerTest.class); // Static --------------------------------------------------------------------------------------- public static void main(String[] args) { BasicConfigurator.configure(); Category.getRoot().setLevel(Level.INFO); Category.getInstance("org.jboss.remoting.transport.socket").setLevel(Level.DEBUG); Category.getInstance("org.jboss.test.remoting").setLevel(Level.DEBUG); Category.getInstance("org.jgroups").setLevel(Level.FATAL); ServerLockupServerTest server = new ServerLockupServerTest(); try { server.setUp(); Thread.sleep(300000); server.tearDown(); System.out.println("Have torn down test."); Thread.sleep(30000); } catch(Exception e) { e.printStackTrace(); } } // Attributes ----------------------------------------------------------------------------------- private int serverPort = 9091; // default port private Connector connector; // Constructors --------------------------------------------------------------------------------- // Public --------------------------------------------------------------------------------------- public String getTransport() { return "socket"; } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new SimpleServerInvocationHandler(); } protected void setUp() throws Exception { if(serverPort < 0) { serverPort = TestUtil.getRandomPort(); } log.debug("port = " + serverPort); connector = new Connector(); String locatorString = getTransport() + "://localhost:" + serverPort + "/?serializationType=jboss"; InvokerLocator locator = new InvokerLocator(locatorString); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlockup/RogueClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlocku0000644000175000017500000000477610555353667033703 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.transport.socket.serverlockup; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.InvokerLocator; import org.jboss.logging.Logger; import java.net.Socket; /** * @author Ovidiu Feodorov * @version $Revision: 1972 $ *

* $Id: RogueClientInvoker.java 1972 2007-01-23 09:39:03Z ovidiu $ */ public class RogueClientInvoker extends MicroSocketClientInvoker { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(RogueClientInvoker.class); // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- // Constructors --------------------------------------------------------------------------------- public RogueClientInvoker(InvokerLocator locator) { super(locator); } // Public --------------------------------------------------------------------------------------- public String toString() { return "RogueClientInvoker[" + Integer.toHexString(hashCode()) + "]"; } // Package protected ---------------------------------------------------------------------------- void openConnectionButDontSendAnything() throws Exception { log.debug(this + " creating simple socket"); Socket socket = new Socket(locator.getHost(), locator.getPort()); log.debug(this + " created socket " + socket + ", sleeping ..."); Thread.sleep(30000); log.debug(this + " done sleeping"); // OutputStream outputStream = socketWrapper.getOutputStream(); // // writeVersion(outputStream, version); // // versionedWrite(outputStream, marshaller, invocation, version); // // InputStream inputStream = socketWrapper.getInputStream(); // // version = readVersion(inputStream); // // response = versionedRead(inputStream, unmarshaller, version); } // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlockup/SimpleServerInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/serverlocku0000644000175000017500000000472710552151674033666 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.transport.socket.serverlockup; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.logging.Logger; import javax.management.MBeanServer; /** * @author Ovidiu Feodorov * @version $Revision: 1814 $ * * $Id: SimpleServerInvocationHandler.java 1814 2007-01-13 12:42:36Z ovidiu $ */ public class SimpleServerInvocationHandler implements ServerInvocationHandler { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(SimpleServerInvocationHandler.class); // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- // Constructors --------------------------------------------------------------------------------- // ServerInvocationHandler implementation ------------------------------------------------------- public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public Object invoke(InvocationRequest invocation) throws Throwable { NameBasedInvocation nbi = (NameBasedInvocation)invocation.getParameter(); String methodName = nbi.getMethodName(); if ("ping".equals(methodName)) { return "pong." + nbi.getParameters()[0]; } return null; } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } // Public --------------------------------------------------------------------------------------- // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/localaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/localaddres0000755000175000017500000000000011632407040033552 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/localaddress/LocalAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/localaddres0000644000175000017500000001437410721124776033577 0ustar twernertwerner/* * 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.transport.socket.localaddress; 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.InvocationResponse; 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 test for JBREM-781. * * @author Ron Sigal * @version $Revision: 2980 $ *

* Copyright Jul 30, 2007 *

*/ public class LocalAddressTestCase extends TestCase { private static Logger log = Logger.getLogger(LocalAddressTestCase.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 the address returned by a "$GET_CLIENT_LOCAL_ADDRESS$" * is valid. */ public void testLocalAddressRequest() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int 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. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI + "/?timeout=1000"); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator1, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Get address of server. // Object o = client.invoke("$GET_CLIENT_LOCAL_ADDRESS$"); // assertTrue(o instanceof InvocationResponse); // InvocationResponse response = (InvocationResponse) o; // assertTrue(response.getResult() instanceof InetAddress); // InetAddress newAddress = (InetAddress) response.getResult(); // This test is updated to conform to new treatment of this facility. // See JBREM-792. InetAddress newAddress = (InetAddress) client.invoke("$GET_CLIENT_LOCAL_ADDRESS$"); String newLocatorURI = getTransport() + "://" + newAddress.getHostAddress() + ":" + port; log.info("new locator: " + newLocatorURI); // Try to connect to locator constructed from returned address. Client newClient = new Client(new InvokerLocator(newLocatorURI)); newClient.connect(); assertEquals("xyz", newClient.invoke("xyz")); client.disconnect(); newClient.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} 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"); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/oneway/0000755000175000017500000000000011632407040032656 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/oneway/OnewayConnectionManagerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/oneway/Onew0000644000175000017500000006240111006472406033517 0ustar twernertwerner/* * 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.transport.socket.oneway; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.LinkedList; 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.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; /** * Tests the oneway connection timer task in MicroSocketClientInvoker. * * November 3, 2007: This class was originally written as a unit test for * JBREM-706. It will also serve as unit test for JBREM-843. * * @author Ron Sigal * @version $Revision: 4115 $ *

* Copyright Jun 23, 2007 *

*/ public class OnewayConnectionManagerTestCase extends TestCase { protected static String FAST = "fast"; protected static String SLOW = "slow"; protected static String DELAY = "delay"; protected static Logger log = Logger.getLogger(OnewayConnectionManagerTestCase.class); protected static boolean firstTime = true; protected static boolean go; protected static Object lock = new Object(); 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); } } /** * Connections time out. Uses default oneway timeout. */ public void testDefaultTimeoutWithTimeouts() 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, "5"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); Client client = new Client(locator, config); client.connect(); Object o = client.getInvoker(); assertTrue(o instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) o; Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(0, pool.size()); assertEquals(0, invoker.getNumberOfUsedConnections()); int INVOCATIONS = 5; HashMap metadata = new HashMap(); metadata.put(DELAY, "10000"); long start = System.currentTimeMillis(); for (int i = 0; i < INVOCATIONS; i++) { client.invokeOneway(SLOW + i, metadata, true); } assertTrue((System.currentTimeMillis() - start < 2000)); for (int i = 0; i < 5; i++) { Thread.sleep(1000); if (INVOCATIONS == invoker.getNumberOfUsedConnections()) break; } assertEquals(0, pool.size()); for (int i = 0; i < 5; i++) { if (handler.startedCount == INVOCATIONS) break; Thread.sleep(1000); } assertEquals(INVOCATIONS, handler.startedCount); Thread.sleep(4000); // All sockets should have timed out by now. assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(0, pool.size()); Thread.sleep(10000); // All invocations should be done by now. assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(0, pool.size()); assertEquals(INVOCATIONS, handler.finishedCount); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * Connections don't time out. Uses default oneway timeout. */ public void testDefaultTimeoutWithNoTimeouts() 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, "5"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); Client client = new Client(locator, config); client.connect(); Object o = client.getInvoker(); assertTrue(o instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) o; Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(0, pool.size()); assertEquals(0, invoker.getNumberOfUsedConnections()); int INVOCATIONS = 5; HashMap metadata = new HashMap(); metadata.put(DELAY, "1000"); long start = System.currentTimeMillis(); for (int i = 0; i < INVOCATIONS; i++) { client.invokeOneway(SLOW + i, metadata, true); } assertTrue((System.currentTimeMillis() - start < 1000)); Thread.sleep(500); assertEquals(INVOCATIONS, invoker.getNumberOfUsedConnections()); assertEquals(0, pool.size()); assertEquals(INVOCATIONS, handler.startedCount); Thread.sleep(2000); // All invocations should have finished by now, and all sockets should // have been returned to the pool. assertEquals(INVOCATIONS, handler.finishedCount); assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(INVOCATIONS, pool.size()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * Connections time out. Uses configured oneway timeout. */ public void testConfiguredTimeoutWithTimeouts() 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, "5"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); config.put(MicroSocketClientInvoker.ONEWAY_CONNECTION_TIMEOUT, "500"); Client client = new Client(locator, config); client.connect(); Object o = client.getInvoker(); assertTrue(o instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) o; Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(0, pool.size()); assertEquals(0, invoker.getNumberOfUsedConnections()); int INVOCATIONS = 5; HashMap metadata = new HashMap(); metadata.put(DELAY, "1000"); long start = System.currentTimeMillis(); for (int i = 0; i < INVOCATIONS; i++) { client.invokeOneway(SLOW + i, metadata, true); } assertTrue((System.currentTimeMillis() - start < 1000)); Thread.sleep(100); assertEquals(INVOCATIONS, invoker.getNumberOfUsedConnections()); assertEquals(0, pool.size()); assertEquals(INVOCATIONS, handler.startedCount); Thread.sleep(2000); // All sockets should have timed out by now. Note that they would not have // timed out with default oneway timeout. assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(0, pool.size()); Thread.sleep(1000); // All invocations should be done by now. assertEquals(INVOCATIONS, handler.finishedCount); assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(0, pool.size()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * Connections don't time out. Uses configured oneway timeout. */ public void testConfiguredTimeoutWithNoTimeouts() 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, "5"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); config.put(MicroSocketClientInvoker.ONEWAY_CONNECTION_TIMEOUT, "6000"); Client client = new Client(locator, config); client.connect(); Object o = client.getInvoker(); assertTrue(o instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) o; Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(0, pool.size()); assertEquals(0, invoker.getNumberOfUsedConnections()); int INVOCATIONS = 5; HashMap metadata = new HashMap(); metadata.put(DELAY, "4000"); long start = System.currentTimeMillis(); for (int i = 0; i < INVOCATIONS; i++) { client.invokeOneway(SLOW + i, metadata, true); } assertTrue((System.currentTimeMillis() - start < 1000)); Thread.sleep(1000); assertEquals(INVOCATIONS, invoker.getNumberOfUsedConnections()); assertEquals(0, pool.size()); assertEquals(INVOCATIONS, handler.startedCount); Thread.sleep(5000); // All invocations should have finished by now, and all sockets should // have been returned to the pool. Note that sockets would have timeed out // if the default oneway timeout value were used. assertEquals(INVOCATIONS, handler.finishedCount); assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(INVOCATIONS, pool.size()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * Does server side oneway invocations. Connections don't have to wait * for invocation to complete. */ public void testOnewayServerSide() 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, "5"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); Client client = new Client(locator, config); client.connect(); Object o = client.getInvoker(); assertTrue(o instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) o; Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(0, pool.size()); assertEquals(0, invoker.getNumberOfUsedConnections()); int INVOCATIONS = 5; HashMap metadata = new HashMap(); metadata.put(DELAY, "5000"); for (int i = 0; i < INVOCATIONS; i++) { client.invokeOneway(SLOW + i, metadata, false); Thread.sleep(500); } Thread.sleep(2000); // Ony one connection should have been created, and it should have been // returned to the pool by now. assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(1, pool.size()); assertEquals(INVOCATIONS, handler.startedCount); Thread.sleep(5000); // All invocations should be done by now. assertEquals(INVOCATIONS, handler.finishedCount); assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(1, pool.size()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * Verify connection management works under heavy load, with some timeouts. */ public void testHeavyLoadWithTimeouts() 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("MaxPoolSize", "300"); 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, "100"); clientConfig.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "100"); clientConfig.put(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "100"); clientConfig.put(MicroSocketClientInvoker.ONEWAY_CONNECTION_TIMEOUT, "1000"); Client client = new Client(locator, clientConfig); client.connect(); Object o = client.getInvoker(); assertTrue(o instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) o; Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(0, pool.size()); assertEquals(0, invoker.getNumberOfUsedConnections()); int INVOCATIONS = 500; OnewayThread[] threads = new OnewayThread[INVOCATIONS]; for (int i = 0; i < INVOCATIONS; i++) { threads[i] = new OnewayThread(client, i, "5000"); threads[i].start(); } synchronized (lock) { go = true; lock.notifyAll(); } Thread.sleep(4000); // Verify first set of invocations were received. assertTrue(100 <= handler.startedCount); Thread.sleep(10000); // Verify rest of invocations were received. assertEquals(INVOCATIONS, handler.startedCount); Thread.sleep(8000); // All invocations should be complete by now. for (int i = 0; i < INVOCATIONS; i++) { assertTrue("failure in thread: " + i, threads[i].ok); } assertEquals(0, invoker.getNumberOfUsedConnections()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * Verify connection management works under heavy load, with no timeouts. */ public void testHeavyLoadWithoutTimeouts() 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("MaxPoolSize", "300"); 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, "100"); clientConfig.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "100"); clientConfig.put(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "100"); clientConfig.put(MicroSocketClientInvoker.ONEWAY_CONNECTION_TIMEOUT, "4000"); Client client = new Client(locator, clientConfig); client.connect(); Object o = client.getInvoker(); assertTrue(o instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) o; Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(0, pool.size()); assertEquals(0, invoker.getNumberOfUsedConnections()); int INVOCATIONS = 500; OnewayThread[] threads = new OnewayThread[INVOCATIONS]; for (int i = 0; i < INVOCATIONS; i++) { threads[i] = new OnewayThread(client, i, "100"); threads[i].start(); } synchronized (lock) { go = true; lock.notifyAll(); } Thread.sleep(4000); // Verify invocations were received. assertEquals(INVOCATIONS, handler.startedCount); // All invocations should be complete by now. for (int i = 0; i < INVOCATIONS; i++) { assertTrue("failure in thread: " + i, threads[i].ok); } Thread.sleep(2000); assertEquals(0, invoker.getNumberOfUsedConnections()); // Commenting out the following test. If the server is busy, it is possible // for some oneway connections to time out, in which case they would not // be returned to the connection pool. // assertEquals(100, pool.size()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** * Make sure timeout value is reset before socket is returned to pool. */ public void testTimeoutReset() 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, "5"); config.put(Client.MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, "1"); config.put(ServerInvoker.TIMEOUT, "5000"); config.put(MicroSocketClientInvoker.ONEWAY_CONNECTION_TIMEOUT, "7000"); Client client = new Client(locator, config); client.connect(); Object o = client.getInvoker(); assertTrue(o instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) o; Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(0, pool.size()); assertEquals(0, invoker.getNumberOfUsedConnections()); int INVOCATIONS = 5; HashMap metadata = new HashMap(); metadata.put(DELAY, "1000"); long start = System.currentTimeMillis(); for (int i = 0; i < INVOCATIONS; i++) { client.invokeOneway(SLOW + i, metadata, true); } assertTrue((System.currentTimeMillis() - start < 1000)); Thread.sleep(500); assertEquals(INVOCATIONS, invoker.getNumberOfUsedConnections()); assertEquals(0, pool.size()); assertEquals(INVOCATIONS, handler.startedCount); Thread.sleep(2000); // All invocations should have finished by now, and all sockets should // have been returned to the pool. assertEquals(INVOCATIONS, handler.finishedCount); assertEquals(0, invoker.getNumberOfUsedConnections()); assertEquals(INVOCATIONS, pool.size()); for (int i = 0; i < INVOCATIONS; i++) { SocketWrapper wrapper = (SocketWrapper) pool.get(i); assertEquals("invalid timeout value: socket" + i, 5000, wrapper.getTimeout()); } client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public class OnewayThread extends Thread { boolean ok; Client client; int id; String delay; public OnewayThread(Client client, int id, String delay) { this.client = client; this.id = id; this.delay = delay; } public void run() { try { synchronized (lock) { while (!go) { try {lock.wait();} catch (InterruptedException e) {} } } HashMap metadata = new HashMap(); metadata.put(DELAY, delay); client.invokeOneway(SLOW + id, metadata, true); 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++; log.debug("startedCount: " + startedCount); } String command = (String) invocation.getParameter(); if (command.startsWith(SLOW)) { Map metadata = invocation.getRequestPayload(); String delayString = (String) metadata.get(DELAY); int delay = Integer.valueOf(delayString).intValue(); Thread.sleep(delay); } synchronized (lock) { finishedCount++; log.debug("invocation done: " + invocation.getParameter()); log.debug("finishedCount: " + finishedCount); } return null; } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/oneway/OnewayInvocationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/oneway/Onew0000644000175000017500000001622410644075745033535 0ustar twernertwerner/* * 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.transport.socket.oneway; 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.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.socket.MicroSocketClientInvoker; /** * Unit test to confirm that MicroSocketClientInvoker.transport() * returns socket to pool in the case of oneway invocations. See JBREM-684. * * @author Ron Sigal * @version $Revision: 2525 $ *

* Copyright Jan 22, 2007 *

*/ public class OnewayInvocationTestCase extends TestCase { private static Logger log = Logger.getLogger("OnewayInvocationTestCase"); private static final int MAX_POOL_SIZE = 50; private static boolean firstTime = true; public void setUp() { if (firstTime) { firstTime = false; String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n"; PatternLayout layout = new PatternLayout(pattern); ConsoleAppender consoleAppender = new ConsoleAppender(layout); Logger.getRootLogger().addAppender(consoleAppender); Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO); Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO); } } public void testServerSideThreads() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); 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(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, Integer.toString(MAX_POOL_SIZE)); Client client = new Client(locator, clientConfig); client.connect(); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker(); invoker.setNumberOfRetries(3); int i = 0; try { for (; i < MAX_POOL_SIZE + 10; i++) { client.invokeOneway(new Integer(i), null, false); log.debug("invocation: " + i); } } catch (Throwable t) { log.info("failed on invocation: " + i + " (should be " + MAX_POOL_SIZE + ")"); } Thread.sleep(2000); assertEquals(MAX_POOL_SIZE + 10, i); assertEquals(MAX_POOL_SIZE + 10, handler.counter); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testClientSideThreads() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); 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(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, Integer.toString(MAX_POOL_SIZE)); Client client = new Client(locator, clientConfig); client.connect(); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker(); invoker.setNumberOfRetries(3); int i = 0; try { for (; i < MAX_POOL_SIZE + 10; i++) { client.invokeOneway(new Integer(i), null, true); log.debug("invocation: " + i); } } catch (Throwable t) { log.info("failed on invocation: " + i + " (should be " + MAX_POOL_SIZE + ")"); } Thread.sleep(2000); assertEquals(MAX_POOL_SIZE + 10, i); assertEquals(MAX_POOL_SIZE + 10, handler.counter); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } public static class TestHandler implements ServerInvocationHandler { public int counter; private Object lock = new Object(); public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { synchronized(lock) { counter++; } Integer i = (Integer) invocation.getParameter(); log.info("got invocation: " + i.intValue()); return new Integer(i.intValue() + 1); } public void addListener(InvokerCallbackHandler callbackHandler) { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("error handling callback"); } } public void removeListener(InvokerCallbackHandler callbackHandler) {} } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionpool/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionp0000755000175000017500000000000011632407037033622 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionpool/ConnectionPoolSizeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionp0000644000175000017500000001550611413660476033640 0ustar twernertwerner/* * 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.transport.socket.connectionpool; 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.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; /** * * Unit test for JBREM-858. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 3, 2007 *

*/ public class ConnectionPoolSizeTestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionPoolSizeTestCase.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 testClientMaxPoolSizeInConnectionPoolKey() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create clients. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI + "/?" + MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG + "=3"); InvokerLocator clientLocator2 = new InvokerLocator(locatorURI + "/?" + MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG + "=7"); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client1 = new Client(clientLocator1, clientConfig); client1.connect(); log.info("client1 is connected: " + clientLocator1); Client client2 = new Client(clientLocator2, clientConfig); client2.connect(); log.info("client2 is connected: " + clientLocator2); // Test connections. assertEquals("abc", client1.invoke("abc")); log.info("connection 1 is good"); assertEquals("def", client2.invoke("def")); log.info("connection 2 is good"); log.info("invoker1: " + client1.getInvoker()); log.info("invoker2: " + client2.getInvoker()); assertTrue(client1.getInvoker() instanceof MicroSocketClientInvoker); assertTrue(client2.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker1 = (MicroSocketClientInvoker) client1.getInvoker(); MicroSocketClientInvoker invoker2 = (MicroSocketClientInvoker) client2.getInvoker(); assertNotSame(invoker1, invoker2); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); assertNotSame(field.get(invoker1), field.get(invoker2)); field = MicroSocketClientInvoker.class.getDeclaredField("address"); field.setAccessible(true); log.info("invoker1.address: " + field.get(invoker1)); log.info("invoker2.address: " + field.get(invoker2)); client1.disconnect(); client2.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"); } } }././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionpool/ConnectionPoolSingleConnectionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionp0000644000175000017500000001414511413660476033636 0ustar twernertwerner/* * 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.transport.socket.connectionpool; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.LinkedList; 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; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; /** * Unit test for JBREM-786 for case when maxPoolSize == 1. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jan 21, 2008 *

*/ public class ConnectionPoolSingleConnectionTestCase extends TestCase { protected static Logger log = Logger.getLogger(ConnectionPoolSingleConnectionTestCase.class); protected static String DELAY = "delay"; 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() { } /** * Verifies that the "create new socket on last retry" feature does not apply when * maxPoolSize == 1. Verifies that the same socket is reused multiple times. */ public void testMaxPoolSizeOne() throws Throwable { log.info("entering " + getName()); // Start server - no connection checking. setupServer(); // Create first client. HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put("maxPoolSize", "1"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Get connection pool. assertTrue(client.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker(); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(1, pool.size()); SocketWrapper socketWrapper = (SocketWrapper) pool.get(0); for (int i = 0; i < 10000; i++) { client.invoke("xyz"); } log.info("made 10000 invocations"); assertEquals(1, pool.size()); assertEquals(socketWrapper, pool.get(0)); 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) {} } }././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionpool/ConnectionPoolRetryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionp0000644000175000017500000002026211413660476033633 0ustar twernertwerner/* * 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.transport.socket.connectionpool; 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; /** * Unit test for JBREM-786, JBREM-890. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 21, 2007 *

*/ public class ConnectionPoolRetryTestCase extends TestCase { protected static Logger log = Logger.getLogger(ConnectionPoolRetryTestCase.class); protected static String DELAY = "delay"; 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() { } /** * Verifies a new connection is created on the last attempt to make * an invocation. Tries to create a situation in which server threads are * frequently evicted and reused with a new socket, leaving the matching * connection in the client side connection pool unusable. If the probability of * getting an unusable connection is high, it is likely that the number * of retries would be exhausted and an exception thrown. The new facility * for always creating a new connection on the last attempt should make it * possible to avoid running out of retries. */ public void testNewConnectionOnLastRetry() throws Throwable { log.info("entering " + getName()); // Start server - no connection checking. setupServer(); // Create first client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig1 = new HashMap(); clientConfig1.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig1.put("numberOfCallRetries", "2"); addExtraClientConfig(clientConfig1); Client client1 = new Client(clientLocator1, clientConfig1); client1.connect(); int BANGERS = 50; int INVOCATIONS = 5000; BangerThread[] bangers = new BangerThread[BANGERS]; for (int i = 0; i < BANGERS; i++) { bangers[i] = new BangerThread(client1, INVOCATIONS, "banger:" + i); } String newLocatorURI = locatorURI + "/?timeout=100000"; InvokerLocator clientLocator2 = new InvokerLocator(newLocatorURI); HashMap clientConfig2 = new HashMap(); clientConfig2.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig1.put("numberOfCallRetries", "4"); addExtraClientConfig(clientConfig2); Client client2 = new Client(clientLocator2, clientConfig2); client2.connect(); for (int i = 0; i < BANGERS; i++) { bangers[i].start(); } for (int i = 0; i < BANGERS; i++) { bangers[i].join(); } for (int i = 0; i < BANGERS; i++) { log.info("banger " + i + " done: " + bangers[i].done); log.info("banger " + i + " ok: " + bangers[i].ok); } for (int i = 0; i < BANGERS; i++) { assertTrue("banger " + i + " not done", bangers[i].done); assertTrue("banger " + i + " experienced error", bangers[i].ok); } client1.disconnect(); client2.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"); config.put("maxPoolSize", "2"); 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 BangerThread extends Thread { public boolean done; public boolean ok; private Client client; private int count; private String name; private boolean error; public BangerThread(Client client, int count, String name) { this.client = client; this.count = count; this.name = name; setName(name); } public void run() { log.info(name + ": started"); for (int i = 0; i < count; i++) { try { long start = System.currentTimeMillis(); client.invoke(name + ":" + i); long duration = System.currentTimeMillis() - start; if (duration > 2000) { log.info(this + " invocation(" + i + ") took " + duration + " ms"); } if ((i + 1) % 1000 == 0) log.info(name + " got response: " + (i+1)); } catch (Throwable e) { log.error("error in thread: " + name + ", invocation: " + i, e); error = true; } } ok = !error; done = true; } } }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionpool/ConnectionPoolSingleRetryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionp0000644000175000017500000001426211413660476033636 0ustar twernertwerner/* * 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.transport.socket.connectionpool; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.LinkedList; 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; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; /** * * Unit test for JBREM-911. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 27, 2008 *

*/ public class ConnectionPoolSingleRetryTestCase extends TestCase { protected static Logger log = Logger.getLogger(ConnectionPoolSingleRetryTestCase.class); protected static String DELAY = "delay"; 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() { } /** * Verifies that the "create new socket on last retry" feature does not apply when * maxPoolSize == 1. Verifies that the same socket is reused multiple times. */ public void testMaxPoolSizeOne() throws Throwable { log.info("entering " + getName()); // Start server - no connection checking. setupServer(); // Create first client. HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put("numberOfCallRetries", "1"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify numberOfCallRetries == 1. assertTrue(client.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(1, invoker.getNumberOfCallRetries()); // Get connection pool. Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertEquals(1, pool.size()); SocketWrapper socketWrapper = (SocketWrapper) pool.get(0); for (int i = 0; i < 10000; i++) { client.invoke("xyz"); } log.info("made 10000 invocations"); assertEquals(1, pool.size()); assertEquals(socketWrapper, pool.get(0)); 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) {} } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/stress/0000755000175000017500000000000011632407037032705 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/stress/SocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/stress/Sock0000644000175000017500000000462710451007053033530 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.stress; import org.apache.log4j.Level; 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 SocketInvokerServerTest { private Connector connector = null; private int maxPoolSize = 300; // private int maxPoolSize = 1000; public String getTransport() { return "socket"; } public void setUp() throws Exception { InvokerLocator locator = new InvokerLocator(getTransport() + "://" + "localhost" + ":" + 6700 + "/?" + "MaxPoolSize=" + maxPoolSize); connector = new Connector(locator); 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) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); SocketInvokerServerTest server = new SocketInvokerServerTest(); try { server.setUp(); // Thread.currentThread().sleep(300000); Thread.currentThread().sleep(7200000); server.tearDown(); System.out.println("Have torn down test."); } 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 } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/stress/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/stress/read0000644000175000017500000000072110451007053033533 0ustar twernertwernerThis package directory contains client/server classes for testing concurrent invocations through the socket transport. These are not included as part of standard testsuite run and need to be run manually. 6/29/06 - Ran with 250 threads on client, each looping 1M times making server invocations. The test itself finally timed out after two hours of running (per code in test classes), but was able over 35K invocations per thread without error or leak in memory.././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/stress/SocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/stress/Sock0000644000175000017500000000554410451007053033527 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.stress; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class SocketInvokerClientTest { private int numOfThreads = 250; // private int numOfCalls = 1000; private int numOfCalls = 1000000; // private int maxClientPoolSize = 50; private int maxClientPoolSize = 250; private boolean[] finishedThreads = new boolean[numOfThreads]; public String getTransport() { return "socket"; } public void testClientCalls() throws Exception { Thread currentThread = null; for (int x = 0; x < numOfThreads; x++) { currentThread = new Thread(new Runnable() { public void run() { Client client = null; try { InvokerLocator locator = new InvokerLocator(getTransport() + "://" + "localhost" + ":" + 6700 + "/?" + "clientMaxPoolSize=" + maxClientPoolSize); client = new Client(locator); client.connect(); String threadName = Thread.currentThread().getName(); for (int i = 0; i < numOfCalls; i++) { Object ret = client.invoke(threadName); if(!ret.equals(threadName)) { System.out.println("ERROR - Should have returned " + threadName + " but returned " + ret); System.exit(1); } if(i % 500 == 0 && i > 0) { System.out.println("Thread " + threadName + " has made " + i + " invocations."); } } System.out.println(threadName + " -- done."); int threadNum = Integer.parseInt(threadName); finishedThreads[threadNum] = true; } catch (Throwable e) { e.printStackTrace(); } finally { client.disconnect(); } } }, "" + x); currentThread.start(); } // Thread.currentThread().sleep(300000); Thread.currentThread().sleep(7200000); for (int r = 0; r < finishedThreads.length; r++) { if (!finishedThreads[r]) { System.out.println("Failed - thread " + r + " never finished."); } } } public static void main(String[] args) { SocketInvokerClientTest client = new SocketInvokerClientTest(); try { client.testClientCalls(); } catch (Exception e) { e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/0000755000175000017500000000000011632407037033050 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/SocketQuickDisconnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Soc0000644000175000017500000000311210712556765033527 0ustar twernertwerner/* * 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.transport.socket.timeout; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class SocketQuickDisconnectTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SocketQuickDisconnectClient.class.getName(), 1, SocketQuickDisconnectServer.class.getName()); } protected long getResultsTimeout() { return 200000; } protected Level getTestLogLevel() { return Level.DEBUG; } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/TimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Tim0000644000175000017500000000257310355142433033530 0ustar twernertwerner/* * 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.transport.socket.timeout; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(TimeoutClientTest.class.getName(), 1, TimeoutServerTest.class.getName()); } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/WriteTimeoutTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Wri0000644000175000017500000006751611413660476033560 0ustar twernertwerner/* * 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.transport.socket.timeout; import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.SSLProtocolException; 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.CannotConnectException; import org.jboss.remoting.Client; import org.jboss.remoting.InvocationFailureException; 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.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 org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; /** * Unit tests for JBREM-1120. * * @author Ron Sigal * @version $Rev$ *

* Copyright Apr 22, 2009 *

*/ public abstract class WriteTimeoutTestParent extends TestCase { private static Logger log = Logger.getLogger(WriteTimeoutTestParent.class); private static boolean firstTime = true; protected static int secondaryServerSocketPort; protected static boolean callbackTest; 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); } TestOutputStream.counter = 0; callbackTest = false; } public void tearDown() { } public void testClientWriteTimeout() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, false, "", -1, -1); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(SocketWrapper.WRITE_TIMEOUT, "1000"); SocketFactory sf = (SocketFactory) getSocketFactoryConstructor().newInstance(new Object[]{new Integer(5000), new Integer(1)}); clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); log.info("**************************************"); log.info("*** WorkerThread error is expected ***"); log.info("**************************************"); // Test client side write timeout. try { client.invoke("abc"); } catch (InvocationFailureException e) { log.info(e.getMessage()); assertNotNull(e.getMessage()); assertTrue(e.getMessage().startsWith("Unable to perform invocation")); assertTrue(e.getCause() instanceof IOException); IOException ioe = (IOException) e.getCause(); assertEquals("closed", ioe.getMessage()); log.info("got expected Exception"); } catch (Throwable t) { log.error("got unexpected Exception", t); fail("got unexpected Exception"); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testServerWriteTimeout() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, false, "1000", 5000, 1); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("numberOfCallRetries", "1"); clientConfig.put("timeout", "10000"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); log.info("**************************************"); log.info("*** WorkerThread error is expected ***"); log.info("**************************************"); // Test server side write timeout. try { client.invoke("abc"); } catch (InvocationFailureException e) { log.info(e.getMessage()); // assertNotNull(e.getMessage()); // assertTrue(e.getMessage().startsWith("Unable to perform invocation")); // assertTrue(e.getCause() instanceof EOFException); log.info("got expected Exception"); } catch (Throwable t) { log.error("got unexpected Exception", t); fail("got unexpected Exception"); } // Test server invoker state. Thread.sleep(4000); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(0, serverInvoker.getCurrentClientPoolSize()); assertEquals(1, serverInvoker.getCurrentThreadPoolSize()); log.info("used ServerThread has returned to threadPool"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testClientCallbackWriteTimeout() throws Throwable { log.info("entering " + getName()); // Start server. if (isBisocket(getTransport())) { callbackTest = true; } setupServer(false, false, "", -1, -1); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(SocketWrapper.WRITE_TIMEOUT, "1000"); if (isBisocket(getTransport())) { SocketFactory sf = (SocketFactory) getSocketFactoryConstructor().newInstance(new Object[]{new Integer(5000), new Integer(1)}); clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf); } else { ServerSocketFactory ssf = (ServerSocketFactory) getServerSocketFactoryConstructor().newInstance(new Object[]{new Integer(5000), new Integer(-1)}); clientConfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf); } addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection client.invoke("abc"); log.info("connection is good"); // Test client callback write timeout. log.info("registering callback handler"); log.info("**************************************"); log.info("*** WorkerThread error is expected ***"); log.info("**************************************"); TestCallbackHandler callbackHandler = new TestCallbackHandler(); HashMap metadata = new HashMap(); if (isBisocket(getTransport())) { // metadata.put(SocketWrapper.WRITE_TIMEOUT, "1000"); metadata.put(Remoting.SOCKET_FACTORY_NAME, getSocketFactoryClassName()); metadata.put("numberOfCallRetries", "1"); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); metadata.put(Bisocket.PING_FREQUENCY, "11111111"); } else { // metadata.put(SocketWrapper.WRITE_TIMEOUT, "1000"); metadata.put(ServerInvoker.SERVER_SOCKET_FACTORY, getServerSocketFactoryClassName()); metadata.put("numberOfCallRetries", "1"); } client.addListener(callbackHandler, metadata, null, true); log.info("called Client.addListener()"); // Test server invoker state. // Wait for local ServerThread to time out. Might take a while in bisocket transports, since // the request to get a socket for the callback client invoker needs its own write on the // control socket. Thread.sleep(20000); log.info("back from sleep"); Set callbackConnectors = client.getCallbackConnectors(callbackHandler); assertEquals(1, callbackConnectors.size()); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); SocketServerInvoker serverInvoker = (SocketServerInvoker) callbackConnector.getServerInvoker(); assertEquals(0, serverInvoker.getCurrentClientPoolSize()); assertEquals(1, serverInvoker.getCurrentThreadPoolSize()); log.info("used ServerThread has returned to threadPool"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testServerCallbackWriteTimeout() throws Throwable { log.info("entering " + getName()); // Start server. if (isBisocket(getTransport())) { callbackTest = true; setupServer(true, false, "1000", 5000, 1); } else { setupServer(false, true, "1000", 5000, 1); } // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("numberOfCallRetries", "1"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection client.invoke("abc"); log.info("connection is good"); // Test server callback write timeout. log.info("registering callback handler"); log.info("**************************************"); log.info("*** WorkerThread error is expected ***"); log.info("**************************************"); HashMap metadata = new HashMap(); if (isBisocket(getTransport())) { metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); } TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, metadata, null, true); log.info("added listener"); // Test server invoker state. Thread.sleep(20000); log.info("waking up"); Throwable t = invocationHandler.t; assertTrue(t instanceof HandleCallbackException); log.info("t.getCause:", t.getCause()); if (t.getCause() instanceof InvocationFailureException) { InvocationFailureException e = (InvocationFailureException) t.getCause(); assertNotNull(e.getMessage()); assertTrue(e.getMessage().startsWith("Unable to perform invocation")); assertTrue(e.getCause() instanceof IOException); IOException ioe = (IOException) e.getCause(); assertEquals("closed", ioe.getMessage()); } else { assertTrue(t.getCause() instanceof CannotConnectException); log.info("t.getCause().getCause(): ", t.getCause().getCause()); assertTrue(t.getCause().getCause() instanceof InvocationTargetException); log.info("t.getCause().getCause().getCause(): ", t.getCause().getCause().getCause()); // assertTrue(t.getCause().getCause().getCause() instanceof SSLProtocolException); assertTrue(t.getCause().getCause().getCause() instanceof IOException); assertEquals("closed", t.getCause().getCause().getCause().getMessage()); } log.info("got expected Exception"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected abstract String getTransport(); protected boolean isBisocket(String transport) { return transport.indexOf("bisocket") >= 0; } protected String getServerSocketFactoryClassName() { return TestServerSocketFactory.class.getName(); } protected Constructor getServerSocketFactoryConstructor() throws NoSuchMethodException { return TestServerSocketFactory.class.getConstructor(new Class[]{int.class, int.class}); } protected String getSocketFactoryClassName() { return TestSocketFactory.class.getName(); } protected Constructor getSocketFactoryConstructor() throws NoSuchMethodException { return TestSocketFactory.class.getConstructor(new Class[]{int.class, int.class}); } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean setWriteTimeout, boolean setCallbackWriteTimeout, String writeTimeout, int blockingTime, int initialWrites) 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"); if (isBisocket(getTransport())) { secondaryServerSocketPort = PortUtil.findFreePort(host); config.put(Bisocket.SECONDARY_BIND_PORT, Integer.toString(secondaryServerSocketPort)); config.put(Bisocket.PING_FREQUENCY, "11111111"); } if (setWriteTimeout) { config.put(SocketWrapper.WRITE_TIMEOUT, writeTimeout); ServerSocketFactory ssf = (ServerSocketFactory) getServerSocketFactoryConstructor().newInstance(new Object[]{new Integer(blockingTime), new Integer(initialWrites)}); config.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf); } if (setCallbackWriteTimeout) { config.put(SocketWrapper.WRITE_TIMEOUT, writeTimeout); SocketFactory sf = (SocketFactory) getSocketFactoryConstructor().newInstance(new Object[]{new Integer(blockingTime), new Integer(initialWrites)}); config.put(Remoting.CUSTOM_SOCKET_FACTORY, sf); } if (callbackTest) { config.put("numberOfCallRetries", "1"); } 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 { Throwable t; public void addListener(final InvokerCallbackHandler callbackHandler) { new Thread() { public void run() { try { log.info("sending callback"); callbackHandler.handleCallback(new Callback("callback")); } catch (Throwable t) { log.info("throwable: ", t); TestInvocationHandler.this.t = t; } } }.start(); } 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 public class TestServerSocketFactory extends ServerSocketFactory { int timeout; int initialWrites; public TestServerSocketFactory() { this.timeout = 5000; this.initialWrites = -1; } public TestServerSocketFactory(int timeout, int initialWrites) { this.timeout = timeout; this.initialWrites = initialWrites; } public ServerSocket createServerSocket() throws IOException { ServerSocket ss = null; if (callbackTest) { ss = ServerSocketFactory.getDefault().createServerSocket(); } else { ss = new TestServerSocket(timeout, initialWrites); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port) throws IOException { ServerSocket ss = null; if (callbackTest && port != secondaryServerSocketPort) { ss = ServerSocketFactory.getDefault().createServerSocket(port); } else { ss = new TestServerSocket(port, timeout, initialWrites); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog) throws IOException { ServerSocket ss = null; if (callbackTest && port != secondaryServerSocketPort) { ss = ServerSocketFactory.getDefault().createServerSocket(port, backlog); } else { ss = new TestServerSocket(port, backlog, timeout, initialWrites); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException { ServerSocket ss = null; if (callbackTest && port != secondaryServerSocketPort) { ss = ServerSocketFactory.getDefault().createServerSocket(port, backlog, ifAddress); } else { ss = new TestServerSocket(port, backlog, ifAddress, timeout, initialWrites); } log.info("returning: " + ss); return ss; } } static class TestServerSocket extends ServerSocket { int timeout; int initialWrites; public TestServerSocket(int timeout, int initialWrites) throws IOException { super(); this.timeout = timeout; this.initialWrites = initialWrites; } public TestServerSocket(int port, int timeout, int initialWrites) throws IOException { super(port); this.timeout = timeout; this.initialWrites = initialWrites; } public TestServerSocket(int port, int backlog, int timeout, int initialWrites) throws IOException { super(port, backlog); this.timeout = timeout; this.initialWrites = initialWrites; } public TestServerSocket(int port, int backlog, InetAddress bindAddr, int timeout, int initialWrites) throws IOException { super(port, backlog, bindAddr); this.timeout = timeout; this.initialWrites = initialWrites; } public Socket accept() throws IOException { Socket s = new TestSocket(timeout, initialWrites); implAccept(s); return s; } public String toString() { return "TestServerSocket[" + getLocalPort() + "]"; } } public static class TestSocketFactory extends SocketFactory { int timeout; int initialWrites = -1; public TestSocketFactory() { timeout = 5000; } public TestSocketFactory(int timeout, int initialWrites) { this.timeout = timeout; this.initialWrites = initialWrites; } public Socket createSocket() { log.info("callbackTest: " + callbackTest); Socket s = null; if (callbackTest) { s = new Socket(); } else { s = new TestSocket(timeout, initialWrites); } log.info(this + " returning " + s); return s; } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { log.info("callbackTest: " + callbackTest + ", port: " + arg1); Socket s = null; if (callbackTest && arg1 != secondaryServerSocketPort) { s = new Socket(arg0, arg1); } else { s = new TestSocket(arg0, arg1, timeout, initialWrites); } log.info(this + " returning " + s); return s; } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { log.info("callbackTest: " + callbackTest + ", port: " + arg1); Socket s = null; if (callbackTest && arg1 != secondaryServerSocketPort) { s = new Socket(arg0, arg1); } else { s = new TestSocket(arg0, arg1, timeout, initialWrites); } log.info(this + " returning " + s); return s; } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { log.info("callbackTest: " + callbackTest + ", port: " + arg1); Socket s = null; if (callbackTest && arg1 != secondaryServerSocketPort) { s = new Socket(arg0, arg1); } else { s = new TestSocket(arg0, arg1, arg2, arg3, timeout, initialWrites); } log.info(this + " returning " + s); return s; } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { log.info("callbackTest: " + callbackTest + ", port: " + arg1); Socket s = null; if (callbackTest && arg1 != secondaryServerSocketPort) { s = new Socket(arg0, arg1); } else { s = new TestSocket(arg0, arg1, arg2, arg3, timeout, initialWrites); } log.info(this + " returning " + s); return s; } } static class TestSocket extends Socket { int timeout; int initialWrites; public TestSocket(int timeout, int initialWrites) { this.timeout = timeout; this.initialWrites = initialWrites; } public TestSocket(String host, int port, int timeout, int initialWrites) throws UnknownHostException, IOException { super(host, port); this.timeout = timeout; this.initialWrites = initialWrites; } public TestSocket(InetAddress address, int port, int timeout, int initialWrites) throws IOException { super(address, port); this.timeout = timeout; this.initialWrites = initialWrites; } public TestSocket(String host, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites) throws IOException { super(host, port, localAddr, localPort); this.timeout = timeout; this.initialWrites = initialWrites; } public TestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites) throws IOException { super(address, port, localAddr, localPort); this.timeout = timeout; this.initialWrites = initialWrites; } public OutputStream getOutputStream() throws IOException { return new TestOutputStream(super.getOutputStream(), timeout, initialWrites); } public String toString() { return "TestSocket[" + getLocalPort() + "->" + getPort() + "]"; } } static class TestOutputStream extends OutputStream { OutputStream os; int timeout; boolean closed; int initialWrites; boolean doWait = true; public static int counter; public TestOutputStream(OutputStream os, int timeout, int initialWrites) { this.os = os; this.timeout = timeout; this.initialWrites = initialWrites; } public void close()throws IOException { closed = true; super.close(); log.info(this + " closed"); } public void write(int b) throws IOException { System.out.print("b: " + b); if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } if (doWait && ++counter > initialWrites) { try { log.info("TestOutputStream.write() sleeping: " + timeout); Thread.sleep(timeout); } catch (InterruptedException e) { e.printStackTrace(); } } os.write(b); } public void write(byte b[], int off, int len) throws IOException { System.out.print("b: "); for (int i = 0; i < len; i++) { System.out.print(b[i] + " "); } System.out.println(""); if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } log.info("TestOutputStream: counter = " + counter + ", initialWrites = " + initialWrites); if (++counter > initialWrites) { try { log.info("TestOutputStream.write() sleeping: " + timeout); Thread.sleep(timeout); } catch (InterruptedException e) { e.printStackTrace(); } } if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } try { log.info(this + " calling write()"); doWait = false; os.write(b, off, len); os.flush(); doWait = true; log.info(this + " back from write()"); } catch (IOException e) { log.info("exception: ", e); throw e; } } } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/CallbackTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Cal0000644000175000017500000002167310713552341033501 0ustar twernertwerner/* * 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.transport.socket.timeout; 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.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.SocketClientInvoker; /** * Unit test written for JBREM-690: http://jira.jboss.com/jira/browse/JBREM-690. * * @author Ron Sigal * @version $Revision: 2907 $ *

* Copyright Jan 10, 2007 *

*/ public class CallbackTimeoutTestCase extends TestCase { protected static Logger log = Logger.getLogger(CallbackTimeoutTestCase.class); protected static boolean firstTime = true; protected static final String INVOKE = "invoke"; protected static final String CALLBACK = "callback"; protected static final String CALLBACK_ONEWAY = "callbackOneway"; 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 xtestCallbackTimeout() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(serverConfig); Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(locator, clientConfig); client.connect(); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, null, null, true); Object response = client.invoke(INVOKE); assertEquals(INVOKE, response); log.info("invocation succeeded"); client.invoke(CALLBACK); assertTrue(callbackHandler.receivedCallback); log.info("received first callback"); Thread.sleep(ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 5000); callbackHandler.receivedCallback = false; client.invoke(CALLBACK); assertTrue(callbackHandler.receivedCallback); log.info("received second callback"); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testOnewayCallbackTimeout() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Connection checking is no longer necessary since ClientSocketWrapper // implements OpenConnectionChecker. // serverConfig.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); addExtraServerConfig(serverConfig); Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); // clientConfig.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); clientConfig.put(SocketClientInvoker.SO_TIMEOUT_FLAG, "5000"); addExtraClientConfig(clientConfig); Client client = new Client(locator, clientConfig); client.connect(); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, null, null, true); Object response = client.invoke(INVOKE); assertEquals(INVOKE, response); log.info("invocation succeeded"); client.invoke(CALLBACK_ONEWAY); Thread.sleep(2000); assertTrue(callbackHandler.receivedCallback); log.info("received first callback"); Thread.sleep(ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 5000); log.info("waking up"); callbackHandler.receivedCallback = false; client.invoke(CALLBACK_ONEWAY); log.info("sent second invocation"); Thread.sleep(2000); assertTrue(callbackHandler.receivedCallback); log.info("received second callback"); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) { } protected void addExtraServerConfig(Map config) { } public class TestHandler implements ServerInvocationHandler { private InvokerCallbackHandler callbackHandler; public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { String command = (String) invocation.getParameter(); if (INVOKE.equals(command)) { return INVOKE; } else if (CALLBACK.equals(command)) { try { callbackHandler.handleCallback(new Callback("callback")); return null; } catch (HandleCallbackException e) { log.error("error handling callback"); throw e; } } else if (CALLBACK_ONEWAY.equals(command)) { try { ServerInvokerCallbackHandler sich = (ServerInvokerCallbackHandler) callbackHandler; sich.handleCallbackOneway(new Callback("callback"), true); return null; } catch (HandleCallbackException e) { log.error("error handling callback"); throw e; } } else { log.error("unrecognized command: " + command); throw new Exception("unrecognized command: " + command); } } public void addListener(InvokerCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } public void removeListener(InvokerCallbackHandler callbackHandler) {} } public class TestCallbackHandler implements InvokerCallbackHandler { public boolean receivedCallback; public void handleCallback(Callback callback) throws HandleCallbackException { receivedCallback = true; log.info("received callback: " + callback); } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000755000175000017500000000000011632407037033552 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/AbstractTimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000436510557732672033577 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Client; import org.jboss.logging.XLevel; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PatternLayout; import org.apache.log4j.ConsoleAppender; import junit.framework.TestCase; /** * @author Tom Elrod */ public abstract class AbstractTimeoutClientTest extends TestCase { public void testClientCalls() { try { InvokerLocator locator = new InvokerLocator(getLocator()); Client client = new Client(locator); client.connect(); client.invokeOneway("cheese"); Thread.currentThread().sleep(8000); client.invokeOneway("poofs"); Thread.currentThread().sleep(5000); Object ret = client.invoke("crackers"); client.disconnect(); // server should be incrementing call count for every invocation (regardless of type) // so ret should equal 3, for 3 invocations it received. assertEquals(3, ((Integer)ret).intValue()); } catch (Throwable throwable) { throwable.printStackTrace(); } } protected abstract String getLocator(); }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/jboss/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000755000175000017500000000000011632407037033552 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/jboss/TimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000260310557732672033570 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway.jboss; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(TimeoutClientTest.class.getName(), 1, TimeoutServerTest.class.getName()); } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/jboss/TimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000421410557732672033570 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway.jboss; import org.jboss.test.remoting.transport.socket.timeout.oneway.AbstractTimeoutClientTest; import org.jboss.logging.XLevel; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PatternLayout; import org.apache.log4j.ConsoleAppender; /** * @author Tom Elrod */ public class TimeoutClientTest extends AbstractTimeoutClientTest { protected String getLocator() { return "socket://localhost:5700/?serializationtype=jboss"; } public static void main(String[] args) { // Logger.getLogger("org.jboss.remoting").setLevel(Level.DEBUG); Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE); 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); AbstractTimeoutClientTest test = new TimeoutClientTest(); test.testClientCalls(); } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/jboss/TimeoutServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000450410557732672033572 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway.jboss; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PatternLayout; import org.apache.log4j.ConsoleAppender; import org.jboss.logging.XLevel; import org.jboss.test.remoting.transport.socket.timeout.oneway.AbstractTimeoutServerTest; /** * @author Tom Elrod */ public class TimeoutServerTest extends AbstractTimeoutServerTest { protected String getLocator() { return "socket://localhost:5700/?serializationtype=jboss&timeout=" + timeout; } public static void main(String[] args) { // Logger.getLogger("org.jboss.remoting").setLevel(Level.DEBUG); Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE); 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); AbstractTimeoutServerTest test = new TimeoutServerTest(); try { test.setUp(); Thread.currentThread().sleep(600000); test.tearDown(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/java/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000755000175000017500000000000011632407037033552 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/java/TimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000260210557732672033567 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway.java; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(TimeoutClientTest.class.getName(), 1, TimeoutServerTest.class.getName()); } }././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/java/TimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000416210557732672033572 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway.java; import org.jboss.test.remoting.transport.socket.timeout.oneway.AbstractTimeoutClientTest; import org.jboss.logging.XLevel; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PatternLayout; import org.apache.log4j.ConsoleAppender; /** * @author Tom Elrod */ public class TimeoutClientTest extends AbstractTimeoutClientTest { protected String getLocator() { return "socket://localhost:5700"; } public static void main(String[] args) { // Logger.getLogger("org.jboss.remoting").setLevel(Level.DEBUG); Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE); 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); AbstractTimeoutClientTest test = new TimeoutClientTest(); test.testClientCalls(); } }././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/java/TimeoutServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000445310557732672033575 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway.java; import org.jboss.test.remoting.transport.socket.timeout.oneway.AbstractTimeoutServerTest; import org.jboss.logging.XLevel; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PatternLayout; import org.apache.log4j.ConsoleAppender; /** * @author Tom Elrod */ public class TimeoutServerTest extends AbstractTimeoutServerTest { protected String getLocator() { return "socket://localhost:5700/?timeout=" + timeout; } public static void main(String[] args) { // Logger.getLogger("org.jboss.remoting").setLevel(Level.DEBUG); Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE); 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); AbstractTimeoutServerTest test = new TimeoutServerTest(); try { test.setUp(); Thread.currentThread().sleep(600000); test.tearDown(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/TimeoutTestHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000433210557436136033565 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.callback.InvokerCallbackHandler; import javax.management.MBeanServer; /** * @author Tom Elrod */ public class TimeoutTestHandler implements ServerInvocationHandler { private InvokerCallbackHandler callbackHandler; private int callCounter = 0; public void setMBeanServer(MBeanServer server) { //To change body of implemented methods use File | Settings | File Templates. } public void setInvoker(ServerInvoker invoker) { //To change body of implemented methods use File | Settings | File Templates. } public Object invoke(InvocationRequest invocation) throws Throwable { System.out.println("received invocation of " + invocation.getParameter()); callCounter++; return new Integer(callCounter); } public void addListener(InvokerCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } public void removeListener(InvokerCallbackHandler callbackHandler) { this.callbackHandler = null; } }././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/oneway/AbstractTimeoutServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/one0000644000175000017500000000365510557732672033600 0ustar twernertwerner/* * 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.transport.socket.timeout.oneway; import org.jboss.remoting.transport.Connector; import org.jboss.logging.XLevel; import org.jboss.jrunit.extensions.ServerTestCase; import org.apache.log4j.Logger; import org.apache.log4j.Level; import org.apache.log4j.PatternLayout; import org.apache.log4j.ConsoleAppender; /** * @author Tom Elrod */ public abstract class AbstractTimeoutServerTest extends ServerTestCase { private Connector connector = null; protected String timeout = "5000"; public void setUp() throws Exception { connector = new Connector(getLocator()); connector.create(); connector.addInvocationHandler("timeout_test", new TimeoutTestHandler()); connector.start(); } protected abstract String getLocator(); public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/keepalive/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/kee0000755000175000017500000000000011632407037033535 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/keepalive/TimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/kee0000644000175000017500000000747210433770344033553 0ustar twernertwerner/* * 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.transport.socket.timeout.keepalive; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.net.SocketTimeoutException; import java.rmi.MarshalException; /** * @author Tom Elrod */ public class TimeoutClientTest { //private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=500&clientMaxPoolSize=100&maxPoolSize=500"; //private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=0&clientMaxPoolSize=10&maxPoolSize=3"; private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=0&clientMaxPoolSize=10&maxPoolSize=3&serializationtype=jboss"; private Client client = null; public void testTimeout() throws Exception { client = new Client(new InvokerLocator(locatorURI)); client.connect(); for(int x = 0; x < 50; x++) { new Thread(new Runnable() { public void run() { try { makeCall(); } catch(Exception e) { e.printStackTrace(); } } }).start(); } } public void makeCall() throws Exception { //test for client timeout try { client.invoke("foo"); client.invoke("foo"); client.invoke("foo"); client.invoke("foo"); Thread.currentThread().sleep(2000); client.invoke("bar"); client.invoke("bar"); client.invoke("bar"); Thread.currentThread().sleep(1000); client.invoke("bar"); client.invoke("bar"); Object ret = client.invoke("bar"); System.out.println("Done making all calls after sleeping. Return is " + ret); } catch(Throwable throwable) { if(throwable instanceof MarshalException) { Throwable cause = throwable.getCause(); if(cause instanceof SocketTimeoutException) { System.out.println("Got socket timeout exception - " + cause.getMessage()); return; } } if(throwable instanceof Exception) { throw (Exception) throwable; } else { throw new Exception(throwable); } } } public static void main(String[] args) { // org.apache.log4j.BasicConfigurator.configure(); // org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE); //org.apache.log4j.Category.getRoot().setLevel(XLevel.TRACE); TimeoutClientTest client = new TimeoutClientTest(); try { client.testTimeout(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/keepalive/TimeoutServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/kee0000644000175000017500000001113710355142433033537 0ustar twernertwerner/* * 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.transport.socket.timeout.keepalive; import javax.management.MBeanServer; 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; /** * @author Tom Elrod */ public class TimeoutServerTest { //private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=500&clientMaxPoolSize=100&maxPoolSize=500"; //private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=0&clientMaxPoolSize=10&maxPoolSize=3"; private String locatorURI = "socket://localhost:8899/?socketTimeout=1000&backlog=0&clientMaxPoolSize=10&maxPoolSize=3&serializationtype=jboss"; private Connector connector = null; private static int counter = 0; public void setUp() throws Exception { connector = new Connector(); InvokerLocator locator = new InvokerLocator(locatorURI); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler("test", new TimeoutHandler()); connector.start(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { // org.apache.log4j.BasicConfigurator.configure(); // org.apache.log4j.Category.getInstance("org.jboss.remoting.transport.socket.ServerThread").setLevel(XLevel.TRACE); // org.apache.log4j.Category.getInstance("org.jboss.remoting.transport.socket.SocketServerInvoker").setLevel(XLevel.TRACE); TimeoutServerTest server = new TimeoutServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } private class TimeoutHandler implements ServerInvocationHandler { /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { Object obj = invocation.getParameter(); if(obj instanceof String && "timeout".equals(obj)) { Thread.currentThread().sleep(30000); } return new Integer(++counter); //TODO: -TME Implement } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/TimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Tim0000644000175000017500000000545610542177366033546 0ustar twernertwerner/* * 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.transport.socket.timeout; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class TimeoutClientTest extends TestCase { // private String locatorURI = "socket://localhost:8899/?timeout=3000"; // private String locatorURI = "socket://localhost:8899"; protected String getTransport() { return "socket"; } public void testTimeout() throws Exception { Map config = new HashMap(); config.put("timeout", "3000"); String locatorURI = getTransport() + "://localhost:8899"; Client client = new Client(new InvokerLocator(locatorURI), config); client.connect(); //test for client timeout try { client.invoke("foo"); Thread.currentThread().sleep(5000); client.invoke("bar"); System.out.println("Done making all calls after sleeping."); } catch(Throwable throwable) { if(throwable instanceof Exception) { throw (Exception) throwable; } else { throw new Exception(throwable); } } long start = System.currentTimeMillis(); long end = 0; try { client.invoke("timeout"); end = System.currentTimeMillis(); } catch(Throwable t) { System.out.println("Caught exception: " + t.getMessage()); end = System.currentTimeMillis(); } long executionTime = end - start; System.out.println("execution time was " + executionTime); boolean timedOut = (executionTime < 10000); assertTrue("Socket did not timeout within expected time", timedOut); } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000755000175000017500000000000011632407037033541 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/InactiveIdleTimeoutTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000644000175000017500000000515410542177366033560 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.timeout.idle; import org.apache.log4j.Logger; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * This is just like IdleTimeoutTestServer except instead of * looking for server threads that are still in read mode waiting for * data from client, want to test for idle server threads that finished with * client/server connection and are just sitting in the thread pool waiting to * be re-used. * * @author Tom Elrod */ public class InactiveIdleTimeoutTestServer extends ServerTestCase { private Connector connector; private Logger logger = Logger.getRootLogger(); protected String getTransport() { return "socket"; } public static void main(String[] args) throws Throwable { InactiveIdleTimeoutTestServer rt = new InactiveIdleTimeoutTestServer(); rt.setUp(); Thread.currentThread().sleep(45000); rt.tearDown(); } public void setUp() throws Exception { startServer(); } public void tearDown() throws Exception { if(connector != null) { try { // check for empty thread pool SocketServerInvoker svrInvoker = (SocketServerInvoker)connector.getServerInvoker(); int threadPoolSize = svrInvoker.getCurrentThreadPoolSize(); if(threadPoolSize > 0) { System.out.println("Error - thread pool should be size of 0, but is " + threadPoolSize); throw new RuntimeException("Thread pool was not size of 0, but " + threadPoolSize); } else { System.out.println("Pass - thread pool size is 0"); } } finally { connector.stop(); connector.destroy(); } } } public void startServer() throws Exception { // String locatorURI = "socket://localhost:54000/?maxPoolSize=2&timeout=60000&backlog=0"; String locatorURI = getTransport() + "://localhost:54000/?maxPoolSize=2&backlog=0&timeout=10000&idleTimeout=15"; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/IdleTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000644000175000017500000000231110522663260033537 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.timeout.idle; import org.jboss.jrunit.harness.TestDriver; public class IdleTimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(IdleTimeoutClientTest.class.getName(), 2, IdleTimeoutTestServer.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 360000; } /** * 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 360000; } /** * 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 360000; } }././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/InactiveIdleTimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000644000175000017500000000411110542177366033550 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.timeout.idle; import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class InactiveIdleTimeoutClientTest extends TestCase { // private static int numOfRunnerThreads = 10; private static int numOfRunnerThreads = 2; private static SynchronizedInt responseCount = new SynchronizedInt(0); private Logger logger = Logger.getRootLogger(); protected String getTransport() { return "socket"; } public static void main(String[] args) throws Throwable { InactiveIdleTimeoutClientTest rt = new InactiveIdleTimeoutClientTest(); // rt.runMultipleClients(Integer.parseInt(args[1])); rt.runMultipleClients(numOfRunnerThreads); } public void testRunClients() throws Throwable { runMultipleClients(numOfRunnerThreads); Thread.currentThread().sleep(60000); } public void runClient(String clientId) throws Throwable { String locatorURI = getTransport() + "://localhost:54000/?clientMaxPoolSize=50&timeout=10000"; InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); String req = clientId; Object resp = client.invoke(req); responseCount.increment(); System.out.println("Received response of: " + resp + ". Response count = " + responseCount); } public void runMultipleClients(int cnt) throws Throwable { for (int i = 0; i < cnt; i++) { Thread t = new Thread(new Runnable() { public void run() { try { Thread.sleep(1000); runClient(Thread.currentThread().getName()); } catch (Throwable e) { logger.error(e); e.printStackTrace(); } } }, Integer.toString(i)); t.start(); } } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/InactiveIdleTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000644000175000017500000000234210522710540033535 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.timeout.idle; import org.jboss.jrunit.harness.TestDriver; public class InactiveIdleTimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InactiveIdleTimeoutClientTest.class.getName(), 1, InactiveIdleTimeoutTestServer.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 360000; } /** * 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 360000; } /** * 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 360000; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/IdleTimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000644000175000017500000000545610542177366033565 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.timeout.idle; import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class IdleTimeoutClientTest extends TestCase { // private static int numOfRunnerThreads = 10; private static int numOfRunnerThreads = 2; private static SynchronizedInt responseCount = new SynchronizedInt(0); private Logger logger = Logger.getRootLogger(); protected String getTransport() { return "socket"; } public static void main(String[] args) throws Throwable { IdleTimeoutClientTest rt = new IdleTimeoutClientTest(); // rt.runMultipleClients(Integer.parseInt(args[1])); rt.runMultipleClients(numOfRunnerThreads); } public void testRunClients() throws Throwable { String locatorURI = getTransport() + "://localhost:54000/?clientMaxPoolSize=50&timeout=10000"; InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); Object resp = client.invoke(Boolean.TRUE); Boolean isFirst = (Boolean)resp; System.out.println("client is first = " + isFirst); Thread.currentThread().sleep(10000); if(isFirst.booleanValue()) { Thread.currentThread().sleep(10000); } runMultipleClients(numOfRunnerThreads); Thread.currentThread().sleep(30000); System.out.println("done with first timeout."); runMultipleClients(numOfRunnerThreads); Thread.currentThread().sleep(12000); System.out.println("response count = " + responseCount.get()); assertEquals(4, responseCount.get()); } public void runClient(String clientId) throws Throwable { String locatorURI = "socket://localhost:54000/?clientMaxPoolSize=50&timeout=10000"; InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); String req = clientId; Object resp = client.invoke(req); responseCount.increment(); System.out.println("Received response of: " + resp + ". Response count = " + responseCount); } public void runMultipleClients(int cnt) throws Throwable { for (int i = 0; i < cnt; i++) { Thread t = new Thread(new Runnable() { public void run() { try { Thread.sleep(1000); runClient(Thread.currentThread().getName()); } catch (Throwable e) { logger.error(e); e.printStackTrace(); } } }, Integer.toString(i)); t.start(); } } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/SafeIdleTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000644000175000017500000001326211413660476033554 0ustar twernertwerner/* * 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.transport.socket.timeout.idle; 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; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-1107. * * @author Ron Sigal * @version *

* Copyright Sep 2, 2009 *

*/ public class SafeIdleTimeoutTestCase extends TestCase { private static Logger log = Logger.getLogger(SafeIdleTimeoutTestCase.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 testSafeIdleTimeout() 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("numberOfCallRetries", "1"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Verify invocation can complete. assertEquals("abc", client.invoke("abc")); // Verify ServerThread was discarded. SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(0, serverInvoker.getCurrentClientPoolSize()); assertEquals(0, serverInvoker.getCurrentThreadPoolSize()); 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 + "/?&idleTimeout=2"; 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 void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { log.info(this + " going to sleep"); Thread.sleep(10000); log.info(this + " has woken up"); return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/IdleTimeoutTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000644000175000017500000000301210542177366033547 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.timeout.idle; import org.apache.log4j.Logger; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class IdleTimeoutTestServer extends ServerTestCase { private Connector connector; private Logger logger = Logger.getRootLogger(); protected String getTransport() { return "socket"; } public static void main(String[] args) throws Throwable { IdleTimeoutTestServer rt = new IdleTimeoutTestServer(); rt.startServer(); } public void setUp() throws Exception { startServer(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void startServer() throws Exception { // String locatorURI = "socket://localhost:54000/?maxPoolSize=2&timeout=60000&backlog=0"; String locatorURI = getTransport() + "://localhost:54000/?maxPoolSize=2&backlog=0&timeout=60000&idleTimeout=5"; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idle/SampleInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/idl0000644000175000017500000000265610522665353033560 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.timeout.idle; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.apache.log4j.Logger; import javax.management.MBeanServer; public class SampleInvocationHandler implements ServerInvocationHandler { private static Logger logger = Logger.getRootLogger(); private boolean first = true; public Object invoke(InvocationRequest invocation) throws Throwable { Object parm = invocation.getParameter(); if(parm instanceof Boolean) { synchronized(this) { if(first) { first = false; return Boolean.TRUE; } else { return Boolean.FALSE; } } } System.out.println(Thread.currentThread() + "******* Invoked " + parm); //Thread.sleep(5000); System.out.println(Thread.currentThread() + "******* Returning - response" + parm); String s = "response" + parm; return s; } public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/TimeoutServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Tim0000644000175000017500000001037510542177366033542 0ustar twernertwerner/* * 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.transport.socket.timeout; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class TimeoutServerTest extends ServerTestCase { // private String locatorURI = "socket://localhost:8899/?timeout=3000"; // private String locatorURI = "socket://localhost:8899"; private Connector connector = null; protected String getTransport() { return "socket"; } public void setUp() throws Exception { Map config = new HashMap(); config.put("timeout", "3000"); String locatorURI = getTransport() + "://localhost:8899"; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(locator, config); connector.create(); connector.addInvocationHandler("test", new TimeoutHandler()); connector.start(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { TimeoutServerTest server = new TimeoutServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } private class TimeoutHandler implements ServerInvocationHandler { /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { Object obj = invocation.getParameter(); if(obj instanceof String && "timeout".equals(obj)) { Thread.currentThread().sleep(30000); } return null; //TODO: -TME Implement } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/SocketQuickDisconnectServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Soc0000644000175000017500000000323610567012300033512 0ustar twernertwerner/* * 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.transport.socket.timeout; import org.jboss.test.remoting.timeout.QuickDisconnectServerParent; /** * @author Ron Sigal * @version $Revision: 2185 $ *

* Copyright Feb 18, 2007 *

*/ public class SocketQuickDisconnectServer extends QuickDisconnectServerParent { public static void main(String[] args) { try { SocketQuickDisconnectServer server = new SocketQuickDisconnectServer(); server.setUp(); Thread.sleep(100000); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "socket"; } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/SocketQuickDisconnectClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Soc0000644000175000017500000000257710567012300033521 0ustar twernertwerner/* * 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.transport.socket.timeout; import org.jboss.test.remoting.timeout.QuickDisconnectClientParent; /** * @author Ron Sigal * @version $Revision: 2185 $ *

* Copyright Feb 17, 2007 *

*/ public class SocketQuickDisconnectClient extends QuickDisconnectClientParent { protected String getTransport() { return "socket"; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/SocketWriteTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Soc0000644000175000017500000000251011413660476033522 0ustar twernertwerner/* * 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.transport.socket.timeout; /** * Unit tests for JBREM-1120. * * @author Ron Sigal * @version $Rev$ *

* Copyright Apr 22, 2009 *

*/ public class SocketWriteTimeoutTestCase extends WriteTimeoutTestParent { protected String getTransport() { return "socket"; } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/SocketDefaultTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Soc0000644000175000017500000001764311413704546033534 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2010, 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.transport.socket.timeout; import java.io.IOException; import java.lang.reflect.Method; import java.net.InetAddress; 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.logging.XLevel; 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.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.socket.ServerAddress; import org.jboss.remoting.transport.socket.SocketClientInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit tests for JBREM-1188. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 16, 2010 */ public class SocketDefaultTimeoutTestCase extends TestCase { private static Logger log = Logger.getLogger(SocketDefaultTimeoutTestCase.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); } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.registerInvokerFactories(getTransport(), getClientFactoryClass(), TestServerFactory.class); return null; } }); } public void tearDown() { } public void testDefaultTimeout() 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"); Method getServerAddress = getClientInvokerClass().getMethod("getServerAddress", new Class[]{}); getServerAddress.setAccessible(true); ClientInvoker clientInvoker = client.getInvoker(); ServerAddress address = (ServerAddress) getServerAddress.invoke(clientInvoker, new Object[]{}); log.info("timeout in use: " + address.timeout); assertEquals(SocketClientInvoker.SO_TIMEOUT_DEFAULT, address.timeout); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "test"; } 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 Class getClientFactoryClass() { return TestSocketClientFactory.class; } protected Class getClientInvokerClass() { return TestSocketClientInvoker.class; } 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 public class TestSocketClientInvoker extends SocketClientInvoker { public TestSocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); } public TestSocketClientInvoker(InvokerLocator locator) { super(locator); } public ServerAddress getServerAddress() { return address; } public String toString() { return "TestSocketClientInvoker"; } } public static class TestSocketClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { ClientInvoker clientInvoker = new TestSocketClientInvoker(locator, config); log.info("TestClientFaotory.createClientInvoker() returning " + clientInvoker); return clientInvoker; } public boolean supportsSSL() { return false; } } public static class TestServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException { log.info("TestServerFactory.createServerInvoker() called"); return new SocketServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } }././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/SSLWriteTimeoutTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/SSL0000644000175000017500000004565211413660476033455 0ustar twernertwerner/* * 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.transport.socket.timeout; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Constructor; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketAddress; import java.net.UnknownHostException; import java.util.Map; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; /** * Unit tests for JBREM-1120. * * @author Ron Sigal * @version $Rev$ *

* Copyright Apr 22, 2009 *

*/ public abstract class SSLWriteTimeoutTestParent extends WriteTimeoutTestParent { private static Logger log = Logger.getLogger(SSLWriteTimeoutTestParent.class); private static boolean firstTime = true; protected static int SECONDARY_SERVER_SOCKET_PORT = 8765; protected static String SECONDARY_SERVER_SOCKET_PORT_STRING = "8765"; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} public void setUp() throws Exception { if (firstTime) { String keyStoreFilePath = getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client"); } super.setUp(); } protected String getServerSocketFactoryClassName() { return SSLTestServerSocketFactory.class.getName(); } protected Constructor getServerSocketFactoryConstructor() throws NoSuchMethodException { return SSLTestServerSocketFactory.class.getConstructor(new Class[]{int.class, int.class}); } protected String getSocketFactoryClassName() { return SSLTestSocketFactory.class.getName(); } protected Constructor getSocketFactoryConstructor() throws NoSuchMethodException { return SSLTestSocketFactory.class.getConstructor(new Class[]{int.class, int.class}); } static public class SSLTestServerSocketFactory extends ServerSocketFactory { int timeout; ServerSocketFactory factory; int initialWrites; public SSLTestServerSocketFactory() throws IOException { this.timeout = 5000; this.initialWrites = -1; setupFactory(); } public SSLTestServerSocketFactory(int timeout, int initialWrites) throws IOException { this.timeout = timeout; this.initialWrites = initialWrites; setupFactory(); } public ServerSocket createServerSocket() throws IOException { ServerSocket ss = null; if (callbackTest) { ss = SSLServerSocketFactory.getDefault().createServerSocket(); } else { ss = new SSLTestServerSocket(timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket())); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port) throws IOException { ServerSocket ss = null; if (callbackTest && port != secondaryServerSocketPort) { ss = SSLServerSocketFactory.getDefault().createServerSocket(port); } else { ss = new SSLTestServerSocket(port, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket())); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog) throws IOException { ServerSocket ss = null; if (callbackTest && port != secondaryServerSocketPort) { ss = SSLServerSocketFactory.getDefault().createServerSocket(port, backlog); } else { ss = new SSLTestServerSocket(port, backlog, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket())); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException { ServerSocket ss = null; if (callbackTest && port != secondaryServerSocketPort) { ss = SSLServerSocketFactory.getDefault().createServerSocket(port, backlog, ifAddress); } else { ss = new SSLTestServerSocket(port, backlog, ifAddress, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket())); } log.info("returning: " + ss); return ss; } protected void setupFactory() throws IOException { SSLSocketBuilder sslSocketBuilder = new SSLSocketBuilder(); sslSocketBuilder.setUseSSLServerSocketFactory(false); factory = sslSocketBuilder.createSSLServerSocketFactory(); } } static class SSLTestServerSocket extends SSLServerSocket { int timeout; int initialWrites; SSLServerSocket serverSocket; public SSLTestServerSocket(int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException { super(); this.timeout = timeout; this.initialWrites = initialWrites; this.serverSocket = serverSocket; } public SSLTestServerSocket(int port, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException { super(port); this.timeout = timeout; this.initialWrites = initialWrites; this.serverSocket = serverSocket; bind(new InetSocketAddress(port), 50); } public SSLTestServerSocket(int port, int backlog, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException { super(port, backlog); this.timeout = timeout; this.initialWrites = initialWrites; this.serverSocket = serverSocket; bind(new InetSocketAddress(port), backlog); } public SSLTestServerSocket(int port, int backlog, InetAddress bindAddr, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException { super(port, backlog, bindAddr); this.timeout = timeout; this.initialWrites = initialWrites; this.serverSocket = serverSocket; bind(new InetSocketAddress(bindAddr, port), 50); } public Socket accept() throws IOException { SSLSocket s1 = (SSLSocket) serverSocket.accept(); Socket s2 = new SSLTestSocket(timeout, initialWrites, s1); return s2; } public void bind(SocketAddress endpoint, int backlog) throws IOException { log.info("serverSocket: " + serverSocket); if (serverSocket != null) log.info("bound: " + serverSocket.isBound()); if (serverSocket != null && !serverSocket.isBound()) { log.info("binding " + serverSocket); serverSocket.bind(endpoint, backlog); } } public String toString() { return "SSLTestServerSocket[" + serverSocket.toString() + "]"; } public boolean getEnableSessionCreation() { return serverSocket.getEnableSessionCreation(); } public String[] getEnabledCipherSuites() { return serverSocket.getEnabledCipherSuites(); } public String[] getEnabledProtocols() { return serverSocket.getEnabledProtocols(); } public boolean getNeedClientAuth() { return serverSocket.getNeedClientAuth(); } public String[] getSupportedCipherSuites() { return serverSocket.getSupportedCipherSuites(); } public String[] getSupportedProtocols() { return serverSocket.getSupportedProtocols(); } public boolean getUseClientMode() { return serverSocket.getUseClientMode(); } public boolean getWantClientAuth() { return serverSocket.getWantClientAuth(); } public void setEnableSessionCreation(boolean arg0) { serverSocket.setEnableSessionCreation(arg0); } public void setEnabledCipherSuites(String[] arg0) { serverSocket.setEnabledCipherSuites(arg0); } public void setEnabledProtocols(String[] arg0) { serverSocket.setEnabledProtocols(arg0); } public void setNeedClientAuth(boolean arg0) { serverSocket.setNeedClientAuth(arg0); } public void setUseClientMode(boolean arg0) { serverSocket.setUseClientMode(arg0); } public void setWantClientAuth(boolean arg0) { serverSocket.setWantClientAuth(arg0); } } public static class SSLTestSocketFactory extends SocketFactory { int timeout; int initialWrites; SocketFactory factory; public SSLTestSocketFactory() throws IOException { timeout = 5000; initialWrites = -1; setupFactory(); } public SSLTestSocketFactory(int timeout, int initialWrites) throws IOException { this.timeout = timeout; this.initialWrites = initialWrites; setupFactory(); } public Socket createSocket() throws IOException { log.info("callbackTest: " + callbackTest); Socket s = null; if (callbackTest) { s = factory.createSocket(); } else { s = new TestSocket(timeout, initialWrites); s = new SSLTestSocket(timeout, initialWrites, ((SSLSocket) factory.createSocket())); } log.info(this + " returning " + s); return s; } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { log.info("callbackTest: " + callbackTest); Socket s = null; if (callbackTest && arg1 != secondaryServerSocketPort) { s = factory.createSocket(arg0, arg1); } else { s = new TestSocket(timeout, initialWrites); s = new SSLTestSocket(arg0, arg1, timeout, initialWrites, ((SSLSocket) factory.createSocket())); } log.info(this + " returning " + s); return s; } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { log.info("callbackTest: " + callbackTest); Socket s = null; if (callbackTest && arg1 != secondaryServerSocketPort) { s = factory.createSocket(arg0, arg1); } else { s = new TestSocket(timeout, initialWrites); s = new SSLTestSocket(arg0, arg1, timeout, initialWrites, ((SSLSocket) factory.createSocket())); } log.info(this + " returning " + s); return s; } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { log.info("callbackTest: " + callbackTest); Socket s = null; if (callbackTest && arg1 != secondaryServerSocketPort) { s = factory.createSocket(arg0, arg1); } else { s = new TestSocket(timeout, initialWrites); s = new SSLTestSocket(arg0, arg1, arg2, arg3, timeout, initialWrites, ((SSLSocket) factory.createSocket())); } log.info(this + " returning " + s); return s; } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { log.info("callbackTest: " + callbackTest); Socket s = null; if (callbackTest && arg1 != secondaryServerSocketPort) { s = factory.createSocket(arg0, arg1); } else { s = new TestSocket(timeout, initialWrites); s = new SSLTestSocket(arg0, arg1, arg2, arg3, timeout, initialWrites, ((SSLSocket) factory.createSocket())); } log.info(this + " returning " + s); return s; } protected void setupFactory() throws IOException { SSLSocketBuilder sslSocketBuilder = new SSLSocketBuilder(); sslSocketBuilder.setUseSSLServerSocketFactory(false); factory = sslSocketBuilder.createSSLSocketFactory(); } } static class SSLTestSocket extends SSLSocket { int timeout; int initialWrites; SSLSocket socket; SocketAddress endpoint; public SSLTestSocket(int timeout, int initialWrites, SSLSocket socket) { this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; } public SSLTestSocket(String host, int port, int timeout, int initialWrites, SSLSocket socket) throws UnknownHostException, IOException { super(host, port); this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; connect(new InetSocketAddress(host, port), timeout); } public SSLTestSocket(InetAddress address, int port, int timeout, int initialWrites, SSLSocket socket) throws IOException { super(address, port); this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; connect(new InetSocketAddress(address, port), timeout); } public SSLTestSocket(String host, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites, SSLSocket socket) throws IOException { super(host, port, localAddr, localPort); this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; bind(new InetSocketAddress(localAddr, localPort)); connect(new InetSocketAddress(host, port), timeout); } public SSLTestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites, SSLSocket socket) throws IOException { super(address, port, localAddr, localPort); this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; bind(new InetSocketAddress(localAddr, localPort)); connect(new InetSocketAddress(address, port), timeout); } public String toString() { return "SSLTestSocket[" + socket.toString() + "]"; } public InputStream getInputStream() throws IOException { return socket.getInputStream(); } public OutputStream getOutputStream() throws IOException { return new TestOutputStream(socket.getOutputStream(), timeout, initialWrites); } public void addHandshakeCompletedListener(HandshakeCompletedListener listener) { socket.addHandshakeCompletedListener(listener); } public void bind(SocketAddress bindpoint) throws IOException { if (socket != null) socket.bind(bindpoint); } public void connect(SocketAddress endpoint) throws IOException { if (socket != null) socket.connect(endpoint); } public void connect(SocketAddress endpoint, int timeout) throws IOException { socket.connect(endpoint, timeout); } public boolean getEnableSessionCreation() { return socket.getEnableSessionCreation(); } public String[] getEnabledCipherSuites() { return socket.getEnabledCipherSuites(); } public String[] getEnabledProtocols() { return socket.getEnabledProtocols(); } public InetAddress getInetAddress() { return socket.getInetAddress(); } public boolean getNeedClientAuth() { return socket.getNeedClientAuth(); } public SSLSession getSession() { return socket.getSession(); } public String[] getSupportedCipherSuites() { return socket.getSupportedCipherSuites(); } public String[] getSupportedProtocols() { return socket.getSupportedProtocols(); } public boolean getUseClientMode() { return socket.getUseClientMode(); } public boolean getWantClientAuth() { return socket.getWantClientAuth(); } public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) { socket.removeHandshakeCompletedListener(listener); } public void setEnableSessionCreation(boolean flag) { socket.setEnableSessionCreation(flag); } public void setEnabledCipherSuites(String[] suites) { socket.setEnabledCipherSuites(suites); } public void setEnabledProtocols(String[] protocols) { socket.setEnabledProtocols(protocols); } public void setNeedClientAuth(boolean need) { socket.setNeedClientAuth(need); } public void setUseClientMode(boolean mode) { socket.setUseClientMode(mode); } public void setWantClientAuth(boolean want) { socket.setWantClientAuth(want); } public void startHandshake() throws IOException { socket.startHandshake(); } } }././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/SocketPerInvocationTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Soc0000644000175000017500000001630410716262301033516 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.timeout; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; import org.jboss.test.remoting.timeout.PerInvocationTimeoutTestRoot; /** * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 2939 $ *

* Copyright Feb 6, 2007 *

*/ public class SocketPerInvocationTimeoutTestCase extends PerInvocationTimeoutTestRoot { /** * This test verifies that the timeout for a socket wrapper gets reset after * an invocation with an invocation specific timeout has been executed. */ public void testTimeoutReset() throws Throwable { log.info("entering " + getName()); ClientInvoker invoker = client.getInvoker(); assertTrue(invoker instanceof MicroSocketClientInvoker); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool = (List) field.get(invoker); assertEquals(0, pool.size()); Object response = client.invoke(NO_WAIT); assertEquals(NO_WAIT, response); assertEquals(1, pool.size()); SocketWrapper socket = (SocketWrapper) pool.get(0); assertEquals(CONFIGURED_TIMEOUT, socket.getTimeout()); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "1000"); response = client.invoke(NO_WAIT, metadata); assertEquals(NO_WAIT, response); assertEquals(1, pool.size()); socket = (SocketWrapper) pool.get(0); assertEquals(CONFIGURED_TIMEOUT, socket.getTimeout()); } // This test verifies that a temporary timeout value gets passed when a new // socket wrapper is created. It is important that the socket wrapper gets // the temporary timeout value because creating object streams entails i/o // on the socket. public void testNewSocketTimeout() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); addServerConfig(serverConfig); final Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); // Disable the server so that the client will need to create a new socket, and // so that the creation of the socket wrapper will fail. new Thread() { public void run() { try { // Give the client a chance to connect to the server, then // disable the server. Thread.sleep(2000); ServerInvoker si = connector.getServerInvoker(); assertTrue(si instanceof SocketServerInvoker); SocketServerInvoker ssi = (SocketServerInvoker) si; Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(ssi); Set threads = clientpool.getContents(); Iterator it = threads.iterator(); while (it.hasNext()) { ServerThread t = (ServerThread) it.next(); t.shutdown(); } ssi.setMaxPoolSize(0); log.info("server is disabled"); } catch (Exception e) { log.info(e); } } }.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(ServerInvoker.TIMEOUT, "20000"); clientConfig.put(Client.ENABLE_LEASE, "true"); addClientConfig(clientConfig); final Client client = new Client(locator, clientConfig); client.connect(); Object response = client.invoke("test 1"); assertEquals("test 1", response); class BooleanHolder {public boolean value;} final BooleanHolder timedOut = new BooleanHolder(); timedOut.value = false; new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(4000); // This invocation will require the creation of a new socket, which // should promptly time out. HashMap metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "1000"); client.invoke("test 3", metadata); fail("failed to time out"); } catch (Throwable e) { timedOut.value = true; log.info("time out", e); } } }.start(); // It should take the Client a little while for LeasePinger's attempts to contact // the server to time out. Wait for 4 seconds after the call to Client.invoke() // and then verify that the Client has timed out according to the temporary timeout // value 1000 instead of the configureed value 20000. Thread.sleep(8000); log.info("testing timeout"); assertTrue(timedOut.value); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected List getPool(ClientInvoker clientInvoker) throws Exception { List pool = null; if (clientInvoker instanceof MicroSocketClientInvoker) { Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); pool = (List) field.get(clientInvoker); } return pool; } public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/ServerThreadReuseAfterTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/timeout/Ser0000644000175000017500000002436411413660476033542 0ustar twernertwerner/* * 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.transport.socket.timeout; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; 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.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.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; public class ServerThreadReuseAfterTimeoutTestCase extends TestCase { private static Logger log = Logger.getLogger(ServerThreadReuseAfterTimeoutTestCase.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 testJavaSerializationDefault() throws Throwable { log.info("entering " + getName()); Map config = new HashMap(); doJavaSerializationTest(config); log.info(getName() + " PASSES"); } public void testJavaSerializationConfigured() throws Throwable { log.info("entering " + getName()); Map config = new HashMap(); config.put(ServerThread.CONTINUE_AFTER_TIMEOUT, "false"); doJavaSerializationTest(config); log.info(getName() + " PASSES"); } public void testJBossSerializationDefault() throws Throwable { log.info("entering " + getName()); Map config = new HashMap(); doJBossSerializationTest(config); log.info(getName() + " PASSES"); } public void testJBossSerializationConfigured() throws Throwable { log.info("entering " + getName()); Map config = new HashMap(); config.put(ServerThread.CONTINUE_AFTER_TIMEOUT, "true"); doJBossSerializationTest(config); log.info(getName() + " PASSES"); } public void doJavaSerializationTest(Map clientConfig) throws Throwable { log.info("entering " + getName()); // Start server. setupServer("java"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); 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"); // Get ServerThread. SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(invoker); assertEquals(1, clientpool.size()); Set s = clientpool.getContents(); ServerThread serverThread1 = (ServerThread) s.iterator().next(); // Get threadpool. field = SocketServerInvoker.class.getDeclaredField("threadpool"); field.setAccessible(true); LinkedList threadpool = (LinkedList) field.get(invoker); assertEquals(0, threadpool.size()); // Wait for ServerThread to time out. Thread.sleep(6000); for (int i = 0; i < 5; i++) { Thread.sleep(2000); if (clientpool.size() == 0) break; } if (clientpool.size() > 0) { fail("expect clientpool.size() == 0"); } // Verify original ServerThread was returned to threadpool. assertEquals(1, threadpool.size()); assertEquals(serverThread1, threadpool.iterator().next()); // Make another invocation and verify ServerThread was reused. client.invoke("xyz"); assertEquals(1, clientpool.size()); s = clientpool.getContents(); ServerThread serverThread2 = (ServerThread) s.iterator().next(); assertEquals(serverThread1, serverThread2); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void doJBossSerializationTest(Map clientConfig) throws Throwable { log.info("entering " + getName()); // Start server. setupServer("jboss"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); 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"); // Get clientpool and ServerThread. SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(invoker); assertEquals(1, clientpool.size()); Set clientpoolContents = clientpool.getContents(); ServerThread serverThread1 = (ServerThread) clientpoolContents.iterator().next(); // Get threadpool. field = SocketServerInvoker.class.getDeclaredField("threadpool"); field.setAccessible(true); LinkedList threadpool = (LinkedList) field.get(invoker); assertEquals(0, threadpool.size()); // Wait for ServerThread to time out. Thread.sleep(8000); // Verify original ServerThread remains in clientpool. assertEquals(0, threadpool.size()); assertEquals(1, clientpool.size()); clientpoolContents = clientpool.getContents(); assertEquals(serverThread1, clientpoolContents.iterator().next()); // Make another invocation and verify ServerThread was reused. client.invoke("xyz"); assertEquals(1, clientpool.size()); clientpoolContents = clientpool.getContents(); ServerThread serverThread2 = (ServerThread) clientpoolContents.iterator().next(); assertEquals(serverThread1, serverThread2); 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(String serializationType) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port + "/?timeout=4000"; locatorURI += "&serializationtype=" + serializationType; 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"); } } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionpools/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionp0000755000175000017500000000000011632407040033614 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionpools/ClearConnectionPoolsTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionp0000644000175000017500000001504310663151254033627 0ustar twernertwerner/* * 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.transport.socket.connectionpools; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.LinkedList; 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.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; /** * Unit test for JBREM-771. * * @author Ron Sigal * @version $Revision: 2681 $ *

* Copyright Aug 22, 2007 *

*/ public class ClearConnectionPoolsTestCase extends TestCase { private static Logger log = Logger.getLogger(ClearConnectionPoolsTestCase.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 MicroSocketClientInvoker clears its own connection pool * in handleDisconnect(). */ public void testClearConnectionPools() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int 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 clients. Using different timeout values will cause a different // connection pool to be created for each MicroSocketClientInvoker. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI + "/?timeout=3000"); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client1 = new Client(clientLocator1, clientConfig); client1.connect(); InvokerLocator clientLocator2 = new InvokerLocator(locatorURI + "/?timeout=7000"); Client client2 = new Client(clientLocator2, clientConfig); client2.connect(); assertEquals("abc", client1.invoke("abc")); assertEquals("abc", client2.invoke("abc")); log.info("clients are connected"); Field field = MicroSocketClientInvoker.class.getDeclaredField("connectionPools"); field.setAccessible(true); Map connectionPools = (Map) field.get(null); assertEquals(2, connectionPools.size()); // Disconnect second client - all pools should be cleard. client2.disconnect(); assertEquals(0, connectionPools.size()); field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(client1.getInvoker()); assertEquals(0, pool.size()); // Make an invocation on client1 to add a connection to its pool. client1.invoke("xyz"); assertEquals(1, pool.size()); // Disconnect client1 and verify that its own connection pool is empty. client1.disconnect(); assertEquals(0, pool.size()); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} 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"); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/restart/0000755000175000017500000000000011632407037033046 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/restart/SocketServerRestartTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/restart/Soc0000644000175000017500000000263510723136700033517 0ustar twernertwerner/* * 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.transport.socket.restart; import org.jboss.test.remoting.restart.ServerRestartTestParent; /** * Unit test for JBREM-745. * * @author Ron Sigal * @version $Revision: 3022 $ *

* Copyright November 27, 2007 *

*/ public class SocketServerRestartTestCase extends ServerRestartTestParent { protected String getTransport() { return "socket"; } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000755000175000017500000000000011632407040033513 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/SocketConnectionCheckTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000536310541703075033531 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.connection; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * @author Tom Elrod */ public class SocketConnectionCheckTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; public void testInvocations() throws Throwable { Client remotingClient = null; try { String locatorURI = getTransport() + "://" + host + ":" + getPort() + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.TRUE; // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); String request = "Do something"; System.out.println("Invoking server with request of '" + request + "'"); long startTime = System.currentTimeMillis(); int numOfCalls = 10000; Object response = null; for(int x = 0; x < numOfCalls; x++) { response = remotingClient.invoke(request); // System.out.println("Invocation response: " + response); } long endTime = System.currentTimeMillis(); System.out.println("Time to make " + numOfCalls + " was " + (endTime -startTime) + " milliseconds."); int callValue = 0; if(response instanceof Integer) { callValue = ((Integer) response).intValue(); } assertEquals(numOfCalls, callValue); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } protected String getTransport() { return transport; } protected int getPort() { return port; } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketConnectionCheckTestClient client = new SocketConnectionCheckTestClient(); try { client.testInvocations(); } catch(Throwable e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/ConnectionWaitTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000001671711413660476033544 0ustar twernertwerner/* * 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.transport.socket.connection; 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; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; /** * Unit test for JBREM-986. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 28, 2008 *

*/ public class ConnectionWaitTestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionWaitTestCase.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 testConnectionWaitDefault() 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"); // Verify connectionWait is set to default value. MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(MicroSocketClientInvoker.CONNECTION_WAIT_DEFAULT, invoker.getConnectionWait()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testConnectionWaitSetInLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI + "/?" + MicroSocketClientInvoker.CONNECTION_WAIT + "=12345"; 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(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify connectionWait is set to configured value. MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(12345, invoker.getConnectionWait()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testConnectionWaitSetInConfigMap() 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(MicroSocketClientInvoker.CONNECTION_WAIT, "12345"); 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"); // Verify connectionWait is set to configured value. MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(12345, invoker.getConnectionWait()); 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) {} } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/SocketConnectionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000327010535452155033527 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.connection; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * 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 SocketConnectionTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketTestClient.class.getName(), 1, SocketTestServer.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; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/SocketTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000001004410541703075033521 0ustar twernertwerner/* * 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.transport.socket.connection; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Version; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * @author Tom Elrod */ public class SocketTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; // private static String host = "192.168.1.100"; private static int port = 5400; private int numOfCalls = 10000; // private int numOfCalls = 2; public void testInvocations() throws Throwable { // System.setProperty(Version.PRE_2_0_COMPATIBLE, "true"); Client remotingClient = null; try { //String locatorURI = transport + "://" + host + ":" + port + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.TRUE; //String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.SERIALIZATIONTYPE + "=jboss"; String locatorURI = getTransport() + "://" + host + ":" + getPort(); // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); String request = "Do something"; System.out.println("Invoking server with request of '" + request + "'"); long startTime = System.currentTimeMillis(); Object response = null; for(int x = 0; x < numOfCalls; x++) { response = remotingClient.invoke(request); // System.out.println("Invocation response: " + response); } long endTime = System.currentTimeMillis(); System.out.println("Time to make " + numOfCalls + " was " + (endTime -startTime) + " milliseconds."); int callValue = 0; if(response instanceof Integer) { callValue = ((Integer) response).intValue(); } assertEquals(numOfCalls, callValue); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketTestClient client = new SocketTestClient(); try { client.testInvocations(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return transport; } protected int getPort() { return port; } }././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/SocketConnectionCheckTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000461210535452155033530 0ustar twernertwerner/* * 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.transport.socket.connection; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.apache.log4j.Level; /** * @author Tom Elrod */ public class SocketConnectionCheckTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketConnectionCheckTestClient.class.getName(), 1, SocketConnectionCheckTestServer.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; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/SocketConnectionCheckTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000001201010541703075033514 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.connection; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.socket.SocketServerInvoker; 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.InvokerCallbackHandler; import javax.management.MBeanServer; /** * @author Tom Elrod */ public class SocketConnectionCheckTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void setupServer(String locatorURI) throws Exception { // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(locator); // creates all the connector's needed resources, such as the server invoker connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setUp() throws Exception { String locatorURI = getTransport() + "://" + host + ":" + getPort() + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.TRUE; setupServer(locatorURI); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketConnectionCheckTestServer server = new SocketConnectionCheckTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } protected String getTransport() { return transport; } protected int getPort() { return port; } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request // System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++SocketConnectionCheckTestServer.callCounter); // System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/SocketTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000001436110541703075033527 0ustar twernertwerner/* * 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.transport.socket.connection; 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.Version; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.socket.SocketServerInvoker; import javax.management.MBeanServer; /** * @author Tom Elrod */ public class SocketTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; // private static String host = "192.168.1.100"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void setupServer(String locatorURI) throws Exception { // System.setProperty(Version.PRE_2_0_COMPATIBLE, "true"); // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(locator); // creates all the connector's needed resources, such as the server invoker connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setUp() throws Exception { //String locatorURI = transport + "://" + host + ":" + port + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.TRUE; //String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.SERIALIZATIONTYPE + "=jboss"; String locatorURI = getTransport() + "://" + host + ":" + getPort(); setupServer(locatorURI); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketTestServer server = new SocketTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } protected String getTransport() { return transport; } protected int getPort() { return port; } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request // System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); // System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/retry/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000755000175000017500000000000011632407040033513 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/retry/SocketRetryClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000571710541703075033534 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.connection.retry; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.socket.SocketClientInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * @author Tom Elrod */ public class SocketRetryClient extends TestCase { private static int numOfThread = 30; public static Throwable throwable = null; public void testConnection() throws Throwable { for (int i = 0; i < numOfThread; i++) { final int x = i; new Thread(new Runnable() { public void run() { try { new Caller().makeCalls(x, 1); } catch (Throwable throwable) { throwable.printStackTrace(); } } }).start(); } Thread.sleep(5000); new Thread(new Runnable() { public void run() { try { new Caller().makeCalls(5, 100); } catch (Throwable throwable) { throwable.printStackTrace(); } } }).start(); Thread.sleep(10000); if (throwable != null) { throw throwable; } } public class Caller { public void makeCalls(int sleepTime, int numOfCalls) throws Throwable { InvokerLocator locator = new InvokerLocator(getTransport() + "://localhost:" + getPort() + "/?" + SocketClientInvoker.SO_TIMEOUT_FLAG + "=" + 1000 + "&" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.FALSE); Client client = new Client(locator); client.connect(); String payload = "foobar"; long startTime = System.currentTimeMillis(); try { for (int x = 0; x < numOfCalls; x++) { Object resp = client.invoke(payload); System.out.println("resp = " + resp); assertEquals("barfoo", resp); Thread.sleep(sleepTime); } long endTime = System.currentTimeMillis(); System.out.println("Total time for " + numOfCalls + ": " + (endTime - startTime)); } catch (Throwable thr) { throwable = thr; } finally { client.disconnect(); } } } public static void main(String[] args) { SocketRetryClient client = new SocketRetryClient(); try { client.testConnection(); } catch (Throwable throwable) { throwable.printStackTrace(); } } protected String getTransport() { return "socket"; } protected int getPort() { return 8888; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/retry/SocketRetryServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000452410541703075033527 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.connection.retry; 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 org.jboss.remoting.transport.socket.SocketClientInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; import javax.management.MBeanServer; /** * @author Tom Elrod */ public class SocketRetryServer extends ServerTestCase { private Connector connector = null; public void setUp() throws Exception { String locatorUri = getTransport() + "://localhost:" + getPort() + "/?" + SocketClientInvoker.SO_TIMEOUT_FLAG + "=" + 1000 + "&" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.FALSE; 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) { SocketRetryServer server = new SocketRetryServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } finally { server.tearDown(); } } protected String getTransport() { return "socket"; } protected int getPort() { return 8888; } 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 "barfoo"; } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/retry/SocketRetryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000263610431540127033524 0ustar twernertwerner/* * 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.transport.socket.connection.retry; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * @author Tom Elrod */ public class SocketRetryTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketRetryClient.class.getName(), 1, SocketRetryServer.class.getName()); } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000755000175000017500000000000011632407037033521 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_classname/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000755000175000017500000000000011632407037033521 5ustar twernertwerner././@LongLink0000000000000000000000000000024500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_classname/SocketFactoryByClassnameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000305710535452155033532 0ustar twernertwerner/* * 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.transport.socket.connection.socketfactory.by_classname; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.socket.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByClassnameTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_classname/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000001635310405606127033531 0ustar twernertwerner/* * 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.transport.socket.connection.socketfactory.by_classname; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.xml.parsers.DocumentBuilderFactory; 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.security.ServerSocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.w3c.dom.Document; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setupServerWithClassname() throws Exception { String serverSocketFactoryValue = ServerSocketFactoryMock.class.getName(); connector = new Connector(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + serverSocketFactoryValue + ""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setConfiguration(xml.getDocumentElement()); connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } public void setUp() throws Exception { setupServerWithClassname(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private javax.net.ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = javax.net.ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_instance/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000755000175000017500000000000011632407040033513 5ustar twernertwerner././@LongLink0000000000000000000000000000024300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_instance/SocketFactoryByInstanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000305410535452155033527 0ustar twernertwerner/* * 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.transport.socket.connection.socketfactory.by_instance; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.socket.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByInstanceTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_instance/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000001563010405627117033530 0ustar twernertwerner/* * 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.transport.socket.connection.socketfactory.by_instance; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; 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.InvokerCallbackHandler; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setUp() throws Exception { setupServerWithInstance(); } private void setupServerWithInstance() throws Exception { String locatorURI = transport + "://" + host + ":" + port; // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(locator); connector.setServerSocketFactory(ServerSocketFactory.getDefault()); // creates all the connector's needed resources, such as the server invoker connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private javax.net.ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = javax.net.ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_mbean/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000755000175000017500000000000011632407037033521 5ustar twernertwerner././@LongLink0000000000000000000000000000023500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_mbean/SocketFactoryByMBeanTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000304610535452155033530 0ustar twernertwerner/* * 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.transport.socket.connection.socketfactory.by_mbean; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.socket.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByMBeanTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/by_mbean/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000001737510405606127033536 0ustar twernertwerner/* * 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.transport.socket.connection.socketfactory.by_mbean; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import javax.xml.parsers.DocumentBuilderFactory; 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.security.ServerSocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.w3c.dom.Document; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void setupServerWithMBeanServer() throws Exception { String serverSocketFactoryValue = "jboss:type=serversocketfactory"; //setup mbean server socket factory MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); ServerSocketFactoryMock service = new ServerSocketFactoryMock(); ObjectName objName = new ObjectName(serverSocketFactoryValue); mbeanServer.registerMBean(service, objName); connector = new Connector(); mbeanServer.registerMBean(connector, new ObjectName("jboss:type=connector")); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + serverSocketFactoryValue + ""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); //connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setUp() throws Exception { setupServerWithMBeanServer(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private javax.net.ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = javax.net.ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/socketfactory/SocketFactoryTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connection/0000644000175000017500000000601510433770344033527 0ustar twernertwerner/* * 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.transport.socket.connection.socketfactory; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class SocketFactoryTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; public void testInvocations() throws Throwable { Client remotingClient = null; try { String locatorURI = transport + "://" + host + ":" + port; //String locatorURI = transport + "://" + host + ":" + port; // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); String request = "Do something"; System.out.println("Invoking server with request of '" + request + "'"); long startTime = System.currentTimeMillis(); Object response = remotingClient.invoke(request); System.out.println("Invocation response: " + response); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestClient client = new SocketFactoryTestClient(); try { client.testInvocations(); } catch(Throwable e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/multihome/0000755000175000017500000000000011632407040033357 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/multihome/SocketMultihomeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/multihome/S0000644000175000017500000000411111413660476033514 0ustar twernertwerner /* * 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.transport.socket.multihome; 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.test.remoting.multihome.MultihomeTestParent; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jan 8, 2008 *

*/ public class SocketMultihomeTestCase extends MultihomeTestParent { protected String getTransport() { return "socket"; } boolean firstTime = true; 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); } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/threadpool/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/threadpool/0000755000175000017500000000000011632407040033515 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/threadpool/ThreadPoolEvictionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/threadpool/0000644000175000017500000004446311413660476033545 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.threadpool; import java.lang.reflect.Field; import java.net.InetAddress; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-890. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 21, 2007 *

*/ public class ThreadPoolEvictionTestCase extends TestCase { protected static Logger log = Logger.getLogger(ThreadPoolEvictionTestCase.class); protected static String DELAY = "delay"; 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() { } /** * Verifies that a ServerThread can be evicted while it's in versionRead(). */ public void testEvictionDuringVersionRead() throws Throwable { log.info("entering " + getName()); // Start server - no connection checking. setupServer(false); // Create first client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig1 = new HashMap(); clientConfig1.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig1); Client client1 = new Client(clientLocator1, clientConfig1); client1.connect(); // Use up server's threadpool. ConnectThread ct1 = new ConnectThread(client1, 500, "ct1"); ConnectThread ct2 = new ConnectThread(client1, 500, "ct2"); ct1.start(); ct2.start(); Thread.sleep(2000); assertTrue(ct1.ok); assertTrue(ct2.ok); // Get clientpool from server. 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); assertEquals(2, clientpool.size()); // Now make another invocation that with a Client with a // separate connection pool. It will create a new connection, // which will require an eviction from the clientpool. String newLocatorURI = locatorURI + "/?timeout=10000"; InvokerLocator clientLocator2 = new InvokerLocator(newLocatorURI); HashMap clientConfig2 = new HashMap(); clientConfig2.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig2); Client client2 = new Client(clientLocator2, clientConfig2); client2.connect(); ConnectThread ct3 = new ConnectThread(client2, 0, "ct3"); ct3.start(); // Verify that eviction succeeded. Thread.sleep(2000); assertTrue(ct3.ok); // Verify that clientpool is the same, i.e., that a ServerThread // was reused. LRUPool newClientpool = (LRUPool) field.get(serverInvoker); assertEquals(clientpool, newClientpool); client1.disconnect(); client2.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verifies that a ServerThread can be evicted when it's in acknowledge(). */ public void testEvictionDuringAcknowledge() throws Throwable { log.info("entering " + getName()); // Start server - do connection checking. setupServer(true); // Create first client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig1 = new HashMap(); clientConfig1.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig1.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); addExtraClientConfig(clientConfig1); Client client1 = new Client(clientLocator1, clientConfig1); client1.connect(); // Use up server's threadpool. ConnectThread ct1 = new ConnectThread(client1, 500, "ct1"); ConnectThread ct2 = new ConnectThread(client1, 500, "ct2"); ct1.start(); ct2.start(); Thread.sleep(4000); assertTrue(ct1.ok); assertTrue(ct2.ok); // Get clientpool from server. 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); assertEquals(2, clientpool.size()); // Now make another invocation that with a Client with a // separate connection pool. It will create a new connection, // which will require an eviction from the clientpool. String newLocatorURI = locatorURI + "/?timeout=10000"; InvokerLocator clientLocator2 = new InvokerLocator(newLocatorURI); HashMap clientConfig2 = new HashMap(); clientConfig2.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig2.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); addExtraClientConfig(clientConfig2); Client client2 = new Client(clientLocator2, clientConfig2); client2.connect(); ConnectThread ct3 = new ConnectThread(client2, 0, "ct3"); ct3.start(); // Verify that eviction succeeded. Thread.sleep(2000); assertTrue(ct3.ok); // Verify that clientpool is the same, i.e., that a ServerThread // was reused. LRUPool newClientpool = (LRUPool) field.get(serverInvoker); assertEquals(clientpool, newClientpool); client1.disconnect(); client2.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verifies that a ServerThread can be evicted when it's in acknowledge(). */ public void testEvictionOfSecondThread() throws Throwable { log.info("entering " + getName()); // Start server - do connection checking. setupServer(true); // Create first client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig1 = new HashMap(); clientConfig1.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig1.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); addExtraClientConfig(clientConfig1); Client client1 = new Client(clientLocator1, clientConfig1); client1.connect(); // Use up server's threadpool. ConnectThread ct1 = new ConnectThread(client1, 5000, "ct1"); ConnectThread ct2 = new ConnectThread(client1, 0, "ct2"); ct1.start(); ct2.start(); Thread.sleep(2000); assertFalse(ct1.ok); assertTrue(ct2.ok); // Get clientpool from server. 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); assertEquals(2, clientpool.size()); // Now make another invocation that with a Client with a // separate connection pool. It will create a new connection, // which will require an eviction from the clientpool. String newLocatorURI = locatorURI + "/?timeout=10000"; InvokerLocator clientLocator2 = new InvokerLocator(newLocatorURI); HashMap clientConfig2 = new HashMap(); clientConfig2.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig2.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); addExtraClientConfig(clientConfig2); Client client2 = new Client(clientLocator2, clientConfig2); client2.connect(); ConnectThread ct3 = new ConnectThread(client2, 0, "ct3"); ct3.start(); // Verify that eviction succeeded. Thread.sleep(2000); assertTrue(ct3.ok); // Verify that clientpool is the same, i.e., that a ServerThread // was reused. LRUPool newClientpool = (LRUPool) field.get(serverInvoker); assertEquals(clientpool, newClientpool); client1.disconnect(); client2.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verifies that a ServerThread can be evicted when it's in acknowledge(). */ public void testDirectEviction() throws Throwable { log.info("entering " + getName()); // Start server - no connection checking, maxPoolSize == 3. setupServer(false, "4"); // Create first client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig1 = new HashMap(); clientConfig1.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig1.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); addExtraClientConfig(clientConfig1); Client client = new Client(clientLocator1, clientConfig1); client.connect(); // Get clientpool from server. 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); // Use up server's threadpool. ConnectThread ct1 = new ConnectThread(client, 16000, "ct1"); ConnectThread ct2 = new ConnectThread(client, 16000, "ct2"); ConnectThread ct3 = new ConnectThread(client, 16000, "ct3"); ConnectThread ct4 = new ConnectThread(client, 0, "ct4"); ct1.start(); Thread.sleep(2000); // +2000 List threads = clientpool.getContentsByAscendingAge(); assertEquals(1, threads.size()); Thread thread0 = (Thread) threads.get(0); ct2.start(); Thread.sleep(2000); // +4000 threads = clientpool.getContentsByAscendingAge(); assertEquals(2, threads.size()); assertEquals(thread0, threads.get(1)); Thread thread1 = (Thread) threads.get(0); ct3.start(); Thread.sleep(2000); // +6000 ct4.start(); Thread.sleep(2000); // +8000 threads = clientpool.getContentsByAscendingAge(); assertEquals(4, threads.size()); assertEquals(thread0, threads.get(3)); assertEquals(thread1, threads.get(2)); Thread thread2 = (Thread) threads.get(1); // Verify newest thread gets evicted. Thread.sleep(4000); // +12000 clientpool.evict(); Thread.sleep(2000); // +14000 threads = clientpool.getContentsByAscendingAge(); assertEquals(3, threads.size()); assertEquals(thread0, threads.get(2)); assertEquals(thread1, threads.get(1)); assertEquals(thread2, threads.get(0)); // Verify none of the other threads is ready to be evicted. clientpool.evict(); threads = clientpool.getContentsByAscendingAge(); assertEquals(3, threads.size()); assertEquals(thread0, threads.get(2)); assertEquals(thread1, threads.get(1)); assertEquals(thread2, threads.get(0)); // Wait until all of the threads are done and verify that // the oldest one gets evicted first. Thread.sleep(12000); // +26000 threads = clientpool.getContentsByAscendingAge(); assertEquals(2, threads.size()); assertEquals(thread1, threads.get(1)); assertEquals(thread2, threads.get(0)); clientpool.evict(); Thread.sleep(2000); // +29000 threads = clientpool.getContentsByAscendingAge(); assertEquals(1, threads.size()); assertEquals(thread2, threads.get(0)); clientpool.evict(); Thread.sleep(2000); // +30000 threads = clientpool.getContentsByAscendingAge(); assertEquals(0, threads.size()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verifies that a ServerThread cannot be evicted in the middle of * an invocation. Also verifies that if all threads are uninteruptible, * then a thread finishes an invocation will check with LRUPool and * return itself to threadpool. */ public void testNoEvictionDuringInvocation() throws Throwable { log.info("entering " + getName()); // Start server - no connection checking. setupServer(false); // Create first client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig1 = new HashMap(); clientConfig1.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig1.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); addExtraClientConfig(clientConfig1); Client client1 = new Client(clientLocator1, clientConfig1); client1.connect(); // Use up server's threadpool. ConnectThread ct1 = new ConnectThread(client1, 10000, "ct1"); ConnectThread ct2 = new ConnectThread(client1, 10000, "ct2"); ct1.start(); ct2.start(); Thread.sleep(5000); // +5000 // Now make another invocation that with a Client with a // separate connection pool. It will create a new connection, // which will require an eviction from the clientpool. String newLocatorURI = locatorURI + "/?timeout=100000"; InvokerLocator clientLocator2 = new InvokerLocator(newLocatorURI); HashMap clientConfig2 = new HashMap(); clientConfig2.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig2.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "true"); addExtraClientConfig(clientConfig2); Client client2 = new Client(clientLocator2, clientConfig2); client2.connect(); ConnectThread ct3 = new ConnectThread(client2, 10000, "ct3"); ct3.start(); assertFalse(ct1.ok); // +5000 assertFalse(ct2.ok); assertFalse(ct3.ok); Thread.sleep(10000); // +15000 assertTrue(ct1.ok); assertTrue(ct2.ok); assertFalse(ct3.ok); Thread.sleep(10000); // + 25000 assertTrue(ct3.ok); client1.disconnect(); client2.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean checkConnection) throws Exception { setupServer(checkConnection, "2"); } protected void setupServer(boolean checkConnection, String maxPoolSize) 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"); config.put("maxPoolSize", maxPoolSize); if (checkConnection) { config.put(SocketServerInvoker.CHECK_CONNECTION_KEY, "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 { log.info("invoke() entered"); Map metadata = invocation.getRequestPayload(); int delay = ((Integer) metadata.get(DELAY)).intValue(); Thread.sleep(delay); log.info("invoke() returning"); return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class ConnectThread extends Thread { public boolean started; public boolean ok; private Client client; private int delay; private String name; public ConnectThread(Client client, int delay, String name) { this.client = client; this.delay = delay; this.name = name; } public void run() { Map metadata = new HashMap(); metadata.put(DELAY, new Integer(delay)); try { log.info(name + " making invocation"); assertEquals("abc", client.invoke("abc", metadata)); log.info(name + " got response"); ok = true; } catch (Throwable e) { log.error("Error", e); } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/0000755000175000017500000000000011632407037032153 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawClie0000644000175000017500000000710010355142433033417 0ustar twernertwerner/* * 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.transport.socket.raw; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.Socket; /** * @author Tom Elrod */ public class RawClient { protected String address = "localhost"; protected int port = 6700; public boolean enableTcpNoDelay = false; public int timeout = 60000; private Socket socket = null; private ObjectOutputStream oos; private ObjectInputStream objInputStream; public void startClient() { while(true) { // try // { // Thread.sleep(1000); // } // catch(InterruptedException e) // { // e.printStackTrace(); // } try { getSocket(); oos.writeObject("This is the request"); //oos.flush(); oos.reset(); // to make sure stream gets reset // Stupid ObjectInputStream holds object graph // can only be set by the client/server sending a TC_RESET oos.writeObject(Boolean.TRUE); oos.flush(); oos.reset(); Object obj = objInputStream.readObject(); objInputStream.readObject(); // for stupid ObjectInputStream reset System.out.println("response: " + obj); } catch(IOException e) { e.printStackTrace(); } catch(ClassNotFoundException e) { e.printStackTrace(); } } } public void getSocket() throws IOException { if(socket == null) { try { socket = new Socket(address, port); socket.setTcpNoDelay(enableTcpNoDelay); // socket.setSoTimeout(timeout); BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream()); // out.flush(); BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); oos = new ObjectOutputStream(out); objInputStream = new ObjectInputStream(in); } catch(IOException e) { e.printStackTrace(); } } else { oos.reset(); oos.writeByte(1); oos.flush(); oos.reset(); objInputStream.readByte(); // objInputStream.reset(); } } public static void main(String[] args) { RawClient client = new RawClient(); client.startClient(); } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawTest0000644000175000017500000000576510506110050033465 0ustar twernertwerner/* * 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.transport.socket.raw; 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 RawTestServer extends ServerTestCase { public static final String RESPONSE = "This is response"; private Connector connector; public void setUp() throws Exception { connector = new Connector("socket://localhost:6700"); 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) { RawTestServer server = new RawTestServer(); try { server.setUp(); } catch (Exception e) { e.printStackTrace(); } } public class TestInvocationHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) { //To change body of implemented methods use File | Settings | File Templates. } public void setInvoker(ServerInvoker invoker) { //To change body of implemented methods use File | Settings | File Templates. } public Object invoke(InvocationRequest invocation) throws Throwable { return RESPONSE; } public void addListener(InvokerCallbackHandler callbackHandler) { //To change body of implemented methods use File | Settings | File Templates. } public void removeListener(InvokerCallbackHandler callbackHandler) { //To change body of implemented methods use File | Settings | File Templates. } } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawTest0000644000175000017500000000257610506110050033462 0ustar twernertwerner/* * 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.transport.socket.raw; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * @author Tom Elrod */ public class RawTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(RawTestClient.class.getName(), 1, RawTestServer.class.getName()); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawServ0000644000175000017500000001205610355142433033470 0ustar twernertwerner/* * 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.transport.socket.raw; //import org.jboss.remoting.transport.socket.OptimizedObjectInputStream; //import org.jboss.remoting.transport.socket.OptimizedObjectOutputStream; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; /** * @author Tom Elrod */ public class RawServer implements Runnable { protected int serverBindPort = 6700; protected int backlog = 200; protected ServerSocket serverSocket; protected InetAddress bindAddress; protected String serverBindAddress = "localhost"; protected int timeout = 60000; // 60 seconds. public RawServer() { try { bindAddress = InetAddress.getByName(serverBindAddress); serverSocket = new ServerSocket(serverBindPort, backlog, bindAddress); } catch(IOException e) { e.printStackTrace(); } } public void startServer() { new Thread(this).start(); } /** * 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 { Socket socket = serverSocket.accept(); socket.setSoTimeout(timeout); BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream()); // OptimizedObjectOutputStream out = new OptimizedObjectOutputStream(bos); // out.flush(); BufferedInputStream bis = new BufferedInputStream(socket.getInputStream()); // OptimizedObjectInputStream in = new OptimizedObjectInputStream(bis); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.flush(); ObjectInputStream objInputStream = new ObjectInputStream(bis); processRequest(objInputStream, oos); while(true) { acknowledge(objInputStream, oos); processRequest(objInputStream, oos); } } catch(IOException e) { e.printStackTrace(); } catch(ClassNotFoundException e) { e.printStackTrace(); } } private void processRequest(ObjectInputStream objInputStream, ObjectOutputStream oos) throws IOException, ClassNotFoundException { Object obj = objInputStream.readObject(); objInputStream.readObject(); // Object obj = in.readObject(); // in.readObject(); // for stupid ObjectInputStream reset System.out.println("Object read: " + obj); Object resp = null; try { // Make absolutely sure thread interrupted is cleared. boolean interrupted = Thread.interrupted(); // call transport on the subclass, get the result to handback resp = "This is response."; } catch(Exception ex) { resp = ex; } Thread.interrupted(); // clear interrupted state so we don't fail on socket writes oos.writeObject(resp); //oos.flush(); oos.reset(); // to make sure stream gets reset // Stupid ObjectInputStream holds object graph // can only be set by the client/server sending a TC_RESET oos.writeObject(Boolean.TRUE); oos.flush(); oos.reset(); } private void acknowledge(ObjectInputStream objInputStream, ObjectOutputStream oos) throws IOException { // now stay open and wait for ack System.out.println("waiting for ack"); byte ACK = objInputStream.readByte(); System.out.println("got ack"); oos.writeByte(ACK); oos.flush(); oos.reset(); } public static void main(String[] args) { RawServer server = new RawServer(); server.startServer(); } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/raw/RawTest0000644000175000017500000000635710624447707033512 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.raw; import junit.framework.TestCase; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.net.Socket; import org.jboss.remoting.Version; /** * @author Tom Elrod */ public class RawTestClient extends TestCase { protected String address = "localhost"; protected int port = 6700; public boolean enableTcpNoDelay = false; public int timeout = 60000; private Socket socket = null; private OutputStream out; private InputStream in; private ObjectOutputStream oos; private ObjectInputStream objInputStream; public void testRawInvocation() { makeRawInvocation(); makeRawInvocation(); } public void makeRawInvocation() { // In response to JBREM-692 (Let marshallers/unmarshallers construct // their preferred streams.), some changes are necessary to make this // test work. SerializableMarshaller and SerializableUnMarshaller now // implement the method getMarshallingStream(), which allows // ClientSocketWrapper and ServerSocketWrapper to get object streams // when they are created and cache them for future use, instead of // recreating them with each invocation. try { getSocket(); // Write version. // out.write(1); oos.write(Version.getDefaultVersion()); out.flush(); // Write invocation. // oos = new ObjectOutputStream(out); oos.reset(); oos.writeObject("This is the request"); oos.flush(); // Get response. // objInputStream = new ObjectInputStream(in); Object obj = objInputStream.readObject(); System.out.println("response: " + obj); assertEquals(RawTestServer.RESPONSE, obj); System.out.println("PASSED"); } catch(IOException e) { e.printStackTrace(); fail(); } catch(ClassNotFoundException e) { e.printStackTrace(); fail(); } } public void getSocket() throws IOException { if(socket == null) { try { socket = new Socket(address, port); socket.setTcpNoDelay(enableTcpNoDelay); // socket.setSoTimeout(timeout); out = new BufferedOutputStream(socket.getOutputStream()); in = new BufferedInputStream(socket.getInputStream()); oos = new ObjectOutputStream(out); objInputStream = new ObjectInputStream(in); } catch(IOException e) { e.printStackTrace(); } } else { // oos.reset(); // oos.writeByte(1); // oos.flush(); // oos.reset(); // objInputStream.readByte(); // objInputStream.reset(); } } public static void main(String[] args) { RawTestClient client = new RawTestClient(); client.testRawInvocation(); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionfailure/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionf0000755000175000017500000000000011632407040033602 5ustar twernertwerner././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionfailure/SocketCallbackConnectionFailureTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/connectionf0000644000175000017500000000306611413660476033624 0ustar twernertwerner /* * 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.transport.socket.connectionfailure; import org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent; /** * Unit test for JBREM-875. * * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Dec 10, 2007 *

*/ public class SocketCallbackConnectionFailureTestCase extends CallbackConnectionFailureTestParent { protected String getTransport() { return "socket"; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/SocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/SocketInvok0000644000175000017500000000523210535452155033550 0ustar twernertwerner/* * 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.transport.socket; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * 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 SocketInvokerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketInvokerClientTest.class.getName(), 1, SocketInvokerServerTest.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; } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketexception/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketexcep0000755000175000017500000000000011632407040033612 5ustar twernertwerner././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketexception/SocketCreationExceptionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketexcep0000644000175000017500000002236311413660476033635 0ustar twernertwerner/* * 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.transport.socket.socketexception; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; 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.Remoting; 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-1152. * * @author Ron Sigal * @version $Rev$ *

* Copyright Sep 9, 2009 *

*/ public class SocketCreationExceptionTestCase extends TestCase { protected static String SEND_CALLBACK = "sendCallback"; private static Logger log = Logger.getLogger(SocketCreationExceptionTestCase.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 testInvocationWithSocketException() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(null); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new SocketException(getName()), 2)); 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"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testInvocationWithIOException() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(null); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException("Connection reset"), 2)); clientConfig.put("generalizeSocketException", "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"); 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(ServerSocketFactory ssf) 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("timeout", "5000"); if (ssf != null) { config.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf); } 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 callbackHandler; public void addListener(InvokerCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } public Object invoke(final InvocationRequest invocation) throws Throwable { Object parameter = invocation.getParameter(); if (SEND_CALLBACK.equals(parameter)) { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("unable to send callback", e); } } return parameter; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } public static class TestSocketFactory extends SocketFactory { int counter; int limit; IOException exception; public TestSocketFactory() { } public TestSocketFactory(IOException exception, int limit) { this.exception = exception; this.limit = limit; } public Socket createSocket() throws IOException { counter++; log.info("counter: " + counter); if (counter <= limit) { log.info("throwing exception"); throw exception; } log.info("returning socket"); return new Socket(); } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { counter++; log.info("counter: " + counter); if (counter <= limit) { throw exception; } log.info("returning socket"); return new Socket(arg0, arg1); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { counter++; log.info("counter: " + counter); if (counter <= limit) { throw exception; } log.info("returning socket"); return new Socket(arg0, arg1); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { counter++; log.info("counter: " + counter); if (counter <= limit) { throw exception; } log.info("returning socket"); return new Socket(arg0, arg1, arg2, arg3); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { counter++; log.info("counter: " + counter); if (counter <= limit) { throw exception; } log.info("returning socket"); return new Socket(arg0, arg1, arg2, arg3); } } }././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketexception/GeneralizeSocketExceptionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketexcep0000644000175000017500000003753111413660476033640 0ustar twernertwerner/* * 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.transport.socket.socketexception; import java.io.IOException; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException; import java.rmi.MarshalException; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.net.SocketFactory; 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.Remoting; 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-1146. * * @author Ron Sigal * @version *

* Copyright Sep 2, 2009 *

*/ public class GeneralizeSocketExceptionTestCase extends TestCase { private static Logger log = Logger.getLogger(GeneralizeSocketExceptionTestCase.class); private static String connectionResetMessage = "yada yada connection reset yada yada"; private static String connectionClosedMessage = "yada yada connection closed yada yada"; private static String brokenPipeMessage = "yada yada broken pipe yada yada"; 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); } TestOutputStream.counter = 0; } public void tearDown() { } public void testConnectionResetNotGeneralized() 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(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException(connectionResetMessage), 2)); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Verify invocation fails. try { client.invoke("abc"); } catch (MarshalException e) { Throwable t = e.getCause(); assertEquals(connectionResetMessage, t.getMessage()); } catch (Throwable e) { fail("Expecteded message: " + connectionResetMessage + ", got: " + e.getMessage()); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testConnectionResetGeneralized() 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(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException(connectionResetMessage), 2)); clientConfig.put("generalizeSocketException", "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Verify invocation succeeds. assertEquals("abc", client.invoke("abc")); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testConnectionClosedNotGeneralized() 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(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException(connectionClosedMessage), 2)); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Verify invocation fails. try { client.invoke("abc"); } catch (MarshalException e) { Throwable t = e.getCause(); assertEquals(connectionClosedMessage, t.getMessage()); } catch (Throwable e) { fail("Expecteded message: " + connectionClosedMessage + ", got: " + e.getMessage()); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testConnectionClosedGeneralized() 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(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException(connectionClosedMessage), 2)); clientConfig.put("generalizeSocketException", "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Verify invocation succeeds. assertEquals("abc", client.invoke("abc")); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testBrokedPipedNotGeneralized() 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(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException(brokenPipeMessage), 2)); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Verify invocation fails. try { client.invoke("abc"); } catch (MarshalException e) { Throwable t = e.getCause(); assertEquals(brokenPipeMessage, t.getMessage()); } catch (Throwable e) { fail("Expecteded message: " + brokenPipeMessage + ", got: " + e.getMessage()); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testBrokedPipeGeneralized() 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(Remoting.CUSTOM_SOCKET_FACTORY, new TestSocketFactory(new IOException(brokenPipeMessage), 2)); clientConfig.put("generalizeSocketException", "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Verify invocation succeeds. assertEquals("abc", client.invoke("abc")); 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 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) {} } public static class TestSocketFactory extends SocketFactory { IOException exception; int throwOn = -1; public TestSocketFactory() { exception = new SocketException("default"); } public TestSocketFactory(IOException exception, int throwOn) { this.exception = exception; this.throwOn = throwOn; } public Socket createSocket() { return new TestSocket(exception, throwOn); } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { return new TestSocket(arg0, arg1, exception, throwOn); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { return new TestSocket(arg0, arg1, exception, throwOn); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { return new TestSocket(arg0, arg1, arg2, arg3, exception, throwOn); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { return new TestSocket(arg0, arg1, arg2, arg3, exception, throwOn); } } static class TestSocket extends Socket { IOException exception; int throwOn; public TestSocket(IOException exception, int throwOn) { this.exception = exception; this.throwOn = throwOn; } public TestSocket(String host, int port, IOException exception, int throwOn) throws UnknownHostException, IOException { super(host, port); this.exception = exception; this.throwOn = throwOn; } public TestSocket(InetAddress address, int port, IOException exception, int throwOn) throws IOException { super(address, port); this.exception = exception; this.throwOn = throwOn; } public TestSocket(String host, int port, InetAddress localAddr, int localPort, IOException exception, int throwOn) throws IOException { super(host, port, localAddr, localPort); this.exception = exception; this.throwOn = throwOn; } public TestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, IOException exception, int throwOn) throws IOException { super(address, port, localAddr, localPort); this.exception = exception; this.throwOn = throwOn; } public OutputStream getOutputStream() throws IOException { return new TestOutputStream(super.getOutputStream(), exception, throwOn); } public String toString() { return "TestSocket[" + getLocalPort() + "->" + getPort() + "]"; } } static class TestOutputStream extends OutputStream { OutputStream os; IOException exception; boolean closed; int throwOn; boolean doThrowException = true; public static int counter; public TestOutputStream(OutputStream os, IOException exception, int throwOn) { this.os = os; this.exception = exception; this.throwOn = throwOn; } public void close()throws IOException { closed = true; super.close(); log.info(this + " closed"); } public void write(int b) throws IOException { System.out.print("b: " + b); if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } if (doThrowException && ++counter == throwOn) { throw exception; } os.write(b); } public void write(byte b[], int off, int len) throws IOException { System.out.print("b: "); for (int i = 0; i < len; i++) { System.out.print(b[i] + " "); } System.out.println(""); if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } log.info("TestOutputStream: counter = " + counter + ", throwOn = " + throwOn); if (++counter == throwOn) { throw exception; } if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } try { log.info(this + " calling write()"); doThrowException = false; os.write(b, off, len); os.flush(); doThrowException = true; log.info(this + " back from write()"); } catch (IOException e) { log.info("exception: ", e); throw e; } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/deadlock/0000755000175000017500000000000011632407040033122 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/deadlock/ShutdownDeadlockTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/deadlock/Sh0000644000175000017500000001171210541703075033426 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transport.socket.deadlock; 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; /** * This test case is for JBREM-576. * Test trys to catch deadlock in shutdown where socket client * invoker being use my multiple Clients. Need one client making * invocations (which will cause sync on pool) and another to * shutdown, which will cause disconnect on socket client invoker, * thus causing it to sync on pool for clearing out the pool. * Since this is an issue of multithreading, is certainly possible * this test will pass even though the deadlock issue still exists. * @author Tom Elrod */ public class ShutdownDeadlockTestCase extends TestCase { private String invokerLocatorUrl = getTransport() + "://localhost:" + getPort() + "/?" + InvokerLocator.FORCE_REMOTE + "=true"; private Client shutdownClient; private Client invocationClient; private Connector connector; public void testDeadlock() throws Exception { xsetUP(); xtestDeadlock(); xtearDown(); } public void xsetUP() throws Exception { connector = new Connector(invokerLocatorUrl); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); shutdownClient = new Client(new InvokerLocator(invokerLocatorUrl)); shutdownClient.connect(); invocationClient = new Client(new InvokerLocator(invokerLocatorUrl)); invocationClient.connect(); } public void xtestDeadlock() throws Exception { final Client aClient = invocationClient; final StringBuffer aBuf = new StringBuffer(); final Client bClient = shutdownClient; final StringBuffer bBuf = new StringBuffer(); Thread a = new Thread(new Runnable() { public void run() { for(int x = 0; x < 10000; x++) { try { aClient.invoke("foo"); } catch (Throwable throwable) { throwable.printStackTrace(); } } aBuf.append("done"); System.out.println("invocation client done"); } }); Thread b = new Thread(new Runnable() { public void run() { for(int i = 0; i < 100; i++) { try { bClient.invoke("bla"); } catch (Throwable throwable) { throwable.printStackTrace(); } } bClient.disconnect(); bBuf.append("done"); System.out.println("shutdown client done"); } }); a.start(); b.start(); Thread.currentThread().sleep(10000); System.out.println("aBuf done = " + ("done".equals(aBuf.toString()))); System.out.println("bBuf done = " + ("done".equals(bBuf.toString()))); } public void xtearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { ShutdownDeadlockTestCase test = new ShutdownDeadlockTestCase(); try { test.testDeadlock(); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "socket"; } protected int getPort() { return 7798; } public class TestInvocationHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) { //To change body of implemented methods use File | Settings | File Templates. } public void setInvoker(ServerInvoker invoker) { //To change body of implemented methods use File | Settings | File Templates. } public Object invoke(InvocationRequest invocation) throws Throwable { return "bar"; } public void addListener(InvokerCallbackHandler callbackHandler) { //To change body of implemented methods use File | Settings | File Templates. } public void removeListener(InvokerCallbackHandler callbackHandler) { //To change body of implemented methods use File | Settings | File Templates. } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/interrupt/0000755000175000017500000000000011632407037033416 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/interrupt/I0000644000175000017500000001636411413660476033550 0ustar twernertwerner/* * 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.transport.socket.interrupt; 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.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.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; /** * Unit test for JBREM-955. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Apr 25, 2008 *

*/ public class InterruptedExceptionTestCase extends TestCase { private static Logger log = Logger.getLogger(InterruptedExceptionTestCase.class); private static boolean firstTime = true; private static String FAST = "fast"; 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 testInterruptedException() 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(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "1"); clientConfig.put("numberOfCallRetries", "1"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals(FAST, client.invoke(FAST)); log.info("connection is good"); InvokerThread t1 = new InvokerThread(client, "abc"); InvokerThread t2 = new InvokerThread(client, "xyz"); // Start first invocation. t1.start(); log.info("started first invocation"); // Give first invocation time to start. Thread.sleep(5000); // Start second invocation. t2.start(); log.info("started second invocation"); // Give second invocation time to start. Thread.sleep(5000); // Interrupt second invocation as it waits for a semaphore. t2.interrupt(); log.info("interrupted second invocation"); // Wait until second invocation throws an exception. synchronized (t2) { t2.wait(10000); } // Verify exception is an InterruptedException wrapped in a RuntimeExceptio. Throwable t = t2.throwable; log.info("throwable: " + t); assertTrue(t instanceof RuntimeException); assertFalse(t instanceof CannotConnectException); assertTrue(t.getCause() instanceof InterruptedException); 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 { Object o = invocation.getParameter(); if (!FAST.equals(o)) { Thread.sleep(20000); } return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class InvokerThread extends Thread { static int counter; Client client; String message; Throwable throwable; public InvokerThread(Client client, String message) { this.client = client; this.message = message; setName("InvokerThread:" + counter++); } public void run() { try { log.info("invocation succeeded: " + client.invoke(message)); } catch (Throwable t) { throwable = t; log.error("invocation error: " + t.getMessage()); } synchronized (this) { notify(); } } } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/interrupt/MockInvokerInterruptTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/interrupt/M0000644000175000017500000001044011413660476033541 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, 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.transport.socket.interrupt; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; import EDU.oswego.cs.dl.util.concurrent.CountDown; /** * Unit test for JBREM-955. * * @author Galder Zamarreno */ public class MockInvokerInterruptTestCase extends TestCase { private static final Logger log = Logger.getLogger(MockInvokerInterruptTestCase.class); public void test000() throws Throwable { InvokerLocator il = new InvokerLocator("unittest", "127.0.0.1", 9999, "mock", null); CountDown startGate = new CountDown(1); MockMicroSocketClientInvoker ci = new MockMicroSocketClientInvoker(il, startGate); InvocationRequest ir = new InvocationRequest("", "", null, null, null, il); Runnable interrupterRunnable = new ThreadInterrupter(Thread.currentThread(), startGate); Thread interrupter = new Thread(interrupterRunnable); interrupter.start(); ci.setMaxPoolSize(0); ci.connect(); try { ci.invoke(ir); } catch(CannotConnectException cce) { log.error("We interrupted the connection, a more meaningul exception should be thrown"); throw cce; } catch (RuntimeException re) { assertTrue(re.getCause() instanceof InterruptedException); } } class MockMicroSocketClientInvoker extends MicroSocketClientInvoker { private CountDown startGate; public MockMicroSocketClientInvoker(InvokerLocator locator, CountDown start) { super(locator); startGate = start; } public void setMaxPoolSize(int maxPoolSize) { this.maxPoolSize = maxPoolSize; } protected SocketWrapper getConnection(Marshaller marshaller, UnMarshaller unmarshaller, boolean tryPool, int timeAllowed) throws Exception { log.info("Request a connection but before that, let's open the start gate"); startGate.release(); return super.getConnection(marshaller, unmarshaller, true, timeAllowed); } } class ThreadInterrupter implements Runnable { private Thread threadToInterrupt; private CountDown startGate; ThreadInterrupter(Thread thread, CountDown start) { threadToInterrupt = thread; startGate = start; } public void run() { try { log.info("Wait for start gate to be opened"); startGate.acquire(); log.info("Start gate opened, let's sleep briefly..."); Thread.sleep(200); log.info("Sleep finished, interrupt the target thread"); threadToInterrupt.interrupt(); } catch (InterruptedException e) { log.error("Error", e); } } } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketfacto0000755000175000017500000000000011632407037033610 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketfactory/SocketCreationListenerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketfacto0000644000175000017500000000260710553067761033626 0ustar twernertwerner/* * 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.transport.socket.socketfactory; import org.jboss.test.remoting.socketfactory.CreationListenerTestRoot; /** * @author Ron Sigal * @version $Revision: 1846 $ *

* Copyright Jan 11, 2007 *

*/ public class SocketCreationListenerTestCase extends CreationListenerTestRoot { protected String getTransport() { return "socket"; } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketfactory/SocketFactoryClassNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketfacto0000644000175000017500000000072411413660476033622 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.socketfactory; import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot; /** * * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jul 18, 2008 *

*/ public class SocketFactoryClassNameTestCase extends SocketFactoryClassNameTestRoot { protected String getTransport() { return "socket"; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/load/0000755000175000017500000000000011632407037032301 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/load/SocketLoadTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/load/Socket0000644000175000017500000001131010713302020033431 0ustar twernertwerner/* * 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.transport.socket.load; 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.InvokerLocator; import org.jboss.remoting.transport.Connector; public class SocketLoadTestCase extends TestCase { private static int numOfRunnerThreads = 10; private static int responseCount = 0; private static Object lock = new Object(); private Connector connector; // static // { // BasicConfigurator.configure(); // Logger.getRootLogger().setLevel(Level.INFO); // Logger.getInstance("org.jboss.remoting.transport.socket").setLevel(Level.ALL); // } private static Logger logger = Logger.getLogger(SocketLoadTestCase.class); protected String getTransport() { return "socket"; } public static void main(String[] args) throws Throwable { SocketLoadTestCase rt = new SocketLoadTestCase(); rt.startServer(); // rt.runMultipleClients(Integer.parseInt(args[1])); rt.runMultipleClients(numOfRunnerThreads); System.in.read(); } public void setUp() throws Exception { logger.error("setUp()"); 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); logger.info("starting server"); startServer(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void startServer() throws Exception { logger.info("startServer()"); String locatorURI = getTransport() + "://localhost:54000/?maxPoolSize=2&timeout=10000"; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } public void testRunClients() throws Throwable { runMultipleClients(numOfRunnerThreads); Thread.currentThread().sleep(120000); logger.info("Response count = " + responseCount + ". Expected 10."); assertEquals(10, responseCount); } public void runClient(String clientId) throws Throwable { String locatorURI = getTransport() + "://localhost:54000/"; InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); String req = clientId; logger.info("client.invoke() " + clientId); Object resp = client.invoke(req); synchronized (lock) { responseCount++; } logger.info("Received response of: " + resp + ". Response count = " + responseCount); System.in.read(); } public void runMultipleClients(int cnt) throws Throwable { for (int i = 0; i < cnt; i++) { Thread t = new Thread(new Runnable() { public void run() { try { Thread.sleep(1000); runClient(Thread.currentThread().getName()); } catch (Throwable e) { logger.error(e); } } }, Integer.toString(i)); t.start(); } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/load/PooledConnectionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/load/Pooled0000644000175000017500000000730210542177366033460 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.load; import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; public class PooledConnectionTestCase extends TestCase { private static int numOfRunnerThreads = 10; // private static int numOfRunnerThreads = 3; private static SynchronizedInt responseCount = new SynchronizedInt(0); private Connector connector; // static // { // BasicConfigurator.configure(); // Logger.getRootLogger().setLevel(Level.INFO); // Logger.getInstance("org.jboss.remoting.transport.socket").setLevel(Level.ALL); // } private Logger logger = Logger.getRootLogger(); protected String getTransport() { return "socket"; } public static void main(String[] args) throws Throwable { PooledConnectionTestCase rt = new PooledConnectionTestCase(); rt.startServer(); // rt.runMultipleClients(Integer.parseInt(args[1])); rt.runMultipleClients(PooledConnectionTestCase.numOfRunnerThreads); } public void setUp() throws Exception { startServer(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void startServer() throws Exception { String locatorURI = getTransport() + "://localhost:54000/?maxPoolSize=10&timeout=10000"; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } public void testRunClients() throws Throwable { runMultipleClients(PooledConnectionTestCase.numOfRunnerThreads); // waiting 8 seconds as the server handler will have waited client calls // 5 seconds, but should only be able to make client invocations 2 at a time. Thread.currentThread().sleep(8000); // should not have all invocations as should be blocking within client invoker (as only // allows 2 concurrent client connections). assertFalse(10 == PooledConnectionTestCase.responseCount.get()); Thread.currentThread().sleep(120000); System.out.println("Response count = " + PooledConnectionTestCase.responseCount + ". Expected 10."); assertEquals(10, PooledConnectionTestCase.responseCount.get()); } public void runClient(String clientId) throws Throwable { String locatorURI = getTransport() + "://localhost:54000/?clientMaxPoolSize=2"; InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); String req = clientId; Object resp = client.invoke(req); PooledConnectionTestCase.responseCount.increment(); System.out.println("Received response of: " + resp + ". Response count = " + PooledConnectionTestCase.responseCount); System.in.read(); } public void runMultipleClients(int cnt) throws Throwable { for (int i = 0; i < cnt; i++) { Thread t = new Thread(new Runnable() { public void run() { try { Thread.sleep(1000); runClient(Thread.currentThread().getName()); } catch (Throwable e) { logger.error(e); e.printStackTrace(); } } }, Integer.toString(i)); t.start(); } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/load/SampleInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/load/Sample0000644000175000017500000000410310423211534033433 0ustar twernertwerner/* * 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.transport.socket.load; 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 javax.management.MBeanServer; public class SampleInvocationHandler implements ServerInvocationHandler { private static Logger logger = Logger.getRootLogger(); public Object invoke(InvocationRequest invocation) throws Throwable { String parm = (String) invocation.getParameter(); System.out.println(Thread.currentThread() + "******* Invoked " + parm); Thread.sleep(5000); System.out.println(Thread.currentThread() + "******* Returning - response" + parm); String s = "response" + parm; return s; } public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/shutdown/0000755000175000017500000000000011632407040033227 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/shutdown/SocketShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/shutdown/So0000644000175000017500000000634510760427654033561 0ustar twernertwerner/* * 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.transport.socket.shutdown; import java.net.InetAddress; import org.jboss.remoting.transport.PortUtil; import org.jboss.test.remoting.shutdown.OpenClient; import org.jboss.test.remoting.shutdown.ShutdownTestParent; import org.jboss.test.remoting.shutdown.ShutdownTestServer; /** * @author Ron Sigal * @version $Revision: 3500 $ *

* Copyright Jan 20, 2007 *

*/ public class SocketShutdownTestCase extends ShutdownTestParent { public void testWithServerThreadsInAcknowledge() throws Throwable { log.info("entering " + getName()); port = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName()); String command = "java -cp \"" + System.getProperty("java.class.path") + "\" "; command += getJVMArguments() + " -Dport=" + port + " "; String serverCommand = command + ShutdownTestServer.class.getName() + " " + getTransport(); serverCommand += " socket.check_connection=true&"; String clientCommand = command + OpenClient.class.getName() + " " + getTransport(); clientCommand += " socket.check_connection=true&"; Executor serverExecutor = new Executor(serverCommand, true); log.info("starting server"); serverExecutor.start(); log.info("waiting on server"); serverExecutor.waitUntilReady(); log.info("server is ready"); Executor clientExecutor = new Executor(clientCommand, false); log.info("starting client"); clientExecutor.start(); log.info("waiting on client"); clientExecutor.waitUntilReady(); log.info("client is ready"); clientExecutor.start(); Thread.sleep(40000); log.info("testing client"); assertFalse(clientSuccessful); log.info("testing server"); assertTrue(serverSuccessful); clientExecutor.destroy(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected String getJVMArguments() { String args = ""; String log4jFilePath = getClass().getResource("../../../shutdown/log4j.xml").getFile(); System.out.println("log4jFilePath: " + log4jFilePath); args += "-Dlog4j.configuration=file:" + log4jFilePath; return args; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/shutdown/SocketImmediateShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/shutdown/So0000644000175000017500000002210411413660476033545 0ustar twernertwerner/* * 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.transport.socket.shutdown; 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; /** * Unit test for JBREM-1123. * * @author Ron Sigal * @version $Rev$ *

* Copyright Apr 19, 2009 *

*/ public class SocketImmediateShutdownTestCase extends TestCase { private static Logger log = Logger.getLogger(SocketImmediateShutdownTestCase.class); private static boolean firstTime = true; private static String SLEEP = "sleep"; 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 testNoImmediateShutdownByDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, false); // 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"); // Test immediate shutdown. client.invokeOneway(SLEEP, null, true); Thread.sleep(4000); ServerInvoker serverInvoker = connector.getServerInvoker(); new Thread() { public void run() { setName("shutdownServer:" + getName()); try { shutdownServer(); } catch (Exception e) { e.printStackTrace(); } } }.start(); Thread.sleep(4000); log.info("testing server"); assertTrue(serverInvoker.isStarted()); Thread.sleep(8000); assertFalse(serverInvoker.isStarted()); log.info(getName() + " PASSES"); } public void testNoImmediateShutdownByConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, false); // 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"); // Test immediate shutdown. client.invokeOneway(SLEEP, null, true); Thread.sleep(4000); ServerInvoker serverInvoker = connector.getServerInvoker(); new Thread() { public void run() { try { setName("shutdownServer:" + getName()); shutdownServer(); } catch (Exception e) { e.printStackTrace(); } } }.start(); Thread.sleep(4000); log.info("testing server"); assertTrue(serverInvoker.isStarted()); Thread.sleep(8000); assertFalse(serverInvoker.isStarted()); log.info(getName() + " PASSES"); } public void testImmediateShutdown() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true); // 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"); // Test immediate shutdown. client.invokeOneway(SLEEP, null, true); Thread.sleep(4000); ServerInvoker serverInvoker = connector.getServerInvoker(); new Thread() { public void run() { try { setName("shutdownServer:" + getName()); shutdownServer(); } catch (Exception e) { e.printStackTrace(); } } }.start(); Thread.sleep(4000); log.info("testing server"); assertFalse(serverInvoker.isStarted()); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean setImmediateShutdown, boolean immediateShutdown) 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(); if (setImmediateShutdown) { config.put("immediateShutdown", Boolean.toString(immediateShutdown)); log.info("immediateShutdown: " + immediateShutdown); } 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) log.info("stopping Connector"); connector.stop(); log.info("stopped Connector"); } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { String request = (String) invocation.getParameter(); log.info("request: " + request); if (SLEEP.equals(request)) { log.info("GOING TO SLEEP"); Thread.sleep(12000); log.info("WOKE UP"); } return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } }././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/shutdown/ProcessInvocationShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/shutdown/Pr0000644000175000017500000001714511413704441033545 0ustar twernertwerner/* * 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.transport.socket.shutdown; import java.io.IOException; import java.net.InetAddress; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.socket.TransportClientFactory; /** * Unit test for JBREM-1076. * * @author Ron Sigal * @version $Rev$ *

* Copyright Apr 12, 2009 *

*/ public class ProcessInvocationShutdownTestCase extends TestCase { private static Logger log = Logger.getLogger(ProcessInvocationShutdownTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected SocketServerInvoker socketServerInvoker; 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 testShutdown() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); assertTrue(connector.getServerInvoker() instanceof TestServerInvoker); log.info("using a TestServerInvoker"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); final Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Start SocketServerInvoker.processInvocation(). new Thread() { public void run() { try { client.invoke("abc"); } catch (Throwable e) { e.printStackTrace(); } } }.start(); Thread.sleep(4000); shutdownServer(); Thread.sleep(4000); assertFalse(TestLRUPool.called); log.info(getName() + " PASSES"); } protected String getTransport() { return "test"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.registerInvokerFactories(getTransport(), TransportClientFactory.class, TestTransportServerFactory.class); return null; } }); 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(); socketServerInvoker = (SocketServerInvoker) connector.getServerInvoker(); socketServerInvoker.setMaxPoolSize(0); } 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 TestLRUPool extends LRUPool { static public boolean called; public TestLRUPool(int min, int max) { super(min, max); } public void insert(Object key, Object o) { log.info(this + ".insert() called"); called = true; } } static class TestServerInvoker extends SocketServerInvoker { public TestServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public TestServerInvoker(InvokerLocator locator) { super(locator); } public synchronized void start() throws IOException { super.start(); clientpool = new TestLRUPool(2, maxPoolSize); clientpool.create(); } } static public class TestTransportServerFactory implements ServerFactory { public boolean called; public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { called = true; log.info(this + ".createServerInvoker() called"); return new TestServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/clientaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/clientaddre0000755000175000017500000000000011632407037033561 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/clientaddress/SocketClientAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/clientaddre0000644000175000017500000000043110720523423033554 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.clientaddress; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class SocketClientAddressTestCase extends ClientAddressTestParent { protected String getTransport() { return "socket"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/0000755000175000017500000000000011632407040032155 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/SSLInvokerConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/SSLInvo0000644000175000017500000000244710412121312033372 0ustar twernertwerner/* * 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.transport.socket.ssl; /** * @author Tom Elrod */ public interface SSLInvokerConstants { int port = 8081; String transport = "sslsocket"; //protected String host = "192.168.1.103"; String host = "localhost"; int callbackPort = 8082; }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/.truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/.trusts0000644000175000017500000000701310345206626033532 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/no_connection_check/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/no_conn0000755000175000017500000000000011632407040033527 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/no_connection_check/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/no_conn0000644000175000017500000001125610432245666033551 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.no_connection_check; import org.apache.log4j.Level; 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.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import javax.net.ServerSocketFactory; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class InvokerServerTest extends ServerTestCase implements SSLInvokerConstants { private int serverPort = port; private Connector connector = null; private static final Logger log = Logger.getLogger(InvokerServerTest.class); public void init(Map metatdata) throws Exception { if (serverPort < 0) { serverPort = TestUtil.getRandomPort(); } InvokerServerTest.log.debug("port = " + serverPort); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); ServerSocketFactory svrSocketFactory = createServerSocketFactory(); connector.setServerSocketFactory(svrSocketFactory); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected String getTransport() { return transport; } private ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; // since doing basic (using default ssl server socket factory) // need to set the system properties to the keystore and password String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); SSLSocketBuilder server = new SSLSocketBuilder(); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } private String buildLocatorURI(Map metadata) { if (metadata == null || metadata.size() == 0) { return getTransport() + "://" + host + ":" + serverPort + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.FALSE; } else { StringBuffer uriBuffer = new StringBuffer(getTransport() + "://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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { init(null); } protected void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); InvokerServerTest server = new InvokerServerTest(); try { server.setUp(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/no_connection_check/InvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/no_conn0000644000175000017500000000324710535452155033547 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.no_connection_check; 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 InvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InvokerClientTest.class.getName(), 1, InvokerServerTest.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; } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/no_connection_check/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/no_conn0000644000175000017500000000613210426437055033544 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.no_connection_check; import junit.framework.TestCase; import org.apache.log4j.Level; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public class InvokerClientTest extends TestCase implements SSLInvokerConstants { private Client client; private static final Logger log = Logger.getLogger(InvokerClientTest.class); public void init() { try { // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + port + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.FALSE); client = new Client(locator, "mock"); client.connect(); } catch (Exception e) { InvokerClientTest.log.error(e.getMessage(), e); } } public void testRemoteCall() throws Throwable { InvokerClientTest.log.debug("running testRemoteCall()"); InvokerClientTest.log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); if ("bar".equals(ret)) { InvokerClientTest.log.debug("PASS"); } else { InvokerClientTest.log.debug("FAILED"); } assertEquals("bar", ret); } protected String getTransport() { return transport; } private 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; } public void setUp() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); init(); } public void tearDown() throws Exception { if (client != null) { client.disconnect(); client = null; } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/builder/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/builder0000755000175000017500000000000011632407040033524 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/builder/SSLSocketInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/builder0000644000175000017500000001404310541703075033535 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.builder; import org.apache.log4j.Level; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.security.SSLServerSocketFactoryService; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.io.IOException; /** * This is the server for the test case to verify can have push callbacks using ssl where * the client mode is used for the client calling back on the callback server living within the * client test instance. * * @author Tom Elrod */ public class SSLSocketInvokerTestServer extends ServerTestCase implements SSLInvokerConstants { private int serverPort; private Connector connector = null; private SSLSocketBuilder socketBuilder = null; private static final Logger log = Logger.getLogger(SSLSocketInvokerTestServer.class); public void init() throws Exception { serverPort = getPort(); if (serverPort < 0) { serverPort = TestUtil.getRandomPort(); } log.debug("port = " + serverPort); MBeanServer server = MBeanServerFactory.createMBeanServer(); // create and register socket server factory service createSSLSocketBuilder(); ServerSocketFactoryMBean serverSocketFactoryMBean = createServerSocketFactoryMBean(); String serverSocketFactoryObjName = "test:type=serversocketfactory"; server.registerMBean(serverSocketFactoryMBean, new ObjectName(serverSocketFactoryObjName)); connector = new Connector(); server.registerMBean(connector, new ObjectName("test:type=connector,transport=sslsocket")); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + serverSocketFactoryObjName + ""); buf.append("" + host + ""); buf.append("" + serverPort + ""); buf.append("" + 20000 + ""); buf.append("" + 0 + ""); buf.append("" + 0 + ""); buf.append(""); buf.append(""); buf.append(" " + getServerInvocationHandler().getClass().getName() + "\n"); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.start(); } private ServerSocketFactoryMBean createServerSocketFactoryMBean() throws Exception { ServerSocketFactoryMBean serverSocketFactoryMBean = null; SSLServerSocketFactoryService sslServerSocketFactoryService = new SSLServerSocketFactoryService(); sslServerSocketFactoryService.setSSLSocketBuilder(socketBuilder); sslServerSocketFactoryService.start(); serverSocketFactoryMBean = sslServerSocketFactoryService; return serverSocketFactoryMBean; } private void createSSLSocketBuilder() throws IOException { socketBuilder = new SSLSocketBuilder(); socketBuilder.setUseSSLServerSocketFactory(false); // socketBuilder.setSecureSocketProtocol("SSL"); socketBuilder.setSecureSocketProtocol("TLS"); socketBuilder.setKeyStoreAlgorithm("SunX509"); socketBuilder.setKeyStoreType("JKS"); String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); // String keyStoreFilePath = this.getClass().getResource("messaging.keystore").getFile(); socketBuilder.setKeyStoreURL(keyStoreFilePath); socketBuilder.setKeyStorePassword("unit-tests-server"); // socketBuilder.setKeyStorePassword("secureexample"); /* * This is optional since if not set, will use * the key store password (and are the same in this case) */ // socketBuilder.setKeyPassword("secureexample"); socketBuilder.setKeyPassword("unit-tests-server"); } protected String getTransport() { return transport; } protected int getPort() { return port; } protected String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); init(); } protected void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { SSLSocketInvokerTestServer server = new SSLSocketInvokerTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/builder/SSLSocketInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/builder0000644000175000017500000001300710541703075033534 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.builder; import junit.framework.TestCase; import org.apache.log4j.Level; 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.invocation.NameBasedInvocation; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import javax.management.MBeanServer; import java.util.HashMap; import java.util.Map; /** * This is the client for the test to make regular ssl based invocation to the server and * have a ssl based callback server. The special test in this case is want to have the callback * client that lives on the server to be in client mode so that this client test only has to have * a truststore locally, yet still use ssl. * * @author Tom Elrod */ public class SSLSocketInvokerTestClient extends TestCase implements SSLInvokerConstants { private Client client; private Connector callbackConnector; private static final Logger log = Logger.getLogger(SSLSocketInvokerTestClient.class); private boolean gotCallback = false; public void init() throws Exception { // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client"); // System.setProperty("javax.net.ssl.trustStorePassword", "secureexample"); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + getPort()); // create callback connector Map config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); callbackConnector = new Connector(getTransport() + "://" + host + ":" + (getPort() + 5), config); callbackConnector.create(); callbackConnector.addInvocationHandler("callback", new CallbackInvokerHandler()); callbackConnector.start(); client = new Client(locator, "mock"); client.connect(); try { client.addListener(new TestCallbackHandler(), callbackConnector.getLocator()); } catch (Throwable throwable) { Exception e = new Exception(throwable.getMessage()); e.initCause(throwable); e.printStackTrace(); throw e; } } public void testRemoteCall() throws Throwable { log.debug("running testRemoteCall()"); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); assertEquals("bar", ret); // this will cause the server to start sending callbacks ret = makeInvocation("test", "foobar"); System.out.println("ret = " + ret); Thread.sleep(5000); //DEBUG // Thread.sleep(600000); assertTrue(gotCallback); } protected String getTransport() { return transport; } protected int getPort() { return port; } private 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; } public void setUp() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); init(); } public void tearDown() throws Exception { if (client != null) { client.disconnect(); client = null; } } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("TestCallbackHandler.handleCallback() - " + callback); gotCallback = true; } } public class CallbackInvokerHandler implements ServerInvocationHandler { private InvokerCallbackHandler listener; public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public Object invoke(InvocationRequest invocation) throws Throwable { System.out.println("CallbackInvokerHandler.invoke() called with " + invocation.getParameter()); return null; } public void addListener(InvokerCallbackHandler callbackHandler) { listener = callbackHandler; } public void removeListener(InvokerCallbackHandler callbackHandler) { listener = null; } } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/builder/SSLSocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/builder0000644000175000017500000000263110434405703033533 0ustar twernertwerner/* * 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.transport.socket.ssl.builder; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class SSLSocketInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLSocketInvokerTestClient.class.getName(), 1, SSLSocketInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/0000755000175000017500000000000011632407040033422 5ustar twernertwerner././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/0000644000175000017500000001470311413660476033444 0ustar twernertwerner/* * 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.transport.socket.ssl.config; import java.net.Socket; import java.net.SocketException; import java.util.HashSet; import java.util.Map; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import org.apache.log4j.Logger; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.sslsocket.SSLSocketServerInvoker; import org.jboss.test.remoting.transport.socket.configuration.SocketServerSocketConfigurationTestCase; /** * Unit test for JBREM-703. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 28, 2008 *

*/ public class SSLSocketServerSocketConfigurationTestCase extends SocketServerSocketConfigurationTestCase { private static Logger log = Logger.getLogger(SSLSocketServerSocketConfigurationTestCase.class); static protected String[] cipherSuites; static protected String[] protocols; public void setUp() throws Exception { if (firstTime) { super.setUp(); SSLSocket s = (SSLSocket) SSLSocketFactory.getDefault().createSocket(); String[] strings = s.getSupportedCipherSuites(); log.info("supported cipher suites: "); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); strings = s.getEnabledCipherSuites(); log.info("enabled cipher suites: "); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); strings = s.getSupportedProtocols(); log.info("supported protocols: "); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); strings = s.getEnabledProtocols(); log.info("enabled protocols: "); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); strings = s.getSupportedCipherSuites(); int len = strings.length - 1; cipherSuites = new String[len]; for (int i = 0; i < len; i++) cipherSuites[i] = strings[i]; strings = s.getSupportedProtocols(); len = strings.length - 1; protocols = new String[len]; for (int i = 0; i < len; i++) protocols[i] = strings[i]; log.info("using cipherSuites: "); for (int i = 0; i < cipherSuites.length; i++) log.info(" " + cipherSuites[i]); log.info("using protocols: "); for (int i = 0; i < protocols.length; i++) log.info(" " + protocols[i]); } } public void tearDown() { } protected void doSocketTest(Socket s) throws SocketException { assertTrue(s.getKeepAlive()); suggestEquals(2345, s.getReceiveBufferSize(), "receiveBufferSize"); suggestEquals(3456, s.getSendBufferSize(), "sendBufferSize"); assertEquals(4567, s.getSoLinger()); suggestEquals(0, s.getTrafficClass(), "trafficClass"); assertTrue(s instanceof SSLSocket); SSLSocket ss = (SSLSocket) s; assertTrue(ss.getEnableSessionCreation()); log.info("actual enabledCipherSuites: "); String[] strings = ss.getEnabledCipherSuites(); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); assertEquals(cipherSuites, ss.getEnabledCipherSuites()); assertEquals(protocols, ss.getEnabledProtocols()); } protected void assertEquals(String[] strings1, String[] strings2) { HashSet set1 = new HashSet(); for (int i = 0; i < strings1.length; i++) set1.add(strings1[i]); HashSet set2 = new HashSet(); for (int i = 0; i < strings2.length; i++) set2.add(strings2[i]); assertEquals(set1, set2); } protected String getTransport() { return "sslsocket"; } protected void addExtraClientConfig(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"); } protected void addExtraServerConfig(Map config) { 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"); } protected void addServerSocketConfig(Map config) { super.addServerSocketConfig(config); config.put("enabledCipherSuites", cipherSuites); config.put("enabledProtocols", protocols); config.put("enableSessionCreation", "true"); } protected void configureServerInvoker(SocketServerInvoker invoker) { super.configureServerInvoker(invoker); if (invoker instanceof SSLSocketServerInvoker) { SSLSocketServerInvoker sslInvoker = (SSLSocketServerInvoker) invoker; sslInvoker.setEnabledCipherSuites(cipherSuites); sslInvoker.setEnabledProtocols(protocols); sslInvoker.setEnableSessionCreation(true); } } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } }././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/0000644000175000017500000001442111413660476033441 0ustar twernertwerner/* * 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.transport.socket.ssl.config; import java.net.Socket; import java.net.SocketException; import java.util.HashSet; import java.util.Map; import javax.management.MBeanServer; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; 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.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.sslsocket.SSLSocketServerInvoker; import org.jboss.test.remoting.transport.socket.configuration.SocketServerSocketConfigurationTestCase; import org.jboss.test.remoting.transport.socket.configuration.SocketSocketConfigurationTestCase; /** * Unit test for JBREM-703. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 28, 2008 *

*/ public class SSLSocketSocketConfigurationTestCase extends SocketSocketConfigurationTestCase { private static Logger log = Logger.getLogger(SSLSocketSocketConfigurationTestCase.class); static protected String[] cipherSuites; static protected String[] protocols; public void setUp() throws Exception { if (firstTime) { super.setUp(); SSLSocket s = (SSLSocket) SSLSocketFactory.getDefault().createSocket(); String[] strings = s.getSupportedCipherSuites(); log.info("supported cipher suites: "); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); strings = s.getEnabledCipherSuites(); log.info("enabled cipher suites: "); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); strings = s.getSupportedProtocols(); log.info("supported protocols: "); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); strings = s.getEnabledProtocols(); log.info("enabled protocols: "); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); strings = s.getSupportedCipherSuites(); int len = strings.length - 1; cipherSuites = new String[len]; for (int i = 0; i < len; i++) cipherSuites[i] = strings[i]; strings = s.getSupportedProtocols(); len = strings.length - 1; protocols = new String[len]; for (int i = 0; i < len; i++) protocols[i] = strings[i]; log.info("using cipherSuites: "); for (int i = 0; i < cipherSuites.length; i++) log.info(" " + cipherSuites[i]); log.info("using protocols: "); for (int i = 0; i < protocols.length; i++) log.info(" " + protocols[i]); } } public void tearDown() { } protected void setupClient(Map config) { super.setupClient(config); config.put("enabledCipherSuites", cipherSuites); config.put("enabledProtocols", protocols); config.put("enableSessionCreation", "true"); } protected void doSocketTest(Socket s) throws SocketException { assertTrue(s.getKeepAlive()); suggestEquals(2345, s.getReceiveBufferSize(), "receiveBufferSize"); suggestEquals(3456, s.getSendBufferSize(), "sendBufferSize"); assertEquals(4567, s.getSoLinger()); suggestEquals(0, s.getTrafficClass(), "trafficClass"); assertTrue(s instanceof SSLSocket); SSLSocket ss = (SSLSocket) s; assertTrue(ss.getEnableSessionCreation()); log.info("actual enabledCipherSuites: "); String[] strings = ss.getEnabledCipherSuites(); for (int i = 0; i < strings.length; i++) log.info(" " + strings[i]); assertEquals(cipherSuites, ss.getEnabledCipherSuites()); assertEquals(protocols, ss.getEnabledProtocols()); } protected void assertEquals(String[] strings1, String[] strings2) { HashSet set1 = new HashSet(); for (int i = 0; i < strings1.length; i++) set1.add(strings1[i]); HashSet set2 = new HashSet(); for (int i = 0; i < strings2.length; i++) set2.add(strings2[i]); assertEquals(set1, set2); } protected String getTransport() { return "sslsocket"; } protected void addExtraClientConfig(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"); } protected void addExtraServerConfig(Map config) { 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"); } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/FactoryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/0000644000175000017500000000262210446027031033426 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.socket.ssl.config; import org.jboss.test.remoting.transport.config.FactoryConfigTestCaseSSLParent; /** * * @author Ron Sigal *

* Copyright (c) May 20, 2006 *

*/ public class FactoryConfigTestCase extends FactoryConfigTestCaseSSLParent { protected String getTransport() { return "sslsocket"; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/timeout/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/timeout0000755000175000017500000000000011632407040033564 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/timeout/SSLSocketWriteTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/timeout0000644000175000017500000000265111413660476033605 0ustar twernertwerner/* * 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.transport.socket.ssl.timeout; import org.jboss.test.remoting.transport.socket.timeout.SSLWriteTimeoutTestParent; /** * Unit tests for JBREM-1120. * * @author Ron Sigal * @version $Rev$ *

* Copyright Apr 22, 2009 *

*/ public class SSLSocketWriteTimeoutTestCase extends SSLWriteTimeoutTestParent { protected String getTransport() { return "sslsocket"; } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/timeout/SSLSocketDefaultTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/timeout0000644000175000017500000000611111413660476033600 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2010, 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.transport.socket.ssl.timeout; import java.io.IOException; import java.util.Map; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.socket.ServerAddress; import org.jboss.remoting.transport.sslsocket.SSLSocketClientInvoker; import org.jboss.test.remoting.transport.socket.timeout.SocketDefaultTimeoutTestCase; /** * Unit tests for JBREM-1188. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 16, 2010 */ public class SSLSocketDefaultTimeoutTestCase extends SocketDefaultTimeoutTestCase { private static Logger log = Logger.getLogger(SSLSocketDefaultTimeoutTestCase.class); protected Class getClientFactoryClass() { return TestSSLSocketClientFactory.class; } protected Class getClientInvokerClass() { return TestSSLSocketClientInvoker.class; } public static class TestSSLSocketClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { ClientInvoker clientInvoker = new TestSSLSocketClientInvoker(locator, config); log.info("TestClientFaotory.createClientInvoker() returning " + clientInvoker); return clientInvoker; } public boolean supportsSSL() { return true; } } public static class TestSSLSocketClientInvoker extends SSLSocketClientInvoker { public TestSSLSocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); } public TestSSLSocketClientInvoker(InvokerLocator locator) throws IOException { super(locator); } public ServerAddress getServerAddress() { return address; } public String toString() { return "TestSSLSocketClientInvoker"; } } }././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/timeout/SSLSocketPerInvocationTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/timeout0000644000175000017500000001431310715774705033610 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.timeout; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; import org.jboss.test.remoting.timeout.SSLPerInvocationTimeoutTestRoot; /** * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 2936 $ *

* Copyright Feb 6, 2007 *

*/ public class SSLSocketPerInvocationTimeoutTestCase extends SSLPerInvocationTimeoutTestRoot { /** * This test verifies that the timeout for a socket wrapper gets reset after * an invocation with an invocation specific timeout has been executed. */ public void testTimeoutReset() throws Throwable { log.info("entering " + getName()); ClientInvoker invoker = client.getInvoker(); assertTrue(invoker instanceof MicroSocketClientInvoker); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool = (List) field.get(invoker); assertEquals(0, pool.size()); Object response = client.invoke(NO_WAIT); assertEquals(NO_WAIT, response); assertEquals(1, pool.size()); SocketWrapper socket = (SocketWrapper) pool.get(0); assertEquals(CONFIGURED_TIMEOUT, socket.getTimeout()); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "1000"); response = client.invoke(NO_WAIT, metadata); assertEquals(NO_WAIT, response); assertEquals(1, pool.size()); socket = (SocketWrapper) pool.get(0); assertEquals(CONFIGURED_TIMEOUT, socket.getTimeout()); } // This test verifies that a temporary timeout value gets passed when a new // socket wrapper is created. It is important that the socket wrapper gets // the temporary timeout value because creating object streams entails i/o // on the socket. public void testNewSocketTimeout() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); addServerConfig(serverConfig); final Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); // Disable the server so that the client will need to create a new socket, and // so that the creation of the socket wrapper will fail. new Thread() { public void run() { try { // Give the client a chance to connect to the server, then // disable the server. Thread.sleep(2000); ServerInvoker si = connector.getServerInvoker(); assertTrue(si instanceof SocketServerInvoker); SocketServerInvoker ssi = (SocketServerInvoker) si; Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(ssi); Set threads = clientpool.getContents(); Iterator it = threads.iterator(); while (it.hasNext()) { ServerThread t = (ServerThread) it.next(); t.shutdown(); } ssi.setMaxPoolSize(0); log.info("server is disabled"); } catch (Exception e) { log.info(e); } } }.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(ServerInvoker.TIMEOUT, "20000"); clientConfig.put(Client.ENABLE_LEASE, "true"); addClientConfig(clientConfig); final Client client = new Client(locator, clientConfig); client.connect(); Object response = client.invoke("test 1"); assertEquals("test 1", response); log.info("first invocation succeeded"); class BooleanHolder {public boolean value;} final BooleanHolder timedOut = new BooleanHolder(); timedOut.value = false; new Thread() { public void run() { try { // Wait for the server to be disabled. Thread.sleep(4000); // This invocation will require the creation of a new socket, which // should promptly time out. HashMap metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "1000"); client.invoke("test 3", metadata); fail("failed to time out"); } catch (Throwable e) { timedOut.value = true; log.info("time out", e); } } }.start(); // It should take the Client a little while for LeasePinger's attempts to contact // the server to time out. Wait for 4 seconds after the call to Client.invoke() // and then verify that the Client has timed out according to the temporary timeout // value 1000 instead of the configureed value 20000. Thread.sleep(8000); assertTrue(timedOut.value); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "sslsocket"; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/handshake/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/handsha0000755000175000017500000000000011632407040033504 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/handshake/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/handsha0000644000175000017500000001104210432245666033517 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.handshake; import org.apache.log4j.Level; 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.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import javax.net.ServerSocketFactory; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class InvokerServerTest extends ServerTestCase implements SSLInvokerConstants { private int serverPort = port; private Connector connector = null; private static final Logger log = Logger.getLogger(InvokerServerTest.class); public void init(Map metatdata) throws Exception { if (serverPort < 0) { serverPort = TestUtil.getRandomPort(); } InvokerServerTest.log.debug("port = " + serverPort); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); ServerSocketFactory svrSocketFactory = createServerSocketFactory(); connector.setServerSocketFactory(svrSocketFactory); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected String getTransport() { return transport; } private ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; // since doing basic (using default ssl server socket factory) // need to set the system properties to the keystore and password String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); SSLSocketBuilder server = new SSLSocketBuilder(); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } private String buildLocatorURI(Map metadata) { if (metadata == null || metadata.size() == 0) { return getTransport() + "://" + host + ":" + serverPort; } else { StringBuffer uriBuffer = new StringBuffer(getTransport() + "://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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { init(null); } protected void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); InvokerServerTest server = new InvokerServerTest(); try { server.setUp(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/handshake/InvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/handsha0000644000175000017500000000323510535452155033521 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.handshake; 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 InvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InvokerClientTest.class.getName(), 1, InvokerServerTest.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; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/handshake/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/handsha0000644000175000017500000001303110426021232033477 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.handshake; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import javax.net.ssl.HandshakeCompletedEvent; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; import java.io.UnsupportedEncodingException; import java.security.cert.Certificate; import java.util.HashMap; import java.util.Map; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public class InvokerClientTest extends TestCase implements SSLInvokerConstants, HandshakeCompletedListener { private Client client; private static final Logger log = Logger.getLogger(InvokerClientTest.class); private String cipherSuite; private Certificate[] localCerts; private Certificate[] peerCerts; public void init() { try { Map config = new HashMap(); config.put(Client.HANDSHAKE_COMPLETED_LISTENER, this); // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + port); client = new Client(locator, "mock", config); client.connect(); } catch (Exception e) { InvokerClientTest.log.error(e.getMessage(), e); } } public void testRemoteCall() throws Throwable { InvokerClientTest.log.debug("running testRemoteCall()"); InvokerClientTest.log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); if ("bar".equals(ret)) { InvokerClientTest.log.debug("PASS"); } else { InvokerClientTest.log.debug("FAILED"); } assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); assertTrue("CipherSuite = TLS_DHE_DSS_WITH_AES_128_CBC_SHA", cipherSuite.equals("TLS_DHE_DSS_WITH_AES_128_CBC_SHA")); // X509Certificate localCert = (X509Certificate) localCerts[0]; // assertTrue("LocalCert.SubjectDN = CN=unit-tests-client, OU=JBoss Inc., O=JBoss Inc., ST=Washington, C=US", // localCert.getSubjectDN().getName().equals("CN=unit-tests-client, OU=JBoss Inc., O=JBoss Inc., ST=Washington, C=US")); } protected String getTransport() { return transport; } private 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; } public void setUp() throws Exception { init(); } public void tearDown() throws Exception { if (client != null) { client.disconnect(); client = null; } } public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) { log.info("handshakeCompleted, event=" + handshakeCompletedEvent); try { cipherSuite = handshakeCompletedEvent.getCipherSuite(); log.info("CipherSuite: " + cipherSuite); System.out.println("CipherSuite: " + cipherSuite); localCerts = handshakeCompletedEvent.getLocalCertificates(); log.info("LocalCertificates:"); if (localCerts != null) { for (int n = 0; n < localCerts.length; n ++) { Certificate cert = localCerts[n]; log.info(cert); System.out.println(cert); } } log.info("PeerCertificates:"); System.out.println("PeerCertificates:"); peerCerts = handshakeCompletedEvent.getPeerCertificates(); if (peerCerts != null) { for (int n = 0; n < peerCerts.length; n ++) { Certificate cert = peerCerts[n]; log.info(cert); System.out.println(cert); } } SSLSession session = handshakeCompletedEvent.getSession(); String[] names = session.getValueNames(); for (int n = 0; n < names.length; n ++) { String name = names[n]; log.info(name + "=" + session.getValue(name)); System.out.println(name + "=" + session.getValue(name)); } String sessionID = null; byte[] id = handshakeCompletedEvent.getSession().getId(); try { sessionID = new String(id, "UTF-8"); } catch (UnsupportedEncodingException e) { log.warn("Failed to create session id using UTF-8, using default", e); sessionID = new String(id); } System.out.println("sessionId: " + sessionID); } catch (SSLPeerUnverifiedException e) { log.error("Failed to get peer cert", e); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/restart/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/restart0000755000175000017500000000000011632407040033562 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/restart/SSLSocketServerRestartTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/restart0000644000175000017500000000440510723136700033571 0ustar twernertwerner/* * 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.transport.socket.ssl.restart; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.restart.ServerRestartTestParent; /** * Unit test for JBREM-745. * * @author Ron Sigal * @version $Revision: 3022 $ *

* Copyright November 27, 2007 *

*/ public class SSLSocketServerRestartTestCase extends ServerRestartTestParent { protected String getTransport() { return "sslsocket"; } protected void addExtraServerConfig(Map config) { 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"); } protected void addExtraClientConfig(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"); } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/multihome/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/multiho0000755000175000017500000000000011632407040033557 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/multihome/SSLSocketMultihomeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/multiho0000644000175000017500000000552311413660476033601 0ustar twernertwerner /* * 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.transport.socket.ssl.multihome; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.transport.socket.multihome.SocketMultihomeTestCase; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jan 8, 2008 *

*/ public class SSLSocketMultihomeTestCase extends SocketMultihomeTestCase { protected String getTransport() { return "sslsocket"; } protected void addExtraServerConfig(Map config) { super.addExtraServerConfig(config); 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"); } protected void addExtraClientConfig(Map config) { super.addExtraClientConfig(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"); } protected void addExtraCallbackConfig(Map config) { super.addExtraCallbackConfig(config); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); 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"); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/.keystorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/.keysto0000644000175000017500000001376110345206626033513 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000755000175000017500000000000011632407040033567 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/TestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000000645011006441205033572 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import java.util.HashMap; import java.util.Map; /** * @author Michael Voss * */ public class TestClient extends TestCase{ private static Logger log = Logger.getLogger(TestClient.class); private String keyStorePath="src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/clientKeyStore"; private String trustStorePath="src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/clientTrustStore"; private String keyStorePassword="testpw"; private String trustStorePassword="testpw"; InvokerLocator locator; Client client; Map configuration; public void setUp() throws Exception{ log.info("entering setUp()"); locator=new InvokerLocator(getTransport() + "://localHost:2001"); //the client side connection endpoint configuration = new HashMap(); //String keyStorePath = this.getClass().getResource("certificate/serverKeyStore").getFile(); //String trustStorePath = this.getClass().getResource("certificate/serverTrustStore").getFile(); String keyStorePath = this.getClass().getResource("certificate/clientKeyStore").getFile(); String trustStorePath = this.getClass().getResource("certificate/clientTrustStore").getFile(); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStorePath); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, keyStorePassword); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStorePath); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, trustStorePassword); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); client=new Client(locator,"Sample",configuration); client.connect(); log.info("leaving setUp()"); } public void tearDown() throws Exception{ log.info("entering tearDown()"); Thread.sleep(10000);//let the server fetch his new truststore and refresh serversocket log.info("finished first sleep in tearDown()"); client.disconnect(); log.info("disconnected client in tearDown()"); Thread.sleep(350000); log.info("finished second sleep in tearDown()"); try { setUp();//secondPass -> client is not accepted by new truststore test();//secondPass -> client is not accepted by new truststore } catch (Throwable e) { log.error("expected Exception", e); client.disconnect(); log.info("SUCCESS"); return; } client.disconnect(); throw new Exception("should not reach this point");//because client should not be accepted by new server truststore } /** * @throws Throwable */ public void test() throws Throwable{ log.info("Invoking server with 'something'"); log.info("Server answer is: "+client.invoke("something")); } protected String getTransport() { return "sslsocket"; } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/ServerSocketRefreshTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000003660311413660476033614 0ustar twernertwerner/* * 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.transport.socket.ssl.serversocketrefresh; import java.io.FileInputStream; import java.io.IOException; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.ServerSocket; import java.security.KeyStore; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; 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.CannotConnectException; 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.callback.InvokerCallbackHandler; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * ServerSocketRefreshTestCase replaces Michael Voss' test * org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh.TestCase. * It tests the same functionality, namely, the hot replacement of a ServerSocket * in a socket transport server. However, it is easier to manage the possibility * that it may take a while to rebind a ServerSocket to an old port. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 9, 2008 *

*/ public class ServerSocketRefreshTestCase extends TestCase { private static Logger log = Logger.getLogger(ServerSocketRefreshTestCase.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 testServerSocketRefresh() 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 trustStorePath = getClass().getResource("certificate/clientTrustStore").getFile(); clientConfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStorePath); clientConfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "testpw"); clientConfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); clientConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStorePath = getClass().getResource("certificate/clientKeyStore").getFile(); clientConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStorePath); clientConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "testpw"); clientConfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); clientConfig.put(InvokerLocator.FORCE_REMOTE, "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"); client.disconnect(); // Get current ServerSocket. SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("acceptThreads"); field.setAccessible(true); SocketServerInvoker.AcceptThread[] threads = null; threads = (SocketServerInvoker.AcceptThread[]) field.get(invoker); assertEquals(1, threads.length); ServerSocket serverSocket = threads[0].getServerSocket(); log.info("original ServerSocket: " + serverSocket); // Update ServerSocket. String trustStorePath2 = getClass().getResource("certificate/serverTrustStore2").getFile(); ServerSocketFactory ssf = createServerSocketFactory("testpw", "testpw", keyStorePath, trustStorePath2); invoker.setNewServerSocketFactory(ssf); log.info("passed in new ServerSocketFactory"); Thread.sleep(10000); int i = 0; while (true) { if (!serverSocket.equals(threads[0].getServerSocket())) break; if (++i >= 10) break; log.info("ServerSocket has not been replaced yet. Will wait 30 seconds and try again."); Thread.sleep(30000); } // Verify new Client is unable to carry out invocation. client = new Client(clientLocator, clientConfig); client.connect(); ServerSocket newServerSocket = threads[0].getServerSocket(); log.info("new ServerSocket: " + newServerSocket); assertNotSame(newServerSocket, serverSocket); boolean success = false; try { System.out.println("*****************************************************************"); System.out.println("****************** EXCEPTIONS EXPECTED ************************"); System.out.println("*****************************************************************"); client.invoke("xyz"); } catch (CannotConnectException e) { log.info("got expected exception:" + e.getMessage()); success = true; } catch (Throwable t) { log.error("got unexpected exception: ", t); } assertTrue("expected exception", success); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "sslsocket"; } 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 keyStorePath = getClass().getResource("certificate/serverKeyStore").getFile(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStorePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "testpw"); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStorePath = getClass().getResource("certificate/serverTrustStore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStorePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "testpw"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); ServerSocketFactory ssf = createServerSocketFactory("testpw", "testpw", keyStorePath, trustStorePath); config.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf); config.put("reuseAddress", "true"); 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(); } /** * returns a SSLServerSocketFactory that requires a client certificate to build up SSL connection * @param keyStorePassword * @param trustStorePassword * @param keyStorePath * @param trustStorePath * @return SSLServerSocketFactory * @throws Exception */ public SSLServerSocketFactory createServerSocketFactory(String keyStorePassword, String trustStorePassword, String keyStorePath, String trustStorePath) throws Exception { SSLServerSocketFactory ssf = createNoAuthServerSocketFactory(keyStorePassword,trustStorePassword,keyStorePath,trustStorePath); return new ClientAuthSocketFactory(ssf); } /** * returns a SSLServerSocketFactory * @param keyStorePassword * @param trustStorePassword * @param keyStorePath * @param trustStorePath * @return SSLServerSocketFactory * @throws Exception */ public static SSLServerSocketFactory createNoAuthServerSocketFactory(String keyStorePassword, String trustStorePassword, String keyStorePath, String trustStorePath) throws Exception { FileInputStream stream=null; try { // create an SSLContext SSLContext context = null; context = SSLContext.getInstance("TLS"); // define password char[] keyPassphrase = keyStorePassword.toCharArray(); char[] trustPassphrase = trustStorePassword.toCharArray(); // load the server key store KeyStore server_keystore = KeyStore.getInstance("JKS"); stream = new FileInputStream(keyStorePath); server_keystore.load(stream, keyPassphrase); stream.close(); // load the server trust store KeyStore server_truststore = KeyStore.getInstance("JKS"); stream = new FileInputStream(trustStorePath); server_truststore.load(stream, trustPassphrase); stream.close(); // initialize a KeyManagerFactory with the KeyStore KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(server_keystore, keyPassphrase); // KeyManagers from the KeyManagerFactory KeyManager[] keyManagers = kmf.getKeyManagers(); // initialize a TrustManagerFactory with the TrustStore TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(server_truststore); // TrustManagers from the TrustManagerFactory TrustManager[] trustManagers = tmf.getTrustManagers(); // initialize context with Keystore and Truststore information context.init(keyManagers, trustManagers, null); // get ServerSocketFactory from context return context.getServerSocketFactory(); } catch (Exception e) { throw e; } finally { try { stream.close(); } catch (Exception ioe) { } } } 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) {} } /** * overrides createServerSocket methods from class SSLServerSocketFactory
* sets NeedClientAuth true, so server asks for a client certificate in the SSL handshake * @author Michael Voss * */ public static class ClientAuthSocketFactory extends SSLServerSocketFactory{ SSLServerSocketFactory serverSocketFactory; /** * @param serverSocketFactory */ public ClientAuthSocketFactory(SSLServerSocketFactory serverSocketFactory) { this.serverSocketFactory = serverSocketFactory; } public ServerSocket createServerSocket() throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0, arg1); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0, arg1, arg2); ss.setNeedClientAuth(true); return ss; } public boolean equals(Object obj) { return serverSocketFactory.equals(obj); } public String[] getDefaultCipherSuites() { return serverSocketFactory.getDefaultCipherSuites(); } public String[] getSupportedCipherSuites() { return serverSocketFactory.getSupportedCipherSuites(); } public int hashCode() { return serverSocketFactory.hashCode(); } public String toString() { return serverSocketFactory.toString(); } } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000755000175000017500000000000011632407040033567 5ustar twernertwerner././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/serverTrustStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000000121110442263232033565 0ustar twernertwernerþíþí clientcert ¸£½,X.509F0‚B0‚«D‰`Õ0  *†H†÷ 0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0 060609115149Z 060907115149Z0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0Ÿ0  *†H†÷ 0‰•œ”ŒaUtâ¶ôÞD¾ áBÃ:[ËL#ßè}ºÀû÷…¯ƒF*…$ê•,†iem¯M3ñÈ/d¼ÇsÝÁßέÞt°¢›3q–ÅqÈ='±!Ö-Õ‘z54 ÄbãË–ºØB(ÞçýîBß?¸B=•^R=ñ~&¡±vƒÃ0  *†H†÷ }$L„ÃAÅ'Ç ½þÜóë$Ž&¢©9ï·3êÁ¬ð¡Ëà<”žMè Ùÿg‰÷aÀ¤uyóD§«Îö¬ÏÓ·jXà¤Ö°¬ÅúìÏ­áš“þ*èÕ¾ãY…Ò[àsªZxŽs5PņŸ;.A/ Fù8+è|ßc+ÆWì~YY½¬—b»½¤ÔTkh‚C²././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/serverKeyStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000000250710442263232033576 0ustar twernertwernerþíþímykey ¸¢á¢»0‚·0 +*‚£„LÚ£„û fbŸ¹oº2KÛùGµŸ¡â8ƒJ¬¡¾;laL,\Hœ¬è|Kß´Úë>‘|€¾ÿçau© `¥×n*Ú ëÎó_ÿ“8¬ä¯öBníRV‹enPæ=ÄË vçeOƒPÛó¶öø›muY˜jÓÞ+çËZ«@×û¯ôß¿[rÿÖçÏ'Á h¡D «ØŠ,¾âl,<}6nΜ¨vGëÇ'Ä!ЀŸÉËÕW–å€x]É×g«ÁÔÛ(^WV]õ6àSÆ88³ËWjd¸eÒìÊ`!•¶TFt¯1CÛ(YFSÆ'^”PÄ>”°o 4ôQÜC’—*w–-;>à€\;­ªWÀ5«—ãh<Ô8Ç/'êÇ‘”rŽ9»õ}Ûc+™Ìï›Nñi ܰ²Œ µ†„$ŒîÀ×(Mª3†…o˜ZÌ_5a®ÙÅ 4ˆv¬2GaŽ(zHž½Ô'·M^FHŽXàª/’ëàoïÄõß1⊹ÐÀI¯Ð¸ÚÌ•ÿÚÛÛ4׈UÜ@)ôß°îFÀ%Ì^:ÂLRç/²h½þü:œ<ƒqSĤ¯¶JK±Vå„>ÅÉTD¾ÊLèm‹Õ¡å 6ž„C»žwûïjªPR個ŸjuVIOðòØê·† ÖÖ¶, ˜,¦‹|=uZJÇX.509F0‚B0‚«D‰`ý0  *†H†÷ 0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0 060609115229Z 060907115229Z0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0Ÿ0  *†H†÷ 0‰–%º‚2,Ð9 Ò/Ȇ¶úÉü¸îü~Y+yŸŸã+³úé›A¬]ú¯$¥ØÑä“zYlK÷ƒ8†Mø[e­2ÌòYuÙ]3âáu°ùä÷CÅÚÿªÝ^í°Ø…ëR‘S MÒr?>/”®òvc¾jê)VûG0x5$q\0  *†H†÷ !0o2EލÞƒ6;W!ÚÊæºÆ%t†úH'_P }¡…Ë;…Îc Q,ˆø/´¿h£vöp-8Ãz Õ‰¼€9ƒÕT%õÁ8˜íÄ5l„ _Ø$\3ÿG;]í¶Ì×7j¶Óü@÷X^1?¥±\!}ÆŸ×vq{gíƒkÌý¢Z<¥X¦âô§NÛ{p•sÙH././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/serverTrustStore2libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000000131710442263232033574 0ustar twernertwernerþíþí clientcert ¸ªgBX.509Œ0‚ˆ0‚ñD‰b•0  *†H†÷ 0Š1 0 UDE10Uanother client10Uanother client10U another client10U another client10Uanother client0 060609115917Z 060907115917Z0Š1 0 UDE10Uanother client10Uanother client10U another client10U another client10Uanother client0Ÿ0  *†H†÷ 0‰×ø~ðrøL™ÇêJ¨'S½|gýƒÀ)L_܃$`õ3RCK4,ØAuÆ|B½2)û b¬õ¤à–ˆå ¥ÊÈÊ©r7êü`¹4ï»a 8Ç'GТ±§âˆ ?o©$Ç¡9PÊÿH¥2ÄðÍ•ÿýÛ4„yÞkj±è ” ƒ™0  *†H†÷ 0¿ôÀ*Ûþ>_?Xù©k˜ÃˆÈ¿ ³; EÎLäûû¼ÞCãËšžëfy]Âî1YUE–»mD‹Üºâ-#M.îqT*€ìë½±Þ0ö{ë'Ó½!×å;I*o¦”¥ZZ)h jâ~$ËyÎWu€1 ,¤•Œ®ÚP¹ek;Ya ÃÐÓ-q°;'&ŠûêD././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/clientTrustStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000000121110442263232033565 0ustar twernertwernerþíþí servercert ¸¤ˆIX.509F0‚B0‚«D‰`ý0  *†H†÷ 0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0 060609115229Z 060907115229Z0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0Ÿ0  *†H†÷ 0‰–%º‚2,Ð9 Ò/Ȇ¶úÉü¸îü~Y+yŸŸã+³úé›A¬]ú¯$¥ØÑä“zYlK÷ƒ8†Mø[e­2ÌòYuÙ]3âáu°ùä÷CÅÚÿªÝ^í°Ø…ëR‘S MÒr?>/”®òvc¾jê)VûG0x5$q\0  *†H†÷ !0o2EލÞƒ6;W!ÚÊæºÆ%t†úH'_P }¡…Ë;…Îc Q,ˆø/´¿h£vöp-8Ãz Õ‰¼€9ƒÕT%õÁ8˜íÄ5l„ _Ø$\3ÿG;]í¶Ì×7j¶Óü@÷X^1?¥±\!}ÆŸ×vq{gíƒkÌ×–zY/Žt}nÑw<¹»5е././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/clientKeyStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000000250710442263232033576 0ustar twernertwernerþíþímykey ¸¢JG»0‚·0 +*‚£´G÷ 9Í õÄÉÆI~š˜fèíµš†·§ÁGoþË\¢t[JæyÁ½ØRŠƒ,üc•zî·Ñʰ0<£Ø~j#¢ä£I^ÁG‹õ|C5m¹ygN]Ž*^Ž"±ü3è<«±FÕîNÝôa¾úŽ™³ÍI£z¾Ê&Žû:r±O«xo· ¸Í™ÍpnCäZµa†'†í!‚ï–&"Y"# hd3¯°s)c¢Œ¬3hóÀ…QóÀ´Ü"]E²_=¼Ys\ é£oÅóÕ»óšçÁ(3QM!ðd>Îß xë§±.^`ºzÚœ63S0PuÒ¬\ŽSÆ—¶û=àä:­qñâX¼NF¾a‡ÔˆåÃ%˔ٶ"Œl"Îí¦° ¯%Fð¬Þ„q p3ÕS&CDÏe"#†²¨öÏ}*ê2¤¥W‚†#Ö½y'ô¶WÀI^«“­Çço8Ô¶1Go¸*hü',ß9OÜßbÅî÷C$o­ñGúG{²9ŽƒÎ `ƒƒ£´¿±Î§[‰«ci úJ'‡ó¶+&'A®Mªê~ôtŽÁ½—9Ó­_ZŽ«ˆþpPí’Çҭப¶~IÎ'ó<ïäTý¡Ÿ§ÑåT¿¨øW‚å÷Y$±­Om Õnœø„xú ó„½IGfÕ×ùìe a«ç¾}èõý ®"Ól~õ7Ü5°‚¯[$A÷?U_ mR£T·ÕSqŒ†ùã!¦‘{3àÀ¯QŠvRóôÚ‡K3‡ZJŠÂÔpò£ )b‹ªvâE½¯ËŒ~®/3Í»¬ìù¼ ý™Š¿dD²a5¾¹ÏW3/ é̓¬FžQ®ªÏ‘¤‘hÆ›™ðçOr;>_‰4ˆwºÂq¬m–ð3XŽX.509F0‚B0‚«D‰`Õ0  *†H†÷ 0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0 060609115149Z 060907115149Z0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0Ÿ0  *†H†÷ 0‰•œ”ŒaUtâ¶ôÞD¾ áBÃ:[ËL#ßè}ºÀû÷…¯ƒF*…$ê•,†iem¯M3ñÈ/d¼ÇsÝÁßέÞt°¢›3q–ÅqÈ='±!Ö-Õ‘z54 ÄbãË–ºØB(ÞçýîBß?¸B=•^R=ñ~&¡±vƒÃ0  *†H†÷ }$L„ÃAÅ'Ç ½þÜóë$Ž&¢©9ï·3êÁ¬ð¡Ëà<”žMè Ùÿg‰÷aÀ¤uyóD§«Îö¬ÏÓ·jXà¤Ö°¬ÅúìÏ­áš“þ*èÕ¾ãY…Ò[àsªZxŽs5PņŸ;.A/ Fù8+è|ßc+ÆWì~àÃèU7«È›ðøU柿ë=ó¿¼././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/TestCase_Retired.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000000163611011212176033572 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; import org.jboss.logging.XLevel; /** * JBREM-427 load a new keystore at runtime
* server is refreshing its serversocket after a new ServerSocketFactory was set
* second client connection attempt fails because client is not accepted by the new truststore * @author Michael Voss * */ public class TestCase_Retired extends TestDriver{ public void declareTestClasses() { addTestClasses(TestClient.class.getName(), 1, TestServer.class.getName()); } protected Level getTestLogLevel() { return XLevel.TRACE; } protected long getResultsTimeout() { return 480000; } protected long getRunTestTimeout() { return 480000; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/TestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/servers0000644000175000017500000002676011006441205033600 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; 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.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.socket.SocketServerInvoker; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import java.io.FileInputStream; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.security.KeyStore; import java.util.HashMap; import java.util.Map; /** * @author Michael Voss * */ public class TestServer extends ServerTestCase{ private static Logger log = Logger.getLogger("TestServer"); protected String localHost="127.0.0.1"; protected String keyStorePath="src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/serverKeyStore"; protected String trustStorePath="src/tests/org/jboss/test/remoting/transport/socket/ssl/serversocketrefresh/certificate/serverTrustStore"; protected String keyStorePassword="testpw"; protected String trustStorePassword="testpw"; protected String port="2001"; protected Connector connector; protected MBeanServer server; protected static boolean invocationDone=false; public void setUp(){ log.info("entering setUp"); // starting connector try{ //make it SSL-ready for sending callbacks (server acts as a client) Map configuration = new HashMap(); keyStorePath = this.getClass().getResource("certificate/serverKeyStore").getFile(); trustStorePath = this.getClass().getResource("certificate/serverTrustStore").getFile(); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStorePath); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, keyStorePassword); configuration.put(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM, "SunX509"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStorePath); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, trustStorePassword); configuration.put(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM, "SunX509"); configuration.put("reuseAddress", "true"); connector = new Connector(configuration); InvokerLocator locator = new InvokerLocator(getTransport() + "://"+localHost+":"+port); connector.setInvokerLocator(locator.getLocatorURI()); server=MBeanServerFactory.createMBeanServer(); server.registerMBean(connector, new ObjectName("jboss.remoting:type=Connector")); connector.create(); //make it SSL-ready for clients that want to build up connection: try{ // create server socket factory ServerSocketFactory svrSocketFactory = createServerSocketFactory(keyStorePassword,trustStorePassword,keyStorePath,trustStorePath); // notice that the invoker has to be explicitly cast to the // SocketServerInvoker type SocketServerInvoker socketSvrInvoker = (SocketServerInvoker) connector.getServerInvoker(); socketSvrInvoker.setServerSocketFactory(svrSocketFactory); } catch(Exception e){ e.printStackTrace(); } connector.addInvocationHandler("Sample",new Sample()); connector.start(); log.info("leaving setUp()"); } catch(Exception e){ e.printStackTrace(); } } public void tearDown() throws Exception { log.info("entering tearDown()"); Thread.sleep(10000); server.unregisterMBean( new ObjectName("jboss.remoting:type=Connector")); connector.removeInvocationHandler("Sample"); connector.stop(); log.info("stopped Connector"); } public void test() throws Exception { log.info("entering test()"); for (int i = 0; i < 5; i++) { if (invocationDone) break; Thread.sleep(2000); } assertTrue(invocationDone); log.info("invocation done"); String keyStorePath2 = this.getClass().getResource("certificate/serverTrustStore2").getFile(); ((SocketServerInvoker) connector.getServerInvoker()).setNewServerSocketFactory(createServerSocketFactory(keyStorePassword,trustStorePassword,keyStorePath,keyStorePath2)); Thread.sleep(250000);//let client build up connection a second time log.info("leaving test()"); } public static void main(String[] args) { TestServer server = new TestServer(); server.setUp(); try { server.test(); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "sslsocket"; } /** * @author Michael Voss * */ public static class Sample implements ServerInvocationHandler { /** * called by the remoting server to handle the invocation from client. * * @param invocation * @return Object * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { invocationDone=true; System.err.println("client invoked: "+invocation.getParameter()); System.err.println("answering: succeess"); return "success"; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler 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 } } /** * returns a SSLServerSocketFactory that requires a client certificate to build up SSL connection * @param keyStorePassword * @param trustStorePassword * @param keyStorePath * @param trustStorePath * @return SSLServerSocketFactory * @throws Exception */ public static SSLServerSocketFactory createServerSocketFactory(String keyStorePassword, String trustStorePassword, String keyStorePath, String trustStorePath) throws Exception { return new ClientAuthSocketFactory(createNoAuthServerSocketFactory(keyStorePassword,trustStorePassword,keyStorePath,trustStorePath)); } /** * returns a SSLServerSocketFactory * @param keyStorePassword * @param trustStorePassword * @param keyStorePath * @param trustStorePath * @return SSLServerSocketFactory * @throws Exception */ public static SSLServerSocketFactory createNoAuthServerSocketFactory(String keyStorePassword, String trustStorePassword, String keyStorePath, String trustStorePath) throws Exception { FileInputStream stream=null; try { // create an SSLContext SSLContext context = null; context = SSLContext.getInstance("TLS"); // define password char[] keyPassphrase = keyStorePassword.toCharArray(); char[] trustPassphrase = trustStorePassword.toCharArray(); // load the server key store KeyStore server_keystore = KeyStore.getInstance("JKS"); stream = new FileInputStream(keyStorePath); server_keystore.load(stream, keyPassphrase); stream.close(); // load the server trust store KeyStore server_truststore = KeyStore.getInstance("JKS"); stream = new FileInputStream(trustStorePath); server_truststore.load(stream, trustPassphrase); stream.close(); // initialize a KeyManagerFactory with the KeyStore KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(server_keystore, keyPassphrase); // KeyManagers from the KeyManagerFactory KeyManager[] keyManagers = kmf.getKeyManagers(); // initialize a TrustManagerFactory with the TrustStore TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509"); tmf.init(server_truststore); // TrustManagers from the TrustManagerFactory TrustManager[] trustManagers = tmf.getTrustManagers(); // initialize context with Keystore and Truststore information context.init(keyManagers, trustManagers, null); // get ServerSocketFactory from context return context.getServerSocketFactory(); } catch (Exception e) { throw e; } finally { try { stream.close(); } catch (Exception ioe) { } } } /** * overrides createServerSocket methods from class SSLServerSocketFactory
* sets NeedClientAuth true, so server asks for a client certificate in the SSL handshake * @author Michael Voss * */ public static class ClientAuthSocketFactory extends SSLServerSocketFactory{ SSLServerSocketFactory serverSocketFactory; /** * @param serverSocketFactory */ public ClientAuthSocketFactory(SSLServerSocketFactory serverSocketFactory) { this.serverSocketFactory = serverSocketFactory; } public ServerSocket createServerSocket() throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0, arg1); ss.setNeedClientAuth(true); return ss; } public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { SSLServerSocket ss = (SSLServerSocket) serverSocketFactory.createServerSocket(arg0, arg1, arg2); ss.setNeedClientAuth(true); return ss; } public boolean equals(Object obj) { return serverSocketFactory.equals(obj); } public String[] getDefaultCipherSuites() { return serverSocketFactory.getDefaultCipherSuites(); } public String[] getSupportedCipherSuites() { return serverSocketFactory.getSupportedCipherSuites(); } public int hashCode() { return serverSocketFactory.hashCode(); } public String toString() { return serverSocketFactory.toString(); } } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/connection_check/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/connect0000755000175000017500000000000011632407040033527 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/connection_check/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/connect0000644000175000017500000001137410541703075033544 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.connection_check; import org.apache.log4j.Level; 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.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import javax.net.ServerSocketFactory; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class InvokerServerTest extends ServerTestCase implements SSLInvokerConstants { private int serverPort; private Connector connector = null; private static final Logger log = Logger.getLogger(InvokerServerTest.class); public void init(Map metatdata) throws Exception { serverPort = getPort(); if (serverPort < 0) { serverPort = TestUtil.getRandomPort(); } InvokerServerTest.log.debug("port = " + serverPort); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); ServerSocketFactory svrSocketFactory = createServerSocketFactory(); connector.setServerSocketFactory(svrSocketFactory); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected String getTransport() { return transport; } protected int getPort() { return port; } private ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; // since doing basic (using default ssl server socket factory) // need to set the system properties to the keystore and password String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); SSLSocketBuilder server = new SSLSocketBuilder(); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } private String buildLocatorURI(Map metadata) { if (metadata == null || metadata.size() == 0) { return getTransport() + "://" + host + ":" + serverPort + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.TRUE; } else { StringBuffer uriBuffer = new StringBuffer(getTransport() + "://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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { init(null); } protected void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); InvokerServerTest server = new InvokerServerTest(); try { server.setUp(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/connection_check/InvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/connect0000644000175000017500000000324410535452155033544 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.connection_check; 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 InvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InvokerClientTest.class.getName(), 1, InvokerServerTest.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; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/connection_check/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/connect0000644000175000017500000000622710541703075033545 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.connection_check; import junit.framework.TestCase; import org.apache.log4j.Level; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public class InvokerClientTest extends TestCase implements SSLInvokerConstants { private Client client; private static final Logger log = Logger.getLogger(InvokerClientTest.class); public void init() { try { // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + getPort() + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.TRUE); client = new Client(locator, "mock"); client.connect(); } catch (Exception e) { InvokerClientTest.log.error(e.getMessage(), e); } } public void testRemoteCall() throws Throwable { InvokerClientTest.log.debug("running testRemoteCall()"); InvokerClientTest.log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); if ("bar".equals(ret)) { InvokerClientTest.log.debug("PASS"); } else { InvokerClientTest.log.debug("FAILED"); } assertEquals("bar", ret); } protected String getTransport() { return transport; } protected int getPort() { return port; } private 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; } public void setUp() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); init(); } public void tearDown() throws Exception { if (client != null) { client.disconnect(); client = null; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/0000755000175000017500000000000011632407040033236 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/I0000644000175000017500000001234010541703075033356 0ustar twernertwerner/* * 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.transport.socket.ssl.basic; 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.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import javax.net.ServerSocketFactory; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class InvokerServerTest extends ServerTestCase implements SSLInvokerConstants { private int serverPort; private Connector connector = null; private static final Logger log = Logger.getLogger(InvokerServerTest.class); public void init(Map metatdata) throws Exception { serverPort = getPort(); if(serverPort < 0) { serverPort = TestUtil.getRandomPort(); } log.debug("port = " + serverPort); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); ServerSocketFactory svrSocketFactory = createServerSocketFactory(); connector.setServerSocketFactory(svrSocketFactory); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected String getTransport() { return transport; } protected int getPort() { return port; } private ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; // since doing basic (using default ssl server socket factory) // need to set the system properties to the keystore and password String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); SSLSocketBuilder server = new SSLSocketBuilder(); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } private String buildLocatorURI(Map metadata) { if(metadata == null || metadata.size() == 0) { return getTransport() + "://" + host + ":" + serverPort; } else { StringBuffer uriBuffer = new StringBuffer(getTransport() + "://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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { init(null); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { InvokerServerTest server = new InvokerServerTest(); try { server.setUp(); Thread.sleep(1200000); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/InvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/I0000644000175000017500000000517410535452155033370 0ustar twernertwerner/* * 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.transport.socket.ssl.basic; 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 InvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InvokerClientTest.class.getName(), 1, InvokerServerTest.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; } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/I0000644000175000017500000000700510541703075033360 0ustar twernertwerner/* * 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.transport.socket.ssl.basic; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import junit.framework.TestCase; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public class InvokerClientTest extends TestCase implements SSLInvokerConstants { private Client client; private static final Logger log = Logger.getLogger(InvokerClientTest.class); public void init() { try { // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + getPort()); client = new Client(locator, "mock"); client.connect(); } catch(Exception e) { log.error(e.getMessage(), e); } } public void testRemoteCall() throws Throwable { log.debug("running testRemoteCall()"); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); if("bar".equals(ret)) { log.debug("PASS"); } else { log.debug("FAILED"); } assertEquals("bar", ret); } protected String getTransport() { return transport; } protected int getPort() { return port; } private 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; } public void setUp() throws Exception { init(); } public void tearDown() throws Exception { if(client != null) { client.disconnect(); client = null; } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/system/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/s0000755000175000017500000000000011632407040033421 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/system/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/s0000644000175000017500000000643110432245666033442 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.basic.system; 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 org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class InvokerServerTest extends ServerTestCase implements SSLInvokerConstants { private int serverPort = port; private Connector connector = null; private static final Logger log = Logger.getLogger(InvokerServerTest.class); public void init(Map metatdata) throws Exception { if (serverPort < 0) { serverPort = TestUtil.getRandomPort(); } InvokerServerTest.log.debug("port = " + serverPort); // since doing basic (using default ssl server socket factory) // need to set the system properties to the keystore and password String keyStoreFilePath = this.getClass().getResource("../../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected String getTransport() { return transport; } private String buildLocatorURI(Map metadata) { if (metadata == null || metadata.size() == 0) { return getTransport() + "://" + host + ":" + serverPort; } else { StringBuffer uriBuffer = new StringBuffer(getTransport() + "://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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { init(null); } protected void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { InvokerServerTest server = new InvokerServerTest(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/system/InvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/s0000644000175000017500000000260410432245666033440 0ustar twernertwerner/* * 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.transport.socket.ssl.basic.system; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class InvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InvokerClientTest.class.getName(), 1, InvokerServerTest.class.getName()); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/system/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/basic/s0000644000175000017500000000512110432245666033435 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.basic.system; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public class InvokerClientTest extends TestCase implements SSLInvokerConstants { private Client client; private static final Logger log = Logger.getLogger(InvokerClientTest.class); public void init() { try { // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("../../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + port); client = new Client(locator, "mock"); client.connect(); } catch (Exception e) { log.error(e.getMessage(), e); e.printStackTrace(); } } public void testRemoteCall() throws Throwable { InvokerClientTest.log.debug("running testRemoteCall()"); // InvokerClientTest.log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); if ("bar".equals(ret)) { InvokerClientTest.log.debug("PASS"); } else { InvokerClientTest.log.debug("FAILED"); } assertEquals("bar", ret); } protected String getTransport() { return transport; } private 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; } public void setUp() throws Exception { init(); } public void tearDown() throws Exception { if (client != null) { client.disconnect(); client = null; } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/custom/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/custom/0000755000175000017500000000000011632407040033467 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/custom/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/custom/0000644000175000017500000001517010446030247033500 0ustar twernertwerner/* * 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.transport.socket.ssl.custom; 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.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import javax.net.ServerSocketFactory; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class InvokerServerTest extends ServerTestCase implements SSLInvokerConstants { protected int serverPort = port; protected Connector connector = null; private static final Logger log = Logger.getLogger(InvokerServerTest.class); public void init(Map metatdata) throws Exception { if(serverPort < 0) { serverPort = TestUtil.getRandomPort(); } log.debug("port = " + serverPort); Map config = new HashMap(); // config.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_TYPE, "JKS"); // String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); // config.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); // config.put(RemotingSSLSocketFactory.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // config.put(RemotingSSLSocketFactory.REMOTING_USE_CLIENT_MODE, "false"); // config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); // String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); // trustStoreFilePath = "output/tests/classes/org/jboss/test/remoting/transport/socket/ssl/.truststore"; // 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"); Connector connector = new Connector(config); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); // ServerSocketFactory svrSocketFactory = createServerSocketFactory(); // connector.setServerSocketFactory(svrSocketFactory); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected String getTransport() { return transport; } private ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; SSLSocketBuilder server = new SSLSocketBuilder(); server.setUseSSLServerSocketFactory(false); server.setSecureSocketProtocol("SSL"); server.setKeyStoreAlgorithm("SunX509"); server.setKeyStoreType("JKS"); String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); server.setKeyStoreURL(keyStoreFilePath); server.setKeyStorePassword("unit-tests-server"); /* * This is optional since if not set, will use * the key store password (and are the same in this case) */ //server.setKeyPassword("unit-tests-server"); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } protected String buildLocatorURI(Map metadata) { if(metadata == null || metadata.size() == 0) { return getTransport() + "://localhost:" + serverPort; } else { StringBuffer uriBuffer = new StringBuffer(getTransport() + "://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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { init(null); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { InvokerServerTest test = new InvokerServerTest(); try { test.setUp(); Thread.currentThread().sleep(20000); test.tearDown(); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/custom/InvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/custom/0000644000175000017500000000530210535452155033501 0ustar twernertwerner /* * 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.transport.socket.ssl.custom; 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 InvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InvokerClientTest.class.getName(), 1, InvokerServerTest.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; } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/custom/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/custom/0000644000175000017500000002525610713022056033502 0ustar twernertwerner/* * 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.transport.socket.ssl.custom; 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.RemoteClientInvoker; 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.invocation.NameBasedInvocation; import org.jboss.remoting.security.CustomSSLSocketFactory; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author Tom Elrod * @version $Revision: 2901 $ *

* Copyright (c) Mar 23, 2006 *

*/ public class InvokerClientTest extends TestCase implements SSLInvokerConstants { private static final Logger log = Logger.getLogger(InvokerClientTest.class); protected Client client; public void init() { try { Map config = new HashMap(); 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"); InvokerLocator locator = new InvokerLocator(getTransport() + "://localhost:" + port); client = new Client(locator, config); client.connect(); } catch(Exception e) { log.error(e.getMessage(), e); } } public void testRemoteCall() throws Throwable { log.debug("running testRemoteCall()"); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); if("bar".equals(ret)) { log.debug("PASS"); } else { log.debug("FAILED"); } assertEquals("bar", ret); } public void testSocketFactoryParameters() { try { Map config = new HashMap(); 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"); InvokerLocator locator = new InvokerLocator(getTransport() + "://localhost:" + port); client = new Client(locator, config); client.connect(); // Test that parameters are properly set. RemoteClientInvoker clientInvoker = (RemoteClientInvoker) client.getInvoker(); CustomSSLSocketFactory socketFactory = (CustomSSLSocketFactory) clientInvoker.getSocketFactory(); assertTrue(socketFactory.getSSLSocketBuilder().getTrustStoreType().equals("JKS")); // assertTrue(socketFactory.gett.equals("JKS")); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } public void testCallbacks() { try { InvokerLocator locator = new InvokerLocator(getTransport() + "://localhost:" + callbackPort); Connector callbackConnector = new Connector(locator.getLocatorURI()); callbackConnector.setServerSocketFactory(createServerSocketFactory()); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, locator, callbackHandleObject); solicitCallback("abc"); // need to wait for brief moment so server can callback Thread.sleep(2000); // remove callback handler from server client.removeListener(callbackHandler); // shut down callback server callbackConnector.stop(); callbackConnector.destroy(); callbackConnector = null; List callbacks = callbackHandler.getCallbacks(); assertEquals(callbacks.size(), 1); // assertEquals(callbacks.get(0), "abc"); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } protected String getTransport() { return transport; } 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; } protected Object solicitCallback(String param) throws Throwable { Object ret = client.invoke(new NameBasedInvocation("test", new Object[]{param}, new String[]{String.class.getName()}), null); return ret; } public void setUp() throws Exception { init(); } public void tearDown() throws Exception { if(client != null) { client.disconnect(); client = null; } } protected ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; SSLSocketBuilder server = new SSLSocketBuilder(); server.setUseSSLServerSocketFactory(false); server.setSecureSocketProtocol("SSL"); server.setTrustStoreAlgorithm("SunX509"); server.setTrustStoreType("JKS"); String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); server.setTrustStoreURL(trustStoreFilePath); server.setTrustStorePassword("unit-tests-client"); // server.setUseClientMode(true); server.setServerSocketUseClientMode(true); server.setSocketUseClientMode(false); /* * This is optional since if not set, will use * the key store password (and are the same in this case) */ //server.setKeyPassword("unit-tests-server"); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } public static class SampleInvocationHandler implements ServerInvocationHandler { public SampleInvocationHandler() { } public Object invoke(InvocationRequest invocation) throws Throwable { return new Integer(0); } public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("entering addListener()"); try { Callback callback = new Callback(new Integer(1)); callbackHandler.handleCallback(callback); System.out.println("sent first callback"); callback = new Callback(new Integer(2)); callbackHandler.handleCallback(callback); System.out.println("sent second callback"); } catch(Exception e) { e.printStackTrace(); } } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } } public static class CallbackHandler implements InvokerCallbackHandler { private ArrayList callbacks = new ArrayList(); public CallbackHandler() { } public ArrayList getCallbacks() { return callbacks; } /** * Will take the callback and print out its values. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { log.info("Received push callback."); log.info("Received callback value of: " + callback.getCallbackObject()); log.info("Received callback server invoker of: " + callback.getServerLocator()); callbacks.add(callback); } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/socketf0000755000175000017500000000000011632407040033534 5ustar twernertwerner././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/socketf0000644000175000017500000000271011413660476033551 0ustar twernertwerner /* * 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.transport.socket.ssl.socketfactory; import org.jboss.test.remoting.socketfactory.SSLSocketFactoryClassNameTestRoot; /** * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Jul 18, 2008 *

*/ public class SSLSocketFactoryClassNameTestCase extends SSLSocketFactoryClassNameTestRoot { protected String getTransport() { return "sslsocket"; } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/socketfactory/SSLSocketCreationListenerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/socketf0000644000175000017500000000262710553067761033562 0ustar twernertwerner/* * 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.transport.socket.ssl.socketfactory; import org.jboss.test.remoting.socketfactory.SSLCreationListenerTestRoot; /** * @author Ron Sigal * @version $Revision: 1846 $ *

* Copyright Jan 11, 2007 *

*/ public class SSLSocketCreationListenerTestCase extends SSLCreationListenerTestRoot { protected String getTransport() { return "sslsocket"; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/shutdown/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/shutdow0000755000175000017500000000000011632407040033573 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/shutdown/SSLSocketShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/shutdow0000644000175000017500000000420710716737553033621 0ustar twernertwerner/* * 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.transport.socket.ssl.shutdown; import org.jboss.test.remoting.transport.socket.shutdown.SocketShutdownTestCase; /** * @author Ron Sigal * @version $Revision: 2951 $ *

* Copyright Jan 20, 2007 *

*/ public class SSLSocketShutdownTestCase extends SocketShutdownTestCase { protected String getTransport() { return "sslsocket"; } protected String getJVMArguments() { String args = ""; String keyStoreFilePath = getClass().getResource("../.keystore").getFile(); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); String log4jFilePath = getClass().getResource("../../../../shutdown/log4j.xml").getFile(); System.out.println("log4jFilePath: " + log4jFilePath); args += "-Djavax.net.ssl.keyStore=" + keyStoreFilePath + " "; args += "-Djavax.net.ssl.keyStorePassword=unit-tests-server "; args += "-Djavax.net.ssl.trustStore=" + trustStoreFilePath + " "; args += "-Djavax.net.ssl.trustStorePassword=unit-tests-client "; args += "-Dlog4j.configuration=file:" + log4jFilePath; return args; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/clientaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/clienta0000755000175000017500000000000011632407040033515 5ustar twernertwerner././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/clientaddress/SSLSocketClientAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/clienta0000644000175000017500000000247310721246022033524 0ustar twernertwernerpackage org.jboss.test.remoting.transport.socket.ssl.clientaddress; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class SSLSocketClientAddressTestCase extends ClientAddressTestParent { protected String getTransport() { return "sslsocket"; } protected void addExtraServerConfig(Map config) { 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"); } protected void addExtraClientConfig(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"); } protected void addExtraCallbackConfig(Map config) { addExtraClientConfig(config); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/test/0000755000175000017500000000000011632407040033134 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/test/SSLSimpleServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/test/SS0000644000175000017500000001037210355142433033412 0ustar twernertwerner/* * 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.transport.socket.ssl.test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.Date; import javax.net.ServerSocketFactory; import org.jboss.remoting.security.SSLSocketBuilder; /** * @author Tom Elrod */ public class SSLSimpleServer { private ServerSocketFactory serverSocketFactory; private boolean keepRunning = true; public void startServer() throws IOException, NoSuchAlgorithmException, KeyManagementException, CertificateException, UnrecoverableKeyException, KeyStoreException { String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); if(serverSocketFactory == null) { SSLSocketBuilder server = new SSLSocketBuilder(); //server.setUseSSLServerSocketFactory(false); // server.setKeyStoreURL(".keystore"); // server.setKeyStorePassword("unit-tests-server"); // /* // * This is optional since if not set, will use // * the key store password (and are the same in this case) // */ // //server.setKeyPassword("unit-tests-server"); // // server.setSecureSocketProtocol("SSL"); serverSocketFactory = server.createSSLServerSocketFactory(); } InetAddress addr = InetAddress.getLocalHost(); final ServerSocket ss = serverSocketFactory.createServerSocket(9097, 200, addr); while(keepRunning) { final Socket sock = ss.accept(); new Thread() { public void run() { try { BufferedReader br = new BufferedReader(new InputStreamReader(sock.getInputStream())); PrintWriter pw = new PrintWriter(sock.getOutputStream()); String data = br.readLine(); pw.println("The time is: " + new Date()); pw.close(); sock.close(); } catch(IOException e) { e.printStackTrace(); } } }.start(); } } public void stopServer() { keepRunning = false; } /** * Allows for the setting of the server socket factory to use. This will bypass the creating of any * custom server socket factory in favor of the one passed. * * @param ssf */ public void setServerSocketFactory(ServerSocketFactory ssf) { this.serverSocketFactory = ssf; } public static void main(String[] args) throws Exception { try { SSLSimpleServer server = new SSLSimpleServer(); server.startServer(); } catch(Throwable thr) { thr.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/test/SSLSimpleClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ssl/test/SS0000644000175000017500000000403110355142433033405 0ustar twernertwerner/* * 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.transport.socket.ssl.test; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.Socket; import javax.net.SocketFactory; import org.jboss.remoting.security.SSLSocketBuilder; /** * @author Tom Elrod */ public class SSLSimpleClient { public static void main(String[] args) throws Exception { SSLSocketBuilder server = new SSLSocketBuilder(); // server.setUseSSLSocketFactory(false); // server.setTrustStoreURL(".truststore"); // server.setSecureSocketProtocol("SSL"); SocketFactory sf = server.createSSLSocketFactory(); Socket s = sf.createSocket(args[0], Integer.parseInt(args[1])); BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream())); PrintWriter pw = new PrintWriter(s.getOutputStream()); System.out.println("What time is it?"); pw.println("What time is it?"); pw.flush(); System.out.println(br.readLine()); s.close(); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ErrorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/ErrorTestCa0000644000175000017500000002572011413704411033501 0ustar twernertwerner/* * 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.transport.socket; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; import java.util.LinkedList; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.ServerSocketWrapper; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketClientInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; /** * Unit tests for JBREM-1183. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 16, 2010 */ public class ErrorTestCase extends TestCase { private static Logger log = Logger.getLogger(ErrorTestCase.class); private static boolean firstTime = true; private static int whenToFail; 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); } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.registerInvokerFactories(getTransport(), TestClientFactory.class, TestServerFactory.class); return null; } }); TestServerThread.threadCounter = 0; } public void tearDown() { } public void testErrorFirstTime() throws Throwable { log.info("entering " + getName()); // Start server. whenToFail = 0; setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("timeout", "2000"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test invocations. assertEquals("abc", client.invoke("abc")); log.info("first invocation succeeded"); assertEquals("lmn", client.invoke("lmn")); log.info("second invocation succeeded"); assertEquals("xyz", client.invoke("xyz")); log.info("third invocation succeeded"); assertEquals(1, TestServerThread.threadCounter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testErrorSecondTime() throws Throwable { log.info("entering " + getName()); // Start server. whenToFail = 1; setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("timeout", "2000"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test invocations. assertEquals("abc", client.invoke("abc")); log.info("first invocation succeeded"); assertEquals("lmn", client.invoke("lmn")); log.info("second invocation succeeded"); assertEquals("xyz", client.invoke("xyz")); log.info("third invocation succeeded"); assertEquals(1, TestServerThread.threadCounter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testErrorThirdTime() throws Throwable { log.info("entering " + getName()); // Start server. whenToFail = 2; setupServer(); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("timeout", "2000"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test invocations. assertEquals("abc", client.invoke("abc")); log.info("first invocation succeeded"); assertEquals("lmn", client.invoke("lmn")); log.info("second invocation succeeded"); assertEquals("xyz", client.invoke("xyz")); log.info("third invocation succeeded"); assertEquals(1, TestServerThread.threadCounter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "test"; } 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 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 TestServerInvoker extends SocketServerInvoker { int counter; public TestServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public TestServerInvoker(InvokerLocator locator) { super(locator); } protected void processInvocation(Socket socket) throws Exception { clientpool = new LRUPool(2, maxPoolSize); clientpool.create(); threadpool = new LinkedList(); ServerThread worker = new TestServerThread(socket, this, clientpool, threadpool, 0, 0, ServerSocketWrapper.class.getName()); worker.start(); } } public static class TestServerThread extends ServerThread { static public int threadCounter; private int counter; public TestServerThread(Socket socket, SocketServerInvoker invoker, LRUPool clientpool, LinkedList threadpool, int timeout, int writeTimeout, String serverSocketClassName) throws Exception { super(socket, invoker, clientpool, threadpool, timeout, writeTimeout, serverSocketClassName); threadCounter++; } protected void processInvocation(SocketWrapper socketWrapper, InputStream inputStream, OutputStream outputStream) throws Exception { super.processInvocation(socketWrapper, inputStream, outputStream); if (counter++ == whenToFail) throw new Error("TestServerThread"); } } public static class TestClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { log.info("TestClientFaotory.createClientInvoker() called"); return new SocketClientInvoker(locator, config); } public boolean supportsSSL() { return false; } } public static class TestServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException { log.info("TestServerFactory.createServerInvoker() called"); return new TestServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/SocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/SocketInvok0000644000175000017500000000344310460062274033546 0ustar twernertwerner/* * 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.transport.socket; import org.jboss.test.remoting.transport.InvokerClientTest; /** * @author Tom Elrod */ public class SocketInvokerClientTest extends InvokerClientTest { public String getTransport() { return "socket"; } public static void main(String[] args) { SocketInvokerClientTest client = new SocketInvokerClientTest(); try { client.setUp(); client.testArrayReturn(); client.testLocalPushCallback(); client.testPullCallback(); client.testPullCallback(); client.testRemotePushCallback(); client.testThrownException(); client.tearDown(); } catch (Throwable throwable) { throwable.printStackTrace(); } } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/0000755000175000017500000000000011632407037033544 5ustar twernertwerner././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/SocketClientPoolWithSemaphoreTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/0000644000175000017500000003724611413660476033567 0ustar twernertwerner/* * 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.transport.socket.socketpool; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-845. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Nov 30, 2007 *

*/ public class SocketClientPoolWithSemaphoreTestCase extends TestCase { protected static String WAIT = "wait"; protected static String DURATION = "duration"; private static Logger log = Logger.getLogger(SocketClientPoolWithSemaphoreTestCase.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 testStressClientPoolTen() 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(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "10"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); for (int i = 0; i < 5000; i++) { assertEquals(Integer.toString(i), (String) client.invoke(Integer.toString(i))); } assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testStressClientPoolOne() 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(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "1"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(1, clientInvoker.getNumberOfAvailableConnections()); for (int i = 0; i < 5000; i++) { assertEquals(Integer.toString(i), (String) client.invoke(Integer.toString(i))); } assertEquals(1, clientInvoker.getNumberOfAvailableConnections()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testMaxPoolSize() 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(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "10"); addExtraClientConfig(clientConfig); final Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); final HashMap metadata = new HashMap(); metadata.put(DURATION, "20000"); for (int i = 0; i < 20; i++) { new Thread() { public void run() { try { client.invoke(WAIT, metadata); } catch (Throwable e) { log.error("Error", e); } } }.start(); } Thread.sleep(10000); assertEquals(10, invocationHandler.counter); assertEquals(0, clientInvoker.getNumberOfAvailableConnections()); Thread.sleep(20000); assertEquals(20, invocationHandler.counter); assertEquals(0, clientInvoker.getNumberOfAvailableConnections()); Thread.sleep(20000); assertEquals(20, invocationHandler.counter); assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testRestartServer() 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(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "10"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); for (int i = 0; i < 50; i++) { assertEquals(Integer.toString(i), (String) client.invoke(Integer.toString(i))); } assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); disableServer(connector); shutdownServer(); setupServer(port); assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); for (int i = 0; i < 50; i++) { assertEquals(Integer.toString(i), (String) client.invoke(Integer.toString(i))); } assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testSemaphoreReleaseAfterGetConnection() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "/?" + MicroSocketClientInvoker.CLIENT_SOCKET_CLASS_FLAG + "=bogus"; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); log.info("clientLocator: " + clientLocator); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "10"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); try { log.info(client.invoke("abc")); fail("expected exception"); } catch (Exception e) { log.info("got expected exception"); } assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testSemaphoreReleaseAfterSocketException() throws Throwable { String exceptionClass = SocketWrapperWithSocketException.class.getName(); doSemaphoreReleaseAfterSocketException(exceptionClass); } public void testSemaphoreReleaseAfterIOException() throws Throwable { String exceptionClass = SocketWrapperWithIOException.class.getName(); doSemaphoreReleaseAfterSocketException(exceptionClass); } protected void doSemaphoreReleaseAfterSocketException(String exceptionClass) throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "/?" + MicroSocketClientInvoker.CLIENT_SOCKET_CLASS_FLAG + "=" + exceptionClass; InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI); log.info("clientLocator: " + clientLocator); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "10"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); try { log.info(client.invoke("abc")); fail("expected exception"); } catch (Exception e) { log.info("got expected exception: " + e, e); } assertEquals(10, clientInvoker.getNumberOfAvailableConnections()); 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 { setupServer(-1); } protected void setupServer(int localPort) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); if (localPort == -1) port = PortUtil.findFreePort(host); else port = localPort; 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); for (int i = 0; i < 5; i++) { try { connector.start(); } catch (Exception e) { log.error("unable to start Connector"); Thread.sleep(60000); } } } protected void disableServer(Connector connector) throws Exception { log.info("disabling " + connector); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("serverSockets"); field.setAccessible(true); List serverSockets = (List) field.get(serverInvoker); ServerSocket ss = (ServerSocket) serverSockets.get(0); ss.close(); field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); Iterator it = clientpool.getContents().iterator(); field = ServerThread.class.getDeclaredField("socket"); field.setAccessible(true); while (it.hasNext()) { Socket socket = (Socket) field.get(it.next()); socket.close(); } field = SocketServerInvoker.class.getDeclaredField("threadpool"); field.setAccessible(true); List threadpool = new ArrayList((List) field.get(serverInvoker)); it = threadpool.iterator(); field = ServerThread.class.getDeclaredField("socket"); field.setAccessible(true); while (it.hasNext()) { Socket socket = (Socket) field.get(it.next()); socket.close(); } log.info("disabled " + connector); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { public int counter; private Object lock = new Object(); public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { synchronized (lock) { counter++; } String command = (String) invocation.getParameter(); if (WAIT.equals(command)) { Map metadata = invocation.getRequestPayload(); int duration = Integer.parseInt((String) metadata.get(DURATION)); Thread.sleep(duration); } return command; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/SocketPoolTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/0000644000175000017500000001154210732650543033553 0ustar twernertwerner/* * 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.transport.socket.socketpool; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.socket.SocketClientInvoker; /** * See SocketPoolTestCase for description. * * @author Ron Sigal * @author Tom Elrod * * @version $Revision: 3204 $ *

* Copyright Nov 2, 2006 *

*/ public class SocketPoolTestClient extends TestCase { private static Logger log = Logger.getLogger(SocketPoolTestClient.class); // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 6413; public void testSocketPool() throws Throwable { Client client = null; try { log.warn("EXCEPTIONS ARE EXPECTED"); String locatorURI = getTransport() + "://" + host + ":" + getPort() + "/?timeout=1000"; log.info("Calling remoting server with locator uri of: " + locatorURI); // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); client = new Client(locator); client.connect(); SocketClientInvoker invoker = (SocketClientInvoker) client.getInvoker(); // No sockets are in use. // assertEquals(0, invoker.usedPooled); // log.info("usedPool: " + invoker.usedPooled); assertEquals(0, invoker.getNumberOfUsedConnections()); // Make SocketPoolTestServer.NUMBER_OF_CALLS invocations. for (int i = 0; i < SocketPoolTestServer.NUMBER_OF_CALLS; i++) { new Invoker(client, i).start(); } Thread.sleep(500); // SocketPoolTestServer.NUMBER_OF_CALLS sockets are in use. // log.info("usedPool: " + invoker.usedPooled); // assertEquals(SocketPoolTestServer.NUMBER_OF_CALLS, invoker.usedPooled); log.info("usedPool: " + invoker.getNumberOfUsedConnections()); assertEquals(SocketPoolTestServer.NUMBER_OF_CALLS, invoker.getNumberOfUsedConnections()); Thread.sleep(5000); // All invocations have timed out. All sockets should be closed and discarded. // log.info("usedPool: " + invoker.usedPooled); // assertEquals(0, invoker.usedPooled); log.info("usedPool: " + invoker.getNumberOfUsedConnections()); assertEquals(0, invoker.getNumberOfUsedConnections()); } finally { if(client != null) { client.disconnect(); } } } /** * 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) { host = args[0]; port = Integer.parseInt(args[1]); } SocketPoolTestClient client = new SocketPoolTestClient(); try { client.testSocketPool(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return transport; } protected int getPort() { return port; } class Invoker extends Thread { private Client client; private int id; Invoker(Client client, int id) { this.client = client; this.id = id; } public void run() { try { client.invoke("payload"); log.info("invoke succeeded: " + id); } catch (Throwable e) { log.info("invoke failed: " + id, e); } } } }././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/SocketWrapperWithSocketException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/0000644000175000017500000000400311413660476033550 0ustar twernertwerner/* * 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.transport.socket.socketpool; import java.io.IOException; import java.io.InputStream; import java.net.Socket; import java.net.SocketException; import java.util.Map; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.transport.socket.ClientSocketWrapper; /** * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Nov 30, 2007 *

*/ public class SocketWrapperWithSocketException extends ClientSocketWrapper { public SocketWrapperWithSocketException(Socket socket, Map metadata, Integer timeout) throws Exception { super(socket, metadata, timeout); } protected InputStream createInputStream(String serializationType, Socket socket, UnMarshaller unmarshaller) throws IOException { return new ExplodingInputStream(); } public static class ExplodingInputStream extends InputStream { public int read() throws IOException { throw new SocketException("bang"); } } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/ConnectionPoolClearanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/0000644000175000017500000001500110665734771033560 0ustar twernertwerner/* * 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.transport.socket.socketpool; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.LinkedList; 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; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; /** * Unit test for JBREM- * * @author Ron Sigal * @version $Revision: 2739 $ *

* Copyright Jul 11, 2007 *

*/ public class ConnectionPoolClearanceTestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionPoolClearanceTestCase.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() { } /** * Tests blocking and nonblocking direct calls to Client.getCallbacks(). */ public void testMultipleClientConnectionPools() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int 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 clients. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI + "/?timeout=1000"); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client1 = new Client(clientLocator1, clientConfig); client1.connect(); log.info("client 1 is connected"); InvokerLocator clientLocator2 = new InvokerLocator(locatorURI + "/?timeout=2000"); Client client2 = new Client(clientLocator2, clientConfig); client2.connect(); log.info("client 2 is connected"); // Test connections. assertEquals("abc", client1.invoke("abc")); assertEquals("xyz", client2.invoke("xyz")); log.info("connections are good"); // Verify there are two connection pools. Field field = MicroSocketClientInvoker.class.getDeclaredField("connectionPools"); field.setAccessible(true); Map connectionPools = (Map) field.get(null); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client1.getInvoker(); assertEquals(2, connectionPools.size()); // Verify client invoker 2's pool has one connection. field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(client2.getInvoker()); assertEquals(1, pool.size()); // Verify both connection pools are eliminated if one client disconnects. client1.disconnect(); assertEquals(0, connectionPools.size()); // Verify client invoker 2's pool is now empty. assertEquals(0, pool.size()); // Verify client invoker 2's pool gets a new connection with an invocation. client2.invoke("def"); assertEquals(1, pool.size()); // Verify client invoker 2's pool is cleared when client 2 disconnects. client2.disconnect(); assertEquals(0, pool.size()); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} 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) {} } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/SocketWrapperWithIOException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/0000644000175000017500000000372611413660476033563 0ustar twernertwerner/* * 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.transport.socket.socketpool; import java.io.IOException; import java.io.InputStream; import java.net.Socket; import java.util.Map; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.transport.socket.ClientSocketWrapper; /** * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Nov 30, 2007 *

*/ public class SocketWrapperWithIOException extends ClientSocketWrapper { public SocketWrapperWithIOException(Socket socket, Map metadata, Integer timeout) throws Exception { super(socket, metadata, timeout); } protected InputStream createInputStream(String serializationType, Socket socket, UnMarshaller unmarshaller) throws IOException { return new ExplodingInputStream(); } public static class ExplodingInputStream extends InputStream { public int read() throws IOException { throw new IOException("bang"); } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/SocketPoolTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/0000644000175000017500000001346110713560607033555 0ustar twernertwerner/* * 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.transport.socket.socketpool; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; 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; /** * See SocketPoolTestCase for description. * * @author Ron Sigal * @author Tom Elrod * * @version $Revision: 2911 $ *

* Copyright Nov 2, 2006 *

*/ public class SocketPoolTestServer extends ServerTestCase { public final static int NUMBER_OF_CALLS = 5; private static Logger log = Logger.getLogger(SocketPoolTestServer.class); private static Object lock = new Object(); private static Object stopLock = new Object(); private static int callCounter; private static boolean done; // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 6413; private Connector connector = null; public void setupServer(String locatorURI) throws Exception { log.warn("EXCEPTIONS ARE EXPECTED"); log.info("Starting remoting server with locator uri of: " + locatorURI); InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(locator); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // This thread will stop the Connector when NUMBER_OF_CALLS // invocations have been received. new Thread() { public void run() { synchronized (lock) { while (!done) { try { lock.wait(); } catch (InterruptedException e) { log.error(e); e.printStackTrace(); } } if(connector != null) { connector.stop(); connector.destroy(); log.info("Connector stopped"); synchronized(stopLock) { stopLock.notify(); } } } } }.start(); } public void tearDown() { } public void setUp() throws Exception { String locatorURI = getTransport() + "://" + host + ":" + getPort(); setupServer(locatorURI); } /** * 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) { host = args[0]; port = Integer.parseInt(args[1]); } SocketPoolTestServer server = new SocketPoolTestServer(); try { server.setUp(); synchronized (stopLock) { while (!done) { try { stopLock.wait(); break; } catch (InterruptedException ignored) {} } } } catch(Exception e) { e.printStackTrace(); } } protected String getTransport() { return transport; } protected int getPort() { return port; } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { public Object invoke(InvocationRequest invocation) throws Throwable { synchronized (lock) { ++callCounter; log.info("callCounter: " + callCounter); } // Waiting for 4 seconds will cause the client to timeout. Thread.sleep(4000); synchronized (lock) { if (callCounter == NUMBER_OF_CALLS) { done = true; lock.notify(); } } return "response"; } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/SocketPoolTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/socketpool/0000644000175000017500000000527310561772611033560 0ustar twernertwerner/* * 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.transport.socket.socketpool; import org.apache.log4j.Level; import org.jboss.logging.XLevel; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * This unit test is introduced in response to JIRA issue JBREM-625. * It verifies that when a socket is discarded, the count of sockets * in use is decremented. * * @author Ron Sigal * @author Tom Elrod * * @version $Revision: 2125 $ *

* Copyright Nov 2, 2006 *

*/ public class SocketPoolTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketPoolTestClient.class.getName(), 1, SocketPoolTestServer.class.getName()); } protected Level getTestLogLevel() { return XLevel.TRACE; } /** * 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; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configuration/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configurati0000755000175000017500000000000011632407040033607 5ustar twernertwerner././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configurati0000644000175000017500000001557411413660476033640 0ustar twernertwerner/* * 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.transport.socket.configuration; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; import java.util.HashMap; import java.util.LinkedList; 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; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; /** * Unit test for JBREM-703. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 28, 2008 *

*/ public class SocketSocketConfigurationTestCase extends TestCase { private static Logger log = Logger.getLogger(SocketSocketConfigurationTestCase.class); protected 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 testConfigureByConfigMap() 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"); setupClient(clientConfig); 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"); assertTrue(client.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker(); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); LinkedList pool = (LinkedList) field.get(invoker); assertTrue(pool.size() > 0); SocketWrapper socketWrapper = (SocketWrapper) pool.get(0); Socket socket = socketWrapper.getSocket(); doSocketTest(socket); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected void setupClient(Map config) { config.put("keepAlive", "true"); config.put("oOBInline", "true"); config.put("receiveBufferSize", "2345"); config.put("sendBufferSize", "3456"); config.put("soLinger", "true"); config.put("soLingerDuration", "4567"); config.put("trafficClass", "0"); } protected void doSocketTest(Socket s) throws SocketException { assertTrue(s.getKeepAlive()); assertTrue(s.getOOBInline()); suggestEquals(2345, s.getReceiveBufferSize(), "receiveBufferSize"); suggestEquals(3456, s.getSendBufferSize(), "sendBufferSize"); assertEquals(4567, s.getSoLinger()); suggestEquals(0, s.getTrafficClass(), "trafficClass"); } protected void suggestEquals(int i1, int i2, String s) { if (i1 != i2) { log.warn(s + " has not been set: expected " + i1 + ", got " + i2); log.warn("note that setting \"" + s + "\" is just a suggestion to the underlying network code"); } } 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) {} } }././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configurati0000644000175000017500000002161411413660476033630 0ustar twernertwerner/* * 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.transport.socket.configuration; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; 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.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.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-703. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 28, 2008 *

*/ public class SocketServerSocketConfigurationTestCase extends TestCase { private static Logger log = Logger.getLogger(SocketServerSocketConfigurationTestCase.class); protected 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 testConfigureByConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // 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"); SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool pool = (LRUPool) field.get(invoker); Set keys = pool.getContents(); assertEquals(1, keys.size()); ServerThread t = (ServerThread) keys.iterator().next(); field = ServerThread.class.getDeclaredField("socket"); field.setAccessible(true); Socket socket = (Socket) field.get(t); doSocketTest(socket); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testConfigureBySetter() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false); // 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"); SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool pool = (LRUPool) field.get(invoker); Set keys = pool.getContents(); assertEquals(1, keys.size()); ServerThread t = (ServerThread) keys.iterator().next(); field = ServerThread.class.getDeclaredField("socket"); field.setAccessible(true); Socket socket = (Socket) field.get(t); doSocketTest(socket); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected void doSocketTest(Socket s) throws SocketException { assertTrue(s.getKeepAlive()); assertTrue(s.getOOBInline()); suggestEquals(2345, s.getReceiveBufferSize(), "receiveBufferSize"); suggestEquals(3456, s.getSendBufferSize(), "sendBufferSize"); assertEquals(4567, s.getSoLinger()); suggestEquals(0, s.getTrafficClass(), "trafficClass"); } protected void suggestEquals(int i1, int i2, String s) { if (i1 != i2) { log.warn(s + " has not been set: expected " + i1 + ", got " + i2); log.warn("note that setting \"" + s + "\" is just a suggestion to the underlying network code"); } } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean useConfigMap) 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"); if (useConfigMap) { addServerSocketConfig(config); } addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); if (!useConfigMap) { SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); configureServerInvoker(invoker); } invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void addServerSocketConfig(Map config) { config.put("keepAlive", "true"); config.put("oOBInline", "true"); config.put("receiveBufferSize", "2345"); config.put("sendBufferSize", "3456"); config.put("soLinger", "true"); config.put("soLingerDuration", "4567"); config.put("trafficClass", "0"); } protected void configureServerInvoker(SocketServerInvoker invoker) { invoker.setReceiveBufferSize(12345); invoker.setKeepAlive(true); invoker.setOOBInline(true); invoker.setReceiveBufferSize(2345); invoker.setSendBufferSize(3456); invoker.setSoLinger(true); invoker.setSoLingerDuration(4567); invoker.setTrafficClass(0); } 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) {} } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketRetryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configurati0000644000175000017500000000450211017321033033604 0ustar twernertwerner/* * 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.transport.socket.configuration; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.socket.SocketClientInvoker; /** * @author Tom Elrod */ public class SocketRetryConfigTestCase extends TestCase { private int callRetries = 6; private int timeout = 1000; public void testConfig() throws Throwable { InvokerLocator locator = new InvokerLocator("socket://localhost:8888" + "/?" + SocketClientInvoker.SO_TIMEOUT_FLAG + "=" + timeout + "&" + "&NumberOfCallRetries=" + callRetries); Connector connector = new Connector("socket://localhost:8888"); Client client = new Client(locator); try { connector.start(); client.connect(); SocketClientInvoker invoker = (SocketClientInvoker)client.getInvoker(); assertEquals(callRetries, invoker.getNumberOfCallRetries()); assertEquals(timeout, invoker.getTimeout()); assertEquals(Boolean.FALSE.booleanValue(), invoker.checkingConnection()); } finally { client.disconnect(); connector.stop(); connector.destroy(); } } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configuration/FactoryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/socket/configurati0000644000175000017500000000261310446027031033613 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.socket.configuration; import org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent; /** * * @author Ron Sigal *

* Copyright (c) May 20, 2006 *

*/ public class FactoryConfigTestCase extends FactoryConfigTestCaseParent { protected String getTransport() { return "socket"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/connector/0000755000175000017500000000000011632407040032056 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/connector/UnregisterServerInvokerObjectNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/connector/Unregist0000644000175000017500000001213210774616035033614 0ustar twernertwerner/* * 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.transport.connector; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; 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.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * This unit test verifies: * * 1. When a Connector creates a ServerInvoker and it has a reference to an MBeanServer, it will * (a) register the ServerInvoker with the MBeanServer, and * (b) it will pass the MBeanServer reference to the ServerInvoker * * 2. When a Connector stops and it destroys a ServerInvoker, it will unregister the ServerInvoker * with the MBeanServer. * * See JIRA issue JBREM-747 * * * @author Ron Sigal * @version $Revision: 3876 $ *

* Copyright May 18, 2007 *

*/ public class UnregisterServerInvokerObjectNameTestCase extends TestCase { private static Logger log = Logger.getLogger(UnregisterServerInvokerObjectNameTestCase.class); private static boolean firstTime = true; 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 testMBeanServerRegistration() throws Throwable { log.info("entering " + getName()); MBeanServer server = null; try { server = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } 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 config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put("bluemonkey", "diamond"); Connector connector = new Connector(serverLocator, config); connector.preRegister(server, null); connector.create(); connector.start(); // Verify that the ServerInvoker has a reference to the MBeanServer ServerInvoker invoker = connector.getServerInvoker(); assertNotNull(invoker); assertEquals(server, invoker.getMBeanServer()); // Verify that the ServerInvoker is registered with the MBeanServer ObjectName objectName = new ObjectName(invoker.getMBeanObjectName()); assertTrue(server.isRegistered(objectName)); assertTrue(server.isInstanceOf(objectName, "org.jboss.remoting.ServerInvoker")); Object o = server.getAttribute(objectName, "Configuration");; assertTrue(o instanceof Map); assertEquals("diamond", ((Map) o).get("bluemonkey")); // Verify that the ServerInvoker is unregistered when the Connector is shut down. connector.stop(); assertFalse(server.isRegistered(objectName)); } protected String getTransport() { return "socket"; } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/connector/ObjectNameWithZeroesAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/connector/ObjectNa0000644000175000017500000001374611413660476033514 0ustar twernertwerner/* * 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.transport.connector; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectInstance; import javax.management.ObjectName; 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.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; /** * Unit test for JBREM-910. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 25, 2008 *

*/ public class ObjectNameWithZeroesAddressTestCase extends TestCase { private static Logger log = Logger.getLogger(ObjectNameWithZeroesAddressTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected MBeanServer mbeanServer; 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 testMethod() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); log.info("Updated locator: " + connector.getInvokerLocator()); ServerInvoker invoker = connector.getServerInvoker(); String name = invoker.getMBeanObjectName(); ObjectName objectName = new ObjectName(name); log.info("objectName:" + objectName); printMBeans(); assertTrue(mbeanServer.isRegistered(objectName)); shutdownServer(); printMBeans(); assertFalse(mbeanServer.isRegistered(objectName)); log.info(getName() + " PASSES"); } protected void printMBeans() { log.info("MBean count: " + mbeanServer.getMBeanCount()); Set mbeans = mbeanServer.queryMBeans(null, null); Iterator it = mbeans.iterator(); int i = 0; while (it.hasNext()) { ObjectInstance mbean = (ObjectInstance) it.next(); log.info("MBean " + i++ + ": " + mbean.getObjectName()); } } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { locatorURI = getTransport() + "://0.0.0.0:5555"; 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); mbeanServer = null; try { mbeanServer = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } connector = new Connector(serverLocator, config); connector.preRegister(mbeanServer, new ObjectName("remoting:service=connector")); 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/transport/http/0000755000175000017500000000000011632407035031047 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/compression/0000755000175000017500000000000011632407035033410 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/compression/CompressedHTTPInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/compression/C0000644000175000017500000000320310570376015033516 0ustar twernertwerner/* * 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.transport.http.compression; import org.jboss.test.remoting.transport.http.HTTPInvokerTestClient; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import java.util.Properties; /** * @author Tom Elrod */ public class CompressedHTTPInvokerTestClient extends HTTPInvokerTestClient { // public void setUp() throws Exception // { // System.setProperty(PerformanceTestCase.REMOTING_METADATA, "serialization=jboss"); // } protected void addHeaders(Properties headerProps) { headerProps.put("Accept-Encoding", "x-gzip, x-deflate, gzip, deflate"); } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/compression/CompressedHTTPInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/compression/C0000644000175000017500000000141310535452155033520 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.compression; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * 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 CompressedHTTPInvokerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(CompressedHTTPInvokerTestClient.class.getName(), 1, CompressedHTTPInvokerTestServer.class.getName()); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/compression/CompressedHTTPInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/compression/C0000644000175000017500000000633610570376015033530 0ustar twernertwerner/* * 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.transport.http.compression; import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; import org.apache.log4j.Level; import java.util.Map; import java.util.HashMap; /** * This test turns on compression for tomcat. When using compression=on for config, * tomcat will only compress responses with size > 1024 (and the request header having * Accept-Encoding). Therefore, only some of the responses in this test will be compressed * (actually only the fourth response from org.jboss.test.remoting.transport.web.WebInvokerTestClient * as it sends a ComplexObject which triggers the sending of WebInvocationHandler.LARGE_OBJECT_RESPONSE_VALUE). * * @author Tom Elrod */ public class CompressedHTTPInvokerTestServer extends HTTPInvokerTestServer { public void init(Map metatdata) throws Exception { if(metatdata == null) { metatdata = new HashMap(); } // adding config to force tomcat compression metatdata.put("compression", "on"); metatdata.put("compressableMimeType", "text/html,text/xml," + "text/plain,application/x-www-form-urlencoded,application/x-java-serialized-object," + "application/octet-stream,application/soap+xml"); // metatdata.put("serialization", "jboss"); super.init(metatdata); } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); CompressedHTTPInvokerTestServer server = new CompressedHTTPInvokerTestServer(); try { server.setUp(); Thread.currentThread().sleep(300000); } catch(Exception e) { e.printStackTrace(); } finally { try { server.tearDown(); } catch(Exception e) { e.printStackTrace(); } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/0000755000175000017500000000000011632407034032326 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/MethodInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/Method0000644000175000017500000001171510427764574033516 0ustar twernertwerner/* * 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.transport.http.method; 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.http.HTTPMetadataConstants; import javax.management.MBeanServer; import java.util.Map; /** * @author Tom Elrod */ public class MethodInvocationHandler implements ServerInvocationHandler { public static final String PUBLIC = "Public"; public static final String ALLOW = "Allow"; public static final String PUBLIC_VALUE = "OPTIONS, POST, GET, HEAD, PUT"; public static final String ALLOW_VALUE = "OPTIONS, POST, GET, HEAD, PUT"; public static final Integer PUT_RESPONSE_CODE = new Integer(201); public static final Integer GET_RESPONSE_CODE = new Integer(202); public static final Integer HEAD_RESPONSE_CODE = new Integer(204); public static final String RESPONSE_HTML = "foo"; /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { Map responseHeaders = invocation.getReturnPayload(); Map headers = invocation.getRequestPayload(); String methodType = (String) headers.get(HTTPMetadataConstants.METHODTYPE); if(methodType != null) { if(methodType.equals("OPTIONS")) { responseHeaders.put(PUBLIC, PUBLIC_VALUE); responseHeaders.put(ALLOW, ALLOW_VALUE); } else if(methodType.equals("GET")) { responseHeaders.put(HTTPMetadataConstants.RESPONSE_CODE, GET_RESPONSE_CODE); return RESPONSE_HTML; } else if(methodType.equals("PUT")) { Object path = headers.get(HTTPMetadataConstants.PATH); if((!"/this/is/some/path".equals(path)) && (!"/this/is/some/path/".equals(path))) { throw new RuntimeException("Path within invocation request payload does not equal '/this/is/some/path', instead is " + path); } Object protocol = headers.get(HTTPMetadataConstants.HTTPVERSION); if(!"HTTP/1.1".equals(protocol)) { throw new RuntimeException("Protocol within invocation request payload does not equal 'HTTP/1.1', instead is " + protocol); } Object contentType = headers.get("content-type"); if(!"application/octet-stream".equals(contentType)) { throw new RuntimeException("Content type within invocation request payload does not equal 'application/octet-stream', instead is " + contentType); } Object putPayload = invocation.getParameter(); System.out.println("Received PUT object: " + putPayload); responseHeaders.put(HTTPMetadataConstants.RESPONSE_CODE, PUT_RESPONSE_CODE); } } return null; } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { //NOOP } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { //NOOP } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //NOOP } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //NOOP } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/HTTPInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/HTTPIn0000644000175000017500000002030310744745577033341 0ustar twernertwerner/* * 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.transport.http.method; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.http.HTTPInvokerConstants; import org.jboss.test.remoting.transport.web.ComplexObject; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author Tom Elrod */ public class HTTPInvokerTestClient extends TestCase implements HTTPInvokerConstants { public String getLocatorURI() { String bindAddr = System.getProperty("jrunit.bind_addr", host); String locatorURI = transport + "://" + bindAddr + ":" + port; String metadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { locatorURI = locatorURI + "/?" + metadata; } return locatorURI; } public String getLocatorURIWithPath() { String bindAddr = System.getProperty("jrunit.bind_addr", host); String locatorURI = transport + "://" + bindAddr + ":" + port + "/this/is/some/path"; String metadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { locatorURI = locatorURI + "/?" + metadata; } return locatorURI; } public void testOptionsInvocation() throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURI()); System.out.println("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); metadata.put("TYPE", "OPTIONS"); // test with null return expected Object response = remotingClient.invoke((Object) null, metadata); assertNull("OPTIONS http invocation should return null", response); String publicValue = (String) ((List) metadata.get(MethodInvocationHandler.PUBLIC)).get(0); assertEquals("Metadata value for " + MethodInvocationHandler.PUBLIC + " should be " + MethodInvocationHandler.PUBLIC_VALUE + " and was " + publicValue, MethodInvocationHandler.PUBLIC_VALUE, publicValue); String allowValue = (String) ((List) metadata.get(MethodInvocationHandler.ALLOW)).get(0); assertEquals("Metadata value for " + MethodInvocationHandler.ALLOW + " should be " + MethodInvocationHandler.ALLOW_VALUE + " and was " + allowValue, MethodInvocationHandler.ALLOW_VALUE, allowValue); } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } public void testPutInvocation() throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURIWithPath()); System.out.println("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); metadata.put("TYPE", "PUT"); // test with null return expected Object response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata); System.out.println("response: " + response); if(response instanceof Exception) { ((Exception)response).printStackTrace(); } Integer responseCode = (Integer) metadata.get(HTTPMetadataConstants.RESPONSE_CODE); assertEquals("Metadata value for " + HTTPMetadataConstants.RESPONSE_CODE + " should be " + MethodInvocationHandler.PUT_RESPONSE_CODE + " and was " + responseCode, MethodInvocationHandler.PUT_RESPONSE_CODE, responseCode); Object respHdr = metadata.get(MethodInvocationHandler.PUBLIC); assertNull(respHdr); } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } public void testGetInvocation() throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURIWithPath()); System.out.println("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); metadata.put("TYPE", "GET"); // test with null return expected Object response = remotingClient.invoke((Object)null, metadata); Integer responseCode = (Integer) metadata.get(HTTPMetadataConstants.RESPONSE_CODE); assertEquals("Metadata value for " + HTTPMetadataConstants.RESPONSE_CODE + " should be " + MethodInvocationHandler.GET_RESPONSE_CODE + " and was " + responseCode, MethodInvocationHandler.GET_RESPONSE_CODE, responseCode); assertEquals("Response value should be " + MethodInvocationHandler.RESPONSE_HTML + " and was " + response, MethodInvocationHandler.RESPONSE_HTML, response); Object respHdr = metadata.get(MethodInvocationHandler.PUBLIC); assertNull(respHdr); } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } public void testHeadInvocation() throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURIWithPath()); System.out.println("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); metadata.put("TYPE", "HEAD"); // test with null return expected Object response = remotingClient.invoke((Object)null, metadata); Integer responseCode = (Integer) metadata.get(HTTPMetadataConstants.RESPONSE_CODE); assertEquals("Metadata value for " + HTTPMetadataConstants.RESPONSE_CODE + " should be " + MethodInvocationHandler.HEAD_RESPONSE_CODE + " and was " + responseCode, MethodInvocationHandler.HEAD_RESPONSE_CODE, responseCode); } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } public static void main(String[] args) { HTTPInvokerTestClient client = new HTTPInvokerTestClient(); try { client.testOptionsInvocation(); client.testPutInvocation(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/HTTPInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/HTTPIn0000644000175000017500000000473710355142433033332 0ustar twernertwerner/* * 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.transport.http.method; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.transport.InvokerServerTest; /** * @author Tom Elrod */ public class HTTPInvokerTestServer extends InvokerServerTest { // 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 NULL_RETURN_PARAM = "return_null"; public static final String OBJECT_RETURN_PARAM = "return_object"; private Connector connector = null; public String getTransport() { return "http"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MethodInvocationHandler(); } protected String getSubsystem() { return "sample"; } public void setUp() throws Exception { serverPort = 8888; super.setUp(); } public static void main(String[] args) { HTTPInvokerTestServer server = new HTTPInvokerTestServer(); try { server.setUp(); Thread.currentThread().sleep(300000); } catch(Exception e) { e.printStackTrace(); } finally { try { server.tearDown(); } catch(Exception e) { e.printStackTrace(); } } } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/HTTPMethodInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/method/HTTPMe0000644000175000017500000000332010535452155033315 0ustar twernertwerner/* * 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.transport.http.method; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * 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 HTTPMethodInvokerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(HTTPInvokerTestClient.class.getName(), 1, HTTPInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/RawHTTPServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/RawHTTPServer0000644000175000017500000001537110355142433033420 0ustar twernertwerner/* * 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.transport.http; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; /** * @author Tom Elrod */ public class RawHTTPServer { private ServerSocket socket; private int port; private boolean started = false; private List clients = Collections.synchronizedList(new ArrayList()); private static int clientCount = 0; private static final int DEFAULT_PORT = 80; private Listener listener; public RawHTTPServer() { this(DEFAULT_PORT); } public RawHTTPServer(int port) { this.port = port; } public void start() { if(!started) { System.out.println("Starting raw http server."); try { this.socket = new ServerSocket(this.port); this.port = socket.getLocalPort(); this.started = true; this.listener = new Listener(); this.listener.start(); System.out.println("Server started."); } catch(IOException e) { System.out.println("Server start failed."); e.printStackTrace(); } } } public synchronized void stop() { if(started) { this.started = false; this.listener.interrupt(); try { this.listener.join(500); } catch(Throwable ig) { } Iterator iter = clients.iterator(); while(iter.hasNext()) { Client client = (Client) iter.next(); client.interrupt(); } clients.clear(); try { this.socket.close(); } catch(Throwable ig) { } this.socket = null; this.listener = null; } } private final class Client extends Thread { Socket socket; InputStream input; OutputStream output; String MIMEType = "text/html"; String content = "This is test results page from RawHTTPServer."; String header = "HTTP 1.0 200 OK\r\n" + "Server: RawHTTPServer\r\n" + "Content-length: " + this.content.getBytes().length + "\r\n" + "Content-type: " + MIMEType + "\r\n\rn\n"; Client(Socket socket) throws IOException { super("RawHTTPServer-Client [" + (++clientCount) + "]"); setDaemon(true); this.socket = socket; this.input = new BufferedInputStream(socket.getInputStream()); this.output = new BufferedOutputStream(socket.getOutputStream()); clients.add(this); } public void run() { while(started) { try { StringBuffer request = new StringBuffer(80); while(true) { int c = input.read(); if(c == '\r' || c == '\n' || c == -1) { break; } request.append((char) c); } if(request.toString().indexOf("HTTP/") != -1) { output.write(this.header.getBytes()); } output.write(this.content.getBytes()); output.flush(); } catch(IOException e) { e.printStackTrace(); } finally { if(socket != null) { try { socket.close(); } catch(IOException e) { e.printStackTrace(); //TODO: -TME Implement } } } /* try { int n = 0; byte[] buffer = new byte[1024]; while (n != -1 || input.available() > 0) { n = input.read(buffer); System.out.println(new String(buffer)); } } catch (IOException e) { e.printStackTrace(); } */ // try // { // output.write(new StringBuffer().append(200).toString().getBytes()); // output.flush(); // } // catch (IOException e) // { // e.printStackTrace(); //TODO: -TME Implement // } } clients.remove(this); } } private final class Listener extends Thread { public Listener() { super("RawHTTPServer-Listener"); //setDaemon(true); setDaemon(false); } public void run() { while(started) { try { // blocks until a new client arrives Socket client = socket.accept(); if(client != null) { // make this a thread pool task new Client(client).start(); } } catch(Exception ex) { if(started) { ex.printStackTrace(); } } } } } public static void main(String[] args) { int port = RawHTTPServer.DEFAULT_PORT; if(args != null && args.length > 0) { port = Integer.parseInt(args[0]); } RawHTTPServer server = new RawHTTPServer(port); server.start(); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/lines/0000755000175000017500000000000011632407034032160 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/lines/HttpLinePreservationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/lines/HttpLin0000644000175000017500000003316011413660476033500 0ustar twernertwerner/* * 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.transport.http.lines; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import java.util.Properties; 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.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.remoting.transport.web.WebUtil; /** * * Unit tests for JBREM-809. * * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright Feb 8, 2008 *

*/ public class HttpLinePreservationTestCase extends TestCase { private static Logger log = Logger.getLogger(HttpLinePreservationTestCase.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 testLinePreservationClientConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); Properties headerProps = new Properties(); headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN); HashMap metadata = new HashMap(); metadata.put("HEADER", headerProps); metadata.put(Client.RAW, "true"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789").append("\r\n"); String message = sb.toString(); assertEquals(message, client.invoke(message, metadata)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLinePreservationClientMetadata() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "true"); // 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"); Properties headerProps = new Properties(); headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN); HashMap metadata = new HashMap(); metadata.put("HEADER", headerProps); metadata.put(Client.RAW, "true"); metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "true"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789"); String message = sb.toString(); assertEquals(message, client.invoke(message, metadata)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoLinePreservationClientConfigServerConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "false"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "false"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); Properties headerProps = new Properties(); headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN); HashMap metadata = new HashMap(); metadata.put("HEADER", headerProps); metadata.put(Client.RAW, "true"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789").append("\r\n"); String sent = sb.toString(); sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789"); String received = sb.toString(); assertEquals(received, client.invoke(sent, metadata)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoLinePreservationClientMetadataServerConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "false"); // 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"); Properties headerProps = new Properties(); headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN); HashMap metadata = new HashMap(); metadata.put("HEADER", headerProps); metadata.put(Client.RAW, "true"); metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "false"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789").append("\r\n"); String sent = sb.toString(); sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789"); String received = sb.toString(); assertEquals(received, client.invoke(sent, metadata)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoLinePreservationClientConfigServerDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, null); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "false"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); Properties headerProps = new Properties(); headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN); HashMap metadata = new HashMap(); metadata.put("HEADER", headerProps); metadata.put(Client.RAW, "true"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789").append("\r\n"); String sent = sb.toString(); sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789"); String received = sb.toString(); assertEquals(received, client.invoke(sent, metadata)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoLinePreservationClientMetadataServerDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, null); // 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"); Properties headerProps = new Properties(); headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN); HashMap metadata = new HashMap(); metadata.put("HEADER", headerProps); metadata.put(Client.RAW, "true"); metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "false"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789").append("\r\n"); String sent = sb.toString(); sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789"); String received = sb.toString(); assertEquals(received, client.invoke(sent, metadata)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoLinePreservationClientServerDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, null); // 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"); Properties headerProps = new Properties(); headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN); HashMap metadata = new HashMap(); metadata.put("HEADER", headerProps); metadata.put(Client.RAW, "true"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789").append("\r\n"); String sent = sb.toString(); sb = new StringBuffer(); for (int i = 0; i < 1000; i++) sb.append("0123456789"); String received = sb.toString(); assertEquals(received, client.invoke(sent, metadata)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean addConfig, String preserveLines) 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"); if (addConfig) { config.put(HTTPUnMarshaller.PRESERVE_LINES, preserveLines); } 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) {} } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/EmptyURITestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/EmptyURITestC0000644000175000017500000001576311413704354033430 0ustar twernertwerner/* * 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.transport.http; import java.io.IOException; import java.net.InetAddress; 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.CannotConnectException; 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.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.coyote.CoyoteInvoker; import org.jboss.remoting.transport.http.TransportClientFactory; /** * Unit test for JBREM-1168. * * @author Ron Sigal * @version $Rev$ *

* Copyright Dec 13, 2009 *

*/ public class EmptyURITestCase extends TestCase { private static Logger log = Logger.getLogger(EmptyURITestCase.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); AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.registerInvokerFactories("http", TransportClientFactory.class, TestCoyoteInvokerFactory.class); return null; } }); } } public void tearDown() { } public void testEmptyURI() 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. try { Object response = client.invoke("abc"); fail("expected CannotConnectException, got: " + response); } catch (CannotConnectException e) { log.info("got expected CannotConnectException"); } catch (Throwable t) { fail("expected CannotConnectException, got: " + t); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } 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 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 public class TestCoyoteInvokerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException { return new TestCoyoteInvoker(locator, config); } public boolean supportsSSL() { return false; } } static class TestCoyoteInvoker extends CoyoteInvoker { public TestCoyoteInvoker(InvokerLocator locator) { super(locator); } public TestCoyoteInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public void service(org.apache.coyote.Request req, org.apache.coyote.Response res) throws Exception { byte[] b = new byte[]{}; req.requestURI().setBytes(b, 0, 0); log.info(this + ".service()"); super.service(req, res); } } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerTe0000644000175000017500000000374610745572664033431 0ustar twernertwerner/* * 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.transport.http; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.web.WebInvokerTestClient; /** * @author Tom Elrod */ public class HTTPInvokerTestClient extends WebInvokerTestClient implements HTTPInvokerConstants { public String getLocatorURI() { String bindAddr = System.getProperty("jrunit.bind_addr", host); String locatorURI = transport + "://" + bindAddr + ":" + port; String metadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { locatorURI = locatorURI + "/?" + metadata; } return locatorURI; } public static void main(String[] args) { HTTPInvokerTestClient client = new HTTPInvokerTestClient(); try { client.testPostInvocation(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerSecurityServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerSe0000644000175000017500000000422111413660476033405 0ustar twernertwerner/* * 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.transport.http; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerServerTest; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

* Copyright May 12, 2008 *

*/ public class HTTPInvokerSecurityServerTest extends InvokerServerTest { public String getTransport() { return "http"; } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting.transport.socket").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jboss.test.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); InvokerServerTest server = new HTTPInvokerSecurityServerTest(); try { server.setUp(); Thread.sleep(300000); server.tearDown(); System.out.println("Have torn down test."); Thread.sleep(30000); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerTe0000644000175000017500000000564410355142433033410 0ustar twernertwerner/* * 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.transport.http; import org.apache.log4j.Level; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.transport.InvokerServerTest; import org.jboss.test.remoting.transport.web.WebInvocationHandler; /** * @author Tom Elrod */ public class HTTPInvokerTestServer extends InvokerServerTest { // 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 NULL_RETURN_PARAM = "return_null"; public static final String OBJECT_RETURN_PARAM = "return_object"; private Connector connector = null; public String getTransport() { return "http"; } protected ServerInvocationHandler getServerInvocationHandler() { return new WebInvocationHandler(); } protected String getSubsystem() { return "sample"; } public void setUp() throws Exception { serverPort = 8888; super.setUp(); } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); HTTPInvokerTestServer server = new HTTPInvokerTestServer(); try { server.setUp(); Thread.currentThread().sleep(300000); } catch(Exception e) { e.printStackTrace(); } finally { try { server.tearDown(); } catch(Exception e) { e.printStackTrace(); } } } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerTe0000644000175000017500000000334210535452155033406 0ustar twernertwerner/* * 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.transport.http; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * 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 HTTPInvokerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(HTTPInvokerTestClient.class.getName(), 1, HTTPInvokerTestServer.class.getName()); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/proxy/0000755000175000017500000000000011632407034032227 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/proxy/HTTPInvokerProxyTestCase_Retired.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/proxy/HTTPInv0000644000175000017500000001443410766560277033434 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transport.http.proxy; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.util.HashMap; import java.util.Map; /** * This class is for testing http client invocations through * public proxy server. Is not a great tests as there is no way * to really prove went through the proxy. Best test can do * is indicate problem with config. Also, test may fail just due * to not being able to use proxy server (as is a public proxy server * in China and have no control over it. for more public proxy server * listings, can see http://www.publicproxyservers.com/page1.html). * Also, no gurantee the content on testUrl will never be changed. * * @author Tom Elrod */ public class HTTPInvokerProxyTestCase_Retired extends TestCase { private Client client; // private String testUrl = "http://www.gnu.org/licenses/gpl.html"; private String testUrl = "http://www.ietf.org/rfc/rfc1766.txt?number=1766"; public void setUp() { init(testUrl); } public void init(String httpTargetURL) { try { InvokerLocator locator = new InvokerLocator(httpTargetURL); Map config = new HashMap(); client = new Client(locator, config); client.connect(); } catch (Exception e) { e.printStackTrace(); } } public String makeInvocationCall(String payload, Map metadata) throws Throwable { Object obj = client.invoke(payload, metadata); System.out.println("invoke returned" + obj); return (String) obj; } public void testHTTPProxyInvocationViaSystemConfig() throws Throwable { Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "GET"); // proxy info System.setProperty("proxySet", "true"); System.setProperty("http.proxyHost", "84.19.177.62"); System.setProperty("http.proxyPort", "8080"); String result = makeInvocationCall(null, metadata); System.out.println("invoke returned" + result); assertEquals(getExpectedGETResult().substring(0, 50), result.substring(0, 50)); } public void testHTTPProxyInvocationViaConfig() throws Throwable { // need to make sure is running jdk 1.5 or higher. // otherwise, no point in running this test method as will // not work with jdk 1.4. boolean isJDK15 = false; try { Class proxyClass = Class.forName("java.net.Proxy"); isJDK15 = true; } catch (ClassNotFoundException e) { System.out.println("Not running jdk 1.5 or higher, so will bypass testHTTPProxyInvocationViaConfig test."); } if(isJDK15) { Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "GET"); // proxy info metadata.put("http.proxyHost", "84.19.177.62"); metadata.put("http.proxyPort", "8080"); String result = makeInvocationCall(null, metadata); System.out.println("invoke returned" + result); assertEquals(getExpectedGETResult().substring(0, 50), result.substring(0, 50)); } } private String getExpectedGETResult() { return "Network Working Group H. AlvestrandRequest for Comments: 1766 "; } /* private String getExpectedGETResult() { return "GNU General Public License - " + "GNU Project - Free Software Foundation (FSF)" + "" + "

GNU General Public License

" + " " + "" + "[ " + "Czech| English| Japanese]" + "" + "


Table of Contents

    " + "
  • GNU GENERAL PUBLIC LICENSE
    • Preamble"; } */ }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAu0000644000175000017500000002454511413660476033603 0ustar twernertwerner/* * 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.transport.http.proxy; import java.io.DataOutputStream; import java.io.EOFException; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; 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.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.util.SecurityUtility; import org.jboss.util.Base64; /** * Unit test for JBREM-1051. * * @author Ron Sigal * @version $Revision: 1.1 $ *

      * Copyright Oct 29, 2008 *

      */ public class ProxyAuthenticationTestCase extends TestCase { private static Logger log = Logger.getLogger(ProxyAuthenticationTestCase.class); private static boolean firstTime = true; private static String syspropAuth = "Basic " + Base64.encodeBytes("sysprop:abc".getBytes()); private static String metadataAuth = "Basic " + Base64.encodeBytes("metadata:xyz".getBytes()); protected TestHttpServer server; 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); }; } /** * Tests behavior with proxy and authorization information stored in system properties. */ public void testProxySyspropAuthSysprop() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Set system properties. System.setProperty("http.proxyHost", server.host); System.setProperty("http.proxyPort", Integer.toString(server.port)); System.setProperty("proxySet", "true"); System.setProperty("http.proxy.username", "sysprop"); System.setProperty("http.proxy.password", "abc"); // Create invocation metadata map. HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); // Run test. doTest(metadata, syspropAuth); log.info(getName() + " PASSES"); } /** * Tests behavior with proxy information stored in system properties * and authorization information stored in system properties and in overriding * invocation metadata map.. */ public void testProxySyspropAuthMeta() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Set system properties. setSystemProperty("http.proxyHost", server.host); setSystemProperty("http.proxyPort", Integer.toString(server.port)); setSystemProperty("proxySet", "true"); setSystemProperty("http.proxy.username", "sysprop"); setSystemProperty("http.proxy.password", "abc"); // Create invocation metadata map. HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("http.proxy.username", "metadata"); metadata.put("http.proxy.password", "xyz"); // Run test. doTest(metadata, metadataAuth); log.info(getName() + " PASSES"); } /** * Tests behavior with proxy information stored in invocation metadata map * and authorization information stored in system properties. */ public void testProxyMetaAuthSysprop() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Set system properties. setSystemProperty("http.proxy.username", "sysprop"); setSystemProperty("http.proxy.password", "abc"); // Create invocation metadata map. HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("http.proxyHost", server.host); metadata.put("http.proxyPort", Integer.toString(server.port)); // Run test. doTest(metadata, syspropAuth); log.info(getName() + " PASSES"); } /** * Tests behavior with proxy information stored in invocation metadata map * and authorization information stored in system properties and overriding * invocation metadata map. */ public void testProxyMetaAuthMeta() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Set system properties. setSystemProperty("http.proxy.username", "sysprop"); setSystemProperty("http.proxy.password", "abc"); // Create invocation metadata map. HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("http.proxyHost", server.host); metadata.put("http.proxyPort", Integer.toString(server.port)); metadata.put("http.proxy.username", "metadata"); metadata.put("http.proxy.password", "xyz"); // Run test. doTest(metadata, metadataAuth); log.info(getName() + " PASSES"); } protected void setupServer() throws Exception { server = new TestHttpServer(); server.start(); synchronized (TestHttpServer.class) { TestHttpServer.class.wait(); } log.info("started server"); } protected void doTest(Map metadata, String auth) throws Throwable { // Create client. String locatorURI = "http://" + server.host + ":" + server.port; log.info("connecting to " + locatorURI); InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(ServerInvoker.TIMEOUT, "10000"); Client client = new Client(clientLocator, config); client.connect(); log.info("client is connected"); try { client.invoke("abc", metadata); } catch (Throwable t) { log.error("invoke failed", t); fail(); } // Verify correct authorization was sent. assertEquals(auth, server.auth); client.disconnect(); } static class TestHttpServer extends Thread { public String host; public int port; public String auth; public void run() { try { log.info("starting HTTP server"); InetAddress localHost = InetAddress.getLocalHost(); final ServerSocket ss = new ServerSocket(0, 100, localHost); host = localHost.getHostAddress(); port = ss.getLocalPort(); synchronized (TestHttpServer.class) { TestHttpServer.class.notify(); } Socket s = ss.accept(); InputStreamReader ir = new InputStreamReader(s.getInputStream()); char[] cbuf = new char[1024]; int len = ir.read(cbuf); String request = String.copyValueOf(cbuf, 0, len); log.info("Request:"); System.out.println(); System.out.println(request); System.out.println(); auth = getAuth(request); log.info("writing response"); DataOutputStream dos = new DataOutputStream(s.getOutputStream()); dos.writeBytes("HTTP/1.1 200 OK" + "\r\n"); dos.writeBytes("Server: testServer"); dos.writeBytes("Content-Type: text/html" + "\r\n"); dos.writeBytes("Content-Length: 0\r\n"); dos.writeBytes("Connection: close\r\n"); dos.writeBytes("\r\n"); log.info("wrote response"); ir.close(); dos.close(); s.close(); ss.close(); log.info("closed HTTP server"); } catch (EOFException e1) { log.info("end of file"); } catch (Exception e2) { log.error("error", e2); } } private String getAuth(String request) { String auth = null; String[] tokens = request.split("[\r\n]+"); for (int i = 0; i < tokens.length; i++) { if (tokens[i].startsWith("Proxy-Authorization")) { auth = tokens[i].split(":[ ]*")[1]; break; } } return auth; } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/config/0000755000175000017500000000000011632407035032314 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/config/FactoryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/config/Factor0000644000175000017500000000260010446027031033447 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.config; import org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent; /** * * @author Ron Sigal *

      * Copyright (c) May 20, 2006 *

      */ public class FactoryConfigTestCase extends FactoryConfigTestCaseParent { protected String getTransport() { return "http"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/0000755000175000017500000000000011632407034032534 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/HttpQuickDisconnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/HttpQ0000644000175000017500000000273210712556233033527 0ustar twernertwerner/* * 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.transport.http.timeout; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class HttpQuickDisconnectTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HttpQuickDisconnectClient.class.getName(), 1, HttpQuickDisconnectServer.class.getName()); } protected long getResultsTimeout() { return 200000; } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/HttpPerInvocationTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/HttpP0000644000175000017500000000230610567262613033527 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.timeout; import java.util.HashMap; import org.jboss.remoting.ServerInvoker; import org.jboss.test.remoting.timeout.PerInvocationTimeoutTestRoot; /** * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 2201 $ *

      * Copyright Feb 6, 2007 *

      */ public class HttpPerInvocationTimeoutTestCase extends PerInvocationTimeoutTestRoot { /** * There seems to be some strange behavior in the BasicThreadPool timeout * mechanism, which could potentially cause a thread to prematurely time out. */ public void testBasicThreadPool() throws Throwable { log.info("entering " + getName()); try { for (int i = 0; i < 1000; i++) { HashMap metadata = new HashMap(); metadata.put(ServerInvoker.TIMEOUT, "1000"); assertEquals(NO_WAIT, client.invoke(NO_WAIT, metadata)); } } catch (Exception e) { log.error(e); fail(); } log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/TimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/Timeo0000644000175000017500000000062710404171322033533 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.timeout; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class TimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(TimeoutClientTest.class.getName(), 1, TimeoutServerTest.class.getName()); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/TimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/Timeo0000644000175000017500000000327310553474505033551 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.timeout; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class TimeoutClientTest extends TestCase { private String locatorURI = "http://localhost:8899/?timeout=3000"; public void testTimeout() throws Exception { Client client = new Client(new InvokerLocator(locatorURI)); client.connect(); //test for client timeout try { client.invoke("foo"); Thread.currentThread().sleep(5000); client.invoke("bar"); System.out.println("Done making all calls after sleeping."); } catch(Throwable throwable) { if(throwable instanceof Exception) { throw (Exception) throwable; } else { throw new Exception(throwable); } } long start = System.currentTimeMillis(); long end = 0; try { client.invoke("timeout"); end = System.currentTimeMillis(); } catch(Throwable t) { System.out.println("Caught exception: " + t.getMessage()); t.printStackTrace(); end = System.currentTimeMillis(); } long executionTime = end - start; System.out.println("execution time was " + executionTime); boolean timedOut = (executionTime < 10000); String jdkVersion = System.getProperty("java.version"); if(!jdkVersion.startsWith("1.4") && !jdkVersion.startsWith("1.3")) { assertTrue("Socket did not timeout within expected time", timedOut); } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/TimeoutServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/Timeo0000644000175000017500000000645610553474505033557 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.timeout; import javax.management.MBeanServer; 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.ServerInvoker; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * @author Tom Elrod */ public class TimeoutServerTest extends ServerTestCase { private String locatorURI = "http://localhost:8899/?timeout=3000"; private Connector connector = null; public void setUp() throws Exception { connector = new Connector(); InvokerLocator locator = new InvokerLocator(locatorURI); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler("test", new org.jboss.test.remoting.transport.http.timeout.TimeoutServerTest.TimeoutHandler()); connector.start(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.jboss.test.remoting.transport.http.timeout.TimeoutServerTest server = new org.jboss.test.remoting.transport.http.timeout.TimeoutServerTest(); try { server.setUp(); Thread.currentThread().sleep(30000); } catch(Exception e) { e.printStackTrace(); } } private class TimeoutHandler implements ServerInvocationHandler { /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { Object obj = invocation.getParameter(); if(obj instanceof String && "timeout".equals(obj)) { System.out.println("server got 'timeout' invocation... sleeping 30 seconds."); Thread.currentThread().sleep(30000); } return null; //TODO: -TME Implement } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/HttpQuickDisconnectClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/HttpQ0000644000175000017500000000324610567406066033536 0ustar twernertwerner/* * 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.transport.http.timeout; import org.jboss.test.remoting.timeout.QuickDisconnectClientParent; /** * @author Ron Sigal * @version $Revision: 2204 $ *

      * Copyright Feb 17, 2007 *

      */ public class HttpQuickDisconnectClient extends QuickDisconnectClientParent { protected String getTransport() { return "http"; } /** * It seems that in jdk 1.4 (at least), HttpURLConnection has a default timeout * of 1000 ms, so the tests are run with a shorter timeout. */ protected int shortTimeout() { return 500; } protected String shortTimeoutString() { return "500"; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/ConnectionTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/Conne0000644000175000017500000000434710553474505033541 0ustar twernertwerner/* * 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.transport.http.timeout; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ConnectionTimeoutTestCase extends TestCase { private String locatorURI = "http://localhost:8899/?timeout=3000"; public void testTimeout() throws Exception { Client client = new Client(new InvokerLocator(locatorURI)); client.connect(); //test for client timeout long start = System.currentTimeMillis(); long end = 0; try { client.invoke("timeout"); end = System.currentTimeMillis(); } catch(Throwable t) { System.out.println("Caught exception: " + t.getMessage()); t.printStackTrace(); end = System.currentTimeMillis(); } long executionTime = end - start; System.out.println("execution time was " + executionTime); boolean timedOut = (executionTime < 10000); String jdkVersion = System.getProperty("java.version"); if(!jdkVersion.startsWith("1.4") && !jdkVersion.startsWith("1.3")) { assertTrue("Socket did not timeout within expected time", timedOut); } } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/ReusedHttpURLConnectionsTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/Reuse0000644000175000017500000003175610636676705033576 0ustar twernertwerner/* * 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.transport.http.timeout; import java.net.InetAddress; import java.net.SocketTimeoutException; 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.ConnectionListener; 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; /** * * @author Ron Sigal * @version $Revision: 2495 $ *

      * Copyright May 31, 2007 *

      */ public class ReusedHttpURLConnectionsTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(ReusedHttpURLConnectionsTestCase.class); private static final String CALLBACK_DELAY_KEY = "callbackDelay"; 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() { } public void testLongThenShortTimeouts() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port + "?timeout=4000"; 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(); log.info("client is connected"); // Test connection. assertEquals("test", client.invoke("test")); // Test connection timeout (4000). HashMap metadata = new HashMap(); try { metadata.put(CALLBACK_DELAY_KEY, "6000"); client.invoke("test", metadata); fail(); } catch (Exception e) { if (e.getCause() instanceof SocketTimeoutException) { log.info(getName() + ": got first expected timeout"); } else { log.error(getName() + ": got unexpected exception", e); fail(); } } // Test per invocation timeout (1000). try { metadata.put("timeout", "1000"); metadata.put(CALLBACK_DELAY_KEY, "3000"); client.invoke("test", metadata); fail(); } catch (Exception e) { if (e.getCause() instanceof SocketTimeoutException) { log.info(getName() + ": got second expected timeout"); } else { log.error(getName() + ": got unexpected exception", e); fail(); } } client.disconnect(); connector.stop(); } public void testShortThenLongTimeouts() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port + "?timeout=1000"; 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(); log.info("client is connected"); // Test connection. assertEquals("test", client.invoke("test")); // Test connection timeout (1000). HashMap metadata = new HashMap(); try { metadata.put(CALLBACK_DELAY_KEY, "3000"); client.invoke("test", metadata); fail(); } catch (Exception e) { if (e.getCause() instanceof SocketTimeoutException) { log.info(getName() + ": got first expected timeout"); } else { log.error(getName() + ": got unexpected exception", e); fail(); } } // Try per invocation timeout (4000). try { metadata.put("timeout", "4000"); metadata.put(CALLBACK_DELAY_KEY, "6000"); client.invoke("test", metadata); fail(); } catch (Exception e) { if (e.getCause() instanceof SocketTimeoutException) { log.info(getName() + ": got second expected timeout"); } else { log.error(getName() + ": got unexpected exception", e); fail(); } } client.disconnect(); connector.stop(); } public void testShortThenZeroTimeouts() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port + "?timeout=1000"; 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(); log.info("client is connected"); // Test connection. assertEquals("test", client.invoke("test")); // Test connection timeout (1000). HashMap metadata = new HashMap(); try { metadata.put(CALLBACK_DELAY_KEY, "3000"); client.invoke("test", metadata); fail(); } catch (Exception e) { if (e.getCause() instanceof SocketTimeoutException) { log.info(getName() + ": got first expected timeout"); } else { log.error(getName() + ": got unexpected exception", e); fail(); } } // Try per invocation timeout (0). try { metadata.put("timeout", "0"); metadata.put(CALLBACK_DELAY_KEY, "5000"); assertEquals("test", client.invoke("test", metadata)); } catch (Exception e) { log.error(getName() + ": got unexpected exception", e); fail(); } client.disconnect(); connector.stop(); } public void testTimeoutsWithConnectionValidator() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port + "?timeout=4000"; 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(); ConnectionListener listener = new TestConnectionListener(); client.addConnectionListener(listener); log.info("client is connected"); // Test connection. assertEquals("test", client.invoke("test")); // Wait for a ping to occur. Thread.sleep(4000); // Try per invocation timeout (0). HashMap metadata = new HashMap(); try { metadata.put("timeout", "0"); metadata.put(CALLBACK_DELAY_KEY, "6000"); assertEquals("test", client.invoke("test", metadata)); } catch (Exception e) { log.error(getName() + ": got unexpected exception", e); fail(); } client.disconnect(); connector.stop(); } protected String getTransport() { return "http"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { Map requestMap = invocation.getRequestPayload(); int delay = 0; String delayString = (String) requestMap.get(CALLBACK_DELAY_KEY); if (delayString != null) delay = Integer.parseInt(delayString); log.info("starting delay: " + delay); Thread.sleep(delay); log.info("ending delay"); return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestInvokerCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException {} } static class TestConnectionListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { } } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/HttpQuickDisconnectServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/timeout/HttpQ0000644000175000017500000000322410567262613033530 0ustar twernertwerner/* * 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.transport.http.timeout; import org.jboss.test.remoting.timeout.QuickDisconnectServerParent; /** * @author Ron Sigal * @version $Revision: 2201 $ *

      * Copyright Feb 18, 2007 *

      */ public class HttpQuickDisconnectServer extends QuickDisconnectServerParent { public static void main(String[] args) { try { HttpQuickDisconnectServer server = new HttpQuickDisconnectServer(); server.setUp(); Thread.sleep(100000); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "http"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/contenttype/0000755000175000017500000000000011632407034033422 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/contenttype/C0000644000175000017500000002142511247273256033544 0ustar twernertwerner/* * 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.transport.http.contenttype; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.InetAddress; import java.net.URL; 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.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.web.WebUtil; /** * Unit test for JBREM-653 and JBREM-1101. * * @author Ron Sigal * @version $Revision: 5417 $ *

      * Copyright Sep 12, 2007 *

      */ public class ContentTypeTestCase extends TestCase { public static String CONTENT_TYPE = "test/testContentType"; public static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y"; public static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y"; public static String REQUEST = "testRequest"; public static String RESPONSE = "testResponse"; private static Logger log = Logger.getLogger(ContentTypeTestCase.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() { } /** * Verifies that content-type may be set in the ServerInvocationHandler. */ public void testContentType() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(CONTENT_TYPE); // Send a message and receive a response using an HttpURLConnection. URL url = new URL(locatorURI); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); byte[] requestBytes = REQUEST.getBytes(); OutputStream os = conn.getOutputStream(); os.write(requestBytes); String contentType = conn.getContentType(); log.info("content-type: " + contentType); InputStream is = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String response = reader.readLine(); log.info("response: " + response); // Verify that content-type is the value set in the ServerInvocationHandler. assertEquals(CONTENT_TYPE, contentType); assertEquals(RESPONSE, response); teardownServer(); log.info(getName() + " PASSES"); } /** * Verifies that content-type with CR supplied by ServerInvocationHandler is discarded. */ public void testInvalidContentTypeServerCR() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(INVALID_CONTENT_TYPE_CR); // Send a message and receive a response using an HttpURLConnection. URL url = new URL(locatorURI); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); byte[] requestBytes = REQUEST.getBytes(); OutputStream os = conn.getOutputStream(); os.write(requestBytes); String contentType = conn.getContentType(); log.info("content-type: " + contentType); InputStream is = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String response = reader.readLine(); log.info("response: " + response); // Verify that content-type is the default value. log.info("content-type: " + contentType); assertEquals(WebUtil.HTML, contentType); assertEquals(RESPONSE, response); teardownServer(); log.info(getName() + " PASSES"); } /** * Verifies that content-type with LF supplied by ServerInvocationHandler is discarded. */ public void testInvalidContentTypeServerLF() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(INVALID_CONTENT_TYPE_LF); // Send a message and receive a response using an HttpURLConnection. URL url = new URL(locatorURI); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); byte[] requestBytes = REQUEST.getBytes(); OutputStream os = conn.getOutputStream(); os.write(requestBytes); String contentType = conn.getContentType(); log.info("content-type: " + contentType); InputStream is = conn.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String response = reader.readLine(); log.info("response: " + response); // Verify that content-type is the default value. log.info("content-type: " + contentType); assertEquals(WebUtil.HTML, contentType); assertEquals(RESPONSE, response); teardownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(String contentType) 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(contentType); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void teardownServer() { if (connector != null) { connector.stop(); } } static class TestInvocationHandler implements ServerInvocationHandler { String contentType; public TestInvocationHandler(String contentType) { this.contentType = contentType; } public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { Map response = invocation.getReturnPayload(); if (response != null) { response.put("Content-Type", contentType); } return RESPONSE; } 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/transport/http/query/0000755000175000017500000000000011632407034032213 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/query/URLQueryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/query/URLQuer0000644000175000017500000001253211413660476033450 0ustar twernertwerner/* * 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.transport.http.query; 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; import org.jboss.remoting.transport.http.HTTPMetadataConstants; /** * Unit test for JBREM-1027. * * @author Ron Sigal * @version $Revision: 1.1 $ *

      * Copyright Aug 28, 2008 *

      */ public class URLQueryTestCase extends TestCase { private static Logger log = Logger.getLogger(URLQueryTestCase.class); private static boolean firstTime = true; protected static final String QUERY = "a=y&b=z"; 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 testQueryInRequestMap() 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. Object response = client.invoke("abc"); log.info("response: " + response); assertEquals(QUERY, response); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } 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 + "/?" + QUERY; 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 { Map requestMap = invocation.getRequestPayload(); log.info("query: " + requestMap.get(HTTPMetadataConstants.QUERY)); return requestMap.get(HTTPMetadataConstants.QUERY); } 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/transport/http/chunked/0000755000175000017500000000000011632407034032467 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedClient2.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunk0000644000175000017500000000373710426565617033510 0ustar twernertwerner/* * 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.transport.http.chunked; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ChunkedClient2 extends TestCase { private String locatorUrl = "http://localhost:8777/?datatype=chunked&" + "marshaller=org.jboss.test.remoting.transport.http.chunked.ChunkedMarshaller&" + "unmarshaller=org.jboss.test.remoting.transport.http.chunked.ChunkedUnMarshaller"; public void testChunkedViaLocator() throws Throwable { System.gc(); String newLocator = locatorUrl + "&chunkedLength=2048"; Client client = new Client(new InvokerLocator(newLocator)); client.connect(); Object response = client.invoke("foobar"); client.disconnect(); System.out.println("response was " + response); assertEquals("barfoo", response); System.gc(); } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunk0000644000175000017500000000624010463542116033466 0ustar twernertwerner/* * 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.transport.http.chunked; 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 org.jboss.test.remoting.transport.web.WebInvocationHandler; import javax.management.MBeanServer; /** * @author Tom Elrod */ public class ChunkedServer extends ServerTestCase { private String locatorUrl = "http://localhost:8777/?datatype=chunked&" + "marshaller=org.jboss.test.remoting.transport.http.chunked.ChunkedMarshaller&" + "unmarshaller=org.jboss.test.remoting.transport.http.chunked.ChunkedUnMarshaller"; private Connector connector = null; public void setUp() throws Exception { connector = new Connector(locatorUrl); connector.create(); connector.addInvocationHandler("test", new WebInvocationHandler()); connector.start(); } public void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } public class TestHandler 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 { System.gc(); return null; //TODO: -TME Implement } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } public static void main(String[] args) { try { ChunkedServer server = new ChunkedServer(); server.setUp(); Thread.sleep(360000); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunked2TestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunk0000644000175000017500000000532110570372756033477 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.chunked; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; /** * @author Tom Elrod */ public class Chunked2TestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(ChunkedClient2.class.getName(), 1, ChunkedServer.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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(PerformanceTestCase.RESULT_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(PerformanceTestCase.TEAR_DOWN_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(PerformanceTestCase.RUN_TEST_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedUnmarshallingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunk0000644000175000017500000001371011413660476033474 0ustar twernertwerner/* * 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.transport.http.chunked; 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.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 test for JBREM-1006. * * @author Ron Sigal * @version $Revision: 1.1 $ *

      * Copyright Aug 8, 2008 *

      */ public class ChunkedUnmarshallingTestCase extends TestCase { private static Logger log = Logger.getLogger(ChunkedUnmarshallingTestCase.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 testChunkedTransmission() 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. HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); String message = "abcdefghijklmnopqrstuvwxyz"; assertEquals(message, client.invoke(message, metadata)); log.info("connection is good"); assertTrue(invocationHandler.isChunked); log.info("invocation was sent chunked"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } 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 += "/?chunkedLength=10"; 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 { boolean isChunked; public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { Map requestMap = invocation.getRequestPayload(); if (requestMap != null) { String transferEncoding = (String) requestMap.get("transfer-encoding"); isChunked = "chunked".equalsIgnoreCase(transferEncoding); } 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"); } } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunk0000644000175000017500000000336110426565617033501 0ustar twernertwerner/* * 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.transport.http.chunked; import org.jboss.remoting.marshal.UnMarshaller; import java.io.IOException; import java.io.InputStream; import java.util.Map; /** * @author Tom Elrod */ public class ChunkedUnMarshaller implements UnMarshaller { public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException { int read = 0; do { read = inputStream.read(); } while (read != -1); return "barfoo"; } public void setClassLoader(ClassLoader classloader) { //TODO: -TME Implement } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { return new ChunkedUnMarshaller(); } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunk0000644000175000017500000000726110570372756033504 0ustar twernertwerner/* * 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.transport.http.chunked; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; /** * @author Tom Elrod */ public class ChunkedTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(ChunkedClient.class.getName(), 1, ChunkedServer.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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(PerformanceTestCase.RESULT_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(PerformanceTestCase.TEAR_DOWN_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(PerformanceTestCase.RUN_TEST_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunk0000644000175000017500000000404110426565617033475 0ustar twernertwerner/* * 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.transport.http.chunked; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class ChunkedClient extends TestCase { private String locatorUrl = "http://localhost:8777/?datatype=chunked&" + "marshaller=org.jboss.test.remoting.transport.http.chunked.ChunkedMarshaller&" + "unmarshaller=org.jboss.test.remoting.transport.http.chunked.ChunkedUnMarshaller"; public void testChunkedViaMap() throws Throwable { System.gc(); Map config = new HashMap(); config.put("chunkedLength", "2048"); Client client = new Client(new InvokerLocator(locatorUrl), config); client.connect(); Object response = client.invoke("foobar"); client.disconnect(); System.out.println("response was " + response); assertEquals("barfoo", response); System.gc(); } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/chunked/Chunk0000644000175000017500000000321310570372756033475 0ustar twernertwerner/* * 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.transport.http.chunked; import org.jboss.remoting.marshal.Marshaller; import java.io.IOException; import java.io.OutputStream; /** * @author Tom Elrod */ public class ChunkedMarshaller implements Marshaller { public void write(Object dataObject, OutputStream output) throws IOException { int iterations = Short.MAX_VALUE * 10000; for (int x = 0; x < iterations; x++) { output.write(x); } // output.write(-1); output.flush(); } public Marshaller cloneMarshaller() throws CloneNotSupportedException { return new ChunkedMarshaller(); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/0000755000175000017500000000000011632407034033205 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000755000175000017500000000000011632407034033547 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_classname/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000755000175000017500000000000011632407034033547 5ustar twernertwerner././@LongLink0000000000000000000000000000024300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_classname/SocketFactoryByClassnameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000644000175000017500000000305210535452155033556 0ustar twernertwerner/* * 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.transport.http.connection.socketfactory.by_classname; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.http.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByClassnameTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000023200000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_classname/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000644000175000017500000002163610437330157033564 0ustar twernertwerner/* * 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.transport.http.connection.socketfactory.by_classname; 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.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.SocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "http"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setupServerWithClassname() throws Exception { String serverSocketFactoryValue = ServerSocketFactoryMock.class.getName(); connector = new Connector(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + serverSocketFactoryValue + ""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); //connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } public void setUp() throws Exception { setupServerWithClassname(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } public static class SocketFactoryMock extends SocketFactory implements SocketFactoryMockMBean, Serializable { private SocketFactory factory = null; public SocketFactoryMock() { } private void init() { System.out.println("SocketFactoryMock - init() called"); this.factory = SocketFactory.getDefault(); } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port, localHost, localPort); } public Socket createSocket(InetAddress host, int port) throws IOException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { if(factory == null) { init(); } return factory.createSocket(address, port, localAddress, localPort); } } public interface SocketFactoryMockMBean extends SocketFactoryMBean { } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_instance/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000755000175000017500000000000011632407034033547 5ustar twernertwerner././@LongLink0000000000000000000000000000024100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_instance/SocketFactoryByInstanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000644000175000017500000000310710535452155033557 0ustar twernertwerner/* * 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.transport.http.connection.socketfactory.by_instance; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.http.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByInstanceTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000023100000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_instance/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000644000175000017500000002101510437330157033553 0ustar twernertwerner/* * 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.transport.http.connection.socketfactory.by_instance; 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.InvokerCallbackHandler; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.SocketFactoryMBean; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "http"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setUp() throws Exception { setupServerWithInstance(); } private void setupServerWithInstance() throws Exception { String locatorURI = transport + "://" + host + ":" + port; // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(locator); connector.setServerSocketFactory(ServerSocketFactory.getDefault()); // creates all the connector's needed resources, such as the server invoker connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } public static class SocketFactoryMock extends SocketFactory implements SocketFactoryMockMBean, Serializable { private SocketFactory factory = null; public SocketFactoryMock() { } private void init() { System.out.println("SocketFactoryMock - init() called"); this.factory = SocketFactory.getDefault(); } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port, localHost, localPort); } public Socket createSocket(InetAddress host, int port) throws IOException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { if(factory == null) { init(); } return factory.createSocket(address, port, localAddress, localPort); } } public interface SocketFactoryMockMBean extends SocketFactoryMBean { } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_mbean/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000755000175000017500000000000011632407034033547 5ustar twernertwerner././@LongLink0000000000000000000000000000023300000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_mbean/SocketFactoryByMBeanTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000644000175000017500000000304210535452155033555 0ustar twernertwerner/* * 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.transport.http.connection.socketfactory.by_mbean; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.http.connection.socketfactory.SocketFactoryTestClient; /** * @author Tom Elrod */ public class SocketFactoryByMBeanTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(SocketFactoryTestClient.class.getName(), 1, SocketFactoryTestServer.class.getName()); } }././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/by_mbean/SocketFactoryTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000644000175000017500000002064610437330157033564 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.connection.socketfactory.by_mbean; 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.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.SocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; /** * @author Tom Elrod */ public class SocketFactoryTestServer extends ServerTestCase { // Default locator values private static String transport = "http"; private static String host = "localhost"; private static int port = 5400; private static int callCounter = 0; private Connector connector = null; public void setupServerWithMBeanServer() throws Exception { String serverSocketFactoryValue = "jboss:type=serversocketfactory"; //setup mbean server socket factory MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); ServerSocketFactoryMock service = new SocketFactoryTestServer.ServerSocketFactoryMock(); ObjectName objName = new ObjectName(serverSocketFactoryValue); mbeanServer.registerMBean(service, objName); connector = new Connector(); mbeanServer.registerMBean(connector, new ObjectName("jboss:type=connector")); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + serverSocketFactoryValue + ""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); //connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } public void tearDown() { if(connector != null) { connector.stop(); connector.destroy(); } } public void setUp() throws Exception { setupServerWithMBeanServer(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestServer server = new SocketFactoryTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); Integer resp = new Integer(++callCounter); System.out.println("Returning response of: " + resp); // Just going to return static string as this is just simple example code. return resp; } /** * 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 } } public static class ServerSocketFactoryMock extends ServerSocketFactory implements ServerSocketFactoryMockMBean { private ServerSocketFactory factory = null; public ServerSocketFactoryMock() { factory = ServerSocketFactory.getDefault(); } public ServerSocket createServerSocket() throws IOException { return factory.createServerSocket(); } public ServerSocket createServerSocket(int i) throws IOException { return factory.createServerSocket(i); } public ServerSocket createServerSocket(int i, int i1) throws IOException { return factory.createServerSocket(i, i1); } public ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException { return factory.createServerSocket(i, i1, inetAddress); } } public interface ServerSocketFactoryMockMBean extends ServerSocketFactoryMBean { } public static class SocketFactoryMock extends SocketFactory implements SocketFactoryMockMBean, Serializable { private SocketFactory factory = null; public SocketFactoryMock() { } private void init() { System.out.println("SocketFactoryMock - init() called"); this.factory = SocketFactory.getDefault(); } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException { if(factory == null) { init(); } return factory.createSocket(host, port, localHost, localPort); } public Socket createSocket(InetAddress host, int port) throws IOException { if(factory == null) { init(); } return factory.createSocket(host, port); } public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { if(factory == null) { init(); } return factory.createSocket(address, port, localAddress, localPort); } } public interface SocketFactoryMockMBean extends SocketFactoryMBean { } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/socketfactory/SocketFactoryTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connection/so0000644000175000017500000000405010433770344033555 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.connection.socketfactory; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class SocketFactoryTestClient extends TestCase { // Default locator values private static String transport = "http"; private static String host = "localhost"; private static int port = 5400; public void testInvocations() throws Throwable { Client remotingClient = null; try { String locatorURI = transport + "://" + host + ":" + port; //String locatorURI = transport + "://" + host + ":" + port; // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); String request = "Do something"; System.out.println("Invoking server with request of '" + request + "'"); long startTime = System.currentTimeMillis(); Object response = remotingClient.invoke(request); System.out.println("Invocation response: " + response); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } SocketFactoryTestClient client = new SocketFactoryTestClient(); try { client.testInvocations(); } catch(Throwable e) { e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/multihome/0000755000175000017500000000000011632407034033051 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/multihome/HttpMultihomeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/multihome/Htt0000644000175000017500000000254711413660476033553 0ustar twernertwerner /* * 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.transport.http.multihome; import org.jboss.test.remoting.multihome.MultihomeTestParent; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

      * Copyright Jan 8, 2008 *

      */ public class HttpMultihomeTestCase extends MultihomeTestParent { protected String getTransport() { return "http"; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/authorization/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/authorization0000755000175000017500000000000011632407034033667 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/authorization/BASICAuthorizationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/authorization0000644000175000017500000001266110660516351033702 0ustar twernertwerner/* * 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.transport.http.authorization; import java.net.InetAddress; import java.util.HashMap; import java.util.HashSet; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-791. * * @author Ron Sigal * @version $Revision: 2631 $ *

      * Copyright Aug 14, 2007 *

      */ public class BASICAuthorizationTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(BASICAuthorizationTestCase.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 org.jboss.remoting.transport.http.HttpClientInvoker.getBasicAuth() * does not insert newlines into Base64 encoded name:password string. */ public void testLongNamePassword() 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"); // Test invocation with BASIC authorization. HashMap metadata = new HashMap(); String s = "abcdefghijklmnopqursuvwxyz"; String name = s + s; String password = s + s; assertEquals(52, name.length()); assertEquals(52, password.length()); metadata.put("http.basic.username", name); metadata.put("http.basic.password", password); assertEquals("xyz", client.invoke("xyz", metadata)); client.disconnect(); connector.stop(); } protected String getTransport() { return "http"; } 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) {} } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/SimpleHTTPServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/SimpleHTTPSer0000644000175000017500000001534710355142433033406 0ustar twernertwerner/* * 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.transport.http; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.ServerSocket; import java.net.Socket; import java.util.Timer; import java.util.TimerTask; /** * @author Tom Elrod */ public class SimpleHTTPServer extends Thread { private byte[] content; private byte[] header; private int port = 80; private static boolean timeout = false; public SimpleHTTPServer(String data, String encoding, String MIMEType, int port) throws UnsupportedEncodingException { this(data.getBytes(encoding), encoding, MIMEType, port); } public SimpleHTTPServer(byte[] data, String encoding, String MIMEType, int port) throws UnsupportedEncodingException { this.content = data; this.port = port; String header = "HTTP/1.1 200 OK\r\n" + "Server: SimpleHTTPServer 1.0\r\n" + "Content-length: " + this.content.length + "\r\n" + "Content-type: " + MIMEType + "\r\n\r\n"; this.header = header.getBytes("ASCII"); } protected void startTimer(Thread currentThread) { Timer timer = new Timer(false); timer.schedule(new TimeoutTimerTask(currentThread), 3000); } public void run() { try { ServerSocket server = new ServerSocket(this.port); System.out.println("Accepting connections on port " + server.getLocalPort()); System.out.println("Data to be sent: "); System.out.write(this.content); while(true) { Socket connection = null; try { connection = server.accept(); OutputStream out = new BufferedOutputStream(connection.getOutputStream()); InputStream in = new BufferedInputStream(connection.getInputStream()); //startTimer(Thread.currentThread()); StringBuffer request = new StringBuffer(80); try { int c = in.read(); while(c != -1 && !timeout) { int q = 0; if(request.length() > 0) { q = request.charAt(request.length() - 1); } request.append((char) c); //System.out.println(request); int n = in.read(); if(c == '\r' && n == '\n') { if(q == '\n') { break; } else { c = n; } } else { c = n; } //Thread.sleep(50); } } catch(Exception e) { e.printStackTrace(); } System.out.println("\n\nHTTP Request:\n\n" + request + "\n\n"); StringBuffer requestHeader = new StringBuffer(80); for(int x = 0; x < request.length(); x++) { char cr = request.charAt(x); if(cr == '\r' || cr == '\n' || cr == -1) { break; } requestHeader.append(cr); } if(requestHeader.toString().indexOf("HTTP/") != -1) { out.write(this.header); } out.write(this.content); out.flush(); } catch(IOException e) { } finally { if(connection != null) { connection.close(); } } } } catch(IOException e) { System.err.println("Could not start server. Port " + this.port + " occupied."); } } public class TimeoutTimerTask extends TimerTask { private Thread curThread; public TimeoutTimerTask(Thread current) { this.curThread = current; } public void run() { timeout = true; curThread.interrupt(); } } public static void main(String[] args) { try { String contentType = "text/plain"; if(args[0].endsWith(".html") || args[0].endsWith(".htm")) { contentType = "text/html"; } InputStream in = new FileInputStream(args[0]); ByteArrayOutputStream out = new ByteArrayOutputStream(); int b; while((b = in.read()) != -1) { out.write(b); } byte[] data = out.toByteArray(); int port; try { port = Integer.parseInt(args[1]); if(port < 1 || port > 65535) { port = 80; } } catch(Exception e) { port = 80; } String encoding = "ASCII"; if(args.length >= 2) { encoding = args[2]; } Thread t = new SimpleHTTPServer(data, encoding, contentType, port); t.start(); } catch(ArrayIndexOutOfBoundsException e) { System.out.println("Usage: java SimpleHTTPServer filename port encoding"); } catch(Exception e) { System.err.println(e); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/raw/0000755000175000017500000000000011632407034031637 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/raw/HTTPInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/raw/HTTPInvok0000644000175000017500000001023210766561154033361 0ustar twernertwerner/* * 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.transport.http.raw; import java.util.HashMap; import java.util.Map; import java.util.Properties; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.http.HTTPInvokerConstants; import org.jboss.test.remoting.transport.web.WebInvocationHandler; /** * This tests the ability of the http transport to correctly handle raw payloads * as well as InvocationRequests and InvocationResponses. * * @author Ron Sigal * @author Tom Elrod * @version $Revision: 3641 $ *

      * Copyright Oct 29, 2006 *

      */ public class HTTPInvokerTestClient extends TestCase implements HTTPInvokerConstants { public void testRawInvocation() throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURI()); System.out.println("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); Object response = remotingClient.invoke("Do something", metadata); System.out.println("Second response should be " + WebInvocationHandler.HTML_PAGE_RESPONSE + " and was: " + response); assertEquals(WebInvocationHandler.HTML_PAGE_RESPONSE, response); } catch (Throwable throwable) { throw new Exception(throwable); } finally { if (remotingClient != null) { remotingClient.disconnect(); } } } public void testCookedInvocation() throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURI()); System.out.println("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Object response = remotingClient.invoke("Do something"); System.out.println("Second response should be " + WebInvocationHandler.HTML_PAGE_RESPONSE + " and was: " + response); assertEquals(WebInvocationHandler.HTML_PAGE_RESPONSE, response); } catch (Throwable throwable) { throw new Exception(throwable); } finally { if (remotingClient != null) { remotingClient.disconnect(); } } } public String getLocatorURI() { String bindAddr = System.getProperty("jrunit.bind_addr", host); String locatorURI = transport + "://" + bindAddr + ":" + port; String metadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { locatorURI = locatorURI + "/?" + metadata; } return locatorURI; } protected void addHeaders(Properties headerProps) { //NO OP - for overriding by sub-classes. } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/raw/HTTPInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/raw/HTTPInvok0000644000175000017500000000304210535452155033354 0ustar twernertwerner/* * 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.transport.http.raw; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; /** * * @author Ron Sigal * @version $Revision: 1650 $ *

      * Copyright Oct 29, 2006 *

      */ public class HTTPInvokerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(HTTPInvokerTestClient.class.getName(), 1, HTTPInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connectionfailure/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connectionfai0000755000175000017500000000000011632407034033606 5ustar twernertwerner././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connectionfailure/HttpCallbackConnectionFailureTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/connectionfai0000644000175000017500000000306111413660476033620 0ustar twernertwerner /* * 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.transport.http.connectionfailure; import org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent; /** * Unit test for JBREM-875. * * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent. * * @author Ron Sigal * @version $Revision: 1.1 $ *

      * Copyright Dec 10, 2007 *

      */ public class HttpCallbackConnectionFailureTestCase extends CallbackConnectionFailureTestParent { protected String getTransport() { return "http"; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerClientTestCase_deleted.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerCl0000644000175000017500000003311111004707300033354 0ustar twernertwerner/* * 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.transport.http; import junit.framework.TestCase; import org.apache.log4j.Level; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.util.HashMap; import java.util.Map; import java.util.Properties; /** * Test case that uses the HTTPInvoker client to call on two different public SOAP services (one based * on Axis and the other based on .NET implementations). * * @author Tom Elrod */ public class HTTPInvokerClientTestCase_deleted extends TestCase { private Client client; public void init(String httpTargetURL) { try { InvokerLocator locator = new InvokerLocator(httpTargetURL); Map config = new HashMap(); config.put(Client.ENABLE_LEASE, "false"); client = new Client(locator, config); client.connect(); } catch(Exception e) { e.printStackTrace(); } } public String makeInvocationCall(String httpTargetURL, String payload, Map metadata) throws Throwable { init(httpTargetURL); Object obj = client.invoke(payload, metadata); System.out.println("invoke returned" + obj); return (String) obj; } /* *** commented out because external site no longer available *** public void testWeatherHTTPInvocation() throws Throwable { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); String testURL = "http://services.xmethods.net:80/soap/servlet/rpcrouter"; String xml = "\n" + "\n" + " \n" + " \n" + " 30106\n" + " \n" + " \n" + ""; Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "POST"); // proxy info //metadata.put("http.proxyHost", "ginger"); //metadata.put("http.proxyPort", "80"); //metadata.put("http.proxy.username", "tom"); //metadata.put("http.proxy.password", "foobar"); Properties headerProps = new Properties(); headerProps.put("SOAPAction", ""); headerProps.put("Content-type", "text/xml; charset=UTF-8"); metadata.put("HEADER", headerProps); HTTPInvokerClientTestCase client = new HTTPInvokerClientTestCase(); String result = client.makeInvocationCall(testURL, xml, metadata); // don't need to comapre full string. (as actual temp value will change each time run) assertEquals(getExpectedWeatherResult().substring(0, 380), result.substring(0, 380)); } */ public void testCitiesByCountryHTTPInvocation() throws Throwable { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); String testURL = "http://www.webserviceX.NET/globalweather.asmx?op=GetCitiesByCountry"; String xml = "\n" + "\n" + " \n" + " \n" + " Germany\n" + " \n" + " \n" + ""; Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "POST"); // proxy info //metadata.put("http.proxyHost", "ginger"); //metadata.put("http.proxyPort", "80"); //metadata.put("http.proxy.username", "tom"); //metadata.put("http.proxy.password", "foobar"); Properties headerProps = new Properties(); headerProps.put("SOAPAction", "http://www.webserviceX.NET/GetCitiesByCountry"); headerProps.put("Content-type", "text/xml; charset=UTF-8"); metadata.put("HEADER", headerProps); HTTPInvokerClientTestCase_deleted client = new HTTPInvokerClientTestCase_deleted(); String result = client.makeInvocationCall(testURL, xml, metadata); // 30 characters will be good enough. assertEquals(getExpectedCityResult().substring(0, 200), result.substring(0, 200)); } // public void testGETHTTPInvocation() throws Throwable // { // // org.apache.log4j.BasicConfigurator.configure(); // org.apache.log4j.Category.getRoot().setLevel(Level.INFO); // org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); // org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); // org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); // // // String testURL = "http://www.gnu.org/licenses/gpl.html"; // // Map metadata = new HashMap(); // metadata.put(Client.RAW, Boolean.TRUE); // metadata.put("TYPE", "GET"); // // HTTPInvokerClientTestCase client = new HTTPInvokerClientTestCase(); // // String result = client.makeInvocationCall(testURL, null, metadata); // // 30 characters will be good enough. // assertEquals(getExpectedGETResult().substring(0, 100), result.substring(0, 100)); // // } private String getExpectedGETResult() { return "GNU General Public License - " + "GNU Project - Free Software Foundation (FSF)" + "" + "

      GNU General Public License

      " + " " + "" + "[ " + "Czech| English| Japanese]" + "" + "


      Table of Contents

        " + "
      • GNU GENERAL PUBLIC LICENSE
        • Preamble"; } private String getExpectedWeatherResult() { return "" + "" + "" + "" + "60.0" + "" + "\n" + "\n" + ""; } private String getExpectedCityResult() { return "" + "<NewDataSet> " + "<Table> <Country>Germany</Country> <City>Berlin-Schoenefeld</City> </Table> <Table> " + "<Country>Germany</Country> <City>Dresden-Klotzsche</City> </Table> <Table> " + " <Country>Germany</Country> <City>Erfurt-Bindersleben</City> </Table> <Table> " + " <Country>Germany</Country> <City>Frankfurt / M-Flughafen</City> </Table> <Table> " + "<Country>Germany</Country> <City>Muenster / Osnabrueck</City> </Table> <Table> " + "<Country>Germany</Country> <City>Hamburg-Fuhlsbuettel</City> </Table> <Table> " + " <Country>Germany</Country> <City>Berlin-Tempelhof</City> </Table> <Table> " + "<Country>Germany</Country> <City>Koeln / Bonn</City> </Table> <Table> " + "<Country>Germany</Country> <City>Duesseldorf</City> </Table> <Table> " + " <Country>Germany</Country> <City>Munich / Riem</City> </Table> <Table> " + " <Country>Germany</Country> <City>Nuernberg</City> </Table> <Table> " + " <Country>Germany</Country> <City>Leipzig-Schkeuditz</City> </Table> <Table> " + " <Country>Germany</Country> <City>Saarbruecken / Ensheim</City> </Table> <Table> " + "<Country>Germany</Country> <City>Stuttgart-Echterdingen</City> </Table> <Table> " + " <Country>Germany</Country> <City>Berlin-Tegel</City> </Table> <Table> " + "<Country>Germany</Country> <City>Hannover</City> </Table> <Table> " + "<Country>Germany</Country> <City>Bremen</City> </Table> <Table> " + " <Country>Germany</Country> <City>Hahn</City> </Table> <Table>" + " <Country>Germany</Country> <City>Baden Wurttemberg, Neuostheim</"; } // public static void main(String[] args) // { // HTTPInvokerClientTest test = new HTTPInvokerClientTest(); // test.testHTTPInvocation(); // } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/0000755000175000017500000000000011632407035032363 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/ErrorHTTPInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/ErrorH0000644000175000017500000001110410355142433033503 0ustar twernertwerner/* * 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.transport.http.errors; import javax.management.MBeanServer; 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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class ErrorHTTPInvokerTestServer extends ServerTestCase { // Default locator values private String transport = "http"; private String host = "localhost"; private int port = 8888; private Connector connector = null; public static final String EXCEPTION_MSG = "Test exception. Is expected."; public void setupServer() throws Exception { String locatorURI = transport + "://" + host + ":" + port; 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(); ServerInvocationHandler invocationHandler = new ErrorInvocationHandler(); // 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(); } } private class ErrorInvocationHandler implements ServerInvocationHandler { /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { //TODO: -TME Implement } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { //TODO: -TME Implement } /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { throw new Exception(EXCEPTION_MSG); } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); ErrorHTTPInvokerTestServer server = new ErrorHTTPInvokerTestServer(); try { server.setupServer(); while(true) { Thread.currentThread().sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/ErrorHTTPInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/ErrorH0000644000175000017500000001114310521052472033504 0ustar twernertwerner/* * 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.transport.http.errors; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.http.WebServerError; import org.jboss.test.remoting.transport.web.WebInvocationHandler; import java.util.HashMap; import java.util.Map; import java.util.Properties; /** * @author Tom Elrod */ public class ErrorHTTPInvokerTestClient extends TestCase { // Default locator values private String transport = "http"; private String host = "localhost"; private int port = 8888; public String getLocatorURI() { return transport + "://" + host + ":" + port; } /** * In this case, the payload will be sent raw, the Exception will be return raw, * and HTTPClientInvoker should return a WebServerError. */ public void testRawInvocation() throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURI()); System.out.println("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "POST"); Properties headerProps = new Properties(); headerProps.put("Content-type", "application/soap+xml"); metadata.put("HEADER", headerProps); try { Object response = remotingClient.invoke(WebInvocationHandler.THROW_EXCEPTION_PARAM, metadata); assertTrue("Did not get exception thrown as expected.", false); } catch(WebServerError wse) { assertTrue("Caught exception as expected", true); } } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } /** * In this case, the payload will be wrapped in an InvocationRequest, the Exception * will be wrapped in an InvocationRequest, and the original Exception should be * thrown. */ public void testCookedInvocation() throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURI()); System.out.println("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); metadata.put("TYPE", "POST"); try { Object response = remotingClient.invoke(WebInvocationHandler.THROW_EXCEPTION_PARAM, metadata); assertTrue("Did not get exception thrown as expected.", false); } catch(Exception e) { assertTrue("Caught exception as expected", ErrorHTTPInvokerTestServer.EXCEPTION_MSG.equals(e.getMessage())); } } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } public static void main(String[] args) { ErrorHTTPInvokerTestClient client = new ErrorHTTPInvokerTestClient(); try { client.testRawInvocation(); client.testCookedInvocation(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/NoThrowOnErrorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/NoThro0000644000175000017500000003364611413660476033542 0ustar twernertwerner/* * 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.transport.http.errors; import java.io.ByteArrayInputStream; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.xml.parsers.DocumentBuilderFactory; 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.ServerConfiguration; 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.http.HTTPMetadataConstants; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.w3c.dom.Document; public class NoThrowOnErrorTestCase extends TestCase { private static Logger log = Logger.getLogger(NoThrowOnErrorTestCase.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 testThrowException() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, true); // 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"); // Should throw exception. try { client.invoke("abc"); fail("should have thrown TestException"); } catch (Exception e) { assertTrue("should have thrown TestException", e instanceof TestException); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoThrowExceptionInMetadata() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, true); // 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"); // Should return exception. HashMap metadata = new HashMap(); metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); assertTrue(client.invoke("abc", metadata) instanceof TestException); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoThrowExceptionInConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, true); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Should return exception. assertTrue(client.invoke("abc") instanceof TestException); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoThrowExceptionInInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true); // 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"); // Should return exception. assertTrue(client.invoke("abc") instanceof TestException); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNoThrowExceptionInXMLConfig() throws Throwable { log.info("entering " + getName()); // Start server. host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append("true"); buf.append("true"); buf.append(""); buf.append(""); buf.append(" " + TestInvocationHandler.class.getName() + "\n"); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector = new Connector(); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.start(); // Create client. locatorURI = connector.getInvokerLocator(); log.info("created server: " + locatorURI); 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"); // Should return exception. assertTrue(client.invoke("abc") instanceof TestException); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testNoThrowExceptionInServerConfig() throws Throwable { log.info("entering " + getName()); // Start server. host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); ServerConfiguration config = new ServerConfiguration("http"); Map locatorConfig = new HashMap(); locatorConfig.put("serverBindAddress", host); locatorConfig.put("serverBindPort", Integer.toString(port)); locatorConfig.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); locatorConfig.put(InvokerLocator.FORCE_REMOTE, "true"); config.setInvokerLocatorParameters(locatorConfig); Map handlers = new HashMap(); handlers.put("test", new TestInvocationHandler()); config.setInvocationHandlers(handlers); connector = new Connector(); connector.setServerConfiguration(config); connector.create(); connector.start(); // Create client. locatorURI = connector.getInvokerLocator(); log.info("created server: " + locatorURI); 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"); // Should return exception. assertTrue(client.invoke("abc") instanceof TestException); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testMetadataOverridesConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, true); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Should return exception. HashMap metadata = new HashMap(); metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "false"); // Should throw exception. try { client.invoke("abc", metadata); fail("should have throw TestException"); } catch (Exception e) { assertTrue("should thrown received testException", e instanceof TestException); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testMetadataOverridesInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Should return exception. HashMap metadata = new HashMap(); metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "false"); // Should throw exception. try { client.invoke("abc", metadata); fail("should have throw TestException"); } catch (Exception e) { assertTrue("should thrown received testException", e instanceof TestException); } client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean addNoThrow, boolean noThrow) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; if (addNoThrow) { locatorURI += "/?" + HTTPMetadataConstants.NO_THROW_ON_ERROR + "=" + noThrow; } 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(); } public static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { throw new TestException(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestException extends Exception {} }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/ErrorHTTPInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/errors/ErrorH0000644000175000017500000000262310355142433033511 0ustar twernertwerner/* * 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.transport.http.errors; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class ErrorHTTPInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ErrorHTTPInvokerTestClient.class.getName(), 1, ErrorHTTPInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerSecurityTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerSe0000644000175000017500000000466711413660476033423 0ustar twernertwerner/* * 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.transport.http; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 12, 2008 *

          */ public class HTTPInvokerSecurityTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(HTTPInvokerSecurityClientTest.class.getName(), 1, HTTPInvokerSecurityServerTest.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. * * @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 60000; } /** * 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 60000; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/retry/0000755000175000017500000000000011632407034032213 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/retry/ConnectionRetryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/retry/Connect0000644000175000017500000003045111413660476033542 0ustar twernertwerner/* * 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.transport.http.retry; 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.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.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.http.HTTPClientInvoker; /** * Unit test for JBREM-979. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 10, 2008 *

          */ public class ConnectionRetryTestCase extends TestCase { private static Logger log = Logger.getLogger(ConnectionRetryTestCase.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.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 tearDown() { } public void testDefaultRetries() throws Throwable { log.info("entering " + getName()); if (System.getProperty("java.version").indexOf("1.4") >= 0) { log.info("retries not supported for jdk 1.4"); return; } // Start server. TestInvocationHandler invocationHandler = new TestInvocationHandler(2, 2); setupServer(invocationHandler); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(ServerInvoker.TIMEOUT, "4000"); 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"); // This call should time out. boolean success = false; try { client.invoke("xyz"); } catch (CannotConnectException e) { log.info("got expected exception"); success = true; } assertTrue("invocation should have thrown exception", success); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testOneRetry() throws Throwable { log.info("entering " + getName()); if (System.getProperty("java.version").indexOf("1.4") >= 0) { log.info("retries not supported for jdk 1.4"); return; } // Start server. TestInvocationHandler invocationHandler = new TestInvocationHandler(2, 2); setupServer(invocationHandler); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPClientInvoker.NUMBER_OF_CALL_ATTEMPTS, "1"); clientConfig.put(ServerInvoker.TIMEOUT, "4000"); 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"); // This call should time out. boolean success = false; try { client.invoke("xyz"); } catch (CannotConnectException e) { log.info("got expected exception"); success = true; } assertTrue("invocation should have thrown exception", success); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testTwoRetries() throws Throwable { log.info("entering " + getName()); if (System.getProperty("java.version").indexOf("1.4") >= 0) { log.info("retries not supported for jdk 1.4"); return; } // Start server. TestInvocationHandler invocationHandler = new TestInvocationHandler(2, 2); setupServer(invocationHandler); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPClientInvoker.NUMBER_OF_CALL_ATTEMPTS, "2"); clientConfig.put(ServerInvoker.TIMEOUT, "4000"); 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"); // This call should succeed on the second attempt. log.info("making second invocation"); assertEquals("xyz", client.invoke("xyz")); log.info("second invocation succeeded as expected"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testFiveRetriesAndFail() throws Throwable { log.info("entering " + getName()); if (System.getProperty("java.version").indexOf("1.4") >= 0) { log.info("retries not supported for jdk 1.4"); return; } // Start server. TestInvocationHandler invocationHandler = new TestInvocationHandler(2, 6); setupServer(invocationHandler); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPClientInvoker.NUMBER_OF_CALL_ATTEMPTS, "5"); clientConfig.put(ServerInvoker.TIMEOUT, "4000"); 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"); // This call should time out once and succeed on the second attempt. log.info("making second invocation"); boolean success = false; try { client.invoke("xyz"); } catch (CannotConnectException e) { log.info("got expected exception"); success = true; } assertTrue("invocation should have thrown exception", success); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testFiveRetriesThenSucceed() throws Throwable { log.info("entering " + getName()); if (System.getProperty("java.version").indexOf("1.4") >= 0) { log.info("retries not supported for jdk 1.4"); return; } // Start server. TestInvocationHandler invocationHandler = new TestInvocationHandler(2, 5); setupServer(invocationHandler); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(HTTPClientInvoker.NUMBER_OF_CALL_ATTEMPTS, "5"); clientConfig.put(ServerInvoker.TIMEOUT, "4000"); 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"); // This call should time out once and succeed on the second attempt. log.info("making second invocation"); long start = System.currentTimeMillis(); assertEquals("xyz", client.invoke("xyz")); log.info("second invocation succeeded"); assertTrue(System.currentTimeMillis() - start >= 4 * 4000); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(ServerInvocationHandler invocationHandler) 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(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } static class TestInvocationHandler implements ServerInvocationHandler { int minDelayAttempt; int maxDelayAttempt; int counter; public TestInvocationHandler(int minDelayAttempt, int maxDelayAttempt) { this.minDelayAttempt = minDelayAttempt; this.maxDelayAttempt = maxDelayAttempt; } public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { counter++; if (minDelayAttempt <= counter && counter <= maxDelayAttempt) { log.info("going to sleep, counter = " + counter); Thread.sleep(8000); log.info("waking up"); } 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"); } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerSecurityClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerSe0000644000175000017500000000253511413660476033413 0ustar twernertwerner/* * 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.transport.http; import org.jboss.test.remoting.transport.InvokerClientTest; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 12, 2008 *

          */ public class HTTPInvokerSecurityClientTest extends InvokerClientTest { public String getTransport() { return "http"; } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/socketfactory0000755000175000017500000000000011632407034033647 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/socketfactory/SocketFactoryClassNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/socketfactory0000644000175000017500000000072011413660476033660 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.socketfactory; import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot; /** * * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jul 18, 2008 *

          */ public class SocketFactoryClassNameTestCase extends SocketFactoryClassNameTestRoot { protected String getTransport() { return "http"; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/shutdown/0000755000175000017500000000000011632407034032721 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/shutdown/HTTPShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/shutdown/HTTP0000644000175000017500000000254410555056447033443 0ustar twernertwerner/* * 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.transport.http.shutdown; import org.jboss.test.remoting.shutdown.ShutdownTestParent; /** * @author Ron Sigal * @version $Revision: 1961 $ *

          * Copyright Jan 20, 2007 *

          */ public class HTTPShutdownTestCase extends ShutdownTestParent { protected String getTransport() { return "http"; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/clientaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/clientaddress0000755000175000017500000000000011632407034033613 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/clientaddress/HttpClientAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/clientaddress0000644000175000017500000000042310720523423033612 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.clientaddress; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class HttpClientAddressTestCase extends ClientAddressTestParent { protected String getTransport() { return "http"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/0000755000175000017500000000000011632407035031650 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/SSLInvokerConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/SSLInvoke0000644000175000017500000000240610355142433033411 0ustar twernertwerner/* * 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.transport.http.ssl; /** * @author Tom Elrod */ public interface SSLInvokerConstants { int port = 8888; String transport = "https"; //protected String host = "192.168.1.103"; String host = "localhost"; }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/.truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/.truststo0000644000175000017500000000701310345206626033564 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žçlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/lines/0000755000175000017500000000000011632407034032761 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/lines/HttpsLinePreservationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/lines/Htt0000644000175000017500000000473711413660476033466 0ustar twernertwerner/* * 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.transport.http.ssl.lines; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.jboss.test.remoting.transport.http.lines.HttpLinePreservationTestCase; /** * Unit tests for JBREM-809. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 8, 2008 *

          */ public class HttpsLinePreservationTestCase extends HttpLinePreservationTestCase { protected String getTransport() { return "https"; } protected void addExtraServerConfig(Map config) { super.addExtraServerConfig(config); 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"); } protected void addExtraClientConfig(Map config) { super.addExtraClientConfig(config); config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); 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"); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/0000755000175000017500000000000011632407034033275 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/HTTPSInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/H0000644000175000017500000000330510446031013033400 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.ssl.builder; import org.jboss.test.remoting.transport.socket.ssl.builder.SSLSocketInvokerTestServer; /** * * @author Ron Sigal * @version $Revision: 1162 $ *

          * Copyright (c) Jun 8, 2006 *

          */ public class HTTPSInvokerTestServer extends SSLSocketInvokerTestServer { public String getTransport() { return "https"; } public static void main(String[] args) { HTTPSInvokerTestServer server = new HTTPSInvokerTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/LocalhostVerifier.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/L0000644000175000017500000000405010446031013033402 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.ssl.builder; import java.net.InetAddress; import java.net.UnknownHostException; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; import org.jboss.logging.Logger; /** * * @author Ron Sigal * @version $Revision: 1162 $ *

          * Copyright (c) Jun 9, 2006 *

          */ public class LocalhostVerifier implements HostnameVerifier { protected static Logger log = Logger.getLogger(LocalhostVerifier.class); public boolean verify(String s, SSLSession sslSession) { System.out.println("s: " + s); System.out.println("sslSession.getPeerHost(): " + sslSession.getPeerHost()); try { InetAddress address1 = InetAddress.getByName(s); InetAddress address2 = InetAddress.getByName(sslSession.getPeerHost()); if (address1.equals(address2)) return true; else return false; } catch (UnknownHostException e) { return false; } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/HTTPSInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/H0000644000175000017500000000275710446031013033412 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.ssl.builder; import org.jboss.jrunit.harness.TestDriver; /** * * @author Ron Sigal * @version $Revision: 1162 $ *

          * Copyright (c) Jun 8, 2006 *

          */ public class HTTPSInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPSInvokerTestClient.class.getName(), 1, HTTPSInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/HTTPSInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/builder/H0000644000175000017500000000265510446031013033407 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.ssl.builder; import org.jboss.test.remoting.transport.socket.ssl.builder.SSLSocketInvokerTestClient; /** * * @author Ron Sigal * @version $Revision: 1162 $ *

          * Copyright (c) Jun 8, 2006 *

          */ public class HTTPSInvokerTestClient extends SSLSocketInvokerTestClient { public String getTransport() { return "https"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/0000755000175000017500000000000011632407034033114 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/SelfIdentifyingHostnameVerifier.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/Se0000644000175000017500000000243710446030573033416 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.ssl.config; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; public class SelfIdentifyingHostnameVerifier implements HostnameVerifier { public boolean verify(String s, SSLSession sslSession) { return true; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/HostnameVerifierTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/Ho0000644000175000017500000003212511413671361033413 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.ssl.config; 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.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.security.SSLSocketBuilder; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import javax.management.MBeanServer; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.HashMap; /** * * @author Ron Sigal *

          * Copyright (c) May 20, 2006 *

          */ public class HostnameVerifierTestCase extends TestCase { private static Logger log = Logger.getLogger(HostnameVerifierTestCase.class); private static Connector connector; private static InvokerLocator locator; public void setUp() { try { if (connector == null) { // Register subclassed transport for test. AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.registerInvokerFactories(getTransport(), TestClientInvokerFactory.class, TestServerInvokerFactory.class); return null; } }); HashMap config = new HashMap(); // Put SSL keystore parameters in config map. config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getClass().getResource("../.keystore").getFile(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Make callback Client use remote invoker. config.put(InvokerLocator.FORCE_REMOTE, "true"); // Start Connector. int freeport = PortUtil.findFreePort(getHostName()); locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); connector = new Connector(locator, config); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); } } catch (Exception e) { log.error(e); e.printStackTrace(); } } public void shutDown() { try { } catch (Exception e) { log.error(e); e.printStackTrace(); } } public void testSetClassNameMetadata() { log.info("entering " + getName()); try { HashMap config = new HashMap(); // Make Client use remote invoker. config.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL truststore parameters in config map. config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); // Put HostnameVerifier class name in metadata. HashMap metadata = new HashMap(); metadata.put(HTTPSClientInvoker.HOSTNAME_VERIFIER, SelfIdentifyingHostnameVerifier.class.getName()); // Connect Client and make invocation. Client client = new Client(locator, config); client.connect(); client.invoke("abc", metadata); // Verify HostnameVerifier class is the class named in config map. ClientInvoker clientInvoker = client.getInvoker(); assertTrue(clientInvoker instanceof TestClientInvoker); TestClientInvoker testClientInvoker = (TestClientInvoker) clientInvoker; assertEquals(SelfIdentifyingHostnameVerifier.class.getName(), testClientInvoker.getHostnameVerifierClassName()); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testSetClassNameConfig() { log.info("entering " + getName()); try { HashMap config = new HashMap(); // Make Client use remote invoker. config.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL truststore parameters in config map. config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); // Put HostnameVerifier class name in config map. config.put(HTTPSClientInvoker.HOSTNAME_VERIFIER, SelfIdentifyingHostnameVerifier.class.getName()); // Connect Client and make invocation. Client client = new Client(locator, config); client.connect(); client.invoke("abc"); // Verify HostnameVerifier class is the class named in config map. ClientInvoker clientInvoker = client.getInvoker(); assertTrue(clientInvoker instanceof TestClientInvoker); TestClientInvoker testClientInvoker = (TestClientInvoker) clientInvoker; assertEquals(SelfIdentifyingHostnameVerifier.class.getName(), testClientInvoker.getHostnameVerifierClassName()); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testIgnoreDirectiveMetadata() { log.info("entering " + getName()); try { HashMap config = new HashMap(); // Make Client use remote invoker. config.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL truststore parameters in config map. config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); // Put "ignore host" directive in config map. HashMap metadata = new HashMap(); metadata.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Connect Client and make invocation. Client client = new Client(locator, config); client.connect(); client.invoke("abc", metadata); // Verify "ignore host" directive was honored. ClientInvoker clientInvoker = client.getInvoker(); assertTrue(clientInvoker instanceof TestClientInvoker); TestClientInvoker testClientInvoker = (TestClientInvoker) clientInvoker; Class[] classes = HTTPSClientInvoker.class.getDeclaredClasses(); String anyhostVerifyClassName = classes[0].getName(); assertEquals(anyhostVerifyClassName, testClientInvoker.getHostnameVerifierClassName()); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testIgnoreDirectiveConfig() { log.info("entering " + getName()); try { HashMap config = new HashMap(); // Make Client use remote invoker. config.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL truststore parameters in config map. config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); // Put "ignore host" directive in config map. config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Connect Client and make invocation. Client client = new Client(locator, config); client.connect(); client.invoke("abc"); // Verify "ignore host" directive was honored. ClientInvoker clientInvoker = client.getInvoker(); assertTrue(clientInvoker instanceof TestClientInvoker); TestClientInvoker testClientInvoker = (TestClientInvoker) clientInvoker; Class[] classes = HTTPSClientInvoker.class.getDeclaredClasses(); String anyhostVerifyClassName = classes[0].getName(); assertEquals(anyhostVerifyClassName, testClientInvoker.getHostnameVerifierClassName()); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testZZZ() { } protected String getHostName() { return "localhost"; } protected String getTransport() { return "https"; } public static class SampleInvocationHandler implements ServerInvocationHandler { private InvokerCallbackHandler callbackHandler; public SampleInvocationHandler() { } public Object invoke(InvocationRequest invocation) throws Throwable { return new Integer(0); } public void addListener(InvokerCallbackHandler callbackHandler) { log.info("entering addListener()"); this.callbackHandler = callbackHandler; try { Callback callback = new Callback(new Integer(1)); callbackHandler.handleCallback(callback); log.info("sent first callback"); } catch(Exception e) { e.printStackTrace(); } } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } public InvokerCallbackHandler getCallbackHandler() { return callbackHandler; } } public static class CallbackHandler implements InvokerCallbackHandler { private ArrayList callbacks = new ArrayList(); public CallbackHandler() { } public ArrayList getCallbacks() { return callbacks; } /** * Will take the callback and print out its values. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { log.info("Received push callback."); log.info("Received callback value of: " + callback.getCallbackObject()); log.info("Received callback server invoker of: " + callback.getServerLocator()); callbacks.add(callback); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/TestClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/Te0000644000175000017500000000377010446030573033420 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.ssl.config; import java.io.IOException; import java.net.HttpURLConnection; import java.util.Map; import javax.net.ssl.HttpsURLConnection; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; public class TestClientInvoker extends HTTPSClientInvoker { private String hostnameVerifierClassName; public TestClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public TestClientInvoker(InvokerLocator locator) { super(locator); } public String getHostnameVerifierClassName() { return hostnameVerifierClassName; } protected HttpURLConnection createURLConnection(String url, Map metadata) throws IOException { HttpsURLConnection sconn = (HttpsURLConnection) super.createURLConnection(url, metadata); hostnameVerifierClassName = sconn.getHostnameVerifier().getClass().getName(); return sconn; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/TestClientInvokerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/Te0000644000175000017500000000311210455077561033416 0ustar twernertwerner/* * 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.transport.http.ssl.config; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TestClientInvokerFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new TestClientInvoker(locator, config); } public boolean supportsSSL() { return true; } }././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/TestServerInvokerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/Te0000644000175000017500000000316610455077561033427 0ustar twernertwerner/* * 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.transport.http.ssl.config; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.coyote.CoyoteInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TestServerInvokerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException { return new CoyoteInvoker(locator, config); } public boolean supportsSSL() { return true; } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/FactoryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/config/Fa0000644000175000017500000000261310446027031033364 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.http.ssl.config; import org.jboss.test.remoting.transport.config.FactoryConfigTestCaseSSLParent; /** * * @author Ron Sigal *

          * Copyright (c) May 20, 2006 *

          */ public class FactoryConfigTestCase extends FactoryConfigTestCaseSSLParent { protected String getTransport() { return "https"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/timeout/0000755000175000017500000000000011632407034033335 5ustar twernertwerner././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/timeout/HttpsPerInvocationTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/timeout/H0000644000175000017500000000133410567444576033472 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.ssl.timeout; import java.util.Map; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.jboss.test.remoting.timeout.SSLPerInvocationTimeoutTestRoot; /** * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 2207 $ *

          * Copyright Feb 6, 2007 *

          */ public class HttpsPerInvocationTimeoutTestCase extends SSLPerInvocationTimeoutTestRoot { protected void addClientConfig(Map config) { super.addClientConfig(config); config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); } protected String getTransport() { return "https"; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/handshake/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/handshake0000755000175000017500000000000011632407034033516 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/handshake/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/handshake0000644000175000017500000001106610432245666033534 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.ssl.handshake; import org.apache.log4j.Level; 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.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import javax.net.ServerSocketFactory; import java.io.IOException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public class InvokerServerTest extends ServerTestCase implements SSLInvokerConstants { private int serverPort = port; private Connector connector = null; private static final Logger log = Logger.getLogger(InvokerServerTest.class); public void init(Map metatdata) throws Exception { if (serverPort < 0) { serverPort = TestUtil.getRandomPort(); } InvokerServerTest.log.debug("port = " + serverPort); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); connector.setInvokerLocator(locator.getLocatorURI()); ServerSocketFactory svrSocketFactory = createServerSocketFactory(); connector.setServerSocketFactory(svrSocketFactory); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected String getTransport() { return transport; } private ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; // since doing basic (using default ssl server socket factory) // need to set the system properties to the keystore and password String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); SSLSocketBuilder server = new SSLSocketBuilder(); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } private String buildLocatorURI(Map metadata) { if (metadata == null || metadata.size() == 0) { return getTransport() + "://" + host + ":" + serverPort; } else { StringBuffer uriBuffer = new StringBuffer(getTransport() + "://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 String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } protected void setUp() throws Exception { init(null); } protected void tearDown() throws Exception { if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); InvokerServerTest server = new InvokerServerTest(); try { server.setUp(); Thread.sleep(60000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/handshake/InvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/handshake0000644000175000017500000000323310535452155033526 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.ssl.handshake; 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 InvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(InvokerClientTest.class.getName(), 1, InvokerServerTest.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; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/handshake/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/handshake0000644000175000017500000001326710426161234033530 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.ssl.handshake; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants; import javax.net.ssl.HandshakeCompletedEvent; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; import java.io.UnsupportedEncodingException; import java.security.cert.Certificate; import java.util.HashMap; import java.util.Map; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public class InvokerClientTest extends TestCase implements SSLInvokerConstants, HandshakeCompletedListener { private Client client; private static final Logger log = Logger.getLogger(InvokerClientTest.class); private String cipherSuite; private Certificate[] localCerts; private Certificate[] peerCerts; public void init() { try { Map config = new HashMap(); config.put(Client.HANDSHAKE_COMPLETED_LISTENER, this); // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + port); client = new Client(locator, "mock", config); client.connect(); } catch (Exception e) { InvokerClientTest.log.error(e.getMessage(), e); } } public void testRemoteCall() throws Throwable { InvokerClientTest.log.debug("running testRemoteCall()"); InvokerClientTest.log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); if ("bar".equals(ret)) { InvokerClientTest.log.debug("PASS"); } else { InvokerClientTest.log.debug("FAILED"); } assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); assertTrue("CipherSuite = TLS_DHE_DSS_WITH_AES_128_CBC_SHA", cipherSuite.equals("TLS_DHE_DSS_WITH_AES_128_CBC_SHA")); // X509Certificate localCert = (X509Certificate) localCerts[0]; // assertTrue("LocalCert.SubjectDN = CN=unit-tests-client, OU=JBoss Inc., O=JBoss Inc., ST=Washington, C=US", // localCert.getSubjectDN().getName().equals("CN=unit-tests-client, OU=JBoss Inc., O=JBoss Inc., ST=Washington, C=US")); } protected String getTransport() { return transport; } private 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; } public void setUp() throws Exception { init(); } public void tearDown() throws Exception { if (client != null) { client.disconnect(); client = null; } } public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) { InvokerClientTest.log.info("handshakeCompleted, event=" + handshakeCompletedEvent); try { cipherSuite = handshakeCompletedEvent.getCipherSuite(); InvokerClientTest.log.info("CipherSuite: " + cipherSuite); System.out.println("CipherSuite: " + cipherSuite); localCerts = handshakeCompletedEvent.getLocalCertificates(); InvokerClientTest.log.info("LocalCertificates:"); if (localCerts != null) { for (int n = 0; n < localCerts.length; n ++) { Certificate cert = localCerts[n]; InvokerClientTest.log.info(cert); System.out.println(cert); } } InvokerClientTest.log.info("PeerCertificates:"); System.out.println("PeerCertificates:"); peerCerts = handshakeCompletedEvent.getPeerCertificates(); if (peerCerts != null) { for (int n = 0; n < peerCerts.length; n ++) { Certificate cert = peerCerts[n]; InvokerClientTest.log.info(cert); System.out.println(cert); } } SSLSession session = handshakeCompletedEvent.getSession(); String[] names = session.getValueNames(); for (int n = 0; n < names.length; n ++) { String name = names[n]; InvokerClientTest.log.info(name + "=" + session.getValue(name)); System.out.println(name + "=" + session.getValue(name)); } String sessionID = null; byte[] id = handshakeCompletedEvent.getSession().getId(); try { sessionID = new String(id, "UTF-8"); } catch (UnsupportedEncodingException e) { InvokerClientTest.log.warn("Failed to create session id using UTF-8, using default", e); sessionID = new String(id); } System.out.println("sessionId: " + sessionID); } catch (SSLPeerUnverifiedException e) { InvokerClientTest.log.error("Failed to get peer cert", e); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/multihome/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/multihome0000755000175000017500000000000011632407034033573 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/multihome/SSLHttpMultihomeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/multihome0000644000175000017500000000570611413660476033615 0ustar twernertwerner /* * 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.transport.http.ssl.multihome; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.jboss.test.remoting.transport.http.multihome.HttpMultihomeTestCase; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jan 8, 2008 *

          */ public class SSLHttpMultihomeTestCase extends HttpMultihomeTestCase { protected String getTransport() { return "https"; } protected void addExtraServerConfig(Map config) { super.addExtraServerConfig(config); 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"); } protected void addExtraClientConfig(Map config) { super.addExtraClientConfig(config); config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); 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"); } protected void addExtraCallbackConfig(Map config) { super.addExtraCallbackConfig(config); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); 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"); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/.keystorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/.keystore0000644000175000017500000001376110345206626033531 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ölibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/basic/0000755000175000017500000000000011632407034032730 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/basic/HTTPSInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/basic/HTT0000644000175000017500000002330010355142433033310 0ustar twernertwerner/* * 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.transport.http.ssl.basic; import java.io.ByteArrayInputStream; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; 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.security.SSLServerSocketFactoryService; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.coyote.ssl.RemotingSSLImplementation; import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants; import org.jboss.test.remoting.transport.web.ComplexObject; import org.w3c.dom.Document; /** * @author Tom Elrod */ public class HTTPSInvokerTestServer extends ServerTestCase implements SSLInvokerConstants { // 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 ComplexObject OBJECT_RESPONSE_VALUE = new ComplexObject(5, "dub", false); public static final ComplexObject LARGE_OBJECT_RESPONSE_VALUE = new ComplexObject(5, "dub", false, 7568); public static final String NULL_RETURN_PARAM = "return_null"; public static final String OBJECT_RETURN_PARAM = "return_object"; private Connector connector = null; public void setupServer() throws Exception { /* String locatorURI = transport + "://" + host + ":" + port; 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(); ServerSocketFactory svrSocketFactory = createServerSocketFactory(); HTTPSServerInvoker httpsSvrInvoker = (HTTPSServerInvoker) connector.getServerInvoker(); httpsSvrInvoker.setServerSocketFactory(svrSocketFactory); HTTPSInvokerTestServer.SampleInvocationHandler invocationHandler = new HTTPSInvokerTestServer.SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); connector.start(); */ MBeanServer server = MBeanServerFactory.createMBeanServer(); // create and register socket server factory service ServerSocketFactoryMBean serverSocketFactoryMBean = createServerSocketFactoryMBean(); String socketFactoryObjName = "test:type=serversocketfactory"; server.registerMBean(serverSocketFactoryMBean, new ObjectName(socketFactoryObjName)); connector = new Connector(); server.registerMBean(connector, new ObjectName("test:type=connector,transport=coyote")); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + RemotingSSLImplementation.class.getName() + ""); buf.append("" + socketFactoryObjName + ""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); buf.append(" " + HTTPSInvokerTestServer.SampleInvocationHandler.class.getName() + "\n"); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); //connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.start(); } private ServerSocketFactoryMBean createServerSocketFactoryMBean() throws Exception { ServerSocketFactoryMBean serverSocketFactoryMBean = null; // since doing basic (using default ssl server socket factory) // need to set the system properties to the keystore and password String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); SSLSocketBuilder socketBuilder = new SSLSocketBuilder(); SSLServerSocketFactoryService sslServerSocketFactoryService = new SSLServerSocketFactoryService(); sslServerSocketFactoryService.setSSLSocketBuilder(socketBuilder); sslServerSocketFactoryService.start(); serverSocketFactoryMBean = sslServerSocketFactoryService; return serverSocketFactoryMBean; } /* private ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; // since doing basic (using default ssl server socket factory) // need to set the system properties to the keystore and password String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); SSLSocketBuilder server = new SSLSocketBuilder(); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } */ protected void setUp() throws Exception { setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { HTTPSInvokerTestServer server = new HTTPSInvokerTestServer(); try { server.setUp(); Thread.currentThread().sleep(600000); } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); if(NULL_RETURN_PARAM.equals(invocation.getParameter())) { return null; } else if(invocation.getParameter() instanceof ComplexObject) { ComplexObject obj = (ComplexObject) invocation.getParameter(); if(obj.getSize() > 1024) { return LARGE_OBJECT_RESPONSE_VALUE; } else { return OBJECT_RESPONSE_VALUE; } } else { // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } } /** * 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 } } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/basic/HTTPSInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/basic/HTT0000644000175000017500000000327110535452155033322 0ustar twernertwerner/* * 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.transport.http.ssl.basic; 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 HTTPSInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPSInvokerTestClient.class.getName(), 1, HTTPSInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/basic/HTTPSInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/basic/HTT0000644000175000017500000000765510433770344033334 0ustar twernertwerner/* * 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.transport.http.ssl.basic; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.jboss.remoting.transport.web.WebUtil; import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants; import org.jboss.test.remoting.transport.web.ComplexObject; import java.util.HashMap; import java.util.Map; import java.util.Properties; /** * @author Tom Elrod */ public class HTTPSInvokerTestClient extends TestCase implements SSLInvokerConstants { public void testInvocationWithHeaders() throws Exception { Client remotingClient = null; try { // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); String locatorURI = transport + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "POST"); Properties headerProps = new Properties(); headerProps.put("SOAPAction", "http://www.example.com/fibonacci"); headerProps.put("Content-type", "application/soap+xml"); metadata.put("HEADER", headerProps); // set this property so does not do host verification metadata.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); Object response = null; // test with null return expected response = remotingClient.invoke(HTTPInvokerTestServer.NULL_RETURN_PARAM, metadata); assertNull(response); response = remotingClient.invoke("Do something", metadata); assertEquals(HTTPInvokerTestServer.RESPONSE_VALUE, response); // test with small object headerProps.put("Content-type", WebUtil.BINARY); response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata); assertEquals(HTTPSInvokerTestServer.OBJECT_RESPONSE_VALUE, response); // test with large object response = remotingClient.invoke(new ComplexObject(2, "foo", true, 8000), metadata); assertEquals(HTTPSInvokerTestServer.LARGE_OBJECT_RESPONSE_VALUE, response); } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/0000755000175000017500000000000011632407034033161 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/HTTPSInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/HT0000644000175000017500000002401710435662220033423 0ustar twernertwerner/* * 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.transport.http.ssl.custom; import java.io.ByteArrayInputStream; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; 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.security.SSLServerSocketFactoryService; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.coyote.ssl.RemotingSSLImplementation; import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants; import org.jboss.test.remoting.transport.web.ComplexObject; import org.w3c.dom.Document; /** * @author Tom Elrod */ public class HTTPSInvokerTestServer extends ServerTestCase implements SSLInvokerConstants { // 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 ComplexObject OBJECT_RESPONSE_VALUE = new ComplexObject(5, "dub", false); public static final ComplexObject LARGE_OBJECT_RESPONSE_VALUE = new ComplexObject(5, "dub", false, 7568); public static final String NULL_RETURN_PARAM = "return_null"; public static final String OBJECT_RETURN_PARAM = "return_object"; private Connector connector = null; public void setupServer() throws Exception { /* String locatorURI = transport + "://" + host + ":" + port; 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(); ServerSocketFactory svrSocketFactory = createServerSocketFactory(); HTTPSServerInvoker httpsSvrInvoker = (HTTPSServerInvoker) connector.getServerInvoker(); httpsSvrInvoker.setServerSocketFactory(svrSocketFactory); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); connector.start(); */ MBeanServer server = MBeanServerFactory.createMBeanServer(); // create and register socket server factory service ServerSocketFactoryMBean serverSocketFactoryMBean = createServerSocketFactoryMBean(); String socketFactoryObjName = "test:type=serversocketfactory"; server.registerMBean(serverSocketFactoryMBean, new ObjectName(socketFactoryObjName)); connector = new Connector(); server.registerMBean(connector, new ObjectName("test:type=connector,transport=coyote")); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + RemotingSSLImplementation.class.getName() + ""); buf.append("" + socketFactoryObjName + ""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); buf.append(" " + HTTPSInvokerTestServer.SampleInvocationHandler.class.getName() + "\n"); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); //connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.start(); } private ServerSocketFactoryMBean createServerSocketFactoryMBean() throws Exception { ServerSocketFactoryMBean serverSocketFactoryMBean = null; SSLSocketBuilder socketBuilder = new SSLSocketBuilder(); socketBuilder.setUseSSLServerSocketFactory(false); socketBuilder.setSecureSocketProtocol("SSL"); socketBuilder.setKeyStoreAlgorithm("SunX509"); socketBuilder.setKeyStoreType("JKS"); String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); socketBuilder.setKeyStoreURL(keyStoreFilePath); socketBuilder.setKeyStorePassword("unit-tests-server"); /* * This is optional since if not set, will use * the key store password (and are the same in this case) */ //server.setKeyPassword("unit-tests-server"); SSLServerSocketFactoryService sslServerSocketFactoryService = new SSLServerSocketFactoryService(); sslServerSocketFactoryService.setSSLSocketBuilder(socketBuilder); sslServerSocketFactoryService.start(); serverSocketFactoryMBean = sslServerSocketFactoryService; return serverSocketFactoryMBean; } /* private ServerSocketFactory createServerSocketFactory() throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException { ServerSocketFactory serverSocketFactory = null; SSLSocketBuilder server = new SSLSocketBuilder(); server.setUseSSLServerSocketFactory(false); server.setSecureSocketProtocol("SSL"); server.setKeyManagementAlgorithm("SunX509"); server.setKeyStoreType("JKS"); String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); server.setKeyStoreURL(keyStoreFilePath); server.setKeyStorePassword("unit-tests-server"); // This is optional since if not set, will use // the key store password (and are the same in this case) //server.setKeyPassword("unit-tests-server"); serverSocketFactory = server.createSSLServerSocketFactory(); return serverSocketFactory; } */ protected void setUp() throws Exception { setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { HTTPSInvokerTestServer server = new HTTPSInvokerTestServer(); try { server.setUp(); Thread.currentThread().sleep(600000); } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); if(NULL_RETURN_PARAM.equals(invocation.getParameter())) { return null; } else if(invocation.getParameter() instanceof ComplexObject) { ComplexObject obj = (ComplexObject) invocation.getParameter(); if(obj.getSize() > 1024) { return LARGE_OBJECT_RESPONSE_VALUE; } else { return OBJECT_RESPONSE_VALUE; } } else { // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } } /** * 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 } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/HTTPSInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/HT0000644000175000017500000000327210535452155033430 0ustar twernertwerner/* * 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.transport.http.ssl.custom; 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 HTTPSInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPSInvokerTestClient.class.getName(), 1, HTTPSInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/CustomHTTPSInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/Cu0000644000175000017500000000625610435742646033477 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.ssl.custom; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.web.WebUtil; import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants; import org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestServer; import org.jboss.test.remoting.transport.web.ComplexObject; import java.util.HashMap; import java.util.Map; import java.util.Properties; /** * @author Tom Elrod */ public class CustomHTTPSInvokerTestClient extends TestCase implements SSLInvokerConstants { public void testInvocation() throws Exception { Client remotingClient = null; try { Map config = new HashMap(); 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"); String locatorURI = transport + "://" + host + ":" + port; 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, config); remotingClient.connect(); Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "POST"); Properties headerProps = new Properties(); headerProps.put("SOAPAction", "http://www.example.com/fibonacci"); headerProps.put("Content-type", "application/soap+xml"); metadata.put("HEADER", headerProps); Object response = null; // test with null return expected response = remotingClient.invoke(HTTPInvokerTestServer.NULL_RETURN_PARAM, metadata); assertNull(response); response = remotingClient.invoke("Do something", metadata); assertEquals(HTTPInvokerTestServer.RESPONSE_VALUE, response); // test with small object headerProps.put("Content-type", WebUtil.BINARY); response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata); assertEquals(org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestServer.OBJECT_RESPONSE_VALUE, response); // test with large object response = remotingClient.invoke(new ComplexObject(2, "foo", true, 8000), metadata); assertEquals(HTTPSInvokerTestServer.LARGE_OBJECT_RESPONSE_VALUE, response); } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/HTTPSInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/custom/HT0000644000175000017500000000625010435742646033435 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.ssl.custom; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.web.WebUtil; import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; import org.jboss.test.remoting.transport.http.ssl.SSLInvokerConstants; import org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestServer; import org.jboss.test.remoting.transport.web.ComplexObject; import java.util.HashMap; import java.util.Map; import java.util.Properties; /** * @author Tom Elrod */ public class HTTPSInvokerTestClient extends TestCase implements SSLInvokerConstants { public void testInvocation() throws Exception { Client remotingClient = null; try { Map config = new HashMap(); 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"); String locatorURI = transport + "://" + host + ":" + port; 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, config); remotingClient.connect(); Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "POST"); Properties headerProps = new Properties(); headerProps.put("SOAPAction", "http://www.example.com/fibonacci"); headerProps.put("Content-type", "application/soap+xml"); metadata.put("HEADER", headerProps); Object response = null; // test with null return expected response = remotingClient.invoke(HTTPInvokerTestServer.NULL_RETURN_PARAM, metadata); assertNull(response); response = remotingClient.invoke("Do something", metadata); assertEquals(HTTPInvokerTestServer.RESPONSE_VALUE, response); // test with small object headerProps.put("Content-type", WebUtil.BINARY); response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata); assertEquals(org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestServer.OBJECT_RESPONSE_VALUE, response); // test with large object response = remotingClient.invoke(new ComplexObject(2, "foo", true, 8000), metadata); assertEquals(HTTPSInvokerTestServer.LARGE_OBJECT_RESPONSE_VALUE, response); } catch(Throwable throwable) { throw new Exception(throwable); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfac0000755000175000017500000000000011632407034033532 5ustar twernertwerner././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfac0000644000175000017500000000270211413660476033545 0ustar twernertwerner /* * 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.transport.http.ssl.socketfactory; import org.jboss.test.remoting.socketfactory.SSLSocketFactoryClassNameTestRoot; /** * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jul 18, 2008 *

          */ public class SSLSocketFactoryClassNameTestCase extends SSLSocketFactoryClassNameTestRoot { protected String getTransport() { return "https"; } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory/HttpsCreationListenerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfac0000644000175000017500000000261710553067761033554 0ustar twernertwerner/* * 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.transport.http.ssl.socketfactory; import org.jboss.test.remoting.socketfactory.SSLCreationListenerTestRoot; /** * @author Ron Sigal * @version $Revision: 1846 $ *

          * Copyright Jan 11, 2007 *

          */ public class HttpsCreationListenerTestCase extends SSLCreationListenerTestRoot { protected String getTransport() { return "https"; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/shutdown/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/shutdown/0000755000175000017500000000000011632407035033523 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/shutdown/HTTPSShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/shutdown/0000644000175000017500000000451310555056447033542 0ustar twernertwerner/* * 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.transport.http.ssl.shutdown; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.jboss.test.remoting.shutdown.ShutdownTestParent; /** * @author Ron Sigal * @version $Revision: 1961 $ *

          * Copyright Jan 20, 2007 *

          */ public class HTTPSShutdownTestCase extends ShutdownTestParent { protected String getTransport() { return "https"; } protected String getJVMArguments() { String args = ""; String keyStoreFilePath = getClass().getResource("../.keystore").getFile(); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); String log4jFilePath = getClass().getResource("../../../../shutdown/log4j.xml").getFile(); System.out.println("log4jFilePath: " + log4jFilePath); args += "-Djavax.net.ssl.keyStore=" + keyStoreFilePath + " "; args += "-Djavax.net.ssl.keyStorePassword=unit-tests-server "; args += "-Djavax.net.ssl.trustStore=" + trustStoreFilePath + " "; args += "-Djavax.net.ssl.trustStorePassword=unit-tests-client "; args += "-Dlog4j.configuration=file:" + log4jFilePath; return args; } protected String getClientArgs() { return HTTPSClientInvoker.IGNORE_HTTPS_HOST + "=true&"; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/clientaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/clientadd0000755000175000017500000000000011632407034033517 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/clientaddress/HttpsClientAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/clientadd0000644000175000017500000000266210720753477033543 0ustar twernertwernerpackage org.jboss.test.remoting.transport.http.ssl.clientaddress; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class HttpsClientAddressTestCase extends ClientAddressTestParent { protected String getTransport() { return "https"; } protected void addExtraServerConfig(Map config) { 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"); } protected void addExtraClientConfig(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(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); } protected void addExtraCallbackConfig(Map config) { addExtraClientConfig(config); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/0000755000175000017500000000000011632407034033276 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/H0000644000175000017500000000473211413660476033426 0ustar twernertwerner/* * 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.transport.http.ssl.marshal; import java.util.Map; import org.apache.log4j.Logger; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.jboss.test.remoting.transport.http.marshal.HttpContentTypeTestCase; /* * Unit tests for JBREM-1145 * * @author Ron Sigal * @version *

          * Copyright Aug 19, 2009 *

          */ public class HttpsContentTypeTestCase extends HttpContentTypeTestCase { private static Logger log = Logger.getLogger(HttpsContentTypeTestCase.class); public void setUp() throws Exception { if (firstTime) { String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); log.info("keystore: " + keyStoreFilePath); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); log.info("truststore: " + trustStoreFilePath); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client"); } super.setUp(); } protected String getTransport() { return "https"; } protected void addExtraClientConfig(Map config) { config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/StaticLoggerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/ssl/StaticLog0000644000175000017500000001076610672116151033475 0ustar twernertwerner/* * 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.transport.http.ssl; 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.PortUtil; /** * Unit test for JBREM-750. * * @author Ron Sigal * @version $Revision: 2762 $ *

          * Copyright Sep 12, 2007 *

          */ public class StaticLoggerTestCase extends TestCase { private static Logger log = Logger.getLogger(StaticLoggerTestCase.class); private static boolean firstTime = true; private InvokerLocator locator; 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 org.jboss.remoting.transport.http.HTTPClientInvoker.log is * declared static so that it is available in HTTPClientInvoker and * HTTPSClientInvoker constructors. */ public void testStaticLogger() throws Throwable { log.info("entering " + getName()); // Create client. String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(locator, config); // client.connect() will fail because of missing truststore url. If // HTTPClientInvoker.log is not static, attempt to log error message will // throw NullPointerException. log.info("###############################################################"); log.info("### Expect logged ERROR message for java.io.IOException: ###"); log.info("### \"Error creating SSL Socket Factory for client invoker.\" ###"); log.info("########################################E######################"); client.connect(); log.info(getName() + " PASSES"); } protected String getTransport() { return "https"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable {return null;} 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/transport/http/keep_alive/0000755000175000017500000000000011632407035033153 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/NoKeepAliveHTTPInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/No0000644000175000017500000000376610744612341033467 0ustar twernertwerner/* * 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.transport.http.keep_alive; import java.util.Properties; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.http.HTTPInvokerConstants; import org.jboss.test.remoting.transport.web.WebInvokerTestClient; /** * @author Tom Elrod */ public class NoKeepAliveHTTPInvokerTestClient extends WebInvokerTestClient implements HTTPInvokerConstants { public String getLocatorURI() { String bindAddr = System.getProperty("jrunit.bind_addr", host); String locatorURI = transport + "://" + bindAddr + ":" + port; String metadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { locatorURI = locatorURI + "/?" + metadata; } return locatorURI; } protected void addHeaders(Properties headerProps) { // tests turning off the keep alive headerProps.put("Connection", "close"); } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/St0000644000175000017500000000364511413660476033503 0ustar twernertwerner /* * 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.transport.http.keep_alive; import java.util.HashMap; import java.util.Map; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Apr 22, 2008 *

          */ public class StressHTTPInvokerTestServer extends HTTPInvokerTestServer { public void setUp() throws Exception { serverPort = 8888; Map metadata = new HashMap(); String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(newMetadata != null && newMetadata.length() > 0) { metadata.putAll(PerformanceServerTest.parseMetadataString(newMetadata)); } metadata.put("maxProcessors", "2000"); init(metadata); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/St0000644000175000017500000000557511011735302033470 0ustar twernertwerner/* * 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.transport.http.keep_alive; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; /** * @author Tom Elrod */ public class StressHTTPInvokerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(StressHTTPInvokerTestClient.class.getName(), 1, StressHTTPInvokerTestServer.class.getName()); } protected Level getTestHarnessLogLevel() { return Level.INFO; } 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. * * @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; } /** * Will get used in server's InvokerLocator. */ protected String getServerJVMArguments() { return "-D" + REMOTING_METADATA + "=maxThreads=500"; } /** * Will get used in client's InvokerLccator. */ protected String getClientJVMArguments() { return "-D" + REMOTING_METADATA + "=maxThreads=500"; } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/NoKeepAliveHTTPInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/No0000644000175000017500000000277210535452155033466 0ustar twernertwerner/* * 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.transport.http.keep_alive; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.jboss.test.remoting.transport.http.HTTPInvokerTestServer; /** * @author Tom Elrod */ public class NoKeepAliveHTTPInvokerTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(NoKeepAliveHTTPInvokerTestClient.class.getName(), 1, HTTPInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/StressHTTPInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/keep_alive/St0000644000175000017500000000447111012357316033470 0ustar twernertwerner/* * 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.transport.http.keep_alive; import org.jboss.remoting.transport.http.HTTPClientInvoker; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.http.HTTPInvokerConstants; import org.jboss.test.remoting.transport.web.WebInvokerTestClient; /** * @author Tom Elrod */ public class StressHTTPInvokerTestClient extends WebInvokerTestClient implements HTTPInvokerConstants { public String getLocatorURI() { String bindAddr = System.getProperty("jrunit.bind_addr", host); String locatorURI = transport + "://" + bindAddr + ":" + port; locatorURI += "/?" + HTTPClientInvoker.NUMBER_OF_CALL_ATTEMPTS + "=3"; String metadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { locatorURI = locatorURI + "&" + metadata; } log.debug("connecting to: " + locatorURI); return locatorURI; } public void testPostInvocation() throws Exception { Thread.sleep(5000); for(int x = 0; x < 1000; x++) { // if ((x + 1) % 100 == 0) log.info("loop: " + (x + 1)); log.info("loop: " + (x + 1)); super.testPostInvocation(); } Thread.sleep(5000); } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/NullInputStreamTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/NullInputStre0000644000175000017500000003174111413660476033577 0ustar twernertwerner/* * 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.transport.http; import java.io.DataOutputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; 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.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.marshal.UnMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.http.HTTPClientInvoker; import org.jboss.remoting.transport.http.WebServerError; /** * Unit test for JBREM-1046. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Oct 27, 2008 *

          */ public class NullInputStreamTestCase extends TestCase { private static Logger log = Logger.getLogger(NullInputStreamTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected Client client; 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); } TestUnMarshaller.clear(); } public void tearDown() { if (client != null) { client.disconnect(); } if (connector != null) { connector.destroy(); } } /** * Tests default behavior with POST method. */ public void testDefaultBehaviorPost() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); boolean ok = false; HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("TYPE", "POST"); try { log.info("response: " + makeInvocation(config, metadata)); fail("expected WebServerError"); } catch (WebServerError e) { log.info("received expected WebServerError"); ok = true; } assertTrue(ok); assertTrue(TestUnMarshaller.enteredRead); assertTrue(TestUnMarshaller.streamIsNull); log.info(getName() + " PASSES"); } /** * Tests default behavior with HEAD method. */ public void testDefaultBehaviorHead() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); boolean ok = false; HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("TYPE", "HEAD"); try { log.info("response: " + makeInvocation(config, metadata)); fail("expected WebServerError"); } catch (WebServerError e) { log.info("received expected WebServerError"); ok = true; } assertTrue(ok); assertTrue(TestUnMarshaller.enteredRead); assertTrue(TestUnMarshaller.streamIsNull); log.info(getName() + " PASSES"); } /** * Tests behavior with unmarshallNullStream == true and with POST method. */ public void testUnmarshalNullStreamTruePost() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); boolean ok = false; HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "true"); HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("TYPE", "POST"); try { log.info("response: " + makeInvocation(config, metadata)); fail("expected WebServerError"); } catch (WebServerError e) { log.info("received expected WebServerError"); ok = true; } assertTrue(ok); assertTrue(TestUnMarshaller.enteredRead); assertTrue(TestUnMarshaller.streamIsNull); log.info(getName() + " PASSES"); } /** * Tests behavior with unmarshallNullStream == true and with HEAD method. */ public void testUnmarshalNullStreamTrueHead() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); boolean ok = false; HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "true"); HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("TYPE", "HEAD"); try { log.info("response: " + makeInvocation(config, metadata)); fail("expected WebServerError"); } catch (WebServerError e) { log.info("received expected WebServerError"); ok = true; } assertTrue(ok); assertTrue(TestUnMarshaller.enteredRead); assertTrue(TestUnMarshaller.streamIsNull); log.info(getName() + " PASSES"); } /** * Tests behavior with unmarshallNullStream == false and with POST method. */ public void testUnmarshalNullStreamFalsePost() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); boolean ok = false; HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "false"); HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("TYPE", "POST"); try { log.info("response: " + makeInvocation(config, metadata)); fail("expected WebServerError"); } catch (WebServerError e) { log.info("received expected WebServerError"); ok = true; } assertTrue(ok); assertFalse(TestUnMarshaller.enteredRead); log.info(getName() + " PASSES"); } /** * Tests behavior with unmarshallNullStream == false and with HEAD method. */ public void testUnmarshalNullStreamFalseHead() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); boolean ok = false; HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "false"); HashMap metadata = new HashMap(); metadata.put(Client.RAW, "true"); metadata.put("TYPE", "HEAD"); try { log.info("response: " + makeInvocation(config, metadata)); fail("expected WebServerError"); } catch (WebServerError e) { log.info("received expected WebServerError"); ok = true; } assertTrue(ok); assertFalse(TestUnMarshaller.enteredRead); log.info(getName() + " PASSES"); } protected Object makeInvocation(HashMap config, HashMap metadata) throws Throwable { // Create client. locatorURI = "http://" + host + ":" + port; locatorURI += "/?unmarshaller=" + TestUnMarshaller.class.getName(); log.info("connecting to " + locatorURI); InvokerLocator clientLocator = new InvokerLocator(locatorURI); Client client = new Client(clientLocator, config); client.connect(); log.info("client is connected"); try { return client.invoke("abc", metadata); } catch (CannotConnectException e) { log.info("exception thrown during invocation: " + e.getMessage()); return "CannotConnectException: ok"; } } protected void setupServer() throws Exception { log.info("setupServer()"); InetAddress localHost = InetAddress.getLocalHost(); final ServerSocket ss = new ServerSocket(0, 100, localHost); host = localHost.getHostAddress(); port = ss.getLocalPort(); new Thread() { public void run() { try { Socket s = ss.accept(); InputStreamReader ir = new InputStreamReader(s.getInputStream()); char[] cbuf = new char[1024]; int len = ir.read(cbuf); log.info("Request:"); System.out.println(); System.out.println(String.copyValueOf(cbuf, 0, len)); System.out.println(); DataOutputStream dos = new DataOutputStream(s.getOutputStream()); dos.writeBytes("HTTP/1.1 500 error" + "\r\n"); dos.writeBytes("Server: testServer"); dos.writeBytes("Content-Type: text/html" + "\r\n"); dos.writeBytes("Content-Length: 0\r\n"); dos.writeBytes("Connection: close\r\n"); dos.writeBytes("\r\n"); ir.close(); dos.close(); s.close(); ss.close(); } catch (EOFException e1) { log.info("end of file"); } catch (Exception e2) { log.error("error", e2); } } }.start(); log.info("started server"); } 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) {} } public static class TestUnMarshaller extends HTTPUnMarshaller { /** The serialVersionUID */ private static final long serialVersionUID = 1L; public static boolean enteredRead; public static boolean streamIsNull; public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { enteredRead = true; streamIsNull = (inputStream == null); log.info("entered TestUnMarshaller.read()"); if (inputStream != null) { return super.read(inputStream, metadata, version); } else { return null; } } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { HTTPUnMarshaller unmarshaller = new TestUnMarshaller(); unmarshaller.setClassLoader(getClassLoader()); return unmarshaller; } public static void clear() { enteredRead = false; streamIsNull = false; } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/marshal/0000755000175000017500000000000011632407034032475 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpC0000644000175000017500000003503111413660476033454 0ustar twernertwerner/* * 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.transport.http.marshal; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; 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.InvokerCallbackHandler; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.http.HTTPMetadataConstants; /** * Unit tests for JBREM-1145. * * @author Ron Sigal * @version *

          * Copyright Aug 17, 2009 *

          */ public class HttpContentTypeTestCase extends TestCase { private static Logger log = Logger.getLogger(HttpContentTypeTestCase.class); protected 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.TRACE); 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); } TestMarshaller.marshallers.clear(); TestUnMarshaller.unmarshallers.clear(); MarshalFactory.addMarshaller("test", new TestMarshaller(), new TestUnMarshaller()); } public void tearDown() { } public void testOrdinaryInvocationDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, false); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); log.info("connecting to: " + serverLocator); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected to " + serverLocator); // Do invocation. Object o = client.invoke("abc"); // Show that an InvocationResponse was incorrectly returned as a Strin.. assertTrue(o instanceof String); String result = (String) o; assertTrue(result.indexOf("org.jboss.remoting.InvocationResponse") >= 0); // Check remoting content type handling. validateOrdinaryInvocation(client); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testOrdinaryInvocationRemotingContentTypeFalse() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, false); // 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 to " + serverLocator); // Do invocation. Object o = client.invoke("abc"); // Show that an InvocationResponse was incorrectly returned as a String. assertTrue(o instanceof String); String result = (String) o; assertTrue(result.indexOf("org.jboss.remoting.InvocationResponse") >= 0); // Check remoting content type handling. validateOrdinaryInvocation(client); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testOrdinaryInvocationRemotingContentTypeTrue() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true); // 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 to " + serverLocator); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Check remoting content type handling. validateOrdinaryInvocation(client); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testRawStringMessageDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, false); // 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 to " + serverLocator); // Test connections. Map metadata = new HashMap(); metadata.put(Client.RAW, "true"); assertEquals("abc", client.invoke("abc", metadata)); log.info("connection is good"); // Check remoting content type handling. validateRawStringMessage(client); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testRawStringMessageRemotingContentTypeFalse() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, false); // 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 to " + serverLocator); // Test connections. Map metadata = new HashMap(); metadata.put(Client.RAW, "true"); assertEquals("abc", client.invoke("abc", metadata)); log.info("connection is good"); // Check remoting content type handling. validateRawStringMessage(client); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testRawStringMessageRemotingContentTypeTrue() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true); // 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 to " + serverLocator); // Test connections. Map metadata = new HashMap(); metadata.put(Client.RAW, "true"); assertEquals("abc", client.invoke("abc", metadata)); log.info("connection is good"); // Check remoting content type handling. validateRawStringMessage(client); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected void validateOrdinaryInvocation(Client client) throws Throwable { assertEquals(6, TestMarshaller.marshallers.size()); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type); assertEquals(4, TestUnMarshaller.unmarshallers.size()); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type); } protected void validateRawStringMessage(Client client) throws Throwable { assertEquals(6, TestMarshaller.marshallers.size()); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type); assertEquals(4, TestUnMarshaller.unmarshallers.size()); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type); } protected String getTransport() { return "http"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean addUseRemotingContentType, boolean useRemotingContentType) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?datatype=test"; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "&" + metadata; } if (addUseRemotingContentType) { locatorURI += "&useRemotingContentType=" + useRemotingContentType; } 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 { Map responseMap = invocation.getReturnPayload(); responseMap.put(HTTPMetadataConstants.CONTENTTYPE, "text/html"); return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } public static class TestMarshaller extends HTTPMarshaller { public static ArrayList marshallers = new ArrayList(); private static final long serialVersionUID = -7528137229006015488L; public String type; public void write(Object dataObject, OutputStream output, int version) throws IOException { log.info(this + " writing " + dataObject); type = (dataObject instanceof String) ? HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING : HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING; super.write(dataObject, output, version); } public Marshaller cloneMarshaller() throws CloneNotSupportedException { TestMarshaller marshaller = new TestMarshaller(); marshallers.add(marshaller); log.info("returning " + marshaller); return marshaller; } } public static class TestUnMarshaller extends HTTPUnMarshaller { public static ArrayList unmarshallers = new ArrayList(); private static final long serialVersionUID = -6422222480047910351L; public String type; public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE); if (o instanceof List) { type = (String) ((List) o).get(0); } else if (o instanceof String) { type = (String) o; } else { log.warn(this + " unrecognized remotingContentType: " + o); } o = super.read(inputStream, metadata, version); log.info(this + " read " + o); return o; } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { TestUnMarshaller unmarshaller = new TestUnMarshaller(); unmarshallers.add(unmarshaller); unmarshaller.setClassLoader(this.customClassLoader); log.info("returning " + unmarshaller); return unmarshaller; } } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/HTTPInvokerCo0000644000175000017500000000236110355142433033372 0ustar twernertwerner/* * 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.transport.http; /** * @author Tom Elrod */ public interface HTTPInvokerConstants { // Default locator values String transport = "http"; String host = "localhost"; int port = 8888; }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/headers/0000755000175000017500000000000011632407035032462 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/headers/ResponseCodeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/http/headers/Respo0000644000175000017500000001611410722220463033475 0ustar twernertwerner/* * 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.transport.http.headers; import java.net.InetAddress; import java.util.Collection; import java.util.HashMap; 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.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.http.HTTPMetadataConstants; /** * Unit test for JBREM-728. * * @author Ron Sigal *

          * Copyright (c) November 24, 2007 *

          * */ public class ResponseCodeTestCase extends TestCase { private static Logger log = Logger.getLogger(ResponseCodeTestCase.class); private static boolean firstTime = true; protected static String RESPONSE_KEY = "responseKey"; protected static String RESPONSE_VALUE = "responseValue"; protected static String RETURN_RESPONSE_HEADER = "returnResponseHeader"; 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 testResponseHeaders() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator1, clientConfig); client.connect(); log.info("client is connected"); // Test connections. HashMap metadata = new HashMap(); assertEquals(RETURN_RESPONSE_HEADER, client.invoke(RETURN_RESPONSE_HEADER, metadata)); log.info("connection is good"); log.info("metadata: " + metadata); // Verify that all entries in the HTTPMetadataConstants.RESPONSE_HEADERS value // also appear in metadata map. Object o = metadata.remove(HTTPMetadataConstants.RESPONSE_HEADERS); assertTrue(o instanceof Map); Map responseHeaders = (Map) o; Set responseHeadersEntries = responseHeaders.entrySet(); Set metadataEntries = metadata.entrySet(); Iterator it = responseHeadersEntries.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); log.info("entry: " + entry); if (entry.getKey() == null) continue; assertTrue("metadata does not contain entry " + entry, metadataEntries.contains(entry)); } // Verify response map entry generated in invocation handler // was added as a response header. assertTrue(responseHeaders.keySet().contains(RESPONSE_KEY)); assertTrue(responseHeaders.get(RESPONSE_KEY) instanceof Collection); List responses = (List) responseHeaders.get(RESPONSE_KEY); assertTrue(responses.size() == 1); assertEquals(RESPONSE_VALUE, responses.get(0)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } 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 { if (RETURN_RESPONSE_HEADER.equals(invocation.getParameter())) invocation.getReturnPayload().put(RESPONSE_KEY, RESPONSE_VALUE); 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/transport/local/0000755000175000017500000000000011632407040031156 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/LocalInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/LocalInvoker0000644000175000017500000002416110455077561033512 0ustar twernertwerner/* * 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.transport.local; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.apache.log4j.Level; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.rmi.server.UID; /** * Test for the Local client invoker to verify will call directly on * local server invoker. * * @author Tom Elrod */ public class LocalInvokerTestCase extends TestCase { private String sessionId = new UID().toString(); private Client client; private String transport = "socket"; private int port = -1; private InvokerLocator locator; private static final String NAME = "LocalInvokerTest.class"; private static final Logger log = Logger.getLogger(LocalInvokerTestCase.class); public LocalInvokerTestCase() { super(NAME); } public LocalInvokerTestCase(String name) { super(name); } public LocalInvokerTestCase(String transport, int port) { super(NAME); this.transport = transport; this.port = port; } public void init() { try { client = new Client(locator, "mock"); client.connect(); } catch(Exception e) { log.error(e.getMessage(), e); } } /** * Create and initalize local server * * @param port * @return * @throws Exception */ private InvokerLocator initServer(int port) throws Exception { if(port < 0) { port = TestUtil.getRandomPort(); } log.debug("port = " + port); // InvokerRegistry.registerInvoker("mock", MockClientInvoker.class, MockServerInvoker.class); Connector connector = new Connector(); InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append("\n"); buf.append(" org.jboss.test.remoting.transport.mock.MockServerInvocationHandler\n"); buf.append("\n"); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); //connector.create(); connector.start(); this.port = port; this.locator = connector.getLocator(); return locator; } public void testLocalInvoke() throws Throwable { try { log.debug("running testLocalInvoke()"); InvokerLocator locator = initServer(-1); init(); // MockInvokerCallbackHandler handler = new MockInvokerCallbackHandler(sessionId); log.debug("client.getInvoker()" + client.getInvoker()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testLocalInvoke() invocation of foo.", "bar".equals(ret)); /* client.addListener(handler, locator); // invoke which should cause callback ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(3000); log.debug("done sleeping."); boolean callbackPerformed = handler.isCallbackReceived(); log.debug("callbackPerformed after adding listener is " + callbackPerformed); assertTrue("Result of runPushCallbackTest() failed since did not get callback.", callbackPerformed); handler.isCallbackReceived(false); // Can now call direct on client //ret = makeInvocation("removeListener", null); client.removeListener(handler); // shouldn't get callback now since removed listener ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(2000); log.debug("done sleeping."); callbackPerformed = handler.isCallbackReceived(); log.debug("callbackPerformed after removing listener is " + callbackPerformed); assertTrue("Result of runPushCallbackTest() failed since did get callback " + "but have been removed as listener.", !callbackPerformed); */ } finally { if(client != null) { client.disconnect(); } } } /** * Tests simple invocation and pull callbacks. Meaning will add a listener and * will then have to get the callbacks from the server. * @throws Throwable */ /* public void testPullCallback() throws Throwable { try { log.debug("running testPullCallback()"); init(); // should be null by default, since don't have connector started, but setting anyway //client.setClientLocator(null); MockInvokerCallbackHandler handler = new MockInvokerCallbackHandler(sessionId); // simple invoke, should return bar Object ret = makeInvocation("bar", "foo"); assertTrue("Result of runPullCallbackTest() invocation of bar.", "foo".equals(ret)); client.addListener(handler); // invoke which should cause callback on server side ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(2000); ret = client.getCallbacks(); log.debug("getCallbacks returned " + ret); log.debug("should have something."); assertTrue("Result of runPullCallbackTest() getCallbacks() after add listener.", ret != null); // can now call directly on client //ret = makeInvocation("removeListener", null); client.removeListener(handler); ret = makeInvocation("getCallbacks", null); log.debug("getCallbacks returned " + ret); log.debug("should have been empty."); assertTrue("Result of runPullCallbackTest() getCallbacks() after remove listener.", ret == null); } finally { if(client != null) { client.disconnect(); client = null; } } } */ /** * Tests complex invocation to get object containing array of complex objects. * * @throws Throwable */ /* public void testArrayReturn() throws Throwable { try { init(); // simple invoke, should return bar Object ret = makeInvocation("testComplexReturn", null); ComplexReturn complexRet = (ComplexReturn)ret; MockTest[] mockTests = complexRet.getMockTests(); assertTrue("ComplexReturn's array should contain 2 items", 2 == mockTests.length); for(int x = 0; x < mockTests.length; x++) { System.err.println(mockTests[x]); MockTest test = mockTests[x]; assertNotNull("MockTest should not be null", test); } // assertTrue("Result of runPullCallbackTest() invocation of bar.", // "foo".equals(ret)); } finally { if(client != null) { client.disconnect(); client = null; } } } */ private 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; } public static Test suite() { return new TestSuite(LocalInvokerTestCase.class); } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); LocalInvokerTestCase client = null; if(args.length == 2) { String transport = args[0]; int port = Integer.parseInt(args[1]); client = new LocalInvokerTestCase(transport, port); } else { client = new LocalInvokerTestCase(LocalInvokerTestCase.class.getName()); System.out.println("Using default transport " + "and default port." + "\nCan enter transport and port."); } try { //regular class run //client.testLocalInvoke(); //client.runInvokers(); // MultipleTestRunner runner = new MultipleTestRunner(); // runner.doRun(client, true); junit.textui.TestRunner.run(suite()); } catch(Throwable e) { e.printStackTrace(); System.exit(1); } System.exit(0); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/LocalInvokerGeneralTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/LocalInvoker0000644000175000017500000000635710356321614033510 0ustar twernertwerner/* * 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.transport.local; import org.jboss.logging.Logger; import org.jboss.remoting.transport.local.LocalClientInvoker; import org.jboss.test.remoting.transport.InvokerClientTest; import org.jboss.test.remoting.transport.socket.SocketInvokerServerTest; /** * A LITestCase. * @author Ron Sigal * @version $Revision: 576 $ *

          * Copyright (c) 2005 *

          */ public class LocalInvokerGeneralTestCase extends InvokerClientTest { private static final Logger log = Logger.getLogger(LocalInvokerGeneralTestCase.class); private SocketInvokerServerTest server; public void setUp() { server = new SocketInvokerServerTest(); try { server.setUp(); } catch(Exception e) { log.error(e); e.printStackTrace(); } try { super.setUp(); } catch(Exception e) { log.error(e); e.printStackTrace(); } } public void tearDown() { try { server.tearDown(); super.tearDown(); Thread.sleep(2000); } catch(Exception e) { log.error(e); e.printStackTrace(); } } public String getTransport() { return "socket"; } public void testLocalPushCallback() throws Throwable { assertTrue(getClient().getInvoker().getClass().equals(LocalClientInvoker.class)); super.testLocalPushCallback(); } public void testRemotePushCallback() throws Throwable { assertTrue(getClient().getInvoker().getClass().equals(LocalClientInvoker.class)); super.testRemotePushCallback(); } public void testPullCallback() throws Throwable { assertTrue(getClient().getInvoker().getClass().equals(LocalClientInvoker.class)); super.testPullCallback(); } public void testArrayReturn() throws Throwable { assertTrue(getClient().getInvoker().getClass().equals(LocalClientInvoker.class)); super.testArrayReturn(); } public void testThrownException() throws Throwable { assertTrue(getClient().getInvoker().getClass().equals(LocalClientInvoker.class)); super.testThrownException(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/transport/0000755000175000017500000000000011632407040033212 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/transport/LocalInvokerTransportTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/transport/Lo0000644000175000017500000000700710551517552033524 0ustar twernertwerner/* * 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.transport.local.transport; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import javax.management.MBeanServer; import java.io.ByteArrayInputStream; /** * @author Tom Elrod */ public class LocalInvokerTransportTestCase extends TestCase { private Client client; private String transport = "local"; private InvokerLocator locator; private static final Logger log = Logger.getLogger(LocalInvokerTransportTestCase.class); // public LocalInvokerTransportTestCase() // { // } // // public LocalInvokerTransportTestCase(String transport) // { // this.transport = transport; // } public void testLocalInvocation() throws Throwable { InvokerLocator locator = new InvokerLocator("local://localhost"); // Connector connector = new Connector("local://localhost"); Connector connector = new Connector(locator); connector.create(); connector.addInvocationHandler("mock", new TestServerInvocationHandler()); connector.start(); // Client client = new Client(new InvokerLocator("local://localhost")); Client client = new Client(locator); client.connect(); client.invoke("barfoo"); } public class TestServerInvocationHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public Object invoke(InvocationRequest invocation) throws Throwable { System.out.println("called with " + invocation.getParameter()); return "foobar"; } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } } public static void main(String[] args) { LocalInvokerTransportTestCase test = new LocalInvokerTransportTestCase(); try { test.testLocalInvocation(); } catch (Throwable throwable) { throwable.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/LocalInvocationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/local/LocalInvocat0000644000175000017500000001203110433770344033464 0ustar twernertwerner/* * 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.transport.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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Just a simple example of how to setup remoting to make an invocation to local target, * so are not actually going out of process, thus not really using any transport protocol. * * @author Tom Elrod */ public class LocalInvocationTestCase extends TestCase { private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; public LocalInvocationTestCase(String name) { super(name); } public static void setupConfiguration(InvokerLocator locator, ServerInvocationHandler invocationHandler) throws Exception { Connector connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); connector.addInvocationHandler("mock", invocationHandler); } public void testInvocation() throws Throwable { InvokerLocator locator = new InvokerLocator("socket://localhost:6789"); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // set up LocalInvocationTestCase.setupConfiguration(locator, invocationHandler); // This could have been new Client(locator), but want to show that subsystem param is null Client remotingClient = new Client(locator); remotingClient.connect(); Object response = remotingClient.invoke("Do something", null); System.out.println("Invocation response: " + response); assertEquals(response, RESPONSE_VALUE); } public static class SampleInvocationHandler implements ServerInvocationHandler { private List listeners = new ArrayList(); /** * 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 } /** * 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 callbackInvocationRequest = new Callback("This is the payload of callback invocation"); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); callbackHandler.handleCallback(callbackInvocationRequest); } 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); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/0000755000175000017500000000000011632407036031674 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketPerformanceTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketP0000644000175000017500000001046010541701456033504 0ustar twernertwerner/* * 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.transport.bisocket; import java.net.InetAddress; import java.util.HashMap; import javax.management.MBeanServer; import junit.framework.TestCase; import org.jboss.logging.Logger; 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.bisocket.Bisocket; /** * @author Ron Sigal * @version $Revision: 1717 $ *

          * Copyright Nov 25, 2006 *

          */ public class BisocketPerformanceTestServer extends TestCase { public static int port = 5423; private static Logger log = Logger.getLogger(BisocketPerformanceTestServer.class); private static String transport = "bisocket"; // remoting server connector private Connector connector; /** * Sets up target remoting server. */ public void setUp() throws Exception { String locatorURI = transport + "://" + InetAddress.getLocalHost().getHostAddress() + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(Bisocket.IS_CALLBACK_SERVER, "false"); connector = new Connector(serverLocator, config); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } /** * Shuts down the server */ public void tearDown() { if (connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { if (args.length == 1) transport = args[0]; BisocketPerformanceTestServer testCase = new BisocketPerformanceTestServer(); try { testCase.setUp(); Thread.sleep(600000); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. When callback client's are registered, will * generate callbacks periodically. */ static class SampleInvocationHandler implements ServerInvocationHandler { InvokerCallbackHandler callbackHandler; public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("Adding callback listener."); this.callbackHandler = callbackHandler; } public Object invoke(InvocationRequest invocation) throws Throwable { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("Unable to send callback"); } return null; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketI0000644000175000017500000000337111413660476033505 0ustar twernertwerner/* * 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.transport.bisocket; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Apr 3, 2008 *

          */ public class BisocketInvokerTestCase extends InvokerTestDriver { // protected String getJVMArguments() // { // String vmArgs = super.getJVMArguments(); // vmArgs = vmArgs + " -D" + Version.PRE_2_0_COMPATIBLE + "=" + Boolean.TRUE.toString(); // return vmArgs; // } public void declareTestClasses() { addTestClasses("org.jboss.test.remoting.transport.bisocket.BisocketInvokerClientTest", 1, "org.jboss.test.remoting.transport.bisocket.BisocketInvokerServerTest"); } }././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketControlConnectionReplacementTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketC0000644000175000017500000003725411413660476033506 0ustar twernertwerner/* * 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.transport.bisocket; import java.io.IOException; import java.io.OutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; 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.DefaultCallbackErrorHandler; 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; /** * Unit test for JBREM-1147. * * @author Ron Sigal * @version *

          * Copyright Aug 14, 2009 *

          */ public class BisocketControlConnectionReplacementTestCase extends TestCase { private static Logger log = Logger.getLogger(BisocketControlConnectionReplacementTestCase.class); protected static int INITIAL_WRITES; protected static boolean firstTime = true; protected static int secondaryServerSocketPort; protected static int numberOfCallbacks = 10; protected static Object lock = new Object(); protected static TestCallbackHandler testCallbackHandler; 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); String jdkVersion = System.getProperty("java.version"); log.info("jdk version: " + jdkVersion); if (jdkVersion != null && jdkVersion.indexOf("1.4") >= 0) { INITIAL_WRITES = 5; } else { INITIAL_WRITES = 2; } } } public void tearDown() { } public void testCreateSocketWithReplacedControlConnection() 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 = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(testCallbackHandler, metadata); synchronized (lock) { lock.wait(120000); } assertEquals(numberOfCallbacks, testCallbackHandler.counter); assertEquals(numberOfCallbacks - 1, testCallbackHandler.max); client.removeListener(testCallbackHandler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } protected String getServerSocketName() { return TestServerSocketFactory.class.getName(); } 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 += "/?" + Bisocket.PING_FREQUENCY + "=2000"; locatorURI += "&" + DefaultCallbackErrorHandler.CALLBACK_ERRORS_ALLOWED + "=100"; 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"); secondaryServerSocketPort = PortUtil.findFreePort(host); config.put(Bisocket.SECONDARY_BIND_PORT, Integer.toString(secondaryServerSocketPort)); config.put(ServerInvoker.SERVER_SOCKET_FACTORY, getServerSocketName()); config.put("numberOfCallRetries", "5"); 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 { int counter; public void addListener(final InvokerCallbackHandler callbackHandler) { if (counter++ > 0) return; new Thread() { public void run() { for (int i = 0; i < 10 * numberOfCallbacks; i++) { try { if (testCallbackHandler.counter >= numberOfCallbacks) { return; } try { Thread.sleep(1000); } catch (InterruptedException e) { log.error("Unexpected interrupt", e); } log.info("sending callback: " + i); callbackHandler.handleCallback(new Callback(Integer.toString(i))); log.info("sent callback: " + i); } catch (HandleCallbackException e) { log.error("Callback error", e); } } } }.start(); } 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 { int counter; int max; public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback: " + counter++); max = Math.max(Integer.valueOf((String) callback.getParameter()).intValue(), max); log.info("max: " + max); if (counter >= numberOfCallbacks) { synchronized (lock) { lock.notifyAll(); } } } } static public class TestServerSocketFactory extends ServerSocketFactory { int timeout; int initialWrites; public TestServerSocketFactory() { this.timeout = 5000; this.initialWrites = INITIAL_WRITES; } public TestServerSocketFactory(int timeout, int initialWrites) { this.timeout = timeout; this.initialWrites = initialWrites; } public ServerSocket createServerSocket() throws IOException { ServerSocket ss = ServerSocketFactory.getDefault().createServerSocket(); log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port) throws IOException { ServerSocket ss = null; if (port != secondaryServerSocketPort) { ss = ServerSocketFactory.getDefault().createServerSocket(port); } else { ss = new TestServerSocket(port, timeout, initialWrites); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog) throws IOException { ServerSocket ss = null; if (port != secondaryServerSocketPort) { ss = ServerSocketFactory.getDefault().createServerSocket(port, backlog); } else { ss = new TestServerSocket(port, backlog, timeout, initialWrites); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException { ServerSocket ss = null; if (port != secondaryServerSocketPort) { ss = ServerSocketFactory.getDefault().createServerSocket(port, backlog, ifAddress); } else { ss = new TestServerSocket(port, backlog, ifAddress, timeout, initialWrites); } log.info("returning: " + ss); return ss; } } static class TestServerSocket extends ServerSocket { int timeout; int initialWrites; public TestServerSocket(int timeout, int initialWrites) throws IOException { super(); this.timeout = timeout; this.initialWrites = initialWrites; } public TestServerSocket(int port, int timeout, int initialWrites) throws IOException { super(port); this.timeout = timeout; this.initialWrites = initialWrites; } public TestServerSocket(int port, int backlog, int timeout, int initialWrites) throws IOException { super(port, backlog); this.timeout = timeout; this.initialWrites = initialWrites; } public TestServerSocket(int port, int backlog, InetAddress bindAddr, int timeout, int initialWrites) throws IOException { super(port, backlog, bindAddr); this.timeout = timeout; this.initialWrites = initialWrites; } public Socket accept() throws IOException { Socket s = new TestSocket(timeout, initialWrites); implAccept(s); return s; } public String toString() { return "TestServerSocket[" + getLocalPort() + "]"; } } static class TestSocket extends Socket { int timeout; int initialWrites; public TestSocket(int timeout, int initialWrites) { this.timeout = timeout; this.initialWrites = initialWrites; } public TestSocket(String host, int port, int timeout, int initialWrites) throws UnknownHostException, IOException { super(host, port); this.timeout = timeout; this.initialWrites = initialWrites; } public TestSocket(InetAddress address, int port, int timeout, int initialWrites) throws IOException { super(address, port); this.timeout = timeout; this.initialWrites = initialWrites; } public TestSocket(String host, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites) throws IOException { super(host, port, localAddr, localPort); this.timeout = timeout; this.initialWrites = initialWrites; } public TestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites) throws IOException { super(address, port, localAddr, localPort); this.timeout = timeout; this.initialWrites = initialWrites; } public OutputStream getOutputStream() throws IOException { return new TestOutputStream(super.getOutputStream(), timeout, initialWrites); } public String toString() { return "TestSocket[" + getLocalPort() + "->" + getPort() + "]"; } } public static class TestOutputStream extends OutputStream { OutputStream os; int timeout; boolean closed; int initialWrites; boolean doCounterTest = true; int counter; public TestOutputStream(OutputStream os, int timeout, int initialWrites) { this.os = os; this.timeout = timeout; this.initialWrites = initialWrites; } public void close()throws IOException { closed = true; super.close(); log.info(this + " closed"); } public void write(int b) throws IOException { if (closed) { log.info("TestOutputStream closed, cannot write"); throw new SocketException("closed"); } if (doCounterTest && ++counter > initialWrites) { close(); throw new SocketException("closed"); } os.write(b); } public void write(byte b[], int off, int len) throws IOException { for (int i = 0; i < len; i++) { System.out.print(b[i] + " "); } System.out.println(""); if (closed) { log.info("TestOutputStream closed, cannot write"); throw new SocketException("closed"); } log.info("TestOutputStream: counter = " + counter + ", initialWrites = " + initialWrites); if (++counter > initialWrites) { close(); throw new SocketException("closed"); } try { log.info(this + " writing"); doCounterTest = false; os.write(b, off, len); doCounterTest = true; log.info(this + " back from writing"); } catch (IOException e) { log.info("exception: ", e); throw e; } } } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectionpool/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000755000175000017500000000000011632407035033575 5ustar twernertwerner././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectionpool/BisocketConnectionPoolSizeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000272311413660476033612 0ustar twernertwerner/* * 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.transport.bisocket.connectionpool; import org.jboss.test.remoting.transport.socket.connectionpool.ConnectionPoolSizeTestCase; /** * * Unit test for JBREM-858 / JBREM-870. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Dec 3, 2007 *

          */ public class BisocketConnectionPoolSizeTestCase extends ConnectionPoolSizeTestCase { protected String getTransport() { return "bisocket"; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/stress/0000755000175000017500000000000011632407035033216 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/stress/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/stress/re0000644000175000017500000000072110540121762033544 0ustar twernertwernerThis package directory contains client/server classes for testing concurrent invocations through the socket transport. These are not included as part of standard testsuite run and need to be run manually. 6/29/06 - Ran with 250 threads on client, each looping 1M times making server invocations. The test itself finally timed out after two hours of running (per code in test classes), but was able over 35K invocations per thread without error or leak in memory.././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/stress/BisocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/stress/Bi0000644000175000017500000000137410540121762033475 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.stress; import org.jboss.test.remoting.transport.socket.stress.SocketInvokerServerTest; /** * @author Tom Elrod */ public class BisocketInvokerServerTest extends SocketInvokerServerTest { public String getTransport() { return "bisocket"; } public static void main(String[] args) { BisocketInvokerServerTest server = new BisocketInvokerServerTest(); try { server.setUp(); // Thread.currentThread().sleep(300000); Thread.sleep(7200000); server.tearDown(); System.out.println("Have torn down test."); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/stress/BisocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/stress/Bi0000644000175000017500000000114610540121762033472 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.stress; import org.jboss.test.remoting.transport.socket.stress.SocketInvokerClientTest; /** * @author Tom Elrod */ public class BisocketInvokerClientTest extends SocketInvokerClientTest { public String getTransport() { return "bisocket"; } public static void main(String[] args) { BisocketInvokerClientTest client = new BisocketInvokerClientTest(); try { client.testClientCalls(); } catch (Exception e) { e.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/0000755000175000017500000000000011632407035033361 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketTimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000247410540121762033471 0ustar twernertwerner/* * 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.transport.bisocket.timeout; import org.jboss.test.remoting.transport.socket.timeout.TimeoutClientTest; /** * @author Tom Elrod */ public class BisocketTimeoutClientTest extends TimeoutClientTest { protected String getTransport() { return "bisocket"; } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketTimeoutServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000315310540121762033464 0ustar twernertwerner/* * 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.transport.bisocket.timeout; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.test.remoting.transport.socket.timeout.TimeoutServerTest; /** * @author Tom Elrod */ public class BisocketTimeoutServerTest extends TimeoutServerTest { protected String getTransport() { return "bisocket"; } public static void main(String[] args) { BisocketTimeoutServerTest server = new BisocketTimeoutServerTest(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketQuickDisconnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000275210666126123033475 0ustar twernertwerner/* * 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.transport.bisocket.timeout; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class BisocketQuickDisconnectTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(BisocketQuickDisconnectClient.class.getName(), 1, BisocketQuickDisconnectServer.class.getName()); } protected long getResultsTimeout() { return 100000; } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketQuickDisconnectClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000326210666126123033472 0ustar twernertwerner/* * 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.transport.bisocket.timeout; import org.jboss.test.remoting.timeout.QuickDisconnectClientParent; /** * @author Ron Sigal * @version $Revision: 2744 $ *

          * Copyright Feb 17, 2007 *

          */ public class BisocketQuickDisconnectClient extends QuickDisconnectClientParent { protected String getTransport() { return "bisocket"; } /** * It seems that in jdk 1.4 (at least), HttpURLConnection has a default timeout * of 1000 ms, so the tests are run with a shorter timeout. */ protected int shortTimeout() { return 500; } protected String shortTimeoutString() { return "500"; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/idle/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/i0000755000175000017500000000000011632407035033532 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/idle/BisocketIdleTimeoutTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/i0000644000175000017500000000104610540121762033532 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.timeout.idle; import org.jboss.test.remoting.transport.socket.timeout.idle.IdleTimeoutTestServer; /** * @author Tom Elrod */ public class BisocketIdleTimeoutTestServer extends IdleTimeoutTestServer { protected String getTransport() { return "bisocket"; } public static void main(String[] args) throws Throwable { BisocketIdleTimeoutTestServer rt = new BisocketIdleTimeoutTestServer(); rt.startServer(); } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/idle/BisocketInactiveIdleTimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/i0000644000175000017500000000061610540121762033534 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.timeout.idle; import org.jboss.test.remoting.transport.socket.timeout.idle.InactiveIdleTimeoutClientTest; /** * @author Tom Elrod */ public class BisocketInactiveIdleTimeoutClientTest extends InactiveIdleTimeoutClientTest { protected String getTransport() { return "bisocket"; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/idle/BisocketIdleTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/i0000644000175000017500000000234310540121762033533 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.timeout.idle; import org.jboss.jrunit.harness.TestDriver; public class BisocketIdleTimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(BisocketIdleTimeoutClientTest.class.getName(), 2, BisocketIdleTimeoutTestServer.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 360000; } /** * 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 360000; } /** * 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 360000; } }././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/idle/BisocketInactiveIdleTimeoutTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/i0000644000175000017500000000165010540121762033533 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.timeout.idle; import org.jboss.test.remoting.transport.socket.timeout.idle.InactiveIdleTimeoutTestServer; /** * This is just like IdleTimeoutTestServer except instead of * looking for server threads that are still in read mode waiting for * data from client, want to test for idle server threads that finished with * client/server connection and are just sitting in the thread pool waiting to * be re-used. * * @author Tom Elrod */ public class BisocketInactiveIdleTimeoutTestServer extends InactiveIdleTimeoutTestServer { protected String getTransport() { return "bisocket"; } public static void main(String[] args) throws Throwable { BisocketInactiveIdleTimeoutTestServer rt = new BisocketInactiveIdleTimeoutTestServer(); rt.setUp(); Thread.sleep(45000); rt.tearDown(); } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/idle/BisocketIdleTimeoutClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/i0000644000175000017500000000056610540121762033540 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.timeout.idle; import org.jboss.test.remoting.transport.socket.timeout.idle.IdleTimeoutClientTest; /** * @author Tom Elrod */ public class BisocketIdleTimeoutClientTest extends IdleTimeoutClientTest { protected String getTransport() { return "bisocket"; } } ././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/idle/BisocketInactiveIdleTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/i0000644000175000017500000000237410540121762033537 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.timeout.idle; import org.jboss.jrunit.harness.TestDriver; public class BisocketInactiveIdleTimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(BisocketInactiveIdleTimeoutClientTest.class.getName(), 1, BisocketInactiveIdleTimeoutTestServer.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 360000; } /** * 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 360000; } /** * 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 360000; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketWriteTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000263711413660476033504 0ustar twernertwerner/* * 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.transport.bisocket.timeout; import org.jboss.test.remoting.transport.socket.timeout.WriteTimeoutTestParent; /** * Unit tests for JBREM-1120. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Apr 22, 2009 *

          */ public class BisocketWriteTimeoutTestCase extends WriteTimeoutTestParent { protected String getTransport() { return "bisocket"; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketQuickDisconnectServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000325010666126123033467 0ustar twernertwerner/* * 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.transport.bisocket.timeout; import org.jboss.test.remoting.timeout.QuickDisconnectServerParent; /** * @author Ron Sigal * @version $Revision: 2744 $ *

          * Copyright Feb 18, 2007 *

          */ public class BisocketQuickDisconnectServer extends QuickDisconnectServerParent { public static void main(String[] args) { try { BisocketQuickDisconnectServer server = new BisocketQuickDisconnectServer(); server.setUp(); Thread.sleep(100000); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "bisocket"; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000262510540121762033467 0ustar twernertwerner/* * 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.transport.bisocket.timeout; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class BisocketTimeoutTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(BisocketTimeoutClientTest.class.getName(), 1, BisocketTimeoutServerTest.class.getName()); } }././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketPerInvocationTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000100010606467750033466 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.timeout; import org.jboss.test.remoting.transport.socket.timeout.SocketPerInvocationTimeoutTestCase; /** * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 2340 $ *

          * Copyright Feb 6, 2007 *

          */ public class BisocketPerInvocationTimeoutTestCase extends SocketPerInvocationTimeoutTestCase { protected String getTransport() { return "bisocket"; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketDefaultTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/B0000644000175000017500000000607411413660476033503 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2010, 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.transport.bisocket.timeout; import java.io.IOException; import java.util.Map; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; import org.jboss.remoting.transport.socket.ServerAddress; import org.jboss.test.remoting.transport.socket.timeout.SocketDefaultTimeoutTestCase; /** * Unit tests for JBREM-1188. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 16, 2010 */ public class BisocketDefaultTimeoutTestCase extends SocketDefaultTimeoutTestCase { private static Logger log = Logger.getLogger(BisocketDefaultTimeoutTestCase.class); protected Class getClientFactoryClass() { return TestBisocketClientFactory.class; } protected Class getClientInvokerClass() { return TestBisocketClientInvoker.class; } public static class TestBisocketClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { ClientInvoker clientInvoker = new TestBisocketClientInvoker(locator, config); log.info("TestClientFaotory.createClientInvoker() returning " + clientInvoker); return clientInvoker; } public boolean supportsSSL() { return false; } } public static class TestBisocketClientInvoker extends BisocketClientInvoker { public TestBisocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); } public TestBisocketClientInvoker(InvokerLocator locator) throws IOException { super(locator); } public ServerAddress getServerAddress() { return address; } public String toString() { return "TestBisocketClientInvoker"; } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketI0000644000175000017500000000443211413660476033504 0ustar twernertwerner/* * 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.transport.bisocket; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerServerTest; /** * @author Tom Elrod */ public class BisocketInvokerServerTest extends InvokerServerTest { public String getTransport() { return "bisocket"; } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting.transport.socket").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jboss.test.remoting").setLevel(Level.DEBUG); // org.apache.log4j.Category.getInstance("org.jboss.remoting.marshall.dynamic.local").setLevel(Level.DEBUG); // org.apache.log4j.Category.getInstance("org.jboss.dtf").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); InvokerServerTest server = new BisocketInvokerServerTest(); try { server.setUp(); Thread.sleep(300000); server.tearDown(); System.out.println("Have torn down test."); Thread.sleep(30000); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/TimerReuseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/TimerReus0000644000175000017500000003206010665734602033546 0ustar twernertwerner/* * 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.transport.bisocket; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Timer; 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.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.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.test.remoting.transport.bisocket.ServerTimerReuseTestCase.TestCallbackHandler; import org.jboss.test.remoting.transport.bisocket.ServerTimerReuseTestCase.TestInvocationHandler; /** * TimerReuseTestCase verifies that it is safe to add a callback BisocketClientInvoker * after the static Timer used by the PingTimerTasks has shut down because all previous * PingTimerTasks have ended. * * See JBREM-748. * * The phenomenon described in JBREM-748 seems to be platform dependent. It's not clear, * for example, how long it takes for a Timer to shut down after all of its tasks have * ended. Therefore, there are multiple test methods that wait varying amounts of * time before installing a second InvokerCallbackHandler. * * @author Ron Sigal * @version $Revision: 2737 $ *

          * Copyright May 31, 2007 *

          */ public class TimerReuseTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(TimerReuseTestCase.class); private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private SampleInvocationHandler 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 testTimerRestartImmdiately() throws Throwable { log.info("entering " + getName()); doTestTimerReuse(1); } public void testTimerRestartAfter1Second() throws Throwable { log.info("entering " + getName()); doTestTimerReuse(1000); } public void testTimerRestartAfter5Seconds() throws Throwable { log.info("entering " + getName()); doTestTimerReuse(5000); } public void testTimerRestartAfter30Seconds() throws Throwable { log.info("entering " + getName()); doTestTimerReuse(30000); } public void testNewControlConnectionImmdiately() throws Throwable { log.info("entering " + getName()); doTestNewControlConnectionTimerReuse(1); } public void testNewControlConnectionAfter1Second() throws Throwable { log.info("entering " + getName()); doTestNewControlConnectionTimerReuse(1000); } public void testNewControlConnectionAfter5Seconds() throws Throwable { log.info("entering " + getName()); doTestNewControlConnectionTimerReuse(5000); } public void testNewControlConnectionAfter30Seconds() throws Throwable { log.info("entering " + getName()); doTestNewControlConnectionTimerReuse(30000); } public void doTestTimerReuse(int waitPeriod) throws Throwable { // 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"); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("First callback handler is installed."); // Reinstall callback handler. Test passes if no exception is thrown. client.removeListener(callbackHandler); Thread.sleep(waitPeriod); client.addListener(callbackHandler, new HashMap()); log.info("Second callback handler is installed."); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); } /** * Verifies that BisocketClientInvoker.replaceControlSocket() reuses static * Timer, if possible. */ public void doTestNewControlConnectionTimerReuse(int waitPeriod) throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int 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. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator1, 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(); HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler, metadata); // Stop PingTimerTask on server. This allows the possibility that the Timer // will be replaced. BisocketServerInvoker serverInvoker = (BisocketServerInvoker) 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(); field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); assertNotNull(callbackClient); BisocketClientInvoker callbackClientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask"); field.setAccessible(true); TimerTask pingTimerTask1 = (TimerTask) field.get(callbackClientInvoker); BisocketClientInvoker ci = (BisocketClientInvoker) client.getInvoker(); assertNotNull(pingTimerTask1); pingTimerTask1.cancel(); // Cause recreation of PingTimerTask on server. If call below to // createControlConnection() doesn't throw an exception, then the test passes. Thread.sleep(waitPeriod); field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectors = (Map) field.get(client); assertEquals(1, callbackConnectors.size()); Set connectors = (Set) callbackConnectors.values().iterator().next(); assertEquals(1, connectors.size()); Connector callbackConnector = (Connector) connectors.iterator().next(); BisocketServerInvoker callbackInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); Map controlConnectionThreadMap = (Map) field.get(callbackInvoker); assertEquals(1, controlConnectionThreadMap.size()); Thread controlConnectionThread = (Thread) controlConnectionThreadMap.values().iterator().next(); Class[] classes = BisocketServerInvoker.class.getDeclaredClasses(); Class ControlConnectionThreadClass = null; for (int i = 0; i < classes.length; i++) { if (classes[i].toString().indexOf("ControlConnectionThread") != -1) { ControlConnectionThreadClass = classes[i]; break; } } assertNotNull(ControlConnectionThreadClass); field = ControlConnectionThreadClass.getDeclaredField("listenerId"); field.setAccessible(true); String listenerId = (String) field.get(controlConnectionThread); assertNotNull(listenerId); callbackInvoker.createControlConnection(listenerId, false); Thread.sleep(2000); // Get PingTimerTask and verify it has changed. field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask"); field.setAccessible(true); TimerTask pingTimerTask2 = (TimerTask) field.get(callbackClientInvoker); assertNotSame(pingTimerTask1, pingTimerTask2); // Shut down. client.removeListener(callbackHandler); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class SampleInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("unable to send callback", e); } } 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 int count; public void handleCallback(Callback callback) throws HandleCallbackException { count++; } } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ServerTimerReuseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ServerTim0000644000175000017500000001466110713011157033541 0ustar twernertwerner/* * 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.transport.bisocket; 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.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 org.jboss.remoting.transport.bisocket.BisocketServerInvoker; /** * ServerTimerReuseTestCase verifies that BisocketServerInvoker.start() reuses an * existing static Timer if possible. See JBREM-778. * * @author Ron Sigal * @version $Revision: 2900 $ *

          * Copyright Jul 20, 2007 *

          */ public class ServerTimerReuseTestCase extends TestCase { private static Logger log = Logger.getLogger(ServerTimerReuseTestCase.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 the Timer used by callback BisocketServerInvoker's is reused. */ public void testTimerReuse() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int 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. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI + "/?timeout=5000"); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator1, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Add first callback handler and get Timer. TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler1, metadata); Field field = BisocketServerInvoker.class.getDeclaredField("timer"); field.setAccessible(true); Timer timer1 = (Timer) field.get(null); // Add second callback handler and verify Timer is unchanged. TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); metadata.clear(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler2, metadata); Timer timer2 = (Timer) field.get(null); assertEquals(timer1, timer2); // Shut down. client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} 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"); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/restart/0000755000175000017500000000000011632407035033357 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/restart/BisocketServerRestartTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/restart/B0000644000175000017500000000264310723136700033466 0ustar twernertwerner/* * 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.transport.bisocket.restart; import org.jboss.test.remoting.restart.ServerRestartTestParent; /** * Unit test for JBREM-745. * * @author Ron Sigal * @version $Revision: 3022 $ *

          * Copyright November 27, 2007 *

          */ public class BisocketServerRestartTestCase extends ServerRestartTestParent { protected String getTransport() { return "bisocket"; } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/CloseControlSocketTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/CloseCont0000644000175000017500000003200610712771600033510 0ustar twernertwerner/* * 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.transport.bisocket; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.Socket; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Timer; 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.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.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.test.remoting.transport.bisocket.ServerTimerReuseTestCase.TestCallbackHandler; import org.jboss.test.remoting.transport.bisocket.ServerTimerReuseTestCase.TestInvocationHandler; /** * TimerReuseTestCase verifies that it is safe to add a callback BisocketClientInvoker * after the static Timer used by the PingTimerTasks has shut down because all previous * PingTimerTasks have ended. * * See JBREM-748. * * The phenomenon described in JBREM-748 seems to be platform dependent. It's not clear, * for example, how long it takes for a Timer to shut down after all of its tasks have * ended. Therefore, there are multiple test methods that wait varying amounts of * time before installing a second InvokerCallbackHandler. * * @author Ron Sigal * @version $Revision: 2897 $ *

          * Copyright May 31, 2007 *

          */ public class CloseControlSocketTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(CloseControlSocketTestCase.class); private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private SampleInvocationHandler 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 testControlSocketClosedWhenDisconnected() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int 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. 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 connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Add callback handler. TestCallbackHandler callbackHandler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler, metadata); // Get control socket. BisocketServerInvoker serverInvoker = (BisocketServerInvoker) 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(); field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); assertNotNull(callbackClient); BisocketClientInvoker callbackClientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); field = BisocketClientInvoker.class.getDeclaredField("controlSocket"); field.setAccessible(true); Socket controlSocket = (Socket) field.get(callbackClientInvoker); assertNotNull(controlSocket); assertFalse(controlSocket.isClosed()); // Remove callback handler, which will shut down control connection. // Verify that control socket gets closed. client.removeListener(callbackHandler); assertTrue(controlSocket.isClosed()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } /** Verifies that a control socket is closed when it is replaced. */ public void testControlSocketClosedWhenReplaced() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int 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. 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 connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Add callback handler. TestCallbackHandler callbackHandler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler, metadata); // Get current control socket. BisocketServerInvoker serverInvoker = (BisocketServerInvoker) 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(); field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); assertNotNull(callbackClient); BisocketClientInvoker callbackClientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); field = BisocketClientInvoker.class.getDeclaredField("controlSocket"); field.setAccessible(true); Socket oldControlSocket = (Socket) field.get(callbackClientInvoker); assertNotNull(oldControlSocket); assertFalse(oldControlSocket.isClosed()); // Cause recreation of control connection on server. field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectors = (Map) field.get(client); assertEquals(1, callbackConnectors.size()); Set connectors = (Set) callbackConnectors.values().iterator().next(); assertEquals(1, connectors.size()); Connector callbackConnector = (Connector) connectors.iterator().next(); BisocketServerInvoker callbackInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); Map controlConnectionThreadMap = (Map) field.get(callbackInvoker); assertEquals(1, controlConnectionThreadMap.size()); Thread controlConnectionThread = (Thread) controlConnectionThreadMap.values().iterator().next(); Class[] classes = BisocketServerInvoker.class.getDeclaredClasses(); Class ControlConnectionThreadClass = null; for (int i = 0; i < classes.length; i++) { if (classes[i].toString().indexOf("ControlConnectionThread") != -1) { ControlConnectionThreadClass = classes[i]; break; } } assertNotNull(ControlConnectionThreadClass); field = ControlConnectionThreadClass.getDeclaredField("listenerId"); field.setAccessible(true); String listenerId = (String) field.get(controlConnectionThread); assertNotNull(listenerId); callbackInvoker.createControlConnection(listenerId, false); // Verify old control socket is closed and has been replaced. Thread.sleep(2000); assertTrue(oldControlSocket.isClosed()); field = BisocketClientInvoker.class.getDeclaredField("controlSocket"); field.setAccessible(true); Socket newControlSocket = (Socket) field.get(callbackClientInvoker); assertNotNull(newControlSocket); assertNotSame(oldControlSocket, newControlSocket); assertFalse(newControlSocket.isClosed()); // Shut down. client.removeListener(callbackHandler); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class SampleInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("unable to send callback", e); } } 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 int count; public void handleCallback(Callback callback) throws HandleCallbackException { count++; } } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackClientWithZeroTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackC0000644000175000017500000002415411413660476033432 0ustar twernertwerner/* * 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.transport.bisocket; import java.io.IOException; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.Socket; 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.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; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.remoting.transport.socket.SocketClientInvoker; /** * Unit test for JBREM-845. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Dec 11, 2007 *

          */ public class CallbackClientWithZeroTimeoutTestCase extends TestCase { private static Logger log = Logger.getLogger(CallbackClientWithZeroTimeoutTestCase.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; 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 testCallbackSocketFailure() 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(); Map metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler, metadata); log.info("callback handler is installed"); // Make sure callback client invoker has timeout == 0. Client callbackClient = invocationHandler.callbackHandler.getCallbackClient(); SocketClientInvoker callbackClientInvoker = (SocketClientInvoker) callbackClient.getInvoker(); assertEquals(0, callbackClientInvoker.getTimeout()); log.info("timeout == 0"); // Verify failing PingTimerTask kicks thread out of BisocketClientInvoker.createSocket(). // 1. Get client side control socket. Set callbackConnectors = client.getCallbackConnectors(callbackHandler); assertEquals(1, callbackConnectors.size()); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); Field field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); Map controlConnectionThreadMap = (Map) field.get(callbackServerInvoker); assertEquals(1, controlConnectionThreadMap.size()); Thread controlConnectionThread = (Thread) controlConnectionThreadMap.values().iterator().next(); assertNotNull(controlConnectionThread); Class controlConnectionThreadClass = null; Class[] classes = BisocketServerInvoker.class.getDeclaredClasses(); for (int i = 0; i < classes.length; i++) { log.info(classes[i]); if (classes[i].getName().indexOf("ControlConnectionThread") >= 0) { controlConnectionThreadClass = classes[i]; break; } } assertNotNull(controlConnectionThreadClass); field = controlConnectionThreadClass.getDeclaredField("controlSocket"); field.setAccessible(true); Socket controlSocket = (Socket) field.get(controlConnectionThread); assertNotNull(controlSocket); // 2. Get server side ControlConnectionThread and stop it. field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSocketThreads"); field.setAccessible(true); Set secondaryServerSocketThreads = (Set) field.get(connector.getServerInvoker()); Thread secondaryServerSocketThread = (Thread) secondaryServerSocketThreads.iterator().next(); assertNotNull(secondaryServerSocketThread); secondaryServerSocketThread.stop(); log.info("stopped secondaryServerSocketThread"); // 3. Try to do callback. client.invokeOneway(CALLBACK); log.info("requested CALLBACK"); // 4. Close client side control socket so PING fails. controlSocket.close(); log.info("closed controlSocket"); // 5. Test that attempt to create a socket for callback threw exception. Thread.sleep(5000); assertTrue(invocationHandler.ok); log.info("got expected Exception doing callback"); client.removeListener(callbackHandler); client.disconnect(); shutdownServer(); 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 + "/?timeout=0"; locatorURI += "&" + Bisocket.PING_FREQUENCY + "=1000"; locatorURI += "&" + Bisocket.MAX_RETRIES + "=1"; locatorURI += "&numberOfCallRetries=1"; 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 boolean ok; 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())) { try { log.info("calling handleCallback()"); callbackHandler.handleCallback(new Callback(CALLBACK)); log.info("called handleCallback()"); } catch (HandleCallbackException e) { log.info("error: " + e.getMessage(), e); Throwable cause = e.getCause(); log.info("cause: " + cause); cause = cause.getCause(); log.info("cause: " + cause); if (cause instanceof IOException && "Unable to create socket".equals(cause.getMessage())) { ok = true; } } } return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public boolean ok; public void handleCallback(Callback callback) throws HandleCallbackException { ok = true; log.info("received callback"); } } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000755000175000017500000000000011632407035033575 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/BisocketConnectionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000272510541702021033574 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.connection; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketConnectionTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(BisocketTestClient.class.getName(), 1, BisocketTestServer.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; } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/BisocketConnectionCheckTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000102110541702021033560 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.connection; import org.jboss.test.remoting.transport.socket.connection.SocketConnectionCheckTestClient; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketConnectionCheckTestClient extends SocketConnectionCheckTestClient { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 17; } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/BisocketConnectionCheckTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000101610541702021033564 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.connection; import org.jboss.test.remoting.transport.socket.connection.SocketConnectionCheckTestServer; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketConnectionCheckTestServer extends SocketConnectionCheckTestServer { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 17; } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/BisocketConnectionCheckTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000472010542175122033600 0ustar twernertwerner/* * 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.transport.bisocket.connection; import org.jboss.test.remoting.transport.InvokerTestDriver; import org.apache.log4j.Level; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketConnectionCheckTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(BisocketConnectionCheckTestClient.class.getName(), 1, BisocketConnectionCheckTestServer.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; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/BisocketTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000355510557303663033616 0ustar twernertwerner/* * 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.transport.bisocket.connection; import org.jboss.test.remoting.transport.socket.connection.SocketTestServer; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketTestServer extends SocketTestServer { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 18; } public static void main(String[] args) { SocketTestServer server = new BisocketTestServer(); try { server.setUp(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/retry/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000755000175000017500000000000011632407035033575 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/retry/BisocketRetryServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000076010541702021033571 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.connection.retry; import org.jboss.test.remoting.transport.socket.connection.retry.SocketRetryServer; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketRetryServer extends SocketRetryServer { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 13; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/retry/BisocketRetryTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000300010541702021033557 0ustar twernertwerner/* * 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.transport.bisocket.connection.retry; import org.jboss.test.remoting.transport.socket.connection.retry.SocketRetryTestCase; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketRetryTestCase extends SocketRetryTestCase { public void declareTestClasses() { addTestClasses(BisocketRetryClient.class.getName(), 1, BisocketRetryServer.class.getName()); } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/retry/BisocketRetryClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000076010541702021033571 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.connection.retry; import org.jboss.test.remoting.transport.socket.connection.retry.SocketRetryClient; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketRetryClient extends SocketRetryClient { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 13; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connection/BisocketTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000270310541702021033570 0ustar twernertwerner/* * 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.transport.bisocket.connection; import org.jboss.test.remoting.transport.socket.connection.SocketTestClient; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketTestClient extends SocketTestClient { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 18; } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/multihome/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/multihome0000755000175000017500000000000011632407035033617 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/multihome/BisocketMultihomeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/multihome0000644000175000017500000003163411413660476033637 0ustar twernertwerner /* * 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.transport.bisocket.multihome; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.ServerSocket; import java.util.ArrayList; import java.util.Enumeration; 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 org.jboss.remoting.Home; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.AddressUtil; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.test.remoting.multihome.MultihomeTestParent; import org.jboss.test.remoting.multihome.TestInvocationHandler; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jan 8, 2008 *

          */ public class BisocketMultihomeTestCase extends MultihomeTestParent { protected ArrayList interfaces = new ArrayList(); protected String getTransport() { return "bisocket"; } protected void addExtraCallbackConfig(Map config) { config.put(Bisocket.IS_CALLBACK_SERVER, "true"); } public void testSecondaryBindPorts() throws Throwable { log.info("entering " + getName()); // Start server. localCreateLocatorURI(); InetAddress address = (InetAddress) interfaces.get(0); int port = PortUtil.findFreePort(address.getHostAddress()); Set secondaryBindPorts = new HashSet(); secondaryBindPorts.add(new Integer(port)); StringBuffer sb = new StringBuffer(Integer.toString(port)); for (int i = 1; i < interfaces.size(); i++) { address = (InetAddress) interfaces.get(i); port = PortUtil.findFreePort(address.getHostAddress()); sb.append('!').append(port); secondaryBindPorts.add(new Integer(port)); } String secondaryBindPortsString = sb.toString(); log.info("secondaryBindPorts: " + secondaryBindPortsString); locatorURI += "&" + Bisocket.SECONDARY_BIND_PORTS + "=" + secondaryBindPortsString; HashMap config = new HashMap(); addExtraServerConfig(config); connector = new Connector(locatorURI, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); // Check bind ports in secondary locator. BisocketServerInvoker invoker = (BisocketServerInvoker) connector.getServerInvoker(); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryLocator"); field.setAccessible(true); InvokerLocator secondaryLocator = (InvokerLocator) field.get(invoker); log.info("secondaryLocator: " + secondaryLocator); List homes = secondaryLocator.getHomeList(); Home h = (Home) homes.get(0); StringBuffer sb2 = new StringBuffer(Integer.toString(h.port)); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb2.append('!').append(h.port); } log.info("sb2: " + sb2.toString()); assertEquals(secondaryBindPortsString, sb2.toString()); // Check bind ports in secondary server sockets. field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSockets"); field.setAccessible(true); Set secondaryServerSockets = (Set) field.get(invoker); assertEquals(secondaryBindPorts.size(), secondaryServerSockets.size()); Set ports = new HashSet(); Iterator it = secondaryServerSockets.iterator(); while (it.hasNext()) { ServerSocket ss = (ServerSocket) it.next(); ports.add(new Integer(ss.getLocalPort())); } assertEquals(secondaryBindPorts, ports); shutdownServer(); log.info(getName() + " PASSES"); } public void testSecondaryConnectPorts() throws Throwable { log.info("entering " + getName()); // Start server. localCreateLocatorURI(); InetAddress address = (InetAddress) interfaces.get(0); int port = PortUtil.findFreePort(address.getHostAddress()); Set secondaryBindPorts = new HashSet(); secondaryBindPorts.add(new Integer(port)); StringBuffer sb = new StringBuffer(Integer.toString(port)); for (int i = 1; i < interfaces.size(); i++) { address = (InetAddress) interfaces.get(i); port = PortUtil.findFreePort(address.getHostAddress()); sb.append('!').append(port); secondaryBindPorts.add(new Integer(port)); } String secondaryBindPortsString = sb.toString(); log.info("secondaryBindPorts: " + secondaryBindPortsString); locatorURI += "&" + Bisocket.SECONDARY_BIND_PORTS + "=" + secondaryBindPortsString; address = (InetAddress) interfaces.get(0); port = PortUtil.findFreePort(address.getHostAddress()); StringBuffer sb2 = new StringBuffer(Integer.toString(port)); for (int i = 1; i < interfaces.size(); i++) { address = (InetAddress) interfaces.get(i); port = PortUtil.findFreePort(address.getHostAddress()); sb2.append('!').append(port); } String secondaryConnectPortsString = sb2.toString(); log.info("secondaryConnectPorts: " + secondaryConnectPortsString); locatorURI += "&" + Bisocket.SECONDARY_CONNECT_PORTS + "=" + secondaryConnectPortsString; log.info("locatorURI: " + locatorURI); HashMap config = new HashMap(); addExtraServerConfig(config); connector = new Connector(locatorURI, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); // Check connect ports in secondary locator. BisocketServerInvoker invoker = (BisocketServerInvoker) connector.getServerInvoker(); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryLocator"); field.setAccessible(true); InvokerLocator secondaryLocator = (InvokerLocator) field.get(invoker); log.info("secondaryLocator: " + secondaryLocator); List homes = secondaryLocator.getHomeList(); Home h = (Home) homes.get(0); StringBuffer sb3 = new StringBuffer(Integer.toString(h.port)); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb3.append('!').append(h.port); } log.info("sb3: " + sb3.toString()); assertEquals(secondaryConnectPortsString, sb3.toString()); // Check bind ports in secondary server sockets. field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSockets"); field.setAccessible(true); Set secondaryServerSockets = (Set) field.get(invoker); assertEquals(secondaryBindPorts.size(), secondaryServerSockets.size()); Set ports = new HashSet(); Iterator it = secondaryServerSockets.iterator(); while (it.hasNext()) { ServerSocket ss = (ServerSocket) it.next(); ports.add(new Integer(ss.getLocalPort())); } assertEquals(secondaryBindPorts, ports); shutdownServer(); log.info(getName() + " PASSES"); } public void testMismatchedSecondaryPorts() throws Throwable { log.info("entering " + getName()); // Start server. localCreateLocatorURI(); InetAddress address = (InetAddress) interfaces.get(0); int port = PortUtil.findFreePort(address.getHostAddress()); Set secondaryBindPorts = new HashSet(); secondaryBindPorts.add(new Integer(port)); StringBuffer sb = new StringBuffer(Integer.toString(port)); for (int i = 1; i < interfaces.size(); i++) { address = (InetAddress) interfaces.get(i); port = PortUtil.findFreePort(address.getHostAddress()); sb.append('!').append(port); secondaryBindPorts.add(new Integer(port)); } String secondaryBindPortsString = sb.toString(); log.info("secondaryBindPorts: " + secondaryBindPortsString); locatorURI += "&" + Bisocket.SECONDARY_BIND_PORTS + "=" + secondaryBindPortsString; address = (InetAddress) interfaces.get(0); port = PortUtil.findFreePort(address.getHostAddress()); StringBuffer sb2 = new StringBuffer(Integer.toString(port)); for (int i = 1; i < interfaces.size(); i++) { address = (InetAddress) interfaces.get(i); port = PortUtil.findFreePort(address.getHostAddress()); sb2.append('!').append(port); } // Add extra secondary connect port. sb2.append('!').append(9876); String secondaryConnectPortsString = sb2.toString(); log.info("secondaryConnectPorts: " + secondaryConnectPortsString); locatorURI += "&" + Bisocket.SECONDARY_CONNECT_PORTS + "=" + secondaryConnectPortsString; log.info("locatorURI: " + locatorURI); HashMap config = new HashMap(); addExtraServerConfig(config); connector = new Connector(locatorURI, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); // Check bind ports in secondary locator. BisocketServerInvoker invoker = (BisocketServerInvoker) connector.getServerInvoker(); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryLocator"); field.setAccessible(true); InvokerLocator secondaryLocator = (InvokerLocator) field.get(invoker); log.info("secondaryLocator: " + secondaryLocator); List homes = secondaryLocator.getHomeList(); Home h = (Home) homes.get(0); StringBuffer sb3 = new StringBuffer(Integer.toString(h.port)); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb3.append('!').append(h.port); } log.info("sb3: " + sb3.toString()); assertEquals(secondaryBindPortsString, sb3.toString()); // Check bind ports in secondary server sockets. field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSockets"); field.setAccessible(true); Set secondaryServerSockets = (Set) field.get(invoker); assertEquals(secondaryBindPorts.size(), secondaryServerSockets.size()); Set ports = new HashSet(); Iterator it = secondaryServerSockets.iterator(); while (it.hasNext()) { ServerSocket ss = (ServerSocket) it.next(); ports.add(new Integer(ss.getLocalPort())); } assertEquals(secondaryBindPorts, ports); shutdownServer(); log.info(getName() + " PASSES"); } protected void localCreateLocatorURI() throws Exception { StringBuffer sb = new StringBuffer(); Enumeration e1 = NetworkInterface.getNetworkInterfaces(); boolean first = true; int counter = 0; loop: while (e1.hasMoreElements()) { NetworkInterface iface = (NetworkInterface) e1.nextElement(); Enumeration e2 = iface.getInetAddresses(); while (e2.hasMoreElements()) { if (++counter > 5) break loop; InetAddress address = (InetAddress) e2.nextElement(); String host = address.getHostAddress(); if (AddressUtil.checkAddress(host)) { log.info("host is functional: " + host); int port = PortUtil.findFreePort(host); if (first) first = false; else sb.append('!'); sb.append(host).append(':').append(port); interfaces.add(address); } else { log.info("skipping host: " + host); } } } locatorURI = getTransport() + "://" + InvokerLocator.MULTIHOME + getPath() + "/?"; locatorURI += InvokerLocator.HOMES_KEY + "=" + sb.toString(); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/listenerID/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/listenerI0000755000175000017500000000000011632407036033553 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/listenerID/ListenerIDonStackTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/listenerI0000644000175000017500000001522710665734665033604 0ustar twernertwerner/* * 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.transport.bisocket.listenerID; 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.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.BisocketClientInvoker; /** * Unit test for JBREM-785. * * @author Ron Sigal * @version $Revision: 2738 $ *

          * Copyright Aug 2, 2007 *

          */ public class ListenerIDonStackTestCase extends TestCase { private static Logger log = Logger.getLogger(ListenerIDonStackTestCase.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() { } /** * Tests blocking and nonblocking direct calls to Client.getCallbacks(). */ public void testStabilityOfListenerId() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int 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. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI + "/?timeout=1000"); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator1, clientConfig); client.connect(); log.info("client is connected"); // Test connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Get listenerId from BisocketClientInvoker and verify it is null. assertTrue(client.getInvoker() instanceof BisocketClientInvoker); BisocketClientInvoker invoker = (BisocketClientInvoker) client.getInvoker(); Field field = BisocketClientInvoker.class.getDeclaredField("listenerId"); field.setAccessible(true); String listenerId = (String) field.get(invoker); log.info("listenerId before adding callback handler (should be null): " + listenerId); assertNull(listenerId); // Add callback handler. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap()); assertEquals(1, callbackHandler.counter); log.info("added callback handler"); // Verify listenerId is still null. listenerId = (String) field.get(invoker); assertNull(listenerId); log.info("listenerId after adding callback handler (should be null): " + listenerId); client.removeListener(callbackHandler); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) { try { callbackHandler.handleCallback(new Callback("test")); } 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) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; log.info("received callback"); } } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/threadpool/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/threadpoo0000755000175000017500000000000011632407035033601 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/threadpool/ServerThreadReuseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/threadpoo0000644000175000017500000002141111413660476033611 0ustar twernertwerner/* * 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.transport.bisocket.threadpool; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.Socket; 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.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; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-938. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Mar 22, 2008 *

          */ public class ServerThreadReuseTestCase extends TestCase { private static Logger log = Logger.getLogger(ServerThreadReuseTestCase.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 testServerThreadReuse() 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(); HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler, metadata, null, true); client.invoke("callback"); assertEquals(1, callbackHandler.counter); log.info("first callback successful"); // Get callback server thread pools. Set callbackConnectors = client.getCallbackConnectors(callbackHandler); assertEquals(1, callbackConnectors.size()); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); BisocketServerInvoker invoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("threadpool"); field.setAccessible(true); List threadpool = (List) field.get(invoker); field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(invoker); assertEquals(0, threadpool.size()); assertEquals(1, clientpool.size()); // Kill worker thread's socket. Set clientpoolContents = clientpool.getContents(); ServerThread serverThread1 = (ServerThread) clientpoolContents.iterator().next(); field = ServerThread.class.getDeclaredField("socket"); field.setAccessible(true); Socket socket = (Socket) field.get(serverThread1); socket.close(); Thread.sleep(4000); assertEquals(1, threadpool.size()); assertEquals(0, clientpool.size()); // Make second callback and verify that worker thread gets reused. client.invoke("callback"); assertEquals(2, callbackHandler.counter); log.info("second callback successful"); assertEquals(0, threadpool.size()); assertEquals(1, clientpool.size()); clientpoolContents = clientpool.getContents(); ServerThread serverThread2 = (ServerThread) clientpoolContents.iterator().next(); assertEquals(serverThread2, serverThread1); log.info("ServerThread was reused"); client.removeListener(callbackHandler); client.disconnect(); shutdownServer(); 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; 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 { HashSet callbackHandlers = new HashSet(); public void addListener(InvokerCallbackHandler callbackHandler) { callbackHandlers.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { String command = (String) invocation.getParameter(); if ("callback".equals(command)) { Callback callback = new Callback("callback"); Iterator it = callbackHandlers.iterator(); while (it.hasNext()) { ServerInvokerCallbackHandler handler; handler = (ServerInvokerCallbackHandler) it.next(); handler.handleCallback(callback); } } return command; } public void removeListener(InvokerCallbackHandler callbackHandler) { callbackHandlers.remove(callbackHandler); } public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class TestCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; log.info("received callback"); } } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectionfailure/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000755000175000017500000000000011632407035033575 5ustar twernertwerner././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectionfailure/BisocketCallbackConnectionFailureTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/connectio0000644000175000017500000000401311413660476033604 0ustar twernertwerner /* * 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.transport.bisocket.connectionfailure; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent; /** * Unit test for JBREM-875. * * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Dec 10, 2007 *

          */ public class BisocketCallbackConnectionFailureTestCase extends CallbackConnectionFailureTestParent { protected String getTransport() { return "bisocket"; } protected String extendInvokerLocator(String locatorURI) { if (!locatorURI.endsWith("/?")) locatorURI += "/?"; locatorURI += Bisocket.PING + "=1000"; locatorURI += Bisocket.MAX_RETRIES + "=1"; return locatorURI; } protected void addExtraCallbackMetadata(Map map) { map.put(Bisocket.IS_CALLBACK_SERVER, "true"); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/SecondaryServerSocketTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/Secondary0000644000175000017500000005454610743035626033570 0ustar twernertwerner/* * 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.transport.bisocket; import java.io.ByteArrayInputStream; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.ServerSocket; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import javax.xml.parsers.DocumentBuilderFactory; 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; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.w3c.dom.Document; /** * Unit tests for JBREM-755. * * @author Ron Sigal * @version $Revision: 3283 $ *

          * Copyright Aug 22, 2007 *

          */ public class SecondaryServerSocketTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(SecondaryServerSocketTestCase.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() { } /** * Verify that secondary port is correctly set when specifed in InvokerLocator. */ public void testSetSecondaryPortByInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int PORT = PortUtil.findFreePort(host); port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?" + Bisocket.SECONDARY_BIND_PORT + "=" + 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"); // Verify secondary ServerSocket port is set correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(serverInvoker instanceof BisocketServerInvoker); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryBindPorts"); field.setAccessible(true); List secondaryBindPorts = (List) field.get(serverInvoker); Integer secondaryBindPort = (Integer) secondaryBindPorts.get(0); assertEquals(PORT, secondaryBindPort.intValue()); field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSockets"); field.setAccessible(true); Set secondaryServerSockets = (Set) field.get(serverInvoker); ServerSocket serverSocket = (ServerSocket) secondaryServerSockets.iterator().next(); assertEquals(PORT, serverSocket.getLocalPort()); client.disconnect(); connector.stop(); } /** * Verify that secondary bind port is correctly set when specifed in config map. */ public void testSetSecondaryBindPortByConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int PORT = PortUtil.findFreePort(host); 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(Bisocket.SECONDARY_BIND_PORT, Integer.toString(PORT)); 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"); // Verify secondary ServerSocket port is set correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(serverInvoker instanceof BisocketServerInvoker); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryBindPorts"); field.setAccessible(true); List secondaryBindPorts = (List) field.get(serverInvoker); Integer secondaryBindPort = (Integer) secondaryBindPorts.get(0); assertEquals(PORT, secondaryBindPort.intValue()); field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSockets"); field.setAccessible(true); Set secondaryServerSockets = (Set) field.get(serverInvoker); ServerSocket serverSocket = (ServerSocket) secondaryServerSockets.iterator().next(); assertEquals(PORT, serverSocket.getLocalPort()); client.disconnect(); connector.stop(); } /** * Verify that secondary bind port is correctly set by * BisocketServerInvoker.setSecondaryBindPort(). */ public void testSetSecondaryBindPortBySetter() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int PORT = PortUtil.findFreePort(host); 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(); assertTrue(connector.getServerInvoker() instanceof BisocketServerInvoker); BisocketServerInvoker serverInvoker = (BisocketServerInvoker) connector.getServerInvoker(); serverInvoker.setSecondaryBindPort(PORT); 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"); // Verify secondary ServerSocket port is set correctly. Field field = BisocketServerInvoker.class.getDeclaredField("secondaryBindPorts"); field.setAccessible(true); List secondaryBindPorts = (List) field.get(serverInvoker); log.info("secondaryBindPorts.size(): " + secondaryBindPorts.size()); Integer secondaryBindPort = (Integer) secondaryBindPorts.get(0); assertEquals(PORT, secondaryBindPort.intValue()); field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSockets"); field.setAccessible(true); Set secondaryServerSockets = (Set) field.get(serverInvoker); ServerSocket serverSocket = (ServerSocket) secondaryServerSockets.iterator().next(); assertEquals(PORT, serverSocket.getLocalPort()); client.disconnect(); connector.stop(); } /** * Verify that secondary bind port is correctly set by when specified * in XML document. */ public void testSetSecondaryBindPortByXMLConfig() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int PORT = PortUtil.findFreePort(host); port = PortUtil.findFreePort(host); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(config); // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + host + ""); buf.append(" " + port + ""); buf.append(" " + PORT + ""); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); String locatorURI = connector.getInvokerLocator(); log.info("Started remoting server with locator uri of: " + locatorURI); serverLocator = new InvokerLocator(locatorURI); // 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"); // Verify secondary ServerSocket port is set correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(serverInvoker instanceof BisocketServerInvoker); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryBindPorts"); field.setAccessible(true); List secondaryBindPorts = (List) field.get(serverInvoker); Integer secondaryBindPort = (Integer) secondaryBindPorts.get(0); assertEquals(PORT, secondaryBindPort.intValue()); field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSockets"); field.setAccessible(true); Set secondaryServerSockets = (Set) field.get(serverInvoker); ServerSocket serverSocket = (ServerSocket) secondaryServerSockets.iterator().next(); assertEquals(PORT, serverSocket.getLocalPort()); client.disconnect(); connector.stop(); } /** * Verify that secondary connect port is correctly set when specifed in config map. */ public void testSetSecondaryConnectPortByConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int PORT = PortUtil.findFreePort(host); 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(Bisocket.SECONDARY_CONNECT_PORT, Integer.toString(PORT)); 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"); // Verify secondaryLocator is set correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(serverInvoker instanceof BisocketServerInvoker); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryLocator"); field.setAccessible(true); InvokerLocator secondaryLocator = (InvokerLocator) field.get(serverInvoker); log.info("secondaryLocator: " + secondaryLocator); assertEquals(PORT, secondaryLocator.getPort()); client.disconnect(); connector.stop(); } /** * Verifies that host in secondary InvokerLocator can be set by * clientConnectAddress parameter. */ public void testClientConnectAddressFromXML() throws Throwable { log.info("entering " + getName()); // Start server. String HOST = InetAddress.getLocalHost().getHostName(); String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); connector = new Connector(config); // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + host + ""); buf.append(" " + port + ""); buf.append(" " + HOST + ""); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); String locatorURI = connector.getInvokerLocator(); log.info("Started remoting server with locator uri of: " + locatorURI); serverLocator = new InvokerLocator(locatorURI); // 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"); // Verify secondaryLocator is set correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(serverInvoker instanceof BisocketServerInvoker); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryLocator"); field.setAccessible(true); InvokerLocator secondaryLocator = (InvokerLocator) field.get(serverInvoker); log.info("secondaryLocator: " + secondaryLocator); assertEquals(HOST, secondaryLocator.getHost()); client.disconnect(); connector.stop(); } /** * Verifies that host in secondary InvokerLocator can be set by InvokerLocator. */ public void testClientConnectAddressFromInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. String HOST = InetAddress.getLocalHost().getHostName(); 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"); // Verify secondaryLocator is set correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(serverInvoker instanceof BisocketServerInvoker); Field field = BisocketServerInvoker.class.getDeclaredField("secondaryLocator"); field.setAccessible(true); InvokerLocator secondaryLocator = (InvokerLocator) field.get(serverInvoker); log.info("secondaryLocator: " + secondaryLocator); assertEquals(HOST, secondaryLocator.getHost()); client.disconnect(); connector.stop(); } /** * Verifies that secondary ServerSocket is bound to the same address as the * primary ServerSocket. */ public void testServerBindAddress() throws Throwable { log.info("entering " + getName()); // Start server. String HOST = InetAddress.getLocalHost().getHostName(); 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.SERVER_BIND_ADDRESS_KEY, HOST); 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"); // Verify secondary ServerSocket port is set correctly. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(serverInvoker instanceof BisocketServerInvoker); Field field = SocketServerInvoker.class.getDeclaredField("serverSockets"); field.setAccessible(true); List serverSockets = (List) field.get(serverInvoker); ServerSocket primaryServerSocket = (ServerSocket) serverSockets.get(0); field = BisocketServerInvoker.class.getDeclaredField("secondaryServerSockets"); field.setAccessible(true); Set secondaryServerSockets = (Set) field.get(serverInvoker); ServerSocket secondaryServerSocket = (ServerSocket) secondaryServerSockets.iterator().next(); assertEquals(primaryServerSocket.getInetAddress(), secondaryServerSocket.getInetAddress()); 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 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) {} } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketImmediateShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketI0000644000175000017500000000071411413660476033503 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket; import org.jboss.test.remoting.transport.socket.shutdown.SocketImmediateShutdownTestCase; /** * Unit test for JBREM-1123. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Apr 19, 2009 *

          */ public class BisocketImmediateShutdownTestCase extends SocketImmediateShutdownTestCase { protected String getTransport() { return "bisocket"; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketT0000644000175000017500000032351611254052030033506 0ustar twernertwerner/* * 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.transport.bisocket; import java.io.ByteArrayInputStream; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.Socket; import java.util.Collection; 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 javax.xml.parsers.DocumentBuilderFactory; 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.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; import org.w3c.dom.Document; /** * @author Ron Sigal * @version $Revision: 5489 $ *

          * Copyright Nov 25, 2006 *

          */ public class BisocketTestCase extends TestCase { public static int port = 5413; private static Logger log = Logger.getLogger(BisocketTestCase.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 TEST_PING_FREQUENCY_STRING = "1000"; private static final int TEST_PING_FREQUENCY = 1000; private static final String TEST_PING_WINDOW_FACTOR_STRING = "3"; private static final int TEST_PING_WINDOW_FACTOR = 3; private static final String TEST_MAX_RETRIES_STRING = "5"; private static final int TEST_MAX_RETRIES = 5; private static final String TEST_CONTROL_CONNECTION_RESTARTS_STRING = "7"; private static final int TEST_CONTROL_CONNECTION_RESTARTS = 7; private static final String TEST_MAX_POOL_SIZE_STRING = "9"; private static final int TEST_MAX_POOL_SIZE = 9; private static boolean firstTime = true; // remoting server connector private Connector connector; 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); } String host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); internalSetUp(port); } protected void internalSetUp(int port) throws Exception { String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); config.put(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, TEST_MAX_POOL_SIZE_STRING); addExtraServerConfig(config); for (int i = 0; i < 5; i++) { try { if (i > 0) { log.info("will retry to start Connector"); } connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); break; } catch (Exception e) { log.info("unable to start Connector for " + serverLocator, e); connector.stop(); Thread.sleep(60000); } } if (connector == null || !connector.isStarted()) { log.error("Unable to start Connector"); throw new Exception("Unable to start Connector: " + serverLocator); } } /** * Shuts down the server */ public void tearDown() { connector.stop(); connector.destroy(); } public void testConfiguration() throws Throwable { log.info("entering " + getName()); connector.stop(); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); serverConfig.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); serverConfig.put(Bisocket.MAX_RETRIES, TEST_MAX_RETRIES_STRING); addExtraServerConfig(serverConfig); connector = new Connector(serverLocator, serverConfig); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Bisocket.IS_CALLBACK_SERVER, "true"); clientConfig.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); clientConfig.put(Bisocket.PING_WINDOW_FACTOR, TEST_PING_WINDOW_FACTOR_STRING); clientConfig.put(Bisocket.MAX_RETRIES, TEST_MAX_RETRIES_STRING); clientConfig.put(Bisocket.MAX_CONTROL_CONNECTION_RESTARTS, TEST_CONTROL_CONNECTION_RESTARTS_STRING); addExtraClientConfig(clientConfig); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); 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()); // Test server invoker configuration. // Actually, none of these parameters are used by the server invoker. // Test callback client invoker configuration. Set callbackHandlers = invocationHandler.callbackHandlers; assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler sich = (ServerInvokerCallbackHandler) callbackHandlers.iterator().next(); Client callbackClient = sich.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker); BisocketClientInvoker callbackClientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); assertEquals(TEST_PING_FREQUENCY, callbackClientInvoker.getPingFrequency()); assertEquals(TEST_MAX_RETRIES, callbackClientInvoker.getMaxRetries()); // Test client invoker configuration. assertTrue(client.getInvoker() instanceof BisocketClientInvoker); BisocketClientInvoker clientInvoker = (BisocketClientInvoker) client.getInvoker(); assertEquals(TEST_PING_FREQUENCY, clientInvoker.getPingFrequency()); assertEquals(TEST_MAX_RETRIES, clientInvoker.getMaxRetries()); // 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(); assertTrue(connector.getServerInvoker() instanceof BisocketServerInvoker); BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); assertEquals(TEST_PING_FREQUENCY, callbackServerInvoker.getPingFrequency()); assertEquals(TEST_PING_WINDOW_FACTOR, callbackServerInvoker.getPingWindowFactor()); field = BisocketServerInvoker.class.getDeclaredField("pingWindow"); field.setAccessible(true); int pingWindow = ((Integer) field.get(callbackServerInvoker)).intValue(); assertEquals(TEST_PING_WINDOW_FACTOR * TEST_PING_FREQUENCY, pingWindow); assertEquals(TEST_MAX_RETRIES, callbackServerInvoker.getSocketCreationRetries()); assertEquals(TEST_CONTROL_CONNECTION_RESTARTS, callbackServerInvoker.getControlConnectionRestarts()); client.removeListener(callbackHandler); client.disconnect(); } public void testXMLConfiguration() throws Throwable { log.info("entering " + getName()); connector.stop(); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(serverConfig); connector = new Connector(serverConfig); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + host + ""); buf.append(" " + port + ""); buf.append(" " + TEST_PING_FREQUENCY_STRING + ""); buf.append(" " + TEST_PING_WINDOW_FACTOR_STRING + ""); buf.append(" " + TEST_MAX_RETRIES_STRING + ""); buf.append(" " + TEST_CONTROL_CONNECTION_RESTARTS_STRING + ""); buf.append(" "); buf.append(""); log.info(buf); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); InvokerLocator serverLocator = connector.getLocator(); System.out.println("started connector with locator uri of: " + serverLocator); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Bisocket.IS_CALLBACK_SERVER, "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()); log.info("client added callback handler"); 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()); // Test server invoker configuration. // Actually, none of these parameters are used by the server invoker. // Test callback client invoker configuration. Set callbackHandlers = invocationHandler.callbackHandlers; assertEquals(1, callbackHandlers.size()); ServerInvokerCallbackHandler sich = (ServerInvokerCallbackHandler) callbackHandlers.iterator().next(); Client callbackClient = sich.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker); BisocketClientInvoker callbackClientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); assertEquals(TEST_PING_FREQUENCY, callbackClientInvoker.getPingFrequency()); assertEquals(TEST_MAX_RETRIES, callbackClientInvoker.getMaxRetries()); // Test client invoker configuration. assertTrue(client.getInvoker() instanceof BisocketClientInvoker); BisocketClientInvoker clientInvoker = (BisocketClientInvoker) client.getInvoker(); assertEquals(TEST_PING_FREQUENCY, clientInvoker.getPingFrequency()); assertEquals(TEST_MAX_RETRIES, clientInvoker.getMaxRetries()); // 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(); assertTrue(connector.getServerInvoker() instanceof BisocketServerInvoker); BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); assertEquals(TEST_PING_FREQUENCY, callbackServerInvoker.getPingFrequency()); assertEquals(TEST_PING_WINDOW_FACTOR, callbackServerInvoker.getPingWindowFactor()); field = BisocketServerInvoker.class.getDeclaredField("pingWindow"); field.setAccessible(true); int pingWindow = ((Integer) field.get(callbackServerInvoker)).intValue(); assertEquals(TEST_PING_WINDOW_FACTOR * TEST_PING_FREQUENCY, pingWindow); assertEquals(TEST_MAX_RETRIES, callbackServerInvoker.getSocketCreationRetries()); assertEquals(TEST_CONTROL_CONNECTION_RESTARTS, callbackServerInvoker.getControlConnectionRestarts()); client.removeListener(callbackHandler); client.disconnect(); } public void testInvocations() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); int invocationCount = 1000; HashMap metadata = new HashMap(1); for (int i = 0; i < invocationCount; i++) { Integer count = new Integer(i); metadata.put(COUNTER, count); Object response = client.invoke(INVOCATION_TEST, metadata); response.equals(count); } client.disconnect(); } public void testInvocationsThenCallbacksThenInvocations() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); int invocationCount = 100; HashMap metadata = new HashMap(1); for (int i = 0; i < invocationCount; i++) { Integer count = new Integer(i); metadata.put(COUNTER, count); Object response = client.invoke(INVOCATION_TEST, metadata); assertTrue(response.equals(count)); } SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); for (int i = 0; i < invocationCount; i++) { client.invoke(CALLBACK_TEST); } assertEquals(invocationCount, callbackHandler.callbackCounter); for (int i = 0; i < invocationCount; i++) { Integer count = new Integer(i); metadata.put(COUNTER, count); Object response = client.invoke(INVOCATION_TEST, metadata); assertTrue(response.equals(count)); } client.removeListener(callbackHandler); client.disconnect(); } public void testAlternatingInvocationsAndCallbacks() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); int invocationCount = 100; HashMap metadata = new HashMap(1); for (int i = 0; i < invocationCount; i++) { Integer count = new Integer(i); metadata.put(COUNTER, count); Object response = client.invoke(INVOCATION_TEST, metadata); client.invoke(CALLBACK_TEST); assertTrue(response.equals(count)); } assertEquals(invocationCount, callbackHandler.callbackCounter); client.removeListener(callbackHandler); client.disconnect(); } public void testPullCallbacks() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler); log.info("client added pull callback handler"); HashMap metadata = new HashMap(1); Integer count = new Integer(3); metadata.put(COUNTER, count); Object response = client.invoke(INVOCATION_TEST, metadata); assertTrue(response.equals(count)); client.invoke(CALLBACK_TEST); List callbacks = client.getCallbacks(callbackHandler); assertEquals(1, callbacks.size()); Field field = BisocketClientInvoker.class.getDeclaredField("listenerIdToClientInvokerMap"); field.setAccessible(true); Map listenerIdToClientInvokerMap = (Map) field.get(client.getInvoker()); assertEquals(0, listenerIdToClientInvokerMap.size()); client.removeListener(callbackHandler); client.disconnect(); } public void testMaxSocketPoolSize() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(4000); client.addListener(callbackHandler, new HashMap()); assertEquals(1, invocationHandler.callbackHandlers.size()); log.info("client added callback handler"); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool = (List) field.get(clientInvoker); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); // field.setAccessible(true); assertEquals(0, pool.size()); // Long usedPooled = (Long) field.get(clientInvoker); // assertEquals(0, usedPooled.intValue()); assertEquals(0, clientInvoker.getNumberOfUsedConnections()); int invocationCount = TEST_MAX_POOL_SIZE; for (int i = 0; i < invocationCount; i++) { client.invokeOneway(CALLBACK_TEST); } Thread.sleep(2000); // +2000 assertEquals(invocationCount, callbackHandler.callbackCounter); assertEquals(0, pool.size()); // usedPooled = (Long) field.get(clientInvoker); // assertEquals(invocationCount, usedPooled.intValue()); assertEquals(invocationCount, clientInvoker.getNumberOfUsedConnections()); for (int i = 0; i < invocationCount; i++) { client.invokeOneway(CALLBACK_TEST); } assertEquals(invocationCount, callbackHandler.callbackCounter); assertEquals(0, pool.size()); // usedPooled = (Long) field.get(clientInvoker); // assertEquals(invocationCount, usedPooled.intValue()); assertEquals(invocationCount, clientInvoker.getNumberOfUsedConnections()); Thread.sleep(1000); // +3000 assertEquals(invocationCount, callbackHandler.callbackCounter); assertEquals(0, pool.size()); // usedPooled = (Long) field.get(clientInvoker); // assertEquals(invocationCount, usedPooled.intValue()); assertEquals(invocationCount, clientInvoker.getNumberOfUsedConnections()); Thread.sleep(3000); // +6000 assertEquals(2 * invocationCount, callbackHandler.callbackCounter); assertEquals(0, pool.size()); // usedPooled = (Long) field.get(clientInvoker); // assertEquals(invocationCount, usedPooled.intValue()); assertEquals(invocationCount, clientInvoker.getNumberOfUsedConnections()); Thread.sleep(4000); // +10000 assertEquals(2 * invocationCount, callbackHandler.callbackCounter); assertEquals(invocationCount, pool.size()); // usedPooled = (Long) field.get(clientInvoker); // assertEquals(0, usedPooled.intValue()); assertEquals(0, clientInvoker.getNumberOfUsedConnections()); client.removeListener(callbackHandler); client.disconnect(); } public void testOneClientOneConnectorOneHandler() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); log.info("client is connected"); String callbackLocatorURI = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector = new Connector(callbackLocatorURI, config); callbackConnector.start(); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(); client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI)); assertEquals(1, invocationHandler.callbackHandlers.size()); log.info("client added callback handler"); client.invokeOneway(CALLBACK_TEST); client.invokeOneway(CALLBACK_TEST); client.invokeOneway(CALLBACK_TEST); Thread.sleep(500); assertEquals(3, callbackHandler.callbackCounter); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool = (List) field.get(clientInvoker); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); field.setAccessible(true); assertEquals(0, pool.size()); // Long usedPooled = (Long) field.get(clientInvoker); // assertEquals(3, usedPooled.intValue()); assertEquals(3, clientInvoker.getNumberOfUsedConnections()); Thread.sleep(3000); assertEquals(3, pool.size()); // usedPooled = (Long) field.get(clientInvoker); // assertEquals(0, usedPooled.intValue()); assertEquals(0, clientInvoker.getNumberOfUsedConnections()); client.removeListener(callbackHandler); client.disconnect(); callbackConnector.stop(); } public void testOneClientOneConnectorTwoHandlers() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); String callbackLocatorURI = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector = new Connector(callbackLocatorURI, config); callbackConnector.start(); DelayedCallbackHandler callbackHandler1 = new DelayedCallbackHandler(); client.addListener(callbackHandler1, new InvokerLocator(callbackLocatorURI)); DelayedCallbackHandler callbackHandler2 = new DelayedCallbackHandler(); client.addListener(callbackHandler2, new InvokerLocator(callbackLocatorURI)); assertEquals(2, invocationHandler.callbackHandlers.size()); log.info("clients added callback handler"); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next(); ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next(); Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient(); Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient(); assertNotSame(callbackClient1, callbackClient2); ClientInvoker clientInvoker1 = callbackClient1.getInvoker(); assertTrue(clientInvoker1 instanceof BisocketClientInvoker); ClientInvoker clientInvoker2 = callbackClient2.getInvoker(); assertTrue(clientInvoker2 instanceof BisocketClientInvoker); assertNotSame(clientInvoker1, clientInvoker2); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool1 = (List) field.get(clientInvoker1); List pool2 = (List) field.get(clientInvoker2); assertNotSame(pool1, pool2); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); // field.setAccessible(true); assertEquals(0, callbackHandler1.callbackCounter); assertEquals(0, callbackHandler2.callbackCounter); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // Long usedPooled1 = (Long) field.get(clientInvoker1); // Long usedPooled2 = (Long) field.get(clientInvoker2); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client.invokeOneway(CALLBACK_TEST); client.invokeOneway(CALLBACK_TEST); Thread.sleep(500); int count1 = callbackHandler1.callbackCounter; int count2 = callbackHandler2.callbackCounter; assertTrue(count1 == 2 && count2 == 0 || count1 == 0 && count2 == 2); if (count1 == 0) { Object temp = callbackHandler1; callbackHandler1 = callbackHandler2; callbackHandler2 = (DelayedCallbackHandler) temp;; } assertEquals(2, callbackHandler1.callbackCounter); assertEquals(0, callbackHandler2.callbackCounter); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(2, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbackCounter); assertEquals(2, callbackHandler2.callbackCounter); assertEquals(2, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(2, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbackCounter); assertEquals(2, callbackHandler2.callbackCounter); assertEquals(2, pool1.size()); assertEquals(2, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(0, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); client.disconnect(); callbackConnector.stop(); } public void testOneClientTwoConnectorsOneHandler() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); log.info("client is connected"); String callbackLocatorURI1 = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector1 = new Connector(callbackLocatorURI1, config); callbackConnector1.start(); String callbackLocatorURI2 = getTransport() + "://" + host + ":2"; Connector callbackConnector2 = new Connector(callbackLocatorURI2, config); callbackConnector2.start(); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(); client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI1)); client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI2)); assertEquals(2, invocationHandler.callbackHandlers.size()); log.info("client added callback handlers"); client.invokeOneway(CALLBACK_TEST); client.invokeOneway(CALLBACK_TEST); Thread.sleep(500); assertEquals(2, callbackHandler.callbackCounter); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next(); ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next(); Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient(); Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient(); assertNotSame(callbackClient1, callbackClient2); assertTrue(callbackClient1.getInvoker() instanceof BisocketClientInvoker); MicroSocketClientInvoker clientInvoker1 = (MicroSocketClientInvoker) callbackClient1.getInvoker(); assertTrue(callbackClient2.getInvoker() instanceof BisocketClientInvoker); MicroSocketClientInvoker clientInvoker2 = (MicroSocketClientInvoker) callbackClient2.getInvoker(); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool1 = (List) field.get(clientInvoker1); List pool2 = (List) field.get(clientInvoker2); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); // field.setAccessible(true); // Long usedPooled1 = (Long) field.get(clientInvoker1); // assertEquals(2, usedPooled1.intValue()); assertEquals(2, clientInvoker1.getNumberOfUsedConnections()); // Long usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled2.intValue()); // assertEquals(0, usedPooled2); assertEquals(0, clientInvoker2.getNumberOfUsedConnections()); Thread.sleep(3000); assertEquals(2, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // assertEquals(0, usedPooled1.intValue()); assertEquals(0, clientInvoker1.getNumberOfUsedConnections()); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(2, usedPooled2.intValue()); assertEquals(2, clientInvoker2.getNumberOfUsedConnections()); Thread.sleep(3000); assertEquals(2, pool1.size()); assertEquals(2, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // assertEquals(0, usedPooled1.intValue()); assertEquals(0, clientInvoker1.getNumberOfUsedConnections()); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled2.intValue()); assertEquals(0, clientInvoker2.getNumberOfUsedConnections()); client.removeListener(callbackHandler); client.disconnect(); callbackConnector1.stop(); callbackConnector2.stop(); } public void testOneClientTwoConnectorsTwoHandlers() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); String callbackLocatorURI1 = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector1 = new Connector(callbackLocatorURI1, config); callbackConnector1.start(); String callbackLocatorURI2 = getTransport() + "://" + host + ":2"; Connector callbackConnector2 = new Connector(callbackLocatorURI2, config); callbackConnector2.start(); DelayedCallbackHandler callbackHandler1 = new DelayedCallbackHandler(); client.addListener(callbackHandler1, new InvokerLocator(callbackLocatorURI1)); DelayedCallbackHandler callbackHandler2 = new DelayedCallbackHandler(); client.addListener(callbackHandler2, new InvokerLocator(callbackLocatorURI2)); assertEquals(2, invocationHandler.callbackHandlers.size()); log.info("clients added callback handler"); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next(); ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next(); Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient(); Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient(); assertNotSame(callbackClient1, callbackClient2); ClientInvoker clientInvoker1 = callbackClient1.getInvoker(); assertTrue(clientInvoker1 instanceof BisocketClientInvoker); ClientInvoker clientInvoker2 = callbackClient2.getInvoker(); assertTrue(clientInvoker2 instanceof BisocketClientInvoker); assertNotSame(clientInvoker1, clientInvoker2); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool1 = (List) field.get(clientInvoker1); List pool2 = (List) field.get(clientInvoker2); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); // field.setAccessible(true); assertEquals(0, callbackHandler1.callbackCounter); assertEquals(0, callbackHandler2.callbackCounter); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // Long usedPooled1 = (Long) field.get(clientInvoker1); // Long usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client.invokeOneway(CALLBACK_TEST); client.invokeOneway(CALLBACK_TEST); Thread.sleep(2000); int count1 = callbackHandler1.callbackCounter; int count2 = callbackHandler2.callbackCounter; assertTrue(count1 == 2 && count2 == 0 || count1 == 0 && count2 == 2); if (count1 == 0) { Object temp = callbackHandler1; callbackHandler1 = callbackHandler2; callbackHandler2 = (DelayedCallbackHandler) temp;; } assertEquals(2, callbackHandler1.callbackCounter); assertEquals(0, callbackHandler2.callbackCounter); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(2, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbackCounter); assertEquals(2, callbackHandler2.callbackCounter); assertEquals(2, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(2, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbackCounter); assertEquals(2, callbackHandler2.callbackCounter); assertEquals(2, pool1.size()); assertEquals(2, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(0, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); client.disconnect(); callbackConnector1.stop(); callbackConnector2.stop(); } public void testTwoClientsOneConnectorOneHandler() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client1 = new Client(serverLocator, config); client1.connect(); Client client2 = new Client(serverLocator, config); client2.connect(); log.info("clients are connected"); assertTrue(client1.getInvoker() instanceof BisocketClientInvoker); assertTrue(client2.getInvoker() instanceof BisocketClientInvoker); String callbackLocatorURI = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector = new Connector(callbackLocatorURI, config); callbackConnector.start(); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(); client1.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI)); client2.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI)); assertEquals(1, invocationHandler.callbackHandlers.size()); log.info("clients added callback handler"); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); ClientInvoker clientInvoker = callbackClient.getInvoker(); assertTrue(clientInvoker instanceof BisocketClientInvoker); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool = (List) field.get(clientInvoker); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); // field.setAccessible(true); assertEquals(0, callbackHandler.callbackCounter); assertEquals(0, pool.size()); // Long usedPooled = (Long) field.get(clientInvoker); // assertEquals(0, usedPooled.longValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker).getNumberOfUsedConnections()); client1.invokeOneway(CALLBACK_TEST); client2.invokeOneway(CALLBACK_TEST); Thread.sleep(500); assertEquals(2, callbackHandler.callbackCounter); assertEquals(0, pool.size()); // usedPooled = (Long) field.get(clientInvoker); // assertEquals(2, usedPooled.longValue()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler.callbackCounter); assertEquals(2, pool.size()); // usedPooled = (Long) field.get(clientInvoker); // assertEquals(0, usedPooled.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker).getNumberOfUsedConnections()); client1.removeListener(callbackHandler); client1.disconnect(); client2.removeListener(callbackHandler); client2.disconnect(); callbackConnector.stop(); } public void testTwoClientsOneConnectorTwoHandlers() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); String callbackLocatorURI = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector = new Connector(callbackLocatorURI, config); callbackConnector.start(); DelayedCallbackHandler callbackHandler1 = new DelayedCallbackHandler(); client.addListener(callbackHandler1, new InvokerLocator(callbackLocatorURI)); DelayedCallbackHandler callbackHandler2 = new DelayedCallbackHandler(); client.addListener(callbackHandler2, new InvokerLocator(callbackLocatorURI)); assertEquals(2, invocationHandler.callbackHandlers.size()); log.info("clients added callback handler"); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next(); ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next(); Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient(); Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient(); assertNotSame(callbackClient1, callbackClient2); ClientInvoker clientInvoker1 = callbackClient1.getInvoker(); assertTrue(clientInvoker1 instanceof BisocketClientInvoker); ClientInvoker clientInvoker2 = callbackClient2.getInvoker(); assertTrue(clientInvoker2 instanceof BisocketClientInvoker); assertNotSame(clientInvoker1, clientInvoker2); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool1 = (List) field.get(clientInvoker1); List pool2 = (List) field.get(clientInvoker2); assertNotSame(pool1, pool2); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); // field.setAccessible(true); assertEquals(0, callbackHandler1.callbackCounter); assertEquals(0, callbackHandler2.callbackCounter); assertEquals(0, pool1.size()); // Long usedPooled1 = (Long) field.get(clientInvoker1); // Long usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client.invokeOneway(CALLBACK_TEST); client.invokeOneway(CALLBACK_TEST); Thread.sleep(500); int count1 = callbackHandler1.callbackCounter; int count2 = callbackHandler2.callbackCounter; assertTrue(count1 == 2 && count2 == 0 || count1 == 0 && count2 == 2); if (count1 == 0) { Object temp = callbackHandler1; callbackHandler1 = callbackHandler2; callbackHandler2 = (DelayedCallbackHandler) temp;; } assertEquals(2, callbackHandler1.callbackCounter); assertEquals(0, callbackHandler2.callbackCounter); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(2, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbackCounter); assertEquals(2, callbackHandler2.callbackCounter); assertEquals(2, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(2, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbackCounter); assertEquals(2, callbackHandler2.callbackCounter); assertEquals(2, pool1.size()); assertEquals(2, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(0, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); client.disconnect(); callbackConnector.stop(); } public void testTwoClientsTwoConnectorsOneHandler() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client1 = new Client(serverLocator, config); client1.connect(); Client client2 = new Client(serverLocator, config); client2.connect(); log.info("clients are connected"); assertTrue(client1.getInvoker() instanceof BisocketClientInvoker); assertTrue(client2.getInvoker() instanceof BisocketClientInvoker); String callbackLocatorURI1 = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector1 = new Connector(callbackLocatorURI1, config); callbackConnector1.start(); String callbackLocatorURI2 = getTransport() + "://" + host + ":2"; Connector callbackConnector2 = new Connector(callbackLocatorURI2, config); callbackConnector2.start(); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(); client1.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI1)); client2.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI2)); assertEquals(2, invocationHandler.callbackHandlers.size()); log.info("clients added callback handler"); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next(); ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next(); Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient(); Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient(); assertNotSame(callbackClient1, callbackClient2); ClientInvoker clientInvoker1 = callbackClient1.getInvoker(); assertTrue(clientInvoker1 instanceof BisocketClientInvoker); ClientInvoker clientInvoker2 = callbackClient2.getInvoker(); assertTrue(clientInvoker2 instanceof BisocketClientInvoker); assertNotSame(clientInvoker1, clientInvoker2); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool1 = (List) field.get(clientInvoker1); List pool2 = (List) field.get(clientInvoker2); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); // field.setAccessible(true); assertEquals(0, callbackHandler.callbackCounter); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // Long usedPooled1 = (Long) field.get(clientInvoker1); // Long usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client1.invokeOneway(CALLBACK_TEST); client2.invokeOneway(CALLBACK_TEST); Thread.sleep(500); assertEquals(2, callbackHandler.callbackCounter); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(2, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(4, callbackHandler.callbackCounter); assertEquals(2, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(2, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(4, callbackHandler.callbackCounter); assertEquals(2, pool1.size()); assertEquals(2, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(0, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client1.removeListener(callbackHandler); client1.disconnect(); client2.removeListener(callbackHandler); client2.disconnect(); callbackConnector1.stop(); callbackConnector2.stop(); } public void testTwoClientsTwoConnectorsTwoHandlers() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); String callbackLocatorURI1 = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector1 = new Connector(callbackLocatorURI1, config); callbackConnector1.start(); String callbackLocatorURI2 = getTransport() + "://" + host + ":2"; Connector callbackConnector2 = new Connector(callbackLocatorURI2, config); callbackConnector2.start(); DelayedCallbackHandler callbackHandler1 = new DelayedCallbackHandler(); client.addListener(callbackHandler1, new InvokerLocator(callbackLocatorURI1)); DelayedCallbackHandler callbackHandler2 = new DelayedCallbackHandler(); client.addListener(callbackHandler2, new InvokerLocator(callbackLocatorURI2)); assertEquals(2, invocationHandler.callbackHandlers.size()); log.info("clients added callback handler"); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler1 = (ServerInvokerCallbackHandler) it.next(); ServerInvokerCallbackHandler serverInvokerCallbackHandler2 = (ServerInvokerCallbackHandler) it.next(); Client callbackClient1 = serverInvokerCallbackHandler1.getCallbackClient(); Client callbackClient2 = serverInvokerCallbackHandler2.getCallbackClient(); assertNotSame(callbackClient1, callbackClient2); ClientInvoker clientInvoker1 = callbackClient1.getInvoker(); assertTrue(clientInvoker1 instanceof BisocketClientInvoker); ClientInvoker clientInvoker2 = callbackClient2.getInvoker(); assertTrue(clientInvoker2 instanceof BisocketClientInvoker); assertNotSame(clientInvoker1, clientInvoker2); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool1 = (List) field.get(clientInvoker1); List pool2 = (List) field.get(clientInvoker2); // field = MicroSocketClientInvoker.class.getDeclaredField("usedPooled"); // field.setAccessible(true); assertEquals(0, callbackHandler1.callbackCounter); assertEquals(0, callbackHandler2.callbackCounter); assertEquals(0, pool1.size()); // Long usedPooled1 = (Long) field.get(clientInvoker1); // Long usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client.invokeOneway(CALLBACK_TEST); client.invokeOneway(CALLBACK_TEST); Thread.sleep(500); int count1 = callbackHandler1.callbackCounter; int count2 = callbackHandler2.callbackCounter; assertTrue(count1 == 2 && count2 == 0 || count1 == 0 && count2 == 2); if (count1 == 0) { Object temp = callbackHandler1; callbackHandler1 = callbackHandler2; callbackHandler2 = (DelayedCallbackHandler) temp;; } assertEquals(2, callbackHandler1.callbackCounter); assertEquals(0, callbackHandler2.callbackCounter); assertEquals(0, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(2, usedPooled1.longValue()); // assertEquals(0, usedPooled2.longValue()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbackCounter); assertEquals(2, callbackHandler2.callbackCounter); assertEquals(2, pool1.size()); assertEquals(0, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(2, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(2, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); Thread.sleep(2000); assertEquals(2, callbackHandler1.callbackCounter); assertEquals(2, callbackHandler2.callbackCounter); assertEquals(2, pool1.size()); assertEquals(2, pool2.size()); // usedPooled1 = (Long) field.get(clientInvoker1); // usedPooled2 = (Long) field.get(clientInvoker2); // assertEquals(0, usedPooled1.intValue()); // assertEquals(0, usedPooled2.intValue()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker1).getNumberOfUsedConnections()); assertEquals(0, ((MicroSocketClientInvoker) clientInvoker2).getNumberOfUsedConnections()); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); client.disconnect(); callbackConnector1.stop(); callbackConnector2.stop(); } public void testHearbeat() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); client.invoke(CALLBACK_TEST); client.invoke(CALLBACK_TEST); client.invoke(CALLBACK_TEST); Thread.sleep(500); assertEquals(3, callbackHandler.callbackCounter); Field 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 callbackConnector = (Connector) callbackConnectorSet.iterator().next(); BisocketServerInvoker invoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); Map controlConnectionThreadMap = (Map) field.get(invoker); assertEquals(1, controlConnectionThreadMap.size()); Thread t = (Thread) controlConnectionThreadMap.values().iterator().next(); Class[] classes = BisocketServerInvoker.class.getDeclaredClasses(); Class invokerClass = 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 ("BisocketServerInvoker$ControlConnectionThread".equals(className)) { invokerClass = classes[i]; break; } } assertTrue(invokerClass != null); field = invokerClass.getDeclaredField("lastPing"); field.setAccessible(true); int pingFrequency = Integer.parseInt(TEST_PING_FREQUENCY_STRING); Thread.sleep(2 * pingFrequency); Long lastPing = (Long) field.get(t); log.info("current: " + System.currentTimeMillis() + ", lastPing: " + lastPing); assertTrue((System.currentTimeMillis() - lastPing.longValue()) < pingFrequency); client.removeListener(callbackHandler); client.disconnect(); } public void testControlConnectionFailureServerSide() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.callbackCounter); ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(serverInvoker instanceof BisocketServerInvoker); 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().toArray()[0]; Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); field = BisocketClientInvoker.class.getDeclaredField("controlSocket"); field.setAccessible(true); Socket controlSocket = (Socket) field.get(clientInvoker); controlSocket.close(); log.info("CLOSED CONTROL SOCKET"); // Shut down the only existing ServerThread on the server side, and therefore // the only existing pooled connection on the client side, forcing the // next invocation to depend on the creation of a new control connection. field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); Set serverThreads = clientpool.getContents(); assertEquals(1, serverThreads.size()); ((ServerThread)serverThreads.iterator().next()).shutdown(); HashMap metadata = new HashMap(); metadata.put(COUNTER, new Integer(0)); client.invoke(INVOCATION_TEST, metadata); Thread.sleep(TEST_PING_FREQUENCY * 4); client.invoke(CALLBACK_TEST); assertEquals(2, callbackHandler.callbackCounter); field = BisocketClientInvoker.class.getDeclaredField("controlSocket"); field.setAccessible(true); Socket newControlSocket = (Socket) field.get(clientInvoker); assertTrue(!controlSocket.equals(newControlSocket)); client.removeListener(callbackHandler); client.disconnect(); } public void testControlConnectionFailureClientSide() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.callbackCounter); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker); BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); Field field = BisocketClientInvoker.class.getDeclaredField("controlSocket"); field.setAccessible(true); Socket serverSideControlSocket = (Socket) field.get(clientInvoker); 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 callbackConnector = (Connector) callbackConnectorSet.iterator().next(); BisocketServerInvoker invoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); Map controlConnectionThreadMap = (Map) field.get(invoker); assertEquals(1, controlConnectionThreadMap.size()); Collection controlConnectionThreads = controlConnectionThreadMap.values(); Thread controlConnectionThread = (Thread) controlConnectionThreads.iterator().next(); Class[] classes = BisocketServerInvoker.class.getDeclaredClasses(); Class controlConnectionThreadClass = 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 ("BisocketServerInvoker$ControlConnectionThread".equals(className)) { controlConnectionThreadClass = classes[i]; break; } } assertTrue(controlConnectionThreadClass != null); field = controlConnectionThreadClass.getDeclaredField("controlSocket"); field.setAccessible(true); Socket clientSideControlSocket = (Socket) field.get(controlConnectionThread); clientSideControlSocket.close(); log.info("CLOSED CONTROL SOCKET"); // Shut down the only existing ServerThread on the server side, and therefore // the only existing pooled connection on the client side, forcing the // next invocation to depend on the creation of a new control connection. field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(connector.getServerInvoker()); Set serverThreads = clientpool.getContents(); assertEquals(1, serverThreads.size()); ((ServerThread)serverThreads.iterator().next()).shutdown(); HashMap metadata = new HashMap(); metadata.put(COUNTER, new Integer(0)); client.invoke(INVOCATION_TEST, metadata); Thread.sleep(TEST_PING_FREQUENCY * 4); client.invoke(CALLBACK_TEST); assertEquals(2, callbackHandler.callbackCounter); Thread newControlConnectionThread = (Thread) controlConnectionThreads.iterator().next(); assertTrue(!controlConnectionThread.equals(newControlConnectionThread)); field = BisocketClientInvoker.class.getDeclaredField("controlSocket"); field.setAccessible(true); Socket newServerSideControlSocket = (Socket) field.get(clientInvoker); assertTrue(!serverSideControlSocket.equals(newServerSideControlSocket)); client.removeListener(callbackHandler); client.disconnect(); } /** * Disabling this test because recent changes to BisocketClientInvoker * (JBREM-1147: "BisocketClientInvoker.createSocket() in callback mode should check for replaced control socket") * allow better recovery, so that the failure expected in this test doesn't occur. * * @throws Throwable */ public void DISABLEDtestControlConnectionFailureBeforeFirstCallback() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); DelayedCallbackHandler callbackHandler = new DelayedCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); // Shut down control connection on client side, so that pings can't be sent // from server. Field 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 callbackConnector = (Connector) callbackConnectorSet.iterator().next(); ServerInvoker cbsi = callbackConnector.getServerInvoker(); assertTrue(cbsi instanceof BisocketServerInvoker); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); Map controlConnectionThreadMap = (Map) field.get(cbsi); assertEquals(1, controlConnectionThreadMap.size()); Thread t1 = (Thread) controlConnectionThreadMap.values().iterator().next(); Class[] classes = BisocketServerInvoker.class.getDeclaredClasses(); Class controlConnectionThreadClass = 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 ("BisocketServerInvoker$ControlConnectionThread".equals(className)) { controlConnectionThreadClass = classes[i]; break; } } assertNotNull(controlConnectionThreadClass); assertEquals(t1.getClass(), controlConnectionThreadClass); field = controlConnectionThreadClass.getDeclaredField("controlSocket"); field.setAccessible(true); Socket controlSocket = (Socket) field.get(t1); assertNotNull(controlSocket); controlSocket.close(); log.info("CLOSED CONTROL SOCKET"); log.info("***************** PingTimerTask failure EXPECTED *********************"); field = controlConnectionThreadClass.getDeclaredField("MAX_INITIAL_ATTEMPTS"); field.setAccessible(true); int MAX_INITIAL_ATTEMPTS = ((Integer) field.get(null)).intValue(); Thread.sleep(TEST_PING_FREQUENCY * (MAX_INITIAL_ATTEMPTS + 1) + 5000); log.info("***********************************************************************"); // Callback should be possible because control connection has been replaced. assertEquals(1, controlConnectionThreadMap.size()); Thread t2 = (Thread) controlConnectionThreadMap.values().iterator().next(); assertNotSame(t2, t1); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.callbackCounter); client.removeListener(callbackHandler); client.disconnect(); } public void testNoControlConnectionRestart() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); Iterator it = invocationHandler.callbackHandlers.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) callbackClient.getInvoker(); Field field = BisocketClientInvoker.class.getDeclaredField("controlSocket"); field.setAccessible(true); Socket controlSocketBefore = (Socket) field.get(clientInvoker); Thread.sleep(4 * TEST_PING_FREQUENCY); Socket controlSocketAfter = (Socket) field.get(clientInvoker); assertEquals(controlSocketBefore, controlSocketAfter); log.info("control socket: " + controlSocketBefore); client.removeListener(callbackHandler); client.disconnect(); } /** * This method tests the ability of a client to connect to a restarted * server after a failure has been detected on the control connection. */ public void testServerSlowRestart() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.callbackCounter); Connector oldConnector = connector; SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(invoker); Set threads = clientpool.getContents(); for (Iterator it = threads.iterator(); it.hasNext(); ) { ServerThread t = (ServerThread) it.next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); SocketWrapper socketWrapper = (SocketWrapper) field.get(t); socketWrapper.close(); } connector.stop(); log.info("STOPPED CONNECTOR"); for (int i = 0; i < 5; i++) { try { internalSetUp(port); break; } catch (Exception e) { log.info("unable to restart connector: retrying in 60 seconds"); tearDown(); Thread.sleep(60000); } } log.info("RESTARTED CONNECTOR"); assertNotSame(connector, oldConnector); // Wait until a failure has been detected on the control connection. Thread.sleep(TEST_PING_FREQUENCY * 5); // It is beyond the scope of Remoting to fail over to a new server, // complete with registered callback handlers. log.info("adding callback handler"); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); client.invoke(CALLBACK_TEST); assertEquals(2, callbackHandler.callbackCounter); client.removeListener(callbackHandler); client.disconnect(); // The ControlMonitorTimerTask from the first callback handler tries to recreate // its control connection, which adds an entry to // BisocketClientInvoker.listenerIdToSocketsMap which cannot be removed, which // interferes with testForLeaks(). // // TODO: Should the possibility of a leak because of this phenomenon be handled? field = BisocketClientInvoker.class.getDeclaredField("listenerIdToSocketsMap"); field.setAccessible(true); Map listenerIdToSocketsMap = (Map) field.get(null); listenerIdToSocketsMap.clear(); } /** * This method tests the ability of a client to connect to a restarted * server before a failure has been detected on the control connection. * It guards against the bug in JBREM-731. */ public void testServerQuickRestart() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.callbackCounter); Connector oldConnector = connector; SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(invoker); Set threads = clientpool.getContents(); for (Iterator it = threads.iterator(); it.hasNext(); ) { ServerThread t = (ServerThread) it.next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); SocketWrapper socketWrapper = (SocketWrapper) field.get(t); socketWrapper.close(); } connector.stop(); log.info("STOPPED CONNECTOR"); for (int i = 0; i < 5; i++) { try { internalSetUp(port); break; } catch (Exception e) { log.info("unable to restart connector: retrying in 60 seconds"); tearDown(); Thread.sleep(60000); } } log.info("RESTARTED CONNECTOR"); assertNotSame(connector, oldConnector); // It is beyond the scope of Remoting to fail over to a new server, // complete with registered callback handlers. log.info("adding callback handler"); client.addListener(callbackHandler, new HashMap()); log.info("client added callback handler"); client.invoke(CALLBACK_TEST); assertEquals(2, callbackHandler.callbackCounter); client.removeListener(callbackHandler); client.disconnect(); // The ControlMonitorTimerTask from the first callback handler tries to recreate // its control connection, which adds an entry to // BisocketClientInvoker.listenerIdToSocketsMap which cannot be removed, which // interferes with testForLeaks(). // // TODO: Should the possibility of a leak because of this phenomenon be handled? field = BisocketClientInvoker.class.getDeclaredField("listenerIdToSocketsMap"); field.setAccessible(true); Map listenerIdToSocketsMap = (Map) field.get(null); listenerIdToSocketsMap.clear(); } public void testDeadControlConnectionShutdown() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); int MAX_RETRIES = 3; config.put(Bisocket.MAX_CONTROL_CONNECTION_RESTARTS, Integer.toString(MAX_RETRIES)); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); String callbackLocatorURI = getTransport() + "://" + host + ":1"; config.put(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector = new Connector(callbackLocatorURI, config); callbackConnector.start(); SimpleCallbackHandler callbackHandler = new SimpleCallbackHandler(); client.addListener(callbackHandler, new InvokerLocator(callbackLocatorURI)); log.info("client added callback handler"); client.invoke(CALLBACK_TEST); assertEquals(1, callbackHandler.callbackCounter); SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(invoker); Set threads = clientpool.getContents(); for (Iterator it = threads.iterator(); it.hasNext(); ) { ServerThread t = (ServerThread) it.next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); SocketWrapper socketWrapper = (SocketWrapper) field.get(t); socketWrapper.close(); } connector.stop(); log.info("STOPPED CONNECTOR"); for (int i = 0; i < 5; i++) { try { internalSetUp(port); break; } catch (Exception e) { log.info("unable to restart connector: retrying in 60 seconds"); Thread.sleep(60000); } } log.info("RESTARTED CONNECTOR"); // Wait until a failure has been detected on the control connection. Thread.sleep(TEST_PING_FREQUENCY * MAX_RETRIES * 8); ServerInvoker callbackServerInvoker = callbackConnector.getServerInvoker(); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); Map controlConnectionThreadMap = (Map) field.get(callbackServerInvoker); assertEquals(0, controlConnectionThreadMap.size()); client.setDisconnectTimeout(0); client.removeListener(callbackHandler); client.disconnect(); } public void testForLeaks() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); int CALLBACK_HANDLER_COUNT = 5; SimpleCallbackHandler[] callbackHandlers = new SimpleCallbackHandler[CALLBACK_HANDLER_COUNT]; for (int i = 0; i < CALLBACK_HANDLER_COUNT; i++) { callbackHandlers[i] = new SimpleCallbackHandler(); client.addListener(callbackHandlers[i], new HashMap()); } client.invoke(CALLBACK_TEST); for (int i = 0; i < CALLBACK_HANDLER_COUNT; i++) { assertEquals(1, callbackHandlers[i].callbackCounter); } // Static fields. Field field = BisocketServerInvoker.class.getDeclaredField("listenerIdToServerInvokerMap"); field.setAccessible(true); Map listenerIdToServerInvokerMap = (Map) field.get(null); field = BisocketClientInvoker.class.getDeclaredField("listenerIdToClientInvokerMap"); field.setAccessible(true); Map listenerIdToClientInvokerMap = (Map) field.get(null); field = BisocketClientInvoker.class.getDeclaredField("listenerIdToCallbackClientInvokerMap"); field.setAccessible(true); Map listenerIdToCallbackClientInvokerMap = (Map) field.get(null); field = BisocketClientInvoker.class.getDeclaredField("listenerIdToSocketsMap"); field.setAccessible(true); Map listenerIdToSocketsMap = (Map) field.get(null); // Non-static fields. field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectors = (Map) field.get(client); assertEquals(CALLBACK_HANDLER_COUNT, callbackConnectors.size()); ServerInvoker[] serverInvokers = new ServerInvoker[CALLBACK_HANDLER_COUNT]; Map[] listenerIdToInvokerLocatorMaps = new Map[CALLBACK_HANDLER_COUNT]; Map[] controlConnectionThreadMaps = new Map[CALLBACK_HANDLER_COUNT]; int i = 0; Iterator it = callbackConnectors.values().iterator(); while (it.hasNext()) { Set set = (Set) it.next(); assertEquals(1, set.size()); Connector c = (Connector) set.iterator().next(); serverInvokers[i] = c.getServerInvoker(); assertTrue(serverInvokers[i] instanceof BisocketServerInvoker); field = BisocketServerInvoker.class.getDeclaredField("listenerIdToInvokerLocatorMap"); field.setAccessible(true); listenerIdToInvokerLocatorMaps[i] = (Map) field.get(serverInvokers[i]); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); controlConnectionThreadMaps[i] = (Map) field.get(serverInvokers[i]); i++; } assertEquals(CALLBACK_HANDLER_COUNT, listenerIdToServerInvokerMap.size()); assertEquals(CALLBACK_HANDLER_COUNT, listenerIdToClientInvokerMap.size()); assertEquals(CALLBACK_HANDLER_COUNT, listenerIdToCallbackClientInvokerMap.size()); assertEquals(CALLBACK_HANDLER_COUNT, listenerIdToSocketsMap.size()); for (int j = 0; j < CALLBACK_HANDLER_COUNT; j++) { assertEquals(1, listenerIdToInvokerLocatorMaps[j].size()); assertEquals(1, controlConnectionThreadMaps[j].size()); field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask"); field.setAccessible(true); assertNotNull(field.get(serverInvokers[j])); } for (int j = 0; j < CALLBACK_HANDLER_COUNT; j++) { client.removeListener(callbackHandlers[j]); } assertEquals(0, listenerIdToServerInvokerMap.size()); assertEquals(0, listenerIdToClientInvokerMap.size()); assertEquals(0, listenerIdToCallbackClientInvokerMap.size()); assertEquals(0, listenerIdToSocketsMap.size()); Class[] classes = BisocketServerInvoker.class.getDeclaredClasses(); Class controlMonitorTimerTaskClass = null; for (int j = 0; j < classes.length; j++) { log.info(classes[j]); String fqn = classes[j].getName(); String className = fqn.substring(fqn.lastIndexOf('.') + 1); log.info(className); if ("BisocketServerInvoker$ControlMonitorTimerTask".equals(className)) { controlMonitorTimerTaskClass = classes[j]; break; } } assertNotNull(controlMonitorTimerTaskClass); for (int j = 0; j < CALLBACK_HANDLER_COUNT; j++) { assertEquals("server invoker: " + j, 0, listenerIdToInvokerLocatorMaps[j].size()); assertEquals("server invoker: " + j, 0, controlConnectionThreadMaps[j].size()); field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask"); field.setAccessible(true); Object controlMonitorTimerTask = field.get(serverInvokers[j]); field = controlMonitorTimerTaskClass.getDeclaredField("listenerIdToInvokerLocatorMap"); field.setAccessible(true); assertNull("server invoker: " + j, field.get(controlMonitorTimerTask)); field = controlMonitorTimerTaskClass.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); assertNull("server invoker: " + j, field.get(controlMonitorTimerTask)); } client.disconnect(); } public void testForLeaksQuickRemoveListener() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostName(); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); log.info("Connecting to: " + serverLocator); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); config.put(Bisocket.PING_FREQUENCY, TEST_PING_FREQUENCY_STRING); addExtraClientConfig(config); Client client = new Client(serverLocator, config); client.connect(); log.info("client is connected"); assertTrue(client.getInvoker() instanceof BisocketClientInvoker); int CALLBACK_HANDLER_COUNT = 5; SimpleCallbackHandler[] callbackHandlers = new SimpleCallbackHandler[CALLBACK_HANDLER_COUNT]; for (int i = 0; i < CALLBACK_HANDLER_COUNT; i++) { callbackHandlers[i] = new SimpleCallbackHandler(); client.addListener(callbackHandlers[i], new HashMap()); } client.invoke(CALLBACK_TEST); for (int i = 0; i < CALLBACK_HANDLER_COUNT; i++) { assertEquals(1, callbackHandlers[i].callbackCounter); } // Static fields. Field field = BisocketServerInvoker.class.getDeclaredField("listenerIdToServerInvokerMap"); field.setAccessible(true); Map listenerIdToServerInvokerMap = (Map) field.get(null); field = BisocketClientInvoker.class.getDeclaredField("listenerIdToClientInvokerMap"); field.setAccessible(true); Map listenerIdToClientInvokerMap = (Map) field.get(null); // Non-static fields. field = Client.class.getDeclaredField("callbackConnectors"); field.setAccessible(true); Map callbackConnectors = (Map) field.get(client); assertEquals(CALLBACK_HANDLER_COUNT, callbackConnectors.size()); ServerInvoker[] serverInvokers = new ServerInvoker[CALLBACK_HANDLER_COUNT]; Map[] listenerIdToInvokerLocatorMaps = new Map[CALLBACK_HANDLER_COUNT]; Map[] controlConnectionThreadMaps = new Map[CALLBACK_HANDLER_COUNT]; int i = 0; Iterator it = callbackConnectors.values().iterator(); while (it.hasNext()) { Set set = (Set) it.next(); assertEquals(1, set.size()); Connector c = (Connector) set.iterator().next(); serverInvokers[i] = c.getServerInvoker(); assertTrue(serverInvokers[i] instanceof BisocketServerInvoker); field = BisocketServerInvoker.class.getDeclaredField("listenerIdToInvokerLocatorMap"); field.setAccessible(true); listenerIdToInvokerLocatorMaps[i] = (Map) field.get(serverInvokers[i]); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); controlConnectionThreadMaps[i] = (Map) field.get(serverInvokers[i]); i++; } assertEquals(CALLBACK_HANDLER_COUNT, listenerIdToServerInvokerMap.size()); assertEquals(CALLBACK_HANDLER_COUNT, listenerIdToClientInvokerMap.size()); for (int j = 0; j < CALLBACK_HANDLER_COUNT; j++) { assertEquals(1, listenerIdToInvokerLocatorMaps[j].size()); assertEquals(1, controlConnectionThreadMaps[j].size()); field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask"); field.setAccessible(true); assertNotNull(field.get(serverInvokers[j])); } client.setDisconnectTimeout(0); for (int j = 0; j < CALLBACK_HANDLER_COUNT; j++) { client.removeListener(callbackHandlers[j]); } assertEquals(0, listenerIdToServerInvokerMap.size()); assertEquals(0, listenerIdToClientInvokerMap.size()); Class[] classes = BisocketServerInvoker.class.getDeclaredClasses(); Class controlMonitorTimerTaskClass = null; for (int j = 0; j < classes.length; j++) { log.info(classes[j]); String fqn = classes[j].getName(); String className = fqn.substring(fqn.lastIndexOf('.') + 1); log.info(className); if ("BisocketServerInvoker$ControlMonitorTimerTask".equals(className)) { controlMonitorTimerTaskClass = classes[j]; break; } } assertNotNull(controlMonitorTimerTaskClass); for (int j = 0; j < CALLBACK_HANDLER_COUNT; j++) { assertEquals("server invoker: " + j, 0, listenerIdToInvokerLocatorMaps[j].size()); assertEquals("server invoker: " + j, 0, controlConnectionThreadMaps[j].size()); field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask"); field.setAccessible(true); Object controlMonitorTimerTask = field.get(serverInvokers[j]); field = controlMonitorTimerTaskClass.getDeclaredField("listenerIdToInvokerLocatorMap"); field.setAccessible(true); assertNull("server invoker: " + j, field.get(controlMonitorTimerTask)); field = controlMonitorTimerTaskClass.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); assertNull("server invoker: " + j, field.get(controlMonitorTimerTask)); } client.disconnect(); } public static void main(String[] args) { BisocketTestCase testCase = new BisocketTestCase(); try { testCase.setUp(); // testCase.testConfiguration(); testCase.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } protected String getTransport() { return "bisocket"; } 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 (INVOCATION_TEST.equals(payload)) { Map requestMap = invocation.getRequestPayload(); Integer counter = (Integer) requestMap.get(COUNTER); return counter; } else 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++; } } } static class DelayedCallbackHandler implements InvokerCallbackHandler { public int callbackCounter; private Object lock = new Object(); private int delay = 2000; public DelayedCallbackHandler() { } public DelayedCallbackHandler(int delay) { this.delay = delay; } public void handleCallback(Callback callback) throws HandleCallbackException { log.debug("received callback: " + callback.getParameter()); synchronized (lock) { callbackCounter++; } try { Thread.sleep(delay); } catch (InterruptedException e) { } } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketI0000644000175000017500000000345511413656340033503 0ustar twernertwerner/* * 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.transport.bisocket; import org.jboss.test.remoting.transport.InvokerClientTest; /** * @author Tom Elrod */ public class BisocketInvokerClientTest extends InvokerClientTest { public String getTransport() { return "bisocket"; } public static void main(String[] args) { BisocketInvokerClientTest client = new BisocketInvokerClientTest(); try { client.setUp(); client.testArrayReturn(); client.testLocalPushCallback(); client.testPullCallback(); client.testPullCallback(); client.testRemotePushCallback(); client.testThrownException(); client.tearDown(); } catch (Throwable throwable) { throwable.printStackTrace(); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketexc0000755000175000017500000000000011632407035033604 5ustar twernertwerner././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketexc0000644000175000017500000002004311413660476033614 0ustar twernertwerner/* * 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.transport.bisocket.socketexception; import java.io.IOException; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.net.ServerSocketFactory; import org.apache.log4j.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 org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.test.remoting.transport.socket.socketexception.SocketCreationExceptionTestCase; /** * Unit tests for JBREM-1152. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Sep 9, 2009 *

          */ public class BisocketSocketCreationExceptionTestCase extends SocketCreationExceptionTestCase { private static Logger log = Logger.getLogger(BisocketSocketCreationExceptionTestCase.class); public void testCallbackException() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(new TestServerSocketFactory(2, new SocketException(getName()))); // 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 connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); TestCallbackHandler callbackHandler = new TestCallbackHandler(); Map metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler, metadata); // Get client side ServerThread pool. Set callbackConnectors = client.getCallbackConnectors(callbackHandler); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); SocketServerInvoker serverInvoker = (SocketServerInvoker) callbackConnector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); // Verify MicroSocketClientInvoker retries invocation after failure to get a connection. client.invoke(SEND_CALLBACK); assertEquals(1, callbackHandler.received); Set set = clientpool.getContents(); Object[] serverThreads = set.toArray(); for (int i = 0; i < serverThreads.length; i++) { ServerThread st = (ServerThread) serverThreads[i]; st.shutdown(); } client.invoke(SEND_CALLBACK); assertEquals(2, callbackHandler.received); set = clientpool.getContents(); serverThreads = set.toArray(); for (int i = 0; i < serverThreads.length; i++) { ServerThread st = (ServerThread) serverThreads[i]; st.shutdown(); } client.invoke(SEND_CALLBACK); assertEquals(3, callbackHandler.received); client.removeListener(callbackHandler); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } static class TestCallbackHandler implements InvokerCallbackHandler { public int received; public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback"); received++; } } static public class TestServerSocketFactory extends ServerSocketFactory { int initialSuccesses; IOException exception; public TestServerSocketFactory() { this.initialSuccesses = -1; this.exception = new IOException(); } public TestServerSocketFactory(int initialSuccesses, IOException exception) { this.initialSuccesses = initialSuccesses; this.exception = exception; } public ServerSocket createServerSocket() throws IOException { ServerSocket ss = new TestServerSocket(initialSuccesses, exception); log.info(this + " returning: " + ss); return ss; } public ServerSocket createServerSocket(int port) throws IOException { ServerSocket ss = new TestServerSocket(port, initialSuccesses, exception); log.info(this + " returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog) throws IOException { ServerSocket ss = new TestServerSocket(port, backlog, initialSuccesses, exception); log.info(this + " returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException { ServerSocket ss = new TestServerSocket(port, backlog, ifAddress, initialSuccesses, exception); log.info(this + " returning: " + ss); return ss; } } static class TestServerSocket extends ServerSocket { int initialSuccesses; IOException exception; int counter; public TestServerSocket(int initialSuccesses, IOException exception) throws IOException { super(); this.initialSuccesses = initialSuccesses; this.exception = exception; } public TestServerSocket(int port, int initialSuccesses, IOException exception) throws IOException { super(port); this.initialSuccesses = initialSuccesses; this.exception = exception; } public TestServerSocket(int port, int backlog, int initialSuccesses, IOException exception) throws IOException { super(port, backlog); this.initialSuccesses = initialSuccesses; this.exception = exception; } public TestServerSocket(int port, int backlog, InetAddress bindAddr, int initialSuccesses, IOException exception) throws IOException { super(port, backlog, bindAddr); this.initialSuccesses = initialSuccesses; this.exception = exception; } public Socket accept() throws IOException { ++counter; Socket s = super.accept(); log.info(this + " counter: " + counter); if (counter > initialSuccesses && counter <= initialSuccesses + 2) { throw exception; } log.info(this + " returning: " + s); return s; } public String toString() { return "TestServerSocket[" + getLocalPort() + "]"; } } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/deadlock/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/deadlock/0000755000175000017500000000000011632407036033442 5ustar twernertwerner././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/deadlock/BisocketShutdownDeadlockTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/deadlock/0000644000175000017500000000245010541702021033433 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.transport.bisocket.deadlock; import org.jboss.test.remoting.transport.socket.deadlock.ShutdownDeadlockTestCase; /** * This test case is for JBREM-576. * Test trys to catch deadlock in shutdown where socket client * invoker being use my multiple Clients. Need one client making * invocations (which will cause sync on pool) and another to * shutdown, which will cause disconnect on socket client invoker, * thus causing it to sync on pool for clearing out the pool. * Since this is an issue of multithreading, is certainly possible * this test will pass even though the deadlock issue still exists. * @author Tom Elrod * @author Ron Sigal */ public class BisocketShutdownDeadlockTestCase extends ShutdownDeadlockTestCase { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 11; } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/clientpool/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/clientpoo0000755000175000017500000000000011632407035033610 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timertask0000755000175000017500000000000011632407036033620 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/timertask0000644000175000017500000003275211413660476033641 0ustar twernertwerner/* * 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.transport.bisocket.timertask; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Timer; 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.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.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.remoting.util.SecurityUtility; /** * Unit test for JBREM-1005. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jun 26, 2008 *

          */ public class TimerTaskTestCase extends TestCase { private static Logger log = Logger.getLogger(TimerTaskTestCase.class); private static boolean firstTime = true; private static boolean purgeMethodAvailable; 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); try { getDeclaredMethod(Timer.class, "purge", new Class[]{}); purgeMethodAvailable = true; } catch (Exception e) { log.info("Timer.purge() is not available: must be running with jdk 1.4"); } } } public void tearDown() { } public void testZeroPingFrequency() throws Throwable { log.info("entering " + getName()); if (!purgeMethodAvailable) { log.info(getName() + " PASSES (trivially)"); return; } // Start server. setupServer("0"); // 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(); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Set up callback handler. TestCallbackHandler callbackHandler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler, metadata); assertEquals(1, callbackHandler.counter); // Verify ControlMonitorTimerTask is not created. Set callbackConnectors = client.getCallbackConnectors(callbackHandler); assertEquals(1, callbackConnectors.size()); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask"); field.setAccessible(true); BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); TimerTask timerTask = (TimerTask) field.get(serverInvoker); assertNull(timerTask); log.info("ControlMonitorTimerTask was not created"); // Verify PingTimerTask is not created. field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); serverInvoker = (BisocketServerInvoker) connector.getServerInvoker(); Map callbackHandlers = (Map) field.get(serverInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient(); BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask"); field.setAccessible(true); timerTask = (TimerTask) field.get(clientInvoker); assertNull(timerTask); log.info("PingTimerTask was not created"); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testNonZeroPingFrequency() throws Throwable { log.info("entering " + getName()); if (!purgeMethodAvailable) { log.info(getName() + " PASSES (trivially)"); return; } // Start server. setupServer("20"); // 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(); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Set up callback handler. TestCallbackHandler callbackHandler = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); client.addListener(callbackHandler, metadata); assertEquals(1, callbackHandler.counter); // Verify ControlMonitorTimerTask is created. Set callbackConnectors = client.getCallbackConnectors(callbackHandler); assertEquals(1, callbackConnectors.size()); Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask"); field.setAccessible(true); BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); TimerTask timerTask = (TimerTask) field.get(serverInvoker); assertNotNull(timerTask); log.info("ControlMonitorTimerTask was created"); // Verify PingTimerTask is created. field = ServerInvoker.class.getDeclaredField("callbackHandlers"); field.setAccessible(true); BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) connector.getServerInvoker(); Map callbackHandlers = (Map) field.get(callbackServerInvoker); assertEquals(1, callbackHandlers.size()); Object o = callbackHandlers.values().iterator().next(); Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient(); BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask"); field.setAccessible(true); timerTask = (TimerTask) field.get(clientInvoker); assertNotNull(timerTask); log.info("PingTimerTask was created"); // Get count of ControlMonitorTimerTasks. field = BisocketServerInvoker.class.getDeclaredField("timer"); field.setAccessible(true); Timer timer = (Timer) field.get(null); field = Timer.class.getDeclaredField("queue"); field.setAccessible(true); Object taskQueue = field.get(timer); Field serverTimerfield = taskQueue.getClass().getDeclaredField("size"); serverTimerfield.setAccessible(true); int serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue(); log.info("ControlMonitorTimerTasks: " + serverSize); // Get count of PingTimerTasks. field = BisocketClientInvoker.class.getDeclaredField("timer"); field.setAccessible(true); timer = (Timer) field.get(null); field = Timer.class.getDeclaredField("queue"); field.setAccessible(true); taskQueue = field.get(timer); Field clientTimerfield = taskQueue.getClass().getDeclaredField("size"); clientTimerfield.setAccessible(true); int clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue(); log.info("PingTimerTasks: " + clientSize); // Shut down callback connection and verify TimerTasks are removed from // Timer queue. client.removeListener(callbackHandler); serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue(); log.info("ControlMonitorTimerTasks: " + serverSize); assertEquals(0, serverSize); clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue(); log.info("PingTimerTasks: " + clientSize); assertEquals(0, clientSize); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(String pingFrequency) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?" + Bisocket.PING_FREQUENCY + "=" + pingFrequency; 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) { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("Unable to send callback", e); } } 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 int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; log.info("received callback"); } } static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketLeakTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketL0000644000175000017500000001442010576347411033505 0ustar twernertwerner/* * 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.transport.bisocket; 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.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; import org.jboss.remoting.transport.bisocket.Bisocket; /** * This class can be profiled for memory leaks. See JBREM-721. * * @author Ron Sigal * @version $Revision: 2316 $ *

          * Copyright March 15, 2007 *

          */ public class BisocketLeakTest extends TestCase { private static Logger log = Logger.getLogger(BisocketLeakTest.class); private static String transport = "bisocket"; private static int LOOPS = 1000; public void testConnectionCreation() throws Throwable { 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().getHostName(); int port = PortUtil.findFreePort(host); String locatorURI = transport + "://" + 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"); serverConfig.put(Bisocket.IS_CALLBACK_SERVER, "false"); Connector connector = new Connector(serverLocator, serverConfig); connector.create(); SampleInvocationHandler 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"); clientConfig.put(Bisocket.IS_CALLBACK_SERVER, "true"); log.info("client onnecting to: " + serverLocator); Client client = new Client(serverLocator, clientConfig); client.connect(); log.info("client is connected"); SampleCallbackHandler callbackHandler = new SampleCallbackHandler(); long start = System.currentTimeMillis(); for (int i = 0; i < LOOPS; i++) { client.invoke("test"); client.addListener(callbackHandler, new HashMap(), null, true); client.removeListener(callbackHandler); assertEquals(i+1, callbackHandler.counter); if ((i+1) % 100 == 0) log.info("connections: " + (i+1)); } long finish = System.currentTimeMillis(); log.info("time to create " + LOOPS + " connections: " + (finish - start)); client.disconnect(); connector.stop(); } /** * Can pass transport and port to be used as parameters. * * @param args */ public static void main(String[] args) { if(args != null && args.length > 0) { transport = args[0]; if (args.length > 1) LOOPS = Integer.parseInt(args[1]); } BisocketLeakTest testCase = new BisocketLeakTest(); try { testCase.setUp(); testCase.testConnectionCreation(); testCase.tearDown(); log.info("done"); } catch(Throwable e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. When callback client's are registered, will * generate callbacks periodically. */ static class SampleInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) { log.debug("Adding callback listener."); try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("Unable to send callback"); } } public Object invoke(InvocationRequest invocation) throws Throwable {return null;} public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class SampleCallbackHandler implements InvokerCallbackHandler { int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; if ((counter + 1) % 1000 == 0) { System.out.println("received callback " + (counter + 1)); } } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketfac0000755000175000017500000000000011632407035033556 5ustar twernertwerner././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory/SocketFactoryClassNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketfac0000644000175000017500000000073011413660476033567 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.socketfactory; import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot; /** * * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jul 18, 2008 *

          */ public class SocketFactoryClassNameTestCase extends SocketFactoryClassNameTestRoot { protected String getTransport() { return "bisocket"; } }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory/BisocketCreationListenerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketfac0000644000175000017500000000434710553330220033560 0ustar twernertwerner/* * 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.transport.bisocket.socketfactory; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.socketfactory.CreationListenerTestRoot; import org.jboss.test.remoting.socketfactory.TestListener; /** * @author Ron Sigal * @version $Revision: 1888 $ *

          * Copyright Jan 11, 2007 *

          */ public class BisocketCreationListenerTestCase extends CreationListenerTestRoot { protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) { config.put(Bisocket.IS_CALLBACK_SERVER, "true"); } protected boolean checkListenersVisited(TestListener listener1, TestListener listener2, TestListener listener3, TestListener listener4) { // Need to treat bisocket transport as a special case because sockets are // created in a special way. return listener1.visited() && listener2.visited() && listener3.visited() && listener4.visited() && !listener1.isClient() && !listener2.isClient() && listener3.isClient() && listener4.isClient(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/load/0000755000175000017500000000000011632407035032612 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/load/BisocketPooledConnectionTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/load/Biso0000644000175000017500000000044310540121762033427 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.load; import org.jboss.test.remoting.transport.socket.load.PooledConnectionTestCase; public class BisocketPooledConnectionTestCase extends PooledConnectionTestCase { protected String getTransport() { return "bisocket"; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/load/BisocketSocketLoadTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/load/Biso0000644000175000017500000000236210540121762033431 0ustar twernertwerner/* * 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.transport.bisocket.load; import org.jboss.test.remoting.transport.socket.load.SocketLoadTestCase; public class BisocketSocketLoadTestCase extends SocketLoadTestCase { protected String getTransport() { return "bisocket"; } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/shutdown/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/shutdown/0000755000175000017500000000000011632407035033546 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/shutdown/BisocketShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/shutdown/0000644000175000017500000000411310716736064033560 0ustar twernertwerner/* * 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.transport.bisocket.shutdown; import org.jboss.test.remoting.transport.socket.shutdown.SocketShutdownTestCase; /** * @author Ron Sigal * @version $Revision: 2947 $ *

          * Copyright Jan 20, 2007 *

          */ public class BisocketShutdownTestCase extends SocketShutdownTestCase { protected String getTransport() { return "bisocket"; } protected String getJVMArguments() { String args = ""; String log4jFilePath = getClass().getResource("../../../shutdown/log4j.xml").getFile(); System.out.println("log4jFilePath: " + log4jFilePath); args += "-Dlog4j.configuration=file:" + log4jFilePath; return args; } protected String getHangingClientClassName() { log.info("returning HangingClass: " + BisocketHangingClient.class.getName()); return BisocketHangingClient.class.getName(); } protected String getClosingClientClassName() { log.info("returning ClosingClass: " + BisocketClosingClient.class.getName()); return BisocketClosingClient.class.getName(); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/shutdown/BisocketHangingClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/shutdown/0000644000175000017500000000214510714275262033557 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.shutdown; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.shutdown.AbstractClient; import org.jboss.test.remoting.shutdown.HangingClient; public class BisocketHangingClient extends HangingClient { public static void main(String[] args) { try { if (args.length == 0) throw new RuntimeException(); String transport = args[0]; HashMap config = new HashMap(); System.out.println("args.length: " + args.length); if (args.length > 1) getConfig(config, args[1]); AbstractClient client = new BisocketHangingClient(transport, config); client.testShutdown(); } catch (Throwable t) { t.printStackTrace(); } } public BisocketHangingClient(String transport, Map config) { super(transport, config); } protected void addCallbackArgs(Map map) { map.put(Bisocket.IS_CALLBACK_SERVER, "true"); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/shutdown/BisocketClosingClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/shutdown/0000644000175000017500000000214510714275262033557 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.shutdown; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.shutdown.AbstractClient; import org.jboss.test.remoting.shutdown.ClosingClient; public class BisocketClosingClient extends ClosingClient { public static void main(String[] args) { try { if (args.length == 0) throw new RuntimeException(); String transport = args[0]; HashMap config = new HashMap(); System.out.println("args.length: " + args.length); if (args.length > 1) getConfig(config, args[1]); AbstractClient client = new BisocketClosingClient(transport, config); client.testShutdown(); } catch (Throwable t) { t.printStackTrace(); } } public BisocketClosingClient(String transport, Map config) { super(transport, config); } protected void addCallbackArgs(Map map) { map.put(Bisocket.IS_CALLBACK_SERVER, "true"); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketPerformanceTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketP0000644000175000017500000001151210540121762033476 0ustar twernertwerner/* * 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.transport.bisocket; import java.net.InetAddress; import java.util.HashMap; 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.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * @author Ron Sigal * @version $Revision: 1702 $ *

          * Copyright Nov 25, 2006 *

          */ public class BisocketPerformanceTestClient extends TestCase { private static Logger log = Logger.getLogger(BisocketPerformanceTestClient.class); private static String transport = "bisocket"; private static int invocations = 1000; public void testBisocket() throws Throwable { String host = InetAddress.getLocalHost().getHostAddress(); int port = BisocketPerformanceTestServer.port; String locatorURI = transport + "://" + host + ":" + port; InvokerLocator serverLocator = new InvokerLocator(locatorURI); System.out.println("Connecting to: " + serverLocator); Client client = new Client(serverLocator); client.connect(); System.out.println("client is connected"); InvokerCallbackHandler callbackHandler = new SampleCallbackHandler(); client.addListener(callbackHandler, new HashMap(), null, true); System.out.println("client added callback handler"); long start = System.currentTimeMillis(); for (int i = 0; i < invocations; i++) { client.invoke("test"); } long finish = System.currentTimeMillis(); System.out.println("time to make " + invocations + " invocations: " + (finish - start)); client.removeListener(callbackHandler); client.disconnect(); } /** * Can pass transport and port to be used as parameters. * * @param args */ public static void main(String[] args) { if(args != null && args.length > 0) { transport = args[0]; if (args.length > 1) invocations = Integer.parseInt(args[1]); } BisocketPerformanceTestClient testCase = new BisocketPerformanceTestClient(); try { testCase.setUp(); testCase.testBisocket(); Thread.sleep(10000); testCase.tearDown(); System.out.println("done"); } catch(Throwable e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. When callback client's are registered, will * generate callbacks periodically. */ static class SampleInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("Adding callback listener."); try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("Unable to send callback"); } } public Object invoke(InvocationRequest invocation) throws Throwable {return null;} public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } static class SampleCallbackHandler implements InvokerCallbackHandler { int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; if ((counter + 1) % 1000 == 0) { System.out.println("received callback " + (counter + 1)); } } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackDisconnectTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackD0000644000175000017500000002300510665733757033440 0ustar twernertwerner/* * 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.transport.bisocket; 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.bisocket.BisocketServerInvoker; import org.jboss.remoting.transport.socket.MicroSocketClientInvoker; /** * Unit test for JBREM-767. * * @author Ron Sigal * @version $Revision: 2732 $ *

          * Copyright Aug 4, 2007 *

          */ public class CallbackDisconnectTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(CallbackDisconnectTestCase.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 BisocketClientInvoker.handleDisconnect() wakes up any threads * blocked in BisocketClientInvoker.createSocket(). */ public void testWakeupsInHandleDisconnect() 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("timeout", "0"); 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"); // Remove existing connections for callback clients. 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()); pool.clear(); // Prevent creation of new connections for callback clients. 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 callbackConnector = (Connector) callbackConnectorSet.iterator().next(); assertTrue(callbackConnector.getServerInvoker() instanceof BisocketServerInvoker); BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); field = BisocketServerInvoker.class.getDeclaredField("controlConnectionThreadMap"); field.setAccessible(true); Map controlConnectionThreadMap = (Map) field.get(callbackServerInvoker); assertEquals(1, controlConnectionThreadMap.size()); Thread controlConnectionThread = (Thread) controlConnectionThreadMap.values().iterator().next(); controlConnectionThread.stop(); // Verify that the call to sockets.wait() in BisocketClientInvoker will // wake up, even though the timeout value is set to 0. class TestThread extends Thread { public boolean done; public Throwable throwable; public void run() { try { log.info("calling client.invoke(CALLBACK_TEST)"); client.invoke(CALLBACK_TEST); log.info("called client.invoke(CALLBACK_TEST)"); } catch (Throwable t) { log.info("TestThread got expected exception: " + t.getMessage()); throwable = t; } done = true; } } TestThread testThread = new TestThread(); testThread.start(); Thread.sleep(2000); callbackClient.disconnect(); Thread.sleep(2000); assertTrue(testThread.done); assertNotNull(testThread.throwable); assertEquals("Error handling callback", testThread.throwable.getMessage()); 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++; } } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/clientaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/clientadd0000755000175000017500000000000011632407035033543 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/clientaddress/BisocketClientAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/clientadd0000644000175000017500000000043710720523423033546 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.clientaddress; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class BisocketClientAddressTestCase extends ClientAddressTestParent { protected String getTransport() { return "bisocket"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/0000755000175000017500000000000011632407036032475 5ustar twernertwerner././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBi0000644000175000017500000003415711413660476033354 0ustar twernertwerner/* * 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.transport.bisocket.ssl; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketAddress; import java.net.UnknownHostException; import javax.net.ServerSocketFactory; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import org.jboss.logging.Logger; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.transport.bisocket.BisocketControlConnectionReplacementTestCase; /** * Unit test for JBREM-1147. * * @author Ron Sigal * @version *

          * Copyright Aug 14, 2009 *

          */ public class SSLBisocketControlConnectionReplacementTestCase extends BisocketControlConnectionReplacementTestCase { private static Logger log = Logger.getLogger(SSLBisocketControlConnectionReplacementTestCase.class); public void setUp() throws Exception { if (firstTime) { String keyStoreFilePath = getClass().getResource(".keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); String trustStoreFilePath = getClass().getResource(".truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client"); } super.setUp(); } protected String getTransport() { return "sslbisocket"; } protected String getServerSocketName() { return SSLTestServerSocketFactory.class.getName(); } static public class SSLTestServerSocketFactory extends ServerSocketFactory { int timeout; ServerSocketFactory factory; int initialWrites; public SSLTestServerSocketFactory() throws IOException { this.timeout = 5000; this.initialWrites = INITIAL_WRITES; setupFactory(); } public SSLTestServerSocketFactory(int timeout, int initialWrites) throws IOException { this.timeout = timeout; this.initialWrites = initialWrites; setupFactory(); } public ServerSocket createServerSocket() throws IOException { ServerSocket ss = SSLServerSocketFactory.getDefault().createServerSocket(); log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port) throws IOException { ServerSocket ss = null; if (port != secondaryServerSocketPort) { ss = SSLServerSocketFactory.getDefault().createServerSocket(port); } else { ss = new SSLTestServerSocket(port, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket())); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog) throws IOException { ServerSocket ss = null; if (port != secondaryServerSocketPort) { ss = SSLServerSocketFactory.getDefault().createServerSocket(port, backlog); } else { ss = new SSLTestServerSocket(port, backlog, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket())); } log.info("returning: " + ss); return ss; } public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException { ServerSocket ss = null; if (port != secondaryServerSocketPort) { ss = SSLServerSocketFactory.getDefault().createServerSocket(port, backlog, ifAddress); } else { ss = new SSLTestServerSocket(port, backlog, ifAddress, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket())); } log.info("returning: " + ss); return ss; } protected void setupFactory() throws IOException { SSLSocketBuilder sslSocketBuilder = new SSLSocketBuilder(); sslSocketBuilder.setUseSSLServerSocketFactory(false); factory = sslSocketBuilder.createSSLServerSocketFactory(); } } static class SSLTestServerSocket extends SSLServerSocket { int timeout; int initialWrites; SSLServerSocket serverSocket; public SSLTestServerSocket(int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException { super(); this.timeout = timeout; this.initialWrites = initialWrites; this.serverSocket = serverSocket; } public SSLTestServerSocket(int port, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException { super(port); this.timeout = timeout; this.initialWrites = initialWrites; this.serverSocket = serverSocket; bind(new InetSocketAddress(port), 50); } public SSLTestServerSocket(int port, int backlog, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException { super(port, backlog); this.timeout = timeout; this.initialWrites = initialWrites; this.serverSocket = serverSocket; bind(new InetSocketAddress(port), backlog); } public SSLTestServerSocket(int port, int backlog, InetAddress bindAddr, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException { super(port, backlog, bindAddr); this.timeout = timeout; this.initialWrites = initialWrites; this.serverSocket = serverSocket; bind(new InetSocketAddress(bindAddr, port), 50); } public Socket accept() throws IOException { SSLSocket s1 = (SSLSocket) serverSocket.accept(); Socket s2 = new SSLTestSocket(timeout, initialWrites, s1); return s2; } public void bind(SocketAddress endpoint, int backlog) throws IOException { log.info("serverSocket: " + serverSocket); if (serverSocket != null) log.info("bound: " + serverSocket.isBound()); if (serverSocket != null && !serverSocket.isBound()) { log.info("binding " + serverSocket); serverSocket.bind(endpoint, backlog); } } public String toString() { return "SSLTestServerSocket[" + serverSocket.toString() + "]"; } public boolean getEnableSessionCreation() { return serverSocket.getEnableSessionCreation(); } public String[] getEnabledCipherSuites() { return serverSocket.getEnabledCipherSuites(); } public String[] getEnabledProtocols() { return serverSocket.getEnabledProtocols(); } public boolean getNeedClientAuth() { return serverSocket.getNeedClientAuth(); } public String[] getSupportedCipherSuites() { return serverSocket.getSupportedCipherSuites(); } public String[] getSupportedProtocols() { return serverSocket.getSupportedProtocols(); } public boolean getUseClientMode() { return serverSocket.getUseClientMode(); } public boolean getWantClientAuth() { return serverSocket.getWantClientAuth(); } public void setEnableSessionCreation(boolean arg0) { serverSocket.setEnableSessionCreation(arg0); } public void setEnabledCipherSuites(String[] arg0) { serverSocket.setEnabledCipherSuites(arg0); } public void setEnabledProtocols(String[] arg0) { serverSocket.setEnabledProtocols(arg0); } public void setNeedClientAuth(boolean arg0) { serverSocket.setNeedClientAuth(arg0); } public void setUseClientMode(boolean arg0) { serverSocket.setUseClientMode(arg0); } public void setWantClientAuth(boolean arg0) { serverSocket.setWantClientAuth(arg0); } } static class SSLTestSocket extends SSLSocket { int timeout; int initialWrites; SSLSocket socket; SocketAddress endpoint; public SSLTestSocket(int timeout, int initialWrites, SSLSocket socket) { this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; } public SSLTestSocket(String host, int port, int timeout, int initialWrites, SSLSocket socket) throws UnknownHostException, IOException { super(host, port); this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; connect(new InetSocketAddress(host, port), timeout); } public SSLTestSocket(InetAddress address, int port, int timeout, int initialWrites, SSLSocket socket) throws IOException { super(address, port); this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; connect(new InetSocketAddress(address, port), timeout); } public SSLTestSocket(String host, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites, SSLSocket socket) throws IOException { super(host, port, localAddr, localPort); this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; bind(new InetSocketAddress(localAddr, localPort)); connect(new InetSocketAddress(host, port), timeout); } public SSLTestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites, SSLSocket socket) throws IOException { super(address, port, localAddr, localPort); this.timeout = timeout; this.initialWrites = initialWrites; this.socket = socket; bind(new InetSocketAddress(localAddr, localPort)); connect(new InetSocketAddress(address, port), timeout); } public String toString() { return "SSLTestSocket[" + socket.toString() + "]"; } public InputStream getInputStream() throws IOException { return socket.getInputStream(); } public OutputStream getOutputStream() throws IOException { return new TestOutputStream(socket.getOutputStream(), timeout, initialWrites); } public void addHandshakeCompletedListener(HandshakeCompletedListener listener) { socket.addHandshakeCompletedListener(listener); } public void bind(SocketAddress bindpoint) throws IOException { if (socket != null) socket.bind(bindpoint); } public void connect(SocketAddress endpoint) throws IOException { if (socket != null) socket.connect(endpoint); } public void connect(SocketAddress endpoint, int timeout) throws IOException { socket.connect(endpoint, timeout); } public boolean getEnableSessionCreation() { return socket.getEnableSessionCreation(); } public String[] getEnabledCipherSuites() { return socket.getEnabledCipherSuites(); } public String[] getEnabledProtocols() { return socket.getEnabledProtocols(); } public InetAddress getInetAddress() { return socket.getInetAddress(); } public boolean getNeedClientAuth() { return socket.getNeedClientAuth(); } public SSLSession getSession() { return socket.getSession(); } public String[] getSupportedCipherSuites() { return socket.getSupportedCipherSuites(); } public String[] getSupportedProtocols() { return socket.getSupportedProtocols(); } public boolean getUseClientMode() { return socket.getUseClientMode(); } public boolean getWantClientAuth() { return socket.getWantClientAuth(); } public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) { socket.removeHandshakeCompletedListener(listener); } public void setEnableSessionCreation(boolean flag) { socket.setEnableSessionCreation(flag); } public void setEnabledCipherSuites(String[] suites) { socket.setEnabledCipherSuites(suites); } public void setEnabledProtocols(String[] protocols) { socket.setEnabledProtocols(protocols); } public void setNeedClientAuth(boolean need) { socket.setNeedClientAuth(need); } public void setUseClientMode(boolean mode) { socket.setUseClientMode(mode); } public void setWantClientAuth(boolean want) { socket.setWantClientAuth(want); } public void startHandshake() throws IOException { socket.startHandshake(); } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/.truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/.trus0000644000175000017500000000701310542176562033502 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/no_connection_check/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/no_co0000755000175000017500000000000011632407035033512 5ustar twernertwerner././@LongLink0000000000000000000000000000022500000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/no_connection_check/SSLBisocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/no_co0000644000175000017500000000067510541702153033521 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.no_connection_check; import org.jboss.test.remoting.transport.socket.ssl.no_connection_check.InvokerClientTest; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerClientTest extends InvokerClientTest { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/no_connection_check/BisocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/no_co0000644000175000017500000000067210541702153033516 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.no_connection_check; import org.jboss.test.remoting.transport.socket.ssl.no_connection_check.InvokerServerTest; /** * @author Tom Elrod * @author Ron Sigal */ public class BisocketInvokerServerTest extends InvokerServerTest { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/no_connection_check/SSLBisocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/no_co0000644000175000017500000000272510541702153033517 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.no_connection_check; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLBisocketInvokerClientTest.class.getName(), 1, BisocketInvokerServerTest.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; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/builder/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/build0000755000175000017500000000000011632407035033514 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/builder/SSLBisocketInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/build0000644000175000017500000000171010545077514033524 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.builder; import org.jboss.test.remoting.transport.bisocket.ssl.SSLBisocketInvokerConstants; import org.jboss.test.remoting.transport.socket.ssl.builder.SSLSocketInvokerTestCase; /** * This is the client for the test to make regular ssl based invocation to the server and * have a ssl based callback server. The special test in this case is want to have the callback * client that lives on the server to be in client mode so that this client test only has to have * a truststore locally, yet still use ssl. * * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerTestClient extends SSLSocketInvokerTestCase implements SSLBisocketInvokerConstants { protected String getTransport() { return "sslbisocket"; } protected int getPort() { return bisocketPort + 7; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/builder/SSLBisocketInvokerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/build0000644000175000017500000000216710545077514033533 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.builder; import org.jboss.test.remoting.transport.bisocket.ssl.SSLBisocketInvokerConstants; import org.jboss.test.remoting.transport.socket.ssl.builder.SSLSocketInvokerTestServer; /** * This is the server for the test case to verify can have push callbacks using ssl where * the client mode is used for the client calling back on the callback server living within the * client test instance. * * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerTestServer extends SSLSocketInvokerTestServer implements SSLBisocketInvokerConstants { public static void main(String[] args) { SSLBisocketInvokerTestServer server = new SSLBisocketInvokerTestServer(); try { server.setUp(); Thread.sleep(600000); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "sslbisocket"; } protected int getPort() { return bisocketPort + 7; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/builder/SSLBisocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/build0000644000175000017500000000273710541702153033524 0ustar twernertwerner/* * 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.transport.bisocket.ssl.builder; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLBisocketInvokerTestClient.class.getName(), 1, SSLBisocketInvokerTestServer.class.getName()); } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBi0000644000175000017500000000431610542175600033336 0ustar twernertwerner/* * 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.transport.bisocket.ssl; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.transport.bisocket.BisocketTestCase; /** * @author Ron Sigal * @version $Revision: 1759 $ *

          * Copyright Dec 15, 2006 *

          */ public class SSLBisocketTestCase extends BisocketTestCase { protected String getTransport() { return "sslbisocket"; } protected void addExtraClientConfig(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"); } protected void addExtraServerConfig(Map config) { 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"); } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/confi0000755000175000017500000000000011632407035033513 5ustar twernertwerner././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketServerSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/confi0000644000175000017500000000373511413660476033534 0ustar twernertwerner/* * 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.transport.bisocket.ssl.config; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.transport.sslbisocket.SSLBisocketServerInvoker; import org.jboss.test.remoting.transport.socket.ssl.config.SSLSocketServerSocketConfigurationTestCase; /** * Unit test for JBREM-703. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 28, 2008 *

          */ public class SSLBisocketServerSocketConfigurationTestCase extends SSLSocketServerSocketConfigurationTestCase { protected String getTransport() { return "sslbisocket"; } protected void configureServerInvoker(SocketServerInvoker invoker) { super.configureServerInvoker(invoker); SSLBisocketServerInvoker sslInvoker = (SSLBisocketServerInvoker) invoker; sslInvoker.setEnabledCipherSuites(cipherSuites); sslInvoker.setEnabledProtocols(protocols); sslInvoker.setEnableSessionCreation(true); } }././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/confi0000644000175000017500000000273011413660476033526 0ustar twernertwerner/* * 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.transport.bisocket.ssl.config; import org.jboss.test.remoting.transport.socket.ssl.config.SSLSocketSocketConfigurationTestCase; /** * Unit test for JBREM-703. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 28, 2008 *

          */ public class SSLBisocketSocketConfigurationTestCase extends SSLSocketSocketConfigurationTestCase { protected String getTransport() { return "sslbisocket"; } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/FactoryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/confi0000644000175000017500000000422210542175677033532 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.bisocket.ssl.config; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.transport.config.FactoryConfigTestCaseSSLParent; /** * * @author Ron Sigal *

          * Copyright (c) May 20, 2006 *

          */ public class FactoryConfigTestCase extends FactoryConfigTestCaseSSLParent { protected String getTransport() { return "sslbisocket"; } protected void addExtraCallbackConfig(Map config) { config.put(Bisocket.IS_CALLBACK_SERVER, "true"); // Callback server invoker needs to create a socket factory to contact // secondary server socket on server side. config.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeo0000755000175000017500000000000011632407035033532 5ustar twernertwerner././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketDefaultTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeo0000644000175000017500000000614511413660476033551 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2010, 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.transport.bisocket.ssl.timeout; import java.io.IOException; import java.util.Map; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.socket.ServerAddress; import org.jboss.remoting.transport.sslbisocket.SSLBisocketClientInvoker; import org.jboss.test.remoting.transport.socket.timeout.SocketDefaultTimeoutTestCase; /** * Unit tests for JBREM-1188. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 16, 2010 */ public class SSLBisocketDefaultTimeoutTestCase extends SocketDefaultTimeoutTestCase { private static Logger log = Logger.getLogger(SSLBisocketDefaultTimeoutTestCase.class); protected Class getClientFactoryClass() { return TestSSLBisocketClientFactory.class; } protected Class getClientInvokerClass() { return TestSSLBisocketClientInvoker.class; } public static class TestSSLBisocketClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { ClientInvoker clientInvoker = new TestSSLBisocketClientInvoker(locator, config); log.info("TestClientFaotory.createClientInvoker() returning " + clientInvoker); return clientInvoker; } public boolean supportsSSL() { return true; } } public static class TestSSLBisocketClientInvoker extends SSLBisocketClientInvoker { public TestSSLBisocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); } public TestSSLBisocketClientInvoker(InvokerLocator locator) throws IOException { super(locator); } public ServerAddress getServerAddress() { return address; } public String toString() { return "TestSSLBisocketClientInvoker"; } } }././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketPerInvocationTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeo0000644000175000017500000000102210607113422033522 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.timeout; import org.jboss.test.remoting.transport.socket.ssl.timeout.SSLSocketPerInvocationTimeoutTestCase; /** * See javadoc for PerInvocationTimeoutTestRoot. * * @author Ron Sigal * @version $Revision: 2348 $ *

          * Copyright Feb 6, 2007 *

          */ public class SSLBisocketPerInvocationTimeoutTestCase extends SSLSocketPerInvocationTimeoutTestCase { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketWriteTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeo0000644000175000017500000000265711413660476033555 0ustar twernertwerner/* * 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.transport.bisocket.ssl.timeout; import org.jboss.test.remoting.transport.socket.timeout.SSLWriteTimeoutTestParent; /** * Unit tests for JBREM-1120. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Apr 22, 2009 *

          */ public class SSLBisocketWriteTimeoutTestCase extends SSLWriteTimeoutTestParent { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/handshake/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/hands0000755000175000017500000000000011632407035033512 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/handshake/SSLBisocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/hands0000644000175000017500000000065110541702153033513 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.handshake; import org.jboss.test.remoting.transport.socket.ssl.handshake.InvokerClientTest; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerClientTest extends InvokerClientTest { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/handshake/SSLBisocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/hands0000644000175000017500000000065110541702153033513 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.handshake; import org.jboss.test.remoting.transport.socket.ssl.handshake.InvokerServerTest; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerServerTest extends InvokerServerTest { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/handshake/SSLBisocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/hands0000644000175000017500000000271610541702153033517 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.handshake; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLBisocketInvokerClientTest.class.getName(), 1, SSLBisocketInvokerServerTest.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; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/restart/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/resta0000755000175000017500000000000011632407035033533 5ustar twernertwerner././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/restart/SSLBisocketServerRestartTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/resta0000644000175000017500000000441310723136700033535 0ustar twernertwerner/* * 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.transport.bisocket.ssl.restart; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.restart.ServerRestartTestParent; /** * Unit test for JBREM-745. * * @author Ron Sigal * @version $Revision: 3022 $ *

          * Copyright November 27, 2007 *

          */ public class SSLBisocketServerRestartTestCase extends ServerRestartTestParent { protected String getTransport() { return "sslbisocket"; } protected void addExtraServerConfig(Map config) { 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"); } protected void addExtraClientConfig(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"); } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/multihome/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/multi0000755000175000017500000000000011632407035033547 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/multihome/SSLBisocketMultihomeTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/multi0000644000175000017500000000562611413660476033571 0ustar twernertwerner /* * 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.transport.bisocket.ssl.multihome; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.transport.bisocket.multihome.BisocketMultihomeTestCase; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jan 8, 2008 *

          */ public class SSLBisocketMultihomeTestCase extends BisocketMultihomeTestCase { protected String getTransport() { return "sslbisocket"; } protected void addExtraServerConfig(Map config) { super.addExtraServerConfig(config); 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"); } protected void addExtraClientConfig(Map config) { super.addExtraClientConfig(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"); } protected void addExtraCallbackConfig(Map config) { super.addExtraCallbackConfig(config); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); 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"); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/.keystorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/.keys0000644000175000017500000001376110542176562033467 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000755000175000017500000000000011632407035033541 5ustar twernertwerner././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/SSLBisocketTestCase_Retired.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000175211011213216033533 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.serversocketrefresh; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; import org.jboss.logging.XLevel; /** * JBREM-427 load a new keystore at runtime
          * server is refreshing its serversocket after a new ServerSocketFactory was set
          * second client connection attempt fails because client is not accepted by the new truststore * @author Michael Voss * @author Ron Sigal * */ public class SSLBisocketTestCase_Retired extends TestDriver{ public void declareTestClasses() { addTestClasses(SSLBisocketTestClient.class.getName(), 1, SSLBisocketTestServer.class.getName()); } protected Level getTestLogLevel() { return XLevel.TRACE; } protected long getResultsTimeout() { return 480000; } protected long getRunTestTimeout() { return 480000; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/certificate/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000755000175000017500000000000011632407035033541 5ustar twernertwerner././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/certificate/serverTrustStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000121110541702153033533 0ustar twernertwernerþíþí clientcert ¸£½,X.509F0‚B0‚«D‰`Õ0  *†H†÷ 0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0 060609115149Z 060907115149Z0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0Ÿ0  *†H†÷ 0‰•œ”ŒaUtâ¶ôÞD¾ áBÃ:[ËL#ßè}ºÀû÷…¯ƒF*…$ê•,†iem¯M3ñÈ/d¼ÇsÝÁßέÞt°¢›3q–ÅqÈ='±!Ö-Õ‘z54 ÄbãË–ºØB(ÞçýîBß?¸B=•^R=ñ~&¡±vƒÃ0  *†H†÷ }$L„ÃAÅ'Ç ½þÜóë$Ž&¢©9ï·3êÁ¬ð¡Ëà<”žMè Ùÿg‰÷aÀ¤uyóD§«Îö¬ÏÓ·jXà¤Ö°¬ÅúìÏ­áš“þ*èÕ¾ãY…Ò[àsªZxŽs5PņŸ;.A/ Fù8+è|ßc+ÆWì~YY½¬—b»½¤ÔTkh‚C²././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/certificate/serverKeyStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000250710541702153033544 0ustar twernertwernerþíþímykey ¸¢á¢»0‚·0 +*‚£„LÚ£„û fbŸ¹oº2KÛùGµŸ¡â8ƒJ¬¡¾;laL,\Hœ¬è|Kß´Úë>‘|€¾ÿçau© `¥×n*Ú ëÎó_ÿ“8¬ä¯öBníRV‹enPæ=ÄË vçeOƒPÛó¶öø›muY˜jÓÞ+çËZ«@×û¯ôß¿[rÿÖçÏ'Á h¡D «ØŠ,¾âl,<}6nΜ¨vGëÇ'Ä!ЀŸÉËÕW–å€x]É×g«ÁÔÛ(^WV]õ6àSÆ88³ËWjd¸eÒìÊ`!•¶TFt¯1CÛ(YFSÆ'^”PÄ>”°o 4ôQÜC’—*w–-;>à€\;­ªWÀ5«—ãh<Ô8Ç/'êÇ‘”rŽ9»õ}Ûc+™Ìï›Nñi ܰ²Œ µ†„$ŒîÀ×(Mª3†…o˜ZÌ_5a®ÙÅ 4ˆv¬2GaŽ(zHž½Ô'·M^FHŽXàª/’ëàoïÄõß1⊹ÐÀI¯Ð¸ÚÌ•ÿÚÛÛ4׈UÜ@)ôß°îFÀ%Ì^:ÂLRç/²h½þü:œ<ƒqSĤ¯¶JK±Vå„>ÅÉTD¾ÊLèm‹Õ¡å 6ž„C»žwûïjªPR個ŸjuVIOðòØê·† ÖÖ¶, ˜,¦‹|=uZJÇX.509F0‚B0‚«D‰`ý0  *†H†÷ 0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0 060609115229Z 060907115229Z0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0Ÿ0  *†H†÷ 0‰–%º‚2,Ð9 Ò/Ȇ¶úÉü¸îü~Y+yŸŸã+³úé›A¬]ú¯$¥ØÑä“zYlK÷ƒ8†Mø[e­2ÌòYuÙ]3âáu°ùä÷CÅÚÿªÝ^í°Ø…ëR‘S MÒr?>/”®òvc¾jê)VûG0x5$q\0  *†H†÷ !0o2EލÞƒ6;W!ÚÊæºÆ%t†úH'_P }¡…Ë;…Îc Q,ˆø/´¿h£vöp-8Ãz Õ‰¼€9ƒÕT%õÁ8˜íÄ5l„ _Ø$\3ÿG;]í¶Ì×7j¶Óü@÷X^1?¥±\!}ÆŸ×vq{gíƒkÌý¢Z<¥X¦âô§NÛ{p•sÙH././@LongLink0000000000000000000000000000022100000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/certificate/serverTrustStore2libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000131710541702153033542 0ustar twernertwernerþíþí clientcert ¸ªgBX.509Œ0‚ˆ0‚ñD‰b•0  *†H†÷ 0Š1 0 UDE10Uanother client10Uanother client10U another client10U another client10Uanother client0 060609115917Z 060907115917Z0Š1 0 UDE10Uanother client10Uanother client10U another client10U another client10Uanother client0Ÿ0  *†H†÷ 0‰×ø~ðrøL™ÇêJ¨'S½|gýƒÀ)L_܃$`õ3RCK4,ØAuÆ|B½2)û b¬õ¤à–ˆå ¥ÊÈÊ©r7êü`¹4ï»a 8Ç'GТ±§âˆ ?o©$Ç¡9PÊÿH¥2ÄðÍ•ÿýÛ4„yÞkj±è ” ƒ™0  *†H†÷ 0¿ôÀ*Ûþ>_?Xù©k˜ÃˆÈ¿ ³; EÎLäûû¼ÞCãËšžëfy]Âî1YUE–»mD‹Üºâ-#M.îqT*€ìë½±Þ0ö{ë'Ó½!×å;I*o¦”¥ZZ)h jâ~$ËyÎWu€1 ,¤•Œ®ÚP¹ek;Ya ÃÐÓ-q°;'&ŠûêD././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/certificate/clientTrustStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000121110541702153033533 0ustar twernertwernerþíþí servercert ¸¤ˆIX.509F0‚B0‚«D‰`ý0  *†H†÷ 0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0 060609115229Z 060907115229Z0h1 0 UDE10 UServer10 UServer10 U Server10 U Server10U Michael Voss0Ÿ0  *†H†÷ 0‰–%º‚2,Ð9 Ò/Ȇ¶úÉü¸îü~Y+yŸŸã+³úé›A¬]ú¯$¥ØÑä“zYlK÷ƒ8†Mø[e­2ÌòYuÙ]3âáu°ùä÷CÅÚÿªÝ^í°Ø…ëR‘S MÒr?>/”®òvc¾jê)VûG0x5$q\0  *†H†÷ !0o2EލÞƒ6;W!ÚÊæºÆ%t†úH'_P }¡…Ë;…Îc Q,ˆø/´¿h£vöp-8Ãz Õ‰¼€9ƒÕT%õÁ8˜íÄ5l„ _Ø$\3ÿG;]í¶Ì×7j¶Óü@÷X^1?¥±\!}ÆŸ×vq{gíƒkÌ×–zY/Žt}nÑw<¹»5е././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/certificate/clientKeyStorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000250710541702153033544 0ustar twernertwernerþíþímykey ¸¢JG»0‚·0 +*‚£´G÷ 9Í õÄÉÆI~š˜fèíµš†·§ÁGoþË\¢t[JæyÁ½ØRŠƒ,üc•zî·Ñʰ0<£Ø~j#¢ä£I^ÁG‹õ|C5m¹ygN]Ž*^Ž"±ü3è<«±FÕîNÝôa¾úŽ™³ÍI£z¾Ê&Žû:r±O«xo· ¸Í™ÍpnCäZµa†'†í!‚ï–&"Y"# hd3¯°s)c¢Œ¬3hóÀ…QóÀ´Ü"]E²_=¼Ys\ é£oÅóÕ»óšçÁ(3QM!ðd>Îß xë§±.^`ºzÚœ63S0PuÒ¬\ŽSÆ—¶û=àä:­qñâX¼NF¾a‡ÔˆåÃ%˔ٶ"Œl"Îí¦° ¯%Fð¬Þ„q p3ÕS&CDÏe"#†²¨öÏ}*ê2¤¥W‚†#Ö½y'ô¶WÀI^«“­Çço8Ô¶1Go¸*hü',ß9OÜßbÅî÷C$o­ñGúG{²9ŽƒÎ `ƒƒ£´¿±Î§[‰«ci úJ'‡ó¶+&'A®Mªê~ôtŽÁ½—9Ó­_ZŽ«ˆþpPí’Çҭப¶~IÎ'ó<ïäTý¡Ÿ§ÑåT¿¨øW‚å÷Y$±­Om Õnœø„xú ó„½IGfÕ×ùìe a«ç¾}èõý ®"Ól~õ7Ü5°‚¯[$A÷?U_ mR£T·ÕSqŒ†ùã!¦‘{3àÀ¯QŠvRóôÚ‡K3‡ZJŠÂÔpò£ )b‹ªvâE½¯ËŒ~®/3Í»¬ìù¼ ý™Š¿dD²a5¾¹ÏW3/ é̓¬FžQ®ªÏ‘¤‘hÆ›™ðçOr;>_‰4ˆwºÂq¬m–ð3XŽX.509F0‚B0‚«D‰`Õ0  *†H†÷ 0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0 060609115149Z 060907115149Z0h1 0 UDE10 UClient10 UClient10 U Client10 U Client10U Michael Voss0Ÿ0  *†H†÷ 0‰•œ”ŒaUtâ¶ôÞD¾ áBÃ:[ËL#ßè}ºÀû÷…¯ƒF*…$ê•,†iem¯M3ñÈ/d¼ÇsÝÁßέÞt°¢›3q–ÅqÈ='±!Ö-Õ‘z54 ÄbãË–ºØB(ÞçýîBß?¸B=•^R=ñ~&¡±vƒÃ0  *†H†÷ }$L„ÃAÅ'Ç ½þÜóë$Ž&¢©9ï·3êÁ¬ð¡Ëà<”žMè Ùÿg‰÷aÀ¤uyóD§«Îö¬ÏÓ·jXà¤Ö°¬ÅúìÏ­áš“þ*èÕ¾ãY…Ò[àsªZxŽs5PņŸ;.A/ Fù8+è|ßc+ÆWì~àÃèU7«È›ðøU柿ë=ó¿¼././@LongLink0000000000000000000000000000023400000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/BisocketServerSocketRefreshTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000354311413660476033557 0ustar twernertwerner /* * 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.transport.bisocket.ssl.serversocketrefresh; import org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh.ServerSocketRefreshTestCase; /** * BisocketServerSocketRefreshTestCase replaces SSLBisocketTestCase * derived from Michael Voss' test * org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh.TestCase. * * It tests the same functionality, namely, the hot replacement of a ServerSocket * in a socket transport server. However, it is easier to manage the possibility * that it may take a while to rebind a ServerSocket to an old port. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 9, 2008 *

          */ public class BisocketServerSocketRefreshTestCase extends ServerSocketRefreshTestCase { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/SSLBisocketTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000057110541702153033543 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.serversocketrefresh; import org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh.TestClient; /** * @author Michael Voss * @author Ron Sigal * */ public class SSLBisocketTestClient extends TestClient { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serversocketrefresh/SSLBisocketTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/serve0000644000175000017500000000120310541702153033534 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.serversocketrefresh; import org.jboss.test.remoting.transport.socket.ssl.serversocketrefresh.TestServer; /** * @author Michael Voss * @author Ron Sigal * */ public class SSLBisocketTestServer extends TestServer { public static void main(String[] args) { TestServer server = new SSLBisocketTestServer(); server.setUp(); try { server.test(); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/connection_check/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/conne0000755000175000017500000000000011632407035033517 5ustar twernertwerner././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/connection_check/SSLBisocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/conne0000644000175000017500000000135010545077514033527 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.connection_check; import org.jboss.test.remoting.transport.bisocket.ssl.SSLBisocketInvokerConstants; import org.jboss.test.remoting.transport.socket.ssl.connection_check.InvokerClientTest; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerClientTest extends InvokerClientTest implements SSLBisocketInvokerConstants { protected String getTransport() { return "sslbisocket"; } protected int getPort() { return bisocketPort + 11; } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/connection_check/SSLBisocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/conne0000644000175000017500000000167410545077514033540 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.connection_check; import org.jboss.test.remoting.transport.bisocket.ssl.SSLBisocketInvokerConstants; import org.jboss.test.remoting.transport.socket.ssl.connection_check.InvokerServerTest; /** * This is the concrete test for invoker server. * * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerServerTest extends InvokerServerTest implements SSLBisocketInvokerConstants { public static void main(String[] args) { SSLBisocketInvokerServerTest server = new SSLBisocketInvokerServerTest(); try { server.setUp(); } catch (Exception e) { e.printStackTrace(); } } protected String getTransport() { return "sslbisocket"; } protected int getPort() { return bisocketPort + 11; } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/connection_check/SSLBisocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/conne0000644000175000017500000000273410541702153033524 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.connection_check; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLBisocketInvokerClientTest.class.getName(), 1, SSLBisocketInvokerServerTest.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; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/basic/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/basic0000755000175000017500000000000011632407035033476 5ustar twernertwerner././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/basic/SSLBisocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/basic0000644000175000017500000000311710545077514033511 0ustar twernertwerner/* * 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.transport.bisocket.ssl.basic; import org.jboss.test.remoting.transport.bisocket.ssl.SSLBisocketInvokerConstants; import org.jboss.test.remoting.transport.socket.ssl.basic.InvokerClientTest; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerClientTest extends InvokerClientTest implements SSLBisocketInvokerConstants { protected String getTransport() { return "sslbisocket"; } protected int getPort() { return bisocketPort + 3; } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/basic/SSLBisocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/basic0000644000175000017500000000355610545077514033520 0ustar twernertwerner/* * 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.transport.bisocket.ssl.basic; import org.jboss.test.remoting.transport.bisocket.ssl.SSLBisocketInvokerConstants; import org.jboss.test.remoting.transport.socket.ssl.basic.InvokerServerTest; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerServerTest extends InvokerServerTest implements SSLBisocketInvokerConstants { public static void main(String[] args) { SSLBisocketInvokerServerTest server = new SSLBisocketInvokerServerTest(); try { server.setUp(); Thread.sleep(1200000); } catch(Exception e) { e.printStackTrace(); } } protected String getTransport() { return "sslbisocket"; } protected int getPort() { return bisocketPort + 3; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/basic/SSLBisocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/basic0000644000175000017500000000466410541702153033507 0ustar twernertwerner/* * 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.transport.bisocket.ssl.basic; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLBisocketInvokerClientTest.class.getName(), 1, SSLBisocketInvokerServerTest.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; } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custo0000755000175000017500000000000011632407036033553 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom/SSLBisocketInvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custo0000644000175000017500000000716210764360367033575 0ustar twernertwerner/* * 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.transport.bisocket.ssl.custom; import java.util.HashMap; import java.util.List; import org.apache.log4j.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.transport.socket.ssl.custom.InvokerClientTest; /** * @author Tom Elrod * @author Ron Sigal * @version $Revision: 3591 $ *

          * Copyright (c) Dec 15, 2006 *

          */ public class SSLBisocketInvokerClientTest extends InvokerClientTest { private static Logger log = Logger.getLogger(SSLBisocketInvokerClientTest.class); public void testCallbacks() { try { InvokerLocator locator = new InvokerLocator(getTransport() + "://localhost:" + callbackPort); HashMap config = new HashMap(); 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(Bisocket.IS_CALLBACK_SERVER, "true"); Connector callbackConnector = new Connector(locator.getLocatorURI(), config); callbackConnector.setServerSocketFactory(createServerSocketFactory()); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, locator, callbackHandleObject); solicitCallback("abc"); // need to wait for brief moment so server can callback Thread.sleep(1000); // remove callback handler from server client.removeListener(callbackHandler); // shut down callback server callbackConnector.stop(); callbackConnector.destroy(); callbackConnector = null; List callbacks = callbackHandler.getCallbacks(); assertEquals(callbacks.size(), 1); // assertEquals(callbacks.get(0), "abc"); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom/SSLBisocketInvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custo0000644000175000017500000000327410542176051033562 0ustar twernertwerner/* * 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.transport.bisocket.ssl.custom; import org.jboss.test.remoting.transport.socket.ssl.custom.InvokerServerTest; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketInvokerServerTest extends InvokerServerTest { public static void main(String[] args) { SSLBisocketInvokerServerTest test = new SSLBisocketInvokerServerTest(); try { test.setUp(); Thread.sleep(20000); test.tearDown(); } catch(Exception e) { e.printStackTrace(); } } protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom/SSLBisocketInvokerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custo0000644000175000017500000000543410541702153033557 0ustar twernertwerner /* * 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.transport.bisocket.ssl.custom; 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 * @author Ron Sigal */ public class SSLBisocketInvokerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SSLBisocketInvokerClientTest.class.getName(), 1, SSLBisocketInvokerServerTest.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; } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socketfactory/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socke0000755000175000017500000000000011632407035033521 5ustar twernertwerner././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socke0000644000175000017500000000271411413660476033536 0ustar twernertwerner /* * 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.transport.bisocket.ssl.socketfactory; import org.jboss.test.remoting.socketfactory.SSLSocketFactoryClassNameTestRoot; /** * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jul 18, 2008 *

          */ public class SSLSocketFactoryClassNameTestCase extends SSLSocketFactoryClassNameTestRoot { protected String getTransport() { return "sslbisocket"; } } ././@LongLink0000000000000000000000000000022600000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socketfactory/SSLBisocketCreationListenerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socke0000644000175000017500000000437310553330112033522 0ustar twernertwerner/* * 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.transport.bisocket.ssl.socketfactory; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.socketfactory.SSLCreationListenerTestRoot; import org.jboss.test.remoting.socketfactory.TestListener; /** * @author Ron Sigal * @version $Revision: 1887 $ *

          * Copyright Jan 11, 2007 *

          */ public class SSLBisocketCreationListenerTestCase extends SSLCreationListenerTestRoot { protected String getTransport() { return "sslbisocket"; } protected void addExtraClientConfig(Map config) { config.put(Bisocket.IS_CALLBACK_SERVER, "true"); } protected boolean checkListenersVisited(TestListener listener1, TestListener listener2, TestListener listener3, TestListener listener4) { // Need to treat sslbisocket transport as a special case because sockets are // created in a special way. return listener1.visited() && listener2.visited() && listener3.visited() && listener4.visited() && !listener1.isClient() && !listener2.isClient() && listener3.isClient() && listener4.isClient(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/shutdown/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/shutd0000755000175000017500000000000011632407036033545 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/shutdown/SSLBisocketShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/shutd0000644000175000017500000000446010716736111033554 0ustar twernertwerner/* * 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.transport.bisocket.ssl.shutdown; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.transport.bisocket.shutdown.BisocketShutdownTestCase; /** * @author Ron Sigal * @version $Revision: 2948 $ *

          * Copyright Jan 20, 2007 *

          */ public class SSLBisocketShutdownTestCase extends BisocketShutdownTestCase { protected String getTransport() { return "sslbisocket"; } protected String getJVMArguments() { String args = ""; String keyStoreFilePath = getClass().getResource("../.keystore").getFile(); String trustStoreFilePath = getClass().getResource("../.truststore").getFile(); String log4jFilePath = getClass().getResource("../../../../shutdown/log4j.xml").getFile(); System.out.println("log4jFilePath: " + log4jFilePath); args += "-Djavax.net.ssl.keyStore=" + keyStoreFilePath + " "; args += "-Djavax.net.ssl.keyStorePassword=unit-tests-server "; args += "-Djavax.net.ssl.trustStore=" + trustStoreFilePath + " "; args += "-Djavax.net.ssl.trustStorePassword=unit-tests-client "; args += "-Dlog4j.configuration=file:" + log4jFilePath; return args; } protected String getClientArgs() { return Bisocket.IS_CALLBACK_SERVER + "=true&"; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/clientaddress/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/clien0000755000175000017500000000000011632407035033507 5ustar twernertwerner././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/clientaddress/SSLBisocketClientAddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/clien0000644000175000017500000000253410720753477033530 0ustar twernertwernerpackage org.jboss.test.remoting.transport.bisocket.ssl.clientaddress; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class SSLBisocketClientAddressTestCase extends ClientAddressTestParent { protected String getTransport() { return "sslbisocket"; } protected void addExtraServerConfig(Map config) { 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"); } protected void addExtraClientConfig(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"); } protected void addExtraCallbackConfig(Map config) { addExtraClientConfig(config); config.put(Bisocket.IS_CALLBACK_SERVER, "true"); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketInvokerConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBi0000644000175000017500000000232210541703007033326 0ustar twernertwerner/* * 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.transport.bisocket.ssl; /** * @author Tom Elrod */ public interface SSLBisocketInvokerConstants { int bisocketPort = 8091; int bisocketCallbackPort = 8092; }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/SeparateControlSocketsTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/SeparateC0000644000175000017500000001760310665734165033510 0ustar twernertwerner/* * 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.transport.bisocket; 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; import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; /** * * @author Ron Sigal * @version $Revision: 2735 $ *

          * Copyright May 31, 2007 *

          */ public class SeparateControlSocketsTestCase extends TestCase { public static int port; private static Logger log = Logger.getLogger(SeparateControlSocketsTestCase.class); private static final String INVOCATION_TEST = "invocationTest"; 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() { } /** * Tests blocking and nonblocking direct calls to Client.getCallbacks(). */ public void testSeparateMapForControlSockets() 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(); log.info("client is connected"); // Test connection. assertEquals(INVOCATION_TEST, client.invoke(INVOCATION_TEST)); // Add callback handler and test callback BisocketClientInvoker socket maps. TestInvokerCallbackHandler callbackHandler = new TestInvokerCallbackHandler(); client.addListener(callbackHandler, new HashMap()); assertEquals(1, invocationHandler.listeners.size()); Iterator it = invocationHandler.listeners.iterator(); ServerInvokerCallbackHandler serverInvokerCallbackHandler; serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) it.next(); Client callbackClient = serverInvokerCallbackHandler.getCallbackClient(); assertNotNull(callbackClient); assertTrue(callbackClient.getInvoker() instanceof BisocketClientInvoker); BisocketClientInvoker callbackClientInvoker; callbackClientInvoker = (BisocketClientInvoker) callbackClient.getInvoker(); Field field = BisocketClientInvoker.class.getDeclaredField("listenerIdToControlSocketsMap"); field.setAccessible(true); Map listenerIdToControlSocketsMap = (Map) field.get(callbackClientInvoker); field = BisocketClientInvoker.class.getDeclaredField("listenerIdToSocketsMap"); field.setAccessible(true); Map listenerIdToSocketsMap = (Map) field.get(callbackClientInvoker); // A set should have been created to hold control sockets. assertEquals(1, listenerIdToControlSocketsMap.size()); Set controlSockets = (Set) listenerIdToControlSocketsMap.values().iterator().next(); assertEquals(0, controlSockets.size()); assertEquals(0, listenerIdToSocketsMap.size()); // Do callback and test socket maps. client.invoke(CALLBACK_TEST); assertEquals(1, listenerIdToControlSocketsMap.size()); assertEquals(0, controlSockets.size()); // A set should have been created to hold ordinary sockets. assertEquals(1, listenerIdToSocketsMap.size()); Set sockets = (Set) listenerIdToSocketsMap.values().iterator().next(); assertEquals(0, sockets.size()); 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 void handleCallback(Callback callback) throws HandleCallbackException {} } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpoo0000755000175000017500000000000011632407035033622 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketPoolTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpoo0000644000175000017500000000310110541702021033606 0ustar twernertwerner/* * 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.transport.bisocket.socketpool; import org.jboss.test.remoting.transport.socket.socketpool.SocketPoolTestClient; /** * See SocketPoolTestCase for description. * * @author Ron Sigal * @author Tom Elrod * * @version $Revision: 1732 $ *

          * Copyright Dec 15, 2006 *

          */ public class BisocketPoolTestClient extends SocketPoolTestClient { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 7; } }././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketClientPoolWithSemaphoreTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpoo0000644000175000017500000000272411413660476033640 0ustar twernertwerner/* * 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.transport.bisocket.socketpool; import org.jboss.test.remoting.transport.socket.socketpool.SocketClientPoolWithSemaphoreTestCase; /** * Unit test for JBREM-845. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Nov 30, 2007 *

          */ public class BisocketClientPoolWithSemaphoreTestCase extends SocketClientPoolWithSemaphoreTestCase { public String getTransport() { return "bisocket"; } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketPoolTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpoo0000644000175000017500000000310210541702021033607 0ustar twernertwerner/* * 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.transport.bisocket.socketpool; import org.jboss.test.remoting.transport.socket.socketpool.SocketPoolTestServer; /** * See SocketPoolTestCase for description. * * @author Ron Sigal * @author Tom Elrod * * @version $Revision: 1732 $ *

          * Copyright Dec 15, 2006 *

          */ public class BisocketPoolTestServer extends SocketPoolTestServer { protected String getTransport() { return "bisocket"; } protected int getPort() { return super.getPort() + 7; } }././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketPoolTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/socketpoo0000644000175000017500000000524210541702021033616 0ustar twernertwerner/* * 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.transport.bisocket.socketpool; import org.apache.log4j.Level; import org.jboss.test.remoting.transport.InvokerTestDriver; /** * This unit test is introduced in response to JIRA issue JBREM-625. * It verifies that when a socket is discarded, the count of sockets * in use is decremented. * * @author Ron Sigal * @author Tom Elrod * * @version $Revision: 1732 $ *

          * Copyright Dec 15, 2006 *

          */ public class BisocketPoolTestCase extends InvokerTestDriver { public void declareTestClasses() { addTestClasses(BisocketPoolTestClient.class.getName(), 1, BisocketPoolTestServer.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; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configura0000755000175000017500000000000011632407035033571 5ustar twernertwerner././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/ConfigureByInvokerLocatorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configura0000644000175000017500000001243010666634265033610 0ustar twernertwerner/* * 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.transport.bisocket.configuration; 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; import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; /** * Unit test for JBREM-734. * * @author Ron Sigal * @version $Revision: 2755 $ *

          * Copyright Sep 2, 2007 *

          */ public class ConfigureByInvokerLocatorTestCase extends TestCase { private static Logger log = Logger.getLogger(ConfigureByInvokerLocatorTestCase.class); private static boolean firstTime = true; // remoting server connector private Connector connector; private InvokerLocator locator; private 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() { } /** * Verifies that BisocketClientInvoker constructor gets parameters from * InovkerLocator. */ public void testConfigByInvokerLocator() throws Throwable { log.info("entering " + getName()); // Start server. String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port + "/?pingFrequency=3000"; locator = 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(locator, serverConfig); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put("pingFrequency", "7000"); addExtraClientConfig(clientConfig); Client client = new Client(locator, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify that BisocketClientInvoker gets pingFrequency == 3000. assertTrue(client.getInvoker() instanceof BisocketClientInvoker); BisocketClientInvoker clientInvoker = (BisocketClientInvoker) client.getInvoker(); assertEquals(3000, clientInvoker.getPingFrequency()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected String getTransport() { return "bisocket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} 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) {} } }././@LongLink0000000000000000000000000000023000000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketServerSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configura0000644000175000017500000000274311413660476033610 0ustar twernertwerner/* * 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.transport.bisocket.configuration; import org.jboss.test.remoting.transport.socket.configuration.SocketServerSocketConfigurationTestCase; /** * Unit test for JBREM-703. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 28, 2008 *

          */ public class BisocketServerSocketConfigurationTestCase extends SocketServerSocketConfigurationTestCase { protected String getTransport() { return "bisocket"; } }././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/FactoryConfigTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configura0000644000175000017500000000312110541701754033573 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.bisocket.configuration; import java.util.Map; import org.jboss.remoting.transport.bisocket.Bisocket; import org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent; /** * * @author Ron Sigal *

          * Copyright (c) Dec 15, 2005 *

          */ public class FactoryConfigTestCase extends FactoryConfigTestCaseParent { protected String getTransport() { return "bisocket"; } protected void configureServer(Map config) { config.put(Bisocket.IS_CALLBACK_SERVER, "false"); } } ././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/bisocket/configura0000644000175000017500000000272211413660476033605 0ustar twernertwerner/* * 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.transport.bisocket.configuration; import org.jboss.test.remoting.transport.socket.configuration.SocketSocketConfigurationTestCase; /** * Unit test for JBREM-703. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 28, 2008 *

          */ public class BisocketSocketConfigurationTestCase extends SocketSocketConfigurationTestCase { protected String getTransport() { return "bisocket"; } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/InvokerServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/InvokerServerTest.0000644000175000017500000001023110743035430033530 0ustar twernertwerner/* * 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.transport; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; 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 org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; /** * This is the concrete test for invoker server. * * @author Tom Elrod */ public abstract class InvokerServerTest extends ServerTestCase { protected int serverPort = 9091; // default port protected Connector connector = null; protected static final Logger log = Logger.getLogger(InvokerServerTest.class); public abstract String getTransport(); public String getSerializationType() { return null; } 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()); System.out.println("Creating connector with locator of " + locator); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); } protected String buildLocatorURI(Map metadata) { String host = System.getProperty("jrunit.bind_addr", "localhost"); if(metadata == null || metadata.size() == 0) { return getTransport() + "://" + host + ":" + serverPort; } else { StringBuffer uriBuffer = new StringBuffer(getTransport() + "://" + host + ":" + 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).append("=").append(value).append("&"); } return uriBuffer.substring(0, uriBuffer.length() - 1); } } protected String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } public void setUp() throws Exception { Map metadata = new HashMap(); String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(newMetadata != null && newMetadata.length() > 0) { metadata.putAll(PerformanceServerTest.parseMetadataString(newMetadata)); } init(metadata); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/0000755000175000017500000000000011632407036031336 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/TestServerInvocationHandler2.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/TestServerI0000644000175000017500000000327710706203105033501 0ustar twernertwerner/* * 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.transport.config; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * Used by POJOConfigurationTestCase. * * @author Ron Sigal * @version $Revision: 2845 $ *

          * Copyright Oct 19, 2007 *

          */ public class TestServerInvocationHandler2 extends AbstractInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(InvocationRequest invocation) throws Throwable {return null;} public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/TestServerSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/TestServerS0000644000175000017500000000347510706203105033513 0ustar twernertwerner/* * 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.transport.config; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import javax.net.ServerSocketFactory; /** * Used by POJOConfigurationTestCase. * * @author Ron Sigal * @version $Revision: 2845 $ *

          * Copyright Oct 18, 2007 *

          */ public class TestServerSocketFactory extends ServerSocketFactory { public ServerSocket createServerSocket(int port) throws IOException { return new ServerSocket(port); } public ServerSocket createServerSocket(int port, int backlog) throws IOException { return new ServerSocket(port, backlog); } public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException { return new ServerSocket(port, backlog, ifAddress); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/.truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/.truststore0000644000175000017500000000701310446025457033603 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/AbstractInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/AbstractInv0000644000175000017500000000312510706203105033472 0ustar twernertwerner/* * 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.transport.config; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; /** * Used by POJOConfigurationTestCase. * * @author Ron Sigal * @version $Revision: 2845 $ *

          * Copyright Oct 19, 2007 *

          */ public abstract class AbstractInvocationHandler implements ServerInvocationHandler { private ServerInvoker serverInvoker; public ServerInvoker getServerInvoker() { return serverInvoker; } public void setInvoker(ServerInvoker invoker) { serverInvoker = invoker; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/TestServerInvocationHandler1.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/TestServerI0000644000175000017500000000330010706203105033464 0ustar twernertwerner/* * 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.transport.config; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * Used by POJOConfigurationTestCase. * * @author Ron Sigal * @version $Revision: 2845 $ *

          * Copyright Oct 19, 2007 *

          */ public class TestServerInvocationHandler1 extends AbstractInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(InvocationRequest invocation) throws Throwable {return null;} public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/POJOConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/POJOConfigu0000644000175000017500000007043510746270264033362 0ustar twernertwerner/* * 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.transport.config; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.net.ServerSocketFactory; 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.Home; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerConfiguration; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.Connector; /** * * POJOConfigurationTestCase verifies that Remoting org.jboss.remoting.transport.Connector's * are properly configured when using the new org.jboss.remoting.ServerConfiguration object. * * @author Ron Sigal * @version $Revision: 3375 $ *

          * Copyright Oct 16, 2007 *

          */ public class POJOConfigurationTestCase extends TestCase { private static Logger log = Logger.getLogger(POJOConfigurationTestCase.class); private static boolean firstTime = true; private static int MAX_HOMES = 5; private Connector connector; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE); 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() { if (connector != null) { connector.destroy(); } } public void testConfiguration() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); // Add invokerLocatorParameters String address = InetAddress.getLocalHost().getHostAddress(); locatorConfig.put("serverBindAddress", address); locatorConfig.put("serverBindPort", "4446"); locatorConfig.put("datatype", "test"); locatorConfig.put("timeout", "12345"); config.setInvokerLocatorParameters(locatorConfig); // Add serverParameters Map serverParameters = new HashMap(); serverParameters.put("clientLeasePeriod", "2345"); serverParameters.put("timeout", "54321"); ServerSocketFactory factory = new TestServerSocketFactory(); serverParameters.put("customServerSocketFactory", factory); config.setServerParameters(serverParameters); // Add invocation handlers Map handlers = new HashMap(); handlers.put("system1", "org.jboss.test.remoting.transport.config.TestServerInvocationHandler1"); ServerInvocationHandler handler2 = new TestServerInvocationHandler2(); handlers.put("system2,system3", handler2); config.setInvocationHandlers(handlers); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector and get ServerInvoker // Get ServerInvoker. connector = new Connector(); connector.setServerConfiguration(config); connector.create(); connector.start(); ServerInvoker invoker = connector.getServerInvoker(); // Check InvokerLocator. InvokerLocator locator = invoker.getLocator(); log.info("constructed InvokerLocator: " + locator); assertEquals("socket://" + address + ":4446/?datatype=test&timeout=12345", locator.getLocatorURI()); // Test parameter that appears only in invokerLocatorParameters. assertEquals("test", invoker.getDataType()); // Test parameter that appears only in serverParameters. assertEquals(2345, invoker.getLeasePeriod()); // Test parameter that appears in both invokerLocatorParameters and // serverParameters. Verify that value in invokerLocatorParameters overrides. assertEquals(12345, invoker.getTimeout()); // Test object injected into serverParameters. assertTrue(invoker.getServerSocketFactory() instanceof TestServerSocketFactory); // Test invocation handlers. assertEquals(3, invoker.getInvocationHandlers().length); assertEquals(3, invoker.getSupportedSubsystems().length); ServerInvocationHandler sih1 = invoker.getInvocationHandler("system1"); ServerInvocationHandler sih2 = invoker.getInvocationHandler("system2"); ServerInvocationHandler sih3 = invoker.getInvocationHandler("system3"); assertTrue(sih1 instanceof TestServerInvocationHandler1); assertTrue(sih2 instanceof TestServerInvocationHandler2); assertTrue(sih3 instanceof TestServerInvocationHandler2); AbstractInvocationHandler aih1 = (AbstractInvocationHandler) sih1; AbstractInvocationHandler aih2 = (AbstractInvocationHandler) sih2; AbstractInvocationHandler aih3 = (AbstractInvocationHandler) sih3; assertEquals(invoker, aih1.getServerInvoker()); assertEquals(invoker, aih2.getServerInvoker()); assertEquals(invoker, aih3.getServerInvoker()); log.info(getName() + " PASSES"); } public void testClientConnectParameters() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); // Add invokerLocatorParameters String serverBindAddress = "localhost"; String serverBindPort = "4446"; String clientConnectAddress = InetAddress.getLocalHost().getHostAddress(); String clientConnectPort = "4447"; locatorConfig.put("serverBindAddress", serverBindAddress); locatorConfig.put("serverBindPort", serverBindPort); locatorConfig.put("clientConnectAddress", clientConnectAddress); locatorConfig.put("clientConnectPort", clientConnectPort); config.setInvokerLocatorParameters(locatorConfig); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector and get ServerInvoker // Get ServerInvoker. connector = new Connector(); connector.setServerConfiguration(config); connector.create(); // Check InvokerLocator. InvokerLocator locator = connector.getLocator(); log.info("constructed InvokerLocator: " + locator); assertEquals("socket://" + clientConnectAddress + ":" + clientConnectPort + "/", locator.getLocatorURI()); log.info(getName() + " PASSES"); } public void testSingleHomeParametersInBothParametersMaps() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); Map serverConfig = new HashMap(); // Add invokerLocatorParameters String serverBindAddress1 = InetAddress.getLocalHost().getHostName(); String serverBindPort1 = "4446"; String clientConnectAddress1 = InetAddress.getLocalHost().getHostAddress(); String clientConnectPort1 = "4447"; locatorConfig.put("serverBindAddress", serverBindAddress1); locatorConfig.put("serverBindPort", serverBindPort1); locatorConfig.put("clientConnectAddress", clientConnectAddress1); locatorConfig.put("clientConnectPort", clientConnectPort1); config.setInvokerLocatorParameters(locatorConfig); // Add serverParameters String serverBindAddress2 = InetAddress.getLocalHost().getHostAddress(); String serverBindPort2 = "4448"; String clientConnectAddress2 = InetAddress.getLocalHost().getHostName(); String clientConnectPort2 = "4447"; serverConfig.put("serverBindAddress", serverBindAddress2); serverConfig.put("serverBindPort", serverBindPort2); serverConfig.put("clientConnectAddress", clientConnectAddress2); serverConfig.put("clientConnectPort", clientConnectPort2); config.setServerParameters(serverConfig); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector and get ServerInvoker // Get ServerInvoker. connector = new Connector(); connector.setServerConfiguration(config); connector.create(); // Check InvokerLocator. InvokerLocator locator = connector.getLocator(); log.info("constructed InvokerLocator: " + locator); assertEquals("socket://" + clientConnectAddress1 + ":" + clientConnectPort1 + "/", locator.getLocatorURI()); // Check Connector's configuration map. Field field = Connector.class.getDeclaredField("configuration"); field.setAccessible(true); Map configuration = (Map) field.get(connector); assertEquals(4, configuration.size()); assertEquals(serverBindAddress2, configuration.get("serverBindAddress")); assertEquals(serverBindPort2, configuration.get("serverBindPort")); assertEquals(clientConnectAddress1, configuration.get("clientConnectAddress")); assertEquals(clientConnectPort1, configuration.get("clientConnectPort")); log.info(getName() + " PASSES"); } public void testMultihomeWithPortsNoDefault() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); // Add non-multihome invokerLocatorParameters - show they don't interfere. String serverBindAddress = "localhost"; String serverBindPort = "4446"; String clientConnectAddress = InetAddress.getLocalHost().getHostAddress(); String clientConnectPort = "4447"; locatorConfig.put("serverBindAddress", serverBindAddress); locatorConfig.put("serverBindPort", serverBindPort); locatorConfig.put("clientConnectAddress", clientConnectAddress); locatorConfig.put("clientConnectPort", clientConnectPort); // Add multihome invokerLocatorParameters. ArrayList homes = new ArrayList(); Enumeration e1 = NetworkInterface.getNetworkInterfaces(); loop: while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); Enumeration e2 = ni.getInetAddresses(); while (e2.hasMoreElements()) { InetAddress ia = (InetAddress) e2.nextElement(); Home h = new Home(ia.getHostAddress(), 3333); homes.add(h); if (homes.size() >= MAX_HOMES) break loop; } } Home h = (Home) homes.get(0); StringBuffer sb = new StringBuffer(h.host).append(':').append(h.port); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb.append('!').append(h.host).append(':').append(h.port); } locatorConfig.put(InvokerLocator.HOMES_KEY, sb.toString()); locatorConfig.put(InvokerLocator.CONNECT_HOMES_KEY, sb.toString()); config.setInvokerLocatorParameters(locatorConfig); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector. connector = new Connector(); connector.setServerConfiguration(config); connector.create(); // Check InvokerLocator. InvokerLocator locator = connector.getLocator(); log.info("constructed InvokerLocator: " + locator); String newLocatorURI = "socket://multihome/?"; newLocatorURI += InvokerLocator.CONNECT_HOMES_KEY + "=" + sb.toString(); newLocatorURI += "&" + InvokerLocator.HOMES_KEY + "=" + sb.toString(); assertEquals(newLocatorURI, locator.getLocatorURI()); log.info(getName() + " PASSES"); } public void testMultihomeNoPortsWithDefaultPort() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); // Add non-multihome invokerLocatorParameters - show they don't interfere. String serverBindAddress = "localhost"; String serverBindPort = "4446"; String clientConnectAddress = InetAddress.getLocalHost().getHostAddress(); String clientConnectPort = "4447"; locatorConfig.put("serverBindAddress", serverBindAddress); locatorConfig.put("serverBindPort", serverBindPort); locatorConfig.put("clientConnectAddress", clientConnectAddress); locatorConfig.put("clientConnectPort", clientConnectPort); // Add multihome invokerLocatorParameters. ArrayList homes = new ArrayList(); Enumeration e1 = NetworkInterface.getNetworkInterfaces(); loop: while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); Enumeration e2 = ni.getInetAddresses(); while (e2.hasMoreElements()) { InetAddress ia = (InetAddress) e2.nextElement(); String host = ia.getHostAddress(); boolean isIPv6 = host.indexOf('[') >= 0 || host.indexOf(':') >= 0; if (isIPv6) host = '[' + host + ']'; Home h = new Home(host, -1); homes.add(h); if (homes.size() >= MAX_HOMES) break loop; } } Home h = (Home) homes.get(0); StringBuffer sb = new StringBuffer(h.host); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb.append('!').append(h.host); } locatorConfig.put(InvokerLocator.CONNECT_HOMES_KEY, sb.toString()); locatorConfig.put(InvokerLocator.HOMES_KEY, sb.toString()); locatorConfig.put(InvokerLocator.DEFAULT_CONNECT_PORT, "3333"); locatorConfig.put(InvokerLocator.DEFAULT_PORT, "4444"); config.setInvokerLocatorParameters(locatorConfig); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector. connector = new Connector(); connector.setServerConfiguration(config); connector.create(); // Check InvokerLocator. h = (Home) homes.get(0); StringBuffer sb_connectHomes = new StringBuffer(h.host).append(':').append("3333"); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb_connectHomes.append('!').append(h.host).append(':').append("3333"); } h = (Home) homes.get(0); StringBuffer sb_homes = new StringBuffer(h.host).append(':').append("4444"); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb_homes.append('!').append(h.host).append(':').append("4444"); } InvokerLocator locator = connector.getLocator(); log.info("constructed InvokerLocator: " + locator); String expectedURI = "socket://multihome/?"; expectedURI += InvokerLocator.CONNECT_HOMES_KEY + "=" + sb_connectHomes.toString() + "&"; expectedURI += InvokerLocator.HOMES_KEY + "=" + sb_homes.toString() + "&"; expectedURI += InvokerLocator.DEFAULT_CONNECT_PORT + "=3333" + "&"; expectedURI += InvokerLocator.DEFAULT_PORT + "=4444"; log.info("actual locator: " + locator); log.info("expected locator: " + expectedURI); assertEquals(new InvokerLocator(expectedURI), locator); log.info(getName() + " PASSES"); } public void testMultihomeDuplicateElements() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); Map serverConfig = new HashMap(); // Add multihome invokerLocatorParameters. ArrayList homes = new ArrayList(); Enumeration e1 = NetworkInterface.getNetworkInterfaces(); loop: while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); Enumeration e2 = ni.getInetAddresses(); while (e2.hasMoreElements()) { InetAddress ia = (InetAddress) e2.nextElement(); Home h = new Home(ia.getHostAddress(), -1); homes.add(h); if (homes.size() >= MAX_HOMES) break loop; } } Home h = (Home) homes.get(0); StringBuffer sb1 = new StringBuffer(h.host).append(':').append("1111"); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb1.append('!').append(h.host).append(":").append("1111"); } locatorConfig.put(InvokerLocator.CONNECT_HOMES_KEY, sb1.toString()); h = (Home) homes.get(0); StringBuffer sb2 = new StringBuffer(h.host).append(':').append("2222"); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb2.append('!').append(h.host).append(":").append("2222"); } serverConfig.put(InvokerLocator.CONNECT_HOMES_KEY, sb2.toString()); h = (Home) homes.get(0); StringBuffer sb3 = new StringBuffer(h.host).append(':').append("3333"); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb3.append('!').append(h.host).append(":").append("3333"); } locatorConfig.put(InvokerLocator.HOMES_KEY, sb3.toString()); h = (Home) homes.get(0); StringBuffer sb4 = new StringBuffer(h.host).append(':').append("4444"); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb4.append('!').append(h.host).append(":").append("4444"); } serverConfig.put(InvokerLocator.HOMES_KEY, sb4.toString()); config.setInvokerLocatorParameters(locatorConfig); config.setServerParameters(serverConfig); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector. connector = new Connector(); connector.setServerConfiguration(config); connector.create(); // Check InvokerLocator. InvokerLocator locator = connector.getLocator(); log.info("constructed InvokerLocator: " + locator); String expectedURI = "socket://multihome/?"; expectedURI += InvokerLocator.CONNECT_HOMES_KEY + "=" + sb1.toString() + "&"; expectedURI += InvokerLocator.HOMES_KEY + "=" + sb3.toString(); assertEquals(expectedURI, locator.getLocatorURI()); log.info(getName() + " PASSES"); } public void testMultihomeHomesInServerConfig() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); Map serverConfig = new HashMap(); // Add multihome invokerLocatorParameters. ArrayList homes = new ArrayList(); Enumeration e1 = NetworkInterface.getNetworkInterfaces(); loop: while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); Enumeration e2 = ni.getInetAddresses(); while (e2.hasMoreElements()) { InetAddress ia = (InetAddress) e2.nextElement(); Home h = new Home(ia.getHostAddress(), -1); homes.add(h); if (homes.size() >= MAX_HOMES) break loop; } } Home h = (Home) homes.get(0); StringBuffer sb4 = new StringBuffer(h.host).append(':').append("4444"); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb4.append('!').append(h.host).append(":").append("4444"); } serverConfig.put(InvokerLocator.HOMES_KEY, sb4.toString()); config.setInvokerLocatorParameters(locatorConfig); config.setServerParameters(serverConfig); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector. connector = new Connector(); connector.setServerConfiguration(config); connector.create(); // Check InvokerLocator. InvokerLocator locator = connector.getLocator(); log.info("constructed InvokerLocator: " + locator); String expectedURI = "socket://multihome/?"; expectedURI += InvokerLocator.HOMES_KEY + "=" + sb4.toString(); assertEquals(expectedURI, locator.getLocatorURI()); log.info(getName() + " PASSES"); } public void testMultihomeMissingHomes() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); Map serverConfig = new HashMap(); // Add multihome invokerLocatorParameters. ArrayList homes = new ArrayList(); Enumeration e1 = NetworkInterface.getNetworkInterfaces(); loop: while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); Enumeration e2 = ni.getInetAddresses(); while (e2.hasMoreElements()) { InetAddress ia = (InetAddress) e2.nextElement(); Home h = new Home(ia.getHostAddress(), -1); homes.add(h); if (homes.size() >= MAX_HOMES) break loop; } } Home h = (Home) homes.get(0); StringBuffer sb1 = new StringBuffer(h.host).append(':').append("1111"); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb1.append('!').append(h.host).append(":").append("1111"); } locatorConfig.put(InvokerLocator.CONNECT_HOMES_KEY, sb1.toString()); config.setInvokerLocatorParameters(locatorConfig); config.setServerParameters(serverConfig); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector. connector = new Connector(); connector.setServerConfiguration(config); try { log.info("================= EXCEPTION EXPECTED ================"); connector.create(); fail("Should have gotten IllegalStateException"); } catch (IllegalStateException e) { String msg = "Error configuring invoker from configuration POJO. Can not continue without invoker."; assertEquals(msg, e.getMessage()); log.info("got expected IllegalStateException"); log.info("======================================================"); } log.info(getName() + " PASSES"); } public void testMultihomeAnonymousPorts() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); // Add non-multihome invokerLocatorParameters - show they don't interfere. String serverBindAddress = "localhost"; String serverBindPort = "4446"; String clientConnectAddress = InetAddress.getLocalHost().getHostAddress(); String clientConnectPort = "4447"; locatorConfig.put("serverBindAddress", serverBindAddress); locatorConfig.put("serverBindPort", serverBindPort); locatorConfig.put("clientConnectAddress", clientConnectAddress); locatorConfig.put("clientConnectPort", clientConnectPort); // Add multihome invokerLocatorParameters. ArrayList homes = new ArrayList(); Enumeration e1 = NetworkInterface.getNetworkInterfaces(); loop: while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); Enumeration e2 = ni.getInetAddresses(); log.info("interface: " + ni.getDisplayName()); while (e2.hasMoreElements()) { InetAddress ia = (InetAddress) e2.nextElement(); String host = ia.getHostAddress(); boolean isIPv6 = host.indexOf('[') >= 0 || host.indexOf(':') >= 0; if (isIPv6) host = '[' + host + ']'; log.info("host: " + host); Home h = new Home(host, -1); homes.add(h); if (homes.size() >= MAX_HOMES) break loop; } } Home h = (Home) homes.get(0); StringBuffer sb = new StringBuffer(h.host); for (int i = 1; i < homes.size(); i++) { h = (Home) homes.get(i); sb.append('!').append(h.host); } locatorConfig.put(InvokerLocator.CONNECT_HOMES_KEY, sb.toString()); locatorConfig.put(InvokerLocator.HOMES_KEY, sb.toString()); config.setInvokerLocatorParameters(locatorConfig); log.info("invokerLocatorParameters: " + config.getInvokerLocatorParameters()); log.info("serverParameters: " + config.getServerParameters()); log.info("invocationHandlers: " + config.getInvocationHandlers()); // Create Connector. connector = new Connector(); connector.setServerConfiguration(config); connector.create(); // Check InvokerLocator. ServerInvoker invoker = connector.getServerInvoker(); InvokerLocator locator = invoker.getLocator(); List homesList = locator.getHomeList(); List connectHomesList = locator.getConnectHomeList(); assertEquals(connectHomesList, homesList); log.info("constructed InvokerLocator: " + locator); String homesString = InvokerLocator.convertHomesListToString(homesList); String connectHomesString = InvokerLocator.convertHomesListToString(connectHomesList); String expectedURI = "socket://multihome/?"; expectedURI += InvokerLocator.CONNECT_HOMES_KEY + "=" + connectHomesString + "&"; expectedURI += InvokerLocator.HOMES_KEY + "=" + homesString; assertEquals(new InvokerLocator(expectedURI), locator); log.info(getName() + " PASSES"); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/.keystore0000644000175000017500000001376110446025457033221 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/FactoryConfigTestCaseSSLParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/FactoryConf0000644000175000017500000012220210774615763033513 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.config; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.security.CustomSSLServerSocketFactory; import org.jboss.remoting.security.CustomSSLSocketFactory; import org.jboss.remoting.security.SSLServerSocketFactoryService; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.SSLSocketBuilderMBean; import org.jboss.remoting.security.SSLSocketFactoryService; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocketFactory; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.Serializable; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; /** * * @author Ron Sigal *

          * Copyright (c) Jul 20, 2006 *

          */ public abstract class FactoryConfigTestCaseSSLParent extends FactoryConfigTestCaseParent { public static int secret; protected static HashMap initParameters = new HashMap(); public void testFactoriesByPassingMBeanInXml() { // There is no specific test for factory identity here, since the ServerSocketFactory // MBeans do not expose access to their internal structure. Instead, we define the // default ServerSocketFactorys and SocketFactorys to use the SSL protocol. Since // try { ///////////////////////////////////// ///// Do server side test. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); secret = ((short) System.currentTimeMillis()) & 0xffff; // Put ServerSocketFactory MBean name in config map. ServerSocketFactory service = getDefaultServerSocketFactory(); String serverSocketFactoryName = "jboss:type=serversocketfactory"; ObjectName objName = new ObjectName(serverSocketFactoryName); MBeanServer mbeanServer = null; try { final ServerSocketFactory finalService = service; final ObjectName finalName = objName; mbeanServer = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); mbeanServer.registerMBean(finalService, finalName); return mbeanServer; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, serverSocketFactoryName); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Put SSL truststore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); // Give different protocol than used by default factories. sconfig.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "TLS"); final Connector connector = new Connector(sconfig); try { final MBeanServer finalServer = mbeanServer; AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { finalServer.registerMBean(connector, new ObjectName("test:type=connector")); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } // Create another ServerSocketFactoryMBean secret = ((short) System.currentTimeMillis()) & 0xffff; service = getDefaultServerSocketFactory(); serverSocketFactoryName = "jboss:type=serversocketfactory2"; objName = new ObjectName(serverSocketFactoryName); try { final MBeanServer finalServer = mbeanServer; final ServerSocketFactory finalService = service; final ObjectName finalName = objName; AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { finalServer.registerMBean(finalService, finalName); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } // Create and set xml configuration document. int freeport = PortUtil.findFreePort(getHostName()); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + getHostName() + ""); buf.append(" " + freeport + ""); buf.append(" "); buf.append( serverSocketFactoryName); buf.append( ""); buf.append(" "); buf.append( getUniqueSocketFactoryClass()); buf.append( ""); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ServerInvoker serverInvoker = connector.getServerInvoker(); ServerSocketFactory ssf = serverInvoker.getServerSocketFactory(); int ssfPort = PortUtil.findFreePort(getHostName()); ServerSocket ss = ssf.createServerSocket(ssfPort); // Verify ServerSocketFactory is the one set in MBeanServer. assertEquals(secret, ss.getSoTimeout()); ///////////////////////////////////////////////// ///// Make Client. There is no specific //// ///// client test for MBean server case. //// ///////////////////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory in config map. SocketFactory sf2 = getDefaultSocketFactory(); cconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf2); // Make Client use remote invoker. InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); Client client = new Client(locator, cconfig); client.connect(); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); // Verify callback SocketFactory was derived from ServerSocketFactory in MBeanServer. Field field = ServerInvoker.class.getDeclaredField("handlers"); field.setAccessible(true); Map handlers = (Map) field.get(serverInvoker); Object obj = handlers.values().iterator().next(); SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj; obj = sampleInvocationHandler.getCallbackHandler(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); ClientInvoker callbackClientInvoker = callbackClient.getInvoker(); SocketFactory sf = callbackClientInvoker.getSocketFactory(); // Show that callback socket factory comes from SSLServerSocketFactory MBean // instead of xml configuration. assertTrue(SSLSocketFactoryService.class == sf.getClass()); Socket s = sf.createSocket(getHostName(), ssfPort); assertEquals(secret, s.getSoTimeout()); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testFactoriesByPassingMBeanInConfigMap() { // There is no specific test for factory identity here, since the ServerSocketFactory // MBeans do not expose access to their internal structure. Instead, we define the // default ServerSocketFactorys and SocketFactorys to use the SSL protocol. Since // try { ///////////////////////////////////// ///// Do server side test. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); secret = ((short) System.currentTimeMillis()) & 0xffff; // Put ServerSocketFactory MBean name in config map. final ServerSocketFactory service = getDefaultServerSocketFactory(); String serverSocketFactoryName = "jboss:type=serversocketfactory"; final ObjectName objName = new ObjectName(serverSocketFactoryName); MBeanServer mbeanServer = null; try { mbeanServer = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); mbeanServer.registerMBean(service, objName); return mbeanServer; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, serverSocketFactoryName); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Put SSL truststore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); // Give different protocol than used by default factories. sconfig.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "TLS"); int freeport = PortUtil.findFreePort(getHostName()); final Connector connector = new Connector(sconfig); try { final MBeanServer finalServer = mbeanServer; AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { finalServer.registerMBean(connector, new ObjectName("test:type=connector")); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } // Create and set xml configuration document. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + getHostName() + ""); buf.append(" " + freeport + ""); buf.append(" "); buf.append( getUniqueSocketFactoryClass()); buf.append( ""); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ServerInvoker serverInvoker = connector.getServerInvoker(); ServerSocketFactory ssf = serverInvoker.getServerSocketFactory(); int ssfPort = PortUtil.findFreePort(getHostName()); ServerSocket ss = ssf.createServerSocket(ssfPort); // Verify ServerSocketFactory is the one set in MBeanServer. assertEquals(secret, ss.getSoTimeout()); ///////////////////////////////////////////////// ///// Make Client. There is no specific //// ///// client test for MBean server case. //// ///////////////////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory in config map. SocketFactory sf2 = getDefaultSocketFactory(); cconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf2); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Client client = new Client(locator, cconfig); client.connect(); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); // Verify callback SocketFactory was derived from ServerSocketFactory in MBeanServer. Field field = ServerInvoker.class.getDeclaredField("handlers"); field.setAccessible(true); Map handlers = (Map) field.get(serverInvoker); Object obj = handlers.values().iterator().next(); SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj; obj = sampleInvocationHandler.getCallbackHandler(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); ClientInvoker callbackClientInvoker = callbackClient.getInvoker(); SocketFactory sf = callbackClientInvoker.getSocketFactory(); // Show that callback socket factory comes from SSLServerSocketFactory MBean // instead of xml configuration. assertTrue(SSLSocketFactoryService.class == sf.getClass()); Socket s = sf.createSocket(getHostName(), ssfPort); assertEquals(secret, s.getSoTimeout()); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testFactoriesFromSSLParameters() { try { ///////////////////////////////////// ///// Do server side test. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "false"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Put SSL truststore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); // Verify ServerSocketFactory was configured according to SSL parameters // in config map. ServerInvoker serverInvoker = connector.getServerInvoker(); ServerSocketFactory ssf = serverInvoker.getServerSocketFactory(); assertTrue(ssf instanceof CustomSSLServerSocketFactory); CustomSSLServerSocketFactory csssf = (CustomSSLServerSocketFactory) ssf; SSLSocketBuilderMBean builder = csssf.getSSLSocketBuilder(); assertFalse(builder.isServerSocketUseClientMode()); assertEquals("JKS", builder.getKeyStoreType()); File file1 = new File(keyStoreFilePath); File file2 = new File(builder.getKeyStore().getFile()); assertEquals(file1, file2); ///////////////////////////////////// ///// Do client side test. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); Client client = new Client(locator, cconfig); client.connect(); // Verify SocketFactory was configured according to SSL parameters // in config map. ClientInvoker clientInvoker = client.getInvoker(); SocketFactory sf = clientInvoker.getSocketFactory(); assertTrue(sf instanceof CustomSSLSocketFactory); CustomSSLSocketFactory cssf = (CustomSSLSocketFactory) sf; builder = cssf.getSSLSocketBuilder(); assertTrue(builder.isSocketUseClientMode()); assertEquals("JKS", builder.getKeyStoreType()); file1 = new File(trustStoreFilePath); file2 = new File(builder.getTrustStore().getFile()); assertEquals(file1, file2); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); // Verify SocketFactory was configured according to SSL parameters in config map. Field field = ServerInvoker.class.getDeclaredField("handlers"); field.setAccessible(true); Map handlers = (Map) field.get(serverInvoker); Object obj = handlers.values().iterator().next(); SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj; obj = sampleInvocationHandler.getCallbackHandler(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); ClientInvoker callbackClientInvoker = callbackClient.getInvoker(); sf = callbackClientInvoker.getSocketFactory(); assertTrue(sf instanceof CustomSSLSocketFactory); cssf = (CustomSSLSocketFactory) sf; builder = cssf.getSSLSocketBuilder(); assertFalse(builder.isSocketUseClientMode()); assertEquals("JKS", builder.getKeyStoreType()); file1 = new File(keyStoreFilePath); file2 = new File(builder.getKeyStore().getFile()); assertEquals(file1, file2); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testFactoriesFromSystemSSLParameters() { try { ///////////////////////////////////// ///// Start Connector. //// ///////////////////////////////////// // There are no specific ServerSocketFactory tests here, since different // transports handle the default case differently. HashMap sconfig = new HashMap(); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Set SSL system properties. System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_FILE_PATH, keyStoreFilePath); System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_PASSWORD, "unit-tests-server"); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_FILE_PATH, trustStoreFilePath); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_PASSWORD, "unit-tests-client"); int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Do client side test. //// ///////////////////////////////////// // There are no specific SocketFactory tests here, since different // transports handle the default case differently. HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, cconfig); client.connect(); // Verify that invocation works. client.invoke("abc"); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } protected ServerSocketFactory getDefaultServerSocketFactory() throws Exception { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SelfIdentifyingSSLSocketBuilder(config, secret); builder.setUseSSLServerSocketFactory(false); SSLServerSocketFactoryService service = new SSLServerSocketFactoryService(); service.setSSLSocketBuilder(builder); service.start(); return service; } protected SocketFactory getDefaultSocketFactory() throws Exception { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SelfIdentifyingSSLSocketBuilder(config, secret); builder.setUseSSLSocketFactory(false); SSLSocketFactoryService service = new SSLSocketFactoryService(); service.setSSLSocketBuilder(builder); service.start(); return service; } protected ServerSocketFactory getDefaultCallbackServerSocketFactory() throws Exception { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SelfIdentifyingSSLSocketBuilder(config, secret); builder.setUseSSLServerSocketFactory(false); SSLServerSocketFactoryService service = new SSLServerSocketFactoryService(); service.setSSLSocketBuilder(builder); service.start(); return service; } protected SocketFactory getDefaultCallbackSocketFactory() throws Exception { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SelfIdentifyingSSLSocketBuilder(config, secret); builder.setUseSSLSocketFactory(false); SSLSocketFactoryService service = new SSLSocketFactoryService(); service.setSSLSocketBuilder(builder); service.start(); return builder.createSSLSocketFactory(); } protected Class getUniqueServerSocketFactoryClass() throws Exception { initParameters.put(UniqueServerSocketFactory.class, getDefaultServerSocketFactory()); return UniqueServerSocketFactory.class; } protected Class getUniqueSocketFactoryClass() throws Exception { initParameters.put(UniqueSocketFactory.class, getDefaultSocketFactory()); return UniqueSocketFactory.class; } protected Class getUniqueCallbackServerSocketFactoryClass() throws Exception { initParameters.put(UniqueCallbackServerSocketFactory.class, getDefaultCallbackServerSocketFactory()); return UniqueCallbackServerSocketFactory.class; } protected Class getUniqueCallbackSocketFactoryClass() throws Exception { initParameters.put(UniqueCallbackSocketFactory.class, getDefaultCallbackSocketFactory()); return UniqueCallbackSocketFactory.class; } public static class SelfIdentifyingSSLSocketBuilder extends SSLSocketBuilder implements Serializable { public int identity; public SelfIdentifyingSSLSocketBuilder(int identity) { super(); this.identity = identity; } public SelfIdentifyingSSLSocketBuilder(Map config, int identity) { super(config); this.identity = identity; } public SocketFactory createSSLSocketFactory() throws IOException { SocketFactory sf = super.createSSLSocketFactory(); return new SelfIdentifyingSocketFactory(sf, identity); } public ServerSocketFactory createSSLServerSocketFactory() throws IOException { ServerSocketFactory ssf = super.createSSLServerSocketFactory(); return new SelfIdentifyingServerSocketFactory(ssf, identity); } } public static class SelfIdentifyingServerSocketFactory extends SSLServerSocketFactory { private ServerSocketFactory ssf; public int identity; public SelfIdentifyingServerSocketFactory(ServerSocketFactory ssf, int identity) { this.ssf = ssf; this.identity = identity; log.info("identity: " + identity); } public ServerSocket createServerSocket(int arg0) throws IOException { ServerSocket ss = ssf.createServerSocket(arg0); ss.setSoTimeout(identity); return ss; } public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { return ssf.createServerSocket(arg0, arg1); } public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { return ssf.createServerSocket(arg0, arg1, arg2); } public String[] getDefaultCipherSuites() { return null; } public String[] getSupportedCipherSuites() { return null; } } public static class SelfIdentifyingSocketFactory extends SSLSocketFactory implements Serializable { private SocketFactory sf; public int identity; public SelfIdentifyingSocketFactory(SocketFactory sf, int identity) { this.sf = sf; this.identity = identity; } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { Socket s = sf.createSocket(arg0, arg1); s.setSoTimeout(identity); return s; } public Socket createSocket() throws IOException { return sf.createSocket(); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { return sf.createSocket(arg0, arg1, arg2, arg3); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { return sf.createSocket(arg0, arg1); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { return sf.createSocket(arg0, arg1, arg2, arg3); } public Socket createSocket(Socket arg0, String arg1, int arg2, boolean arg3) throws IOException { return ((SSLSocketFactory)sf).createSocket(arg0, arg1, arg2, arg3); } public String[] getDefaultCipherSuites() { return ((SSLSocketFactory)SSLSocketFactory.getDefault()).getDefaultCipherSuites(); } public String[] getSupportedCipherSuites() { return ((SSLSocketFactory)SSLSocketFactory.getDefault()).getSupportedCipherSuites(); } } public static class UniqueServerSocketFactory extends SelfIdentifyingServerSocketFactory { public UniqueServerSocketFactory() { super((ServerSocketFactory) initParameters.get(UniqueServerSocketFactory.class), 0); } } public static class UniqueSocketFactory extends SelfIdentifyingSocketFactory { public UniqueSocketFactory() { super((SocketFactory) initParameters.get(UniqueSocketFactory.class), 0); } } public static class UniqueCallbackServerSocketFactory extends SelfIdentifyingServerSocketFactory { public UniqueCallbackServerSocketFactory() { super((ServerSocketFactory) initParameters.get(UniqueCallbackServerSocketFactory.class), 0); } } public static class UniqueCallbackSocketFactory extends SelfIdentifyingSocketFactory { public UniqueCallbackSocketFactory() { super((SocketFactory) initParameters.get(UniqueCallbackSocketFactory.class), 0); } } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/FactoryConfigTestCaseParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/config/FactoryConf0000644000175000017500000014704010774615674033523 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.transport.config; 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.Remoting; 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.security.SSLSocketBuilder; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.SocketFactoryMBean; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import org.w3c.dom.Document; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; /** * * @author Ron Sigal * @version $Revision: 3873 $ *

          * Copyright (c) Jun 13, 2006 *

          */ public abstract class FactoryConfigTestCaseParent extends TestCase { protected static Logger log = Logger.getLogger(FactoryConfigTestCaseParent.class); protected static boolean firstTime = true; abstract protected String getTransport(); public static String getKeystoreFilePath() { File dir = (File)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new File(FactoryConfigTestCaseParent.class.getResource(".").getFile()); } }); while (!"transport".equals(dir.getName())) { dir = new File(dir.getParent()); } return dir.getPath() + File.separator + "config/.keystore"; } public static String getTruststoreFilePath() { File dir = new File(FactoryConfigTestCaseParent.class.getResource(".").getFile()); while (!"transport".equals(dir.getName())) { dir = new File(dir.getParent()); } return dir.getPath() + File.separator + "config/.truststore"; } public void setUp() { if (firstTime) { firstTime = false; log.info("********************************************************"); log.info("*********** FactoryConfigTestCase: " + getTransport() + " ***********"); log.info("********************************************************"); } } public void testFactoriesBySettingInvokers() { try { ///////////////////////////////////// ///// Do server side test. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Put ServerSocketFactory and SocketFactory in config map. ServerSocketFactory ssf1 = getDefaultServerSocketFactory(); sconfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf1); SocketFactory sf1 = getDefaultCallbackSocketFactory(); sconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf1); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Put ServerSocketFactory MBean name in config map. ServerSocketFactory serverSocketService = getDefaultServerSocketFactory(); String serverSocketFactoryName = "jboss:type=serversocketfactory"; ObjectName objName = new ObjectName(serverSocketFactoryName); MBeanServer mbeanServer = null; try { mbeanServer = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } mbeanServer.registerMBean(serverSocketService, objName); sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, serverSocketFactoryName); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Put SSL truststore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); Connector connector = new Connector(sconfig); mbeanServer.registerMBean(connector, new ObjectName("test:type=connector")); // Create and set xml configuration document. int freeport = PortUtil.findFreePort(getHostName()); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + getHostName() + ""); buf.append(" " + freeport + ""); buf.append(" "); buf.append( getUniqueServerSocketFactoryClass()); buf.append(" "); buf.append(" "); buf.append( getUniqueSocketFactoryClass()); buf.append(" "); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); // Set ServerSocketFactory and SocketFactory in ServerInvoker. ServerInvoker serverInvoker = connector.getServerInvoker(); ServerSocketFactory ssf2 = getDefaultServerSocketFactory(); serverInvoker.setServerSocketFactory(ssf2); SocketFactory sf2 = getDefaultCallbackSocketFactory(); serverInvoker.setSocketFactory(sf2); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); // Verify ServerSocketFactory is the one set in ServerInvoker. assertTrue(ssf2 == serverInvoker.getServerSocketFactory()); ///////////////////////////////////// ///// Do client side test. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory in config map. SocketFactory sf3 = getDefaultSocketFactory(); cconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf3); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Client client = new Client(locator, cconfig); client.connect(); // Set SocketFactory in ClientInvoker. SocketFactory sf4 = getDefaultSocketFactory(); ClientInvoker clientInvoker = client.getInvoker(); clientInvoker.setSocketFactory(sf4); // Verify SocketFactory is the one set in ClientInvoker. assertTrue(sf4 == clientInvoker.getSocketFactory()); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); // Verify callback SocketFactory is the one set in SocketInvoker. Field field = ServerInvoker.class.getDeclaredField("handlers"); field.setAccessible(true); Map handlers = (Map) field.get(serverInvoker); Object obj = handlers.values().iterator().next(); SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj; obj = sampleInvocationHandler.getCallbackHandler(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); ClientInvoker callbackClientInvoker = callbackClient.getInvoker(); assertTrue(sf2 == callbackClientInvoker.getSocketFactory()); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testFactoriesBySettingConnectorAndClient() { try { ///////////////////////////////////// ///// Do server side test. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Put ServerSocketFactory and SocketFactory in config map. ServerSocketFactory ssf1 = getDefaultServerSocketFactory(); sconfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf1); SocketFactory sf1 = getDefaultCallbackSocketFactory(); sconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf1); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Put ServerSocketFactory MBean name in config map. ServerSocketFactory serverSocketService = getDefaultServerSocketFactory(); String serverSocketFactoryName = "jboss:type=serversocketfactory"; ObjectName objName = new ObjectName(serverSocketFactoryName); MBeanServer mbeanServer = null; try { mbeanServer = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } mbeanServer.registerMBean(serverSocketService, objName); sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, serverSocketFactoryName); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Put SSL truststore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); Connector connector = new Connector(sconfig); mbeanServer.registerMBean(connector, new ObjectName("test:type=connector")); // Create and set xml configuration document. int freeport = PortUtil.findFreePort(getHostName()); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + getHostName() + ""); buf.append(" " + freeport + ""); buf.append(" "); buf.append( getUniqueServerSocketFactoryClass()); buf.append(" "); buf.append(" "); buf.append( getUniqueSocketFactoryClass()); buf.append(" "); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); // Set ServerSocketFactory and SocketFactory in Connector. ServerSocketFactory ssf2 = getDefaultServerSocketFactory(); connector.setServerSocketFactory(ssf2); SocketFactory sf2 = getDefaultCallbackSocketFactory(); connector.setSocketFactory(sf2); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); // Verify ServerSocketFactory is the one set in Connector. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(ssf2 == serverInvoker.getServerSocketFactory()); ///////////////////////////////////// ///// Do client side test. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory in config map. SocketFactory sf3 = getDefaultSocketFactory(); cconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf3); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Client client = new Client(locator, cconfig); // Set SocketFactory in Client. SocketFactory sf4 = getDefaultSocketFactory(); client.setSocketFactory(sf4); client.connect(); // Verify SocketFactory is the one set in Client. ClientInvoker clientInvoker = client.getInvoker(); assertTrue(sf4 == clientInvoker.getSocketFactory()); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); // Verify callback SocketFactory is the one set in Connector. Field field = ServerInvoker.class.getDeclaredField("handlers"); field.setAccessible(true); Map handlers = (Map) field.get(serverInvoker); Object obj = handlers.values().iterator().next(); SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj; obj = sampleInvocationHandler.getCallbackHandler(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); ClientInvoker callbackClientInvoker = callbackClient.getInvoker(); assertTrue(sf2 == callbackClientInvoker.getSocketFactory()); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testFactoriesByPassingInConfig() { try { ///////////////////////////////////// ///// Do server side test. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Put ServerSocketFactory and SocketFactory in config map. ServerSocketFactory ssf1 = getDefaultServerSocketFactory(); sconfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf1); SocketFactory sf1 = getDefaultCallbackSocketFactory(); sconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf1); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Put ServerSocketFactory MBean name in config map. ServerSocketFactory serverSocketService = getDefaultServerSocketFactory(); String serverSocketFactoryName = "jboss:type=serversocketfactory"; ObjectName objName = new ObjectName(serverSocketFactoryName); MBeanServer mbeanServer = null; try { mbeanServer = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } mbeanServer.registerMBean(serverSocketService, objName); sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, serverSocketFactoryName); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Put SSL truststore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); Connector connector = new Connector(sconfig); mbeanServer.registerMBean(connector, new ObjectName("test:type=connector")); // Create and set xml configuration document. int freeport = PortUtil.findFreePort(getHostName()); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + getHostName() + ""); buf.append(" " + freeport + ""); buf.append(" "); buf.append( getUniqueServerSocketFactoryClass()); buf.append(" "); buf.append(" "); buf.append( getUniqueSocketFactoryClass()); buf.append(" "); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); // Verify ServerSocketFactory is the one passed in config map. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(ssf1 == serverInvoker.getServerSocketFactory()); ///////////////////////////////////// ///// Do client side test. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory in config map. SocketFactory sf2 = getDefaultSocketFactory(); cconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf2); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Client client = new Client(locator, cconfig); client.connect(); // Verify SocketFactory is the one passed in config map. ClientInvoker clientInvoker = client.getInvoker(); assertTrue(sf2 == clientInvoker.getSocketFactory()); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); // Verify callback SocketFactory is the one passed in config map. Field field = ServerInvoker.class.getDeclaredField("handlers"); field.setAccessible(true); Map handlers = (Map) field.get(serverInvoker); Object obj = handlers.values().iterator().next(); SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj; obj = sampleInvocationHandler.getCallbackHandler(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); ClientInvoker callbackClientInvoker = callbackClient.getInvoker(); assertTrue(sf1 == callbackClientInvoker.getSocketFactory()); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testFactoriesByClassNameInXmlDoc() { try { ///////////////////////////////////// ///// Do server side test. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Put class names of ServerSocketFactory and SocketFactory in config map. sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, ServerSocketFactory.getDefault().getClass().getName()); sconfig.put(Remoting.SOCKET_FACTORY_NAME, SocketFactory.getDefault().getClass().getName()); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Put ServerSocketFactory MBean name in config map. final ServerSocketFactory serverSocketService = getDefaultServerSocketFactory(); String serverSocketFactoryName = "jboss:type=serversocketfactory"; final ObjectName objName = new ObjectName(serverSocketFactoryName); MBeanServer mbeanServer = null; try { mbeanServer = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } try { final MBeanServer finalServer = mbeanServer; AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { finalServer.registerMBean(serverSocketService, objName); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } // mbeanServer.registerMBean(serverSocketService, objName); sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, serverSocketFactoryName); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Put SSL truststore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); Connector connector = new Connector(sconfig); // Create and set xml configuration document. int freeport = PortUtil.findFreePort(getHostName()); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + getHostName() + ""); buf.append(" " + freeport + ""); buf.append(" " + getUniqueServerSocketFactoryClass().getName() + ""); buf.append(" "); buf.append( getUniqueCallbackSocketFactoryClass().getName()); buf.append( ""); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); // Verify ServerSocketFactory is the one passed in config map. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(getUniqueServerSocketFactoryClass() == serverInvoker.getServerSocketFactory().getClass()); ///////////////////////////////////// ///// Do client side test. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory class name in config map. cconfig.put(Remoting.SOCKET_FACTORY_NAME, getUniqueSocketFactoryClass().getName()); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Client client = new Client(locator, cconfig); client.connect(); // Verify SocketFactory is the one passed in config map. ClientInvoker clientInvoker = client.getInvoker(); assertTrue(getUniqueSocketFactoryClass() == clientInvoker.getSocketFactory().getClass()); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); // Verify callback SocketFactory is the one passed in config map. Field field = ServerInvoker.class.getDeclaredField("handlers"); field.setAccessible(true); Map handlers = (Map) field.get(serverInvoker); Object obj = handlers.values().iterator().next(); SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj; obj = sampleInvocationHandler.getCallbackHandler(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); ClientInvoker callbackClientInvoker = callbackClient.getInvoker(); assertTrue(getUniqueCallbackSocketFactoryClass() == callbackClientInvoker.getSocketFactory().getClass()); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } public void testFactoriesByClassNameInConfigMap() { try { ///////////////////////////////////// ///// Do server side test. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Put class names of ServerSocketFactory and SocketFactory in config map. sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, getUniqueServerSocketFactoryClass().getName()); sconfig.put(Remoting.SOCKET_FACTORY_NAME, getUniqueCallbackSocketFactoryClass().getName()); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Special case: tell HTTPSClientInvoker to ignore hostname in certificates. // This is because InvokerLocator turns "localhost" into "127.0.0.1". Should // be fixed by JBREM-497. sconfig.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true"); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Put SSL truststore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); // Verify ServerSocketFactory is the one passed in config map. ServerInvoker serverInvoker = connector.getServerInvoker(); assertTrue(getUniqueServerSocketFactoryClass() == serverInvoker.getServerSocketFactory().getClass()); ///////////////////////////////////// ///// Do client side test. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory class name in config map. cconfig.put(Remoting.SOCKET_FACTORY_NAME, getUniqueSocketFactoryClass().getName()); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); Client client = new Client(locator, cconfig); client.connect(); // Verify SocketFactory is the one passed in config map. ClientInvoker clientInvoker = client.getInvoker(); assertTrue(getUniqueSocketFactoryClass() == clientInvoker.getSocketFactory().getClass()); ////////////////////////////////////////////// ///// Do server side callback test. //// ////////////////////////////////////////////// Thread.sleep(500); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); HashMap config = new HashMap(); addExtraCallbackConfig(config); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), config); ServerSocketFactory ssf3 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf3); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); // Verify that callback succeeded. assertEquals(1, callbackHandler.getCallbacks().size()); // Verify callback SocketFactory is the one passed in config map. Field field = ServerInvoker.class.getDeclaredField("handlers"); field.setAccessible(true); Map handlers = (Map) field.get(serverInvoker); Object obj = handlers.values().iterator().next(); SampleInvocationHandler sampleInvocationHandler = (SampleInvocationHandler) obj; obj = sampleInvocationHandler.getCallbackHandler(); ServerInvokerCallbackHandler serverInvokerCallbackHandler = (ServerInvokerCallbackHandler) obj; field = ServerInvokerCallbackHandler.class.getDeclaredField("callBackClient"); field.setAccessible(true); Client callbackClient = (Client) field.get(serverInvokerCallbackHandler); ClientInvoker callbackClientInvoker = callbackClient.getInvoker(); assertTrue(getUniqueCallbackSocketFactoryClass() == callbackClientInvoker.getSocketFactory().getClass()); client.disconnect(); callbackConnector.stop(); connector.stop(); log.info(getName() + " PASSES"); } catch (Throwable t) { log.error(t); t.printStackTrace(); log.info(getName() + " FAILS"); fail(); } } protected String getHostName() { return "localhost"; } protected ServerSocketFactory getDefaultServerSocketFactory() throws Exception { return new SelfIdentifyingServerSocketFactory(); } protected SocketFactory getDefaultSocketFactory() throws Exception { return SocketFactory.getDefault(); } protected ServerSocketFactory getDefaultCallbackServerSocketFactory() throws Exception { return new SelfIdentifyingServerSocketFactory(); } protected SocketFactory getDefaultCallbackSocketFactory() throws Exception { return SocketFactory.getDefault(); } protected Class getUniqueServerSocketFactoryClass() throws Exception { return UniqueServerSocketFactory.class; } protected Class getUniqueSocketFactoryClass() throws Exception { return UniqueSocketFactory.class; } protected Class getUniqueCallbackServerSocketFactoryClass() throws Exception { return UniqueServerSocketFactory.class; } protected Class getUniqueCallbackSocketFactoryClass() throws Exception { return UniqueSocketFactory.class; } protected void addExtraCallbackConfig(Map config) { } public static class UniqueServerSocketFactory extends ServerSocketFactory implements ServerSocketFactoryMBean { public ServerSocket createServerSocket(int arg0) throws IOException { return new ServerSocket(arg0); } public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { return new ServerSocket(arg0, arg1); } public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { return new ServerSocket(arg0, arg1, arg2); } } public static class UniqueSocketFactory extends SocketFactory implements SocketFactoryMBean { public Socket createSocket() throws IOException { return new Socket(); } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { return new Socket(arg0, arg1); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { return new Socket(arg0, arg1, arg2, arg3); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { return new Socket(arg0, arg1); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { return new Socket(arg0, arg1, arg2, arg3); } } public interface SelfIdentifyingServerSocketFactoryMBean extends ServerSocketFactoryMBean { ServerSocket createServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException; ServerSocket createServerSocket(int port, int backlog) throws IOException; ServerSocket createServerSocket(int port) throws IOException; ServerSocket createServerSocket() throws IOException; long getIdentity(); void setIdentity(long identity); } public static class SelfIdentifyingServerSocketFactory extends ServerSocketFactory implements SelfIdentifyingServerSocketFactoryMBean { private long identity; public SelfIdentifyingServerSocketFactory() { } public long getIdentity() { return identity; } public void setIdentity(long identity) { this.identity = identity; } public ServerSocket createServerSocket(int arg0) throws IOException { return new SelfIdentifyingServerSocket(arg0, identity); } public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { return new SelfIdentifyingServerSocket(arg0, arg1, identity); } public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { return new SelfIdentifyingServerSocket(arg0, arg1, arg2, identity); } class SelfIdentifyingServerSocket extends ServerSocket { private long identity; public SelfIdentifyingServerSocket(int port, int backlog, InetAddress bindAddr, long identity) throws IOException { super(port, backlog, bindAddr); this.identity = identity; } public SelfIdentifyingServerSocket(int port, int backlog, long identity) throws IOException { super(port, backlog); this.identity = identity; } public SelfIdentifyingServerSocket(int port, long identity) throws IOException { super(port); this.identity = identity; } public SelfIdentifyingServerSocket(long identity) throws IOException { super(); this.identity = identity; } public long getIdentity() { return identity; } } } public static class SampleInvocationHandler implements ServerInvocationHandler { private InvokerCallbackHandler callbackHandler; public SampleInvocationHandler() { } public Object invoke(InvocationRequest invocation) throws Throwable { return new Integer(0); } public void addListener(InvokerCallbackHandler callbackHandler) { log.info("entering addListener()"); this.callbackHandler = callbackHandler; try { Callback callback = new Callback(new Integer(1)); callbackHandler.handleCallback(callback); log.info("sent first callback"); } catch(Exception e) { e.printStackTrace(); } } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } public InvokerCallbackHandler getCallbackHandler() { return callbackHandler; } } public static class CallbackHandler implements InvokerCallbackHandler { private ArrayList callbacks = new ArrayList(); public CallbackHandler() { } public ArrayList getCallbacks() { return callbacks; } /** * Will take the callback and print out its values. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { log.info("Received push callback."); log.info("Received callback value of: " + callback.getCallbackObject()); log.info("Received callback server invoker of: " + callback.getServerLocator()); callbacks.add(callback); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/0000755000175000017500000000000011632407040030641 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/WebInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/WebInvocationH0000644000175000017500000002105010723465064033453 0ustar twernertwerner/* * 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.transport.web; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import org.apache.log4j.Logger; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * @author Tom Elrod */ public class WebInvocationHandler implements ServerInvocationHandler { // 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 ComplexObject OBJECT_RESPONSE_VALUE = new ComplexObject(5, "dub", false); public static final ComplexObject LARGE_OBJECT_RESPONSE_VALUE = new ComplexObject(5, "dub", false, 7568); public static final String NULL_RETURN_PARAM = "return_null"; public static final String OBJECT_RETURN_PARAM = "return_object"; public static final String THROW_EXCEPTION_PARAM = "throw_exception"; public static final String STRING_RETURN_PARAM = "return_string"; public static final String USER_AGENT_PARAM = "user_agent"; public static final String HTML_PAGE_RESPONSE = "Test HTML page" + "

          HTTP/Servlet Test HTML page

          This is a simple page served for test." + "

          Should show up in browser or via invoker client"; public static final String SET_CONTENT_TYPE = "setContentType"; public static final String CONTENT_TYPE = "test/testContentType"; public static final String GET_ADDRESS = "getAddress"; public static final String OPEN_CONNECTION = "openConnection"; public static final String SEND_CALLBACK = "sendCallback"; public static final String COPY = "copy:"; public static final int ANSWER = 17; public static final String CHECK_MBEAN_SERVER = "checkMBeanServer"; public static final String DEFAULT_DOMAIN = "defaultDomain"; protected static String HEADER_RESPONSE_KEY = "responseKey"; protected static String HEADER_RESPONSE_VALUE = "responseValue"; protected static String RETURN_RESPONSE_HEADER = "returnResponseHeader"; private static Logger log = Logger.getLogger(WebInvocationHandler.class); private InvokerCallbackHandler callbackHandler; private MBeanServer server; /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request Object request = invocation.getParameter(); log.debug("Invocation request is: " + request); if(NULL_RETURN_PARAM.equals(request)) { return null; } else if(THROW_EXCEPTION_PARAM.equals(request)) { log.debug("throwing WebTestException"); throw new WebTestException("This is an exception being thrown as part of test case. It is intentional."); } else if(request instanceof ComplexObject) { ComplexObject obj = (ComplexObject) request; if(obj.getSize() > 1024) { return LARGE_OBJECT_RESPONSE_VALUE; } else { return OBJECT_RESPONSE_VALUE; } } else if(STRING_RETURN_PARAM.equals(request)) { // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } else if(USER_AGENT_PARAM.equals(request)) { // return user agent found in map return invocation.getRequestPayload().get("user-agent"); } else if (SET_CONTENT_TYPE.equals(request)) { Map returnPayload = invocation.getReturnPayload(); if (returnPayload == null) { returnPayload = new HashMap(); invocation.setReturnPayload(returnPayload); } returnPayload.put("Content-Type", CONTENT_TYPE); return CONTENT_TYPE; } else if (GET_ADDRESS.equals(request)) { InetAddress address = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS); log.info("returning address: " + address); return address; } else if (OPEN_CONNECTION.equals(request)) { InetAddress addr = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS); log.info("creating socket connected to: " + addr); Integer callbackPortInt = (Integer) invocation.getRequestPayload().get("callbackPort"); int callbackPort = callbackPortInt.intValue(); Socket s = new Socket(addr, callbackPort); log.info("created socket connected to: " + addr); OutputStream os = s.getOutputStream(); os.write(ANSWER); log.info("wrote answer"); s.close(); return null; } else if (SEND_CALLBACK.equals(request)) { callbackHandler.handleCallback(new Callback("callback")); return null; } else if (request instanceof String && ((String)request).startsWith(COPY)) { return ((String) invocation.getParameter()).substring(5); } else if (RETURN_RESPONSE_HEADER.equals(request)) { Map returnPayload = invocation.getReturnPayload(); if (returnPayload == null) { returnPayload = new HashMap(); invocation.setReturnPayload(returnPayload); } returnPayload.put(HEADER_RESPONSE_KEY, HEADER_RESPONSE_VALUE); return request; } else if (CHECK_MBEAN_SERVER.equals(request)) { log.info("MBeanServer: " + server); Map metadata = invocation.getRequestPayload(); String defaultDomain = (String) metadata.get(DEFAULT_DOMAIN); log.info("defaultDomain: " + defaultDomain); if ("jboss".equals(defaultDomain)) return new Boolean("jboss".equals(server.getDefaultDomain())); else if ("platform".equals(defaultDomain)) return new Boolean(!("jboss".equals(server.getDefaultDomain()))); else return new Boolean(false); } else { return HTML_PAGE_RESPONSE; } } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } /** * 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) { this.server = server; } /** * 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 } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/WebTestException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/WebTestExcepti0000644000175000017500000000246610703330263033473 0ustar twernertwerner/* * 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.transport.web; import java.io.IOException; /** * @author Ron Sigal * @version $Revision: 2816 $ *

          * Copyright Oct 9, 2007 *

          */ public class WebTestException extends IOException { public WebTestException(String message) { super(message); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/ComplexObject.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/ComplexObject.0000644000175000017500000000406110355142433033404 0ustar twernertwerner/* * 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.transport.web; import java.io.Serializable; /** * @author Tom Elrod */ public class ComplexObject implements Serializable { public int i = 42; public String s = "test"; public boolean b = true; public byte[] bytes = new byte[0]; public ComplexObject() { } public ComplexObject(int i, String s, boolean b) { this.i = i; this.s = s; this.b = b; } public ComplexObject(int i, String s, boolean b, int byteSize) { this(i, s, b); bytes = new byte[byteSize]; } public void setBytes(byte[] bytes) { this.bytes = bytes; } public int getSize() { return bytes.length; } public boolean equals(Object o) { if(o instanceof ComplexObject) { ComplexObject co = (ComplexObject) o; if(co.i == i && co.s.equals(s) && co.b == b) { return true; } else { return false; } } else { return false; } } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/WebInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/web/WebInvokerTest0000644000175000017500000003064411246346031033511 0ustar twernertwerner/* * 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.transport.web; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.Properties; import javax.net.ssl.HttpsURLConnection; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.remoting.transport.http.WebServerError; import org.jboss.remoting.transport.web.WebUtil; /** * @author Tom Elrod */ public abstract class WebInvokerTestClient extends TestCase { protected static Logger log = Logger.getLogger(WebInvokerTestClient.class); public abstract String getLocatorURI(); public void testPostInvocation() throws Exception { testPostInvocationSub(true); testPostInvocationSub(false); checkContentType(); } /** * If raw == true, set content-type appropriately. * If raw == false, all content will be binary and well be treated as binary. */ public void testPostInvocationSub(boolean raw) throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURI()); log.debug("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); if (raw) { // The following use of two versions of Client.RAW is to account for the // fact that the value of Client.RAW changed from Remoting 1.4.x to // Remoting 2.0.0. This test is used as part of the version compatibility // test suite. Yuck. metadata.put("rawPayload", Boolean.TRUE); metadata.put("RAW_PAYLOAD", Boolean.TRUE); } metadata.put("TYPE", "POST"); Properties headerProps = new Properties(); if (raw) { headerProps.put(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING); } else { headerProps.put("Content-Type", WebUtil.BINARY); headerProps.put(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING); } addHeaders(headerProps); metadata.put("HEADER", headerProps); Properties headerProps1 = new Properties(headerProps); HashMap onewayMetadata1 = new HashMap(metadata); onewayMetadata1.put("HEADER", headerProps1); remotingClient.invokeOneway("Do something", onewayMetadata1, true); Properties headerProps2 = new Properties(headerProps); HashMap onewayMetadata2 = new HashMap(metadata); onewayMetadata2.put("HEADER", headerProps2); remotingClient.invokeOneway("Do something", onewayMetadata2, false); Thread.sleep(100); // test with null return expected Object response = null; response = remotingClient.invoke(WebInvocationHandler.NULL_RETURN_PARAM, metadata); log.debug("First response should be null and was: " + response); assertNull(response); response = remotingClient.invoke("Do something", metadata); log.debug("Second response should be " + WebInvocationHandler.HTML_PAGE_RESPONSE + " and was: " + response); assertEquals(WebInvocationHandler.HTML_PAGE_RESPONSE, response); if (raw) { headerProps.put("Content-Type", WebUtil.BINARY); } response = remotingClient.invoke(new ComplexObject(2, "foo", true), metadata); log.debug("Third response should be " + WebInvocationHandler.OBJECT_RESPONSE_VALUE + " and was: " + response); assertEquals(WebInvocationHandler.OBJECT_RESPONSE_VALUE, response); response = remotingClient.invoke(new ComplexObject(2, "foo", true, 3000), metadata); log.debug("Fourth response should be " + WebInvocationHandler.LARGE_OBJECT_RESPONSE_VALUE + " and was: " + response); assertEquals(WebInvocationHandler.LARGE_OBJECT_RESPONSE_VALUE, response); if (raw) { headerProps.put("Content-Type", "application/soap+xml"); } response = remotingClient.invoke(WebInvocationHandler.STRING_RETURN_PARAM, metadata); log.debug("Fifth response should be " + WebInvocationHandler.RESPONSE_VALUE + " and was: " + response); assertEquals(WebInvocationHandler.RESPONSE_VALUE, response); checkUserAgent(remotingClient, metadata); makeExceptionInvocation(remotingClient, metadata); } catch (Throwable throwable) { throw new Exception(throwable); } finally { if (remotingClient != null) { remotingClient.disconnect(); } } } protected void checkUserAgent(Client remotingClient, Map metadata) throws Throwable { Object response; String remotingUserAgentValue = "JBossRemoting - "; response = remotingClient.invoke(WebInvocationHandler.USER_AGENT_PARAM, metadata); log.debug("Sixth response start with " + remotingUserAgentValue + " and was: " + response); boolean correctUserAgent = ((String) response).startsWith(remotingUserAgentValue); assertTrue("User-Agent should be begin with " + remotingUserAgentValue + " but was " + response, correctUserAgent); } protected void makeExceptionInvocation(Client remotingClient, Map metadata) throws Throwable { Object response = null; try { log.debug("making exception invocation"); response = remotingClient.invoke(WebInvocationHandler.THROW_EXCEPTION_PARAM, metadata); assertTrue("Should have thrown WebServerError and not made it to here.", false); } catch (Exception error) { log.debug("exception: " + error + " " + error.getMessage()); // having to check class name instead of just catching type WebServerError so // can use for backwards compatibility tests since WebServerError is new since 2.0.0.CR1. if (getLocatorURI().indexOf("dont-return-exception=true") >= 0) { assertTrue("Did not get WebServerError", error instanceof WebServerError); assertNotNull(error.getMessage()); assertTrue(error.getMessage().indexOf("Error occurred processing invocation request. ") >= 0); } else if (Boolean.TRUE.equals(metadata.get("rawPayload")) || Boolean.TRUE.equals(metadata.get("RAW_PAYLOAD"))) { assertTrue("Did not get WebServerError", error instanceof WebServerError); assertNotNull(error.getMessage()); log.debug("message: " + error.getMessage()); log.debug("message type: " + error.getMessage().getClass()); assertTrue(error.getMessage().startsWith("Error received when calling on web server.")); } else { assertTrue("Did not get WebTestException", error instanceof WebTestException); } } metadata.put(HTTPMetadataConstants.NO_THROW_ON_ERROR, "true"); response = remotingClient.invoke(WebInvocationHandler.THROW_EXCEPTION_PARAM, metadata); if (response instanceof Exception) { log.debug("Return from invocation is of type Exception as expected."); assertTrue("Received exception return as expected.", true); } else { log.info("Did not get Exception type returned as expected."); assertTrue("Should have received Exception as return.", false); } metadata.remove(HTTPMetadataConstants.NO_THROW_ON_ERROR); } protected void checkContentType() throws Exception { log.debug("check_content_type: " + System.getProperty("check_content_type")); String s = System.getProperty("check_content_type", "true"); boolean doCheck = Boolean.valueOf(s).booleanValue(); if (!doCheck) { log.debug("skipping content type check"); return; } String urlString = getLocatorURI(); int pos = urlString.indexOf("servlet"); if (pos == 0) { urlString = "http" + urlString.substring("servlet".length()); } pos = urlString.indexOf("sslservlet"); if (pos == 0) { urlString = "https" + urlString.substring("sslservlet".length()); } URL url = new URL(urlString); OutputStream os = null; String contentType = null; if (urlString.startsWith("https")) { HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.addRequestProperty(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING); os = conn.getOutputStream(); byte[] requestBytes = WebInvocationHandler.SET_CONTENT_TYPE.getBytes(); os.write(requestBytes); contentType = conn.getContentType(); } else { HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.addRequestProperty(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING); os = conn.getOutputStream(); byte[] requestBytes = WebInvocationHandler.SET_CONTENT_TYPE.getBytes(); os.write(requestBytes); contentType = conn.getContentType(); } // Verify that content-type is the value set in the ServerInvocationHandler. log.debug("content-type: " + contentType); assertEquals(WebInvocationHandler.CONTENT_TYPE, contentType); } public void testGetInvocation() throws Exception { testGetInvocationSub(true); testGetInvocationSub(false); } protected void testGetInvocationSub(boolean raw) throws Exception { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(getLocatorURI()); log.debug("Calling remoting server with locator uri of: " + getLocatorURI()); remotingClient = new Client(locator); remotingClient.connect(); Map metadata = new HashMap(); if (raw) { metadata.put(Client.RAW, Boolean.TRUE); } metadata.put("TYPE", "GET"); Object response = null; // test with null return expected response = remotingClient.invoke((Object) null, metadata); log.debug("Response should be " + WebInvocationHandler.HTML_PAGE_RESPONSE + " and was: " + response); assertEquals(WebInvocationHandler.HTML_PAGE_RESPONSE, response); response = remotingClient.invoke((Object) null, metadata); log.debug("Response should be " + WebInvocationHandler.HTML_PAGE_RESPONSE + " and was: " + response); assertEquals(WebInvocationHandler.HTML_PAGE_RESPONSE, response); } catch (Throwable throwable) { throw new Exception(throwable); } finally { if (remotingClient != null) { remotingClient.disconnect(); } } } protected void addHeaders(Properties headerProps) { //NO OP - for overriding by sub-classes. } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/0000755000175000017500000000000011632407036031555 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/MBeanServerSelectionTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/MBeanServe0000644000175000017500000000747511413660476033512 0ustar twernertwerner/* * 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.transport.servlet; import java.util.HashMap; import java.util.Map; 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.InvokerLocator; import org.jboss.test.remoting.transport.web.WebInvocationHandler; /** * * Used to test JBREM-746. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Nov 29, 2007 *

          */ public abstract class MBeanServerSelectionTestParent extends TestCase { private static Logger log = Logger.getLogger(MBeanServerSelectionTestParent.class); private static boolean firstTime = true; protected String locatorURI; public void setUp() throws Exception { if (firstTime) { firstTime = false; Logger.getLogger("org.jboss.remoting").setLevel(XLevel.TRACE); 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 testMBeanServerSelection() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(new InvokerLocator(locatorURI), clientConfig); client.connect(); log.info("client is connected: " + locatorURI); // Test connections. assertEquals("abc", client.invoke("copy:abc")); log.info("connection is good"); // Verify ServletServerInvoker is using the platform MBeanServer. HashMap metadata = new HashMap(); metadata.put(WebInvocationHandler.DEFAULT_DOMAIN, getDefaultDomain()); Object o = client.invoke(WebInvocationHandler.CHECK_MBEAN_SERVER, metadata); Boolean response = (Boolean) o; assertTrue(response.booleanValue()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected abstract String getDefaultDomain(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer() throws Exception { locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet"; } protected void shutdownServer() throws Exception { } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/readme.txt0000644000175000017500000000417611166051307033561 0ustar twernertwernerThe servlet (and sslservlet) transport tests require a web container. Currently, these tests have to be run manually (JBREM-139 has been created to automate this). Until then, here are the instructions for running the tests manually. ******************************************************* ***** JBREM-139 is done. ***** ***** See tests.functional.servlet in build.xml. ***** ******************************************************* servlet 1. Get JBossAS and copy remoting's servlet-invoker.war (from distro or build) to the deploy directory. 2. Copy the WEB-INF/web.xml under this directory into the that of the servlet-invoker.war/WEB-INF directory. 3. Copy remoting-servlet-invoker-service.xml to deploy directory. 4. Copy jboss-remoting-tests.jar to server lib directory 5. Start web container (JBossAS). 6. Run *TestClient. To run MBeanServerPlatformTestClient, uncomment the "mbeanServer" init-param in web.xml. Also, run JBossAS with # Enable the jconsole agent locally with integration of the jboss MBeans JAVA_OPTS="$JAVA_OPTS -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl" JAVA_OPTS="$JAVA_OPTS -Djboss.platform.mbeanserver" JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote" added to run.bat or run.sh. See http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossMBeansInJConsole for more information. sslservlet 1. Steps 1-4 above, except use the WEB-INF/web.xml and remoting-servlet-invoker-service.xml that is under the servlet/ssl directory. 2. Copy the servlet/ssl/.keystore file to the server conf directory 3. Edit jboss-web.deployer/server.xml to enable ssl connector. It should look like following: 4. Start web container (JBossAS). 5. Run SSLServletInvokerTestClient or SSLServletClientAddressTestClient. ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ResponseCodeTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ResponseCo0000644000175000017500000000311710722220566033562 0ustar twernertwerner/* * 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.transport.servlet; import org.jboss.test.remoting.transport.http.headers.ResponseCodeTestCase; /** * Unit test for JBREM-728. * * @author Ron Sigal *

          * Copyright (c) November 24, 2007 *

          * */ public class ResponseCodeTestClient extends ResponseCodeTestCase { protected String getTransport() { return "servlet"; } protected void setupServer() { locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet"; port = 8080; } protected void shutdownServer() { } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ServletClientAddressTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ServletCli0000644000175000017500000000136410721116705033556 0ustar twernertwernerpackage org.jboss.test.remoting.transport.servlet; import java.net.InetAddress; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class ServletClientAddressTestClient extends ClientAddressTestParent { protected String getTransport() { return "servlet"; } protected String getCallbackTransport() { return "socket"; } protected void setupServer() { locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet"; port = 8080; } protected String reconstructLocator(InetAddress address) { return "servlet://" + address.getHostAddress() + ":8080/servlet-invoker/ServerInvokerServlet"; } protected void shutdownServer() { } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/0000755000175000017500000000000011632407036033311 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/r0000644000175000017500000000152711413660476033510 0ustar twernertwerner servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?createUniqueObjectName=true&useAllParams=true&blockingMode=blocking org.jboss.test.remoting.transport.servlet.callback.TestInvocationHandler ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/CallbackTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/C0000644000175000017500000001104411413660476033424 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, 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.transport.servlet.callback; import java.util.HashMap; 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.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; /** * Unit test for pull callbacks over servlet transport: JBREM-1079. * * @author Ron Sigal * @version *

          * Copyright Jan 16, 2009 *

          */ public class CallbackTestClient extends TestCase { private static Logger log = Logger.getLogger(CallbackTestClient.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 testMethod() throws Throwable { log.info("entering " + getName()); // Create client. locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet"; locatorURI += "/?createUniqueObjectName=true&useAllParams=true&blockingMode=blocking"; InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); Client client = new Client(clientLocator, clientConfig); client.connect(); log.info("client is connected"); // Test connection. log.info("result: " + client.invoke("abc")); assertEquals(null, client.invoke("abc")); log.info("connection is good"); // Install client side callback handlers. TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); HashMap metadata = new HashMap(); client.addListener(callbackHandler1, metadata); client.addListener(callbackHandler2, metadata); // Request callbacks. int COUNT = 100; for (int i = 0; i < COUNT; i++) { client.invoke("callback"); } log.info("sleeping for 2000 ms"); Thread.sleep(2000); log.info("waking up"); // Verify all callbacks arrived. assertEquals(COUNT, callbackHandler1.counter); assertEquals(COUNT, callbackHandler1.counter); client.removeListener(callbackHandler1); client.removeListener(callbackHandler2); client.disconnect(); log.info(getName() + " PASSES"); } static class TestCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/W0000755000175000017500000000000011632407036033440 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/W0000644000175000017500000000240211413660476033446 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?createUniqueObjectName=true&useAllParams=true&blockingMode=blocking The servlet server invoker locator url 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/TestInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/callback/T0000644000175000017500000000503211413660476033445 0ustar twernertwerner/* * JBoss, Home of Professional Open Source. * Copyright 2008, 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.transport.servlet.callback; import java.util.HashSet; import java.util.Iterator; import javax.management.MBeanServer; 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.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; public class TestInvocationHandler implements ServerInvocationHandler { private static Logger log = Logger.getLogger(TestInvocationHandler.class); private HashSet listeners = new HashSet(); public void addListener(InvokerCallbackHandler callbackHandler) { listeners.add(callbackHandler); log.info("added " + callbackHandler); } public Object invoke(InvocationRequest invocation) throws Throwable { log.debug("invocation: " + invocation.getParameter()); Iterator it = listeners.iterator(); Callback callback = new Callback("callback"); while (it.hasNext()) { InvokerCallbackHandler handler = (InvokerCallbackHandler) it.next(); handler.handleCallback(callback); log.debug("sent callback to " + handler); } return null; } public void removeListener(InvokerCallbackHandler callbackHandler) { listeners.remove(callbackHandler); log.info("removed " + callbackHandler); } public void setInvoker(ServerInvoker invoker) { } public void setMBeanServer(MBeanServer server) { } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000755000175000017500000000000011632407036033625 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/jboss/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000755000175000017500000000000011632407036033625 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/jboss/MBeanServerJBossTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000644000175000017500000000267411413660476033646 0ustar twernertwerner /* * 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.transport.servlet.mbeanserver.jboss; import org.jboss.test.remoting.transport.servlet.MBeanServerSelectionTestParent; /** * Used to test JBREM-746. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Nov 29, 2007 *

          */ public class MBeanServerJBossTestClient extends MBeanServerSelectionTestParent { protected String getDefaultDomain() { return "jboss"; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/jboss/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000755000175000017500000000000011632407036033625 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/jboss/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000644000175000017500000000261511413660476033641 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet invokerName jboss.remoting:host=localhost,port=8080,service=invoker,transport=servlet The servlet server invoker 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/platform/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000755000175000017500000000000011632407036033625 5ustar twernertwerner././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/platform/MBeanServerPlatformTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000644000175000017500000000271111413660476033636 0ustar twernertwerner /* * 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.transport.servlet.mbeanserver.platform; import org.jboss.test.remoting.transport.servlet.MBeanServerSelectionTestParent; /** * * Used to test JBREM-746. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Nov 29, 2007 *

          */ public class MBeanServerPlatformTestClient extends MBeanServerSelectionTestParent { protected String getDefaultDomain() { return "platform"; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/platform/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000755000175000017500000000000011632407036033625 5ustar twernertwerner././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserver/platform/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/mbeanserve0000644000175000017500000000261011413660476033634 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet invokerName jboss.remoting:host=localhost,port=8080,service=invoker,transport=servlet The servlet server invoker mbeanServer *platform* The servlet server invoker 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreservelines/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreserve0000755000175000017500000000000011632407036033666 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreservelines/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreserve0000644000175000017500000000321211413660476033674 0ustar twernertwernerThe servlet (and sslservlet) transport tests require a web container. Currently, these tests have to be run manually (JBREM-139 has been created to automate this). Until then, here are the instructions for running the tests manually. ******************************************************* ***** JBREM-139 is done. ***** ***** See tests.functional.servlet in build.xml. ***** ******************************************************* servlet 1. Get JBossAS and copy remoting's servlet-invoker.war (from distro or build) to the deploy directory. 2. Copy the WEB-INF/web.xml under this directory into the that of the servlet-invoker.war/WEB-INF directory. 3. Copy remoting-servlet-invoker-service.xml to deploy directory. 4. Copy jboss-remoting-tests.jar to server lib directory 5. Start web container (JBossAS). 6. Run ServletLinePreservationTestClient. sslservlet 1. Steps 1-4 above, except use the WEB-INF/web.xml and remoting-servlet-invoker-service.xml that is under the servlet/ssl directory. 2. Copy the servlet/ssl/.keystore file to the server conf directory 3. Edit jboss-web.deployer/server.xml to enable ssl connector. It should look like following: 4. Start web container (JBossAS). 5. Run SSLServletInvokerTestClient or SSLServletClientAddressTestClient. ././@LongLink0000000000000000000000000000022300000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreservelines/ServletNoLinePreservationTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreserve0000644000175000017500000000350411413660476033700 0ustar twernertwerner/* * 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.transport.servlet.nopreservelines; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.transport.http.lines.HttpLinePreservationTestCase; /** * Unit tests for JBREM-809. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 8, 2008 *

          */ public class ServletNoLinePreservationTestClient extends HttpLinePreservationTestCase { protected String getTransport() { return "servlet"; } protected void setupServer(boolean addConfig, String preserveLines) throws Exception { locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet"; serverLocator = new InvokerLocator(locatorURI); } public void testLinePreservationClientConfig() {} public void testLinePreservationClientMetadata() {} }././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreservelines/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreserve0000644000175000017500000000155611413660476033705 0ustar twernertwerner localhost 8080 false servlet-invoker/ServerInvokerServlet org.jboss.test.remoting.transport.servlet.nopreservelines.TestInvocationHandler ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreservelines/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreserve0000755000175000017500000000000011632407036033666 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreservelines/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreserve0000644000175000017500000000226611413660476033704 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet invokerName jboss.remoting:host=localhost,port=8080,service=invoker,transport=servlet The servlet server invoker 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreservelines/TestInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/nopreserve0000644000175000017500000000355411413660476033705 0ustar twernertwerner/* * 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.transport.servlet.nopreservelines; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * For JBREM-809. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 8, 2008 *

          */ public 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) {} }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ServletInvokerNoExceptionTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ServletInv0000644000175000017500000000404610712234557033611 0ustar twernertwerner/* * 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.transport.servlet; import org.jboss.test.remoting.transport.web.WebInvokerTestClient; /** * This test is identical to ServletInvokerTestClient except that it, in the case * when an exception is thrown on the server, ServletServerInvoker is explicitly instructed * not to return the actual exception. * * See JBREM-813 and JBREM-675. * * @author Tom Elrod * @author Ron Sigal */ public class ServletInvokerNoExceptionTestClient extends WebInvokerTestClient { public static final Integer ERROR_RESPONSE_CODE = new Integer(500); public String getLocatorURI() { return "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?dont-return-exception=true"; } public static void main(String[] args) { ServletInvokerNoExceptionTestClient client = new ServletInvokerNoExceptionTestClient(); try { client.testPostInvocation(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttyp0000755000175000017500000000000011632407036033705 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerOK.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttyp0000644000175000017500000000454611413660476033726 0ustar twernertwerner/* * 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.transport.servlet.contenttype; import java.util.Map; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * For JBREM-1101 unit tests. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Sep 1, 2009 *

          */ public class TestInvocationHandlerOK implements ServerInvocationHandler { public static String CONTENT_TYPE = "test/testContentType"; public static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y"; public static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y"; public static String REQUEST = "testRequest"; public static String RESPONSE = "testResponse"; public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { Map response = invocation.getReturnPayload(); if (response != null) { response.put("Content-Type", CONTENT_TYPE); } return RESPONSE; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerCR.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttyp0000644000175000017500000000456111413660476033723 0ustar twernertwerner/* * 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.transport.servlet.contenttype; import java.util.Map; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * For JBREM-1101 unit tests. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Sep 1, 2009 *

          */ public class TestInvocationHandlerCR implements ServerInvocationHandler { public static String CONTENT_TYPE = "test/testContentType"; public static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y"; public static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y"; public static String REQUEST = "testRequest"; public static String RESPONSE = "testResponse"; public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { Map response = invocation.getReturnPayload(); if (response != null) { response.put("Content-Type", INVALID_CONTENT_TYPE_CR); } return RESPONSE; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerLF.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttyp0000644000175000017500000000456111413660476033723 0ustar twernertwerner/* * 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.transport.servlet.contenttype; import java.util.Map; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * For JBREM-1101 unit tests. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Sep 1, 2009 *

          */ public class TestInvocationHandlerLF implements ServerInvocationHandler { public static String CONTENT_TYPE = "test/testContentType"; public static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y"; public static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y"; public static String REQUEST = "testRequest"; public static String RESPONSE = "testResponse"; public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { Map response = invocation.getReturnPayload(); if (response != null) { response.put("Content-Type", INVALID_CONTENT_TYPE_CR); } return RESPONSE; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttyp0000644000175000017500000000437011413660476033721 0ustar twernertwerner servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=OK org.jboss.test.remoting.transport.servlet.contenttype.TestInvocationHandlerOK servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=CR org.jboss.test.remoting.transport.servlet.contenttype.TestInvocationHandlerCR servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=LF org.jboss.test.remoting.transport.servlet.contenttype.TestInvocationHandlerLF ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttyp0000644000175000017500000000400411413660476033713 0ustar twernertwerner/* * 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.transport.servlet.contenttype; import org.apache.log4j.Logger; import org.jboss.test.remoting.transport.http.contenttype.ContentTypeTestCase; /** * Unit tests for JBREM-1101. * * @author Ron Sigal * @version *

          * Copyright Sep 1, 2009 *

          */ public class ServletContentTypeTestClient extends ContentTypeTestCase { protected static Logger log = Logger.getLogger(ServletContentTypeTestClient.class); protected void setupServer(String contentType) throws Exception { locatorURI = "http://localhost:8080/servlet-invoker/ServerInvokerServlet"; if (CONTENT_TYPE.equals(contentType)) { locatorURI += "/OK"; } if (INVALID_CONTENT_TYPE_CR.equals(contentType)) { locatorURI += "/CR"; } else if (INVALID_CONTENT_TYPE_LF.equals(contentType)) { locatorURI += "/LF"; } log.info("setting InvokerLocator to " + locatorURI); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttyp0000755000175000017500000000000011632407036033705 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/contenttyp0000644000175000017500000000573711413660476033731 0ustar twernertwerner ServerInvokerServletOK The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=OK The servlet server invoker locator url 1 ServerInvokerServletCR The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=CR The servlet server invoker locator url 1 ServerInvokerServletLF The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=LF The servlet server invoker locator url 1 ServerInvokerServletOK /ServerInvokerServlet/OK/* ServerInvokerServletCR /ServerInvokerServlet/CR/* ServerInvokerServletLF /ServerInvokerServlet/LF/* ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/remoting-s0000644000175000017500000000135311166046506033571 0ustar twernertwerner servlet://localhost:8080/servlet-invoker/ServerInvokerServlet org.jboss.test.remoting.transport.web.WebInvocationHandler ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/0000755000175000017500000000000011632407036033560 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/0000644000175000017500000000236211413660476033573 0ustar twernertwernerThe servlet (and sslservlet) transport tests require a web container. Currently, these tests have to be run manually (JBREM-139 has been created to automate this). Until then, here are the instructions for running the tests manually. ******************************************************* ***** JBREM-139 is done. ***** ***** See tests.functional.servlet in build.xml. ***** ******************************************************* servlet 1. Get JBossAS and copy remoting's servlet-invoker.war (from distro or build) to the deploy directory. 2. Edit the InvokerLocator attribute in remoting-servlet-invoker-service.xml, using a suitable set of addresses. 3. Edit ServletMultihomeTestClient.setupServer(), using the same set of addresses in the InvokerLocator. 4. Edit server.xml, giving the Connectors used by ServletMultihomeTestCase the same set of addresses. 5. Copy the WEB-INF/web.xml under this directory into the that of the servlet-invoker.war/WEB-INF directory. 6. Copy remoting-servlet-invoker-service.xml to deploy directory. 7. Build jboss-remoting-tests.jar and copy it to server lib directory. 8. Copy server.xml to deploy/jboss-web.deployer. 9. Start web container (JBossAS). 10. Run ServletMultihomeTestClient. ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/0000644000175000017500000000142711413660476033574 0ustar twernertwerner servlet://multihome/servlet-invoker/ServerInvokerServlet/?homes=localhost:7071!localhost:7082!localhost:7093 org.jboss.test.remoting.multihome.TestInvocationHandler ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/0000755000175000017500000000000011632407036033560 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/0000644000175000017500000000226611413660476033576 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet invokerName jboss.remoting:service=invoker,transport=servlet,host=multihome,port=-1 The servlet server invoker 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/ServletMultihomeTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/multihome/0000644000175000017500000000404111413660476033567 0ustar twernertwerner /* * 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.transport.servlet.multihome; import java.util.Map; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.multihome.MultihomeTestParent; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jan 13, 2008 *

          */ public class ServletMultihomeTestClient extends MultihomeTestParent { protected String getTransport() { return "servlet"; } protected void setupServer() throws Exception { locatorURI = getTransport() + "://" + InvokerLocator.MULTIHOME + getPath() + "/?"; locatorURI += InvokerLocator.CONNECT_HOMES_KEY + "=localhost:7071!localhost:7082!localhost:7093"; serverLocator = new InvokerLocator(locatorURI); log.info("server locator: " + locatorURI); } protected String getPath() { return "/servlet-invoker/ServerInvokerServlet"; } protected void addExtraCallbackConfig(Map config) { config.put(Client.CALLBACK_SERVER_PROTOCOL, "http"); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preserveli0000755000175000017500000000000011632407036033656 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preserveli0000644000175000017500000000321211413660476033664 0ustar twernertwernerThe servlet (and sslservlet) transport tests require a web container. Currently, these tests have to be run manually (JBREM-139 has been created to automate this). Until then, here are the instructions for running the tests manually. ******************************************************* ***** JBREM-139 is done. ***** ***** See tests.functional.servlet in build.xml. ***** ******************************************************* servlet 1. Get JBossAS and copy remoting's servlet-invoker.war (from distro or build) to the deploy directory. 2. Copy the WEB-INF/web.xml under this directory into the that of the servlet-invoker.war/WEB-INF directory. 3. Copy remoting-servlet-invoker-service.xml to deploy directory. 4. Copy jboss-remoting-tests.jar to server lib directory 5. Start web container (JBossAS). 6. Run ServletLinePreservationTestClient. sslservlet 1. Steps 1-4 above, except use the WEB-INF/web.xml and remoting-servlet-invoker-service.xml that is under the servlet/ssl directory. 2. Copy the servlet/ssl/.keystore file to the server conf directory 3. Edit jboss-web.deployer/server.xml to enable ssl connector. It should look like following: 4. Start web container (JBossAS). 5. Run SSLServletInvokerTestClient or SSLServletClientAddressTestClient. ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preserveli0000644000175000017500000000155311413660476033672 0ustar twernertwerner localhost 8080 true servlet-invoker/ServerInvokerServlet org.jboss.test.remoting.transport.servlet.preservelines.TestInvocationHandler ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preserveli0000755000175000017500000000000011632407036033656 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preserveli0000644000175000017500000000226611413660476033674 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet invokerName jboss.remoting:host=localhost,port=8080,service=invoker,transport=servlet The servlet server invoker 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/TestInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preserveli0000644000175000017500000000355211413660476033673 0ustar twernertwerner/* * 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.transport.servlet.preservelines; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * For JBREM-809. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 8, 2008 *

          */ public 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) {} }././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/ServletLinePreservationTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/preserveli0000644000175000017500000000342311413660476033670 0ustar twernertwerner/* * 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.transport.servlet.preservelines; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.transport.http.lines.HttpLinePreservationTestCase; /** * Unit tests for JBREM-809. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 8, 2008 *

          */ public class ServletLinePreservationTestClient extends HttpLinePreservationTestCase { protected String getTransport() { return "servlet"; } protected void setupServer(boolean addConfig, String preserveLines) throws Exception { locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet"; serverLocator = new InvokerLocator(locatorURI); } public void testPreservationClientNoPreservationServer() {} }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/WEB-INF/0000755000175000017500000000000011632407036032604 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/WEB-INF/we0000644000175000017500000000261511413660476033154 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet invokerName jboss.remoting:host=localhost,port=8080,service=invoker,transport=servlet The servlet server invoker 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/server.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/server.xml0000644000175000017500000002211111413660476033610 0ustar twernertwerner libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/0000755000175000017500000000000011632407036032356 5ustar twernertwerner././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerExceptionTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLSer0000644000175000017500000000455011413660476033426 0ustar twernertwerner/* * 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.transport.servlet.ssl; import org.jboss.test.remoting.transport.web.WebInvokerTestClient; /** * This test is identical to ServletInvokerTestClient except that it, in the case * when an exception is thrown on the server, ServletServerInvoker is instructed * to return the actual exception. * * See JBREM-813. * * @author Tom Elrod * @author Ron Sigal */ public class SSLServletInvokerExceptionTestClient extends WebInvokerTestClient { public static final Integer ERROR_RESPONSE_CODE = new Integer(500); public String getLocatorURI() { // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); return "sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet"; //return "http://localhost:8080/servlet-invoker/ServerInvokerServlet"; } public static void main(String[] args) { SSLServletInvokerExceptionTestClient client = new SSLServletInvokerExceptionTestClient(); try { client.testPostInvocation(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/key.pemlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/key.pe0000644000175000017500000000321711413660476033505 0ustar twernertwerner-----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEAyaG+QNelum8cel3100Ibu7haTEum4wNYn9tEvkXG1dn8F9AT /ax4+RnvmTZ2gW0kKjQ+28pHI1gjE9WSYdZx/ypI9BcOtiwcJUqM+e7JNH9JHCVJ TL3k8D22GOlctUrie9jbgBHxfApjJaI6V47ZIRXOFK9OXV0Ud+Vbsoe34LIMAddK Acc7lT9Mi9D6fIo50SZ1zd4lM6xUJX5/LpokmPHQ/ONUNP0Tz793EzZqBjyc9kPg nsZfq4UCSB4By4OCjsFctsQECc6DC6PFnI9Edz1pVdxlrK2Yee2OMCEMHe4PLF7h dM7nBJFZGEnXGl9T2XOaXvX1+OtzHanYGpG/1wIDAQABAoIBAQChJldjhbccMU/G cTBW/0AhIW9yCQjB6Vu8r8fadvQ62PUFpzVDCsTI+rSndIL0YGGGJamTirCejAPF B23uKjGEKayTAZatfMWl/FZ+Lx26inzJNPfHkQHYDMpsUJ7a+pXXO/P7ANxLMhYZ 7vXIIxBgxAeoOpBcSFdil/pYzuXke5u66LuT9fSpc1btx3Md4FYMjelhubNbr4+U rVH428968z3MpeZZCDlxgVwyO5nJuIpNLgrB5xA0UJTdgxW6mIUbbGQLdxPBXKbD 2MehmKWOpO5eEsr2IijHtAZerJf4cSoBMsjjke4GNVBRdyiAaK8pugomsGSf2HUd pvu7rXgBAoGBAPxBa74wvNlV+YQ7+PwDbyoNOmKjg/0xdG7AKrqVA/wK5kLXUFmP eJgQTgJsSZZhHgY/eKWot9zvmHCy6FanjvLwDWaUzRrEL8+Pr7QiuIn2/lkJfltH 0PRTiH/aopkgy9HJLS/6gwzK4Fd02uOXBRo4h9ypVnNT9yPFqvJYWVwBAoGBAMyf 81J5Ot1B7S0KsHR9JTpUqNGkH2newB9wJMWcW9q0KewYDpF0Rgs4ax4764+PqXX0 bYnByUZDv10dlaRtONDWofBqQRZIhCWeVX9R1Cbuv9LX6wYh6vY9hyzKBpTJDqiR Tasr0b8KaJYe0JuNARb9O+9cyTplloyXwIbcUXvXAoGAW4vCdjtpzdYNv5ekPJFi fnhef/2noPOZtbe3yg7aa1XpSsipOFeBBG6mYOq7qf+Eze+q8TPRxjSNthi3iPs2 PaQwuNG3vccFMuaKdW1EW41vsRBo8ueVRZYrK3tFFx132qKP66GWfcYCtLqL1Zyx FVr+s24hGamXPzw1Vc4KYAECgYBj41DsWbGagKw+6JDqzIx3xQwECpIrJEm1DxFk RcexI3GzhqrV5mSq5Yek4qtDEWYv5nnyXV7bpgasddyuv4KUr7GtorDTJ+MaWghy doeR2cpaKnzYKYaBXde2zYgY6Wz2bLf1bxaco4AaiEBdLp/xkPzJBApXL3AmgY3C R5qfUQKBgQD4sCNRpfRCPE8LeDR+rAEAD3PZpWCtdEdyKMK+VwPeQbdWZFrk67j0 vL34WwXx+akcX2RFt8bpexFzJDQVAUDqC7ODrXsPoyKugtvSQc7Qi4ZIfavTeNtH XIo19uMz4Ips/NbpFwIgccHe5M812lAB8MfVhgMJ8aQxiXwuHkn9rw== -----END RSA PRIVATE KEY----- ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/cert.pemlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/cert.p0000644000175000017500000000316311413660476033505 0ustar twernertwerner-----BEGIN CERTIFICATE----- MIIElTCCA32gAwIBAgIJAPhG0v99Wy3zMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYD VQQGEwJVUzERMA8GA1UECBMITmV3IFlvcmsxETAPBgNVBAcTCEtpbmdzdG9uMRAw DgYDVQQKEwdSZWQgSGF0MQ4wDAYDVQQLEwVKQm9zczESMBAGA1UEAxMJUm9uIFNp Z2FsMSIwIAYJKoZIhvcNAQkBFhNyb24uc2lnYWxAamJvc3MuY29tMB4XDTA3MTIw ODE5NTEwMFoXDTE3MTIwNTE5NTEwMFowgY0xCzAJBgNVBAYTAlVTMREwDwYDVQQI EwhOZXcgWW9yazERMA8GA1UEBxMIS2luZ3N0b24xEDAOBgNVBAoTB1JlZCBIYXQx DjAMBgNVBAsTBUpCb3NzMRIwEAYDVQQDEwlSb24gU2lnYWwxIjAgBgkqhkiG9w0B CQEWE3Jvbi5zaWdhbEBqYm9zcy5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw ggEKAoIBAQDJob5A16W6bxx6XfXTQhu7uFpMS6bjA1if20S+RcbV2fwX0BP9rHj5 Ge+ZNnaBbSQqND7bykcjWCMT1ZJh1nH/Kkj0Fw62LBwlSoz57sk0f0kcJUlMveTw PbYY6Vy1SuJ72NuAEfF8CmMlojpXjtkhFc4Ur05dXRR35Vuyh7fgsgwB10oBxzuV P0yL0Pp8ijnRJnXN3iUzrFQlfn8umiSY8dD841Q0/RPPv3cTNmoGPJz2Q+Cexl+r hQJIHgHLg4KOwVy2xAQJzoMLo8Wcj0R3PWlV3GWsrZh57Y4wIQwd7g8sXuF0zucE kVkYSdcaX1PZc5pe9fX463Mdqdgakb/XAgMBAAGjgfUwgfIwHQYDVR0OBBYEFN+M 7t4JkzOTGoIy/kMzexQq3Q/sMIHCBgNVHSMEgbowgbeAFN+M7t4JkzOTGoIy/kMz exQq3Q/soYGTpIGQMIGNMQswCQYDVQQGEwJVUzERMA8GA1UECBMITmV3IFlvcmsx ETAPBgNVBAcTCEtpbmdzdG9uMRAwDgYDVQQKEwdSZWQgSGF0MQ4wDAYDVQQLEwVK Qm9zczESMBAGA1UEAxMJUm9uIFNpZ2FsMSIwIAYJKoZIhvcNAQkBFhNyb24uc2ln YWxAamJvc3MuY29tggkA+EbS/31bLfMwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B AQUFAAOCAQEAofqIsXgRe9IpK+o2GBk0R3iLgNaCh5y87/lLINVJEGegb3+80BEy AADXYjvCh7v33ieeIw7UfUTvhFwZoAQqMjOI3nBbW/r4ul8BnxVkXNl5+1QqB5O6 1KyC3cgh3uEaBW2EwotHiyHW9XSQbgHDPnX/YB2freGipC9oF7Ox3uYZ3bZFb5j1 p/R7x/vkM/ho9rw0Inl2jCNghzrRznCnSf3rxezDRoTBoYirIYl55C+SUyvcC1E8 pHQ3mY9BXy0g1B9dpmFY7zCir3WnsBovs4qKGPfsHDsdhQl6LRf/EgDf0ISvxqhJ K3KOozBADRcRPUeFpwy/EVKeT0PCIFQufQ== -----END CERTIFICATE----- ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/keystorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/keysto0000644000175000017500000001376111166047670033635 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletClientAddressTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLSer0000644000175000017500000000313111166050065033410 0ustar twernertwernerpackage org.jboss.test.remoting.transport.servlet.ssl; import java.net.InetAddress; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.clientaddress.ClientAddressTestParent; public class SSLServletClientAddressTestClient extends ClientAddressTestParent { protected String getTransport() { return "sslservlet"; } protected String getCallbackTransport() { return "socket"; } protected void addExtraServerConfig(Map config) { 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"); } protected void addExtraClientConfig(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"); } protected void setupServer() { locatorURI = "sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet"; port = 8443; } protected String reconstructLocator(InetAddress address) { return "sslservlet://" + address.getHostAddress() + ":8443/servlet-invoker/ServerInvokerServlet"; } protected void shutdownServer() { } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLServletInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/SSLSer0000644000175000017500000000211611166050065033412 0ustar twernertwernerpackage org.jboss.test.remoting.transport.servlet.ssl; import org.jboss.test.remoting.transport.web.WebInvokerTestClient; /** * @author Tom Elrod */ public class SSLServletInvokerTestClient extends WebInvokerTestClient { public static final Integer ERROR_RESPONSE_CODE = new Integer(500); public String getLocatorURI() { // since doing basic (using default ssl server socket factory) // need to set the system properties to the truststore String trustStoreFilePath = this.getClass().getResource("truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); return "sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet"; //return "http://localhost:8080/servlet-invoker/ServerInvokerServlet"; } public static void main(String[] args) { SSLServletInvokerTestClient client = new SSLServletInvokerTestClient(); try { client.testPostInvocation(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/trusts0000644000175000017500000000701311166047670033654 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoti0000644000175000017500000000136511166047712033610 0ustar twernertwerner sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet org.jboss.test.remoting.transport.web.WebInvocationHandler ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/multihome/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/multih0000755000175000017500000000000011632407036033601 5ustar twernertwerner././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/multihome/SSLServletMultihomeTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/multih0000644000175000017500000000553211413660476033616 0ustar twernertwerner /* * 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.transport.servlet.ssl.multihome; import java.util.Map; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.test.remoting.transport.socket.multihome.SocketMultihomeTestCase; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jan 13, 2008 *

          */ public class SSLServletMultihomeTestClient extends SocketMultihomeTestCase { protected String getTransport() { return "sslservlets"; } protected void addExtraServerConfig(Map config) { super.addExtraServerConfig(config); 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"); } protected void addExtraClientConfig(Map config) { super.addExtraClientConfig(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"); } protected void addExtraCallbackConfig(Map config) { super.addExtraCallbackConfig(config); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); 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"); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/cert.derlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/cert.d0000644000175000017500000000223110743037312033454 0ustar twernertwerner0‚•0‚}  øFÒÿ}[-ó0  *†H†÷ 0??1 0 UUS10UNew York10UKingston10U Red Hat10 U JBoss10U Ron Sigal1"0  *†H†÷  ron.sigal@jboss.com0 071208195100Z 171205195100Z0??1 0 UUS10UNew York10UKingston10U Red Hat10 U JBoss10U Ron Sigal1"0  *†H†÷  ron.sigal@jboss.com0‚"0  *†H†÷ ‚0‚ ‚É¡¾@×¥ºoz]õÓB»¸ZLK¦ãXŸÛD¾EÆÕÙüÐý¬xùï™6v?m$*4>ÛÊG#X#Õ’aÖqÿ*Hô¶,%JŒùîÉ4I%IL½äð=¶é\µJâ{ØÛ€ñ| c%¢:WŽÙ!ίN]]wå[²‡·à² ×JÇ;•?L‹Ðú|Š9Ñ&uÍÞ%3¬T%~.š$˜ñÐüãT4ýÏ¿w6j<œöCàžÆ_«…H˃‚ŽÁ\¶Ä ΃ £Åœ?Dw=iUÜe¬­˜yíŽ0! î,^átÎç‘YI×_SÙsš^õõøës©Ø‘¿×£?õ0?ò0UߌîÞ “3“‚2þC3{*Ýì0?ÂU#?º0?·€ߌîÞ “3“‚2þC3{*Ýì¡?“¤??0??1 0 UUS10UNew York10UKingston10U Red Hat10 U JBoss10U Ron Sigal1"0  *†H†÷  ron.sigal@jboss.com‚ øFÒÿ}[-ó0 U0ÿ0  *†H†÷ ‚¡úˆ±x{Ò)+ê64Gx‹€Ö‚‡œ¼ïùK ÕIg o¼Ð2×b;‡»÷Þ'ž#Ô}Dï„\ *23ˆÞp[[úøº_Ÿd\ÙyûT*“ºÔ¬‚ÝÈ!Þám„‹G‹!Öõt?nÃ>uÿ`Ÿ­á¢¤/h³±ÞæݶEo˜õ§ô{Çûä3øhö¼4"yvŒ#`‡:ÑÎp§IýëÅìÃF„Á¡ˆ«!‰yä/’S+Ü Q<¤t7™?A_- Ô]¦aXï0¢¯u§°/³ŠŠ÷ì;… z-ÿßЄ¯Æ¨I+rŽ£0@ =G…§ ¿RžOC T.}././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-IN0000755000175000017500000000000011632407036033220 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-IN0000644000175000017500000000263110456602664033233 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet The servlet server invoker locator url 1 ServerInvokerServlet /ServerInvokerServlet/* libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/0000755000175000017500000000000011632407036033204 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/ContentTypeTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/Co0000644000175000017500000001424111413660476033500 0ustar twernertwerner/* * 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.transport.servlet.marshal; import java.util.HashMap; import java.util.Map; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.test.remoting.transport.http.marshal.HttpContentTypeTestCase; /** * Unit tests for JBREM-1145. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright August 17, 2009 *

          */ public class ContentTypeTestClient extends HttpContentTypeTestCase { private static Logger log = Logger.getLogger(ContentTypeTestClient.class); protected void validateOrdinaryInvocation(Client client) throws Throwable { // Local tests log.info("TestMarshaller.marshallers.size(): " + TestMarshaller.marshallers.size()); log.info("TestMarshaller.unmarshallers.size(): " + TestUnMarshaller.unmarshallers.size()); assertEquals(2, TestMarshaller.marshallers.size()); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(1)).type); assertEquals(2, TestUnMarshaller.unmarshallers.size()); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type); // Remote tests int serverMarshallerCount = ((Integer) client.invoke(TestInvocationHandler.GET_NUMBER_OF_MARSHALLERS)).intValue(); log.info("server side marshallers: " + serverMarshallerCount); int serverUnmarshallerCount = ((Integer) client.invoke(TestInvocationHandler.GET_NUMBER_OF_UNMARSHALLERS)).intValue(); log.info("server side unmarshallers: " + serverUnmarshallerCount); Map metadata = new HashMap(); metadata.put(TestInvocationHandler.N, Integer.toString(serverMarshallerCount - 1)); String type = (String) client.invoke(TestInvocationHandler.GET_NTH_MARSHALLER_TYPE, metadata); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, type); metadata.put(TestInvocationHandler.N, Integer.toString(serverUnmarshallerCount - 1)); type = (String) client.invoke(TestInvocationHandler.GET_NTH_UNMARSHALLER_TYPE, metadata); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, type); client.invoke(TestInvocationHandler.RESET); } protected void validateRawStringMessage(Client client) throws Throwable { // Local tests log.info("TestMarshaller.marshallers.size(): " + TestMarshaller.marshallers.size()); log.info("TestMarshaller.unmarshallers.size(): " + TestUnMarshaller.unmarshallers.size()); assertEquals(2, TestMarshaller.marshallers.size()); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(1)).type); assertEquals(2, TestUnMarshaller.unmarshallers.size()); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type); // Remote tests int serverMarshallerCount = ((Integer) client.invoke(TestInvocationHandler.GET_NUMBER_OF_MARSHALLERS)).intValue(); log.info("server side marshallers: " + serverMarshallerCount); int serverUnmarshallerCount = ((Integer) client.invoke(TestInvocationHandler.GET_NUMBER_OF_UNMARSHALLERS)).intValue(); log.info("server side unmarshallers: " + serverUnmarshallerCount); assertEquals(4, serverMarshallerCount); assertEquals(6, serverUnmarshallerCount); Map metadata = new HashMap(); metadata.put(TestInvocationHandler.N, "3"); String type = (String) client.invoke(TestInvocationHandler.GET_NTH_MARSHALLER_TYPE, metadata); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, type); metadata.put(TestInvocationHandler.N, "1"); type = (String) client.invoke(TestInvocationHandler.GET_NTH_UNMARSHALLER_TYPE, metadata); assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, type); client.invoke(TestInvocationHandler.RESET); } protected String getTransport() { return "servlet"; } protected void setupServer(boolean addUseRemotingContentType, boolean useRemotingContentType) throws Exception { String path = null; String useRemotingContentTypeAttribute = null; if (addUseRemotingContentType) { if (useRemotingContentType) { path = "servlet-invoker/ServerInvokerServlet/true"; useRemotingContentTypeAttribute = "&useRemotingContentType=true"; } else { path = "servlet-invoker/ServerInvokerServlet/false"; useRemotingContentTypeAttribute = "&useRemotingContentType=false"; } } else { path = "servlet-invoker/ServerInvokerServlet/default"; useRemotingContentTypeAttribute = ""; } String locatorURI = "servlet://localhost:8080/" + path + "/?datatype=test&marshaller=org.jboss.test.remoting.marshall.TestMarshaller&unmarshaller=org.jboss.test.remoting.marshall.TestUnmarshaller" + useRemotingContentTypeAttribute; serverLocator = new InvokerLocator(locatorURI); } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/TestMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/Te0000644000175000017500000000456411413660476033516 0ustar twernertwerner/* * 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.transport.servlet.marshal; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import org.jboss.logging.Logger; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.remoting.transport.http.HTTPMetadataConstants; /** * Part of unit tests for JBREM-1145 * * @author Ron Sigal * @version $Rev$ *

          * Copyright Aug 20, 2009 *

          */ public class TestMarshaller extends HTTPMarshaller { private static Logger log = Logger.getLogger(TestMarshaller.class); public static ArrayList marshallers = new ArrayList(); private static final long serialVersionUID = -7528137229006015488L; public String type; public void write(Object dataObject, OutputStream output, int version) throws IOException { log.info(this + " writing " + dataObject); type = (dataObject instanceof String) ? HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING : HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING; super.write(dataObject, output, version); } public Marshaller cloneMarshaller() throws CloneNotSupportedException { TestMarshaller marshaller = new TestMarshaller(); marshallers.add(marshaller); log.info("returning " + marshaller); return marshaller; } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/config/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/co0000755000175000017500000000000011632407036033526 5ustar twernertwerner././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/config/ServletConfigurationMapTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/co0000644000175000017500000000543011413660476033540 0ustar twernertwerner/* * 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.transport.servlet.marshal.config; import java.util.Map; import org.apache.log4j.Logger; import org.jboss.test.remoting.marshall.config.ConfigurationMapTestParent; /** * Unit tests for JBREM-1102. * * @author Ron Sigal * @version *

          * Copyright Mar 21, 2009 *

          */ public class ServletConfigurationMapTestClient extends ConfigurationMapTestParent { protected static Logger log = Logger.getLogger(ServletConfigurationMapTestClient.class); public void testDatatypeConfigDefault() throws Throwable { log.info("skipping " + getName()); } public void testDatatypePassConfigMapFalse() throws Throwable { log.info("skipping " + getName()); } public void testFQNConfigDefault() throws Throwable { log.info("skipping " + getName()); } public void testFQNPassConfigMapFalse() throws Throwable { log.info("skipping " + getName()); } protected int marshallerCountDatatype() { return 2; } protected int unmarshallerCountDatatype() { return 2; } protected int marshallerCountFQN() { return 1; } protected int unmarshallerCountFQN() { return 1; } protected String getTransport() { return "servlet"; } protected void setupServer(String parameter, Map extraConfig) throws Exception { locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?" + parameter; // "marshaller=org.jboss.test.remoting.marshall.config.ConfigTestMarshaller&" + // "unmarshaller=org.jboss.test.remoting.marshall.config.ConfigTestUnmarshaller"; log.info("setting InvokerLocator to " + locatorURI); } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/config/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/co0000644000175000017500000000163011413660476033536 0ustar twernertwerner servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?marshaller=org.jboss.test.remoting.marshall.config.ConfigTestMarshaller&unmarshaller=org.jboss.test.remoting.marshall.config.ConfigTestUnmarshaller org.jboss.test.remoting.marshall.config.TestInvocationHandler ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/config/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/co0000755000175000017500000000000011632407036033526 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/config/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/co0000644000175000017500000000252011413660476033535 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?marshaller=org.jboss.test.remoting.marshall.config.ConfigTestMarshaller&unmarshaller=org.jboss.test.remoting.marshall.config.ConfigTestUnmarshaller The servlet server invoker locator url 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/re0000644000175000017500000000711011413660476033542 0ustar twernertwerner 127.0.0.1 8080 servlet-invoker/ServerInvokerServlet/default test org.jboss.test.remoting.transport.servlet.marshal.TestMarshaller org.jboss.test.remoting.transport.servlet.marshal.TestUnMarshaller org.jboss.test.remoting.transport.servlet.marshal.TestInvocationHandler 127.0.0.1 8080 servlet-invoker/ServerInvokerServlet/false test org.jboss.test.remoting.transport.servlet.marshal.TestMarshaller org.jboss.test.remoting.transport.servlet.marshal.TestUnMarshaller false org.jboss.test.remoting.transport.servlet.marshal.TestInvocationHandler 127.0.0.1 8080 servlet-invoker/ServerInvokerServlet/true test org.jboss.test.remoting.transport.servlet.marshal.TestMarshaller org.jboss.test.remoting.transport.servlet.marshal.TestUnMarshaller true org.jboss.test.remoting.transport.servlet.marshal.TestInvocationHandler ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/TestUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/Te0000644000175000017500000000575711413660476033523 0ustar twernertwerner/* * 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.transport.servlet.marshal; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.transport.http.HTTPMetadataConstants; /** * Part of unit tests for JBREM-1145. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Aug 20, 2009 *

          */ public class TestUnMarshaller extends HTTPUnMarshaller { public static ArrayList unmarshallers = new ArrayList(); private static final long serialVersionUID = -6422222480047910351L; public String type; public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE); if (o instanceof List) { type = (String) ((List) o).get(0); } else if (o instanceof String) { type = (String) o; } else { o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_LC); log.info("remotingcontenttype: " + o); if (o instanceof List) { type = (String) ((List) o).get(0); } else if (o instanceof String) { type = (String) o; } else { log.warn(this + " unrecognized remotingContentType: " + o); } } o = super.read(inputStream, metadata, version); log.info(this + " read " + o); return o; } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { TestUnMarshaller unmarshaller = new TestUnMarshaller(); unmarshallers.add(unmarshaller); unmarshaller.setClassLoader(this.customClassLoader); log.info("returning " + unmarshaller, new Exception()); return unmarshaller; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/noconfig/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/no0000755000175000017500000000000011632407036033541 5ustar twernertwerner././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/noconfig/ServletConfigurationMapTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/no0000644000175000017500000000531111413660476033551 0ustar twernertwerner/* * 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.transport.servlet.marshal.noconfig; import java.util.Map; import org.apache.log4j.Logger; import org.jboss.test.remoting.marshall.config.ConfigurationMapTestParent; /** * Unit tests for JBREM-1102. * * @author Ron Sigal * @version *

          * Copyright Mar 21, 2009 *

          */ public class ServletConfigurationMapTestClient extends ConfigurationMapTestParent { protected static Logger log = Logger.getLogger(ServletConfigurationMapTestClient.class); public void testDatatypePassConfigMapTrue() throws Throwable { log.info("skipping " + getName()); } public void testFQNConfigPassConfigMapTrue() throws Throwable { log.info("skipping " + getName()); } protected int marshallerCountDatatype() { return 2; } protected int unmarshallerCountDatatype() { return 2; } protected int marshallerCountFQN() { return 1; } protected int unmarshallerCountFQN() { return 1; } protected int marshallerDatatypeUnused() { return 0; } protected int marshallerFQNUnused() { return 0; } protected String getTransport() { return "servlet"; } protected void setupServer(String parameter, Map extraConfig) throws Exception { locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?" + parameter; // "marshaller=org.jboss.test.remoting.marshall.config.ConfigTestMarshaller&" + // "unmarshaller=org.jboss.test.remoting.marshall.config.ConfigTestUnmarshaller"; log.info("setting InvokerLocator to " + locatorURI); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/noconfig/remoting-servlet-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/no0000644000175000017500000000137711413660476033561 0ustar twernertwerner servlet://localhost:8080/servlet-invoker/ServerInvokerServlet org.jboss.test.remoting.marshall.config.TestInvocationHandler ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/noconfig/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/no0000755000175000017500000000000011632407036033541 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/noconfig/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/no0000644000175000017500000000226711413660476033560 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://localhost:8080/servlet-invoker/ServerInvokerServlet The servlet server invoker locator url 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/WE0000755000175000017500000000000011632407036033440 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/WE0000644000175000017500000000706711413660476033462 0ustar twernertwerner ServerInvokerServletDefault The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://127.0.0.1:8080/servlet-invoker/ServerInvokerServlet/default/?datatype=test&marshaller=org.jboss.test.remoting.transport.servlet.marshal.TestMarshaller&unmarshaller=org.jboss.test.remoting.transport.servlet.marshal.TestUnmarshaller The servlet server invoker locator url 1 ServerInvokerServletFalse The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://127.0.0.1:8080/servlet-invoker/ServerInvokerServlet/false/?datatype=test&marshaller=org.jboss.test.remoting.transport.servlet.marshal.TestMarshaller&unmarshaller=org.jboss.test.remoting.transport.servlet.marshal.TestUnmarshaller&useRemotingContentType=false The servlet server invoker locator url 1 ServerInvokerServletTrue The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet locatorUrl servlet://127.0.0.1:8080/servlet-invoker/ServerInvokerServlet/true/?datatype=test&marshaller=org.jboss.test.remoting.transport.servlet.marshal.TestMarshaller&unmarshaller=org.jboss.test.remoting.transport.servlet.marshal.TestUnmarshaller&useRemotingContentType=true The servlet server invoker locator url 1 ServerInvokerServletDefault /ServerInvokerServlet/default/* ServerInvokerServletFalse /ServerInvokerServlet/false/* ServerInvokerServletTrue /ServerInvokerServlet/true/* ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/TestInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/marshal/Te0000644000175000017500000001021211413660476033501 0ustar twernertwerner/* * 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.transport.servlet.marshal; import java.util.HashMap; import java.util.Map; 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.marshal.MarshalFactory; import org.jboss.remoting.transport.http.HTTPMetadataConstants; /** * For JBREM-1145. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright August 17, 2009 *

          */ public class TestInvocationHandler implements ServerInvocationHandler { public static String GET_NUMBER_OF_MARSHALLERS = "getNumberOfMarshallers"; public static String GET_NUMBER_OF_UNMARSHALLERS = "getNumberOfUnmarshallers"; public static String GET_NTH_MARSHALLER_TYPE = "getNthMarshallerType"; public static String GET_NTH_UNMARSHALLER_TYPE = "getNthUnarshallerType"; public static String RESET = "reset"; public static String N = "n"; private static Logger log = Logger.getLogger(TestInvocationHandler.class); static { MarshalFactory.addMarshaller("test", new TestMarshaller(), new TestUnMarshaller()); } public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { String s = (String) invocation.getParameter(); log.info("command: " + s); if (RESET.equals(s)) { log.info("doing reset"); TestMarshaller.marshallers.clear(); TestUnMarshaller.unmarshallers.clear(); log.info("TestMarshaller.marshallers: " + TestMarshaller.marshallers); log.info("TestUnMarshaller.unmarshallers: " + TestUnMarshaller.unmarshallers); } else if (GET_NUMBER_OF_MARSHALLERS.equals(s)) { return new Integer(TestMarshaller.marshallers.size()); } else if (GET_NUMBER_OF_UNMARSHALLERS.equals(s)) { return new Integer(TestUnMarshaller.unmarshallers.size()); } else if (GET_NTH_MARSHALLER_TYPE.equals(s)) { int n = Integer.valueOf((String)invocation.getRequestPayload().get(N)).intValue(); return ((TestMarshaller)TestMarshaller.marshallers.get(n)).type; } else if (GET_NTH_UNMARSHALLER_TYPE.equals(s)) { int n = Integer.valueOf((String)invocation.getRequestPayload().get(N)).intValue(); return ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(n)).type; } else if ("abc".equals(s)) { Map responseMap = invocation.getReturnPayload(); if (responseMap == null) { responseMap = new HashMap(); invocation.setReturnPayload(responseMap); } responseMap.put(HTTPMetadataConstants.CONTENTTYPE, "text/html"); return invocation.getParameter(); } return invocation.getParameter(); } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ServletInvokerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ServletInv0000644000175000017500000000337310456613751033615 0ustar twernertwerner/* * 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.transport.servlet; import org.jboss.test.remoting.transport.web.WebInvokerTestClient; /** * @author Tom Elrod */ public class ServletInvokerTestClient extends WebInvokerTestClient { public static final Integer ERROR_RESPONSE_CODE = new Integer(500); public String getLocatorURI() { return "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet"; //return "http://localhost:8080/servlet-invoker/ServerInvokerServlet"; } public static void main(String[] args) { ServletInvokerTestClient client = new ServletInvokerTestClient(); try { client.testPostInvocation(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ServletInvokerExceptionTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/servlet/ServletInv0000644000175000017500000000403510712234641033601 0ustar twernertwerner/* * 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.transport.servlet; import org.jboss.test.remoting.transport.web.WebInvokerTestClient; /** * This test is identical to ServletInvokerTestClient except that it, in the case * when an exception is thrown on the server, ServletServerInvoker is explicitly instructed * to return the actual exception. * * See JBREM-813 and JBREM-675. * * @author Tom Elrod * @author Ron Sigal */ public class ServletInvokerExceptionTestClient extends WebInvokerTestClient { public static final Integer ERROR_RESPONSE_CODE = new Integer(500); public String getLocatorURI() { return "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?dont-return-exception=false"; } public static void main(String[] args) { ServletInvokerExceptionTestClient client = new ServletInvokerExceptionTestClient(); try { client.testPostInvocation(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/InvokerClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/InvokerClientTest.0000644000175000017500000003372510744611501033515 0ustar twernertwerner/* * 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.transport; import junit.framework.TestCase; import org.apache.log4j.Level; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.ComplexReturn; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import org.jboss.test.remoting.transport.mock.MockInvokerCallbackHandler; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.jboss.test.remoting.transport.mock.MockTest; import java.net.BindException; import java.rmi.server.UID; /** * This is the actual concrete test for the invoker client. Uses socket transport by default. * * @author Tom Elrod */ public abstract class InvokerClientTest extends TestCase { private String sessionId = new UID().toString(); private Client client; protected Connector connector; protected InvokerLocator locator; protected int port = 9091; //default port protected int callbackPort = -1; protected String metadata = null; public static final Logger log = Logger.getLogger(InvokerClientTest.class); public abstract String getTransport(); public int getCallbackPort() { return callbackPort; } public void init() { try { String host = System.getProperty("jrunit.bind_addr", "localhost"); String locatorURI = getTransport() + "://" + host+ ":" + port; if(metadata != null) { locatorURI = locatorURI + "/?" + metadata; } log.info("connecting to: " + locatorURI); InvokerLocator locator = new InvokerLocator(locatorURI); client = new Client(locator, "mock"); client.connect(); } catch(Exception e) { log.error(e.getMessage(), e); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { if(port < 0) { port = TestUtil.getRandomPort(); } log.debug("port = " + port); // InvokerRegistry.registerInvoker("mock", MockClientInvoker.class, MockServerInvoker.class); connector = new Connector(); String locatorURI = getTransport() + "://localhost:" + port; if(metadata != null) { locatorURI = locatorURI + "/?" + metadata; } InvokerLocator locator = new InvokerLocator(locatorURI); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); return locator; } protected String getSubsystem() { return "mock"; } protected ServerInvocationHandler getServerInvocationHandler() { return new MockServerInvocationHandler(); } public void setUp() throws Exception { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(newMetadata != null && newMetadata.length() > 0) { metadata = newMetadata; log.info("Using metadata: " + metadata); } newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA_CALLBACK); if(newMetadata != null && newMetadata.length() > 0) { if(metadata == null) { metadata = newMetadata; } else { metadata += newMetadata; } log.info("Using metadata: " + metadata); } // this is a retry hack because in some cases, can get duplicate callback server ports // when trying to find a free one. int retryLimit = 3; for(int x = 0; x < retryLimit; x++) { try { locator = initServer(getCallbackPort()); } catch(BindException e) { if(x + 1 == retryLimit) { throw e; } else { continue; } } break; } init(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } /** * Test simple invocation and adding of listener with push callback (meaning server * will send callback message when it gets it) to a local callback server * * @throws Throwable */ public void testLocalPushCallback() throws Throwable { log.debug("running testLocalPushCallback()"); sessionId = new UID().toString(); sessionId = client.getSessionId(); MockInvokerCallbackHandler handler = new MockInvokerCallbackHandler(sessionId); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testLocalPushCallback() invocation of foo.", "bar".equals(ret)); if("bar".equals(ret)) { log.debug("PASS"); } else { log.debug("FAILED - testLocalPushCallback1"); } client.addListener(handler, locator); // invoke which should cause callback ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(3000); log.debug("done sleeping."); int callbacksPerformed = handler.isCallbackReceived(); log.debug("callbacksPerformed after adding listener is " + callbacksPerformed); assertTrue("Result of testLocalPushCallback() failed since did not get callback.", (callbacksPerformed == 1)); if(callbacksPerformed == 1) { log.debug("PASS"); } else { log.debug("FAILED - testLocalPushCallback2"); } // Can now call direct on client client.removeListener(handler); // shouldn't get callback now since removed listener ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(2000); log.debug("done sleeping."); callbacksPerformed = handler.isCallbackReceived(); log.debug("callbackPerformed after removing listener is " + callbacksPerformed); assertTrue("Result of testLocalPushCallback() failed since did get callback " + "but have been removed as listener.", (callbacksPerformed == 1)); if(callbacksPerformed == 1) { log.debug("PASS"); } else { log.debug("FAILED - testLocalPushCallback3"); } } /** * Test simple invocation and adding of listener with push callback (meaning server * will send callback message when it gets it) to a remote callback server * * @throws Throwable */ public void testRemotePushCallback() throws Throwable { log.debug("running testRemotePushCallback()"); sessionId = new UID().toString(); //InvokerLocator locator = client.getInvoker().getLocator(); sessionId = client.getSessionId(); MockInvokerCallbackHandler handler = new MockInvokerCallbackHandler(sessionId); log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); // simple invoke, should return bar Object ret = makeInvocation("foo", "bar"); assertTrue("Result of testRemotePushCallback() invocation of foo.", "bar".equals(ret)); if("bar".equals(ret)) { log.debug("PASS"); } else { log.debug("FAILED - testRemotePushCallback1"); } client.addListener(handler, locator); // invoke which should cause callback ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(3000); log.debug("done sleeping."); // TODO: No way to currently check the remote callback handler // to see if it got callback -TME /* int callbacksPerformed = handler.isCallbackReceived(); log.debug("callbacksPerformed after adding listener is " + callbacksPerformed); assertTrue("Result of testRemotePushCallback() failed since did not get callback.", (callbacksPerformed == 1)); */ // Can now call direct on client client.removeListener(handler); // shouldn't get callback now since removed listener ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(2000); log.debug("done sleeping."); /* callbacksPerformed = handler.isCallbackReceived(); log.debug("callbackPerformed after removing listener is " + callbacksPerformed); assertTrue("Result of testRemotePushCallback() failed since did get callback " + "but have been removed as listener.", (callbacksPerformed == 1)); */ } /** * Tests simple invocation and pull callbacks. Meaning will add a listener and * will then have to get the callbacks from the server. * * @throws Throwable */ public void testPullCallback() throws Throwable { log.debug("running testPullCallback()"); // should be null by default, since don't have connector started, but setting anyway //client.setClientLocator(null); MockInvokerCallbackHandler handler = new MockInvokerCallbackHandler(sessionId); // simple invoke, should return bar Object ret = makeInvocation("bar", "foo"); assertTrue("Result of runPullCallbackTest() invocation of bar.", "foo".equals(ret)); if("foo".equals(ret)) { log.debug("PASS"); } else { log.debug("FAILED - testPullCallback1"); } client.addListener(handler); // invoke which should cause callback on server side ret = makeInvocation("test", "test"); // allow time for callback Thread.sleep(5000); ret = client.getCallbacks(handler); log.debug("getCallbacks returned " + ret); log.debug("should have something."); assertTrue("Result of runPullCallbackTest() getCallbacks() after add listener.", ret != null); if(ret != null) { log.debug("PASS"); } else { log.debug("FAILED - testPullCallback2"); } // can now call directly on client //ret = makeInvocation("removeListener", null); client.removeListener(handler); ret = makeInvocation("getCallbacks", null); log.debug("getCallbacks returned " + ret); log.debug("should have been empty."); assertTrue("Result of runPullCallbackTest() getCallbacks() after remove listener.", ret == null); if(ret == null) { log.debug("PASS"); } else { log.debug("FAILED - testPullCallback3"); } } /** * Tests complex invocation to get object containing array of complex objects. * * @throws Throwable */ public void testArrayReturn() throws Throwable { // simple invoke, should return bar Object ret = makeInvocation("testComplexReturn", null); ComplexReturn complexRet = (ComplexReturn) ret; MockTest[] mockTests = complexRet.getMockTests(); assertTrue("ComplexReturn's array should contain 2 items", 2 == mockTests.length); if(2 == mockTests.length) { log.debug("PASS"); } else { log.debug("FAILED - testArrayReturn1"); } for(int x = 0; x < mockTests.length; x++) { System.err.println(mockTests[x]); MockTest test = mockTests[x]; assertNotNull("MockTest should not be null", test); if(test != null) { log.debug("PASS"); } else { log.debug("FAILED - testArrayReturn2"); } } // assertTrue("Result of runPullCallbackTest() invocation of bar.", // "foo".equals(ret)); } public void testThrownException() throws Throwable { try { makeInvocation("testException", null); assertTrue("Did not get exception thrown as expected.", false); } catch(Exception throwable) { assertTrue("Got exception thrown as expected.", true); } } protected Client getClient() { return client; } protected Object makeInvocation(String method, String param) throws Throwable { return client.invoke(new NameBasedInvocation(method, new Object[]{param}, new String[]{String.class.getName()}), null); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/InvokerTestDriver.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/InvokerTestDriver.0000644000175000017500000000447110355142433033527 0ustar twernertwerner/* * 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.transport; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public abstract class InvokerTestDriver extends TestDriver { public static final String REMOTING_METADATA = "remoting.metadata"; public static final String JVM_MAX_HEAP_SIZE = "jvm.mx"; protected String getClientJVMArguments() { return getJVMArguments(); } /** * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness). * The default value is null. * * @return */ protected String getServerJVMArguments() { return getJVMArguments(); } /** * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness). * The default value is null. * * @return */ protected String getJVMArguments() { String vmArgs = ""; String metadata = System.getProperty(REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { vmArgs = "-D" + REMOTING_METADATA + "=" + metadata; } String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE); if(jvmMx != null && jvmMx.length() > 0) { vmArgs = vmArgs + " -Xmx" + jvmMx + "m"; } return vmArgs; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/0000755000175000017500000000000011632407040031015 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockTest.java0000644000175000017500000000275610355142433033426 0ustar twernertwerner/* * 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.transport.mock; import java.io.Serializable; /** * MockTest - This is just an empty class for testing complex object returns. * It does nothing other than provide an object payload to be passed around. * * @author Jeff Haynie * @version $Revision: 566 $ */ public class MockTest implements Serializable { String value = "This is some value"; public MockTest() { } public String getValue() { return value; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockClientInv0000644000175000017500000000620410355142433033452 0ustar twernertwerner/* * 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.transport.mock; import java.io.IOException; import java.util.Map; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.RemoteClientInvoker; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; /** * MockClientInvoker * * @author Jeff Haynie * @version $Revision: 566 $ */ public class MockClientInvoker extends RemoteClientInvoker { private final MockServerInvoker server; private boolean loaded = false; public MockClientInvoker(InvokerLocator locator, MockServerInvoker server) { super(locator); this.server = server; } /** * subclasses must implement this method to provide a hook to connect to the remote server, if this applies * to the specific transport. However, in some transport implementations, this may not make must difference since * the connection is not persistent among invocations, such as SOAP. In these cases, the method should * silently return without any processing. * * @throws ConnectionFailedException */ protected void handleConnect() throws ConnectionFailedException { } /** * subclasses must implement this method to provide a hook to disconnect from the remote server, if this applies * to the specific transport. However, in some transport implementations, this may not make must difference since * the connection is not persistent among invocations, such as SOAP. In these cases, the method should * silently return without any processing. */ protected void handleDisconnect() { } public void connect() throws ConnectionFailedException { } public void disconnect() { } protected String getDefaultDataType() { return null; } public boolean isConnected() { return false; } protected Object transport(String sessionId, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller) throws IOException, ConnectionFailedException { return server.invoke(invocation); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockServerInv0000644000175000017500000000361410355142433033504 0ustar twernertwerner/* * 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.transport.mock; import java.util.Map; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; /** * MockServerInvoker * * @author Jeff Haynie * @version $Revision: 566 $ */ public class MockServerInvoker extends ServerInvoker { boolean loaded = false; public MockServerInvoker(InvokerLocator locator) { super(locator); } public MockServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } protected String getDefaultDataType() { return null; } /** * returns true if the transport is bi-directional in nature, for example, * SOAP in unidirectional and SOCKETs are bi-directional (unless behind a firewall * for example). * * @return */ public boolean isTransportBiDirectional() { return false; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockServerInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockServerInv0000644000175000017500000002112610434676565033522 0ustar twernertwerner/* * 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.transport.mock; import java.rmi.MarshalledObject; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.management.MBeanServer; 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.invocation.InternalInvocation; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.test.remoting.ComplexReturn; import org.jboss.test.remoting.byvalue.ByValuePayload; /** * MockServerInvocationHandler * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 1066 $ */ public class MockServerInvocationHandler implements ServerInvocationHandler { private ServerInvoker invoker; private List listeners = Collections.synchronizedList(new ArrayList()); private Map clientListeners = new HashMap(); private static final Logger log = Logger.getLogger(MockServerInvocationHandler.class); /** * 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 NameBasedInvocation) { NameBasedInvocation nbi = (NameBasedInvocation) param; methodName = nbi.getMethodName(); params = nbi.getParameters(); sig = nbi.getSignature(); } else if(param instanceof InternalInvocation) { InternalInvocation ii = (InternalInvocation) param; methodName = ii.getMethodName(); params = ii.getParameters(); } else { log.info("Don't recognize the parameter type, so just returning it."); return param; } String sessionId = invocation.getSessionId(); String subsystem = invocation.getSubsystem(); log.debug("invoke() called with method: " + methodName + "\tsessionId: " + sessionId + "\tsubsystem:" + subsystem); //deprecated since specific to JMX (old way of handling callbacks) if(methodName.equals("testComplexReturn")) { //Need to send back complex object containing array of complext objects. ComplexReturn ret = new ComplexReturn(); return ret; } if(methodName.equals("testMarshalledObject")) { ComplexReturn ret = new ComplexReturn(); MarshalledObject mObj = new MarshalledObject(ret); return mObj; } else if(methodName.equals("test")) { // will cause a callback on all the listeners log.debug("test called on server invocation handler, so should do callback."); CallbackDispatcher callbackDispatcher = new CallbackDispatcher(invocation.getSessionId(), invocation.getSubsystem(), new NameBasedInvocation("handleCallback", params, sig)); Thread callbackThread = new Thread(callbackDispatcher); callbackThread.start(); } else if(methodName.equals("addClientListener")) { Object obj = params[0]; InvokerCallbackHandler clientHandler = (InvokerCallbackHandler) obj; clientListeners.put(invocation.getSessionId(), clientHandler); } else if(methodName.equals("removeClientListener")) { Object obj = params[0]; InvokerCallbackHandler clientHandler = (InvokerCallbackHandler) obj; clientListeners.remove(invocation.getSessionId()); } else if(methodName.equals("handleCallback")) { // got a callback from remote server InvokerCallbackHandler clientHandler = (InvokerCallbackHandler) clientListeners.get(sessionId); clientHandler.handleCallback(new Callback(invocation.getParameter())); } else if(methodName.equals("testException") || methodName.equals("testThrowException")) { throw new Exception("Got call from client to throw exception. This is expected."); } else if(methodName.equals("testByValue")) { // check to see if by value payload was serialized at some point Object arg = params[0]; if(arg instanceof ByValuePayload) { ByValuePayload byValuePayload = (ByValuePayload) arg; return new Boolean(byValuePayload.wasMarshalled()); } else { // Error in tests return Boolean.FALSE; } } Object ret = null; if(params != null) { ret = params[0]; log.info("Found a parameter to return " + ret); } // end of if () else { log.info("returning null"); } // end of else return ret; } /** * @param sessionId * @deprecated */ private void handleRemoveNotificationListener(String sessionId) { listeners.remove(sessionId); } /** * @param clientLocator * @param subsystem * @param sessionId * @throws Exception * @deprecated */ private void handleAddNotificationListener(InvokerLocator clientLocator, String subsystem, String sessionId) throws Exception { Client callBackClient = new Client(clientLocator, subsystem); callBackClient.connect(); listeners.add(callBackClient); } 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); } private class CallbackDispatcher implements Runnable { private String sessionId; private String subsystem; private Object param; public CallbackDispatcher(String sessionId, String subsystem, Object param) { this.sessionId = sessionId; this.subsystem = subsystem; this.param = param; } public void run() { List tempList = null; synchronized(listeners) { tempList = new ArrayList(listeners); } Iterator itr = tempList.iterator(); while(itr.hasNext()) { try { InvokerCallbackHandler handler = (InvokerCallbackHandler) itr.next(); Callback invocation = new Callback(param); handler.handleCallback(invocation); } catch(Throwable e) { e.printStackTrace(); } } } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockInvokerCallbackHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/transport/mock/MockInvokerCa0000644000175000017500000000572210355142433033444 0ustar twernertwerner/* * 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.transport.mock; import java.io.Serializable; import java.util.List; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * @author Tom Elrod */ public class MockInvokerCallbackHandler implements InvokerCallbackHandler, Serializable { private String callbackId; private int callbacksRecieved = 0; public MockInvokerCallbackHandler(String callbackId) { this.callbackId = callbackId; } /** * 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.err.println("We got callback on client. " + callback + " for " + this); this.callbacksRecieved++; } public int isCallbackReceived() { System.err.println("returning " + callbacksRecieved + " for callback recieved for " + this); return this.callbacksRecieved; } //TODO: Important that client caller keeps id unique and maintains id // since used as key when add/remove listener in client subsystem handler -TME public String getId() { return callbackId; } /** * Will get current list of callbacks. * * @return */ //TODO: This is messed up. Why should client InvokerCallbackHandler have to implement this? // should probably make parent interface that does not have this one -TME public List getCallbacks() { return null; } /** * This method is required to be called upon removing a callback listener * so can clean up resources used by the handler. In particular, should * call disconnect on internal Client. */ public void destroy() { } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/deploy/0000755000175000017500000000000011632407041027325 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/deploy/DualDeploymentTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/deploy/DualDeploymentTestCas0000644000175000017500000002214311005734300033462 0ustar twernertwerner/* * 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.deploy; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvalidConfigurationException; 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; import javax.management.MBeanServerFactory; import javax.management.ObjectName; /** * @author Tom Elrod */ public class DualDeploymentTestCase extends TestCase { private static int idCounter = 1; public DualDeploymentTestCase(String name) { super(name); } /** * This test checks to see if use the exact same locator uri, will get the * exact same server invoker (even though connectors are different). If add handler to * each of the different connectors (with different subsystems), will really be two handlers in the same server invoker * * @throws Throwable */ public void testSameLocator() throws Throwable { MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); String locator1 = "socket://localhost:5701"; String locator2 = "socket://localhost:5701"; int id1 = 1; int id2 = 2; Connector connector1 = setupServer(locator1, mbeanServer); SampleInvocationHandler invocationHandler1 = new SampleInvocationHandler(id1); connector1.addInvocationHandler("sub1", invocationHandler1); Connector connector2 = null; try { connector2 = setupServer(locator2, mbeanServer); SampleInvocationHandler invocationHandler2 = new SampleInvocationHandler(id2); connector2.addInvocationHandler("sub2", invocationHandler2); } catch(InvalidConfigurationException e) { assertTrue("Got InvalidConfigurationException as expected.", true); return; } finally { connector1.stop(); connector1.destroy(); if(connector2 != null) { connector2.stop(); connector2.destroy(); } } assertTrue("Did not get InvalidConfigurationException as expected.", false); } /** * This checks to makes sure if you add a handler with the same subsystem value, it will return the existing * one. * * @throws Throwable */ public void testSameSubsystem() throws Throwable { MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); String locator1 = "socket://localhost:5703"; int id1 = 1; int id2 = 2; Connector connector1 = setupServer(locator1, mbeanServer); SampleInvocationHandler invocationHandler1 = new SampleInvocationHandler(id1); ServerInvocationHandler previous = connector1.addInvocationHandler("sub1", invocationHandler1); assertNull(previous); SampleInvocationHandler invocationHandler2 = new SampleInvocationHandler(id2); previous = connector1.addInvocationHandler("sub1", invocationHandler2); assertEquals(invocationHandler1, previous); ServerInvocationHandler[] handlers1 = connector1.getInvocationHandlers(); assertEquals(1, handlers1.length); connector1.stop(); connector1.destroy(); } /** * Disabling this test. * * org.jboss.remoting.ServerInvoker is not written to support * the assertion "should always use the last handler added" made below. * * There are two choices: * * 1. Implement the feature, or * 2. Eliminate the test. * * Since there is no provision in the Remoting Guide that supports this feature, and * it doesn't seem particularly useful, we'll leave the ServerInvoker code alone * and eliminate the test. - Ron Sigal, 4/29/08 * * If multiple handlers added to connector (thus server invoker) and subsystem is NOT * specified in client, then will be processed by last handler added. * * @throws Throwable */ public void xtestNoSubsystem() throws Throwable { MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); String locator1 = "socket://localhost:5704"; String locator2 = "socket://localhost:5705"; int id1 = 1; int id2 = 2; int id3 = 3; int id4 = 4; Connector connector1 = setupServer(locator1, mbeanServer); SampleInvocationHandler invocationHandler1 = new SampleInvocationHandler(id1); connector1.addInvocationHandler("sub1", invocationHandler1); SampleInvocationHandler invocationHandler2 = new SampleInvocationHandler(id2); connector1.addInvocationHandler("sub2", invocationHandler2); SampleInvocationHandler invocationHandler3 = new SampleInvocationHandler(id3); connector1.addInvocationHandler("sub3", invocationHandler3); Connector connector2 = setupServer(locator2, mbeanServer); SampleInvocationHandler invocationHandler4 = new SampleInvocationHandler(id4); connector2.addInvocationHandler("sub4", invocationHandler4); Client client = new Client(new InvokerLocator(locator1)); Client client2 = new Client(new InvokerLocator(locator2)); client.connect(); client2.connect(); Object ret1 = client.invoke("Do something"); Object ret2 = client2.invoke("Do something"); // should always use the last handler added assertEquals("" + id3, ret1); assertEquals("" + id4, ret2); connector1.stop(); connector1.destroy(); connector2.stop(); connector2.destroy(); } public Connector setupServer(String locatorURI, MBeanServer mbeanServer) 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()); int randomInt = idCounter++; ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol() + ",id=" + randomInt); mbeanServer.registerMBean(connector, obj); connector.start(); return connector; } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { private int id = 0; public SampleInvocationHandler(int id) { this.id = id; } public int getId() { return id; } /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Just going to return static string as this is just simple example code. return "" + id; } /** * 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 } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/0000755000175000017500000000000011632407031027323 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/StreamingConnectorTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/StreamingConnectorTes0000644000175000017500000001064610766571165033556 0ustar twernertwernerpackage org.jboss.test.remoting.stream; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; import java.io.File; import java.io.FileInputStream; import java.net.URL; import java.util.Map; /** * @author Tom Elrod */ public class StreamingConnectorTestClient extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI; private Client remotingClient = null; private File testFile = null; private FileInputStream fileInput = null; private boolean error = false; private Connector connector = null; private String streamConnectorLocatorUri; public void testStream() throws Throwable { for(int x = 0; x < 5; x++) { // new Thread(new Runnable() { // public void run() // { // try // { sendStream(); // } // catch (Throwable throwable) // { // throwable.printStackTrace(); // error = true; // } // } // }).start(); } // Thread.sleep(5000); // assertFalse(error); } public void sendStream() throws Throwable { URL fileURL = this.getClass().getResource("test.txt"); if(fileURL == null) { throw new Exception("Can not find file test.txt"); } testFile = new File(fileURL.getFile()); fileInput = new FileInputStream(testFile); String param = "foobar"; long fileLength = testFile.length(); System.out.println("File size = " + fileLength); Object ret = remotingClient.invoke(fileInput, param, connector); Map responseMap = (Map)ret; String subSys = (String)responseMap.get("subsystem"); String clientId = (String)responseMap.get("clientid"); String paramVal = (String)responseMap.get("paramval"); assertEquals("test_stream".toUpperCase(), subSys); assertEquals(remotingClient.getSessionId(), clientId); assertEquals("foobar", paramVal); Object response = remotingClient.invoke("get_size"); int returnedFileLength = ((Integer) response).intValue(); System.out.println("Invocation response: " + response); if(fileLength == returnedFileLength) { System.out.println("PASS"); } else { System.out.println("FAILED - returned file length was " + returnedFileLength); } assertEquals(fileLength, returnedFileLength); } public void setUp() throws Exception { String bindAddr = System.getProperty("jrunit.bind_addr", host); locatorURI = transport + "://" + bindAddr + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator, "test_stream"); remotingClient.connect(); setupServer(); } private void setupServer() throws Exception { String bindAddr = System.getProperty("jrunit.bind_addr", host); streamConnectorLocatorUri = transport + "://" + bindAddr + ":" + 5410; connector = new Connector(streamConnectorLocatorUri); connector.create(); connector.start(); } public void tearDown() throws Exception { if(remotingClient != null) { remotingClient.disconnect(); } if(fileInput != null) { fileInput.close(); } } /** * 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) { StreamingConnectorTestClient.transport = args[0]; StreamingConnectorTestClient.port = Integer.parseInt(args[1]); } String locatorURI = StreamingConnectorTestClient.transport + "://" + StreamingConnectorTestClient.host + ":" + StreamingConnectorTestClient.port; StreamingConnectorTestClient client = new StreamingConnectorTestClient(); try { client.setUp(); client.testStream(); client.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/StreamingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/StreamingTestCase.jav0000644000175000017500000000266711006206303033417 0ustar twernertwerner/* * 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.stream; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class StreamingTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(StreamingTestClient.class.getName(), 1, StreamingTestServer.class.getName()); } protected long getResultsTimeout() { return 90000; } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/Streaming2TestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/Streaming2TestCase.ja0000644000175000017500000000062710535452155033323 0ustar twernertwernerpackage org.jboss.test.remoting.stream; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class Streaming2TestCase extends TestDriver { public void declareTestClasses() { addTestClasses(StreamingConnectorTestClient.class.getName(), 1, StreamingTestServer.class.getName()); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/StreamingTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/StreamingTestServer.j0000644000175000017500000001523011015201772033456 0ustar twernertwerner/* * 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.stream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Map; import java.util.HashMap; import javax.management.MBeanServer; import org.apache.log4j.Logger; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.stream.StreamInvocationHandler; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class StreamingTestServer extends ServerTestCase { private static Logger log = Logger.getLogger(StreamingTestServer.class); // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI; private Connector connector = null; public void setupServer() throws Exception { String bindAddr = System.getProperty("jrunit.bind_addr", host); locatorURI = transport + "://" + bindAddr + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); log.info("Starting remoting server with locator uri of: " + locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); TestStreamInvocationHandler invocationHandler = new TestStreamInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("test_stream", invocationHandler); connector.start(); log.info("Started remoting server with locator uri of: " + locatorURI); } protected void setUp() throws Exception { setupServer(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } StreamingTestServer server = new StreamingTestServer(); try { server.setUp(); // sleep the thread for 10 seconds while waiting for client to call Thread.sleep(10000); server.tearDown(); } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class TestStreamInvocationHandler implements StreamInvocationHandler { private InputStream stream = null; private int streamSize = 0; /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request log.info("Invocation request is: " + invocation.getParameter()); // Just going to return static string as this is just simple example code. return new Integer(streamSize); } /** * 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 } public Object handleStream(InputStream stream, InvocationRequest param) { this.stream = stream; try { ByteArrayOutputStream out = new ByteArrayOutputStream(); byte buf[] = new byte[4096]; while(true) { int c = this.stream.read(buf); if(c < 0) { break; } out.write(buf, 0, c); } byte[] bytes = out.toByteArray(); streamSize = bytes.length; log.info("Read stream. Contents is: " + new String(bytes)); } catch(IOException e) { e.printStackTrace(); } finally { try { stream.close(); } catch(IOException e) { e.printStackTrace(); } } // build return map Map retMap = new HashMap(); retMap.put("subsystem", param.getSubsystem()); retMap.put("clientid", param.getSessionId()); retMap.put("paramval", param.getParameter()); return retMap; } } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/StreamingTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/StreamingTestClient.j0000644000175000017500000001174111015201772033431 0ustar twernertwerner/* * 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.stream; import junit.framework.TestCase; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.io.File; import java.io.FileInputStream; import java.net.URL; import java.util.Map; /** * @author Tom Elrod */ public class StreamingTestClient extends TestCase { private static Logger log = Logger.getLogger(StreamingTestClient.class); // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI; private Client remotingClient = null; private File testFile = null; private FileInputStream fileInput = null; private boolean error = false; public void testStream() throws Throwable { for(int x = 0; x < 5; x++) { // new Thread(new Runnable() { // public void run() // { // try // { sendStream(); // } // catch (Throwable throwable) // { // throwable.printStackTrace(); // error = true; // } // } // }).start(); } // Thread.sleep(5000); // assertFalse(error); log.info("Waiting to give server a chance to send "); log.info("org.jboss.remoting.stream.StreamHandler.CLOSE message"); Thread.sleep(5000); } public void sendStream() throws Throwable { URL fileURL = this.getClass().getResource("test.txt"); if(fileURL == null) { throw new Exception("Can not find file test.txt"); } testFile = new File(fileURL.getFile()); fileInput = new FileInputStream(testFile); String param = "foobar"; long fileLength = testFile.length(); log.info("File size = " + fileLength); Object ret = remotingClient.invoke(fileInput, param); Map responseMap = (Map)ret; String subSys = (String)responseMap.get("subsystem"); String clientId = (String)responseMap.get("clientid"); String paramVal = (String)responseMap.get("paramval"); assertEquals("test_stream".toUpperCase(), subSys); assertEquals(remotingClient.getSessionId(), clientId); assertEquals("foobar", paramVal); Object response = remotingClient.invoke("get_size"); int returnedFileLength = ((Integer) response).intValue(); log.info("Invocation response: " + response); if(fileLength == returnedFileLength) { log.info("PASS"); } else { log.info("FAILED - returned file length was " + returnedFileLength); } assertEquals(fileLength, returnedFileLength); } public void setUp() throws Exception { String bindAddr = System.getProperty("jrunit.bind_addr", host); locatorURI = transport + "://" + bindAddr + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); log.info("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator, "test_stream"); remotingClient.connect(); } public void tearDown() throws Exception { if(remotingClient != null) { remotingClient.disconnect(); } if(fileInput != null) { fileInput.close(); } } /** * 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; StreamingTestClient client = new StreamingTestClient(); try { client.setUp(); client.testStream(); client.tearDown(); } catch(Throwable e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/stream/test.txt0000644000175000017500000001365110233342174031053 0ustar twernertwernerThis is a test file to be streamed. The rest is filler. adsfasdf;lkasdjf;laskdfjjjjjjjjjjjjjfasdfl;kajfaw;elkfjawef asdf;alsdkfja as;dlkfjasfweoifjasdfl; asdf;lkajfwaef asdf;alskdfjas d;flkasjdf adf sadfajsd;lfkasjdf;aslkdfjas;dlkfjasd;flkjas sdfa dfasdflas;skdfjas dflkajs dfasl;dkfjasdl;fkjasd a dflaskdfjasdlfkjasdfl;kaj asdlfkjasdf;lkadjfasd fasdflkasjdf a;sdlkfj ad;slfkjaf ;lekfjqw4eofijasd;vknsmdv adfals;dfkjadf ;lkasdjf a;sdlkfj asdlkfja dfadfasdfadsf;oiwwjefwa'elfja adflkaj f3oe4ifjaefaslkdjf a;lsdkfj awefiojwe fl;akdjf als;dkfja df asdf afm;welfkawejfa sdlkfjas f;li4fjaseflka djf asd asdkfa sdf;lkjewal;kfja sd;lkgjasdf akfje adsfadf;lwi4efjnadkfz sdlzksjfalwekrjw isdjaldfkajsdlfkasjdfla;ksd fj asdfj;lakdsjfa ;welkfj2e3ofiajefklasdfj asdlkfjads kfadjf al;dsf adfjeofijalfdknbaslrganvz;dlkfaj w;lefkajwefalwefkajv aedfkjad ajdfl;a kdfja;lfkj2 ifa jef[aoiwefja;dslkgawje [oiajdfj;ladk j adsja;elkijwe[oiadjs akl;djf lwekfj awel;fkja asdfkalsdfj sasl;dfkjas dlfkasjdf;l ef awefsd;lfkasdjf asdsl; fkjsad f;lkasdjf as;ldkfjas d;lfkjasd f;l a df;asldfkjasd fklasdjf lwekfjawef;lkasjd as;ldkfjasdsf;lkasdjf a;lkdf adsf asd;flkjawef;lkwjef ;sldkfj asd;lkfj asdf;lkkjwefa lsefkjasd ;flksadj as df;lakfjewlkfjsdflksdj vxzcviojflaewijfawe flksadf sa adsfasdf;lkasdjf;laskdfjjjjjjjjjjjjjfasdfl;kajfaw;elkfjawef asdf;alsdkfja as;dlkfjasfweoifjasdfl; asdf;lkajfwaef asdf;alskdfjas d;flkasjdf adf sadfajsd;lfkasjdf;aslkdfjas;dlkfjasd;flkjas sdfa dfasdflas;skdfjas dflkajs dfasl;dkfjasdl;fkjasd a dflaskdfjasdlfkjasdfl;kaj asdlfkjasdf;lkadjfasd fasdflkasjdf a;sdlkfj ad;slfkjaf ;lekfjqw4eofijasd;vknsmdv adfals;dfkjadf ;lkasdjf a;sdlkfj asdlkfja dfadfasdfadsf;oiwwjefwa'elfja adflkaj f3oe4ifjaefaslkdjf a;lsdkfj awefiojwe fl;akdjf als;dkfja df asdf afm;welfkawejfa sdlkfjas f;li4fjaseflka djf asd asdkfa sdf;lkjewal;kfja sd;lkgjasdf akfje adsfadf;lwi4efjnadkfz sdlzksjfalwekrjw isdjaldfkajsdlfkasjdfla;ksd fj asdfj;lakdsjfa ;welkfj2e3ofiajefklasdfj asdlkfjads kfadjf al;dsf adfjeofijalfdknbaslrganvz;dlkfaj w;lefkajwefalwefkajv aedfkjad ajdfl;a kdfja;lfkj2 ifa jef[aoiwefja;dslkgawje [oiajdfj;ladk j adsja;elkijwe[oiadjs akl;djf lwekfj awel;fkja asdfkalsdfj sasl;dfkjas dlfkasjdf;l ef awefsd;lfkasdjf asdsl; fkjsad f;lkasdjf as;ldkfjas d;lfkjasd f;l a df;asldfkjasd fklasdjf lwekfjawef;lkasjd as;ldkfjasdsf;lkasdjf a;lkdf adsf asd;flkjawef;lkwjef ;sldkfj asd;lkfj asdf;lkkjwefa lsefkjasd ;flksadj as df;lakfjewlkfjsdflksdj vxzcviojflaewijfawe flksadf sa adsfasdf;lkasdjf;laskdfjjjjjjjjjjjjjfasdfl;kajfaw;elkfjawef asdf;alsdkfja as;dlkfjasfweoifjasdfl; asdf;lkajfwaef asdf;alskdfjas d;flkasjdf adf sadfajsd;lfkasjdf;aslkdfjas;dlkfjasd;flkjas sdfa dfasdflas;skdfjas dflkajs dfasl;dkfjasdl;fkjasd a dflaskdfjasdlfkjasdfl;kaj asdlfkjasdf;lkadjfasd fasdflkasjdf a;sdlkfj ad;slfkjaf ;lekfjqw4eofijasd;vknsmdv adfals;dfkjadf ;lkasdjf a;sdlkfj asdlkfja dfadfasdfadsf;oiwwjefwa'elfja adflkaj f3oe4ifjaefaslkdjf a;lsdkfj awefiojwe fl;akdjf als;dkfja df asdf afm;welfkawejfa sdlkfjas f;li4fjaseflka djf asd asdkfa sdf;lkjewal;kfja sd;lkgjasdf akfje adsfadf;lwi4efjnadkfz sdlzksjfalwekrjw isdjaldfkajsdlfkasjdfla;ksd fj asdfj;lakdsjfa ;welkfj2e3ofiajefklasdfj asdlkfjads kfadjf al;dsf adfjeofijalfdknbaslrganvz;dlkfaj w;lefkajwefalwefkajv aedfkjad ajdfl;a kdfja;lfkj2 ifa jef[aoiwefja;dslkgawje [oiajdfj;ladk j adsja;elkijwe[oiadjs akl;djf lwekfj awel;fkja asdfkalsdfj sasl;dfkjas dlfkasjdf;l ef awefsd;lfkasdjf asdsl; fkjsad f;lkasdjf as;ldkfjas d;lfkjasd f;l a df;asldfkjasd fklasdjf lwekfjawef;lkasjd as;ldkfjasdsf;lkasdjf a;lkdf adsf asd;flkjawef;lkwjef ;sldkfj asd;lkfj asdf;lkkjwefa lsefkjasd ;flksadj as df;lakfjewlkfjsdflksdj vxzcviojflaewijfawe flksadf sa adsfasdf;lkasdjf;laskdfjjjjjjjjjjjjjfasdfl;kajfaw;elkfjawef asdf;alsdkfja as;dlkfjasfweoifjasdfl; asdf;lkajfwaef asdf;alskdfjas d;flkasjdf adf sadfajsd;lfkasjdf;aslkdfjas;dlkfjasd;flkjas sdfa dfasdflas;skdfjas dflkajs dfasl;dkfjasdl;fkjasd a dflaskdfjasdlfkjasdfl;kaj asdlfkjasdf;lkadjfasd fasdflkasjdf a;sdlkfj ad;slfkjaf ;lekfjqw4eofijasd;vknsmdv adfals;dfkjadf ;lkasdjf a;sdlkfj asdlkfja dfadfasdfadsf;oiwwjefwa'elfja adflkaj f3oe4ifjaefaslkdjf a;lsdkfj awefiojwe fl;akdjf als;dkfja df asdf afm;welfkawejfa sdlkfjas f;li4fjaseflka djf asd asdkfa sdf;lkjewal;kfja sd;lkgjasdf akfje adsfadf;lwi4efjnadkfz sdlzksjfalwekrjw isdjaldfkajsdlfkasjdfla;ksd fj asdfj;lakdsjfa ;welkfj2e3ofiajefklasdfj asdlkfjads kfadjf al;dsf adfjeofijalfdknbaslrganvz;dlkfaj w;lefkajwefalwefkajv aedfkjad ajdfl;a kdfja;lfkj2 ifa jef[aoiwefja;dslkgawje [oiajdfj;ladk j adsja;elkijwe[oiadjs akl;djf lwekfj awel;fkja asdfkalsdfj sasl;dfkjas dlfkasjdf;l ef awefsd;lfkasdjf asdsl; fkjsad f;lkasdjf as;ldkfjas d;lfkjasd f;l a df;asldfkjasd fklasdjf lwekfjawef;lkasjd as;ldkfjasdsf;lkasdjf a;lkdf adsf asd;flkjawef;lkwjef ;sldkfj asd;lkfj asdf;lkkjwefa lsefkjasd ;flksadj as df;lakfjewlkfjsdflksdj vxzcviojflaewijfawe flksadf sa adsfasdf;lkasdjf;laskdfjjjjjjjjjjjjjfasdfl;kajfaw;elkfjawef asdf;alsdkfja as;dlkfjasfweoifjasdfl; asdf;lkajfwaef asdf;alskdfjas d;flkasjdf adf sadfajsd;lfkasjdf;aslkdfjas;dlkfjasd;flkjas sdfa dfasdflas;skdfjas dflkajs dfasl;dkfjasdl;fkjasd a dflaskdfjasdlfkjasdfl;kaj asdlfkjasdf;lkadjfasd fasdflkasjdf a;sdlkfj ad;slfkjaf ;lekfjqw4eofijasd;vknsmdv adfals;dfkjadf ;lkasdjf a;sdlkfj asdlkfja dfadfasdfadsf;oiwwjefwa'elfja adflkaj f3oe4ifjaefaslkdjf a;lsdkfj awefiojwe fl;akdjf als;dkfja df asdf afm;welfkawejfa sdlkfjas f;li4fjaseflka djf asd asdkfa sdf;lkjewal;kfja sd;lkgjasdf akfje adsfadf;lwi4efjnadkfz sdlzksjfalwekrjw isdjaldfkajsdlfkasjdfla;ksd fj asdfj;lakdsjfa ;welkfj2e3ofiajefklasdfj asdlkfjads kfadjf al;dsf adfjeofijalfdknbaslrganvz;dlkfaj w;lefkajwefalwefkajv aedfkjad ajdfl;a kdfja;lfkj2 ifa jef[aoiwefja;dslkgawje [oiajdfj;ladk j adsja;elkijwe[oiadjs akl;djf lwekfj awel;fkja asdfkalsdfj sasl;dfkjas dlfkasjdf;l ef awefsd;lfkasdjf asdsl; fkjsad f;lkasdjf as;ldkfjas d;lfkjasd f;l a df;asldfkjasd fklasdjf lwekfjawef;lkasjd as;ldkfjasdsf;lkasdjf a;lkdf adsf asd;flkjawef;lkwjef ;sldkfj asd;lkfj asdf;lkkjwefa lsefkjasd ;flksadj as df;lakfjewlkfjsdflksdj vxzcviojflaewijfawe flksadf salibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/0000755000175000017500000000000011632407033030712 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/SSLSocketFactoryClassNameTestRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/SSLSocketFacto0000644000175000017500000000643111413660476033441 0ustar twernertwerner /* * 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.socketfactory; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import javax.net.SocketFactory; import javax.net.ssl.SSLSocketFactory; import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot.TestSocketFactory; /** * * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jul 18, 2008 *

          */ public abstract class SSLSocketFactoryClassNameTestRoot extends SocketFactoryClassNameTestRoot { public void setUp() throws Exception { super.setUp(); String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client"); String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); System.setProperty("org.jboss.security.ignoreHttpsHost", "true"); } protected Class getSocketFactoryClass() { return TestSSLSocketFactory.class; } public static class TestSSLSocketFactory extends SocketFactory { SocketFactory sf = SSLSocketFactory.getDefault(); public TestSSLSocketFactory() { } public Socket createSocket() throws IOException, UnknownHostException { return sf.createSocket(); } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { return sf.createSocket(arg0, arg1); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { return sf.createSocket(arg0, arg1); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { return sf.createSocket(arg0, arg1, arg2, arg3); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { return sf.createSocket(arg0, arg1, arg2, arg3); } } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/CreationListenerTestRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/CreationListen0000644000175000017500000004644710712767620033610 0ustar twernertwerner/* * 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.socketfactory; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; 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.Remoting; 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.socketfactory.CreationListenerServerSocketFactory; import org.jboss.remoting.socketfactory.CreationListenerSocketFactory; import org.jboss.remoting.socketfactory.SocketCreationListener; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * @author Ron Sigal * @version $Revision: 2895 $ *

          * Copyright Jan 10, 2007 *

          */ public abstract class CreationListenerTestRoot extends TestCase { protected static Logger log = Logger.getLogger(CreationListenerTestRoot.class); protected static boolean firstTime = true; 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 testSimpleClientSocketCases() throws Exception { log.info("entering " + getName()); final InetAddress address = InetAddress.getLocalHost(); final String host = address.getHostAddress(); final int port = PortUtil.findFreePort(host); class T extends Thread { boolean running; boolean failed = false; void shutdown() {running = false;} boolean failed() {return failed;} public void run() { running = true; try { ServerSocket ss = new ServerSocket(port, 100, address); while (running) { ss.accept(); } ss.close(); } catch (IOException e) { failed = true; } } }; T t = new T(); t.start(); Thread.sleep(2000); TestListener listener = new TestListener(); SocketFactory sf = getSocketFactory(); SocketFactory clsf = new CreationListenerSocketFactory(sf, listener); assertFalse(listener.visited()); clsf.createSocket(); assertTrue(listener.visited()); listener.reset(); assertFalse(listener.visited()); clsf.createSocket(host, port); assertTrue(listener.visited()); listener.reset(); assertFalse(listener.visited()); clsf.createSocket(host, port, address, PortUtil.findFreePort(host)); assertTrue(listener.visited()); listener.reset(); assertFalse(listener.visited()); clsf.createSocket(address, port); assertTrue(listener.visited()); listener.reset(); assertFalse(listener.visited()); clsf.createSocket(address, port, address, PortUtil.findFreePort(host)); assertTrue(listener.visited()); assertTrue(!t.failed()); t.shutdown(); log.info(getName() + " PASSES"); } public void testSimpleServerSocketCases() throws Exception { log.info("entering " + getName()); final InetAddress address = InetAddress.getLocalHost(); final String host = address.getHostAddress(); class T extends Thread { private ServerSocket ss; private boolean failed = false; boolean failed() {return failed;} T(ServerSocket ss) {this.ss = ss;} public void run() { try { ss.accept(); ss.close(); } catch (IOException e) { log.error(e); failed = true; } } } TestListener listener = new TestListener(); ServerSocketFactory ssf = getServerSocketFactory(); ServerSocketFactory clssf = new CreationListenerServerSocketFactory(ssf, listener); ServerSocket ss = clssf.createServerSocket(); int freePort = PortUtil.findFreePort(host); ss.bind(new InetSocketAddress(host, freePort)); T t = new T(ss); t.start(); assertFalse(listener.visited()); new Socket(host, freePort); Thread.sleep(500); assertTrue(listener.visited()); assertTrue(!t.failed()); freePort = PortUtil.findFreePort(host); ss = clssf.createServerSocket(freePort); t = new T(ss); t.start(); listener.reset(); assertFalse(listener.visited()); new Socket(host, freePort); Thread.sleep(500); assertTrue(listener.visited()); assertTrue(!t.failed()); freePort = PortUtil.findFreePort(host); ss = clssf.createServerSocket(freePort, 100); t = new T(ss); t.start(); listener.reset(); assertFalse(listener.visited()); new Socket(host, freePort); Thread.sleep(500); assertTrue(listener.visited()); assertTrue(!t.failed()); freePort = PortUtil.findFreePort(host); ss = clssf.createServerSocket(freePort, 100, InetAddress.getLocalHost()); t = new T(ss); t.start(); listener.reset(); assertFalse(listener.visited()); new Socket(host, freePort); Thread.sleep(500); assertTrue(listener.visited()); assertTrue(!t.failed()); log.info(getName() + " PASSES"); } public void testClientSideListener() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); TestListener listener1 = new TestListener(); config.put(Remoting.SOCKET_CREATION_CLIENT_LISTENER, listener1); TestListener listener2 = new TestListener(); config.put(Remoting.SOCKET_CREATION_SERVER_LISTENER, listener2); Client client = new Client(locator, config); assertFalse(listener1.visited()); assertFalse(listener2.visited()); client.connect(); Integer i = (Integer) client.invoke(new Integer(17)); assertEquals(18, i.intValue()); Thread.sleep(500); assertTrue(listener1.visited()); assertFalse(listener2.visited()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testServerSideListener() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); ServerSocketFactory ssf = getServerSocketFactory(); serverConfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf); TestListener listener1 = new TestListener(); serverConfig.put(Remoting.SOCKET_CREATION_SERVER_LISTENER, listener1); TestListener listener2 = new TestListener(); serverConfig.put(Remoting.SOCKET_CREATION_CLIENT_LISTENER, listener2); Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, clientConfig); client.connect(); Integer i = (Integer) client.invoke(new Integer(29)); assertEquals(30, i.intValue()); Thread.sleep(500); assertTrue(listener1.visited()); assertFalse(listener2.visited()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testCallbackListeners() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.FORCE_REMOTE, "true"); ServerSocketFactory ssf = getServerSocketFactory(); serverConfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf); TestListener listener1 = new TestListener(); log.info("listener1: " + listener1); serverConfig.put(Remoting.SOCKET_CREATION_SERVER_LISTENER, listener1); TestListener listener2 = new TestListener(); log.info("listener2: " + listener2); serverConfig.put(Remoting.SOCKET_CREATION_CLIENT_LISTENER, listener2); addExtraServerConfig(serverConfig); Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); TestListener listener3 = new TestListener(); log.info("listener3: " + listener3); clientConfig.put(Remoting.SOCKET_CREATION_CLIENT_LISTENER, listener3); TestListener listener4 = new TestListener(); log.info("listener4: " + listener4); clientConfig.put(Remoting.SOCKET_CREATION_SERVER_LISTENER, listener4); addExtraClientConfig(clientConfig); Client client = new Client(locator, clientConfig); client.connect(); client.addListener(new TestCallbackHandler(), null, null, true); Integer i = (Integer) client.invoke(new Integer(29)); assertEquals(30, i.intValue()); Thread.sleep(500); assertTrue(checkListenersVisited(listener1, listener2, listener3, listener4)); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected boolean checkListenersVisited(TestListener listener1, TestListener listener2, TestListener listener3, TestListener listener4) { return listener1.visited() && listener2.visited() && listener3.visited() && listener4.visited() && !listener1.isClient() && listener2.isClient() && listener3.isClient() && !listener4.isClient(); } public void testExceptionFromClientListener() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); FailingTestListener listener = new FailingTestListener(); config.put(Remoting.SOCKET_CREATION_CLIENT_LISTENER, listener); Client client = new Client(locator, config); try { client.connect(); client.invoke(new Integer(17)); fail("didn't get expected exception"); } catch (Exception e) { log.info("CAUGHT EXPECTED EXCEPTION"); } client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testExceptionFromServerListener() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); ServerSocketFactory ssf = getServerSocketFactory(); serverConfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf); FailingTestListener listener = new FailingTestListener(); serverConfig.put(Remoting.SOCKET_CREATION_SERVER_LISTENER, listener); Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(ServerInvoker.TIMEOUT, "1000"); final Client client = new Client(locator, clientConfig); class TestThread extends Thread { public boolean failed = false; public void run() { try { client.connect(); client.invoke(new Integer(29)); failed = true; client.disconnect(); fail("invoke() should have timed out"); } catch (Throwable t) { log.info("CAUGHT EXPECTED EXCEPTION"); } } }; TestThread t = new TestThread(); t.start(); Thread.sleep(2000); assertFalse(t.failed); connector.stop(); log.info(getName() + " PASSES"); } public void testCreateClientListenerFromClassName() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); StaticTestListener.reset(); String listenerClassName = StaticTestListener.class.getName(); config.put(Remoting.SOCKET_CREATION_CLIENT_LISTENER, listenerClassName); Client client = new Client(locator, config); client.connect(); Integer i = (Integer) client.invoke(new Integer(17)); assertEquals(18, i.intValue()); Thread.sleep(500); assertTrue(StaticTestListener.visited()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testServerSideListenerFromClassName() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(); ServerSocketFactory ssf = getServerSocketFactory(); serverConfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf); StaticTestListener.reset(); String listenerClassName = StaticTestListener.class.getName(); serverConfig.put(Remoting.SOCKET_CREATION_SERVER_LISTENER, listenerClassName); Connector connector = new Connector(locator, serverConfig); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, clientConfig); client.connect(); Integer i = (Integer) client.invoke(new Integer(29)); assertEquals(30, i.intValue()); Thread.sleep(500); assertTrue(StaticTestListener.visited()); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected abstract String getTransport(); protected SocketFactory getSocketFactory() { return SocketFactory.getDefault(); } protected ServerSocketFactory getServerSocketFactory() { return ServerSocketFactory.getDefault(); } protected void addExtraClientConfig(Map config) { } protected void addExtraServerConfig(Map config) { } public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { Integer i = (Integer) invocation.getParameter(); return new Integer(i.intValue() + 1); } public void addListener(InvokerCallbackHandler callbackHandler) { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("error handling callback"); } } public void removeListener(InvokerCallbackHandler callbackHandler) {} } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback: " + callback); } } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/FailingTestListener.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/FailingTestLis0000644000175000017500000000271510553325646033535 0ustar twernertwerner/* * 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.socketfactory; import java.io.IOException; import java.net.Socket; import org.jboss.remoting.socketfactory.SocketCreationListener; /** * @author Ron Sigal * @version $Revision: 1885 $ *

          * Copyright Jan 16, 2007 *

          */ public class FailingTestListener implements SocketCreationListener { public void socketCreated(Socket socket, Object source) throws IOException { throw new IOException(); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/TestListener.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/TestListener.j0000644000175000017500000000412110553325646033522 0ustar twernertwerner/* * 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.socketfactory; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import javax.net.SocketFactory; import org.apache.log4j.Logger; import org.jboss.remoting.socketfactory.SocketCreationListener; /** * @author Ron Sigal * @version $Revision: 1885 $ *

          * Copyright Jan 16, 2007 *

          */ public class TestListener implements SocketCreationListener { private static Logger log = Logger.getLogger(TestListener.class); private boolean visited; private boolean client; public void socketCreated(Socket socket, Object source) throws IOException { visited = true; if (source instanceof SocketFactory) client = true; else if (source instanceof ServerSocket) client = false; else log.error("unrecognized socket source: " + source); log.info(this + ": " + source); } public boolean visited() { return visited; } public boolean isClient() { return client; } public void reset() { visited = false; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/StaticTestListener.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/StaticTestList0000644000175000017500000000316510553325646033577 0ustar twernertwerner/* * 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.socketfactory; import java.io.IOException; import java.net.Socket; import org.jboss.remoting.socketfactory.SocketCreationListener; /** * @author Ron Sigal * @version $Revision: 1885 $ *

          * Copyright Jan 16, 2007 *

          */ public class StaticTestListener implements SocketCreationListener { private static boolean visited; public void socketCreated(Socket socket, Object source) throws IOException { visited = true; } public static boolean visited() { return visited; } public static void reset() { visited = false; } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/SSLCreationListenerTestRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/SSLCreationLis0000644000175000017500000000435010553067761033450 0ustar twernertwerner/* * 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.socketfactory; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocketFactory; /** * @author Ron Sigal * @version $Revision: 1846 $ *

          * Copyright Jan 12, 2007 *

          */ public abstract class SSLCreationListenerTestRoot extends CreationListenerTestRoot { public void setUp() throws Exception { super.setUp(); String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client"); String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile(); System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath); System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server"); System.setProperty("org.jboss.security.ignoreHttpsHost", "true"); } protected SocketFactory getSocketFactory() { return SSLSocketFactory.getDefault(); } protected ServerSocketFactory getServerSocketFactory() { return SSLServerSocketFactory.getDefault(); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFa0000644000175000017500000002421511413660476033457 0ustar twernertwerner/* * 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.socketfactory; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; 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.Remoting; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.socketfactory.SocketCreationListener; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit tests for JBREM-1121. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Apr 21, 2009 *

          */ public class UseAllSocketFactoryParamsTestCase extends TestCase { private static Logger log = Logger.getLogger(UseAllSocketFactoryParamsTestCase.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); } TestSocketCreationListener.called = false; } public void tearDown() { } public void testDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, null); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); log.info("clientConfig: " + 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"); // Verify that TestSocketCreationListener was called. assertFalse(TestSocketCreationListener.called); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllSocketFactoryParamsFalseInLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "false"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); log.info("clientConfig: " + 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"); // Verify that TestSocketCreationListener was called. assertFalse(TestSocketCreationListener.called); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllSocketFactoryParamsFalseInConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, null); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Remoting.USE_ALL_SOCKET_FACTORY_PARAMS, "false"); addExtraClientConfig(clientConfig); log.info("clientConfig: " + 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"); // Verify that TestSocketCreationListener was called. assertFalse(TestSocketCreationListener.called); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllSocketFactoryParamsTrueInLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); log.info("clientConfig: " + 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"); // Verify that TestSocketCreationListener was called. assertTrue(TestSocketCreationListener.called); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testUseAllSocketFactoryParamsTrueInConfig() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, null); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Remoting.USE_ALL_SOCKET_FACTORY_PARAMS, "true"); addExtraClientConfig(clientConfig); log.info("clientConfig: " + 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"); // Verify that TestSocketCreationListener was called. assertTrue(TestSocketCreationListener.called); 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(boolean setUseAllParams, String useAllParams) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?" + Remoting.SOCKET_CREATION_CLIENT_LISTENER + "=" + TestSocketCreationListener.class.getName(); String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "&" + metadata; } if (setUseAllParams) { locatorURI += "&" + Remoting.USE_ALL_SOCKET_FACTORY_PARAMS + "=" + useAllParams; } 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) {} } public static class TestSocketCreationListener implements SocketCreationListener { static public boolean called; public TestSocketCreationListener() { log.info("TestSocketCreationListener created"); } public void socketCreated(Socket socket, Object source) throws IOException { called = true; log.info("TestSocketCreationListener called"); } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryC0000644000175000017500000002532411413660476033537 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2008, 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.socketfactory; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.net.SocketFactory; 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.AbstractInvoker; 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.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1014. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jul 18, 2008 *

          */ public abstract class SocketFactoryClassNameTestRoot extends TestCase { private static Logger log = Logger.getLogger(SocketFactoryClassNameTestRoot.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 testSocketFactoryClassNameInLocator() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&" + Remoting.SOCKET_FACTORY_CLASS_NAME + "=" + getSocketFactoryClass().getName(); 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(); log.info("client is connected to " + clientLocatorURI); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify client invoker is using configured SocketFactory. AbstractInvoker invoker = (AbstractInvoker) client.getInvoker(); SocketFactory socketFactory = invoker.getSocketFactory(); log.info("SocketFactory: " + socketFactory); assertTrue(getSocketFactoryClass().isInstance(socketFactory)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testSocketFactoryClassNameInConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Remoting.SOCKET_FACTORY_CLASS_NAME, getSocketFactoryClass().getName()); 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"); // Verify client invoker is using configured SocketFactory. AbstractInvoker invoker = (AbstractInvoker) client.getInvoker(); SocketFactory socketFactory = invoker.getSocketFactory(); log.info("SocketFactory: " + socketFactory); assertTrue(getSocketFactoryClass().isInstance(socketFactory)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testSocketFactoryClassNameInLocatorWithUseAllParams() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // Create client. String clientLocatorURI = locatorURI; clientLocatorURI += "&" + Remoting.SOCKET_FACTORY_CLASS_NAME + "=" + getSocketFactoryClass().getName(); 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(); log.info("client is connected to " + clientLocatorURI); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); // Verify client invoker is using configured SocketFactory. AbstractInvoker invoker = (AbstractInvoker) client.getInvoker(); SocketFactory socketFactory = invoker.getSocketFactory(); log.info("SocketFactory: " + socketFactory); assertTrue(getSocketFactoryClass().isInstance(socketFactory)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testSocketFactoryClassNameInConfigMapWithUseAllParams() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Remoting.SOCKET_FACTORY_CLASS_NAME, getSocketFactoryClass().getName()); 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"); // Verify client invoker is using configured SocketFactory. AbstractInvoker invoker = (AbstractInvoker) client.getInvoker(); SocketFactory socketFactory = invoker.getSocketFactory(); log.info("SocketFactory: " + socketFactory); assertTrue(getSocketFactoryClass().isInstance(socketFactory)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected abstract String getTransport(); protected Class getSocketFactoryClass() { return TestSocketFactory.class; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(boolean useAllParams) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port + "/?x=x"; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "&" + metadata; } if (useAllParams) { locatorURI += "&" + Remoting.USE_ALL_SOCKET_FACTORY_PARAMS + "=true"; } 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) {} } public static class TestSocketFactory extends SocketFactory { SocketFactory sf = SocketFactory.getDefault(); public TestSocketFactory() { } public Socket createSocket() throws IOException, UnknownHostException { return sf.createSocket(); } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { return sf.createSocket(arg0, arg1); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { return sf.createSocket(arg0, arg1); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { return sf.createSocket(arg0, arg1, arg2, arg3); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { return sf.createSocket(arg0, arg1, arg2, arg3); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/0000755000175000017500000000000011632407043027636 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/http/0000755000175000017500000000000011632407043030615 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/http/metadata/0000755000175000017500000000000011632407043032375 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/http/metadata/HTTPUnMarshallerMock.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/http/metadata/HTTPU0000644000175000017500000000370210624443615033233 0ustar twernertwerner/* * 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.marshall.http.metadata; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; /** * @author Tom Elrod */ public class HTTPUnMarshallerMock extends HTTPUnMarshaller { private Map metadata = new HashMap(); /** * Will try to unmarshall data from inputstream. Will try to convert to either an object * or a string. If there is no data to read, will return null. * * @param inputStream * @return * @throws java.io.IOException * @throws ClassNotFoundException */ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); this.metadata.putAll(metadata); return ret; } public Map getMetadata() { return metadata; } }././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/http/metadata/HTTPUnMarshallerMetadataTestCase_Retired.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/http/metadata/HTTPU0000644000175000017500000001222610766557755033256 0ustar twernertwerner/* * 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.marshall.http.metadata; import junit.framework.TestCase; import org.apache.log4j.Level; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; /** * Test case that uses the HTTPInvoker client to call on two different public SOAP services (one based * on Axis and the other based on .NET implementations). * * @author Tom Elrod */ public class HTTPUnMarshallerMetadataTestCase_Retired extends TestCase { private Client client; public void init(String httpTargetURL, HTTPUnMarshallerMock unmarshaller) { try { InvokerLocator locator = new InvokerLocator(httpTargetURL); client = new Client(locator); client.connect(); client.setUnMarshaller(unmarshaller); client.connect(); } catch(Exception e) { e.printStackTrace(); } } public String makeInvocationCall(String httpTargetURL, String payload, Map metadata, HTTPUnMarshallerMock unmarshaller) throws Throwable { init(httpTargetURL, unmarshaller); Object obj = client.invoke(payload, metadata); System.out.println("invoke returned" + obj); return (String) obj; } public void testWeatherHTTPInvocation() throws Throwable { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG); String testURL = "http://services.xmethods.net:80/soap/servlet/rpcrouter"; String xml = "\n" + "\n" + " \n" + " \n" + " 30106\n" + " \n" + " \n" + ""; Map metadata = new HashMap(); metadata.put(Client.RAW, Boolean.TRUE); metadata.put("TYPE", "POST"); Properties headerProps = new Properties(); headerProps.put("SOAPAction", ""); headerProps.put("Content-type", "text/xml; charset=UTF-8"); metadata.put("HEADER", headerProps); HTTPUnMarshallerMetadataTestCase_Retired client = new HTTPUnMarshallerMetadataTestCase_Retired(); HTTPUnMarshallerMock unmarshaller = new HTTPUnMarshallerMock(); String result = client.makeInvocationCall(testURL, xml, metadata, unmarshaller); // expect to get the following header assertNotNull(unmarshaller.getMetadata()); List header = (List) unmarshaller.getMetadata().get("Status"); assertEquals("200", header.get(0)); // don't need to comapre full string. (as actual temp value will change each time run) assertEquals(getExpectedWeatherResult().substring(0, 380), result.substring(0, 380)); } private String getExpectedWeatherResult() { return "" + "" + "" + "" + "60.0" + "" + "\n" + "\n" + ""; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/serializable/0000755000175000017500000000000011632407043032304 5ustar twernertwerner././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/serializable/SerializableMarshallingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/serializable/Serial0000644000175000017500000000514210355142433033450 0ustar twernertwerner/* * 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.marshall.serializable; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import junit.framework.TestCase; /** * @author Tom Elrod */ public class SerializableMarshallingTestCase extends TestCase { private Marshaller marshaller; private UnMarshaller unmarshaller; protected void setUp() throws Exception { super.setUp(); marshaller = MarshalFactory.getMarshaller(SerializableMarshaller.DATATYPE); unmarshaller = MarshalFactory.getUnMarshaller(SerializableUnMarshaller.DATATYPE); } public void testMarshalling() throws IOException, ClassNotFoundException { String testData = "This is some test data"; Object param = new String(testData); ByteArrayOutputStream output = new ByteArrayOutputStream(); marshaller.write(param, output); byte[] byteArray = new byte[output.size()]; byteArray = output.toByteArray(); ByteArrayInputStream input = new ByteArrayInputStream(byteArray); Object result = unmarshaller.read(input, null); System.out.println("Result: " + result); assertEquals(testData, result); } protected void tearDown() throws Exception { super.tearDown(); marshaller = null; unmarshaller = null; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/0000755000175000017500000000000011632407043031262 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/0000755000175000017500000000000011632407043032354 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/MarshallerLoadingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/Marsh0000644000175000017500000000546110774615370033371 0ustar twernertwerner/* * 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.marshall.dynamic.local; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; 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 MarshallerLoadingTestCase extends TestDriver { /** * Returns the classpath to be added to the classpath used to start the client tests. * Default return is null, which means no extra classpath will be added. * * @return */ protected String getExtendedServerClasspath() { String path = null; try { path = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return System.getProperty("loader.path"); } }); } catch (PrivilegedActionException e) { } return path; } /** * Returns the classpath to be added to the classpath used to start the client tests. * Default return is null, which means no extra classpath will be added. * * @return */ protected String getExtendedClientClasspath() { return System.getProperty("loader.path"); } public void declareTestClasses() { addTestClasses(MarshallerLoadingClient.class.getName(), 1, MarshallerLoadingServer.class.getName()); } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/MarshallerLoadingConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/Marsh0000644000175000017500000000342510355142433033355 0ustar twernertwerner/* * 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.marshall.dynamic.local; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public interface MarshallerLoadingConstants { // Default locator values static String transport = "socket"; static String host = "localhost"; static int port = 5300; static String dataType = "test"; static String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.DATATYPE + "=" + dataType + "&" + InvokerLocator.MARSHALLER + "=" + "org.jboss.test.remoting.marshall.dynamic.local.TestMarshaller" + "&" + InvokerLocator.UNMARSHALLER + "=" + "org.jboss.test.remoting.marshall.dynamic.local.TestUnMarshaller"; } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/TestMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/TestM0000644000175000017500000000370510624443567033353 0ustar twernertwerner/* * 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.marshall.dynamic.local; import java.io.IOException; import java.io.OutputStream; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; /** * @author Tom Elrod */ public class TestMarshaller extends SerializableMarshaller { public final static String DATATYPE = "test"; //private TestWrapper wrapper = null; /** * Take the data object and write to the output. Has ben customized * for working with ObjectOutputStreams since requires extra messaging. * * @param dataObject Object to be writen to output * @param output The data output to write the object * data to. */ public void write(Object dataObject, OutputStream output, int version) throws IOException { TestWrapper wrapper = new TestWrapper(dataObject); super.write(wrapper, output, version); } public String getDataType() { return DATATYPE; } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/TestWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/TestW0000644000175000017500000000254410355142433033352 0ustar twernertwerner/* * 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.marshall.dynamic.local; import java.io.Serializable; /** * @author Tom Elrod */ public class TestWrapper implements Serializable { private Object payload = null; public TestWrapper(Object payload) { this.payload = payload; } public Object getPayload() { return payload; } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/TestUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/TestU0000644000175000017500000000315410624443615033353 0ustar twernertwerner/* * 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.marshall.dynamic.local; import java.io.IOException; import java.io.InputStream; import java.util.Map; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; /** * @author Tom Elrod */ public class TestUnMarshaller extends SerializableUnMarshaller { public final static String DATATYPE = "test"; public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); ret = ((TestWrapper) ret).getPayload(); return ret; } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/MarshallerLoadingServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/Marsh0000644000175000017500000001464610355142433033364 0ustar twernertwerner/* * 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.marshall.dynamic.local; import java.io.IOException; import java.util.Enumeration; import javax.management.MBeanServer; import org.apache.log4j.Level; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; 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; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class MarshallerLoadingServer extends ServerTestCase implements MarshallerLoadingConstants { private Connector connector; private static final Logger log = Logger.getLogger(MarshallerLoadingServer.class); // 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); log.info("Starting remoting server with locator uri of: " + locatorURI); Connector 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); } public void setUp() throws Exception { setupServer(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void setLogging() { 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.jboss.remoting.marshall.dynamic.local").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jboss.dtf").setLevel(Level.DEBUG); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); org.apache.log4j.SimpleLayout layout = new org.apache.log4j.SimpleLayout(); try { org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, getClass().getName() + "_output.log"); fileAppender.setThreshold(Level.DEBUG); org.apache.log4j.Category.getRoot().addAppender(fileAppender); } catch(IOException e) { e.printStackTrace(); } // org.apache.log4j.ConsoleAppender consoleAppender = new org.apache.log4j.ConsoleAppender(); // consoleAppender.setThreshold(Level.INFO); // org.apache.log4j.Category.getRoot().addAppender(consoleAppender); //System.out.println("Root log level = " + org.apache.log4j.Category.getRoot().getLevel()); Enumeration appenders = org.apache.log4j.Category.getRoot().getAllAppenders(); while(appenders.hasMoreElements()) { org.apache.log4j.Appender appender = (org.apache.log4j.Appender) appenders.nextElement(); //System.out.println(appender.getName()); if(appender instanceof org.apache.log4j.ConsoleAppender) { ((org.apache.log4j.ConsoleAppender) appender).setThreshold(Level.INFO); } } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } /** * 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 } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/MarshallerLoadingClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/local/Marsh0000644000175000017500000000371010433770344033357 0ustar twernertwerner/* * 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.marshall.dynamic.local; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class MarshallerLoadingClient extends TestCase implements MarshallerLoadingConstants { public void testInvocation() throws Throwable { Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); Object response = remotingClient.invoke("Do something", null); assertTrue(true); System.out.println("Invocation response: " + response); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/0000755000175000017500000000000011632407043032555 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/socket/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/sock0000755000175000017500000000000011632407043033435 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/socket/TestObject.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/sock0000644000175000017500000000300610355142433033436 0ustar twernertwerner/* * 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.marshall.dynamic.remote.socket; import java.io.Serializable; import java.util.Random; /** * @author Tom Elrod */ public class TestObject implements Serializable { private int id = 0; private String identifier = null; public TestObject() { id = new Random().nextInt(); identifier = String.valueOf(id); } public String toString() { return "TestObject (" + super.toString() + "): id = " + id + ", identifier = " + identifier; } }././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/socket/MarshallerLoadingConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/sock0000644000175000017500000000363610355142433033447 0ustar twernertwerner/* * 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.marshall.dynamic.remote.socket; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public interface MarshallerLoadingConstants { // Default locator values static String transport = "socket"; static String host = "localhost"; static int port = 5400; static int loaderPort = 5401; static String dataType = "test"; static String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.DATATYPE + "=" + dataType + "&" + InvokerLocator.LOADER_PORT + "=" + loaderPort + "&" + InvokerLocator.MARSHALLER + "=" + "org.jboss.test.remoting.marshall.dynamic.remote.socket.TestMarshaller" + "&" + InvokerLocator.UNMARSHALLER + "=" + "org.jboss.test.remoting.marshall.dynamic.remote.socket.TestUnMarshaller"; ; } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/socket/TestMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/sock0000644000175000017500000000402110624443567033447 0ustar twernertwerner/* * 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.marshall.dynamic.remote.socket; import java.io.IOException; import java.io.OutputStream; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.test.remoting.marshall.dynamic.remote.TestWrapper; /** * @author Tom Elrod */ public class TestMarshaller extends SerializableMarshaller { public final static String DATATYPE = "test"; //private TestWrapper wrapper = null; /** * Take the data object and write to the output. Has ben customized * for working with ObjectOutputStreams since requires extra messaging. * * @param dataObject Object to be writen to output * @param output The data output to write the object * data to. */ public void write(Object dataObject, OutputStream output, int version) throws IOException { TestWrapper wrapper = new TestWrapper(dataObject); super.write(wrapper, output, version); } public String getDataType() { return DATATYPE; } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/socket/TestUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/sock0000644000175000017500000000327010624443615033446 0ustar twernertwerner/* * 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.marshall.dynamic.remote.socket; import java.io.IOException; import java.io.InputStream; import java.util.Map; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import org.jboss.test.remoting.marshall.dynamic.remote.TestWrapper; /** * @author Tom Elrod */ public class TestUnMarshaller extends SerializableUnMarshaller { public final static String DATATYPE = "test"; public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); ret = ((TestWrapper) ret).getPayload(); return ret; } }././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/socket/MarshallerLoadingServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/sock0000644000175000017500000001320111047673207033443 0ustar twernertwerner/* * 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.marshall.dynamic.remote.socket; 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.InvokerCallbackHandler; import org.jboss.remoting.loading.RemotingClassLoader; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class MarshallerLoadingServer extends ServerTestCase implements MarshallerLoadingConstants { private Connector connector; // String to be returned from invocation handler upon client invocation calls. private static Object RESPONSE_VALUE = null; public void setupServer() throws Exception { System.out.println("locatorURI: " + locatorURI); String newLocatorURI = locatorURI; String metadata = System.getProperty("remoting.metadata"); System.out.println("metadata: " + metadata); if(metadata != null) { newLocatorURI += "&" + metadata; } InvokerLocator locator = new InvokerLocator(newLocatorURI); System.out.println("Starting remoting server with locator uri of: " + newLocatorURI); 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); } public void setUp() throws Exception { setResponseObject(); setupServer(); } private void setResponseObject() throws ClassNotFoundException, IllegalAccessException, InstantiationException { // Class testObjClass = Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.socket.TestObject"); RemotingClassLoader loader = new RemotingClassLoader(MarshallerLoadingServer.class.getClassLoader(), Thread.currentThread().getContextClassLoader()); Class testObjClass = Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.socket.TestObject", false, loader); RESPONSE_VALUE = testObjClass.newInstance(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { MarshallerLoadingServer server = new MarshallerLoadingServer(); try { server.setUp(); while(true) { Thread.currentThread().sleep(5000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } /** * 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 } } }././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/socket/MarshallerLoadingClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/sock0000644000175000017500000000554211047672703033454 0ustar twernertwerner/* * 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.marshall.dynamic.remote.socket; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class MarshallerLoadingClient extends TestCase implements MarshallerLoadingConstants { public void testInvocation() throws Throwable { Client remotingClient = null; // first, make sure can not load marshaller from current classpath try { Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.socket.TestMarshaller"); assertTrue("Was able to load the TestMarshaller class locally, when it should NOT be on the classpath.", false); Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.socket.TestObject"); assertTrue("Was able to load the TestObject class locally, when it should NOT be on the classpath.", false); return; } catch(ClassNotFoundException e) { assertTrue("Was not able to load TestMarshaller from local classpath as expected.", true); } try { String newLocatorURI = locatorURI; String metadata = System.getProperty("remoting.metadata"); if(metadata != null) { newLocatorURI += "&" + metadata; } InvokerLocator locator = new InvokerLocator(newLocatorURI); System.out.println("Calling remoting server with locator uri of: " + newLocatorURI); remotingClient = new Client(locator); remotingClient.connect(); Object response = remotingClient.invoke("Do something", null); assertTrue(true); System.out.println("Invocation response: " + response); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } }././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/socket/SocketMarshallerLoadingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/sock0000644000175000017500000000567411047673275033467 0ustar twernertwerner/* * 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.marshall.dynamic.remote.socket; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; 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 SocketMarshallerLoadingTestCase extends TestDriver { /** * Returns the classpath to be added to the classpath used to start the client tests. * Default return is null, which means no extra classpath will be added. * * @return */ protected String getExtendedServerClasspath() { String path = null; try { path = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return System.getProperty("loader.path"); } }); } catch (PrivilegedActionException e) { } return path; } public void declareTestClasses() { addTestClasses(MarshallerLoadingClient.class.getName(), 1, MarshallerLoadingServer.class.getName()); } protected String getClientJVMArguments() { return getJVMArguments(); } protected String getServerJVMArguments() { return getJVMArguments(); } protected String getJVMArguments() { String vmArgs = ""; String metadata = System.getProperty("remoting.metadata"); if(metadata != null && metadata.length() > 0) { vmArgs = "-Dremoting.metadata=" + metadata; } return vmArgs; } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http0000755000175000017500000000000011632407043033455 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http/TestObject.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http0000644000175000017500000000300410355142433033454 0ustar twernertwerner/* * 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.marshall.dynamic.remote.http; import java.io.Serializable; import java.util.Random; /** * @author Tom Elrod */ public class TestObject implements Serializable { private int id = 0; private String identifier = null; public TestObject() { id = new Random().nextInt(); identifier = String.valueOf(id); } public String toString() { return "TestObject (" + super.toString() + "): id = " + id + ", identifier = " + identifier; } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http/MarshallerLoadingConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http0000644000175000017500000000362610355142433033466 0ustar twernertwerner/* * 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.marshall.dynamic.remote.http; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public interface MarshallerLoadingConstants { // Default locator values static String transport = "http"; static String host = "localhost"; static int port = 5402; static int loaderPort = 5403; static String dataType = "test"; static String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.DATATYPE + "=" + dataType + "&" + InvokerLocator.LOADER_PORT + "=" + loaderPort + "&" + InvokerLocator.MARSHALLER + "=" + "org.jboss.test.remoting.marshall.dynamic.remote.http.TestMarshaller" + "&" + InvokerLocator.UNMARSHALLER + "=" + "org.jboss.test.remoting.marshall.dynamic.remote.http.TestUnMarshaller"; ; } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http/HTTPMarshallerLoadingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http0000644000175000017500000000567011047672527033502 0ustar twernertwerner/* * 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.marshall.dynamic.remote.http; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; 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 HTTPMarshallerLoadingTestCase extends TestDriver { /** * Returns the classpath to be added to the classpath used to start the client tests. * Default return is null, which means no extra classpath will be added. * * @return */ protected String getExtendedServerClasspath() { String path = null; try { path = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return System.getProperty("loader.path"); } }); } catch (PrivilegedActionException e) { } return path; } public void declareTestClasses() { addTestClasses(MarshallerLoadingClient.class.getName(), 1, MarshallerLoadingServer.class.getName()); } protected String getClientJVMArguments() { return getJVMArguments(); } protected String getServerJVMArguments() { return getJVMArguments(); } protected String getJVMArguments() { String vmArgs = ""; String metadata = System.getProperty("remoting.metadata"); if(metadata != null && metadata.length() > 0) { vmArgs = "-Dremoting.metadata=" + metadata; } return vmArgs; } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http/TestMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http0000644000175000017500000000376710624443567033507 0ustar twernertwerner/* * 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.marshall.dynamic.remote.http; import java.io.IOException; import java.io.OutputStream; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.test.remoting.marshall.dynamic.remote.TestWrapper; /** * @author Tom Elrod */ public class TestMarshaller extends HTTPMarshaller { public final static String DATATYPE = "test"; //private TestWrapper wrapper = null; /** * Take the data object and write to the output. Has ben customized * for working with ObjectOutputStreams since requires extra messaging. * * @param dataObject Object to be writen to output * @param output The data output to write the object * data to. */ public void write(Object dataObject, OutputStream output, int version) throws IOException { TestWrapper wrapper = new TestWrapper(dataObject); super.write(wrapper, output, version); } public String getDataType() { return DATATYPE; } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http/TestUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http0000644000175000017500000000323610624443615033470 0ustar twernertwerner/* * 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.marshall.dynamic.remote.http; import java.io.IOException; import java.io.InputStream; import java.util.Map; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.test.remoting.marshall.dynamic.remote.TestWrapper; /** * @author Tom Elrod */ public class TestUnMarshaller extends HTTPUnMarshaller { public final static String DATATYPE = "test"; public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object ret = super.read(inputStream, metadata, version); ret = ((TestWrapper) ret).getPayload(); return ret; } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http/MarshallerLoadingServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http0000644000175000017500000001304111047672640033465 0ustar twernertwerner/* * 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.marshall.dynamic.remote.http; 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.InvokerCallbackHandler; import org.jboss.remoting.loading.RemotingClassLoader; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class MarshallerLoadingServer extends ServerTestCase implements MarshallerLoadingConstants { private Connector connector; // String to be returned from invocation handler upon client invocation calls. private static Object RESPONSE_VALUE = null; public void setupServer() throws Exception { System.out.println("locatorURI: " + locatorURI); String newLocatorURI = locatorURI; String metadata = System.getProperty("remoting.metadata"); System.out.println("metadata: " + metadata); if(metadata != null) { newLocatorURI += "&" + metadata; } InvokerLocator locator = new InvokerLocator(newLocatorURI); System.out.println("Starting remoting server with locator uri of: " + newLocatorURI); 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); } public void setUp() throws Exception { setResponseObject(); setupServer(); } private void setResponseObject() throws ClassNotFoundException, IllegalAccessException, InstantiationException { // Class testObjClass = Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.http.TestObject"); RemotingClassLoader loader = new RemotingClassLoader(MarshallerLoadingServer.class.getClassLoader(), Thread.currentThread().getContextClassLoader()); Class testObjClass = Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.socket.TestObject", false, loader); RESPONSE_VALUE = testObjClass.newInstance(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { MarshallerLoadingServer server = new MarshallerLoadingServer(); try { server.setUp(); } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } /** * 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 } } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http/MarshallerLoadingClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/http0000644000175000017500000001005611047672606033472 0ustar twernertwerner/* * 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.marshall.dynamic.remote.http; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class MarshallerLoadingClient extends TestCase implements MarshallerLoadingConstants { public void testInvocation() throws Throwable { Client remotingClient = null; // first, make sure can not load marshaller from current classpath try { Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.http.TestMarshaller"); assertTrue("Was able to load the TestMarshaller class locally, when it should NOT be on the classpath.", false); Class.forName("org.jboss.test.remoting.marshall.dynamic.remote.http.TestObject"); assertTrue("Was able to load the TestObject class locally, when it should NOT be on the classpath.", false); return; } catch(ClassNotFoundException e) { assertTrue("Was not able to load TestMarshaller from local classpath as expected.", true); } try { String newLocatorURI = locatorURI; String metadata = System.getProperty("remoting.metadata"); if(metadata != null) { newLocatorURI += "&" + metadata; } InvokerLocator locator = new InvokerLocator(newLocatorURI); System.out.println("Calling remoting server with locator uri of: " + newLocatorURI); remotingClient = new Client(locator); remotingClient.connect(); Object response = remotingClient.invoke("Do something", null); assertTrue(true); System.out.println("Invocation response: " + response); } finally { if(remotingClient != null) { remotingClient.disconnect(); } } } public static void main(String[] args) { MarshallerLoadingClient client = new MarshallerLoadingClient(); try { client.testInvocation(); } catch(Throwable throwable) { throwable.printStackTrace(); } } /** * Can pass transport and port to be used as parameters. * Valid transports are 'rmi' and 'socket'. * * @param args */ // public static void main(String[] args) // { // org.apache.log4j.BasicConfigurator.configure(); // org.apache.log4j.Category.getRoot().setLevel(Level.INFO); // org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG); // // /* // if(args != null && args.length == 2) // { // transport = args[0]; // port = Integer.parseInt(args[1]); // } // */ // MarshallerLoadingClient client = new MarshallerLoadingClient(MarshallerLoadingClient.class.getName()); // try // { // MultipleTestRunner runner = new MultipleTestRunner(); // runner.doRun(client, true); // } // catch(Throwable e) // { // e.printStackTrace(); // System.exit(1); // } // System.exit(0); // } // }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/TestWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/Test0000644000175000017500000000254510355142433033425 0ustar twernertwerner/* * 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.marshall.dynamic.remote; import java.io.Serializable; /** * @author Tom Elrod */ public class TestWrapper implements Serializable { private Object payload = null; public TestWrapper(Object payload) { this.payload = payload; } public Object getPayload() { return payload; } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/clas0000755000175000017500000000000011632407043033420 5ustar twernertwerner././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/InjectedClassloadersTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/clas0000644000175000017500000002616411413660476033443 0ustar twernertwerner/* * 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.marshall.dynamic.remote.classloaders; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; 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.ServerConfiguration; 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 test for JBREM-1000. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Aug 9, 2008 *

          */ public class InjectedClassloadersTestCase extends TestCase { private static Logger log = Logger.getLogger(InjectedClassloadersTestCase.class); private static String jarFileName; private static String targetClassName = "org.jboss.test.remoting.marshall.dynamic.remote.classloaders.ResponseImpl"; private static final int BY_DIRECT_INJECTION = 1; private static final int BY_SERVER_CONFIGURATION = 2; private static final int BY_CONFIG_MAP = 3; private static Object RESPONSE_VALUE; private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestClassLoader1 classLoader1; protected TestClassLoader2 classLoader2; protected TestInvocationHandler invocationHandler; public static void main(String[] args) { InjectedClassloadersTestCase server = new InjectedClassloadersTestCase(); try { server.setUp(); while(true) { Thread.sleep(5000); } } catch(Exception e) { e.printStackTrace(); } } 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); jarFileName = getSystemProperty("loader.path"); ClassLoader cl = new TestClassLoader2(getClass().getClassLoader(), jarFileName, targetClassName); Class c = Class.forName(targetClassName, false, cl); RESPONSE_VALUE = c.newInstance(); } } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void testByDirectInjection() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(BY_DIRECT_INJECTION); // 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"); // Verify that unmarshaller can get ResponseImpl class. Object response = client.invoke("abc"); log.info("response: " + response); assertEquals(targetClassName, response.getClass().getName()); // Verify that MarshallerLoaderHandler tried both configured classLoaders. assertTrue(classLoader1.queriedForTarget); assertTrue(classLoader2.queriedForTarget); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testByServerConfiguration() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(BY_SERVER_CONFIGURATION); // 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"); // Verify that unmarshaller can get ResponseImpl class. Object response = client.invoke("abc"); log.info("response: " + response); assertEquals(targetClassName, response.getClass().getName()); // Verify that MarshallerLoaderHandler tried both configured classLoaders. assertTrue(classLoader1.queriedForTarget); assertTrue(classLoader2.queriedForTarget); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testByConfigMap() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(BY_CONFIG_MAP); // 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"); // Verify that unmarshaller can get ResponseImpl class. Object response = client.invoke("abc"); log.info("response: " + response); assertEquals(targetClassName, response.getClass().getName()); // Verify that MarshallerLoaderHandler tried both configured classLoaders. assertTrue(classLoader1.queriedForTarget); assertTrue(classLoader2.queriedForTarget); 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(int configMethod) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); String loaderPort = Integer.toString(PortUtil.findFreePort(host)); locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?" + InvokerLocator.LOADER_PORT + "=" + loaderPort; serverLocator = new InvokerLocator(locatorURI); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); ArrayList classLoaders = new ArrayList(); classLoader1 = new TestClassLoader1(targetClassName); classLoader2 = new TestClassLoader2(getClass().getClassLoader(), jarFileName, targetClassName); classLoaders.add(classLoader1); classLoaders.add(classLoader2); switch (configMethod) { case BY_DIRECT_INJECTION: log.info("injecting: BY_DIRECT_INJECTION"); connector = new Connector(serverLocator, config); connector.setRemoteClassLoaders(classLoaders); break; case BY_SERVER_CONFIGURATION: log.info("injecting: BY_SERVER_CONFIGURATION"); ServerConfiguration serverConfiguration = new ServerConfiguration(getTransport()); Map serverParameters = new HashMap(); serverParameters.put(Remoting.REMOTE_CLASS_LOADERS, classLoaders); serverConfiguration.setServerParameters(serverParameters); Map invokerLocatorParameters = new HashMap(); invokerLocatorParameters.put(InvokerLocator.LOADER_PORT, loaderPort); serverConfiguration.setInvokerLocatorParameters(invokerLocatorParameters); connector = new Connector(config); connector.setServerConfiguration(serverConfiguration); break; case BY_CONFIG_MAP: log.info("injecting: BY_CONFIG_MAP"); config.put(Remoting.REMOTE_CLASS_LOADERS, classLoaders); connector = new Connector(locatorURI, config); break; default: log.error("unrecognized configMethod: " + configMethod); return; } connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); locatorURI = connector.getInvokerLocator(); log.info("Started remoting server with locator uri of: " + locatorURI); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } private String getSystemProperty(final String name) { String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static class TestInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) {} public Object invoke(final InvocationRequest invocation) throws Throwable { return RESPONSE_VALUE; } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/ResponseImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/clas0000644000175000017500000000266211413660476033440 0ustar twernertwerner /* * 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.marshall.dynamic.remote.classloaders; import java.io.Serializable; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Aug 8, 2008 *

          */ public class ResponseImpl implements Response, Serializable { /** The serialVersionUID */ private static final long serialVersionUID = -1012825226667853526L; public Object getResult() { return "result"; } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader1.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/clas0000644000175000017500000000435011413660476033434 0ustar twernertwerner /* * 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.marshall.dynamic.remote.classloaders; import java.io.InputStream; import org.apache.log4j.Logger; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Aug 8, 2008 *

          */ public class TestClassLoader1 extends ClassLoader { public boolean queriedForTarget; private static Logger log = Logger.getLogger(TestClassLoader1.class); private String targetClassName; private String targetClassFileName; public TestClassLoader1(String targetClassName) { this.targetClassName = targetClassName; this.targetClassFileName = targetClassName.replace('.', '/') + ".class"; } protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { log.info(this + " queried for class: " + name); if (targetClassName.equals(name)) { queriedForTarget = true; } return null; } public InputStream getResourceAsStream(String name) { log.info(this + " queried for resource InputStream: " + name); if (targetClassFileName.equals(name)) { log.info(this + " looking for resource InputStream: " + name); queriedForTarget = true; } return null; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/Response.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/clas0000644000175000017500000000235311413660476033435 0ustar twernertwerner /* * 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.marshall.dynamic.remote.classloaders; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Aug 8, 2008 *

          */ public interface Response { public Object getResult(); } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/classloaders/TestClassLoader2.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/dynamic/remote/clas0000644000175000017500000001252511413660476033437 0ustar twernertwerner /* * 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.marshall.dynamic.remote.classloaders; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.jar.JarInputStream; import java.util.zip.ZipEntry; import org.apache.log4j.Logger; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Aug 8, 2008 *

          */ public class TestClassLoader2 extends ClassLoader { public boolean queriedForTarget; private static Logger log = Logger.getLogger(TestClassLoader2.class); private String jarFileName; private String targetClassName; private String targetClassFileName; public static void main(String[] args) { String jarFileName = "C:/cygwin/home/rsigal/workspace/JBossRemoting-2.x/output/lib/jboss-remoting-loading-tests.jar"; String className = "org.jboss.test.remoting.marshall.dynamic.remote.classloaders.ResponseImpl"; ClassLoader cl = TestClassLoader2.class.getClassLoader(); TestClassLoader2 tcl2 = new TestClassLoader2(cl, jarFileName, className); try { Class c = tcl2.loadClass(className); Object o = c.newInstance(); log.info("new object: " + o); } catch (Exception e) { e.printStackTrace(); } } public TestClassLoader2(ClassLoader parent, String jarFileName, String targetClassName) { super(parent); this.jarFileName = jarFileName; this.targetClassName = targetClassName; this.targetClassFileName = targetClassName.replace('.', '/') + ".class"; } public InputStream getResourceAsStream(String name) { try { log.info(this + " queried for resource InputStream: " + name); if (targetClassFileName.equals(name)) { log.info(this + " looking for resource InputStream: " + name); queriedForTarget = true; byte[] bytecode = loadByteCodeFromClassFileName(name); log.info(this + " returning resource InputStream: " + name); return new ByteArrayInputStream(bytecode); } else { return super.getResourceAsStream(name); } } catch (Exception e) { log.error(this + " unable to find resource: " + name); return null; } } protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { try { log.info(this + " queried for class: " + name); if (targetClassName.equals(name)) { log.info(this + " loading class: " + name); queriedForTarget = true; byte[] bytes = loadByteCodeFromClassName(name); Class c = defineClass(name, bytes, 0, bytes.length); if (resolve) { resolveClass(c); } return c; } else { return super.loadClass(name, resolve); } } catch (IOException e) { throw new ClassNotFoundException(name); } } private byte[] loadByteCodeFromClassName(String classname) throws ClassNotFoundException, IOException { String classFileName = classname.replace('.', '/') + ".class"; return loadByteCodeFromClassFileName(classFileName); } private byte[] loadByteCodeFromClassFileName(String classFileName) throws ClassNotFoundException, IOException { File file = new File(jarFileName); JarInputStream jis = new JarInputStream(new FileInputStream(file)); ZipEntry entry = jis.getNextEntry(); try { while (entry != null) { log.info("name: " + entry.getName()); if (classFileName.equals(entry.getName())) break; entry = jis.getNextEntry(); } log.info("size: " + entry.getSize()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] tmp = new byte[1024]; int read = 0; while( (read = jis.read(tmp)) > 0 ) { baos.write(tmp, 0, read); } byte[] bytecode = baos.toByteArray(); return bytecode; } finally { if( jis != null ) jis.close(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/0000755000175000017500000000000011632407043031103 5ustar twernertwerner././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigur0000644000175000017500000000254511413660476033460 0ustar twernertwerner/* * 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.marshall.config; /** * Unit tests for JBREM-1102. * * @author Ron Sigal * @version *

          * Copyright Mar 21, 2009 *

          */ public class HttpConfigurationMapTestCase extends ConfigurationMapTestParent { protected String getTransport() { return "http"; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestM0000644000175000017500000000341611413660476033422 0ustar twernertwerner/* * 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.marshall.config; import org.jboss.remoting.marshal.Marshaller; /** * * @author Ron Sigal * @version *

          * Copyright Mar 24, 2009 *

          */ public class LocatorTestMarshaller extends ConfigTestMarshaller { private static final long serialVersionUID = 1L; public static volatile int cloned; public static volatile boolean wrote; public Marshaller cloneMarshaller() throws CloneNotSupportedException { cloned++; log.info("cloned LocatorTestMarshaller"); return new LocatorTestMarshaller(); } public static boolean ok() { return !wrote && cloned == 0; } public static void reset() { cloned = 0; wrote = false; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestU0000644000175000017500000000361211413660476033430 0ustar twernertwerner/* * 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.marshall.config; import org.jboss.remoting.marshal.UnMarshaller; /** * @author Ron Sigal * @version *

          * Copyright Mar 24, 2009 *

          */ public class LocatorTestUnmarshaller extends ConfigTestUnmarshaller { private static final long serialVersionUID = 1L; public static volatile int cloned; public static volatile boolean read; public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { cloned++; log.info("cloned LocatorTestUnmarshaller"); ConfigTestUnmarshaller unmarshaller = new LocatorTestUnmarshaller(); unmarshaller.setClassLoader(this.customClassLoader); return unmarshaller; } public static boolean ok() { return !read && cloned == 0; } public static void reset() { cloned = 0; read = false; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java0000644000175000017500000000260311413660476033377 0ustar twernertwerner/* * 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.marshall.config; import java.io.Serializable; /** * @author Ron Sigal * @version *

          * Copyright Mar 24, 2009 *

          */ class Wrapper implements Serializable { private static final long serialVersionUID = 1L; public Object wrappee; public Wrapper(Object o) { wrappee = o; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/SocketConfig0000644000175000017500000000255111413660476033417 0ustar twernertwerner/* * 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.marshall.config; /** * Unit tests for JBREM-1102. * * @author Ron Sigal * @version *

          * Copyright Mar 21, 2009 *

          */ public class SocketConfigurationMapTestCase extends ConfigurationMapTestParent { protected String getTransport() { return "socket"; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUn0000644000175000017500000000525411413660476033414 0ustar twernertwerner/* * 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.marshall.config; import java.io.IOException; import java.io.InputStream; import java.util.Map; import org.apache.log4j.Logger; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; /** * @author Ron Sigal * @version *

          * Copyright Mar 24, 2009 *

          */ public class ConfigTestUnmarshaller extends SerializableUnMarshaller { protected static Logger log = Logger.getLogger(ConfigTestUnmarshaller.class); private static final long serialVersionUID = 1L; public static volatile int cloned; public static volatile boolean read; public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { cloned++; log.info("cloned ConfigTestUnmarshaller"); // log.info("cloned ConfigTestUnmarshaller", new Exception()); ConfigTestUnmarshaller unmarshaller = new ConfigTestUnmarshaller(); unmarshaller.setClassLoader(this.customClassLoader); return unmarshaller; } public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { Object o = super.read(inputStream, metadata, version); if (!(o instanceof Wrapper)) { throw new IOException("expected Wrapper"); } log.info(this + "read Wrapper"); read = true; return ((Wrapper)o).wrappee; } public static boolean ok(boolean b, int count) { log.info("read: " + read + ", cloned: " + cloned); return read == b && cloned == count; } public static void reset() { cloned = 0; read = false; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/Configuratio0000644000175000017500000003313511413660476033474 0ustar twernertwerner/* * 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.marshall.config; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; 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.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1102. * * @author Ron Sigal * @version *

          * Copyright Mar 20, 2009 *

          */ public abstract class ConfigurationMapTestParent extends TestCase { private static Logger log = Logger.getLogger(ConfigurationMapTestParent.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.TRACE); 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); } ConfigTestMarshaller.reset(); ConfigTestUnmarshaller.reset(); LocatorTestMarshaller.reset(); LocatorTestUnmarshaller.reset(); } public void tearDown() { } public void testDatatypeConfigDefault() throws Throwable { log.info("entering " + getName()); // Cache marshaller/unmarshaller. MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new ConfigTestUnmarshaller()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.DATATYPE, "config"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.DATATYPE, "config"); 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"); // Do tests. assertTrue(ConfigTestMarshaller.ok(false, marshallerDatatypeUnused())); assertTrue(ConfigTestUnmarshaller.ok(false, 0)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testDatatypePassConfigMapFalse() throws Throwable { log.info("entering " + getName()); // Cache marshaller/unmarshaller. MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new ConfigTestUnmarshaller()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.DATATYPE, "config"); serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.DATATYPE, "config"); clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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"); // Do tests. assertTrue(ConfigTestMarshaller.ok(false, marshallerDatatypeUnused())); assertTrue(ConfigTestUnmarshaller.ok(false, 0)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testDatatypePassConfigMapTrue() throws Throwable { log.info("entering " + getName()); // Cache marshaller/unmarshaller. MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new ConfigTestUnmarshaller()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.DATATYPE, "config"); serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.DATATYPE, "config"); clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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"); // Do tests. assertTrue(ConfigTestMarshaller.ok(true, marshallerCountDatatype())); assertTrue(ConfigTestUnmarshaller.ok(true, unmarshallerCountDatatype())); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testFQNConfigDefault() throws Throwable { log.info("entering " + getName()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); serverConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); clientConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); 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"); // Do tests. assertTrue(ConfigTestMarshaller.ok(false,marshallerFQNUnused())); assertTrue(ConfigTestUnmarshaller.ok(false, 0)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testFQNPassConfigMapFalse() throws Throwable { log.info("entering " + getName()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); serverConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); clientConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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"); // Do tests. assertTrue(ConfigTestMarshaller.ok(false, marshallerFQNUnused())); assertTrue(ConfigTestUnmarshaller.ok(false, 0)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testFQNConfigPassConfigMapTrue() throws Throwable { log.info("entering " + getName()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); serverConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); clientConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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"); // Do tests. assertTrue(ConfigTestMarshaller.ok(true, marshallerCountFQN())); assertTrue(ConfigTestUnmarshaller.ok(true, unmarshallerCountFQN())); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected int marshallerCountDatatype() { return 6; } protected int unmarshallerCountDatatype() { return 4; } protected int marshallerCountFQN() { return 3; } protected int unmarshallerCountFQN() { return 2; } protected int marshallerDatatypeUnused() { return 2; } protected int marshallerFQNUnused() { return 1; } protected abstract String getTransport(); protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(String parameter, Map extraConfig) throws Exception { log.info("parameter: " + parameter); log.info("extraConfig: " + extraConfig); host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port + "/?" + parameter; // locatorURI += "&serializationtype=jboss"; 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); if (extraConfig != null) { config.putAll(extraConfig); } connector = new Connector(serverLocator, config); connector.create(); invocationHandler = getInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); } protected void shutdownServer() throws Exception { if (connector != null) connector.stop(); } protected TestInvocationHandler getInvocationHandler() { return new TestInvocationHandler(); } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/BisocketConf0000644000175000017500000003123111413660476033407 0ustar twernertwerner/* * 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.marshall.config; import java.util.HashMap; import org.apache.log4j.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.marshal.MarshalFactory; /** * Unit tests for JBREM-1102. * * @author Ron Sigal * @version *

          * Copyright Mar 21, 2009 *

          */ public class BisocketConfigurationMapTestCase extends ConfigurationMapTestParent { private static Logger log = Logger.getLogger(BisocketConfigurationMapTestCase.class); protected String getTransport() { return "bisocket"; } public void testDatatypeConfigWithCallbacksDefault() throws Throwable { log.info("entering " + getName()); // Cache marshaller/unmarshaller. MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new ConfigTestUnmarshaller()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.DATATYPE, "config"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.DATATYPE, "config"); 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 callbacks. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap()); // Do tests. assertTrue(ConfigTestMarshaller.ok(false, 4)); assertTrue(ConfigTestUnmarshaller.ok(false, 0)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); assertEquals(1, callbackHandler.counter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testDatatypeConfigWithCallbacksPassConfigMapFalse() throws Throwable { log.info("entering " + getName()); // Cache marshaller/unmarshaller. MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new ConfigTestUnmarshaller()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.DATATYPE, "config"); serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.DATATYPE, "config"); clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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 callbacks. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap()); // Do tests. assertTrue(ConfigTestMarshaller.ok(false, 4)); assertTrue(ConfigTestUnmarshaller.ok(false, 0)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); assertEquals(1, callbackHandler.counter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testDatatypeConfigWithCallbacksPassConfigMapTrue() throws Throwable { log.info("entering " + getName()); // Cache marshaller/unmarshaller. MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new ConfigTestUnmarshaller()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.DATATYPE, "config"); serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.DATATYPE, "config"); clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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 callbacks. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap()); // Do tests. assertTrue(ConfigTestMarshaller.ok(true, 12)); assertTrue(ConfigTestUnmarshaller.ok(true, 8)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); assertEquals(1, callbackHandler.counter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testFQNConfigWithCallbacksDefault() throws Throwable { log.info("entering " + getName()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); serverConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); clientConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); 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"); // Do callback. // Configure callbacks. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap()); // Do tests. assertTrue(ConfigTestMarshaller.ok(false, 2)); assertTrue(ConfigTestUnmarshaller.ok(false, 0)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); assertEquals(1, callbackHandler.counter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testFQNConfigWithCallbacksPassConfigMapFalse() throws Throwable { log.info("entering " + getName()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); serverConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); clientConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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"); // Do callback. // Configure callbacks. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap()); // Do tests. assertTrue(ConfigTestMarshaller.ok(false, 2)); assertTrue(ConfigTestUnmarshaller.ok(false, 0)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); assertEquals(1, callbackHandler.counter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testFQNConfigWithCallbacksPassConfigMapTrue() throws Throwable { log.info("entering " + getName()); // Start server. HashMap serverConfig = new HashMap(); serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); serverConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true"); setupServer("x=y", serverConfig); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName()); clientConfig.put(InvokerLocator.UNMARSHALLER, ConfigTestUnmarshaller.class.getName()); clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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"); // Do callback. // Configure callbacks. TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, new HashMap()); // Do tests. assertTrue(ConfigTestMarshaller.ok(true, 6)); assertTrue(ConfigTestUnmarshaller.ok(true, 4)); assertTrue(LocatorTestMarshaller.ok()); assertTrue(LocatorTestUnmarshaller.ok()); assertEquals(1, callbackHandler.counter); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected TestInvocationHandler getInvocationHandler() { return new BisocketTestInvocationHandler(); } static class BisocketTestInvocationHandler extends TestInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) { try { callbackHandler.handleCallback(new Callback("callback")); } catch (HandleCallbackException e) { log.error("Error sending callback", e); } } } static class TestCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; log.info("received callback"); } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/TestInvocati0000644000175000017500000000353511413660476033460 0ustar twernertwerner/* * 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.marshall.config; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * @author Ron Sigal * @version *

          * Copyright Mar 24, 2009 *

          */ public 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) {} } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMa0000644000175000017500000000634211413660476033366 0ustar twernertwerner/* * 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.marshall.config; import java.io.IOException; import java.io.OutputStream; import org.apache.log4j.Logger; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; /** * @author Ron Sigal * @version *

          * Copyright Mar 24, 2009 *

          */ public class ConfigTestMarshaller extends SerializableMarshaller { protected static Logger log = Logger.getLogger(ConfigTestMarshaller.class); private static final long serialVersionUID = 1L; private static volatile int cloned; // private static volatile int wrote; private static volatile IntHolder wrote = new IntHolder(0); public void write(Object dataObject, OutputStream output, int version) throws IOException { log.info(this + "writing Wrapper"); super.write(new Wrapper(dataObject), output, version); // wrote++; wrote.increment(); log.info("wrote: " + wrote + ", cloned: " + cloned); } public Marshaller cloneMarshaller() throws CloneNotSupportedException { cloned++; log.info("cloned ConfigTestMarshaller: wrote: " + wrote + ", cloned: " + cloned ); // log.info("cloned ConfigTestMarshaller", new Exception()); return new ConfigTestMarshaller(); } public static boolean ok(boolean b, int count) { log.info("wrote: " + wrote + ", cloned: " + cloned); // return (b ? wrote > 0 : wrote == 0) && cloned == count; int w = wrote.getI(); return (b ? w > 0 : w == 0); } public static void reset() { cloned = 0; // wrote = 0; wrote.setI(0); log.info("reset(): wrote: " + wrote + ", cloned: " + cloned); } static class IntHolder { int i; IntHolder(int i) { this.i = i; } public int getI() { return i; } public void setI(int i) { this.i = i; log.info("setting i", new Exception("setting i")); } public void increment() { i++; log.info("incrementing i", new Exception("incrementing i")); } public String toString() { return Integer.toString(i); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigura0000644000175000017500000000254311413660476033327 0ustar twernertwerner/* * 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.marshall.config; /** * Unit tests for JBREM-1102. * * @author Ron Sigal * @version *

          * Copyright Mar 21, 2009 *

          */ public class RMIConfigurationMapTestCase extends ConfigurationMapTestParent { protected String getTransport() { return "rmi"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/0000755000175000017500000000000011632407043031322 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/EncryptionStandaloneTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/EncryptionS0000644000175000017500000001573510762443663033550 0ustar twernertwerner/* * 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.marshall.encrypt; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.encryption.EncryptingMarshaller; import org.jboss.remoting.marshal.encryption.EncryptingUnMarshaller; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import junit.framework.TestCase; //$Id: EncryptionStandaloneTest.java 3560 2008-03-02 06:22:43Z ron.sigal@jboss.com $ /** * Tests Remoting Encryption facilities * @author Anil Saldhana * @since Aug 16, 2006 * @version $Revision: 3560 $ */ public class EncryptionStandaloneTest extends TestCase { private Marshaller marshaller; private UnMarshaller unmarshaller; private String[] standard = new String[] {null, "AES", "DES", "Blowfish", "DESede"}; private String[] padded = new String[] {"AES/CBC/PKCS5Padding", "AES/PCBC/PKCS5Padding","AES/PCBC/PKCS5Padding", "AES/CFB/PKCS5Padding", "AES/OFB/PKCS5Padding", "DES/CBC/PKCS5Padding", "DES/PCBC/PKCS5Padding","DES/PCBC/PKCS5Padding", "DES/CFB/PKCS5Padding", "DES/OFB/PKCS5Padding", "DESede/CBC/PKCS5Padding", "DESede/PCBC/PKCS5Padding","DESede/PCBC/PKCS5Padding", "DESede/CFB/PKCS5Padding", "DESede/OFB/PKCS5Padding"}; private String[] unpadded = new String[] {"AES/CBC/NoPadding", "AES/PCBC/NoPadding","AES/PCBC/NoPadding", "AES/CFB/NoPadding", "AES/OFB/NoPadding", "DES/CBC/NoPadding", "DES/PCBC/NoPadding","DES/PCBC/NoPadding", "DES/CFB/NoPadding", "DES/OFB/NoPadding", "DESede/CBC/NoPadding", "DESede/PCBC/NoPadding","DESede/PCBC/NoPadding", "DESede/CFB/NoPadding", "DESede/OFB/NoPadding"}; public void testSerializable() throws IOException, ClassNotFoundException { for(int i = 0 ; i < standard.length; i++) runAlgoTest(standard[i]); for(int i = 0 ; i < padded.length; i++) runAlgoTest(padded[i]); for(int i = 0 ; i < unpadded.length; i++) runAlgoTest(unpadded[i]); } public void testWrappedSerializable() throws IOException, ClassNotFoundException { for(int i = 0 ; i < standard.length; i++) runWrappedSerializableTest(standard[i]); for(int i = 0 ; i < padded.length; i++) runWrappedSerializableTest(padded[i]); for(int i = 0 ; i < unpadded.length; i++) runWrappedSerializableTest(unpadded[i]); } /** * Commented out usecases not supported * @throws IOException * @throws ClassNotFoundException */ public void testHTTP() throws IOException, ClassNotFoundException { for(int i = 0 ; i < standard.length; i++) runHttpTest(standard[i]); for(int i = 0 ; i < padded.length; i++) runHttpTest(padded[i]); //NoPadding is not correctly supported by HttpUnMarshaller /*for(int i = 0 ; i < unpadded.length; i++) runHttpTest(unpadded[i]); */ } protected void runOneTest() throws IOException, ClassNotFoundException { String testData = "This is some test data"; Object param = new String(testData); ByteArrayOutputStream output = new ByteArrayOutputStream(); marshaller.write(param, output); byte[] byteArray = new byte[output.size()]; byteArray = output.toByteArray(); ByteArrayInputStream input = new ByteArrayInputStream(byteArray); Object result = unmarshaller.read(input, null); System.out.println("Result: " + result); assertEquals(testData, result); } private void runAlgoTest(String algo) throws IOException, ClassNotFoundException { EncryptingMarshaller em = new EncryptingMarshaller(); EncryptingUnMarshaller um = new EncryptingUnMarshaller(); if(algo != null) { em.setCipherAlgorithm(algo); um.setCipherAlgorithm(algo); } MarshalFactory.addMarshaller(EncryptingMarshaller.DATATYPE,em, um); marshaller = MarshalFactory.getMarshaller(EncryptingMarshaller.DATATYPE); unmarshaller = MarshalFactory.getUnMarshaller(EncryptingMarshaller.DATATYPE); runOneTest(); } private void runHttpTest(String algo) throws IOException, ClassNotFoundException { String datatype = "encryptedHTTP"; Marshaller m = MarshalFactory.getMarshaller(HTTPMarshaller.DATATYPE); UnMarshaller u = MarshalFactory.getUnMarshaller(HTTPUnMarshaller.DATATYPE); EncryptingMarshaller em = new EncryptingMarshaller(m); EncryptingUnMarshaller um = new EncryptingUnMarshaller(u); if(algo != null) { em.setCipherAlgorithm(algo); um.setCipherAlgorithm(algo); } MarshalFactory.addMarshaller(datatype,em, um); marshaller = MarshalFactory.getMarshaller(datatype); unmarshaller = MarshalFactory.getUnMarshaller(datatype); runOneTest(); } private void runWrappedSerializableTest(String algo) throws IOException, ClassNotFoundException { String datatype = "encryptedSerializable"; String sd = SerializableMarshaller.DATATYPE; String sud = SerializableUnMarshaller.DATATYPE; EncryptingMarshaller em = new EncryptingMarshaller(MarshalFactory.getMarshaller(sd)); EncryptingUnMarshaller um = new EncryptingUnMarshaller(MarshalFactory.getUnMarshaller(sud)); if(algo != null) { em.setCipherAlgorithm(algo); um.setCipherAlgorithm(algo); } MarshalFactory.addMarshaller(datatype,em, um); marshaller = MarshalFactory.getMarshaller(datatype); unmarshaller = MarshalFactory.getUnMarshaller(datatype); } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/EncryptingMarshallerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/EncryptingM0000644000175000017500000001320010473664041033505 0ustar twernertwerner/* * 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.marshall.encrypt; 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.InvokerCallbackHandler; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.encryption.EncryptingMarshaller; import org.jboss.remoting.marshal.encryption.EncryptingUnMarshaller; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.transport.Connector; /** * A EncryptingMarshallerTestServer. * * @author Anil.Saldhana@jboss.org * @version $Revision: 1402 $ */ public class EncryptingMarshallerTestServer extends ServerTestCase { private static final Object lock = new Object(); public void setUp() { String javauri = "socket://localhost:5300/?datatype=encrypt" + "&"+ InvokerLocator.SERIALIZATIONTYPE + "=" + SerializationStreamFactory.JAVA_ENCRYPT; String jbosslocatorURI = "socket://localhost:5400/?datatype=encrypt" + "&"+ InvokerLocator.SERIALIZATIONTYPE + "=" + SerializationStreamFactory.JBOSS_ENCRYPT; EncryptionServerThread jbossThread = new EncryptionServerThread(jbosslocatorURI,2); EncryptionServerThread javaThread = new EncryptionServerThread(javauri,2); //Start the two threads - one for JBoss Invocation and one for Java invocation jbossThread.start(); javaThread.start(); } public static void main(String[] args) { try { new EncryptingMarshallerTestServer().setUp(); } catch (Exception e) { e.printStackTrace(); } } public class EncryptionServerThread extends Thread { private String locatorURI = null; private int counter = 0; public EncryptionServerThread(String url, int counter) { this.counter = counter; this.locatorURI = url; } public void run() { try { MarshalFactory.addMarshaller("encrypt", new EncryptingMarshaller(), new EncryptingUnMarshaller()); 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.create(); JavaInvocationHandler invocationHandler = new JavaInvocationHandler(counter); connector.addInvocationHandler("sample", invocationHandler); connector.start(); synchronized(lock) { lock.wait(); } connector.stop(); connector.destroy(); } catch(Exception e) { e.printStackTrace(); } } } /** * Noop Invocation Handler * @author Anil Saldhana * @version $Revision: 1402 $ */ public abstract class AdapterInvocationHandler implements ServerInvocationHandler { public void addListener(InvokerCallbackHandler callbackHandler) { } public abstract Object invoke(InvocationRequest invocation) throws Throwable; public void removeListener(InvokerCallbackHandler callbackHandler) { } public void setInvoker(ServerInvoker invoker) { } public void setMBeanServer(MBeanServer server) { } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public class JavaInvocationHandler extends AdapterInvocationHandler { private int counter = 0; public JavaInvocationHandler(int counter) { this.counter = counter; } /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { if(++counter == 2) { synchronized(lock) { lock.notify(); } } Object obj = invocation.getParameter(); return obj; } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/EncryptingMarshallerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/EncryptingM0000644000175000017500000001107310473663765033527 0ustar twernertwerner/* * 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.marshall.encrypt; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.encryption.EncryptingMarshaller; import org.jboss.remoting.marshal.encryption.EncryptingUnMarshaller; import org.jboss.remoting.serialization.SerializationStreamFactory; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; /** * Test Client for the marshaller that can do encryption * @author Anil.Saldhana@jboss.org */ public class EncryptingMarshallerTestClient extends TestCase { private Marshaller marshaller; private UnMarshaller unmarshaller; protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); marshaller = null; unmarshaller = null; } public void testJavaInvocations() { try { Thread.sleep(5000); // Wait for server to start. MarshalFactory.addMarshaller("encrypt", new EncryptingMarshaller(), new EncryptingUnMarshaller()); String locatorURI = "socket://localhost:5300/?datatype=encrypt&"+ InvokerLocator.SERIALIZATIONTYPE + "=" + SerializationStreamFactory.JAVA_ENCRYPT; InvokerLocator locator = new InvokerLocator(locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); String request1 = "First request"; Object response1 = remotingClient.invoke(request1); assertTrue(request1.equals(response1)); Object request2 = new Integer(17); Object response2 = remotingClient.invoke(request2); assertTrue(request2.equals(response2)); } catch(Throwable e) { e.printStackTrace(); fail(); } } public void testJBossInvocations() { try { Thread.sleep(5000); // Wait for server to start. MarshalFactory.addMarshaller("encrypt", new EncryptingMarshaller(), new EncryptingUnMarshaller()); String locatorURI = "socket://localhost:5400/?datatype=encrypt&"+ InvokerLocator.SERIALIZATIONTYPE + "=" + SerializationStreamFactory.JBOSS_ENCRYPT; InvokerLocator locator = new InvokerLocator(locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); String request1 = "First request"; Object response1 = remotingClient.invoke(request1); assertTrue(request1.equals(response1)); Object request2 = new Integer(17); Object response2 = remotingClient.invoke(request2); assertTrue(request2.equals(response2)); } catch(Throwable e) { e.printStackTrace(); fail(); } } protected void runOneTest() throws IOException, ClassNotFoundException { String testData = "This is some test data"; Object param = new String(testData); ByteArrayOutputStream output = new ByteArrayOutputStream(); marshaller.write(param, output); byte[] byteArray = new byte[output.size()]; byteArray = output.toByteArray(); ByteArrayInputStream input = new ByteArrayInputStream(byteArray); Object result = unmarshaller.read(input, null); System.out.println("Result: " + result); assertEquals(testData, result); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/EncryptingMarshallerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/encrypt/EncryptingM0000644000175000017500000000354110762443647033524 0ustar twernertwerner/* * 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.marshall.encrypt; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * A EncryptingMarshallerTestCase. * * @author Anil.Saldhana@jboss.org * @version $Revision: 3559 $ */ public class EncryptingMarshallerTest extends TestDriver { public void declareTestClasses() { addTestClasses(EncryptingMarshallerTestClient.class.getName(), 1, EncryptingMarshallerTestServer.class.getName()); } protected Level getTestLogLevel() { return Level.ERROR; } /*protected String getClientJVMArguments() { return "-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"; } */ /*protected String getServerJVMArguments() { return "-Xdebug -Xrunjdwp:transport=dt_socket,address=8686,server=y,suspend=y"; } */ } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/0000755000175000017500000000000011632407043031471 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/CompressingMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/Compressin0000644000175000017500000000322310355142433033536 0ustar twernertwerner/* * 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.marshall.compress; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * A CompressingMarshallerTestCase. * * @author Ron Sigal * @version $Revision: 566 $ *

          * Copyright (c) 2005 *

          */ public class CompressingMarshallerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(CompressingMarshallerTestClient.class.getName(), 1, CompressingMarshallerTestServer.class.getName()); } protected Level getTestLogLevel() { return Level.ERROR; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/RMICompressionStressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/RMICompres0000644000175000017500000000263511413660476033412 0ustar twernertwerner/* * 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.marshall.compress; import org.jboss.test.remoting.marshall.compress.CompressionStressTestParent; /** * Unit test for JBREM-677. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Mar 6, 2008 *

          */ public class RMICompressionStressTestCase extends CompressionStressTestParent { protected String getTransport() { return "rmi"; } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/NewCompressingMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/NewCompres0000644000175000017500000001462311413660476033514 0ustar twernertwerner/* * 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.marshall.compress; 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.marshal.MarshalFactory; import org.jboss.remoting.marshal.compress.CompressingMarshaller; import org.jboss.remoting.marshal.compress.CompressingUnMarshaller; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1077. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Jul 27, 2009 *

          */ public class NewCompressingMarshallerTestCase extends TestCase { private static Logger log = Logger.getLogger(NewCompressingMarshallerTestCase.class); private static boolean firstTime = true; private static char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; private static int COUNT = 10000; 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); MarshalFactory.addMarshaller(CompressingMarshaller.DATATYPE, new CompressingMarshaller(), new CompressingUnMarshaller()); } } public void tearDown() { } public void testCompression() 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 connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); StringBuffer sb = new StringBuffer(); for (int i = 0; i < COUNT; i++) { String msg = sb.append(digits[i % 10]).toString(); Object response = client.invoke(msg); assertEquals("error on invocation " + i, msg, response); if (i % (COUNT / 10) == 0) { log.info("OK: " + i); } } 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 + "/?datatype=" + CompressingMarshaller.DATATYPE; 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 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"); } } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/HttpCompressionStressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/HttpCompre0000644000175000017500000000263711413660476033521 0ustar twernertwerner/* * 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.marshall.compress; import org.jboss.test.remoting.marshall.compress.CompressionStressTestParent; /** * Unit test for JBREM-677. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Mar 6, 2008 *

          */ public class HttpCompressionStressTestCase extends CompressionStressTestParent { protected String getTransport() { return "http"; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/SocketCompressionStressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/SocketComp0000644000175000017500000000264411413660476033501 0ustar twernertwerner/* * 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.marshall.compress; import org.jboss.test.remoting.marshall.compress.CompressionStressTestParent; /** * Unit test for JBREM-677. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Mar 6, 2008 *

          */ public class SocketCompressionStressTestCase extends CompressionStressTestParent { protected String getTransport() { return "socket"; } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/WrappedHttpUnMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/WrappedHtt0000644000175000017500000001375111413660476033515 0ustar twernertwerner/* * 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.marshall.compress; 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.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.compress.CompressingMarshaller; import org.jboss.remoting.marshal.compress.CompressingUnMarshaller; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-927. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Mar 13, 2008 *

          */ public class WrappedHttpUnMarshallerTestCase extends TestCase { private static Logger log = Logger.getLogger(WrappedHttpUnMarshallerTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected TestInvocationHandler invocationHandler; protected String longMessage; 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); Marshaller marshaller = new CompressingMarshaller(new HTTPMarshaller()); UnMarshaller unmarshaller = new CompressingUnMarshaller(new HTTPUnMarshaller()); MarshalFactory.addMarshaller("compressedHttp", marshaller, unmarshaller); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 200; i++) { sb.append("abcdefghij"); } longMessage = sb.toString(); } } public void tearDown() { } public void testMethod() 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"); Map metadata = new HashMap(); metadata.put(Client.RAW, "true"); assertEquals(longMessage, client.invoke(longMessage, metadata)); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "http"; } 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 += "/?datatype=compressedHttp"; 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) {} } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/CompressingMarshallerTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/Compressin0000644000175000017500000001167510355142433033550 0ustar twernertwerner/* * 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.marshall.compress; 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.InvokerCallbackHandler; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.compress.CompressingMarshaller; import org.jboss.remoting.marshal.compress.CompressingUnMarshaller; import org.jboss.remoting.transport.Connector; /** * A CompressingMarshallerTestServer. * * @author Ron Sigal * @version $Revision: 566 $ *

          * Copyright (c) 2005 *

          */ public class CompressingMarshallerTestServer extends ServerTestCase { private static final Object lock = new Object(); public void setUp() { new Thread() { public void run() { try { MarshalFactory.addMarshaller("compress", new CompressingMarshaller(), new CompressingUnMarshaller()); String locatorURI = "socket://localhost:5400/?datatype=compress"; 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.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); synchronized(lock) { lock.wait(); } connector.stop(); connector.destroy(); } catch(Exception e) { e.printStackTrace(); } } }.start(); } public static void main(String[] args) { new CompressingMarshallerTestServer().setUp(); } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { int counter; /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { if(++counter == 2) { synchronized(lock) { lock.notify(); } } return invocation.getParameter(); } /** * 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 } } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/CompressingMarshallerTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/Compressin0000644000175000017500000001225010433770344033543 0ustar twernertwerner/* * 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.marshall.compress; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.compress.CompressingMarshaller; import org.jboss.remoting.marshal.compress.CompressingUnMarshaller; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; /** * @author Tom Elrod */ public class CompressingMarshallerTestClient extends TestCase { private Marshaller marshaller; private UnMarshaller unmarshaller; protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); marshaller = null; unmarshaller = null; } public void testSerializable() throws IOException, ClassNotFoundException { MarshalFactory.addMarshaller(CompressingMarshaller.DATATYPE, new CompressingMarshaller(), new CompressingUnMarshaller()); marshaller = MarshalFactory.getMarshaller(CompressingMarshaller.DATATYPE); unmarshaller = MarshalFactory.getUnMarshaller(CompressingMarshaller.DATATYPE); runOneTest(); } public void testWrappedSerializable() throws IOException, ClassNotFoundException { String datatype = "compressedSerializable"; MarshalFactory.addMarshaller(datatype, new CompressingMarshaller(MarshalFactory.getMarshaller(SerializableMarshaller.DATATYPE)), new CompressingUnMarshaller(MarshalFactory.getUnMarshaller(SerializableUnMarshaller.DATATYPE))); marshaller = MarshalFactory.getMarshaller(datatype); unmarshaller = MarshalFactory.getUnMarshaller(datatype); runOneTest(); } public void testHTTP() throws IOException, ClassNotFoundException { String datatype = "compressedHTTP"; MarshalFactory.addMarshaller(datatype, new CompressingMarshaller(MarshalFactory.getMarshaller(HTTPMarshaller.DATATYPE)), new CompressingUnMarshaller(MarshalFactory.getUnMarshaller(HTTPUnMarshaller.DATATYPE))); marshaller = MarshalFactory.getMarshaller(datatype); unmarshaller = MarshalFactory.getUnMarshaller(datatype); runOneTest(); } public void testInvocations() { try { Thread.sleep(5000); // Wait for server to start. MarshalFactory.addMarshaller("compress", new CompressingMarshaller(), new CompressingUnMarshaller()); String locatorURI = "socket://localhost:5400/?datatype=compress"; InvokerLocator locator = new InvokerLocator(locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); String request1 = "First request"; Object response1 = remotingClient.invoke(request1); assertTrue(request1.equals(response1)); Object request2 = new Integer(17); Object response2 = remotingClient.invoke(request2); assertTrue(request2.equals(response2)); } catch(Throwable e) { e.printStackTrace(); fail(); } } protected void runOneTest() throws IOException, ClassNotFoundException { String testData = "This is some test data"; Object param = new String(testData); ByteArrayOutputStream output = new ByteArrayOutputStream(); marshaller.write(param, output); byte[] byteArray = new byte[output.size()]; byteArray = output.toByteArray(); ByteArrayInputStream input = new ByteArrayInputStream(byteArray); Object result = unmarshaller.read(input, null); System.out.println("Result: " + result); assertEquals(testData, result); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/CompressionStressTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/compress/Compressio0000644000175000017500000001500311413660476033546 0ustar twernertwerner/* * 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.marshall.compress; 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.MicroRemoteClientInvoker; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.compress.CompressingMarshaller; import org.jboss.remoting.marshal.compress.CompressingUnMarshaller; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-677. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Mar 6, 2008 *

          */ abstract public class CompressionStressTestParent extends TestCase { private static Logger log = Logger.getLogger(CompressionStressTestParent.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); MarshalFactory.addMarshaller("compress", new CompressingMarshaller(), new CompressingUnMarshaller()); } } public void tearDown() { } public void testCompression() 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"); // Verify CompressingMarshaller / CompressingUnMarshaller are being used. MicroRemoteClientInvoker invoker = (MicroRemoteClientInvoker) client.getInvoker(); assertTrue(invoker.getMarshaller() instanceof CompressingMarshaller); assertTrue(invoker.getUnMarshaller() instanceof CompressingUnMarshaller); StringBuffer sb = new StringBuffer(10000); for (int i = 0; i < 1000; i++) { sb.append(((char) i % 10)); String msg = sb.toString(); Object result = client.invoke(msg); assertEquals("failed on invocation " + i, msg, result); if ((i + 1) % 100 == 0) { log.info("invocations: " + (i + 1)); log.info("length: " + msg.length()); } } 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 + "/?datatype=compress"; 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(); } 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 { // log.info("parameter: " + invocation.getParameter()); // log.info("server: type: " + invocation.getParameter().getClass()); // log.info("server length: " + ((String)invocation.getParameter()).length()); 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/marshall/preferredstream/0000755000175000017500000000000011632407043033030 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/TestObjectOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/Tes0000644000175000017500000000064010561526247033516 0ustar twernertwernerpackage org.jboss.test.remoting.marshall.preferredstream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; public class TestObjectOutputStream extends ObjectOutputStream { public TestObjectOutputStream(OutputStream out) throws IOException { super(out); } public TestObjectOutputStream() throws IOException, SecurityException { super(); } } ././@LongLink0000000000000000000000000000022000000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/BisocketPreferredStreamMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/Bis0000644000175000017500000000251610562003355033473 0ustar twernertwerner/* * 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.marshall.preferredstream; /** * @author Ron Sigal * @version $Revision: 2129 $ *

          * Copyright Feb 5, 2007 *

          */ public class BisocketPreferredStreamMarshallerTestCase extends PreferredStreamMarshallerTestRoot { protected String getTransport() { return "bisocket"; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/TestMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/Tes0000644000175000017500000000353210561526247033521 0ustar twernertwerner/* * 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.marshall.preferredstream; import java.io.IOException; import java.io.OutputStream; import java.util.Map; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; /** * @author Ron Sigal * @version $Revision: 2121 $ *

          * Copyright Jan 29, 2007 *

          */ public class TestMarshaller extends SerializableMarshaller { /** The serialVersionUID */ private static final long serialVersionUID = 5639800228740710244L; public TestMarshaller() {} public OutputStream getMarshallingStream(OutputStream outputStream, Map config) throws IOException { return new TestObjectOutputStream(outputStream); } public Marshaller cloneMarshaller() throws CloneNotSupportedException { return new TestMarshaller(); } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/PreferredStreamMarshallerTestRoot.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/Pre0000644000175000017500000003133510572210664033511 0ustar twernertwerner/* * 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.marshall.preferredstream; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; 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.InvokerCallbackHandler; 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; /** * This test verifies that the socket transport caches and reuses object streams * provided by PreferredStream(Un)Marshallers. * * @author Ron Sigal * @version $Revision: 2255 $ *

          * Copyright Jan 10, 2007 *

          */ public abstract class PreferredStreamMarshallerTestRoot extends TestCase { protected static Logger log = Logger.getLogger(PreferredStreamMarshallerTestRoot.class); protected static boolean firstTime = true; 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 testSerializableMarshallerUnMarshaller() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?marshaller=org.jboss.remoting.marshal.serializable.SerializableMarshaller"; locatorURI += "&unmarshaller=org.jboss.remoting.marshal.serializable.SerializableUnMarshaller"; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, config); client.connect(); Integer i = (Integer) client.invoke(new Integer(17)); assertEquals(18, i.intValue()); // Make sure client has object streams. assertTrue(client.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool = (List) field.get(clientInvoker); assertEquals(1, pool.size()); ClientSocketWrapper csw = (ClientSocketWrapper) pool.get(0); field = ClientSocketWrapper.class.getDeclaredField("in"); field.setAccessible(true); InputStream client_in1 = (InputStream) field.get(csw); assertTrue(client_in1 instanceof ObjectInputStream); field = ClientSocketWrapper.class.getDeclaredField("out"); field.setAccessible(true); OutputStream client_out1 = (OutputStream) field.get(csw); assertTrue(client_out1 instanceof ObjectOutputStream); // Make sure server has object streams. assertTrue(connector.getServerInvoker() instanceof SocketServerInvoker); SocketServerInvoker ssi = (SocketServerInvoker) connector.getServerInvoker(); field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(ssi); assertEquals(1, clientpool.size()); Set threads = clientpool.getContents(); ServerThread serverThread = (ServerThread) threads.iterator().next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); ServerSocketWrapper ssw = (ServerSocketWrapper) field.get(serverThread); field = ClientSocketWrapper.class.getDeclaredField("in"); field.setAccessible(true); InputStream server_in1 = (InputStream) field.get(ssw); assertTrue(server_in1 instanceof ObjectInputStream); field = ClientSocketWrapper.class.getDeclaredField("out"); field.setAccessible(true); OutputStream server_out1 = (OutputStream) field.get(ssw); assertTrue(server_out1 instanceof ObjectOutputStream); // Do another invocation. i = (Integer) client.invoke(new Integer(19)); assertEquals(20, i.intValue()); // Make sure client and server reused the cached streams. field = ClientSocketWrapper.class.getDeclaredField("in"); field.setAccessible(true); InputStream client_in2 = (InputStream) field.get(csw); assertTrue(client_in2 instanceof ObjectInputStream); field = ClientSocketWrapper.class.getDeclaredField("out"); field.setAccessible(true); OutputStream client_out2 = (OutputStream) field.get(csw); assertTrue(client_out2 instanceof ObjectOutputStream); field = ClientSocketWrapper.class.getDeclaredField("in"); field.setAccessible(true); InputStream server_in2 = (InputStream) field.get(ssw); assertTrue(server_in2 instanceof ObjectInputStream); field = ClientSocketWrapper.class.getDeclaredField("out"); field.setAccessible(true); OutputStream server_out2 = (OutputStream) field.get(ssw); assertTrue(server_out2 instanceof ObjectOutputStream); assertEquals(client_in1, client_in2); assertEquals(client_out1, client_out2); assertEquals(server_in1, server_in2); assertEquals(server_out1, server_out2); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } public void testTestMarshallerUnMarshaller() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = getTransport() + "://" + host + ":" + port; locatorURI += "/?marshaller=org.jboss.test.remoting.marshall.preferredstream.TestMarshaller"; locatorURI += "&unmarshaller=org.jboss.test.remoting.marshall.preferredstream.TestUnMarshaller"; InvokerLocator locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); connector.addInvocationHandler("test", new TestHandler()); connector.start(); HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); Client client = new Client(locator, config); client.connect(); Integer i = (Integer) client.invoke(new Integer(17)); assertEquals(18, i.intValue()); // Make sure client has object streams from test directory. assertTrue(client.getInvoker() instanceof MicroSocketClientInvoker); MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); Field field = MicroSocketClientInvoker.class.getDeclaredField("pool"); field.setAccessible(true); List pool = (List) field.get(clientInvoker); assertEquals(1, pool.size()); ClientSocketWrapper csw = (ClientSocketWrapper) pool.get(0); field = ClientSocketWrapper.class.getDeclaredField("in"); field.setAccessible(true); InputStream client_in1 = (InputStream) field.get(csw); assertTrue(client_in1 instanceof TestObjectInputStream); field = ClientSocketWrapper.class.getDeclaredField("out"); field.setAccessible(true); OutputStream client_out1 = (OutputStream) field.get(csw); assertTrue(client_out1 instanceof TestObjectOutputStream); // Make sure server has object streams from test directory. assertTrue(connector.getServerInvoker() instanceof SocketServerInvoker); SocketServerInvoker ssi = (SocketServerInvoker) connector.getServerInvoker(); field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(ssi); assertEquals(1, clientpool.size()); Set threads = clientpool.getContents(); ServerThread serverThread = (ServerThread) threads.iterator().next(); field = ServerThread.class.getDeclaredField("socketWrapper"); field.setAccessible(true); ServerSocketWrapper ssw = (ServerSocketWrapper) field.get(serverThread); field = ClientSocketWrapper.class.getDeclaredField("in"); field.setAccessible(true); InputStream server_in1 = (InputStream) field.get(ssw); assertTrue(server_in1 instanceof TestObjectInputStream); field = ClientSocketWrapper.class.getDeclaredField("out"); field.setAccessible(true); OutputStream server_out1 = (OutputStream) field.get(ssw); assertTrue(server_out1 instanceof TestObjectOutputStream); // Do another invocation. i = (Integer) client.invoke(new Integer(19)); assertEquals(20, i.intValue()); // Make sure client and server reused the cached streams. field = ClientSocketWrapper.class.getDeclaredField("in"); field.setAccessible(true); InputStream client_in2 = (InputStream) field.get(csw); assertTrue(client_in2 instanceof ObjectInputStream); field = ClientSocketWrapper.class.getDeclaredField("out"); field.setAccessible(true); OutputStream client_out2 = (OutputStream) field.get(csw); assertTrue(client_out2 instanceof ObjectOutputStream); field = ClientSocketWrapper.class.getDeclaredField("in"); field.setAccessible(true); InputStream server_in2 = (InputStream) field.get(ssw); assertTrue(server_in2 instanceof TestObjectInputStream); field = ClientSocketWrapper.class.getDeclaredField("out"); field.setAccessible(true); OutputStream server_out2 = (OutputStream) field.get(ssw); assertTrue(server_out2 instanceof TestObjectOutputStream); assertEquals(client_in1, client_in2); assertEquals(client_out1, client_out2); assertEquals(server_in1, server_in2); assertEquals(server_out1, server_out2); client.disconnect(); connector.stop(); log.info(getName() + " PASSES"); } protected abstract String getTransport(); protected void addExtraClientConfig(Map config) { } protected void addExtraServerConfig(Map config) { } public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { Integer i = (Integer) invocation.getParameter(); return new Integer(i.intValue() + 1); } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } }././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/TestUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/Tes0000644000175000017500000000372110757515360033522 0ustar twernertwerner/* * 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.marshall.preferredstream; import java.io.IOException; import java.io.InputStream; import java.util.Map; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; /** * @author Ron Sigal * @version $Revision: 3479 $ *

          * Copyright Jan 29, 2007 *

          */ public class TestUnMarshaller extends SerializableUnMarshaller { /** The serialVersionUID */ private static final long serialVersionUID = 37467690240020013L; public TestUnMarshaller() {} public InputStream getMarshallingStream(InputStream inputStream, Map config) throws IOException { return new TestObjectInputStream(inputStream); } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { SerializableUnMarshaller unmarshaller = new TestUnMarshaller(); unmarshaller.setClassLoader(getClassLoader()); return unmarshaller; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/TestObjectInputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/Tes0000644000175000017500000000062710561526247033523 0ustar twernertwernerpackage org.jboss.test.remoting.marshall.preferredstream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; public class TestObjectInputStream extends ObjectInputStream { public TestObjectInputStream(InputStream in) throws IOException { super(in); } public TestObjectInputStream() throws IOException, SecurityException { super(); } } ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/SocketPreferredStreamMarshallerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/marshall/preferredstream/Soc0000644000175000017500000000251210562003355033476 0ustar twernertwerner/* * 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.marshall.preferredstream; /** * @author Ron Sigal * @version $Revision: 2129 $ *

          * Copyright Feb 5, 2007 *

          */ public class SocketPreferredStreamMarshallerTestCase extends PreferredStreamMarshallerTestRoot { protected String getTransport() { return "socket"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/0000755000175000017500000000000011632407032027704 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/ShutdownTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/ShutdownTestServer.0000644000175000017500000001351110722765475033571 0ustar twernertwerner/* * 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.shutdown; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import org.apache.log4j.Logger; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; 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; /** * This is the server half of a unit test designed to verify that a Remoting application * will shut down without any stray threads hanging it up. To exercise as many * Remoting threads as possible, the server enables leasing and registers a * connection listener. * * @author Ron Sigal * @version $Revision: 3011 $ *

          * Copyright Jan 19, 2007 *

          */ public class ShutdownTestServer extends ServerTestCase { public static int port = 9876; private static Logger log = Logger.getLogger(ShutdownTestServer.class); private Connector connector; private String transport; private Map extraConfig; public ShutdownTestServer(String transport, Map config) { this.transport = transport; this.extraConfig = config; } public void setUp() throws Exception { String host = InetAddress.getLocalHost().getHostAddress(); String portString = System.getProperty("port"); log.info("portString: " + portString); int port = Integer.parseInt(portString); String locatorURI = transport + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap serverConfig = new HashMap(extraConfig); log.info("serverConfig: " + serverConfig); connector = new Connector(locator, serverConfig); connector.create(); connector.setLeasePeriod(2000); connector.addInvocationHandler("test", new TestHandler()); connector.addConnectionListener(new TestListener()); connector.start(); log.info("server started at: " + locatorURI); log.info("READY"); } public void tearDown() { if (connector != null) { connector.stop(); log.info("server shut down"); } } public static void main(String[] args) { if (args.length == 0) throw new RuntimeException(); HashMap config = new HashMap(); System.out.println("server args.length: " + args.length); if (args.length > 1) getConfig(config, args[1]); String transport = args[0]; ShutdownTestServer server = new ShutdownTestServer(transport, config); try { server.setUp(); log.info("server back from setUp()"); Thread.sleep(25000); log.info("server calling tearDown()"); server.tearDown(); log.info("server back from tearDown()"); } catch(Exception e) { e.printStackTrace(); } } protected static void getConfig(Map config, String configs) { int start = 0; int ampersand = configs.indexOf('&'); while (ampersand > 0) { String s = configs.substring(start, ampersand); int equals = s.indexOf('='); String param = s.substring(0, equals); String value = s.substring(equals + 1); config.put(param, value); start = ampersand + 1; ampersand = configs.indexOf('&', start); } log.info("config: " + config); log.info("configs: " + configs); } public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { Integer i = (Integer) invocation.getParameter(); return new Integer(i.intValue() + 1); } public void addListener(InvokerCallbackHandler callbackHandler) { try { log.info("sending callback"); callbackHandler.handleCallback(new Callback("callback")); log.info("sent callback"); } catch (HandleCallbackException e) { log.info("error handling callback"); e.printStackTrace(); } } public void removeListener(InvokerCallbackHandler callbackHandler) {} } public static class TestListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { log.info("got connection exception: " + throwable); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/local/0000755000175000017500000000000011632407032030776 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/local/LocalShutdownTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/local/LocalShutdown0000644000175000017500000003306110565236326033524 0ustar twernertwerner/* * 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.shutdown.local; 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.ConnectionListener; 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.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; /** * Provides unit tests that verifies that Client.disconnectLocal() and * Client.removeListenerLocal() do not attempt to contact the server. * * @author Ron Sigal * @version $Revision: 2172 $ *

          * Copyright Jan 18, 2007 *

          */ public class LocalShutdownTestCase extends TestCase { private Logger log = Logger.getLogger(LocalShutdownTestCase.class); protected 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.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 testDummy() { } // public void testDisconnectLocal() throws Throwable // { // log.info("entering " + getName()); // // // Start server. // String host = InetAddress.getLocalHost().getHostAddress(); // int port = PortUtil.findFreePort(host); // String locatorURI = "socket://" + host + ":" + port; // InvokerLocator locator = new InvokerLocator(locatorURI); // HashMap serverConfig = new HashMap(); // Connector connector = new Connector(locator, serverConfig); // connector.create(); // connector.addInvocationHandler("test", new TestHandler()); // connector.addConnectionListener(new TestListener()); // connector.start(); // // // Connect client, verify that a lease exists, then disconnect client // // and verify that lease has been removed on server. // HashMap clientConfig = new HashMap(); // clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); // clientConfig.put(Client.ENABLE_LEASE, "true"); // clientConfig.put(InvokerLocator.CLIENT_LEASE_PERIOD, "1000"); // Client client = new Client(locator, clientConfig); // client.connect(); // Integer i = (Integer) client.invoke(new Integer(7)); // assertEquals(8, i.intValue()); // Thread.sleep(1000); // ServerInvoker serverInvoker = connector.getServerInvoker(); // Field field = ServerInvoker.class.getDeclaredField("clientLeases"); // field.setAccessible(true); // Map clientLeases = (Map) field.get(serverInvoker); // assertEquals(1, clientLeases.size()); // field = MicroRemoteClientInvoker.class.getDeclaredField("invokerSessionId"); // field.setAccessible(true); // String invokerSessionId = (String) field.get(client.getInvoker()); // assertTrue(clientLeases.containsKey(invokerSessionId)); // client.disconnect(); // assertEquals(0, clientLeases.size()); // // // Connect new client, verify that a lease exists, then locally disconnect // // client and verify that lease still exists on server. // client = new Client(locator, clientConfig); // client.connect(); // i = (Integer) client.invoke(new Integer(11)); // assertEquals(12, i.intValue()); // Thread.sleep(1000); // assertEquals(1, clientLeases.size()); // invokerSessionId = (String) field.get(client.getInvoker()); // assertTrue(clientLeases.containsKey(invokerSessionId)); // client.disconnectLocal(); // assertEquals(1, clientLeases.size()); // assertTrue(clientLeases.containsKey(invokerSessionId)); // // connector.stop(); // log.info(getName() + " PASSES"); // } // public void testRemoveListenerLocalPushCallbacks() throws Throwable { // log.info("entering " + getName()); // // // Start server. // 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(InvokerLocator.FORCE_REMOTE, "true"); // Connector connector = new Connector(locator, serverConfig); // connector.create(); // connector.addInvocationHandler("test", new TestHandler()); // connector.start(); // // // Connect client, add a callback handler, then call Client.removeListener() // // and verify that callback handler has been removed on server. // HashMap clientConfig = new HashMap(); // clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Client client = new Client(locator, clientConfig); // client.connect(); // Integer i = (Integer) client.invoke(new Integer(7)); // assertEquals(8, i.intValue()); // TestCallbackHandler callbackHandler = new TestCallbackHandler(); // client.addListener(callbackHandler, null, null, true); // ServerInvoker serverInvoker = connector.getServerInvoker(); // Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); // field.setAccessible(true); // Map callbackHandlers = (Map) field.get(serverInvoker); // assertEquals(1, callbackHandlers.size()); // client.removeListener(callbackHandler); // assertEquals(0, callbackHandlers.size()); // client.disconnect(); // // // Connect client, add a callback handler, then call Client.removeListenerLocal() // // and verify that callback handler still exists on server. // client = new Client(locator, clientConfig); // client.connect(); // i = (Integer) client.invoke(new Integer(11)); // assertEquals(12, i.intValue()); // callbackHandler = new TestCallbackHandler(); // client.addListener(callbackHandler, null, null, true); // assertEquals(1, callbackHandlers.size()); // client.removeListenerLocal(callbackHandler); // assertEquals(1, callbackHandlers.size()); // client.disconnect(); // // connector.stop(); // log.info(getName() + " PASSES"); // } // // // public void testRemoveListenerLocalPolledCallbacks() throws Throwable // { // log.info("entering " + getName()); // // // Start server. // 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(InvokerLocator.FORCE_REMOTE, "true"); // Connector connector = new Connector(locator, serverConfig); // connector.create(); // connector.addInvocationHandler("test", new TestHandler()); // connector.start(); // // // Connect client, add a callback handler, then call Client.removeListener() // // and verify that callback handler has been removed on server. // HashMap clientConfig = new HashMap(); // clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Client client = new Client(locator, clientConfig); // client.connect(); // Integer i = (Integer) client.invoke(new Integer(7)); // assertEquals(8, i.intValue()); // TestCallbackHandler callbackHandler = new TestCallbackHandler(); // client.addListener(callbackHandler, null, null, false); // ServerInvoker serverInvoker = connector.getServerInvoker(); // Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); // field.setAccessible(true); // Map callbackHandlers = (Map) field.get(serverInvoker); // assertEquals(1, callbackHandlers.size()); // client.removeListener(callbackHandler); // assertEquals(0, callbackHandlers.size()); // client.disconnect(); // // // Connect client, add a callback handler, then call Client.removeListenerLocal() // // and verify that callback handler still exists on server. // client = new Client(locator, clientConfig); // client.connect(); // i = (Integer) client.invoke(new Integer(11)); // assertEquals(12, i.intValue()); // callbackHandler = new TestCallbackHandler(); // client.addListener(callbackHandler, null, null, false); // assertEquals(1, callbackHandlers.size()); // client.removeListenerLocal(callbackHandler); // assertEquals(1, callbackHandlers.size()); // client.disconnect(); // // connector.stop(); // log.info(getName() + " PASSES"); // } // // // public void testRemoveListenerLocalPullCallbacks() throws Throwable // { // log.info("entering " + getName()); // // // Start server. // 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(InvokerLocator.FORCE_REMOTE, "true"); // Connector connector = new Connector(locator, serverConfig); // connector.create(); // connector.addInvocationHandler("test", new TestHandler()); // connector.start(); // // // Connect client, add a callback handler, then call Client.removeListener() // // and verify that callback handler has been removed on server. // HashMap clientConfig = new HashMap(); // clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Client client = new Client(locator, clientConfig); // client.connect(); // Integer i = (Integer) client.invoke(new Integer(7)); // assertEquals(8, i.intValue()); // TestCallbackHandler callbackHandler = new TestCallbackHandler(); // client.addListener(callbackHandler); // ServerInvoker serverInvoker = connector.getServerInvoker(); // Field field = ServerInvoker.class.getDeclaredField("callbackHandlers"); // field.setAccessible(true); // Map callbackHandlers = (Map) field.get(serverInvoker); // assertEquals(1, callbackHandlers.size()); // client.removeListener(callbackHandler); // assertEquals(0, callbackHandlers.size()); // client.disconnect(); // // // Connect client, add a callback handler, then call Client.removeListenerLocal() // // and verify that callback handler still exists on server. // client = new Client(locator, clientConfig); // client.connect(); // i = (Integer) client.invoke(new Integer(11)); // assertEquals(12, i.intValue()); // callbackHandler = new TestCallbackHandler(); // client.addListener(callbackHandler); // assertEquals(1, callbackHandlers.size()); // client.removeListenerLocal(callbackHandler); // assertEquals(1, callbackHandlers.size()); // client.disconnect(); // // connector.stop(); // log.info(getName() + " PASSES"); } public class TestHandler implements ServerInvocationHandler { public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public Object invoke(InvocationRequest invocation) throws Throwable { Integer i = (Integer) invocation.getParameter(); return new Integer(i.intValue() + 1); } public void addListener(InvokerCallbackHandler callbackHandler) {} public void removeListener(InvokerCallbackHandler callbackHandler) {} } public class TestListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) {} } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { log.info("received callback: " + callback); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/ClosingClient.java0000644000175000017500000000426110555056447033324 0ustar twernertwerner/* * 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.shutdown; import java.util.HashMap; import java.util.Map; /** * This class is derived from AbstractClient, and its overriding method daemon() returns * true. That is, AbstractClient will create a long running daemon thread which should not * prevent it from terminating. * * @author Ron Sigal * @version $Revision: 1961 $ *

          * Copyright Jan 19, 2007 *

          */ public class ClosingClient extends AbstractClient { public ClosingClient(String transport, Map config) { super(transport, config); } public static void main(String[] args) { try { if (args.length == 0) throw new RuntimeException(); String transport = args[0]; HashMap config = new HashMap(); System.out.println("args.length: " + args.length); if (args.length > 1) getConfig(config, args[1]); AbstractClient client = new ClosingClient(transport, config); client.testShutdown(); } catch (Throwable t) { t.printStackTrace(); } } protected boolean daemon() { return true; } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/HangingClient.java0000644000175000017500000000425710555056447033306 0ustar twernertwerner/* * 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.shutdown; import java.util.HashMap; import java.util.Map; /** * This class is derived from AbstractClient, and its overriding method daemon() returns * false. That is, AbstractClient will create a long running daemon thread which should * prevent it from terminating. * * @author Ron Sigal * @version $Revision: 1961 $ *

          * Copyright Jan 19, 2007 *

          */ public class HangingClient extends AbstractClient { public HangingClient(String transport, Map config) { super(transport, config); } public static void main(String[] args) { try { if (args.length == 0) throw new RuntimeException(); String transport = args[0]; HashMap config = new HashMap(); System.out.println("args.length: " + args.length); if (args.length > 1) getConfig(config, args[1]); AbstractClient client = new HangingClient(transport, config); client.testShutdown(); } catch (Throwable t) { t.printStackTrace(); } } protected boolean daemon() { return false; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/ShutdownTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/ShutdownTestParent.0000644000175000017500000002640010722765475033555 0ustar twernertwerner/* * 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.shutdown; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.InetAddress; 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.transport.PortUtil; /** * This unit test is meant to guard against the possibility of accidentally * creating non-daemon threads that prevent the Remoting subsystem from * terminating. * * See JIRA issue JBREM-674 "add test case for client exiting correctly". * (http://jira.jboss.com/jira/browse/JBREM-674) * * @author Ron Sigal * @version $Revision: 3011 $ *

          * Copyright Jan 19, 2007 *

          */ public abstract class ShutdownTestParent extends TestCase { protected static Logger log = Logger.getLogger(ShutdownTestParent.class); protected static boolean firstTime = true; protected boolean serverSuccessful; protected boolean clientSuccessful; protected int port; public void setUp() { 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); } serverSuccessful = false; clientSuccessful = false; } /** * This test case verifies that the test really works. In particular, * a non-daemon thread is created in the client JVM that prevents it * from shutting down in the expected time frame. */ public void testHangingClient() throws Throwable { log.info("entering " + getName()); port = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName()); String command = "java -cp \"" + System.getProperty("java.class.path") + "\" "; command += getJVMArguments() + " -Dport=" + port + " "; String serverCommand = command + ShutdownTestServer.class.getName() + " " + getTransport(); serverCommand += " " + getServerArgs(); String clientCommand = command + getHangingClientClassName() + " " + getTransport(); clientCommand += " " + getClientArgs(); Executor serverExecutor = new Executor(serverCommand, true); log.info("starting server"); serverExecutor.start(); log.info("waiting on server"); serverExecutor.waitUntilReady(); log.info("server is ready"); Executor clientExecutor = new Executor(clientCommand, false); log.info("starting client"); clientExecutor.start(); log.info("waiting on client"); clientExecutor.waitUntilReady(); log.info("client is ready"); Thread.sleep(15000); log.info("testing client"); assertFalse(clientSuccessful); Thread.sleep(15000); log.info("testing server"); assertTrue(serverSuccessful); log.info(getName() + " PASSES"); } /** * This test verifies that a JVM with a client, and another JVM with a server, * both terminate. */ public void testClosingClient() throws Throwable { log.info("entering " + getName()); port = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName()); String command = "java -cp \"" + System.getProperty("java.class.path") + "\" "; command += getJVMArguments() + " -Dport=" + port + " "; String serverCommand = command + ShutdownTestServer.class.getName() + " " + getTransport(); serverCommand += " " + getServerArgs(); String clientCommand = command + getClosingClientClassName() + " " + getTransport(); clientCommand += " " + getClientArgs(); Executor serverExecutor = new Executor(serverCommand, true); log.info("starting server"); serverExecutor.start(); log.info("waiting on server"); serverExecutor.waitUntilReady(); log.info("server is ready"); Executor clientExecutor = new Executor(clientCommand, false); log.info("starting client"); clientExecutor.start(); log.info("waiting on client"); clientExecutor.waitUntilReady(); log.info("client is ready"); Thread.sleep(15000); log.info("testing client"); assertTrue(clientSuccessful); Thread.sleep(15000); log.info("testing server"); assertTrue(serverSuccessful); log.info(getName() + " PASSES"); } /** * This test verifies that a server can shut down even if the client does not. */ public void testOpenClient() throws Throwable { log.info("entering " + getName()); port = PortUtil.findFreePort(InetAddress.getLocalHost().getHostName()); String command = "java -cp \"" + System.getProperty("java.class.path") + "\" "; command += getJVMArguments() + " -Dport=" + port + " "; String serverCommand = command + ShutdownTestServer.class.getName() + " " + getTransport(); serverCommand += " " + getServerArgs(); String clientCommand = command + OpenClient.class.getName() + " " + getTransport(); clientCommand += " " + getClientArgs(); Executor serverExecutor = new Executor(serverCommand, true); log.info("starting server"); serverExecutor.start(); log.info("waiting on server"); serverExecutor.waitUntilReady(); log.info("server is ready"); Executor clientExecutor = new Executor(clientCommand, false); log.info("starting client"); clientExecutor.start(); log.info("waiting on client"); clientExecutor.waitUntilReady(); log.info("client is ready"); Thread.sleep(40000); log.info("testing client"); assertFalse(clientSuccessful); log.info("testing server"); assertTrue(serverSuccessful); clientExecutor.destroy(); log.info(getName() + " PASSES"); } protected String getJVMArguments() throws Exception { return ""; } protected String getServerArgs() { return ""; } protected String getClientArgs() { return ""; } protected String getHangingClientClassName() { return HangingClient.class.getName(); } protected String getClosingClientClassName() { return ClosingClient.class.getName(); } abstract protected String getTransport(); public class Executor { private String command; private boolean server; private boolean successful; private Process process; private boolean ready; private Object lock = new Object(); public Executor(String command, boolean server) { this.server = server; this.command = command; } public boolean successful() { return successful; } public void start() throws Exception { executeCommand(command); } private void executeCommand(String command) throws Exception { final String finalCommand = command; new Thread() { public void run() { try { log.info("executing: " + finalCommand); final Process local = Runtime.getRuntime().exec(finalCommand); process = local; final BufferedReader errStream = new BufferedReader(new InputStreamReader(local.getErrorStream())); final BufferedReader inStream = new BufferedReader(new InputStreamReader(local.getInputStream())); new Thread() { public void run() { try { String errOut = null; while((errOut = errStream.readLine()) != null) { System.err.println(errOut); } } catch(IOException e) { } } }.start(); new Thread() { public void run() { try { String stdOut = null; while((stdOut = inStream.readLine()) != null) { System.out.println(stdOut); if (stdOut.indexOf("READY") > -1) { log.info("READY"); synchronized (lock) { ready = true; lock.notify(); } } } } catch(IOException e) { } } }.start(); local.waitFor(); String clientOrServer = server ? "server" : "client"; log.info(clientOrServer + " exit value: " + local.exitValue()); successful = (local.exitValue() == 0); if (server) serverSuccessful = successful; else clientSuccessful = successful; } catch(Exception e) { log.error("Error starting process: " + finalCommand, e); } } }.start(); } public void waitUntilReady() { synchronized (lock) { while (!ready) { try { lock.wait(); } catch (InterruptedException e) { } } } } public void destroy() { process.destroy(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/log4j.xml0000644000175000017500000000701411012356650031450 0ustar twernertwerner ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/AbstractClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/AbstractClient.java0000644000175000017500000001557310722765475033505 0ustar twernertwerner/* * 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.shutdown; 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.ConnectionListener; import org.jboss.remoting.InvokerLocator; 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; /** * @author Ron Sigal * @version $Revision: 3011 $ *

          * Copyright Jan 19, 2007 *

          */ public abstract class AbstractClient extends TestCase { private static Logger log = Logger.getLogger(AbstractClient.class); private String transport; private Map extraConfig; public AbstractClient(String transport, Map config) { this.transport = transport; this.extraConfig = new HashMap(config); log.info("client transport: " + transport); log.info("log4j.configuration: " + System.getProperty("log4j.configuration")); Runtime.getRuntime().traceMethodCalls(true); } /** * This test is used to verify that a JVM with a client connected to a server will shut * down. To exercise as many threads as possible, it enables leasing, registers a * connection listener, and registers a callback handler for blocking polled callbacks * and another callback handler for nonblocking polled callbacks. * * At the end of the method, it creates a Thread which runs longer that this test is * supposed to last. According to the value returned by the overridden abstract * method daemon(), it the Thread will be a daemon or non-daemon thread. */ public void testShutdown() throws Throwable { try { String host = InetAddress.getLocalHost().getHostAddress(); String portString = System.getProperty("port"); int port = Integer.parseInt(portString); String locatorURI = transport + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(extraConfig); clientConfig.put(Client.ENABLE_LEASE, "true"); clientConfig.put(InvokerLocator.CLIENT_LEASE_PERIOD, "1000"); Client client = new Client(locator, clientConfig); client.connect(); log.info("client connected"); log.info("READY"); ConnectionListener listener = new ShutdownTestServer.TestListener(); client.addConnectionListener(listener, 1000); Integer i = (Integer) client.invoke(new Integer(17)); if (18 != i.intValue()) throw new Exception("invocation failed"); log.info("invocation successful"); TestCallbackHandler callbackHandler1 = new TestCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(ServerInvoker.BLOCKING_TIMEOUT, "2000"); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); addCallbackArgs(metadata); log.info("metadata: " + metadata); client.addListener(callbackHandler1, metadata, null, false); log.info("added blocking listener 1"); TestCallbackHandler callbackHandler2 = new TestCallbackHandler(); metadata.clear(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "500"); metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.NONBLOCKING); addCallbackArgs(metadata); log.info("metadata: " + metadata); client.addListener(callbackHandler2, metadata, null, false); log.info("added nonblocking listener 2"); Thread.sleep(4000); if (!callbackHandler1.receivedCallback) { log.info("callback 1 failed"); throw new Exception("callback 1 failed"); } if (!callbackHandler2.receivedCallback) { log.info("callback 2 failed"); throw new Exception("callback 2 failed"); } log.info("callback successful"); client.removeConnectionListener(listener); log.info("calling removeListener(): 1"); client.removeListener(callbackHandler1); log.info("calling removeListener(): 2"); client.removeListener(callbackHandler2); log.info("calling disconnect()"); client.disconnect(); Thread t = new Thread() { public void run() { try { Thread.sleep(20000); } catch (InterruptedException e) { log.info("interrupted"); } } }; t.setDaemon(daemon()); t.start(); log.info("client disconnected"); } catch (Exception e) { log.info("exception in client: " + e); System.exit(1); } } abstract protected boolean daemon(); protected void addCallbackArgs(Map map) { return; } protected static void getConfig(Map config, String configs) { int start = 0; int ampersand = configs.indexOf('&'); while (ampersand > 0) { String s = configs.substring(start, ampersand); int equals = s.indexOf('='); String param = s.substring(0, equals); String value = s.substring(equals + 1); config.put(param, value); start = ampersand + 1; ampersand = configs.indexOf('&', start); } } public class TestCallbackHandler implements InvokerCallbackHandler { public boolean receivedCallback; public void handleCallback(Callback callback) throws HandleCallbackException { receivedCallback = true; log.info("received callback: " + callback); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/shutdown/OpenClient.java0000644000175000017500000001143710722765475032636 0ustar twernertwerner/* * 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.shutdown; 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; /** * @author Ron Sigal * @version $Revision: 3011 $ *

          * Copyright Jan 19, 2007 *

          */ public class OpenClient extends TestCase { private static Logger log = Logger.getLogger(OpenClient.class); private String transport; private Map extraConfig; private Client client; public OpenClient(String transport, Map config) { this.transport = transport; this.extraConfig = new HashMap(config); log.info("client transport: " + transport); Runtime.getRuntime().traceMethodCalls(true); } /** * This test is used to verify that a server can shut down even if a client does not. */ public void testShutdown() throws Throwable { try { String host = InetAddress.getLocalHost().getHostAddress(); String portString = System.getProperty("port"); int port = Integer.parseInt(portString); String locatorURI = transport + "://" + host + ":" + port; InvokerLocator locator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(extraConfig); client = new Client(locator, clientConfig); client.connect(); log.info("client connected"); log.info("READY"); for (int i = 0; i < 5; i++) { new InvokerThread(i).start(); } log.info("going to sleep"); log.info("*******************************************************"); log.info("**************** EXPECT EXCEPTIONS ****************"); log.info("*******************************************************"); Thread.sleep(60000); log.info("calling disconnect()"); client.disconnect(); log.info("client disconnected"); } catch (Exception e) { log.info("exception in client: " + e); System.exit(1); } } protected void addCallbackArgs(Map map) { return; } protected static void getConfig(Map config, String configs) { int start = 0; int ampersand = configs.indexOf('&'); while (ampersand > 0) { String s = configs.substring(start, ampersand); int equals = s.indexOf('='); String param = s.substring(0, equals); String value = s.substring(equals + 1); config.put(param, value); start = ampersand + 1; ampersand = configs.indexOf('&', start); } } public static void main(String[] args) { try { if (args.length == 0) throw new RuntimeException(); String transport = args[0]; HashMap config = new HashMap(); System.out.println("args.length: " + args.length); if (args.length > 1) getConfig(config, args[1]); OpenClient client = new OpenClient(transport, config); client.testShutdown(); } catch (Throwable t) { t.printStackTrace(); } } public class InvokerThread extends Thread { private int id; public InvokerThread(int id) { this.id = id; setName("InvokerThread:" + id); } public void run() { try { log.info("client " + id + " making invocation"); client.invoke(new Integer(id)); log.info("client " + id + " made invocation"); } catch (Throwable e) { e.printStackTrace(); } } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/clientaddress/0000755000175000017500000000000011632407033030656 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/clientaddress/ClientAddressTestParent.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/clientaddress/ClientAddressT0000644000175000017500000002573510721244253033466 0ustar twernertwerner/* * 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.clientaddress; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; 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.Remoting; 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; public abstract class ClientAddressTestParent extends TestCase { private static Logger log = Logger.getLogger(ClientAddressTestParent.class); private static final String GET_ADDRESS = "getAddress"; private static final String OPEN_CONNECTION = "openConnection"; private static final String COPY = "copy:"; private static final String SEND_CALLBACK = "sendCallback"; private static final int ANSWER = 17; private static boolean firstTime = true; protected Connector connector; protected InvokerLocator serverLocator; protected String locatorURI; protected String host; protected int port; protected TestInvocationHandler invocationHandler; protected int callbackPort; 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 a valid InetAddress for the client is passed to the * org.jboss.remoting.ServerInvocationHandler in the * org.jboss.remoting.InvocationRequest requestPayload. * @throws Throwable */ public void testClientAddress() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(); // Create client. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator1, clientConfig); client.connect(); log.info("client is connected"); // Test client address facility. final InetAddress localAddressFromServer = (InetAddress) client.invoke(GET_ADDRESS); log.info("local address according to server: " + localAddressFromServer); final int randomPort = PortUtil.findFreePort(localAddressFromServer.getHostAddress()); callbackPort = randomPort; class TestThread extends Thread { public int result = -1; public void run() { try { ServerSocket ss = new ServerSocket(randomPort, 200, localAddressFromServer); log.info("created ServerSocket bound to: " + ss.getLocalSocketAddress()); Socket s = ss.accept(); log.info("accepted socket: " + s); InputStream is = s.getInputStream(); result = is.read(); log.info("read: " + result); s.close(); ss.close(); } catch (Exception e) { log.error(e); } } }; TestThread t = new TestThread(); t.start(); Thread.sleep(5000); HashMap metadata = new HashMap(); metadata.put("callbackPort", new Integer(callbackPort)); client.invoke(OPEN_CONNECTION, metadata); Thread.sleep(5000); assertEquals(ANSWER, t.result); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verifies that the address returned by * org.jboss.remoting.Client.getAddressSeenByServer() is valid. */ public void testGetAddressSeenByServer() 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: " + locatorURI); // Test connections. assertEquals("abc", client.invoke("copy:abc")); log.info("connection is good"); // Get address as seen by server and create callback Connector with that address. InetAddress callbackAddress = client.getAddressSeenByServer(); log.info("client address seen by server: " + callbackAddress); String callbackHost = callbackAddress.getHostAddress(); int callbackPort = PortUtil.findFreePort(callbackHost); String callbackLocatorURI = getCallbackTransport() + "://" + callbackHost + ":" + callbackPort; callbackLocatorURI += "/?timeout=10000"; InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); log.info("callback locator: " + callbackLocator); HashMap callbackConfig = new HashMap(); addExtraCallbackConfig(callbackConfig); Connector callbackConnector = new Connector(callbackLocator, callbackConfig); callbackConnector.start(); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, callbackLocator); // Tell server to send a callback, and verify it was received. client.invoke(SEND_CALLBACK); assertEquals(1, callbackHandler.counter); client.removeListener(callbackHandler); callbackConnector.stop(); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } protected abstract String getTransport(); protected String getCallbackTransport() { return getTransport(); } 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() { if (connector != null) connector.stop(); } protected String reconstructLocator(InetAddress address) { return getTransport() + "://" + address.getHostAddress() + ":" + port; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void addExtraCallbackConfig(Map config) {} class TestInvocationHandler implements ServerInvocationHandler { private InvokerCallbackHandler callbackHandler; public void addListener(InvokerCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } public Object invoke(final InvocationRequest invocation) throws Throwable { Object o = invocation.getParameter(); if (! (o instanceof String)) throw new Exception("command should be a String: " + o); String command = (String) o; log.info("command: " + command); if (GET_ADDRESS.equals(command)) { return invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS); } else if (OPEN_CONNECTION.equals(command)) { InetAddress addr = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS); log.info("creating socket connected to: " + addr); Integer callbackPortInt = (Integer) invocation.getRequestPayload().get("callbackPort"); int callbackPort = callbackPortInt.intValue(); Socket s = new Socket(addr, callbackPort); log.info("created socket connected to: " + addr); OutputStream os = s.getOutputStream(); os.write(ANSWER); log.info("wrote answer"); s.close(); return null; } else if (SEND_CALLBACK.equals(command)) { callbackHandler.handleCallback(new Callback("callback")); return null; } else if (command.startsWith(COPY)) { return command.substring(5); } else { throw new Exception("unrecognized command: " + command); } } public void removeListener(InvokerCallbackHandler callbackHandler) {} public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } class TestCallbackHandler implements InvokerCallbackHandler { public int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; log.info("received callback"); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ssl/0000755000175000017500000000000011632407043026634 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ssl/SSLSocketBuilderTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ssl/SSLSocketBuilderTestCase0000644000175000017500000000711310761423553033344 0ustar twernertwerner/* * 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.ssl; import junit.framework.TestCase; import org.jboss.remoting.security.SSLSocketBuilder; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import java.io.IOException; import java.util.HashMap; import java.util.Map; /** * Test case to validate behavior of SSLSocketBuilder. * @author Tom Elrod */ public class SSLSocketBuilderTestCase extends TestCase { /** * Test is specifically to verify can have different keystore password * and key password (per JBREM-488) * @throws IOException */ public void testKeyPassword() throws IOException { SSLSocketBuilder socketBuilder = new SSLSocketBuilder(); socketBuilder.setUseSSLServerSocketFactory(false); socketBuilder.setSecureSocketProtocol("TLS"); socketBuilder.setKeyStoreAlgorithm("SunX509"); socketBuilder.setKeyStoreType("JKS"); String keyStoreFilePath = this.getClass().getResource("ssl.keystore").getFile(); socketBuilder.setKeyStoreURL(keyStoreFilePath); socketBuilder.setKeyStorePassword("foobar"); socketBuilder.setKeyPassword("barfoo"); ServerSocketFactory svrSocketFactory = socketBuilder.createSSLServerSocketFactory(); assertNotNull(svrSocketFactory); } /** * Added for JBREM-510. */ public void testSocketFactoryInServerMode() throws Throwable { try { Map config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); SSLSocketBuilder socketBuilder = new SSLSocketBuilder(config); socketBuilder.setUseSSLSocketFactory(false); socketBuilder.createSSLSocketFactory(); fail("should have thrown IOException"); } catch (IOException e) { assertEquals("Error initializing socket factory SSL context: Can not find keystore url.", e.getMessage()); } } /** * Added for JBREM-510. */ public void testSocketFactoryInClientMode() throws IOException { SSLSocketBuilder socketBuilder = new SSLSocketBuilder(); socketBuilder.setUseSSLServerSocketFactory(false); socketBuilder.setSecureSocketProtocol("TLS"); socketBuilder.setKeyStoreAlgorithm("SunX509"); socketBuilder.setKeyStoreType("JKS"); String trustStoreFilePath = this.getClass().getResource("ssl.truststore").getFile(); socketBuilder.setTrustStoreURL(trustStoreFilePath); socketBuilder.setTrustStorePassword("foobar"); SocketFactory socketFactory = socketBuilder.createSSLSocketFactory(); assertNotNull(socketFactory); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ssl/ssl.keystore0000644000175000017500000000251010436460515031226 0ustar twernertwernerþíþíssl ~Túº0‚¶0 +*‚¢ž@è„¢knéÿ<½?#´‹)eC<›ÎtRĽãßÌÿL¹Ž±fìZ‚’¨íž_)GmbKéni#€vh‹r\`Uû¼¨ÁçãÉÕH*™Š‹3ÿ™Ì»ü!u=[ßpÄÅÊ:×Õ!ü©7ùü'‰×úOú÷HtœÁ–Rm/DGBº k`Óé2œ ¿—B:²d…l¾r~þ^@§Õd¼ò6WÌDYçûR(åÜ ¼ŸxJÇ-s[ú"Q±¶ˆŽ&‘øAŸø„—:Ü6G .n¬L³£÷ âÓÓ#¤eñ€yãa8Æ+bóM šß¨èl©lQÄÆD^tTP¦ûMU÷ÝQ$à4}GmÄ+f_¦;Çïw¢l¤Ôsømõ‰“ç%ib½T¬C[þSB¹Ù±<Zz Žé±|ª„¶ß¸ÿT•ôMÊ >Jâöø€ÑžRM‘­ ç/Í7¤+Tà×k¹©r ½"ß3Wú­YQðÄ|¬#êŠÿ†,‹0ú¢H”Ç á,‡Û;µØ+‡ÀPéäÖ<îæafy‡23!R°ÜÃ3ÔYæ¶Ì~fæmò;ÒP·§¸Šæ3êÜÈø§ý3²0x0Nö­ê8"\u.kÛŒ`ÅN˜êÀä‡bQšX?äG "$3Ä›ôUÞ:ÂÝsgù¢~º• økÇÏ.4²V`/Ь5Fÿ;â0¸ôM|gÑR¾M*¹ãý"í1Ì5t\*Täkv¯mž/7ÈVÞ|Ç@œÊ=?ÈLFÆŽuè¨2Ù©hY ¾¤ô•T„'#eš ?îow+š•é>ÊЉ«]9¦l ˆ€‹ïÅ—ÄES^ƒÛ85 ÓûT<ÌbÞ·meÎXNsX.509J0‚F0‚¯Dz_ 0  *†H†÷ 0j1 0 UUS1 0 UGA10UAtlanta10U  JBoss Inc10U  Development10U Tom Elrod0 060529024009Z 090501024009Z0j1 0 UUS1 0 UGA10UAtlanta10U  JBoss Inc10U  Development10U Tom Elrod0Ÿ0  *†H†÷ 0‰«Ÿ$Cò?ÃÆÙXÃRon Sigal *

          * Copyright Dec 19, 2009 *

          * @version $Rev$ */ public class EmptyStoreTestCase extends TestCase { private static Logger log = Logger.getLogger(EmptyStoreTestCase.class); private static boolean firstTime = true; 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 testNONEKeyStore() throws Throwable { log.info("entering " + getName()); // Create SSLSocketBuilder. HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, "NONE"); // config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "dummy"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, "NONE"); // config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "dummy"); SSLSocketBuilder socketBuilder = new SSLSocketBuilder(config); socketBuilder.setUseSSLServerSocketFactory(false); socketBuilder.setUseSSLSocketFactory(false); // Create ServerSocket. try { ServerSocketFactory ssf = socketBuilder.createSSLServerSocketFactory(); ServerSocket ss = ssf.createServerSocket(); ss.close(); } catch (IOException e) { fail("Unable to create ServerSocket"); } // Create Socket. try { SocketFactory sf = socketBuilder.createSSLSocketFactory(); Socket s = sf.createSocket(); s.close(); } catch (IOException e) { fail("Unable to create Socket"); } log.info(getName() + " PASSES"); } /** * Creates "NONE" dynamically to test JBREM-1185. */ public void testDistinctNONEKeyStore() throws Throwable { log.info("entering " + getName()); // Create SSLSocketBuilder. HashMap config = new HashMap(); String none = new StringBuffer("NONE").toString(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, none); // config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "dummy"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, none); // config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "dummy"); SSLSocketBuilder socketBuilder = new SSLSocketBuilder(config); socketBuilder.setUseSSLServerSocketFactory(false); socketBuilder.setUseSSLSocketFactory(false); // Create ServerSocket. try { ServerSocketFactory ssf = socketBuilder.createSSLServerSocketFactory(); ServerSocket ss = ssf.createServerSocket(); ss.close(); } catch (IOException e) { fail("Unable to create ServerSocket"); } // Create Socket. try { SocketFactory sf = socketBuilder.createSSLSocketFactory(); Socket s = sf.createSocket(); s.close(); } catch (IOException e) { fail("Unable to create Socket"); } log.info(getName() + " PASSES"); } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ssl/SSLSupportedTransportTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ssl/SSLSupportedTransportTes0000644000175000017500000000461411413671173033530 0ustar twernertwerner/* * 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.ssl; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import junit.framework.TestCase; import org.jboss.remoting.InvokerRegistry; /** * @author Tom Elrod */ public class SSLSupportedTransportTestCase extends TestCase { public void testTransportSupportsSSL() throws Exception { final String[] transports = new String[] {"socket", "sslsocket", "multiplex", "sslmultiplex", "rmi", "sslrmi", "http", "https"}; boolean[] expextedResult = new boolean[] {false, true, false, true, false, true, false, true}; for(int x = 0; x < transports.length; x++) { Boolean isSupported = null; final int finalX = x; try { isSupported = (Boolean) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new Boolean(InvokerRegistry.isSSLSupported(transports[finalX])); } }); } catch (PrivilegedActionException pae) { throw pae.getException(); } assertEquals("transport " + transports[x] + " was supposed to be " + expextedResult[x] + " for supporting ssl.", expextedResult[x], isSupported.booleanValue()); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ssl/ssl.truststore0000644000175000017500000000120610436460515031620 0ustar twernertwernerþíþíssl ~ï¥X.509J0‚F0‚¯Dz_ 0  *†H†÷ 0j1 0 UUS1 0 UGA10UAtlanta10U  JBoss Inc10U  Development10U Tom Elrod0 060529024009Z 090501024009Z0j1 0 UUS1 0 UGA10UAtlanta10U  JBoss Inc10U  Development10U Tom Elrod0Ÿ0  *†H†÷ 0‰«Ÿ$Cò?ÃÆÙXÃRon Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 17, 2010 */ public class MalformedLocatorTestCase extends TestCase { private ByteArrayOutputStream baos; private PrintStream originalPrintStream; private Logger log; public void setUp() throws Exception { originalPrintStream = System.out; baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); setOut(ps); 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); log = Logger.getLogger(MalformedLocatorTestCase.class); } public void tearDown() { } public void testMalformedLocatorDefaultLogging() throws Throwable { log.info("entering " + getName()); String locatorURI = "bisocket://UNDER_SCORE:4457//?JBM_clientMaxPoolSize=200"; InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println(locatorURI + " -> " + locator); setOut(originalPrintStream); String s = new String(baos.toByteArray()); System.out.println(s); assertTrue(s.indexOf("WARN") >= 0); assertTrue(s.indexOf("Host resolves to null") >= 0); System.out.println(getName() + " PASSES"); } public void testMalformedLocatorLoggingTurnedOff() throws Throwable { log.info("entering " + getName()); setSystemProperty(InvokerLocator.SUPPRESS_HOST_WARNING, "true"); String locatorURI = "bisocket://UNDER_SCORE:4457//?JBM_clientMaxPoolSize=200"; InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println(locatorURI + " -> " + locator); setOut(originalPrintStream); String s = new String(baos.toByteArray()); System.out.println(s); assertTrue(s.indexOf("WARN") == -1); assertTrue(s.indexOf("Host resolves to null") == -1); System.out.println(getName() + " PASSES"); } public void testMalformedLocatorLoggingTurnedOn() throws Throwable { log.info("entering " + getName()); setSystemProperty(InvokerLocator.SUPPRESS_HOST_WARNING, "false"); String locatorURI = "bisocket://UNDER_SCORE:4457//?JBM_clientMaxPoolSize=200"; InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println(locatorURI + " -> " + locator); setOut(originalPrintStream); String s = new String(baos.toByteArray()); System.out.println(s); assertTrue(s.indexOf("WARN") >= 0); assertTrue(s.indexOf("Host resolves to null") >= 0); System.out.println(getName() + " PASSES"); } public void testWellformedLocator() throws Throwable { log.info("entering " + getName()); String locatorURI = "bisocket://UNDERSCORE:4457//?JBM_clientMaxPoolSize=200"; InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println(locatorURI + " -> " + locator); setOut(originalPrintStream); String s = new String(baos.toByteArray()); System.out.println(s); assertTrue(s.indexOf("WARN") == -1); assertTrue(s.indexOf("Host resolves to null") == -1); System.out.println(getName() + " PASSES"); } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } static private void setOut(final PrintStream ps) { if (SecurityUtility.skipAccessControl()) { System.setOut(ps); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { System.setOut(ps); return null; } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/locator/InvokerLocatorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/locator/InvokerLocatorTestCa0000644000175000017500000005254711161050424033475 0ustar twernertwerner/* * 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.locator; import java.net.InetAddress; import java.net.MalformedURLException; import java.util.List; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Home; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class InvokerLocatorTestCase extends TestCase { protected Logger log = Logger.getLogger(InvokerLocatorTestCase.class); public void testLegacyParsingFlag() throws Exception { // Test no legacy flag configuration. InvokerLocator locator = new InvokerLocator("http://localhost:1234/services"); assertEquals("/services", locator.getPath()); // Test setting legacy parsing by System property System.setProperty(InvokerLocator.LEGACY_PARSING, "true"); locator = new InvokerLocator("http://localhost:1234/services"); assertEquals("services", locator.getPath()); // Test setting legacy parsing by InvokerLocator static field. System.setProperty(InvokerLocator.LEGACY_PARSING, ""); InvokerLocator.setUseLegacyParsing(true); locator = new InvokerLocator("http://localhost:1234/services"); assertEquals("services", locator.getPath()); // Test that static field overrides System property. InvokerLocator.setUseLegacyParsing(true); System.setProperty(InvokerLocator.LEGACY_PARSING, "false"); locator = new InvokerLocator("http://localhost:1234/services"); assertEquals("services", locator.getPath()); // Test that static field overrides System property. InvokerLocator.setUseLegacyParsing(false); System.setProperty(InvokerLocator.LEGACY_PARSING, "true"); locator = new InvokerLocator("http://localhost:1234/services"); assertEquals("/services", locator.getPath()); } /** * testLegacyLocatorConfig tests the original version of InvokerLocator parsing. */ public void testLegacyLocatorConfig() throws Exception { System.setProperty(InvokerLocator.LEGACY_PARSING, "true"); InvokerLocator locator = new InvokerLocator("http://localhost:1234/services/uri:Test"); InvokerLocator locator2 = new InvokerLocator("http://localhost:1234"); InvokerLocator locator3 = new InvokerLocator("http://127.0.0.1:1234"); InvokerLocator locator4 = new InvokerLocator("http://1.2.3.4/aaa"); InvokerLocator locator5 = new InvokerLocator("http://1.2.3.4/abB"); assertFalse(locator.equals(null)); assertFalse(locator.equals(locator2)); assertFalse(locator.isSameEndpoint(null)); assertTrue(locator.isSameEndpoint(locator2)); assertFalse(locator.equals(locator3)); assertFalse(locator.isSameEndpoint(locator3)); assertTrue(locator4.equals(locator4)); assertFalse(locator4.equals(locator5)); assertTrue(locator5.equals(locator5)); assertFalse(locator5.equals(locator4)); String url = locator.getLocatorURI(); String origUrl = locator.getOriginalURI(); // assertEquals("http://127.0.0.1:1234/services/uri:Test", url); assertEquals("http://localhost:1234/services/uri:Test", url); assertEquals("http://localhost:1234/services/uri:Test", origUrl); locator = new InvokerLocator("http://localhost/services/uri:Test"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); // assertEquals("http://127.0.0.1/services/uri:Test", url); assertEquals("http://localhost/services/uri:Test", url); assertEquals("http://localhost/services/uri:Test", origUrl); locator = new InvokerLocator("socket://localhost:1234"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); // assertEquals("socket://127.0.0.1:1234/", url); assertEquals("socket://localhost:1234/", url); assertEquals("socket://localhost:1234", origUrl); locator = new InvokerLocator("socket://localhost:1234/some/path"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); // assertEquals("socket://127.0.0.1:1234/some/path", url); assertEquals("socket://localhost:1234/some/path", url); assertEquals("socket://localhost:1234/some/path", origUrl); locator = new InvokerLocator("socket://myhost:1234"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); assertEquals("socket://myhost:1234/", url); assertEquals("socket://myhost:1234", origUrl); locator = new InvokerLocator("socket://myhost"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); assertEquals("socket://myhost/", url); assertEquals("socket://myhost", origUrl); locator = new InvokerLocator("socket://myhost"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); assertEquals("socket://myhost/", url); assertEquals("socket://myhost", origUrl); } /** * testURILocatorConfig() tests the new version of InvokerLocator parsing. */ public void testURILocatorConfig() throws Exception { InvokerLocator.setUseLegacyParsing(false); System.setProperty(InvokerLocator.LEGACY_PARSING, "false"); InvokerLocator locator = new InvokerLocator("http://localhost:1234/services/uri:Test"); InvokerLocator locator2 = new InvokerLocator("http://localhost:1234"); InvokerLocator locator3 = new InvokerLocator("http://127.0.0.1:1234"); InvokerLocator locator4 = new InvokerLocator("http://1.2.3.4/aaa"); InvokerLocator locator5 = new InvokerLocator("http://1.2.3.4/abB"); // Test that path starts with '/', in accordance with // RFC 2396 "Uniform Resource Identifiers (URI): Generic Syntax" assertEquals("/services/uri:Test", locator.getPath()); assertEquals("", locator2.getPath()); assertEquals("/aaa", locator4.getPath()); assertEquals("/abB", locator5.getPath()); assertFalse(locator.equals(null)); assertFalse(locator.equals(locator2)); assertFalse(locator.isSameEndpoint(null)); assertTrue(locator.isSameEndpoint(locator2)); assertFalse(locator.equals(locator3)); assertFalse(locator.isSameEndpoint(locator3)); assertTrue(locator4.equals(locator4)); assertFalse(locator4.equals(locator5)); assertTrue(locator5.equals(locator5)); assertFalse(locator5.equals(locator4)); String url = locator.getLocatorURI(); String origUrl = locator.getOriginalURI(); // assertEquals("http://127.0.0.1:1234/services/uri:Test", url); assertEquals("http://localhost:1234/services/uri:Test", url); assertEquals("http://localhost:1234/services/uri:Test", origUrl); locator = new InvokerLocator("http://localhost/services/uri:Test"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); // assertEquals("http://127.0.0.1/services/uri:Test", url); assertEquals("http://localhost/services/uri:Test", url); assertEquals("http://localhost/services/uri:Test", origUrl); locator = new InvokerLocator("socket://localhost:1234"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); // assertEquals("socket://127.0.0.1:1234/", url); assertEquals("socket://localhost:1234/", url); assertEquals("socket://localhost:1234", origUrl); locator = new InvokerLocator("socket://localhost:1234/some/path"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); // assertEquals("socket://127.0.0.1:1234/some/path", url); assertEquals("socket://localhost:1234/some/path", url); assertEquals("socket://localhost:1234/some/path", origUrl); locator = new InvokerLocator("socket://myhost:1234"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); assertEquals("socket://myhost:1234/", url); assertEquals("socket://myhost:1234", origUrl); locator = new InvokerLocator("socket://myhost"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); assertEquals("socket://myhost/", url); assertEquals("socket://myhost", origUrl); locator = new InvokerLocator("socket://myhost"); url = locator.getLocatorURI(); origUrl = locator.getOriginalURI(); assertEquals("socket://myhost/", url); assertEquals("socket://myhost", origUrl); } public void testJBREM645() throws MalformedURLException { InvokerLocator.setUseLegacyParsing(false); System.setProperty(InvokerLocator.LEGACY_PARSING, "false"); String locatorURI ="socket://succubus.starkinternational.com:4446?datatype=invocation"; InvokerLocator locator = new InvokerLocator(locatorURI); int port = locator.getPort(); assertEquals(4446, port); } public void testMultihome() throws Throwable { // Test with host == "multihome". String url = "socket://multihome:44/?connecthomes=a.b:55!c.d!e.f:66&homes=g.h:77!i.j"; InvokerLocator locator = new InvokerLocator(url); assertEquals("multihome", locator.getHost()); String connectHomes = locator.getConnectHomes(); assertEquals("a.b:55!c.d:44!e.f:66", connectHomes); List connectHomeList = locator.getConnectHomeList(); assertEquals(3, connectHomeList.size()); assertEquals(new Home("a.b", 55), connectHomeList.get(0)); assertEquals(new Home("c.d", 44), connectHomeList.get(1)); assertEquals(new Home("e.f", 66), connectHomeList.get(2)); String homes = locator.getHomes(); assertEquals("g.h:77!i.j:44", homes); List homeList = locator.getHomeList(); assertEquals(2, homeList.size()); assertEquals(new Home("g.h", 77), homeList.get(0)); assertEquals(new Home("i.j", 44), homeList.get(1)); url = "socket://multihome:44/?homes=a.b:55!c.d!e.f:66"; locator = new InvokerLocator(url); assertEquals("multihome", locator.getHost()); homes = locator.getHomes(); assertEquals("a.b:55!c.d:44!e.f:66", homes); homeList = locator.getHomeList(); assertEquals(3, homeList.size()); assertEquals(new Home("a.b", 55), homeList.get(0)); assertEquals(new Home("c.d", 44), homeList.get(1)); assertEquals(new Home("e.f", 66), homeList.get(2)); connectHomes = locator.getConnectHomes(); assertEquals("", connectHomes); connectHomeList = locator.getConnectHomeList(); assertEquals(0, connectHomeList.size()); // Test with host != "multihome". url = "socket://jboss.org:44/?connecthomes=a.b:55!c.d!e.f:66&homes=g.h:77!i.j"; locator = new InvokerLocator(url); assertEquals("jboss.org", locator.getHost()); assertEquals(44, locator.getPort()); assertEquals("g.h:77!i.j:44", locator.getHomes()); assertEquals(2, locator.getHomeList().size()); assertTrue(locator.getHomeList().contains(new Home("g.h", 77))); assertTrue(locator.getHomeList().contains(new Home("i.j", 44))); assertEquals("jboss.org:44", locator.getConnectHomes()); assertEquals(1, locator.getConnectHomeList().size()); assertTrue(locator.getConnectHomeList().contains(new Home("jboss.org", 44))); url = "socket://jboss.org:44/?homes=a.b:55!c.d!e.f:66"; locator = new InvokerLocator(url); assertEquals("jboss.org", locator.getHost()); assertEquals(44, locator.getPort()); assertEquals("a.b:55!c.d:44!e.f:66", locator.getHomes()); homeList = locator.getHomeList(); assertEquals(3, homeList.size()); assertTrue(homeList.contains(new Home("a.b", 55))); assertTrue(homeList.contains(new Home("c.d", 44))); assertTrue(homeList.contains(new Home("e.f", 66))); connectHomes = locator.getConnectHomes(); assertEquals("jboss.org:44", connectHomes); connectHomeList = locator.getConnectHomeList(); assertEquals(1, connectHomeList.size()); assertEquals(new Home("jboss.org", 44), connectHomeList.get(0)); // Test InvokerLocator.isMultihome(). locator = new InvokerLocator("socket://jboss.org:44"); assertFalse(locator.isMultihome()); locator = new InvokerLocator("socket://jboss.org:44/?homes=a.b:55!c.d!e.f:66"); assertFalse(locator.isMultihome()); locator = new InvokerLocator("socket://jboss.org:44/?connecthomes=a.b:55!c.d!e.f:66"); assertFalse(locator.isMultihome()); locator = new InvokerLocator("socket://multihome/?homes=a.b:55!c.d!e.f:66"); assertTrue(locator.isMultihome()); } public void testBasicCompatibilityNoMultihome() throws Throwable { InvokerLocator l1 = new InvokerLocator("socket://a.b:8888/some/path/?y=z"); InvokerLocator l2 = new InvokerLocator("socket://c.d:8888/some/path/?y=z"); InvokerLocator l3 = new InvokerLocator("socket://a.b:9999/some/path/?y=z"); InvokerLocator l4 = new InvokerLocator("socket://a.b:8888/other/path/?y=z"); InvokerLocator l5 = new InvokerLocator("socket://a.b:8888/some/path/?a=b"); assertTrue(l1.isCompatibleWith(l1)); assertFalse(l1.isCompatibleWith(l2)); assertFalse(l1.isCompatibleWith(l3)); assertFalse(l1.isCompatibleWith(l4)); assertFalse(l1.isCompatibleWith(l5)); assertTrue(l1.isCompatibleWith(l1)); assertFalse(l2.isCompatibleWith(l1)); assertFalse(l3.isCompatibleWith(l1)); assertFalse(l4.isCompatibleWith(l1)); assertFalse(l5.isCompatibleWith(l1)); } public void testBasicCompatibilityWithMultihome() throws Throwable { InvokerLocator l1 = new InvokerLocator("socket://multihome:8888/some/path/?y=z&homes=a.b!c.d"); InvokerLocator l2 = new InvokerLocator("socket://multihome:9999/some/path/?y=z&homes=a.b!c.d"); InvokerLocator l3 = new InvokerLocator("socket://multihome:8888/other/path/?y=z&homes=a.b!c.d"); InvokerLocator l4 = new InvokerLocator("socket://multihome:8888/some/path/?a=b&homes=a.b!c.d"); assertTrue(l1.isCompatibleWith(l1)); assertFalse(l1.isCompatibleWith(l2)); assertFalse(l1.isCompatibleWith(l3)); assertFalse(l1.isCompatibleWith(l4)); assertFalse(l2.isCompatibleWith(l1)); assertTrue(l2.isCompatibleWith(l2)); assertFalse(l2.isCompatibleWith(l3)); assertFalse(l2.isCompatibleWith(l4)); assertFalse(l3.isCompatibleWith(l1)); assertFalse(l3.isCompatibleWith(l2)); assertTrue(l3.isCompatibleWith(l3)); assertFalse(l3.isCompatibleWith(l4)); assertFalse(l4.isCompatibleWith(l1)); assertFalse(l4.isCompatibleWith(l2)); assertFalse(l4.isCompatibleWith(l3)); assertTrue(l4.isCompatibleWith(l4)); } public void testMultihomeCompatibility() throws Throwable { InvokerLocator l1 = new InvokerLocator("socket://a.b:11/some/path/?y=z"); InvokerLocator l2 = new InvokerLocator("socket://c.d:22/some/path/?y=z"); InvokerLocator l3 = new InvokerLocator("socket://multihome:11/some/path/?y=z&homes=a.b!c.d"); InvokerLocator l4 = new InvokerLocator("socket://multihome:11/some/path/?y=z&homes=a.b!c.d!e.f"); InvokerLocator l5 = new InvokerLocator("socket://multihome:11/some/path/?y=z&homes=a.b:22!e.f!g.h"); InvokerLocator l6 = new InvokerLocator("socket://multihome:11/some/path/?y=z&connecthomes=a.b&homes=a.b:22!c.d:22"); assertTrue(l1.isCompatibleWith(l1)); assertFalse(l1.isCompatibleWith(l2)); assertTrue(l1.isCompatibleWith(l3)); assertTrue(l1.isCompatibleWith(l4)); assertFalse(l1.isCompatibleWith(l5)); assertTrue(l1.isCompatibleWith(l6)); assertFalse(l2.isCompatibleWith(l1)); assertTrue(l2.isCompatibleWith(l2)); assertFalse(l2.isCompatibleWith(l3)); assertFalse(l2.isCompatibleWith(l4)); assertFalse(l2.isCompatibleWith(l5)); assertTrue(l2.isCompatibleWith(l6)); assertTrue(l3.isCompatibleWith(l1)); assertFalse(l3.isCompatibleWith(l2)); assertTrue(l3.isCompatibleWith(l3)); assertTrue(l3.isCompatibleWith(l4)); assertFalse(l3.isCompatibleWith(l5)); assertTrue(l3.isCompatibleWith(l6)); assertTrue(l4.isCompatibleWith(l1)); assertFalse(l4.isCompatibleWith(l2)); assertTrue(l4.isCompatibleWith(l3)); assertTrue(l4.isCompatibleWith(l4)); assertTrue(l4.isCompatibleWith(l5)); assertTrue(l4.isCompatibleWith(l6)); assertFalse(l5.isCompatibleWith(l1)); assertFalse(l5.isCompatibleWith(l2)); assertFalse(l5.isCompatibleWith(l3)); assertTrue(l5.isCompatibleWith(l4)); assertTrue(l5.isCompatibleWith(l5)); assertTrue(l5.isCompatibleWith(l6)); assertTrue(l6.isCompatibleWith(l1)); assertFalse(l6.isCompatibleWith(l2)); assertTrue(l6.isCompatibleWith(l3)); assertTrue(l6.isCompatibleWith(l4)); assertFalse(l6.isCompatibleWith(l5)); assertTrue(l6.isCompatibleWith(l6)); } public void testMultihomeDefaultPorts() throws Throwable { InvokerLocator l = new InvokerLocator("socket://multihome/?homes=a.b!c.d:12"); assertEquals("a.b:-1!c.d:12", l.getHomes()); l = new InvokerLocator("socket://multihome/?homes=a.b!c.d:12&" + InvokerLocator.DEFAULT_PORT + "=13"); assertEquals("a.b:13!c.d:12", l.getHomes()); l = new InvokerLocator("socket://multihome/?homes=a.b!c.d:12&" + InvokerLocator.DEFAULT_CONNECT_PORT + "=14"); assertEquals("a.b:-1!c.d:12", l.getHomes()); l = new InvokerLocator("socket://multihome/?homes=a.b!c.d:12&" + InvokerLocator.DEFAULT_PORT + "=13&" + InvokerLocator.DEFAULT_CONNECT_PORT + "=14"); assertEquals("a.b:13!c.d:12", l.getHomes()); l = new InvokerLocator("socket://multihome:11/?homes=a.b!c.d:12"); assertEquals("a.b:11!c.d:12", l.getHomes()); l = new InvokerLocator("socket://multihome:11/?homes=a.b!c.d:12&" + InvokerLocator.DEFAULT_PORT + "=13"); assertEquals("a.b:13!c.d:12", l.getHomes()); l = new InvokerLocator("socket://multihome:11/?homes=a.b!c.d:12&" + InvokerLocator.DEFAULT_CONNECT_PORT + "=14"); assertEquals("a.b:11!c.d:12", l.getHomes()); l = new InvokerLocator("socket://multihome:11/?homes=a.b!c.d:12&" + InvokerLocator.DEFAULT_PORT + "=13&" + InvokerLocator.DEFAULT_CONNECT_PORT + "=14"); assertEquals("a.b:13!c.d:12", l.getHomes()); l = new InvokerLocator("socket://multihome/?connecthomes=a.b!c.d:12"); assertEquals("a.b:-1!c.d:12", l.getConnectHomes()); l = new InvokerLocator("socket://multihome/?connecthomes=a.b!c.d:12&" + InvokerLocator.DEFAULT_PORT + "=13"); assertEquals("a.b:13!c.d:12", l.getConnectHomes()); l = new InvokerLocator("socket://multihome/?connecthomes=a.b!c.d:12&" + InvokerLocator.DEFAULT_CONNECT_PORT + "=14"); assertEquals("a.b:14!c.d:12", l.getConnectHomes()); l = new InvokerLocator("socket://multihome/?connecthomes=a.b!c.d:12&" + InvokerLocator.DEFAULT_PORT + "=13&" + InvokerLocator.DEFAULT_CONNECT_PORT + "=14"); assertEquals("a.b:14!c.d:12", l.getConnectHomes()); l = new InvokerLocator("socket://multihome:11/?connecthomes=a.b!c.d:12"); assertEquals("a.b:11!c.d:12", l.getConnectHomes()); l = new InvokerLocator("socket://multihome:11/?connecthomes=a.b!c.d:12&" + InvokerLocator.DEFAULT_PORT + "=13"); assertEquals("a.b:13!c.d:12", l.getConnectHomes()); l = new InvokerLocator("socket://multihome:11/?connecthomes=a.b!c.d:12&" + InvokerLocator.DEFAULT_CONNECT_PORT + "=14"); assertEquals("a.b:14!c.d:12", l.getConnectHomes()); l = new InvokerLocator("socket://multihome:11/?connecthomes=a.b!c.d:12&" + InvokerLocator.DEFAULT_PORT + "=13&" + InvokerLocator.DEFAULT_CONNECT_PORT + "=14"); assertEquals("a.b:14!c.d:12", l.getConnectHomes()); } /** * For JBREM-936. */ public void testNullHost() throws Exception { InvokerLocator locator = new InvokerLocator("socket://:7777"); boolean byHost = true; String host = null; try { String s = System.getProperty(InvokerLocator.BIND_BY_HOST, "True"); byHost = Boolean.valueOf(s).booleanValue(); } catch(Exception e) { } if(byHost) { host = InetAddress.getLocalHost().getHostName(); } else { host = InetAddress.getLocalHost().getHostAddress(); } assertEquals(host, locator.getHost()); } /** * For JBREM-1110. */ public void testEmptyParameters() throws Exception { InvokerLocator locator = new InvokerLocator("socket://:7777"); assertNotNull(locator.getParameters()); } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/locator/ExtraneousEqualsTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/locator/ExtraneousEqualsTest0000755000175000017500000000544211413660476033611 0ustar twernertwerner/* * 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.locator; 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.InvokerLocator; public class ExtraneousEqualsTestCase extends TestCase { private static Logger log = Logger.getLogger(ExtraneousEqualsTestCase.class); private static boolean firstTime = true; 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 testExtraneousEquals() throws Throwable { log.info("entering " + getName()); // Create client. String locatorURI = "socket://localhost:8080/abc?xyz"; InvokerLocator locator = new InvokerLocator(locatorURI); log.info(locator.getLocatorURI()); assertEquals(locator.getLocatorURI(), locatorURI); locatorURI = "socket://localhost:8080/abc?pqr=123&xyz"; locator = new InvokerLocator(locatorURI); log.info(locator.getLocatorURI()); assertEquals(locator.getLocatorURI(), locatorURI); locatorURI = "socket://localhost:8080/abc?pqr&xyz=123"; locator = new InvokerLocator(locatorURI); log.info(locator.getLocatorURI()); assertEquals(locator.getLocatorURI(), locatorURI); log.info(getName() + " PASSES"); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/byvalue/0000755000175000017500000000000011632407032027500 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/byvalue/ByValuePayload.java0000644000175000017500000000564210355142433033235 0ustar twernertwerner/* * 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.byvalue; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; /** * @author Tom Elrod */ public class ByValuePayload implements Externalizable { private boolean hasBeenMarshalled = false; public boolean wasMarshalled() { return hasBeenMarshalled; } /** * The object implements the readExternal method to restore its * contents by calling the methods of DataInput for primitive * types and readObject for objects, strings and arrays. The * readExternal method must read the values in the same sequence * and with the same types as were written by writeExternal. * * @param in the stream to read data from in order to restore the object * @throws java.io.IOException if I/O errors occur * @throws ClassNotFoundException If the class for an object being * restored cannot be found. */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { hasBeenMarshalled = true; } /** * The object implements the writeExternal method to save its contents * by calling the methods of DataOutput for its primitive values or * calling the writeObject method of ObjectOutput for objects, strings, * and arrays. * * @param out the stream to write the object to * @throws java.io.IOException Includes any I/O exceptions that may occur * @serialData Overriding methods should use this tag to describe * the data layout of this Externalizable object. * List the sequence of element types and, if possible, * relate the element to a public/protected field and/or * method of this Externalizable class. */ public void writeExternal(ObjectOutput out) throws IOException { //NO OP - just care that readExternal is called on the deserialize } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/byvalue/ByValueInvocationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/byvalue/ByValueInvocationTes0000644000175000017500000001253410555164454033520 0ustar twernertwerner/* * 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.byvalue; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; /** * Just a simple example of how to setup remoting to make an invocation to local target, * so are not actually going out of process, thus not really using any transport protocol. * * @author Tom Elrod */ public class ByValueInvocationTestCase extends TestCase { private Connector connector = null; public void setupConfiguration(InvokerLocator locator, ServerInvocationHandler invocationHandler) throws Exception { connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.start(); connector.addInvocationHandler("mock", invocationHandler); } public void testJavaInvocation() throws Throwable { InvokerLocator locator = new InvokerLocator("rmi://localhost:5400/?" + InvokerLocator.BYVALUE + "=" + Boolean.TRUE.toString()); ServerInvocationHandler invocationHandler = new MockServerInvocationHandler(); try { // set up setupConfiguration(locator, invocationHandler); Thread.sleep(3000); // This could have been new Client(locator), but want to show that subsystem param is null Client remotingClient = new Client(locator); remotingClient.connect(); ByValuePayload byValuePayload = new ByValuePayload(); Object response = remotingClient.invoke(new NameBasedInvocation("testByValue", new Object[]{byValuePayload}, new String[]{byValuePayload.getClass().getName()}), null); System.out.println("Invocation response: " + response); if (response instanceof Boolean) { assertTrue("Result of testByValue is false.", ((Boolean) response).booleanValue()); } else { assertTrue("Result of testByValue was not even of type Boolean.", false); } remotingClient.disconnect(); } finally { if (connector != null) { connector.stop(); connector.destroy(); connector = null; } } } public void testJBossInvocation() throws Throwable { InvokerLocator locator = new InvokerLocator("rmi://localhost:5401/?" + InvokerLocator.BYVALUE + "=" + Boolean.TRUE.toString() + "&" + InvokerLocator.SERIALIZATIONTYPE + "=" + "jboss"); ServerInvocationHandler invocationHandler = new MockServerInvocationHandler(); try { // set up setupConfiguration(locator, invocationHandler); Thread.sleep(3000); // This could have been new Client(locator), but want to show that subsystem param is null Client remotingClient = new Client(locator); remotingClient.connect(); ByValuePayload byValuePayload = new ByValuePayload(); Object response = remotingClient.invoke(new NameBasedInvocation("testByValue", new Object[]{byValuePayload}, new String[]{byValuePayload.getClass().getName()}), null); System.out.println("Invocation response: " + response); if (response instanceof Boolean) { assertTrue("Result of testByValue is false.", ((Boolean) response).booleanValue()); } else { assertTrue("Result of testByValue was not even of type Boolean.", false); } remotingClient.disconnect(); } finally { if (connector != null) { connector.stop(); connector.destroy(); connector = null; } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/0000755000175000017500000000000011632407031027121 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/rmi/0000755000175000017500000000000011632407031027710 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/rmi/RMILeaseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/rmi/RMILeaseTestCase.j0000644000175000017500000000304710427764574033147 0ustar twernertwerner/* * 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.lease.rmi; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class RMILeaseTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(RMILeaseTestClient.class.getName(), 1, RMILeaseTestServer.class.getName()); } protected Level getTestHarnessLogLevel() { return Level.INFO; } protected Level getTestLogLevel() { return Level.DEBUG; } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/rmi/RMILeaseTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/rmi/RMILeaseTestServer0000644000175000017500000000371410427764574033313 0ustar twernertwerner/* * 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.lease.rmi; import org.jboss.test.remoting.lease.LeaseTestServer; /** * @author Tom Elrod */ public class RMILeaseTestServer extends LeaseTestServer { private static String transport = "rmi"; protected String getTransport() { return transport; } public static void main(String[] args) { final LeaseTestServer server = new RMILeaseTestServer(); try { server.setupServer(); try { new Thread(new Runnable() { public void run() { server.testForError(); } }).start(); Thread.currentThread().sleep(30000); server.isRunning = false; } catch(InterruptedException e) { e.printStackTrace(); } server.tearDown(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/rmi/RMILeaseTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/rmi/RMILeaseTestClient0000644000175000017500000000311510427764574033256 0ustar twernertwerner/* * 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.lease.rmi; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.lease.LeaseTestClient; /** * @author Tom Elrod */ public class RMILeaseTestClient extends LeaseTestClient { // Default locator values private static String transport = "rmi"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true"; protected String getLocatorUri() { return locatorURI; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/0000755000175000017500000000000011632407031030411 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/SocketLeaseTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/SocketLeaseTest0000644000175000017500000000312710427764574033424 0ustar twernertwerner/* * 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.lease.socket; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.lease.LeaseTestClient; /** * @author Tom Elrod */ public class SocketLeaseTestClient extends LeaseTestClient { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true"; protected String getLocatorUri() { return locatorURI; } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/ClientLeasePeriodTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/ClientLeasePeri0000644000175000017500000001224010567167344033363 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.lease.socket; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.LeasePinger; import java.util.HashMap; import java.util.Map; /** * @author Ovidiu Feodorov * @version $Revision: 2193 $ * $Id: ClientLeasePeriodTestClient.java 2193 2007-02-22 01:16:20Z rsigal $ */ public class ClientLeasePeriodTestClient extends TestCase { // Constants ------------------------------------------------------------------------------------ // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- // Constructors --------------------------------------------------------------------------------- // Public --------------------------------------------------------------------------------------- public void testLeasePeriodNoLease() throws Throwable { Client client = new Client(new InvokerLocator(ClientLeasePeriodTestServer.locatorURINoLease)); assertEquals(-1, client.getLeasePeriod()); } public void testLeasePeriodDefaultLease() throws Throwable { Map conf = new HashMap(); conf.put(Client.ENABLE_LEASE, Boolean.TRUE); Client client = new Client(new InvokerLocator(ClientLeasePeriodTestServer.locatorURILease), conf); client.connect(); assertEquals(LeasePinger.DEFAULT_LEASE_PERIOD, client.getLeasePeriod()); } public void testLeasePeriodCustomLease() throws Throwable { // the custom lease value should be smaller than the default lease, because the smalles // lease interval takes precedence long customLeasePeriod = LeasePinger.DEFAULT_LEASE_PERIOD - 7; Map conf = new HashMap(); conf.put(Client.ENABLE_LEASE, Boolean.TRUE); conf.put(InvokerLocator.CLIENT_LEASE_PERIOD, Long.toString(customLeasePeriod)); Client client = new Client(new InvokerLocator(ClientLeasePeriodTestServer.locatorURILease), conf); client.connect(); assertEquals(customLeasePeriod, client.getLeasePeriod()); } public void testLeasePeriodTwoClients() throws Throwable { // the custom lease value should be smaller than the default lease, because the smalles // lease interval takes precedence long customLeasePeriod = LeasePinger.DEFAULT_LEASE_PERIOD - 9; long customLeasePeriod2 = LeasePinger.DEFAULT_LEASE_PERIOD - 10; Map conf = new HashMap(); conf.put(Client.ENABLE_LEASE, Boolean.TRUE); conf.put(InvokerLocator.CLIENT_LEASE_PERIOD, Long.toString(customLeasePeriod)); Client client = new Client(new InvokerLocator(ClientLeasePeriodTestServer.locatorURILease), conf); client.connect(); assertEquals(customLeasePeriod, client.getLeasePeriod()); conf.put(InvokerLocator.CLIENT_LEASE_PERIOD, Long.toString(customLeasePeriod2)); Client client2 = new Client(new InvokerLocator(ClientLeasePeriodTestServer.locatorURILease), conf); // this client will get a brand new invoker (because the configuration is different and // InvokerRegistry looks at that), so we'll have different LeasePinger instances, so will // have different lease periods client2.connect(); assertEquals(customLeasePeriod, client.getLeasePeriod()); assertEquals(customLeasePeriod2, client2.getLeasePeriod()); } public void testLeasePeriodMultipleClientsSameInvoker() throws Throwable { Map conf = new HashMap(); conf.put(Client.ENABLE_LEASE, Boolean.TRUE); Client client = new Client(new InvokerLocator(ClientLeasePeriodTestServer.locatorURILease), conf); client.connect(); assertEquals(LeasePinger.DEFAULT_LEASE_PERIOD, client.getLeasePeriod()); Client client2 = new Client(new InvokerLocator(ClientLeasePeriodTestServer.locatorURILease), conf); client2.connect(); assertEquals(LeasePinger.DEFAULT_LEASE_PERIOD, client2.getLeasePeriod()); // test terminating lease client2.getInvoker().terminateLease(client2.getSessionId(), -1); assertEquals(-1, client2.getLeasePeriod()); assertEquals(LeasePinger.DEFAULT_LEASE_PERIOD, client.getLeasePeriod()); // make sure that invoking terminateLease() again on a client with no lease is a noop client2.getInvoker().terminateLease(client2.getSessionId(), -1); client.getInvoker().terminateLease(client.getSessionId(), -1); assertEquals(-1, client2.getLeasePeriod()); assertEquals(-1, client.getLeasePeriod()); } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/multiple/0000755000175000017500000000000011632407031032244 5ustar twernertwerner././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/multiple/SocketLeaseTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/multiple/Socket0000644000175000017500000001242610570001021033411 0ustar twernertwernerpackage org.jboss.test.remoting.lease.socket.multiple; 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.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class SocketLeaseTestClient extends TestCase { private static Logger log = Logger.getLogger(SocketLeaseTestClient.class); // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true"; private String callbackLocatorURI = transport + "://" + host + ":" + (port + 1); private int COUNT = 50; private boolean[] success = new boolean[COUNT]; private boolean[] done = new boolean[COUNT]; // public void setUp() // { // org.apache.log4j.BasicConfigurator.configure(); // org.apache.log4j.Category.getRoot().setLevel(Level.INFO); // org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE); // org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); // } public void setUp() { log.info("entering setUp()"); } protected String getLocatorUri() { return locatorURI; } public void testMultipleLeases() throws Throwable { log.info("entering " + getName()); class CallerThread extends Thread { int id; CallerThread(int id) { this.id = id; } public void run() { try { log.info("calling runClient(" + id + ")"); runClient(id); log.info("runClient(" + id + ") returns"); done[id] = true; } catch (Throwable e) { e.printStackTrace(); } } } for (int i = 0; i < COUNT; i++) { Thread t = new CallerThread(i); t.setName("client: " + i); t.start(); log.info("started client thread " + i); } Thread.sleep(35000); boolean allDone = false; while (!allDone) { allDone = true; for (int i = 0; i < COUNT; i++) { allDone &= done[i]; log.info("done[" + i + "]: " + done[i]); } Thread.sleep(1000); } boolean allSuccess = true; for (int i = 0; i < COUNT; i++) { allSuccess &= success[i]; } log.info("success: " + allSuccess); assertTrue(allSuccess); log.info(getName() + " PASSES"); } public void runClient(int id) throws Throwable { InvokerLocator locator = new InvokerLocator(getLocatorUri()); System.out.println("Calling remoting server with locator uri of: " + getLocatorUri()); //InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); //Connector callbackConnector = new Connector(callbackLocator); //callbackConnector.create(); //callbackConnector.start(); //TestCallbackHandler callbackHandler = new TestCallbackHandler(); Map metadata = new HashMap(); metadata.put("clientName", "test1"); Client remotingClient1 = new Client(locator, metadata); remotingClient1.connect(); //remotingClient1.addListener(callbackHandler, callbackLocator); Object ret = remotingClient1.invoke("test1"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); // now create second client Map metadata2 = new HashMap(); metadata2.put("clientName", "test1"); Client remotingClient2 =new Client(locator, metadata2); remotingClient2.connect(); //remotingClient2.addListener(callbackHandler, callbackLocator); ret = remotingClient2.invoke("test2"); System.out.println("Response was: " + ret); ret = remotingClient1.invoke("test1"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); if(remotingClient1 != null) { //remotingClient1.removeListener(callbackHandler); remotingClient1.disconnect(); } System.out.println("remoting client 1 (thread " + id + ") disconnected"); //Thread.currentThread().sleep(10000); Thread.currentThread().sleep(30000); ret = remotingClient2.invoke("test2"); System.out.println("Response was: " + ret); if(remotingClient2 != null) { //remotingClient2.removeListener(callbackHandler); remotingClient2.disconnect(); } success[id] = true; log.info("thread " + id + " successful"); } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("callback: " + callback); } } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/multiple/SocketLeaseTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/multiple/Socket0000644000175000017500000000256110504141002033411 0ustar twernertwernerpackage org.jboss.test.remoting.lease.socket.multiple; import org.apache.log4j.Level; import org.jboss.logging.XLevel; import org.jboss.test.remoting.lease.LeaseTestServer; /** * @author Tom Elrod */ public class SocketLeaseTestServer extends LeaseTestServer { private static String transport = "socket"; protected String getTransport() { return transport; } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); final LeaseTestServer server = new SocketLeaseTestServer(); try { server.setupServer(); try { new Thread(new Runnable() { public void run() { server.testForError(); } }).start(); Thread.currentThread().sleep(60000); server.isRunning = false; } catch (InterruptedException e) { e.printStackTrace(); } server.tearDown(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/multiple/SocketLeaseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/multiple/Socket0000644000175000017500000000263010743004500033414 0ustar twernertwernerpackage org.jboss.test.remoting.lease.socket.multiple; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; import org.jboss.logging.XLevel; /** * @author Tom Elrod */ public class SocketLeaseTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SocketLeaseTestClient.class.getName(), 1, SocketLeaseTestServer.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 360000; } /** * 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 360000; } /** * 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 360000; } protected Level getTestLogLevel() { return XLevel.INFO; } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/ClientLeasePeriodTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/ClientLeasePeri0000644000175000017500000000464010554623211033352 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.lease.socket; import org.jboss.jrunit.harness.TestDriver; /** * @author Ovidiu Feodorov * @version $Revision: 1946 $ * $Id: ClientLeasePeriodTestCase.java 1946 2007-01-21 08:38:33Z ovidiu $ */ public class ClientLeasePeriodTestCase extends TestDriver { // Constants ------------------------------------------------------------------------------------ // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- // Constructors --------------------------------------------------------------------------------- // TestDriver overrides ------------------------------------------------------------------------- public void declareTestClasses() { addTestClasses(ClientLeasePeriodTestClient.class.getName(), 1, ClientLeasePeriodTestServer.class.getName()); } // Public --------------------------------------------------------------------------------------- // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected String getClientJVMArguments() { if (Boolean.getBoolean("clientdebug")) { return "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=n,suspend=n,address=jrunit_client"; } return ""; } protected long getResultsTimeout() { if (Boolean.getBoolean("clientdebug")) { return 3600000L; } return super.getResultsTimeout(); } protected long getTearDownTimeout() { if (Boolean.getBoolean("clientdebug")) { return 3600000L; } return super.getTearDownTimeout(); } protected long getRunTestTimeout() { if (Boolean.getBoolean("clientdebug")) { return 3600000L; } return super.getRunTestTimeout(); } // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/ClientLeasePeriodTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/ClientLeasePeri0000644000175000017500000000627210565236157033370 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.lease.socket; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.logging.Logger; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.Client; /** * @author Ovidiu Feodorov * @version $Revision: 2171 $ * $Id: ClientLeasePeriodTestServer.java 2171 2007-02-16 05:09:03Z rsigal $ */ public class ClientLeasePeriodTestServer extends ServerTestCase { // Constants ------------------------------------------------------------------------------------ public static String locatorURINoLease = "socket://localhost:9900"; public static String locatorURILease = "socket://localhost:9909"; protected static Logger log = Logger.getLogger(ClientLeasePeriodTestServer.class); // Static --------------------------------------------------------------------------------------- public static void main(String[] args) { try { ClientLeasePeriodTestServer server = new ClientLeasePeriodTestServer(); server.setUp(); Thread.sleep(600000); server.tearDown(); } catch (Exception e) { log.error(e); } } // Attributes ----------------------------------------------------------------------------------- private Connector connectorNoLease; private Connector connectorLease; private ConnectionListener connectionListener; // Constructors --------------------------------------------------------------------------------- // Public --------------------------------------------------------------------------------------- // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected void setUp() throws Exception { connectorNoLease = new Connector(ClientLeasePeriodTestServer.locatorURINoLease); connectorNoLease.create(); connectorNoLease.start(); connectorLease = new Connector(ClientLeasePeriodTestServer.locatorURILease); connectorLease.create(); connectorLease.start(); connectionListener = new ConnectionListener() { public void handleConnectionException(Throwable throwable, Client client) { } }; // activate leases connectorLease.addConnectionListener(connectionListener); super.setUp(); } protected void tearDown() throws Exception { if(connectorLease != null) { connectorLease.removeConnectionListener(connectionListener); connectorLease.stop(); connectorLease.destroy(); } if(connectorNoLease != null) { connectorNoLease.stop(); connectorNoLease.destroy(); } super.tearDown(); } // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/SocketLeaseTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/SocketLeaseTest0000644000175000017500000000373010427764574033424 0ustar twernertwerner/* * 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.lease.socket; import org.jboss.test.remoting.lease.LeaseTestServer; /** * @author Tom Elrod */ public class SocketLeaseTestServer extends LeaseTestServer { private static String transport = "socket"; protected String getTransport() { return transport; } public static void main(String[] args) { final LeaseTestServer server = new SocketLeaseTestServer(); try { server.setupServer(); try { new Thread(new Runnable() { public void run() { server.testForError(); } }).start(); Thread.currentThread().sleep(30000); server.isRunning = false; } catch(InterruptedException e) { e.printStackTrace(); } server.tearDown(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/SocketLeaseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/socket/SocketLeaseTest0000644000175000017500000000257210535452155033414 0ustar twernertwerner/* * 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.lease.socket; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class SocketLeaseTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(SocketLeaseTestClient.class.getName(), 1, SocketLeaseTestServer.class.getName()); } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/LeaseCreationFailureTe0000644000175000017500000002600211413660476033376 0ustar twernertwerner/* * 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.lease; import java.io.IOException; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.net.SocketFactory; 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.CannotConnectException; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; 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.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * Unit test for JBREM-1154. * * @author Ron Sigal * @version *

          * Copyright Sep 11, 2009 *

          */ public class LeaseCreationFailureTestCase extends TestCase { private static Logger log = Logger.getLogger(LeaseCreationFailureTestCase.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 testLeaseCreationFailure() 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(Remoting.SOCKET_FACTORY_NAME, TestSocketFactory.class.getName()); clientConfig.put(Client.ENABLE_LEASE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); // Verify that Client.connect() throws Exception if LeasePinger.addClient() fails. try { client.connect(); fail("expected exception"); } catch (CannotConnectException e) { log.info("got exception", e); assertEquals("got wrong exception", "Error setting up client lease upon performing connect.", e.getMessage()); } catch (Throwable t) { log.info("got wrong exception", t); fail("got wrong exception"); } assertFalse(client.isConnected()); 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("clientLeasePeriod", "1000"); addExtraServerConfig(config); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.addConnectionListener(new TestConnectionListener()); 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 TestConnectionListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { } } public static class TestSocketFactory extends SocketFactory { int initialSuccesses = 2; public TestSocketFactory() { } public TestSocketFactory(int initialSuccesses) { this.initialSuccesses = initialSuccesses; } public Socket createSocket() { Socket s = new TestSocket(initialSuccesses); log.info("returning " + s); return s; } public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { Socket s = new TestSocket(arg0, arg1, initialSuccesses); log.info("returning " + s); return s; } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { Socket s = new TestSocket(arg0, arg1, initialSuccesses); log.info("returning " + s); return s; } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { Socket s = new TestSocket(arg0, arg1, arg2, arg3, initialSuccesses); log.info("returning " + s); return s; } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { Socket s = new TestSocket(arg0, arg1, arg2, arg3, initialSuccesses); log.info("returning " + s); return s; } } static class TestSocket extends Socket { int initialSuccesses; public TestSocket(int initialWrites) { this.initialSuccesses = initialWrites; } public TestSocket(String host, int port, int initialWrites) throws UnknownHostException, IOException { super(host, port); this.initialSuccesses = initialWrites; } public TestSocket(InetAddress address, int port, int initialWrites) throws IOException { super(address, port); this.initialSuccesses = initialWrites; } public TestSocket(String host, int port, InetAddress localAddr, int localPort, int initialWrites) throws IOException { super(host, port, localAddr, localPort); this.initialSuccesses = initialWrites; } public TestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int initialWrites) throws IOException { super(address, port, localAddr, localPort); this.initialSuccesses = initialWrites; } public OutputStream getOutputStream() throws IOException { return new TestOutputStream(super.getOutputStream(), initialSuccesses); } public String toString() { return "TestSocket[" + getLocalPort() + "->" + getPort() + "]"; } } static class TestOutputStream extends OutputStream { OutputStream os; boolean closed; int initialWrites; boolean doThrow = true; public static int counter; public TestOutputStream(OutputStream os, int initialWrites) { this.os = os; this.initialWrites = initialWrites; } public void close()throws IOException { closed = true; super.close(); log.info(this + " closed"); } public void write(int b) throws IOException { System.out.print("b: " + b); if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } if (doThrow && ++counter > initialWrites) { log.info("throwing exception"); throw new IOException(""); } os.write(b); } public void write(byte b[], int off, int len) throws IOException { System.out.print("b: "); for (int i = 0; i < len; i++) { System.out.print(b[i] + " "); } System.out.println(""); if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } log.info("TestOutputStream: counter = " + ++counter + ", initialWrites = " + initialWrites); if (counter > initialWrites) { log.info("throwing exception"); throw new IOException(""); } if (closed) { log.info("TestOutputStream closed, cannot write"); throw new IOException("closed"); } try { log.info(this + " calling write()"); doThrow = false; os.write(b, off, len); os.flush(); doThrow = true; log.info(this + " back from write()"); } catch (IOException e) { log.info("exception: ", e); throw e; } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/0000755000175000017500000000000011632407031030100 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/HTTPLeaseTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/HTTPLeaseTestServ0000644000175000017500000000446410504414132033261 0ustar twernertwerner/* * 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.lease.http; import org.apache.log4j.Level; import org.jboss.logging.XLevel; import org.jboss.test.remoting.lease.LeaseTestServer; /** * @author Tom Elrod */ public class HTTPLeaseTestServer extends LeaseTestServer { private static String transport = "http"; protected String getTransport() { return transport; } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); final LeaseTestServer server = new HTTPLeaseTestServer(); try { server.setupServer(); try { new Thread(new Runnable() { public void run() { server.testForError(); } }).start(); Thread.currentThread().sleep(300000); server.isRunning = false; } catch(InterruptedException e) { e.printStackTrace(); } server.tearDown(); } catch(Exception e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/multiple/0000755000175000017500000000000011632407031031733 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/multiple/HTTPLeaseTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/multiple/HTTPLeas0000644000175000017500000000253410504414132033243 0ustar twernertwernerpackage org.jboss.test.remoting.lease.http.multiple; import org.apache.log4j.Level; import org.jboss.logging.XLevel; import org.jboss.test.remoting.lease.LeaseTestServer; /** * @author Tom Elrod */ public class HTTPLeaseTestServer extends LeaseTestServer { private static String transport = "http"; protected String getTransport() { return transport; } public static void main(String[] args) { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); final LeaseTestServer server = new HTTPLeaseTestServer(); try { server.setupServer(); try { new Thread(new Runnable() { public void run() { server.testForError(); } }).start(); Thread.currentThread().sleep(300000); server.isRunning = false; } catch(InterruptedException e) { e.printStackTrace(); } server.tearDown(); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/multiple/HTTPLeaseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/multiple/HTTPLeas0000644000175000017500000000256710535452155033264 0ustar twernertwerner/* * 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.lease.http.multiple; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class HTTPLeaseTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPLeaseTestClient.class.getName(), 1, HTTPLeaseTestServer.class.getName()); } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/multiple/HTTPLeaseTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/multiple/HTTPLeas0000644000175000017500000001057610504414132033250 0ustar twernertwerner/* * 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.lease.http.multiple; 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; import java.util.Map; /** * @author Tom Elrod */ public class HTTPLeaseTestClient extends TestCase { // Default locator values private static String transport = "http"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true"; private String callbackLocatorURI = transport + "://" + host + ":" + (port + 1); // public void setUp() // { // org.apache.log4j.BasicConfigurator.configure(); // org.apache.log4j.Category.getRoot().setLevel(Level.INFO); // org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE); // org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); // } protected String getLocatorUri() { return locatorURI; } public void testMultipleLeases() throws Throwable { InvokerLocator locator = new InvokerLocator(getLocatorUri()); System.out.println("Calling remoting server with locator uri of: " + getLocatorUri()); //InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); //Connector callbackConnector = new Connector(callbackLocator); //callbackConnector.create(); //callbackConnector.start(); //TestCallbackHandler callbackHandler = new TestCallbackHandler(); Map metadata = new HashMap(); metadata.put("clientName", "test1"); Client remotingClient1 = new Client(locator, metadata); remotingClient1.connect(); //remotingClient1.addListener(callbackHandler, callbackLocator); Object ret = remotingClient1.invoke("test1"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); // now create second client Map metadata2 = new HashMap(); metadata2.put("clientName", "test1"); Client remotingClient2 =new Client(locator, metadata2); remotingClient2.connect(); //remotingClient2.addListener(callbackHandler, callbackLocator); ret = remotingClient2.invoke("test2"); System.out.println("Response was: " + ret); ret = remotingClient1.invoke("test1"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); if(remotingClient1 != null) { //remotingClient1.removeListener(callbackHandler); remotingClient1.disconnect(); } System.out.println("remoting client 1 disconnected"); //Thread.currentThread().sleep(10000); Thread.currentThread().sleep(30000); ret = remotingClient2.invoke("test2"); System.out.println("Response was: " + ret); if(remotingClient2 != null) { //remotingClient2.removeListener(callbackHandler); remotingClient2.disconnect(); } } public class TestCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("callback: " + callback); } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/HTTPLeaseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/HTTPLeaseTestCase0000644000175000017500000000262110535452155033221 0ustar twernertwerner/* * 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.lease.http; import org.apache.log4j.Level; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class HTTPLeaseTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(HTTPLeaseTestClient.class.getName(), 1, HTTPLeaseTestServer.class.getName()); } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/HTTPLeaseTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/http/HTTPLeaseTestClie0000644000175000017500000000312110427764574033231 0ustar twernertwerner/* * 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.lease.http; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.lease.LeaseTestClient; /** * @author Tom Elrod */ public class HTTPLeaseTestClient extends LeaseTestClient { // Default locator values private static String transport = "http"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true"; protected String getLocatorUri() { return locatorURI; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/local/0000755000175000017500000000000011632407031030213 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/local/LocalLeaseTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/local/LocalLeaseTestCa0000644000175000017500000000477610433107255033267 0ustar twernertwernerpackage org.jboss.test.remoting.lease.local; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; 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 LocalLeaseTestCase extends TestCase implements ConnectionListener { private Client client = null; private Connector connector = null; private boolean connectionFailure = false; public void setUp() throws Exception { String locatorUri = "socket://localhost:8888" + "/?" + InvokerLocator.CLIENT_LEASE + "=" + "true"; connector = new Connector(); connector.setInvokerLocator(locatorUri); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); connector.addConnectionListener(this); client = new Client(new InvokerLocator(locatorUri)); } public void testConnection() throws Throwable { client.connect(); client.invoke("foobar"); Thread.sleep(5000); client.disconnect(); Thread.sleep(20000); assertFalse(connectionFailure); connector.removeConnectionListener(this); } public void tearDown() { if(client != null) { client.disconnect(); } if(connector != null) { connector.stop(); connector.destroy(); } } public void handleConnectionException(Throwable throwable, Client client) { System.out.println("got connection exception."); connectionFailure = true; } 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 null; //TODO: -TME Implement } 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/lease/LeaseTestServer.java0000644000175000017500000001450210504307156033052 0ustar twernertwerner/* * 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.lease; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; 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.w3c.dom.Document; import javax.management.MBeanServer; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; /** * @author Tom Elrod */ public abstract class LeaseTestServer extends ServerTestCase implements ConnectionListener { // Default locator values private static String host = "localhost"; private static int port = 5400; private boolean error = false; private boolean disconnect = false; private Connector connector = null; public boolean isRunning = true; // String to be returned from invocation handler upon client invocation calls. private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; protected abstract String getTransport(); public void setupServer() throws Exception { connector = new Connector(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("3000"); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); buf.append(" " + SampleInvocationHandler.class.getName() + "\n"); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); //connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.addConnectionListener(this); connector.start(); } public void testForError() { while(isRunning) { assertTrue("Received connection failure from client that was not due to disconnect.", !error); try { Thread.currentThread().sleep(1000); } catch(InterruptedException e) { e.printStackTrace(); } } } public void setUp() throws Exception { setupServer(); } public void tearDown() throws Exception { isRunning = false; if(connector != null) { connector.stop(); connector.destroy(); } if(!disconnect) { throw new RuntimeException("Never got disconnect notification from any of the clients."); } } public void handleConnectionException(Throwable throwable, Client client) { System.out.println("received connection exception from " + client + " (session id = " + client.getSessionId() + ") " + "with exception of " + throwable + " and configuration of " + client.getConfiguration()); if(throwable == null) { // since there was not an exception (will be one if was from a disconnect), // need to indicate error. error = true; } else { disconnect = true; } } /** * Simple invocation handler implementation. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } /** * 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 } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/timeout/0000755000175000017500000000000011632407031030607 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/timeout/LeasePingerTimeoutTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/timeout/LeasePingerTim0000644000175000017500000002566011413660476033426 0ustar twernertwerner/* * 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.lease.timeout; import java.lang.reflect.Field; import java.net.InetAddress; 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.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.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.ServerThread; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-956. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Apr 20, 2008 *

          */ public class LeasePingerTimeoutTestCase extends TestCase { private static Logger log = Logger.getLogger(LeasePingerTimeoutTestCase.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() { } /** * Verifies that LeasePinger uses standard "timeout" parameter in the absence * of a "leasePingerTimeout" parameter. */ public void testDefaultTimeout() 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(); // Get LeasePinger. MicroRemoteClientInvoker clientInvoker = (MicroRemoteClientInvoker) client.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(clientInvoker); // Prevent server from answering PINGs. SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); assertEquals(1, clientpool.size()); ServerThread st = (ServerThread) clientpool.getContents().iterator().next(); while (clientpool.size() > 0) { st.evict(); Thread.sleep(1000); } field = SocketServerInvoker.class.getDeclaredField("threadpool"); field.setAccessible(true); List threadpool = (List) field.get(serverInvoker); threadpool.clear(); assertEquals(0, threadpool.size()); log.info("clientpool.size(): " + clientpool.size()); log.info("threadpool.size(): " + threadpool.size()); serverInvoker.setMaxPoolSize(0); // Verify that PING fails after default timeout. Field succeedField = LeasePinger.class.getDeclaredField("pingSucceeded"); succeedField.setAccessible(true); Field invokedField = LeasePinger.class.getDeclaredField("pingInvoked"); invokedField.setAccessible(true); boolean pingInvoked = ((Boolean) invokedField.get(pinger)).booleanValue(); while (!pingInvoked) { Thread.sleep(1000); pingInvoked = ((Boolean) invokedField.get(pinger)).booleanValue(); } // Verify that PING has been sent but not answered. log.info("pingInvoked: " + pingInvoked); Thread.sleep(5000); assertTrue(((Boolean) invokedField.get(pinger)).booleanValue()); assertFalse(((Boolean) succeedField.get(pinger)).booleanValue()); log.info("LeasePinger has not timed out after 5000 ms"); client.setDisconnectTimeout(0); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } /** * Verifies that LeasePinger uses "leasePingerTimeout" if it is present. */ public void testLeasePingerTimeout() 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(LeasePinger.LEASE_PINGER_TIMEOUT, "1000"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator, clientConfig); client.connect(); // Get LeasePinger. MicroRemoteClientInvoker clientInvoker = (MicroRemoteClientInvoker) client.getInvoker(); Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger"); field.setAccessible(true); LeasePinger pinger = (LeasePinger) field.get(clientInvoker); // Prevent server from answering PINGs. SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); field = SocketServerInvoker.class.getDeclaredField("clientpool"); field.setAccessible(true); LRUPool clientpool = (LRUPool) field.get(serverInvoker); assertEquals(1, clientpool.size()); ServerThread st = (ServerThread) clientpool.getContents().iterator().next(); while (clientpool.size() > 0) { st.evict(); Thread.sleep(1000); } field = SocketServerInvoker.class.getDeclaredField("threadpool"); field.setAccessible(true); List threadpool = (List) field.get(serverInvoker); threadpool.clear(); assertEquals(0, threadpool.size()); log.info("clientpool.size(): " + clientpool.size()); log.info("threadpool.size(): " + threadpool.size()); serverInvoker.setMaxPoolSize(0); // Verify that PING fails after default timeout. Field succeedField = LeasePinger.class.getDeclaredField("pingSucceeded"); succeedField.setAccessible(true); Field invokedField = LeasePinger.class.getDeclaredField("pingInvoked"); invokedField.setAccessible(true); boolean pingInvoked = ((Boolean) invokedField.get(pinger)).booleanValue(); while (!pingInvoked) { Thread.sleep(1000); pingInvoked = ((Boolean) invokedField.get(pinger)).booleanValue(); } // Verify that PING has been sent but not answered. log.info("pingInvoked: " + pingInvoked); Thread.sleep(5000); log.info("ping invoked: " + ((Boolean)invokedField.get(pinger)).booleanValue()); log.info("ping succeeded: " + ((Boolean)succeedField.get(pinger)).booleanValue()); assertTrue(((Boolean) invokedField.get(pinger)).booleanValue()); assertFalse(((Boolean) succeedField.get(pinger)).booleanValue()); log.info("LeasePinger has timed out within 5000 ms"); client.setDisconnectTimeout(0); 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; locatorURI += "/?enableLease=true"; locatorURI += "&" + InvokerLocator.CLIENT_LEASE + "=true"; locatorURI += "&leasePeriod=10000"; locatorURI += "&timeout=10000"; 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.addConnectionListener(new TestConnectionListener()); 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 TestConnectionListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/LeaseTestClient.java0000644000175000017500000000714410433770344033032 0ustar twernertwerner/* * 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.lease; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public abstract class LeaseTestClient extends TestCase { private Client remotingClient = null; protected abstract String getLocatorUri(); public void testLeaseDisconnect() throws Throwable { InvokerLocator locator = new InvokerLocator(getLocatorUri()); System.out.println("Calling remoting server with locator uri of: " + getLocatorUri()); Map metadata = new HashMap(); metadata.put("clientName", "test1"); remotingClient = new Client(locator, metadata); remotingClient.connect(); Object ret = remotingClient.invoke("test1"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); ret = remotingClient.invoke("test1"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); if(remotingClient != null) { remotingClient.disconnect(); } } public void testLeaseTimeout() throws Throwable { InvokerLocator locator = new InvokerLocator(getLocatorUri()); System.out.println("Calling remoting server with locator uri of: " + getLocatorUri()); Map metadata = new HashMap(); metadata.put("clientName", "test1"); remotingClient = new Client(locator, metadata); remotingClient.connect(); Object ret = remotingClient.invoke("test3"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); ret = remotingClient.invoke("test2"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); ret = remotingClient.invoke("test2"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(10000); ret = remotingClient.invoke("test2"); System.out.println("Response was: " + ret); Thread.currentThread().sleep(1000); if(remotingClient != null) { remotingClient.disconnect(); } } public void testLeaseTimeout2() throws Throwable { InvokerLocator locator = new InvokerLocator(getLocatorUri()); System.out.println("Calling remoting server with locator uri of: " + getLocatorUri()); Map metadata = new HashMap(); metadata.put("clientName", "test3"); remotingClient = new Client(locator, metadata); remotingClient.connect(); Thread.currentThread().sleep(10000); remotingClient.disconnect(); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/timer/0000755000175000017500000000000011632407031030241 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/timer/TimerUtilTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/timer/TimerUtilTestCas0000644000175000017500000000454410504141002033366 0ustar twernertwerner/* * 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.lease.timer; import junit.framework.TestCase; import org.jboss.remoting.util.TimerUtil; import java.util.TimerTask; /** * @author Tom Elrod */ public class TimerUtilTestCase extends TestCase { private boolean[] fires = new boolean[10]; private int counter = 0; public void testTimerUtit() throws Exception { TimerTask task = new TestTimerTask(); TimerUtil.schedule(task, 5000); // fire 0 Thread.currentThread().sleep(6000); task.cancel(); Thread.currentThread().sleep(6000); task = new TestTimerTask(); TimerUtil.schedule(task, 5000); // fire 1 & 2 Thread.currentThread().sleep(12000); task.cancel(); Thread.currentThread().sleep(12000); task = new TestTimerTask(); TimerUtil.schedule(task, 5000); // fire 3 Thread.currentThread().sleep(6000); task.cancel(); // collect results int firedCounter = 0; for(int x = 0; x < fires.length; x++) { boolean fired = fires[x]; if(fired) { firedCounter++; } } assertEquals(4, firedCounter); } public class TestTimerTask extends TimerTask { public void run() { System.out.println("timer fire: " + counter); fires[counter++] = true; } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/0000755000175000017500000000000011632407031030605 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/ServletLeaseTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/ServletLeaseTe0000644000175000017500000000317210553621675033437 0ustar twernertwerner/* * 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.lease.servlet; import org.jboss.test.remoting.lease.LeaseTestClient; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ServletLeaseTestClient extends LeaseTestClient { // Default locator values private static String transport = "servlet"; private static String host = "localhost"; private static int port = 8080; private String locatorURI = transport + "://" + host + ":" + port + "/servlet-invoker/ServerInvokerServlet/?" + InvokerLocator.CLIENT_LEASE + "=" + "true"; protected String getLocatorUri() { return locatorURI; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/readme.txt0000644000175000017500000000150310553621675032617 0ustar twernertwernerThe servlet lease test require a web container. Currently, this test has to be run manually. Here are the instructions for running the test manually. servlet 1. Get JBossAS and copy remoting's servlet-invoker.war (from distro or build) to the deploy directory. 2. Copy the WEB-INF/web.xml under this directory into the that of the servlet-invoker.war/WEB-INF directory. 3. Copy remoting-servlet-invoker-service.xml to deploy directory. 4. Copy jboss-remoting-tests.jar to server lib directory 5. Start web container (JBossAS). 6. Run ServletLeaseTestClient. Even with this, will still have to look at the JBoss server.log (or just console output), where should see something like: INFO [STDOUT] Connection exception: null for Client org.jboss.remoting.Client@274608 every time the client lease expires on the server side. ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/ServletHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/ServletHandler0000644000175000017500000001023310553621675033466 0ustar twernertwerner/* * 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.lease.servlet; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.Client; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.ConnectorMBean; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.ServerSocketFactoryWrapper; import org.jboss.remoting.callback.InvokerCallbackHandler; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.management.MBeanServerInvocationHandler; import javax.management.MalformedObjectNameException; import java.util.Iterator; /** * @author Tom Elrod */ public class ServletHandler implements ServerInvocationHandler, ConnectionListener { public ServletHandler() { try { ObjectName connectorObjName = new ObjectName("jboss.remoting:service=Connector,transport=Servlet"); MBeanServer mbeanServer = getMBeanServer(); System.out.println("Found jboss mbean server."); if(mbeanServer != null) { ConnectorMBean servletConnector = (ConnectorMBean)MBeanServerInvocationHandler.newProxyInstance(mbeanServer, connectorObjName, ConnectorMBean.class, false); servletConnector.addConnectionListener(this); } } catch (MalformedObjectNameException e) { e.printStackTrace(); } } protected MBeanServer getMBeanServer() { // the intention of having this as a separate protected method is for subclasses to override // it in case this servlet is not running in JBossAS and thus needs to find an non-JBoss // MBeanServer. This design won't work however since when this servlet is loaded, it will // still need to load in this JBoss specific MBeanServerLocator. But, this servlet also // requires JBoss logging too so its not like this is the only place that breaks if not running // in JBossAS. To complete this design, we must make this parent servlet an abstract class, // which this method abstract. Then we need to create a JBoss-specific subclass with this // method's code in its getMBeanServer(). for (Iterator i = MBeanServerFactory.findMBeanServer(null).iterator(); i.hasNext();) { MBeanServer server = (MBeanServer) i.next(); if (server.getDefaultDomain().equals("jboss")) { return server; } } return null; } public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public Object invoke(InvocationRequest invocation) throws Throwable { return "foobar"; } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void handleConnectionException(Throwable throwable, Client client) { System.out.println("Connection exception: " + throwable.getMessage() + " for Client " + client); } }././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/remoting-servlet-server-invoker-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/remoting-servl0000644000175000017500000000163310553621675033525 0ustar twernertwerner 3000 org.jboss.test.remoting.lease.servlet.ServletHandler libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/WEB-INF/0000755000175000017500000000000011632407031031634 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/servlet/WEB-INF/web.xm0000644000175000017500000000266510553621675033005 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet invokerName jboss.remoting:service=invoker,transport=servlet The servlet server invoker 1 ServerInvokerServlet /ServerInvokerServlet/* ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/UniquePingerTaskTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/UniquePingerTaskTestCa0000644000175000017500000001416411253212413033411 0ustar twernertwerner/* * 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.lease; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.InetAddress; import java.util.HashMap; 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.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.LeasePinger; 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.SocketClientInvoker; /** * Unit test for JBREM-794. * * @author Ron Sigal * @version $Revision: 5467 $ *

          * Copyright Aug 22, 2007 *

          */ public class UniquePingerTaskTestCase extends TestCase { private static Logger log = Logger.getLogger(UniquePingerTaskTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected Connector connector; protected 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 LeasePinger.LeaseTimerTask gets created. */ public void testUniqueLeaseTimerTask() throws Throwable { log.info("entering " + getName()); setupServer(); SocketClientInvoker clientInvoker = new SocketClientInvoker(serverLocator); clientInvoker.connect(); LeasePinger leasePinger = new LeasePinger(clientInvoker, "abc", 2000); log.info("expect WARN \"failed to ping to server\""); Method method = LeasePinger.class.getDeclaredMethod("setLeasePingerId", new Class[]{String.class}); method.setAccessible(true); method.invoke(leasePinger, new Object[]{"dummyID"}); leasePinger.addClient("def", null, 1000); // Verify LeasePingerTimerTask has not been created. Field field = LeasePinger.class.getDeclaredField("timerTask"); field.setAccessible(true); TimerTask timerTask = (TimerTask) field.get(leasePinger); assertNull(timerTask); leasePinger.startPing(); timerTask = (TimerTask) field.get(leasePinger); assertNotNull(timerTask); // Verify new LeasePingerTimerTask gets created when adding new Client // with shorter lease period. leasePinger.addClient("ghi", null, 500); TimerTask newTimerTask = (TimerTask) field.get(leasePinger); assertNotSame(newTimerTask, timerTask); log.info(getName() + " PASSES"); } protected void setupServer() throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = "socket://" + 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("leasePeriod", "1000"); connector = new Connector(serverLocator, config); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.addConnectionListener(new TestConnectionListener()); 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 TestConnectionListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { } } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/InjectedConnectionListenerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/InjectedConnectionList0000644000175000017500000001653311413660476033470 0ustar twernertwernerpackage org.jboss.test.remoting.lease; import java.io.ByteArrayInputStream; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; 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.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; /** * * Unit test for JBREM-1012. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jul 18, 2008 *

          */ public class InjectedConnectionListenerTestCase extends TestCase { private static Logger log = Logger.getLogger(InjectedConnectionListenerTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; 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); } TestConnectionListener.gotException = false; } public void tearDown() { } public void testInjectionWithClassName() throws Throwable { log.info("entering " + getName()); // Start server. MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); setupServer(TestConnectionListener.class.getName(), mbeanServer); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "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"); // Verify ConnectionListener is notified. log.info("client disconnecting"); client.disconnect(); log.info("client disconnected"); assertTrue(TestConnectionListener.gotException); shutdownServer(); log.info(getName() + " PASSES"); } public void testInjectionWithMBean() throws Throwable { log.info("entering " + getName()); // Start server. String connectionListenerName = "jboss:type=connectionlistener"; ObjectName objName = new ObjectName(connectionListenerName); MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); TestConnectionListener listener = new TestConnectionListener(); mbeanServer.registerMBean(listener, objName); setupServer(connectionListenerName, mbeanServer); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(Client.ENABLE_LEASE, "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"); // Verify ConnectionListener is notified. log.info("client disconnecting"); client.disconnect(); log.info("client disconnected"); assertTrue(TestConnectionListener.gotException); shutdownServer(); log.info(getName() + " PASSES"); } protected String getTransport() { return "socket"; } protected void addExtraClientConfig(Map config) {} protected void addExtraServerConfig(Map config) {} protected void setupServer(String listener, MBeanServer mbeanServer) throws Exception { HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraServerConfig(config); Connector connector = new Connector(config); mbeanServer.registerMBean(connector, new ObjectName("test:type=connector")); host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(" "); buf.append(" " + host + ""); buf.append(" " + port + ""); buf.append(" " + listener + ""); buf.append(" 5000"); buf.append(" "); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.addInvocationHandler("test", new TestInvocationHandler()); connector.start(); locatorURI = connector.getInvokerLocator(); log.info("Started remoting server with locator uri of: " + locatorURI); } 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) {} } public interface TestConnectionListenerMBean extends ConnectionListener { } public static class TestConnectionListener implements TestConnectionListenerMBean { public static boolean gotException; public void handleConnectionException(Throwable throwable, Client client) { gotException = true; log.info("TestConnectionListener got exception"); } } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/LeaseUnitTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/LeaseUnitTestCase.java0000644000175000017500000002016110506110050033300 0ustar twernertwerner/* * 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.lease; import junit.framework.TestCase; import org.apache.log4j.Level; import org.jboss.logging.XLevel; import org.jboss.remoting.ConnectionNotifier; import org.jboss.remoting.Lease; import java.util.Map; /** * @author Tom Elrod */ public class LeaseUnitTestCase extends TestCase { public void setUp() { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.INFO); org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(XLevel.TRACE); org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.FATAL); } public void testLease() throws Exception { ConnectionNotifierMock notifier = new ConnectionNotifierMock(); Lease lease = new Lease("123", 5000, "foobar", null, notifier, null); lease.startLease(); System.out.println("test - lease started"); System.out.println("test - sleeping 3 seconds"); Thread.currentThread().sleep(3000); assertFalse(notifier.notificationFired); System.out.println("test - update lease"); lease.updateLease(5000); System.out.println("test - sleeping 5 seconds"); Thread.currentThread().sleep(5000); assertFalse(notifier.notificationFired); System.out.println("test - update lease"); lease.updateLease(5000); System.out.println("test - sleeping 10 seconds"); Thread.currentThread().sleep(10000); assertFalse(notifier.notificationFired); System.out.println("test - update lease"); lease.updateLease(5000); System.out.println("test - sleeping 60 seconds"); Thread.currentThread().sleep(60000); assertTrue(notifier.notificationFired); } public void testMultipleLeases() throws Exception { ConnectionNotifierMock notifier1 = new ConnectionNotifierMock(); ConnectionNotifierMock notifier2 = new ConnectionNotifierMock(); ConnectionNotifierMock notifier3 = new ConnectionNotifierMock(); Lease lease1 = new Lease("123", 3000, "foo", null, notifier1, null); Lease lease2 = new Lease("456", 5000, "bar", null, notifier2, null); Lease lease3 = new Lease("789", 10000, "foobar", null, notifier3, null); lease1.startLease(); lease2.startLease(); lease3.startLease(); // when first started, the lease window is lease period X 2 System.out.println("waiting 5 seconds before update."); Thread.currentThread().sleep(5000); assertFalse(notifier1.notificationFired); assertFalse(notifier2.notificationFired); assertFalse(notifier3.notificationFired); lease1.updateLease(3000); lease2.updateLease(5000); lease3.updateLease(10000); // having to so 5 second sleep again, because lease window // not activated until after the first update is made System.out.println("waiting 5 seconds before update."); Thread.currentThread().sleep(5000); assertFalse(notifier1.notificationFired); assertFalse(notifier2.notificationFired); assertFalse(notifier3.notificationFired); lease1.updateLease(3000); lease2.updateLease(5000); lease3.updateLease(10000); // now initial delay is gone (since update with the same delay times), // however, the lease window is bigger (should be 10 seconds) since took so long to update, // therefore, should be able to wait 8 seconds now without firing System.out.println("waiting 8 seconds before update."); Thread.currentThread().sleep(8000); assertFalse(notifier1.notificationFired); assertFalse(notifier2.notificationFired); assertFalse(notifier3.notificationFired); // will let lease1 timeout, but update lease 2 & 3 to new times // which should reset the delay window to new value of 6 seconds lease2.updateLease(3000); lease3.updateLease(3000); // will be waiting 2 seconds and then updating lease 2 & 3 // several times as we don't want to change the lease window // for them, but have to allow lease 1 to timeout (and since it's // lease window is now 10 and requires two internal timeouts on the // lease before the notification is fired, means need to wait a total // of 20 seonds) System.out.println("waiting 2 seconds before update"); Thread.currentThread().sleep(2000); // note, should *not* change the lease window lease2.updateLease(3000); lease3.updateLease(3000); System.out.println("waiting 2 seconds before update"); Thread.currentThread().sleep(2000); // note, should *not* change the lease window lease2.updateLease(3000); lease3.updateLease(3000); System.out.println("waiting 2 seconds before update"); Thread.currentThread().sleep(2000); // note, should *not* change the lease window lease2.updateLease(3000); lease3.updateLease(3000); System.out.println("waiting 2 seconds before update"); Thread.currentThread().sleep(2000); // note, should *not* change the lease window lease2.updateLease(3000); lease3.updateLease(3000); System.out.println("waiting 2 seconds before update"); Thread.currentThread().sleep(2000); // note, should *not* change the lease window lease2.updateLease(3000); lease3.updateLease(3000); System.out.println("waiting 2 seconds before update"); Thread.currentThread().sleep(2000); // note, should *not* change the lease window lease2.updateLease(3000); lease3.updateLease(3000); System.out.println("waiting 2 seconds before update"); Thread.currentThread().sleep(2000); // should be total of 22 seconds for lease 1, so should have timeout assertTrue(notifier1.notificationFired); assertFalse(notifier2.notificationFired); assertFalse(notifier3.notificationFired); // will let lease2 timout now, but update lease 3, but use same time. lease3.updateLease(3000); System.out.println("waiting 4 seonds before update"); Thread.currentThread().sleep(4000); lease3.updateLease(3000); System.out.println("4 seconds for lease 2 timeout"); Thread.currentThread().sleep(4000); lease3.updateLease(3000); System.out.println("4 seconds for lease 2 timeout"); Thread.currentThread().sleep(4000); assertTrue(notifier2.notificationFired); assertFalse(notifier3.notificationFired); // now will let lease 3 timeout System.out.println("waiting 15 seconds for lease 3 timeout"); Thread.currentThread().sleep(15000); assertTrue(notifier3.notificationFired); } public static class ConnectionNotifierMock extends ConnectionNotifier { public boolean notificationFired = false; public void connectionLost(String locatorurl, String clientSessionId, Map requestPayload) { System.out.println("connection lost"); notificationFired = true; } public void connectionTerminated(String locatorURL, String clientSessionId, Map requestPayload) { System.out.println("connection terminate"); notificationFired = true; } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/synchronization/0000755000175000017500000000000011632407031032362 5ustar twernertwerner././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/synchronization/MultipleClientSynchronizationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/lease/synchronization/Multip0000644000175000017500000002472710714016571033600 0ustar twernertwerner/* * 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.lease.synchronization; import java.net.InetAddress; import java.util.Date; 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.ConnectionListener; 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; /** * * @author Ron Sigal * @version $Revision: 2913 $ *

          * Copyright Jul 31, 2007 *

          */ public class MultipleClientSynchronizationTestCase extends TestCase { protected static Logger log = Logger.getLogger(MultipleClientSynchronizationTestCase.class); protected static boolean firstTime = true; protected static BooleanHolder go1 = new BooleanHolder(); protected static BooleanHolder go2 = new BooleanHolder(); protected static BooleanHolder stop1 = new BooleanHolder(); protected static BooleanHolder stop2 = new BooleanHolder(); protected static InvokerLocator locator; protected static int counter; protected static Object lock = new Object(); 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); } counter = 0; } public void testMultipleClientsStoppingAndStartingSimultaneously() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "socket://" + host + ":" + port; locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); connector.setLeasePeriod(1000); connector.addConnectionListener(new TestListener()); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); int INVOCATIONS = 1000; ClientThread[] threads = new ClientThread[INVOCATIONS]; // Start clients 0..499. for (int i = 0; i < INVOCATIONS / 2; i++) { threads[i] = new ClientThread(i, go1, stop1); threads[i].start(); } synchronized (go1) { go1.value = true; go1.notifyAll(); } Thread.sleep(5000); // Stop clients 0..499 and start clients 500..999. for (int i = INVOCATIONS / 2; i < INVOCATIONS; i++) { threads[i] = new ClientThread(i, go2, stop2); threads[i].start(); } synchronized (stop1) { stop1.value = true; stop1.notifyAll(); } synchronized (go2) { go2.value = true; go2.notifyAll(); } Thread.sleep(5000); // Stop clients 500..999. synchronized (stop2) { stop2.value = true; stop2.notifyAll(); } // Wait for clients to disconnect. for (int i = 0; i < 60; i++) { synchronized (lock) { log.info("counter: " + counter); if (counter == INVOCATIONS) break; } try { Thread.sleep(2000); } catch (Exception e) { } } // Verify that all clients started and stopped successfully. for (int i = 0; i < INVOCATIONS; i++) { assertTrue(new Date() + ": failure in thread: " + i, threads[i].ok); } connector.stop(); log.info(getName() + " PASSES"); } public void testMultipleClientsStartingStoppingStarting() throws Throwable { log.info("entering " + getName()); String host = InetAddress.getLocalHost().getHostAddress(); int port = PortUtil.findFreePort(host); String locatorURI = "socket://" + host + ":" + port; locator = new InvokerLocator(locatorURI); Connector connector = new Connector(locator); connector.create(); connector.setLeasePeriod(1000); connector.addConnectionListener(new TestListener()); TestHandler handler = new TestHandler(); connector.addInvocationHandler("test", handler); connector.start(); int INVOCATIONS = 1000; ClientThread[] threads = new ClientThread[INVOCATIONS]; // Start clients 0..499. for (int i = 0; i < INVOCATIONS / 2; i++) { threads[i] = new ClientThread(i, go1, stop1); threads[i].start(); } synchronized (go1) { go1.value = true; go1.notifyAll(); } Thread.sleep(5000); // Stop clients 0..499. synchronized (stop1) { stop1.value = true; stop1.notifyAll(); } // Start clients 500..999. for (int i = INVOCATIONS / 2; i < INVOCATIONS; i++) { threads[i] = new ClientThread(i, go2, stop2); threads[i].start(); } synchronized (go2) { go2.value = true; go2.notifyAll(); } Thread.sleep(5000); // Stop clients 500..999. synchronized (stop2) { stop2.value = true; stop2.notifyAll(); } // Wait for clients to disconnect. for (int i = 0; i < 60; i++) { synchronized (lock) { log.info("counter: " + counter); if (counter == INVOCATIONS) break; } try { Thread.sleep(2000); } catch (Exception e) { } } // Verify that all clients started and stopped successfully. for (int i = 0; i < INVOCATIONS; i++) { assertTrue(new Date() + ": failure in thread: " + threads[i], threads[i].ok); } connector.stop(); log.info(getName() + " PASSES"); } public class ClientThread extends Thread { boolean ok; int id; BooleanHolder startFlag; BooleanHolder stopFlag; Client client; public ClientThread(int id, BooleanHolder startFlag, BooleanHolder stopFlag) throws Exception { this.id = id; this.startFlag = startFlag; this.stopFlag = stopFlag; HashMap config = new HashMap(); config.put(InvokerLocator.FORCE_REMOTE, "true"); config.put(Client.ENABLE_LEASE, "true"); config.put(InvokerLocator.CLIENT_LEASE_PERIOD, "1000"); client = new Client(locator, config); setName("ClientThread-" + id); log.debug("client created (" + id + "): " + client.getSessionId()); } public void run() { try { synchronized (startFlag) { while (!startFlag.value) { try {startFlag.wait();} catch (InterruptedException e) {} } } log.debug("client got start flag (" + id + "): " + client.getSessionId()); client.connect(); log.debug("client connected (" + id + "): " + client.getSessionId()); } catch (Throwable e) { e.printStackTrace(); } try { log.debug("client waiting for stop flag (" + id + "): " + client.getSessionId()); synchronized (stopFlag) { while (!stopFlag.value) { try {stopFlag.wait();} catch (InterruptedException e) {} } } log.debug("client got stop flag (" + id + "): " + client.getSessionId()); client.disconnect(); // log.info("client disconnected (" + id + "): " + client.getSessionId()); ok = true; log.debug("client ok (" + id + "):" + client.getSessionId()); synchronized (lock) { counter++; } } catch (Throwable e) { e.printStackTrace(); } } } static class TestHandler 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) {} } public static class TestListener implements ConnectionListener { public void handleConnectionException(Throwable throwable, Client client) { log.debug("got connection exception: " + throwable); } } static class BooleanHolder { public boolean value; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/0000755000175000017500000000000011632407032027446 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/0000755000175000017500000000000011632407032030530 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/service/0000755000175000017500000000000011632407032032170 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/service/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/service/readme0000644000175000017500000000073210233342174033353 0ustar twernertwernerThis is a manual test. To perform test, put the jboss-remoting-tests.jar in the server/all/lib directory of the jboss server. Then put the mbeanhandler-service.xml in the server/all/deploy directory. Then start jboss with the all configuration (i.e. run -c all). This should start the MBeanHadler MBean (since it is defined as a service bean within the service.xml) and the Connector. Then run the ClientTest. This should make the invocation on the MBeanHandler class.././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/service/ClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/service/Client0000644000175000017500000000455110433770344033345 0ustar twernertwerner/* * 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.handler.mbean.service; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ClientTest { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; public void makeInvocation(String locatorURI) throws Throwable { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); Object response = remotingClient.invoke("Do something"); System.out.println("Invocation response: " + response); } /** * 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; ClientTest clientTest = new ClientTest(); try { clientTest.makeInvocation(locatorURI); } catch(Throwable e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/service/mbeanhandler-service.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/service/mbeanh0000644000175000017500000000544710456070655033371 0ustar twernertwerner 1 303 304 60000 ${jboss.bind.address} 5400 false 200 test:type=handler 2410 ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/ClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/ClientTest.jav0000644000175000017500000000375010433770344033324 0ustar twernertwerner/* * 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.handler.mbean; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ClientTest extends TestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = null; public void testMakeInvocation() throws Throwable { if(locatorURI == null) { locatorURI = transport + "://" + host + ":" + port; } InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); Object response = remotingClient.invoke("Do something"); assertEquals(response, ServerTest.RESPONSE_VALUE); remotingClient.disconnect(); } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/MBeanHandlerMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/MBeanHandlerMB0000644000175000017500000000232310355142433033154 0ustar twernertwerner/* * 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.handler.mbean; import org.jboss.remoting.ServerInvocationHandler; /** * @author Tom Elrod */ public interface MBeanHandlerMBean extends ServerInvocationHandler { }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/MBeanHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/MBeanHandler.j0000644000175000017500000000615510355142433033174 0ustar twernertwerner/* * 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.handler.mbean; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * @author Tom Elrod */ public class MBeanHandler implements MBeanHandlerMBean { private MBeanServer server = null; private ServerInvoker invoker = null; /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { this.server = server; } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { this.invoker = invoker; } /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { System.out.println(invocation.getParameter()); return ServerTest.RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { // NO OP for test } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { // NO OP for test } /*************************************************************** * Following satisfies being a mbean service within JBossAS * ***************************************************************/ /** * create the service, do expensive operations etc */ void create() throws Exception { } /** * start the service, create is already called */ void start() throws Exception { } /** * stop the service */ void stop() { } /** * destroy the service, tear down */ void destroy() { } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/MBeanHandlerTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/MBeanHandlerTe0000644000175000017500000000326510535452155033241 0ustar twernertwerner/* * 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.handler.mbean; 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 MBeanHandlerTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ClientTest.class.getName(), 1, ServerTest.class.getName()); } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/ServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/handler/mbean/ServerTest.jav0000644000175000017500000000624410355142433033350 0ustar twernertwerner/* * 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.handler.mbean; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class ServerTest extends ServerTestCase { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; 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 from the TestServer invocation"; public void setupServer() throws Exception { MBeanServer server = MBeanServerFactory.createMBeanServer(); 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(); server.registerMBean(connector, new ObjectName("test:type=connector,transport=socket")); // now create Mbean handler and register with mbean server MBeanHandler handler = new MBeanHandler(); ObjectName objName = new ObjectName("test:type=handler"); server.registerMBean(handler, objName); connector.addInvocationHandler("test", objName); } public void setUp() throws Exception { setupServer(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } /** * Can pass transport and port to be used as parameters. * Valid transports are 'rmi' and 'socket'. * * @param args */ public static void main(String[] args) { ServerTest serverTest = new ServerTest(); try { serverTest.setUp(); } catch(Exception e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/0000755000175000017500000000000011632407033026716 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/IPv6InvokerLocatorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/IPv6InvokerLocatorTestC0000644000175000017500000001200211413660476033256 0ustar twernertwerner/* * 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.ipv6; import java.util.HashMap; import java.util.Map; 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.InvokerLocator; import org.jboss.remoting.transport.Connector; /** * Unit tests for JBREM-1175. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Jan 8, 2010 *

          */ public class IPv6InvokerLocatorTestCase extends TestCase { private static Logger log = Logger.getLogger(IPv6InvokerLocatorTestCase.class); private static boolean firstTime = true; protected String host; protected int port; protected String locatorURI; protected InvokerLocator serverLocator; protected 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 tearDown() { } public void testHostWithBrackets() { log.info("entering " + getName()); Map params = new HashMap(); params.put("x", "y"); assertTrue(doTest("socket", "[::]", 1234, "a/b", params, "socket://[::]:1234/a/b?x=y")); assertTrue(doTest("socket", "[::1]", 1234, "a/b", params, "socket://[::1]:1234/a/b?x=y")); assertTrue(doTest("socket", "[0:0:0:0:0:0:0:1]", 1234, "a/b", params, "socket://[0:0:0:0:0:0:0:1]:1234/a/b?x=y")); assertTrue(doTest("socket", "[0:0:0:0:0:0:127.0.0.1]", 1234, "a/b", params, "socket://[0:0:0:0:0:0:127.0.0.1]:1234/a/b?x=y")); assertTrue(doTest("socket", "[3ffe:1900:4545:3:200:f8ff:fe21:67cf]", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]:1234/a/b?x=y")); String version = System.getProperty("java.version"); if (version.startsWith("1.4")) { log.info("java version is " + version + ". Skipping test"); } else { assertTrue(doTest("socket", "[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]:1234/a/b?x=y")); } log.info(getName() + " PASSES"); } public void testHostWithoutBrackets() { log.info("entering " + getName()); Map params = new HashMap(); params.put("x", "y"); assertTrue(doTest("socket", "::", 1234, "a/b", params, "socket://[::]:1234/a/b?x=y")); assertTrue(doTest("socket", "::1", 1234, "a/b", params, "socket://[::1]:1234/a/b?x=y")); assertTrue(doTest("socket", "0:0:0:0:0:0:0:1", 1234, "a/b", params, "socket://[0:0:0:0:0:0:0:1]:1234/a/b?x=y")); assertTrue(doTest("socket", "0:0:0:0:0:0:127.0.0.1", 1234, "a/b", params, "socket://[0:0:0:0:0:0:127.0.0.1]:1234/a/b?x=y")); assertTrue(doTest("socket", "3ffe:1900:4545:3:200:f8ff:fe21:67cf", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]:1234/a/b?x=y")); String version = System.getProperty("java.version"); if (version.startsWith("1.4")) { log.info("java version is " + version + ". Skipping test"); } else { assertTrue(doTest("socket", "3ffe:1900:4545:3:200:f8ff:fe21:67cf%5", 1234, "a/b", params, "socket://[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]:1234/a/b?x=y")); } log.info(getName() + " PASSES"); } protected boolean doTest(String protocol, String host, int port, String path, Map params, String expected) { InvokerLocator locator = new InvokerLocator(protocol, host, port, path, params); log.info(host + " -> " + locator.getLocatorURI()); return expected.equals(locator.getLocatorURI()); } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/PercentEncodingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/PercentEncodingTestCase0000644000175000017500000000573611413660476033370 0ustar twernertwerner/* * 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.ipv6; 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.InvokerLocator; /** * * Unit test for * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jan 23, 2008 *

          */ public class PercentEncodingTestCase extends TestCase { private static Logger log = Logger.getLogger(PercentEncodingTestCase.class); private static boolean firstTime = true; 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); log.info("java.version: " + System.getProperty("java.version")); } } public void tearDown() { } public void testPercentEncoding() throws Throwable { log.info("entering " + getName()); String version = System.getProperty("java.version"); if (version.startsWith("1.4")) { log.info("java version is " + version + ". Skipping test"); } else { String locatorURI = "socket://[fe80::205:9aff:fe3c:7800%7]:7777/"; InvokerLocator locator = new InvokerLocator(locatorURI); assertEquals(locatorURI, locator.getLocatorURI()); locatorURI = "socket://multihome/?homes=[fe80::205:9aff:fe3c:7800%7]:7777![fe80::214:22ff:feef:68bb%4]:8888"; locator = new InvokerLocator(locatorURI); assertEquals(locatorURI, locator.getLocatorURI()); } log.info(getName() + " PASSES"); } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/IPv6HostWithNoBracketsTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/IPv6HostWithNoBracketsT0000644000175000017500000003502711413660476033237 0ustar twernertwerner/* * 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.ipv6; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.xml.parsers.DocumentBuilderFactory; 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.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerConfiguration; 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.util.SecurityUtility; import org.w3c.dom.Document; import org.w3c.dom.Element; /** * Unit tests for JBREM-1164. * * @author Ben Clare * @author Ron Sigal * * @version $Rev$ *

          * Copyright Dec 20, 2009 *

          */ public class IPv6HostWithNoBracketsTestCase extends TestCase { private static Logger log = Logger.getLogger(IPv6HostWithNoBracketsTestCase.class); private static boolean firstTime = true; private static int port = 8080; 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 testXMLWithoutBrackets() throws Throwable { log.info("entering " + getName()); assertTrue(doXMLTest("::", ++port)); assertTrue(doXMLTest("::1", ++port)); assertTrue(doXMLTest("0:0:0:0:0:0:0:1", ++port)); assertTrue(doXMLTest("0:0:0:0:0:0:127.0.0.1", ++port)); assertTrue(doXMLTest("3ffe:1900:4545:3:200:f8ff:fe21:67cf", ++port)); String version = System.getProperty("java.version"); if (version.startsWith("1.4")) { log.info("java version is " + version + ". Skipping test"); } else { assertTrue(doXMLTest("3ffe:1900:4545:3:200:f8ff:fe21:67cf%5", ++port)); } log.info(getName() + " PASSES"); } public void testXMLWithBrackets() throws Throwable { log.info("entering " + getName()); assertTrue(doXMLTest("[::]", ++port)); assertTrue(doXMLTest("[::1]", ++port)); assertTrue(doXMLTest("[0:0:0:0:0:0:0:1]", ++port)); assertTrue(doXMLTest("[0:0:0:0:0:0:127.0.0.1]", ++port)); assertTrue(doXMLTest("[3ffe:1900:4545:3:200:f8ff:fe21:67cf]", ++port)); String version = System.getProperty("java.version"); if (version.startsWith("1.4")) { log.info("java version is " + version + ". Skipping test"); } else { assertTrue(doXMLTest("[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]", ++port)); } log.info(getName() + " PASSES"); } public void testXMLWithoutHost() throws Exception { log.info("entering " + getName()); String xml = new StringBuffer() .append("\n") .append(" \n") .append(" \n") .append(" \n") .append(" " + port + "\n") .append(" 10000\n") .append(" \n") .append(" \n") .append(" " + SampleInvocationHandler.class.getName() + "\n") .append(" \n") .append(" \n") .append(" \n") .append("\n").toString(); Connector connector = new Connector(); ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes()); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); Element element = doc.getDocumentElement(); connector.setConfiguration(element); try { connector.create(); InvokerLocator expected = new InvokerLocator("socket://" + getLocalHost() + ":" + port + "/?timeout=10000"); InvokerLocator actual = connector.getLocator(); log.info("Expected: " + expected); log.info("Actual: " + actual);InetAddress.getLocalHost(); assertEquals(expected, actual); } catch (Exception e) { log.error("Exception caught " + e.getMessage()); } finally { connector.stop(); } log.info(getName() + " PASSES"); } public void testServerConfigurationWithoutBrackets() throws Throwable { log.info("entering " + getName()); assertTrue(doServerConfigurationTest("::", ++port)); assertTrue(doServerConfigurationTest("::1", ++port)); assertTrue(doServerConfigurationTest("0:0:0:0:0:0:0:1", ++port)); assertTrue(doServerConfigurationTest("0:0:0:0:0:0:127.0.0.1", ++port)); assertTrue(doServerConfigurationTest("3ffe:1900:4545:3:200:f8ff:fe21:67cf", ++port)); String version = System.getProperty("java.version"); if (version.startsWith("1.4")) { log.info("java version is " + version + ". Skipping test"); } else { assertTrue(doServerConfigurationTest("3ffe:1900:4545:3:200:f8ff:fe21:67cf%5", ++port)); } log.info(getName() + " PASSES"); } public void testServerConfigurationWithBrackets() throws Throwable { log.info("entering " + getName()); assertTrue(doServerConfigurationTest("[::]", ++port)); assertTrue(doServerConfigurationTest("[::1]", ++port)); assertTrue(doServerConfigurationTest("[0:0:0:0:0:0:0:1]", ++port)); assertTrue(doServerConfigurationTest("[0:0:0:0:0:0:127.0.0.1]", ++port)); assertTrue(doServerConfigurationTest("[3ffe:1900:4545:3:200:f8ff:fe21:67cf]", ++port)); String version = System.getProperty("java.version"); if (version.startsWith("1.4")) { log.info("java version is " + version + ". Skipping test"); } else { assertTrue(doServerConfigurationTest("[3ffe:1900:4545:3:200:f8ff:fe21:67cf%5]", ++port)); } log.info(getName() + " PASSES"); } public void testServerConfigurationWithoutHost() throws Throwable { log.info("entering " + getName()); // Create ServerConfiguration. ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); // Add invokerLocatorParameters. locatorConfig.put("serverBindPort", Integer.toString(port)); locatorConfig.put("timeout", "10000"); config.setInvokerLocatorParameters(locatorConfig); // Add invocation handler. Map handlers = new HashMap(); ServerInvocationHandler handler = new SampleInvocationHandler(); handlers.put("test", handler); config.setInvocationHandlers(handlers); // Create Connector. Connector connector = new Connector(); try { connector.setServerConfiguration(config); connector.create(); InvokerLocator expected = new InvokerLocator("socket://" + getLocalHost() + ":" + port + "/?timeout=10000"); InvokerLocator actual = connector.getLocator(); log.info("Expected: " + expected); log.info("Actual: " + actual); assertEquals(expected, actual); } catch (Exception e) { log.error("Exception caught ", e); } finally { connector.stop(); } log.info(getName() + " PASSES"); } protected boolean doXMLTest(String host, int port) throws Exception { String xml = new StringBuffer() .append("\n") .append(" \n") .append(" \n") .append(" \n") .append(" " + host + "\n") .append(" " + port + "\n") .append(" 10000\n") .append(" \n") .append(" \n") .append(" " + SampleInvocationHandler.class.getName() + "\n") .append(" \n") .append(" \n") .append(" \n") .append("\n").toString(); Connector connector = new Connector(); ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes()); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); Element element = doc.getDocumentElement(); connector.setConfiguration(element); try { connector.create(); InvokerLocator expected = new InvokerLocator("socket://" + fixHostnameForURL(host) + ":" + port + "/?timeout=10000"); InvokerLocator actual = connector.getLocator(); log.info("Expected: " + expected); log.info("Actual: " + actual); assertEquals(expected, actual); return true; } catch (Exception e) { log.error("Exception caught ", e); return false; } finally { connector.stop(); } } protected boolean doServerConfigurationTest(String host, int port) throws Exception { // Create ServerConfiguration. ServerConfiguration config = new ServerConfiguration("socket"); Map locatorConfig = new HashMap(); // Add invokerLocatorParameters. locatorConfig.put("serverBindAddress", host); locatorConfig.put("serverBindPort", Integer.toString(port)); locatorConfig.put("timeout", "10000"); config.setInvokerLocatorParameters(locatorConfig); // Add invocation handler. Map handlers = new HashMap(); ServerInvocationHandler handler = new SampleInvocationHandler(); handlers.put("test", handler); config.setInvocationHandlers(handlers); // Create Connector. Connector connector = new Connector(); try { connector.setServerConfiguration(config); connector.create(); InvokerLocator expected = new InvokerLocator("socket://" + fixHostnameForURL(host) + ":" + port + "/?timeout=10000"); InvokerLocator actual = connector.getLocator(); log.info("Expected: " + expected); log.info("Actual: " + actual); assertEquals(expected, actual); return true; } catch (Exception e) { log.error("Exception caught ", e); return false; } finally { connector.stop(); } } static protected String fixHostnameForURL(String host) { if (host == null) return host ; // if the hostname is an IPv6 literal, enclose it in brackets if (host.indexOf(':') != -1 && host.indexOf("[") == -1) { System.out.println("HOST: [" + host + "]"); return "[" + host + "]" ; } else { return host; } } static protected String getLocalHost() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { try { System.setProperty("java.net.preferIPv6Addresses", "true"); return InetAddress.getLocalHost().getHostAddress(); } catch (IOException e) { return InetAddress.getByName("127.0.0.1").getHostAddress(); } } try { return (String) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { try { System.setProperty("java.net.preferIPv6Addresses", "true"); return InetAddress.getLocalHost().getHostAddress(); } catch (IOException e) { return InetAddress.getByName("127.0.0.1").getHostAddress(); } } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } public static class SampleInvocationHandler implements ServerInvocationHandler { public Object invoke(InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void addListener(InvokerCallbackHandler callbackHandler) {} 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/ipv6/IPv6TestCase.java0000644000175000017500000001700211413660476032012 0ustar twernertwerner/* * 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.ipv6; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; 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.transport.Connector; import org.jboss.remoting.transport.PortUtil; /** * * Unit test for JBREM-852. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Dec 4, 2007 *

          */ public class IPv6TestCase extends TestCase { private static Logger log = Logger.getLogger(IPv6TestCase.class); private static boolean firstTime = true; private static boolean ipv6IsAvailable = true; // remoting server connector private Connector connector; private InvokerLocator serverLocator; private TestInvocationHandler invocationHandler; 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); log.info("java.version: " + System.getProperty("java.version")); try { InetAddress addr = InetAddress.getByName("[::1]"); new ServerSocket(3333, 200, addr); } catch (Exception e) { if ("Protocol family unavailable".equalsIgnoreCase(e.getMessage()) || "Protocol family not supported".equalsIgnoreCase(e.getMessage())) { ipv6IsAvailable = false; log.info("ipV6 is not available"); } } } } public void tearDown() { } public void testRawIPv6() throws Throwable { log.info("entering " + getName()); if (!ipv6IsAvailable) return; final InetAddress addr = InetAddress.getByName("[::1]"); new Thread() { public void run() { try { ServerSocket ss = new ServerSocket(4446, 200, addr); log.info("ss address: " + ss.getInetAddress()); Socket s = ss.accept(); InputStream is = s.getInputStream(); log.info("read: " + is.read()); s.close(); ss.close(); } catch (Exception e) { log.error("error", e); } } }.start(); Thread.sleep(2000); Socket s = new Socket(addr, 4446); log.info("s address: " + s.getInetAddress()); log.info("s local address: " + s.getLocalAddress()); OutputStream os = s.getOutputStream(); os.write(17); log.info("wrote 17"); s.close(); log.info(getName() + " PASSES"); } public void testRemotingIPv6Loopback() throws Throwable { log.info("entering " + getName()); if (!ipv6IsAvailable) return; doRemotingTest("[::1]"); log.info(getName() + " PASSES"); } public void testRemotingIPv6Any() throws Throwable { log.info("entering " + getName()); if (!ipv6IsAvailable) return; doRemotingTest("[::]"); log.info(getName() + " PASSES"); } public void testRemotingIPv4Mapped() throws Throwable { if (!ipv6IsAvailable) return; doRemotingTest("[::ffff:127.0.0.1]"); } protected void doRemotingTest(String host) throws Throwable { // Start server. InetAddress[] addresses = InetAddress.getAllByName("localhost"); for (int i = 0; i < addresses.length; i++) { log.info("addresses[" + i + "]: " + addresses[i]); } int port = PortUtil.findFreePort(host); String locatorURI = "socket://" + host + ":" + port + "/?timeout=10000"; 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. InvokerLocator clientLocator1 = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); addExtraClientConfig(clientConfig); Client client = new Client(clientLocator1, clientConfig); client.connect(); log.info("client is connected"); // Test connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); 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 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"); } } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/ObjectNameWithIPv6AddressTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/ipv6/ObjectNameWithIPv6Addre0000644000175000017500000001743711413660476033176 0ustar twernertwerner/* * 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.ipv6; import java.net.InetAddress; import java.net.ServerSocket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectInstance; import javax.management.ObjectName; 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.network.NetworkRegistry; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; public class ObjectNameWithIPv6AddressTestCase extends TestCase { private static Logger log = Logger.getLogger(ObjectNameWithIPv6AddressTestCase.class); private static boolean firstTime = true; private static boolean ipv6IsAvailable = 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); log.info("java.version: " + System.getProperty("java.version")); try { InetAddress addr = InetAddress.getByName("[::1]"); new ServerSocket(3333, 200, addr); } catch (Exception e) { if ("Protocol family unavailable".equalsIgnoreCase(e.getMessage()) || "Protocol family not supported".equalsIgnoreCase(e.getMessage())) { ipv6IsAvailable = false; log.info("ipV6 is not available"); } } } } public void tearDown() { } public void testIPv6Loopback() throws Throwable { log.info("entering " + getName()); doTest("[::1]"); log.info(getName() + " PASSES"); } public void testIPv6Any() throws Throwable { log.info("entering " + getName()); doTest("[::]"); log.info(getName() + " PASSES"); } public void testIPv4Mapped() throws Throwable { log.info("entering " + getName()); doTest("[::ffff:127.0.0.1]"); log.info(getName() + " PASSES"); } protected void doTest(String host) throws Throwable { if (!ipv6IsAvailable) return; MBeanServer server = null; try { server = (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } Connector connector = new Connector(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port; serverLocator = new InvokerLocator(locatorURI); connector.setInvokerLocator(locatorURI); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + getTransport()); server.registerMBean(connector, obj); connector.create(); invocationHandler = new TestInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); connector.start(); ServerInvoker serverInvoker = connector.getServerInvoker(); ObjectName objectName = new ObjectName(serverInvoker.getMBeanObjectName()); assertTrue(objectName.getCanonicalName().indexOf(host) >= 0); assertTrue(server.isRegistered(objectName)); log.info(objectName + " is registered"); // 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 connections. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); client.disconnect(); shutdownServer(); } 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"); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/0000755000175000017500000000000011632407043030334 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/PerformanceReporter.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/PerformanceRepor0000644000175000017500000000554210355142433033536 0ustar twernertwerner/* * 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.performance; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Date; import java.util.Iterator; import java.util.Map; /** * @author Tom Elrod */ public class PerformanceReporter { /** * Will write to report file with all the values passed. * * @param testName Name of test run. Typically should be class and test method name. * @param totalCount Total number of iterations for a test (i.e. number of calls to the server). * @param totalTime How long, in milliseconds, that the test took. This is really how long it took * to make the calls to the server and not the extra time for test setup. * @param metadata Any key value pairs would like added to the report. For example, would want to * add the transport and maybe the total number of server count. * @throws IOException */ public static void writeReport(String testName, long totalTime, int totalCount, Map metadata) throws IOException { File reportFile = new File("performance_report.txt"); if(!reportFile.exists()) { reportFile.createNewFile(); } FileWriter reportWriter = new FileWriter(reportFile, true); reportWriter.write("\n\nTest results for test: " + testName + "\n"); reportWriter.write("When run: " + new Date()); reportWriter.write("\nTotal count: " + totalCount); reportWriter.write("\nTotal time: " + totalTime); if(metadata != null) { Iterator itr = metadata.keySet().iterator(); while(itr.hasNext()) { Object key = itr.next(); Object value = metadata.get(key); reportWriter.write("\n" + key + " = " + value); } } reportWriter.write("\n\n"); reportWriter.close(); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/0000755000175000017500000000000011632407043033067 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/PerformanceClientSideTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/Per0000644000175000017500000000524310470171753033551 0ustar twernertwerner/* * 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.performance.asynchronous; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; /** * @author Tom Elrod */ public class PerformanceClientSideTestCase extends PerformanceTestCase { public void declareTestClasses() { //**************** LOGGING *********************** // 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.SimpleLayout layout = new org.apache.log4j.SimpleLayout(); // try // { // org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log"); // fileAppender.setThreshold(Level.DEBUG); // fileAppender.setAppend(false); // org.apache.log4j.Category.getRoot().addAppender(fileAppender); // } // catch(IOException e) // { // e.printStackTrace(); // } //*************** END LOGGING *********************** String numOfClients = System.getProperty(NUMBER_OF_CLIENTS); if(numOfClients != null && numOfClients.length() > 0) { try { numberOfClients = Integer.parseInt(numOfClients); } catch(NumberFormatException e) { e.printStackTrace(); } } addTestClasses(PerformanceClientSideClientTest.class.getName(), numberOfClients, PerformanceServerTest.class.getName()); } }././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/PerformanceServerSideTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/Per0000644000175000017500000000524310470171753033551 0ustar twernertwerner/* * 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.performance.asynchronous; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; /** * @author Tom Elrod */ public class PerformanceServerSideTestCase extends PerformanceTestCase { public void declareTestClasses() { //**************** LOGGING *********************** // 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.SimpleLayout layout = new org.apache.log4j.SimpleLayout(); // try // { // org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log"); // fileAppender.setThreshold(Level.DEBUG); // fileAppender.setAppend(false); // org.apache.log4j.Category.getRoot().addAppender(fileAppender); // } // catch(IOException e) // { // e.printStackTrace(); // } //*************** END LOGGING *********************** String numOfClients = System.getProperty(NUMBER_OF_CLIENTS); if(numOfClients != null && numOfClients.length() > 0) { try { numberOfClients = Integer.parseInt(numOfClients); } catch(NumberFormatException e) { e.printStackTrace(); } } addTestClasses(PerformanceServerSideClientTest.class.getName(), numberOfClients, PerformanceServerTest.class.getName()); } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/PerformanceServerSideClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/Per0000644000175000017500000000455310355142433033547 0ustar twernertwerner/* * 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.performance.asynchronous; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.test.remoting.performance.synchronous.Payload; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import junit.framework.Test; /** * @author Tom Elrod */ public class PerformanceServerSideClientTest extends PerformanceClientTest { public static Test suite() { return new ThreadLocalDecorator(PerformanceServerSideClientTest.class, 1); } protected String getBenchmarkName() { return "PerformanceServerSideClientTest"; } protected Object makeClientCall(String testInvocation, Payload payloadWrapper) throws Throwable { return makeOnewayInvocation(testInvocation, payloadWrapper, false); } protected void verifyResults(int x, Object resp) { //NO OP since no return } public static void main(String[] args) { PerformanceServerSideClientTest test = new PerformanceServerSideClientTest(); try { test.setUp(); test.testClientCalls(); } catch(Throwable throwable) { throwable.printStackTrace(); } finally { try { test.tearDown(); } catch(Exception e) { e.printStackTrace(); } } } }././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/PerformanceClientSideClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/asynchronous/Per0000644000175000017500000000455611015166145033552 0ustar twernertwerner/* * 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.performance.asynchronous; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.test.remoting.performance.synchronous.Payload; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import junit.framework.Test; /** * @author Tom Elrod */ public class PerformanceClientSideClientTest extends PerformanceClientTest { public static Test suite() { return new ThreadLocalDecorator(PerformanceClientSideClientTest.class, 1); } protected String getBenchmarkName() { return "PerformanceClientSideClientTest"; } protected Object makeClientCall(String testInvocation, Payload payloadWrapper) throws Throwable { return makeOnewayInvocation(testInvocation, payloadWrapper, true); } protected void verifyResults(int x, Object resp) { //NO OP since no return } public static void main(String[] args) { PerformanceClientSideClientTest test = new PerformanceClientSideClientTest(); try { test.setUp(); test.testClientCalls(); } catch(Throwable throwable) { throwable.printStackTrace(); } finally { try { test.tearDown(); } catch(Exception e) { e.printStackTrace(); } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/profiler/0000755000175000017500000000000011632407042032155 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/profiler/ProfileTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/profiler/Profile0000644000175000017500000000446710412065547033520 0ustar twernertwerner/* * 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.performance.profiler; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; /** * @author Tom Elrod */ public class ProfileTest { // private String numOfCalls = "100"; private String numOfCalls = "10000"; // private String numOfCalls = "1000000"; public void profilerTest() throws Throwable { PerformanceServerTest server = new PerformanceServerTest(); server.setUp(); System.out.println("Server setup"); System.setProperty(PerformanceTestCase.NUMBER_OF_CALLS, numOfCalls); System.setProperty(PerformanceTestCase.REMOTING_METADATA, "foo=bar"); PerformanceClientTest client = new PerformanceClientTest(); client.setUp(); System.out.println("Client setup"); client.testClientCalls(); System.out.println("Done with testing client calls"); client.tearDown(); server.tearDown(); } public static void main(String[] args) { ProfileTest test = new ProfileTest(); try { test.profilerTest(); } catch(Throwable throwable) { throwable.printStackTrace(); } } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/profiler/ProfileTest2.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/profiler/Profile0000644000175000017500000000431610412065547033511 0ustar twernertwernerpackage org.jboss.test.remoting.performance.profiler; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; /** * @author Tom Elrod */ public class ProfileTest2 { private static int numOfClients = 10; private static int numOfLoops = 100; private String numOfCalls = "1000"; // private String numOfCalls = "1000000"; private PerformanceServerTest server = null; public void profilerTest() throws Throwable { setupServer(); System.setProperty(PerformanceTestCase.NUMBER_OF_CALLS, numOfCalls); System.setProperty(PerformanceTestCase.REMOTING_METADATA, "foo=bar"); for(int x = 0; x < numOfClients; x++) { new Thread(new Runnable() { public void run() { try { for(int i = 0; i < numOfLoops;i++) { runClientTest(); } } catch(Throwable throwable) { throwable.printStackTrace(); } } }).start(); } while(numOfClients > 0) { Thread.currentThread().sleep(5000); } server.tearDown(); } public void setupServer() throws Exception { server = new PerformanceServerTest(); server.setUp(); System.out.println("Server setup"); } public void runClientTest() throws Throwable { PerformanceClientTest client = new PerformanceClientTest(); client.setUp(); System.out.println("Client setup"); client.testClientCalls(); System.out.println("Done with testing client calls"); client.tearDown(); numOfClients--; System.out.println("Number of clients = " + numOfClients); } public static void main(String[] args) { ProfileTest2 test = new ProfileTest2(); try { test.profilerTest(); } catch(Throwable throwable) { throwable.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/0000755000175000017500000000000011632407043031125 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/0000755000175000017500000000000011632407042031713 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIPerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIPerfo0000644000175000017500000002043210471377750033276 0ustar twernertwerner/* * 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.performance.raw.rmi; import org.apache.log4j.Level; import org.jboss.jrunit.harness.BenchmarkTestDriver; import java.io.IOException; /** * @author Tom Elrod */ public class RMIPerformanceTestCase extends BenchmarkTestDriver //TestDriver { protected int numberOfClients = 1; public static final String REMOTING_TRANSPORT = "remoting.transport"; public static final String REMOTING_METADATA = "remoting.metadata"; public static final String REMOTING_SERIALIZATION = "remoting.serialization"; public static final String PAYLOAD_SIZE = "remoting.payload.size"; public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients"; public static final String NUMBER_OF_CALLS = "remoting.number_of_calls"; public static final String JVM_MAX_HEAP_SIZE = "jvm.mx"; public static final String RESULT_TIMEOUT = "jrunit.result_timeout"; public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout"; public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout"; public static final String REMOTING_HOST = "remoting.host"; public void declareTestClasses() { //**************** LOGGING *********************** 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.SimpleLayout layout = new org.apache.log4j.SimpleLayout(); try { org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log"); fileAppender.setThreshold(Level.DEBUG); fileAppender.setAppend(false); org.apache.log4j.Category.getRoot().addAppender(fileAppender); } catch(IOException e) { e.printStackTrace(); } //*************** END LOGGING *********************** String numOfClients = System.getProperty(NUMBER_OF_CLIENTS); if(numOfClients != null && numOfClients.length() > 0) { try { numberOfClients = Integer.parseInt(numOfClients); } catch(NumberFormatException e) { e.printStackTrace(); } } addTestClasses(getClientTestClass(), numberOfClients, RMIPerformanceServer.class.getName()); } protected String getClientTestClass() { return RMIPerformanceClient.class.getName(); } protected Level getTestHarnessLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * The log level to run as for the test case. * * @return */ protected Level getTestLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness). * The default value is null. * * @return */ protected String getClientJVMArguments() { return getJVMArguments(); // String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 "; // args = args + getJVMArguments(); // return args; } /** * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness). * The default value is null. * * @return */ protected String getServerJVMArguments() { return getJVMArguments(); } /** * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness). * The default value is null. * * @return */ private String getJVMArguments() { String vmArgs = ""; String transport = System.getProperty(REMOTING_TRANSPORT); if(transport != null && transport.length() > 0) { vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport; } String host = System.getProperty(REMOTING_HOST); if(host != null && host.length() > 0) { vmArgs = "-D" + REMOTING_HOST + "=" + host; } String serialization = System.getProperty(REMOTING_SERIALIZATION); if(serialization != null && serialization.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization; } String metadata = System.getProperty(REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata; } String payloadSize = System.getProperty(PAYLOAD_SIZE); if(payloadSize != null && payloadSize.length() > 0) { vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize; } String numOfCalls = System.getProperty(NUMBER_OF_CALLS); if(numOfCalls != null && numOfCalls.length() > 0) { vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls; } String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE); if(jvmMx != null && jvmMx.length() > 0) { vmArgs = vmArgs + " -Xmx" + jvmMx + "m"; } return vmArgs; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(RESULT_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(TEAR_DOWN_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(RUN_TEST_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIServerRemote.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIServe0000644000175000017500000000255610355142433033303 0ustar twernertwerner/* * 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.performance.raw.rmi; import java.rmi.Remote; import java.rmi.RemoteException; /** * @author Tom Elrod */ public interface RMIServerRemote extends Remote { public Object makeCall(Object obj, Object param) throws RemoteException; public Object sendNumberOfCalls(Object obj, Object param) throws RemoteException; }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMICallbackServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMICallb0000644000175000017500000001002510355142433033222 0ustar twernertwerner/* * 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.performance.raw.rmi; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import EDU.oswego.cs.dl.util.concurrent.Latch; /** * @author Tom Elrod */ public class RMICallbackServer extends UnicastRemoteObject implements RMICallbackServerRemote, PerformanceCallbackKeeper { private String sessionId; private Latch lock; private int numberOfCallsProcessed = 0; private int numberofDuplicates = 0; public RMICallbackServer(String sessionId, Latch lock) throws RemoteException { super(); this.sessionId = sessionId; this.lock = lock; } public int getNumberOfCallsProcessed() { return numberOfCallsProcessed; } public int getNumberOfDuplicates() { return numberofDuplicates; } /** * 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 { Object ret = callback.getCallbackObject(); Integer[] handledArray = (Integer[]) ret; Integer numOfCallsHandled = (Integer) handledArray[0]; Integer numOfDuplicates = (Integer) handledArray[1]; System.out.println("Server is done. Number of calls handled: " + numOfCallsHandled); numberOfCallsProcessed = numOfCallsHandled.intValue(); System.out.println("Number of duplicate calls: " + numOfDuplicates); numberofDuplicates = numOfDuplicates.intValue(); Object obj = callback.getCallbackHandleObject(); //String handbackObj = (String) obj; //System.out.println("Handback object should be " + sessionId + " and server called back with " + handbackObj); lock.release(); } public void start() { try { // if(System.getSecurityManager() == null) // { // System.setSecurityManager(new RMISecurityManager()); // } int port = 1099; Registry registry = LocateRegistry.getRegistry(port); String name = "//" + sessionId + "/RMICallbackServer"; registry.rebind(name, this); System.out.println("RMICallbackServer bound"); } catch(Exception e) { System.err.println("RMICallbackServer exception: " + e.getMessage()); e.printStackTrace(); } } public void finishedProcessing(Object obj) throws RemoteException { System.out.println("finishedProcessing called with " + obj); Callback callback = (Callback) obj; try { handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIPerformanceServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIPerfo0000644000175000017500000000445510471377750033305 0ustar twernertwerner/* * 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.performance.raw.rmi; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.util.Map; /** * @author Tom Elrod */ public class RMIPerformanceServer extends PerformanceServerTest { private int rmiPort = 1099; private Registry registry = null; public void init(Map metatdata) throws Exception { //super.init(metatdata); try { registry = LocateRegistry.createRegistry(rmiPort); RMIServerRemote engine = new RMIServer(host); // Naming.rebind(name, engine); registry.rebind("//" + host + "/RMIServer", engine); } catch(RemoteException e) { e.printStackTrace(); } } public void tearDown() throws Exception { super.tearDown(); registry.unbind("//" + host + "/RMIServer"); } public static void main(String[] args) { PerformanceServerTest test = new RMIPerformanceServer(); try { test.setUp(); Thread.currentThread().sleep(300000); test.tearDown(); //System.exit(0); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/MultiThreadedRMIPerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/MultiThr0000644000175000017500000000244710355142433033416 0ustar twernertwerner/* * 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.performance.raw.rmi; /** * @author Tom Elrod */ public class MultiThreadedRMIPerformanceTestCase extends RMIPerformanceTestCase { protected String getClientTestClass() { return MultiThreadedRMIPerformanceClient.class.getName(); } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/MultiThreadedRMIPerformanceClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/MultiThr0000644000175000017500000001017110471377750033422 0ustar twernertwerner/* * 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.performance.raw.rmi; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.MultiThreadedPerformanceClientTest; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import java.rmi.Remote; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UID; import java.util.Map; /** * @author Tom Elrod */ public class MultiThreadedRMIPerformanceClient extends MultiThreadedPerformanceClientTest { private int rmiPort = 1099; private RMIServerRemote rmiServer; private String clientSessionId = new UID().toString(); protected static final Logger log = Logger.getLogger(MultiThreadedRMIPerformanceClient.class); public static Test suite() { return new ThreadLocalDecorator(MultiThreadedRMIPerformanceClient.class, 1); } public void init() { //super.init(); String name = "//" + host+ "/RMIServer"; // RMIServer svr = (RMIServer) Naming.lookup(name); try { //Registry regsitry = LocateRegistry.getRegistry("localhost", rmiPort); Registry regsitry = LocateRegistry.getRegistry(rmiPort); Remote remoteObj = regsitry.lookup(name); rmiServer = (RMIServerRemote) remoteObj; } catch(Exception e) { log.error("Error initializating rmi client.", e); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { return null; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock); callbackServer.start(); return callbackServer; } protected void populateMetadata(Map metadata) { super.populateMetadata(metadata); metadata.put("transport", "raw_rmi"); metadata.put("serialization", "java"); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = "raw_rmi" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java"; } } return config; } protected Object makeInvocation(String method, Object param) throws Throwable { if(method.equals(NUM_OF_CALLS)) { return rmiServer.sendNumberOfCalls(clientSessionId, param); } else if(method.equals(TEST_INVOCATION)) { return rmiServer.makeCall(clientSessionId, param); } else { throw new Exception("Was not able to find remote method call for " + method); } } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIPerformanceClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIPerfo0000644000175000017500000001007010471377750033273 0ustar twernertwerner/* * 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.performance.raw.rmi; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import java.rmi.Remote; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UID; import java.util.Map; /** * @author Tom Elrod */ public class RMIPerformanceClient extends PerformanceClientTest { private int rmiPort = 1099; private RMIServerRemote rmiServer; private String clientSessionId = new UID().toString(); protected static final Logger log = Logger.getLogger(RMIPerformanceClient.class); public static Test suite() { return new ThreadLocalDecorator(RMIPerformanceClient.class, 1); } public void init() { //super.init(); String name = "//" + host + "/RMIServer"; // RMIServer svr = (RMIServer) Naming.lookup(name); try { //Registry regsitry = LocateRegistry.getRegistry("localhost", rmiPort); Registry regsitry = LocateRegistry.getRegistry(rmiPort); Remote remoteObj = regsitry.lookup(name); rmiServer = (RMIServerRemote) remoteObj; } catch(Exception e) { log.error("Error initializating rmi client.", e); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { return null; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock); callbackServer.start(); return callbackServer; } protected void populateMetadata(Map metadata) { super.populateMetadata(metadata); metadata.put("transport", "raw_rmi"); metadata.put("serialization", "java"); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = "raw_rmi" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java"; } } return config; } protected Object makeInvocation(String method, Object param) throws Throwable { if(method.equals(NUM_OF_CALLS)) { return rmiServer.sendNumberOfCalls(clientSessionId, param); } else if(method.equals(TEST_INVOCATION)) { return rmiServer.makeCall(clientSessionId, param); } else { throw new Exception("Was not able to find remote method call for " + method); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIHandl0000644000175000017500000000536410471377750033260 0ustar twernertwerner/* * 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.performance.raw.rmi; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import java.rmi.NotBoundException; import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; /** * @author Tom Elrod */ public class RMIHandler implements InvokerCallbackHandler { private RMICallbackServerRemote callbackServer; public RMIHandler(String host, String sessionId) { int rmiPort = 1099; String name = "//" + sessionId + "/RMICallbackServer"; // RMIServer svr = (RMIServer) Naming.lookup(name); try { Registry regsitry = LocateRegistry.getRegistry(host, rmiPort); Remote remoteObj = regsitry.lookup(name); callbackServer = (RMICallbackServerRemote) remoteObj; } catch(RemoteException e) { e.printStackTrace(); } catch(NotBoundException e) { e.printStackTrace(); } } /** * 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("Need to make call on RMICallbackServer with results. " + callback); try { callbackServer.finishedProcessing(callback); } catch(RemoteException e) { e.printStackTrace(); throw new HandleCallbackException(e.getMessage()); } } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMIServe0000644000175000017500000001046710471377750033316 0ustar twernertwerner/* * 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.performance.raw.rmi; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; import org.jboss.logging.Logger; import org.jboss.test.remoting.performance.synchronous.CallTracker; import org.jboss.test.remoting.performance.synchronous.Payload; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject; import java.util.Map; /** * @author Tom Elrod */ public class RMIServer extends UnicastRemoteObject implements RMIServerRemote { private static final Logger log = Logger.getLogger(RMIServer.class); private Map callTrackers = new ConcurrentHashMap(); private String host = "localhost"; public RMIServer(String host) throws RemoteException { super(); this.host = host; } public Object sendNumberOfCalls(Object obj, Object param) throws RemoteException { System.out.println("sent number of calls " + obj + " " + param); String sessionId = (String) obj; Integer totalCountInteger = (Integer) param; int totalCount = totalCountInteger.intValue(); System.out.println("received totalCallCount call with total count of " + totalCount + " from " + sessionId); CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if(tracker != null) { tracker.createTotalCount(totalCount); } else { RMIHandler callbackHandler = new RMIHandler(host, sessionId); tracker = new CallTracker(sessionId, callbackHandler); callTrackers.put(sessionId, tracker); tracker.createTotalCount(totalCount); } return totalCountInteger; } public Object makeCall(Object obj, Object param) throws RemoteException { Payload payload = (Payload) param; //System.out.println(payload); int clientInvokeCallCount = payload.getCallNumber(); String sessionId = (String) obj; CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if(tracker != null) { tracker.verifyClientInvokeCount(clientInvokeCallCount); } else { log.error("No call tracker exists for session id " + sessionId); throw new RemoteException("No call tracker exists for session id " + sessionId); } // just passing return, even though not needed return new Integer(clientInvokeCallCount); } public void start() { try { // if(System.getSecurityManager() == null) // { // System.setSecurityManager(new RMISecurityManager()); // } int port = 1099; Registry registry = LocateRegistry.createRegistry(port); String name = "//" + host + "/RMIServer"; RMIServerRemote engine = new RMIServer(host); // Naming.rebind(name, engine); registry.rebind(name, this); System.out.println("RMIServer bound"); } catch(Exception e) { System.err.println("RMIServer exception: " + e.getMessage()); e.printStackTrace(); } } public static void main(String[] args) { try { String host = "localhost"; RMIServer server = new RMIServer(host); server.start(); } catch(RemoteException e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMICallbackServerRemote.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/rmi/RMICallb0000644000175000017500000000243210355142433033225 0ustar twernertwerner/* * 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.performance.raw.rmi; import java.rmi.Remote; import java.rmi.RemoteException; /** * @author Tom Elrod */ public interface RMICallbackServerRemote extends Remote { public void finishedProcessing(Object obj) throws RemoteException; }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/readme.txt0000644000175000017500000000267610326214351033133 0ustar twernertwernerThis package contains simple tests of sending invocation requests object (which contain simple string as payload) and returning invocation response object (containing simple string as payload). These tests use different transports and are for comparing the processing time for the remote calls over these transports. This client to server call is repeated 250K times. The package structure defines which transport type. - remoting - java - rmi - socket - jboss - rmi (which is misleading as jboss serialization not working for rmi yet, so really using java serialization). - socket - rmi - socket These tests are not automated, so will have to manually run the server and client classes for each directory. When doing this, results should look somewhat like: JBoss Remoting (rmi & java serialization) - 74116 milliseconds JBoss Remoting (socket & java serialization) - 74888 milliseconds JBoss Remoting (socket & jboss serialization) - 70041 milliseconds RMI - 79064 milliseconds Socket - 82869 milliseconds Note, this is not a real world test of raw vs remoting in the sense that if were using raw transport (rmi or socket) without using JBoss Remoting, would not have to use invocation request/response objects, but just the raw string payload (so would obviously be faster if doing this). These tests are to verify extra overhead of using remoting framework vs the raw alternative, using the exact same object types as payload.libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/0000755000175000017500000000000011632407043032415 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/SocketPerformanceServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Socke0000644000175000017500000000472310473412022033405 0ustar twernertwerner/* * 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.performance.raw.socket; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import java.util.Map; /** * @author Tom Elrod */ public class SocketPerformanceServer extends PerformanceServerTest { private SocketServer server = null; private int numOfClients; public void init(Map metatdata) throws Exception { server = new SocketServer(host, numOfClients); server.setUp(); } public void setUp() throws Exception { String numOfClientsString = System.getProperty(PerformanceTestCase.NUMBER_OF_CLIENTS); if(numOfClientsString != null && numOfClientsString.length() > 0) { try { numOfClients = Integer.parseInt(numOfClientsString); } catch(NumberFormatException e) { e.printStackTrace(); } } super.setUp(); } public void tearDown() throws Exception { super.tearDown(); if(server != null) { server.tearDown(); } } public static void main(String[] args) { PerformanceServerTest test = new SocketPerformanceServer(); try { test.setUp(); Thread.currentThread().sleep(300000); test.tearDown(); //System.exit(0); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/SocketPerformanceClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Socke0000644000175000017500000001257410473415155033422 0ustar twernertwerner/* * 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.performance.raw.socket; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.Socket; import java.rmi.server.UID; import java.util.Map; /** * @author Tom Elrod */ public class SocketPerformanceClient extends PerformanceClientTest { private int port = 7600; private Socket socket = null; private ObjectOutputStream oos; private ObjectInputStream objInputStream; private int timeout = 20000; private String clientSessionId = new UID().toString(); protected static final Logger log = Logger.getLogger(SocketPerformanceClient.class); public static Test suite() { return new ThreadLocalDecorator(SocketPerformanceClient.class, 1); } public void init() { // try // { // getSocket(); // } // catch(IOException e) // { // e.printStackTrace(); // } } protected InvokerLocator initServer(int port) throws Exception { return null; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { SocketCallbackServer callbackServer = new SocketCallbackServer(host, clientSessionId, serverDoneLock); callbackServer.start(); makeInvocation("callbackserver", new Integer(callbackServer.getBindPort())); return callbackServer; } protected void populateMetadata(Map metadata) { super.populateMetadata(metadata); metadata.put("transport", "raw_socket"); metadata.put("serialization", "java"); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = "raw_socket" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java"; } } return config; } protected Object makeInvocation(String method, Object param) throws Throwable { // Socket socket = new Socket(address, port); // socket.setSoTimeout(timeout); // BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream()); // BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); // // ObjectOutputStream oos = new ObjectOutputStream(out); // ObjectInputStream objInputStream = new ObjectInputStream(in); getSocket(); SocketPayload payload = new SocketPayload(method, clientSessionId, param); oos.writeObject(payload); oos.reset(); oos.writeObject(Boolean.TRUE); oos.flush(); oos.reset(); Object obj = objInputStream.readObject(); objInputStream.readObject(); // objInputStream.close(); // oos.close(); // socket.close(); return obj; } private void getSocket() throws IOException { if(socket == null) { try { socket = new Socket(host, port); socket.setSoTimeout(timeout); BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream()); BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); oos = new ObjectOutputStream(out); objInputStream = new ObjectInputStream(in); } catch(IOException e) { e.printStackTrace(); throw e; } } else { oos.reset(); oos.writeByte(1); oos.flush(); oos.reset(); objInputStream.readByte(); } } public static void main(String[] args) { SocketPerformanceClient test = new SocketPerformanceClient(); try { test.setUp(); test.testClientCalls(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } }././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/SocketPerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Socke0000644000175000017500000002130510473412022033400 0ustar twernertwerner/* * 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.performance.raw.socket; import org.apache.log4j.Level; import org.jboss.jrunit.harness.BenchmarkTestDriver; import java.io.IOException; /** * @author Tom Elrod */ public class SocketPerformanceTestCase extends BenchmarkTestDriver //TestDriver { protected int numberOfClients = 1; public static final String REMOTING_TRANSPORT = "remoting.transport"; public static final String REMOTING_METADATA = "remoting.metadata"; public static final String REMOTING_SERIALIZATION = "remoting.serialization"; public static final String PAYLOAD_SIZE = "remoting.payload.size"; public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients"; public static final String NUMBER_OF_CALLS = "remoting.number_of_calls"; public static final String JVM_MAX_HEAP_SIZE = "jvm.mx"; public static final String RESULT_TIMEOUT = "jrunit.result_timeout"; public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout"; public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout"; public static final String REMOTING_HOST = "remoting.host"; public void declareTestClasses() { //**************** LOGGING *********************** 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.SimpleLayout layout = new org.apache.log4j.SimpleLayout(); try { org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log"); fileAppender.setThreshold(Level.DEBUG); fileAppender.setAppend(false); org.apache.log4j.Category.getRoot().addAppender(fileAppender); } catch(IOException e) { e.printStackTrace(); } //*************** END LOGGING *********************** String numOfClients = System.getProperty(NUMBER_OF_CLIENTS); if(numOfClients != null && numOfClients.length() > 0) { try { numberOfClients = Integer.parseInt(numOfClients); } catch(NumberFormatException e) { e.printStackTrace(); } } addTestClasses(getClientTestClass(), numberOfClients, SocketPerformanceServer.class.getName()); } protected String getClientTestClass() { return SocketPerformanceClient.class.getName(); } protected Level getTestHarnessLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * The log level to run as for the test case. * * @return */ protected Level getTestLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness). * The default value is null. * * @return */ protected String getClientJVMArguments() { return getJVMArguments(); // String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 "; // args = args + getJVMArguments(); // return args; } /** * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness). * The default value is null. * * @return */ protected String getServerJVMArguments() { return getJVMArguments(); } /** * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness). * The default value is null. * * @return */ private String getJVMArguments() { String vmArgs = ""; String transport = System.getProperty(REMOTING_TRANSPORT); if(transport != null && transport.length() > 0) { vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport; } String host = System.getProperty(REMOTING_HOST); if(host != null && host.length() > 0) { vmArgs = "-D" + REMOTING_HOST + "=" + host; } String serialization = System.getProperty(REMOTING_SERIALIZATION); if(serialization != null && serialization.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization; } String metadata = System.getProperty(REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata; } String payloadSize = System.getProperty(PAYLOAD_SIZE); if(payloadSize != null && payloadSize.length() > 0) { vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize; } String numOfCalls = System.getProperty(NUMBER_OF_CALLS); if(numOfCalls != null && numOfCalls.length() > 0) { vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls; } String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE); if(jvmMx != null && jvmMx.length() > 0) { vmArgs = vmArgs + " -Xmx" + jvmMx + "m"; } String numOfClients = System.getProperty(NUMBER_OF_CLIENTS); if(numOfClients != null && numOfClients.length() > 0) { try { numberOfClients = Integer.parseInt(numOfClients); vmArgs = vmArgs + " -D" + NUMBER_OF_CLIENTS + "=" + numberOfClients; } catch(NumberFormatException e) { e.printStackTrace(); } } return vmArgs; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(RESULT_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(TEAR_DOWN_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(RUN_TEST_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/MultiThreadedSocketPerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Multi0000644000175000017500000000246110355142433033435 0ustar twernertwerner/* * 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.performance.raw.socket; /** * @author Tom Elrod */ public class MultiThreadedSocketPerformanceTestCase extends SocketPerformanceTestCase { protected String getClientTestClass() { return MultiThreadedSocketPerformanceClient.class.getName(); } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/SocketHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Socke0000644000175000017500000000566610471377750033434 0ustar twernertwerner/* * 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.performance.raw.socket; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.Socket; /** * @author Tom Elrod */ public class SocketHandler implements InvokerCallbackHandler { private String serverBindAddress = "localhost"; private int serverBindPort = 6710; private String sessionId; public SocketHandler(String host, String sessionId, int callbackServerPort) { this.serverBindAddress = host; this.sessionId = sessionId; this.serverBindPort = callbackServerPort; } public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("Need to make call on SocketCallbackServer with results. " + callback); try { System.out.println("Making callback call to " + serverBindPort); Socket socket = new Socket(serverBindAddress, serverBindPort); BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream()); BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); ObjectOutputStream oos = new ObjectOutputStream(out); ObjectInputStream objInputStream = new ObjectInputStream(in); oos.writeObject(callback); oos.reset(); oos.writeObject(Boolean.TRUE); oos.flush(); oos.reset(); Object obj = objInputStream.readObject(); objInputStream.readObject(); } catch(IOException e) { e.printStackTrace(); throw new HandleCallbackException(e.getMessage(), e); } catch(ClassNotFoundException e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/SocketPayload.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Socke0000644000175000017500000000321410355142433033404 0ustar twernertwerner/* * 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.performance.raw.socket; import java.io.Serializable; /** * @author Tom Elrod */ public class SocketPayload implements Serializable { private String method = null; private String sessionId = null; private Object payload = null; public SocketPayload(String method, String sessionId, Object payload) { this.method = method; this.sessionId = sessionId; this.payload = payload; } public String getMethod() { return method; } public String getSessionId() { return sessionId; } public Object getPayload() { return payload; } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/SocketCallbackServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Socke0000644000175000017500000001313510471377750033422 0ustar twernertwerner/* * 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.performance.raw.socket; import EDU.oswego.cs.dl.util.concurrent.Latch; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; /** * @author Tom Elrod */ public class SocketCallbackServer implements PerformanceCallbackKeeper { private String serverBindAddress = "localhost"; private int serverBindPort = 6710; private InetAddress bindAddress; private ServerSocket serverSocket; private int backlog = 2; private String sessionId; private Latch lock; private int numberOfCallsProcessed = 0; private int numberofDuplicates = 0; public SocketCallbackServer(String host, String sessionId, Latch lock) { this.serverBindAddress = host; this.sessionId = sessionId; this.lock = lock; } public int getNumberOfCallsProcessed() { return numberOfCallsProcessed; } public int getNumberOfDuplicates() { return numberofDuplicates; } public int getBindPort() { return serverBindPort; } public void start() throws Exception { calculateBindPort(); bindAddress = InetAddress.getByName(serverBindAddress); serverSocket = new ServerSocket(serverBindPort, backlog, bindAddress); System.out.println("started SocketCallbackServer on port " + serverBindPort); // this was done inline since TestCase already has a void parameter run() method // so could not create a run() method for the Runnable implementation. for(int x = 0; x < 1; x++) { new Thread() { public void run() { try { startServer(); } catch(Exception e) { e.printStackTrace(); } } }.start(); } } private void calculateBindPort() { serverBindPort = TestUtil.getRandomPort(); } private void startServer() { try { Socket socket = serverSocket.accept(); BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream()); BufferedInputStream bis = new BufferedInputStream(socket.getInputStream()); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.flush(); ObjectInputStream objInputStream = new ObjectInputStream(bis); processRequest(objInputStream, oos); } catch(Exception e) { e.printStackTrace(); } } private void processRequest(ObjectInputStream objInputStream, ObjectOutputStream oos) throws IOException, ClassNotFoundException, HandleCallbackException { System.out.println("SocketCallbackServer::procesRequest() called " + serverBindPort); Object obj = objInputStream.readObject(); try { objInputStream.readObject(); oos.writeObject(Boolean.TRUE); oos.reset(); oos.writeObject(Boolean.TRUE); oos.flush(); oos.reset(); } catch(IOException e) { e.printStackTrace(); } catch(ClassNotFoundException e) { e.printStackTrace(); } Callback callback = (Callback) obj; handleCallback(callback); } public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("SocketCallbackServer::handleCallback() called " + serverBindPort); Object ret = callback.getCallbackObject(); Integer[] handledArray = (Integer[]) ret; Integer numOfCallsHandled = (Integer) handledArray[0]; Integer numOfDuplicates = (Integer) handledArray[1]; System.out.println("Server is done. Number of calls handled: " + numOfCallsHandled); numberOfCallsProcessed = numOfCallsHandled.intValue(); System.out.println("Number of duplicate calls: " + numOfDuplicates); numberofDuplicates = numOfDuplicates.intValue(); Object obj = callback.getCallbackHandleObject(); //String handbackObj = (String) obj; //System.out.println("Handback object should be " + sessionId + " and server called back with " + handbackObj); lock.release(); System.out.println("SocketCallbackServer - released lock " + serverBindPort); } }././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/MultiThreadedSocketPerformanceClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Multi0000644000175000017500000001325210476467055033453 0ustar twernertwerner/* * 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.performance.raw.socket; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.MultiThreadedPerformanceClientTest; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.Socket; import java.rmi.server.UID; import java.util.Map; /** * @author Tom Elrod */ public class MultiThreadedSocketPerformanceClient extends MultiThreadedPerformanceClientTest { private int port = 7600; private Socket socket = null; private ObjectOutputStream oos; private ObjectInputStream objInputStream; private int timeout = 20000; private String clientSessionId = new UID().toString(); protected static final Logger log = Logger.getLogger(MultiThreadedSocketPerformanceClient.class); public static Test suite() { return new ThreadLocalDecorator(MultiThreadedSocketPerformanceClient.class, 1); } public void init() { // try // { // getSocket(); // } // catch(IOException e) // { // e.printStackTrace(); // } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { return null; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { SocketCallbackServer callbackServer = new SocketCallbackServer(host, clientSessionId, serverDoneLock); callbackServer.start(); makeInvocation("callbackserver", new Integer(callbackServer.getBindPort())); return callbackServer; } protected void populateMetadata(Map metadata) { super.populateMetadata(metadata); metadata.put("transport", "raw_socket"); metadata.put("serialization", "java"); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = "raw_socket" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java"; } } return config; } protected Object makeInvocation(String method, Object param) throws Throwable { Object obj = null; synchronized(host) { // Socket socket = new Socket(address, port); // socket.setSoTimeout(timeout); // BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream()); // BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); // // ObjectOutputStream oos = new ObjectOutputStream(out); // ObjectInputStream objInputStream = new ObjectInputStream(in); getSocket(); SocketPayload payload = new SocketPayload(method, clientSessionId, param); oos.writeObject(payload); oos.reset(); oos.writeObject(Boolean.TRUE); oos.flush(); oos.reset(); obj = objInputStream.readObject(); objInputStream.readObject(); // objInputStream.close(); // oos.close(); // socket.close(); } return obj; } private void getSocket() throws IOException { if(socket == null) { try { socket = new Socket(host, port); socket.setSoTimeout(timeout); BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream()); BufferedInputStream in = new BufferedInputStream(socket.getInputStream()); oos = new ObjectOutputStream(out); objInputStream = new ObjectInputStream(in); } catch(IOException e) { e.printStackTrace(); throw e; } } else { oos.reset(); oos.writeByte(1); oos.flush(); oos.reset(); objInputStream.readByte(); } } public static void main(String[] args) { MultiThreadedSocketPerformanceClient test = new MultiThreadedSocketPerformanceClient(); try { test.setUp(); test.testClientCalls(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/SocketServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/raw/socket/Socke0000644000175000017500000002201610476462020033406 0ustar twernertwerner/* * 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.performance.raw.socket; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; import org.jboss.logging.Logger; import org.jboss.test.remoting.performance.synchronous.CallTracker; import org.jboss.test.remoting.performance.synchronous.Payload; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.EOFException; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.util.Map; /** * @author Tom Elrod */ public class SocketServer { private int serverBindPort = 7600; private int backlog = 200; private ServerSocket serverSocket; private InetAddress bindAddress; private String serverBindAddress = "localhost"; private int timeout = 20000; private int serverReadThreads; private ThreadLocal callbackServerPort = new ThreadLocal(); private boolean continueToRun = true; // flag to keep the server listening // private int requestCounter = 0; private Map callTrackers = new ConcurrentHashMap(); private static final Logger log = Logger.getLogger(SocketServer.class); public SocketServer(String host, int numOfClients) { serverBindAddress = host; serverReadThreads = numOfClients; } protected void setUp() throws Exception { System.out.println("SimpleServerTest::setUp() called."); // org.apache.log4j.Category.getRoot().info("SimpleServerTest::setUp() called."); bindAddress = InetAddress.getByName(serverBindAddress); System.out.println("Starting ServerSocket on " + serverBindPort + ", " + serverBindAddress); serverSocket = new ServerSocket(serverBindPort, backlog, bindAddress); // this was done inline since TestCase already has a void parameter run() method // so could not create a run() method for the Runnable implementation. for(int x = 0; x < serverReadThreads; x++) { new Thread() { public void run() { try { startServer(); } catch(Exception e) { e.printStackTrace(); } } }.start(); } } private void startServer() { try { Socket socket = serverSocket.accept(); socket.setSoTimeout(timeout); BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream()); BufferedInputStream bis = new BufferedInputStream(socket.getInputStream()); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.flush(); ObjectInputStream objInputStream = new ObjectInputStream(bis); processRequest(objInputStream, oos); // objInputStream.close(); // oos.close(); // socket.close(); while(continueToRun) { acknowledge(objInputStream, oos); processRequest(objInputStream, oos); } } catch (EOFException e) { log.debug(e); } catch(Exception e) { e.printStackTrace(); // org.apache.log4j.Category.getRoot().debug("Done processing on client socket."); } System.out.println("Done processing on client socket."); } private void processRequest(ObjectInputStream objInputStream, ObjectOutputStream oos) throws Exception { Object obj = objInputStream.readObject(); objInputStream.readObject(); SocketPayload payload = (SocketPayload) obj; Object response = processPayload(payload); Thread.interrupted(); // clear interrupted state so we don't fail on socket writes oos.writeObject(response); oos.reset(); oos.writeObject(Boolean.TRUE); oos.flush(); oos.reset(); // ++requestCounter; } private Object processPayload(SocketPayload payload) throws Exception { String method = payload.getMethod(); String sessionId = payload.getSessionId(); Object param = payload.getPayload(); if(PerformanceClientTest.NUM_OF_CALLS.equals(method)) { Integer totalCountInteger = (Integer) param; int totalCount = totalCountInteger.intValue(); System.out.println("received totalCallCount call with total count of " + totalCount + " from " + sessionId); CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if(tracker != null) { tracker.createTotalCount(totalCount); } else { int port = ((Integer)callbackServerPort.get()).intValue(); SocketHandler callbackHandler = new SocketHandler(serverBindAddress, sessionId, port); tracker = new CallTracker(sessionId, callbackHandler); callTrackers.put(sessionId, tracker); tracker.createTotalCount(totalCount); } return totalCountInteger; } else if(PerformanceClientTest.TEST_INVOCATION.equals(method)) { Payload clientPayload = (Payload) param; int clientInvokerCallCount = clientPayload.getCallNumber(); CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if(tracker != null) { tracker.verifyClientInvokeCount(clientInvokerCallCount); } else { log.error("No call tracker exists for session id " + sessionId); throw new Exception("No call tracker exists for session id " + sessionId); } return new Integer(clientInvokerCallCount); } else if("callbackserver".equals(method)) { // callbackServerPort = ((Integer) param).intValue(); callbackServerPort.set(param); return null; } else { throw new Exception("Can not process for method " + method); } } private void acknowledge(ObjectInputStream objInputStream, ObjectOutputStream oos) throws IOException { byte ACK = objInputStream.readByte(); oos.writeByte(ACK); oos.flush(); oos.reset(); } public void testRequestCount() { while(continueToRun) { try { Thread.currentThread().sleep(10000); } catch(InterruptedException e) { e.printStackTrace(); } // System.out.println("Requests taken: " + requestCounter); // org.apache.log4j.Category.getRoot().info("SimpleServerTest::testRequestCount() - Requests taken: " + requestCounter); } // org.apache.log4j.Category.getRoot().info("SimpleServerTest::testRequestCount() - Total request taken: " + requestCounter); } protected void tearDown() throws Exception { continueToRun = false; // System.out.println("Tearing down. Processed " + requestCounter + " requests"); // org.apache.log4j.Category.getRoot().info("Tearing down. Processed " + requestCounter + " requests"); if(serverSocket != null && !serverSocket.isClosed()) { serverSocket.close(); serverSocket = null; } } public static void main(String[] args) { int numOfClients = 1; String numOfClientsString = System.getProperty(PerformanceTestCase.NUMBER_OF_CLIENTS); if(numOfClientsString != null && numOfClientsString.length() > 0) { try { numOfClients = Integer.parseInt(numOfClientsString); } catch(NumberFormatException e) { e.printStackTrace(); } } String serverBindAddress = "localhost"; SocketServer server = new SocketServer(serverBindAddress, numOfClients); try { server.setUp(); server.testRequestCount(); } catch(Exception e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/0000755000175000017500000000000011632407042031635 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/0000755000175000017500000000000011632407042032424 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000577410475157645033476 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.springframework.remoting.rmi.RmiProxyFactoryBean; /** * @author Tom Elrod */ public class SpringRMIHandler implements InvokerCallbackHandler { private SpringRMICallbackServer springRMICallbackServer; private String sessionId; public SpringRMIHandler(String sessionId) { this.sessionId = sessionId; } public void start() { // Resource res = new ClassPathResource("SpringRMICallbackServerService.xml", SpringRMIHandler.class); // BeanFactory factory = new XmlBeanFactory(res); // springRMICallbackServer = (SpringRMICallbackServer)factory.getBean("springRMICallbackServerService:" ); /* Instead of creating callback server proxies by injection, the following xml declaration is replaced by programmatic creation. Each callback server is registered under a name ending in the sessionId. */ RmiProxyFactoryBean factory = new RmiProxyFactoryBean(); factory.setServiceUrl("rmi://localhost:1299/SpringRMICallbackServerService:" + sessionId); factory.setServiceInterface(org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer.class); try { factory.afterPropertiesSet(); } catch (Exception e) { System.out.println("unable to create callback proxy"); System.out.println(e); } springRMICallbackServer = (SpringRMICallbackServer)factory.getObject(); } public SpringRMICallbackServer getSpringRMICallbackServer() { return springRMICallbackServer; } public void setSpringRMICallbackServer(SpringRMICallbackServer springRMICallbackServer) { this.springRMICallbackServer = springRMICallbackServer; } public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("Need to make call on SpringRMICallbackServer with results. " + callback); try { springRMICallbackServer.finishedProcessing(callback); } catch(Exception e) { e.printStackTrace(); throw new HandleCallbackException(e.getMessage()); } } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000113310467676676033472 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; /** * @author Tom Elrod */ public interface SpringRMIServer { public Object makeCall(Object obj, Object param); public Object sendNumberOfCalls(Object obj, Object param); }././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/MultiThreadedSpringRMIPerformanceClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Multi0000644000175000017500000001544010476466071033461 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.MultiThreadedPerformanceClientTest; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.remoting.rmi.RmiServiceExporter; import java.rmi.server.UID; import java.util.Map; /** * @author Tom Elrod */ public class MultiThreadedSpringRMIPerformanceClient extends MultiThreadedPerformanceClientTest { private SpringRMIServer springRMIServerService; private String clientSessionId = new UID().toString(); protected static final Logger log = Logger.getLogger(MultiThreadedSpringRMIPerformanceClient.class); public static Test suite() { return new ThreadLocalDecorator(MultiThreadedSpringRMIPerformanceClient.class, 1); } public SpringRMIServer getSpringRMIServerService() { return springRMIServerService; } public void setSpringRMIServerService(SpringRMIServer springRMIServerService) { this.springRMIServerService = springRMIServerService; } public void init() { Resource res = new ClassPathResource("SpringRMIClientService.xml", SpringRMIPerformanceClient.class); BeanFactory factory = new XmlBeanFactory(res); springRMIServerService = (SpringRMIServer)factory.getBean("springRMIServerService"); /* //super.init(); String name = "//localhost/RMIServer"; // RMIServer svr = (RMIServer) Naming.lookup(name); try { //Registry regsitry = LocateRegistry.getRegistry("localhost", rmiPort); Registry regsitry = LocateRegistry.getRegistry(rmiPort); Remote remoteObj = regsitry.lookup(name); rmiServer = (RMIServerRemote) remoteObj; } catch(Exception e) { log.error("Error initializating rmi client.", e); } */ } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { return null; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { String springServiceXml = this.getClass().getResource("SpringRMIClientService.xml").getFile(); // ApplicationContext context = new FileSystemXmlApplicationContext(springServiceXml); ApplicationContext context = null; for (int i = 0; i < 10; i++) { try { context = new FileSystemXmlApplicationContext(springServiceXml); if (context != null) break; } catch (Exception e) { Thread.sleep(2000); } } SpringRMICallbackServer callbackServer = (SpringRMICallbackServer) context.getBean("springRMICallbackServerService"); callbackServer.setClientSessionId(clientSessionId); callbackServer.setServerDoneLock(serverDoneLock); /* Instead of exporting callback servers by injection, the following xml declaration is carried out programmatically. Each callback server is registered under a name ending in the sessionId. */ for (int i = 0; i < 10; i++) { try { RmiServiceExporter exporter = new RmiServiceExporter(); exporter.setServiceName("SpringRMICallbackServerService:" + clientSessionId); exporter.setService(callbackServer); exporter.setServiceInterface(org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer.class); exporter.setRegistryPort(1299); exporter.afterPropertiesSet(); log.info("exported SpringRMICallbackServerService:" + clientSessionId); break; } catch (Exception e) { Thread.sleep(2000); } } return callbackServer; // RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock); // callbackServer.start(); // return callbackServer; } protected void populateMetadata(Map metadata) { super.populateMetadata(metadata); metadata.put("transport", "spring_rmi"); metadata.put("serialization", "java"); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = "spring_rmi" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java"; } } return config; } protected Object makeInvocation(String method, Object param) throws Throwable { if(method.equals(NUM_OF_CALLS)) { return springRMIServerService.sendNumberOfCalls(clientSessionId, param); } else if(method.equals(TEST_INVOCATION)) { return springRMIServerService.makeCall(clientSessionId, param); } else { throw new Exception("Was not able to find remote method call for " + method); } } public static void main(String[] args) { MultiThreadedPerformanceClientTest test = new MultiThreadedSpringRMIPerformanceClient(); try { test.setUp(); test.testClientCalls(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIServerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000440310475161475033456 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; import org.jboss.test.remoting.performance.synchronous.CallTracker; import org.jboss.test.remoting.performance.synchronous.Payload; import java.util.Map; /** * @author Tom Elrod */ public class SpringRMIServerImpl implements SpringRMIServer { private Map callTrackers = new ConcurrentHashMap(); public Object sendNumberOfCalls(Object obj, Object param) { System.out.println("sent number of calls " + obj + " " + param); String sessionId = (String) obj; Integer totalCountInteger = (Integer) param; int totalCount = totalCountInteger.intValue(); System.out.println("received totalCallCount call with total count of " + totalCount + " from " + sessionId); CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if (tracker != null) { tracker.createTotalCount(totalCount); } else { SpringRMIHandler callbackHandler = new SpringRMIHandler(sessionId); callbackHandler.start(); tracker = new CallTracker(sessionId, callbackHandler); callTrackers.put(sessionId, tracker); tracker.createTotalCount(totalCount); } return totalCountInteger; } public Object makeCall(Object obj, Object param) { Payload payload = (Payload) param; int clientInvokeCallCount = payload.getCallNumber(); String sessionId = (String) obj; CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if (tracker != null) { tracker.verifyClientInvokeCount(clientInvokeCallCount); } else { System.err.println("No call tracker exists for session id " + sessionId); throw new RuntimeException("No call tracker exists for session id " + sessionId); } return new Integer(clientInvokeCallCount); } }././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMICallbackServerService.xml.savelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000141710475161610033447 0ustar twernertwerner ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMICallbackServerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000466610467676676033510 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; import EDU.oswego.cs.dl.util.concurrent.Latch; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; /** * @author Tom Elrod */ public class SpringRMICallbackServerImpl implements SpringRMICallbackServer { private String sessionId; private Latch lock; private int numberOfCallsProcessed = 0; private int numberOfDuplicates = 0; // public SpringRMICallbackServerImpl(String sessionId, Latch lock) // { // this.sessionId = sessionId; // this.lock = lock; // } public void finishedProcessing(Object obj) { System.out.println("finishedProcessing called with " + obj); Callback callback = (Callback)obj; try { handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } public void setClientSessionId(String clientSessionId) { this.sessionId = clientSessionId; } public void setServerDoneLock(Latch serverDoneLock) { this.lock = serverDoneLock; } public int getNumberOfCallsProcessed() { return numberOfCallsProcessed; } public int getNumberOfDuplicates() { return numberOfDuplicates; } public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); Integer[] handledArray = (Integer[])ret; Integer numOfCallsHandled = (Integer) handledArray[0]; Integer numOfDuplicates = (Integer) handledArray[1]; System.out.println("Server is done. Number of calls handled: " + numOfCallsHandled); numberOfCallsProcessed = numOfCallsHandled.intValue(); System.out.println("Number of duplicate calls: " + numOfDuplicates); numberOfDuplicates = numOfDuplicates.intValue(); Object obj = callback.getCallbackHandleObject(); //String handbackObj = (String) obj; //System.out.println("Handback object should be " + sessionId + " and server called back with " + handbackObj); lock.release(); } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIPerformanceServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000260010474740306033446 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import java.util.Map; /** * @author Tom Elrod */ public class SpringRMIPerformanceServer extends PerformanceServerTest { public void init(Map metadata) { String springServiceXml = this.getClass().getResource("SpringRMIServerService.xml").getFile(); ApplicationContext context = new FileSystemXmlApplicationContext(springServiceXml); SpringRMIServer server = (SpringRMIServer) context.getBean("springRMIServerService"); } public static void main(String[] args) { PerformanceServerTest server = new SpringRMIPerformanceServer(); try { server.setUp(); Thread.currentThread().sleep(3600000); server.tearDown(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIPerformanceClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000001516510475447472033471 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.remoting.rmi.RmiServiceExporter; import java.rmi.server.UID; import java.util.Map; /** * @author Tom Elrod */ public class SpringRMIPerformanceClient extends PerformanceClientTest { private SpringRMIServer springRMIServerService; private String clientSessionId = new UID().toString(); protected static final Logger log = Logger.getLogger(SpringRMIPerformanceClient.class); public static Test suite() { return new ThreadLocalDecorator(SpringRMIPerformanceClient.class, 1); } public SpringRMIServer getSpringRMIServerService() { return springRMIServerService; } public void setSpringRMIServerService(SpringRMIServer springRMIServerService) { this.springRMIServerService = springRMIServerService; } public void init() { Resource res = new ClassPathResource("SpringRMIClientService.xml", SpringRMIPerformanceClient.class); BeanFactory factory = new XmlBeanFactory(res); springRMIServerService = (SpringRMIServer)factory.getBean("springRMIServerService"); /* //super.init(); String name = "//localhost/RMIServer"; // RMIServer svr = (RMIServer) Naming.lookup(name); try { //Registry regsitry = LocateRegistry.getRegistry("localhost", rmiPort); Registry regsitry = LocateRegistry.getRegistry(rmiPort); Remote remoteObj = regsitry.lookup(name); rmiServer = (RMIServerRemote) remoteObj; } catch(Exception e) { log.error("Error initializating rmi client.", e); } */ } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { return null; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { String springServiceXml = this.getClass().getResource("SpringRMIClientService.xml").getFile(); ApplicationContext context = null; for (int i = 0; i < 10; i++) { try { context = new FileSystemXmlApplicationContext(springServiceXml); if (context != null) break; } catch (Exception e) { Thread.sleep(2000); } } SpringRMICallbackServer callbackServer = (SpringRMICallbackServer) context.getBean("springRMICallbackServerService"); callbackServer.setClientSessionId(clientSessionId); callbackServer.setServerDoneLock(serverDoneLock); /* Instead of exporting callback servers by injection, the following xml declaration is carried out programmatically. Each callback server is registered under a name ending in the sessionId. */ for (int i = 0; i < 10; i++) { try { RmiServiceExporter exporter = new RmiServiceExporter(); exporter.setServiceName("SpringRMICallbackServerService:" + clientSessionId); exporter.setService(callbackServer); exporter.setServiceInterface(org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer.class); exporter.setRegistryPort(1299); exporter.afterPropertiesSet(); log.info("exported SpringRMICallbackServerService:" + clientSessionId); break; } catch (Exception e) { Thread.sleep(2000); } } return callbackServer; // RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock); // callbackServer.start(); // return callbackServer; } protected void populateMetadata(Map metadata) { super.populateMetadata(metadata); metadata.put("transport", "spring_rmi"); metadata.put("serialization", "java"); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = "spring_rmi" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java"; } } return config; } protected Object makeInvocation(String method, Object param) throws Throwable { if(method.equals(NUM_OF_CALLS)) { return springRMIServerService.sendNumberOfCalls(clientSessionId, param); } else if(method.equals(TEST_INVOCATION)) { return springRMIServerService.makeCall(clientSessionId, param); } else { throw new Exception("Was not able to find remote method call for " + method); } } public static void main(String[] args) { SpringRMIPerformanceClient test = new SpringRMIPerformanceClient(); try { test.setUp(); test.testClientCalls(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } }././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/MultiThreadedSpringRMIPerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Multi0000644000175000017500000000126410467676676033476 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; /** * @author Tom Elrod */ public class MultiThreadedSpringRMIPerformanceTestCase extends SpringRMIPerformanceTestCase { protected String getClientTestClass() { return MultiThreadedSpringRMIPerformanceClient.class.getName(); } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMICallbackServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000157410467676676033503 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; import EDU.oswego.cs.dl.util.concurrent.Latch; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; /** * @author Tom Elrod */ public interface SpringRMICallbackServer extends PerformanceCallbackKeeper, InvokerCallbackHandler { public void finishedProcessing(Object obj); void setClientSessionId(String clientSessionId); void setServerDoneLock(Latch serverDoneLock); }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIClientService.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000250410475162066033453 0ustar twernertwerner ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIServerService.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000000132710474740121033446 0ustar twernertwerner ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/SpringRMIPerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/rmi/Sprin0000644000175000017500000001742110474740536033462 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.rmi; import org.apache.log4j.Level; import org.jboss.jrunit.harness.BenchmarkTestDriver; import org.jboss.logging.Logger; import java.io.IOException; /** * @author Tom Elrod */ public class SpringRMIPerformanceTestCase extends BenchmarkTestDriver { protected int numberOfClients = 1; public static final String REMOTING_TRANSPORT = "remoting.transport"; public static final String REMOTING_METADATA = "remoting.metadata"; public static final String REMOTING_SERIALIZATION = "remoting.serialization"; public static final String PAYLOAD_SIZE = "remoting.payload.size"; public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients"; public static final String NUMBER_OF_CALLS = "remoting.number_of_calls"; public static final String JVM_MAX_HEAP_SIZE = "jvm.mx"; public static final String RESULT_TIMEOUT = "jrunit.result_timeout"; public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout"; public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout"; public static final String REMOTING_HOST = "remoting.host"; private static Logger log = Logger.getLogger(SpringRMIPerformanceTestCase.class); public void declareTestClasses() { //**************** LOGGING *********************** 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.SimpleLayout layout = new org.apache.log4j.SimpleLayout(); try { org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log"); fileAppender.setThreshold(Level.DEBUG); fileAppender.setAppend(false); org.apache.log4j.Category.getRoot().addAppender(fileAppender); } catch(IOException e) { e.printStackTrace(); } //*************** END LOGGING *********************** String numOfClients = System.getProperty(NUMBER_OF_CLIENTS); if(numOfClients != null && numOfClients.length() > 0) { try { numberOfClients = Integer.parseInt(numOfClients); } catch(NumberFormatException e) { e.printStackTrace(); } } addTestClasses(getClientTestClass(), numberOfClients, SpringRMIPerformanceServer.class.getName()); } protected String getClientTestClass() { return SpringRMIPerformanceClient.class.getName(); } protected Level getTestHarnessLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * The log level to run as for the test case. * * @return */ protected Level getTestLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness). * The default value is null. * * @return */ protected String getClientJVMArguments() { return getJVMArguments(); // String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 "; // args = args + getJVMArguments(); // return args; } /** * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness). * The default value is null. * * @return */ protected String getServerJVMArguments() { return getJVMArguments(); } /** * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness). * The default value is null. * * @return */ private String getJVMArguments() { String vmArgs = ""; String transport = System.getProperty(REMOTING_TRANSPORT); if(transport != null && transport.length() > 0) { vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport; } String host = System.getProperty(REMOTING_HOST); if(host != null && host.length() > 0) { vmArgs = "-D" + REMOTING_HOST + "=" + host; } String serialization = System.getProperty(REMOTING_SERIALIZATION); if(serialization != null && serialization.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization; } String metadata = System.getProperty(REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata; } String payloadSize = System.getProperty(PAYLOAD_SIZE); if(payloadSize != null && payloadSize.length() > 0) { vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize; } String numOfCalls = System.getProperty(NUMBER_OF_CALLS); if(numOfCalls != null && numOfCalls.length() > 0) { vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls; } String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE); if(jvmMx != null && jvmMx.length() > 0) { vmArgs = vmArgs + " -Xmx" + jvmMx + "m"; } log.info(vmArgs); return vmArgs; } /** * 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() { long defaultTimeout = 6000000; // default to 100 minutes String timeout = System.getProperty(RESULT_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 6000000; // default to 100 minutes String timeout = System.getProperty(TEAR_DOWN_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 6000000; // default to 100 minutes String timeout = System.getProperty(RUN_TEST_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/0000755000175000017500000000000011632407042032614 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/read0000644000175000017500000000411510477160436033464 0ustar twernertwernerThis text covers how to run the spring http performance benchmark test. This test can not be run automatically within remoting testsuite since requires deploying a web app. So in order to run this test, will have to do it manually. First step is to get a web container to deploy within. Any web container will do, but I have been using Tomcat 5.5.17. Am also using Spring framework 1.2.8. Steps to run tests: 1. Run remoting build with tests.jars target. This will build the jboss-remoting.jar and jboss-remoting-tests.jar that will be needed within web deployment file. 2. Create web deployment file. This currently has to be done manually. Create new directory and copy src/tests/org/jboss/test/remoting/performance/spring/http/web/WEB-INF into this new directory. Should then have WEB-INF directory with contents applicationContext.xml, remoting-servlet.xml, and web.xml under root directory. Now create a lib directory under the WEB-INF directory. Copy the jboss-remoting.jar and jboss-remoting-tests.jar into the lib directory. Also copy all the jars under the remoting project's lib/spring directory into this new lib directory. Will also need to copy /lib/oswego-concurrent/lib/concurrent.jar into the lib directory. Now zip up the WEB-INF directory into a file called remoting.war. This will be the web deployment file. Its contents should be: remoting.war - WEB-INF - applicationContext.xml - remoting-servlet.xml - web.xml - lib - concurrent.jar - jboss-remoting-tests.jar - jboss-remoting.jar - spring-aop.jar - spring-beans.jar - spring-context.jar - spring-core.jar - spring-remoting.jar - spring-web.jar - spring-webmvc.jar - spring.jar 3. Deploy remoting.war to web container (i.e. copy to apache-tomcat-5.5.17\webapps directory). 4. Start web container (i.e. apache-tomcat-5.5.17\bin\startup.bat/sh) 5. Run the benchmark client. This can be done by running ant target "tests.performance.sequence.spring_http". The following system properties are used: - perf.seq.numofclients - perf.seq.numofcalls - perf.seq.payloadsize ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/client/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/clie0000755000175000017500000000000011632407042033451 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/client/SpringHttpCallbackServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/clie0000644000175000017500000000160610470171753033464 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.http.client; import EDU.oswego.cs.dl.util.concurrent.Latch; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; /** * @author Tom Elrod */ public interface SpringHttpCallbackServer extends PerformanceCallbackKeeper, InvokerCallbackHandler { public void finishedProcessing(Object obj); void setClientSessionId(String clientSessionId); void setServerDoneLock(Latch serverDoneLock); } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/client/SpringHttpCallbackServerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/clie0000644000175000017500000000445610470171753033472 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.http.client; import EDU.oswego.cs.dl.util.concurrent.Latch; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; /** * @author Tom Elrod */ public class SpringHttpCallbackServerImpl implements SpringHttpCallbackServer { private String sessionId; private Latch lock; private int numberOfCallsProcessed = 0; private int numberOfDuplicates = 0; public void finishedProcessing(Object obj) { System.out.println("finishedProcessing called with " + obj); Callback callback = (Callback)obj; try { handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } public void setClientSessionId(String clientSessionId) { this.sessionId = clientSessionId; } public void setServerDoneLock(Latch serverDoneLock) { this.lock = serverDoneLock; } public int getNumberOfCallsProcessed() { return numberOfCallsProcessed; } public int getNumberOfDuplicates() { return numberOfDuplicates; } public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); Integer[] handledArray = (Integer[])ret; Integer numOfCallsHandled = (Integer) handledArray[0]; Integer numOfDuplicates = (Integer) handledArray[1]; System.out.println("Server is done. Number of calls handled: " + numOfCallsHandled); numberOfCallsProcessed = numOfCallsHandled.intValue(); System.out.println("Number of duplicate calls: " + numOfDuplicates); numberOfDuplicates = numOfDuplicates.intValue(); Object obj = callback.getCallbackHandleObject(); //String handbackObj = (String) obj; //System.out.println("Handback object should be " + sessionId + " and server called back with " + handbackObj); lock.release(); } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/client/SpringHttpPerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/clie0000644000175000017500000001744210475434747033503 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.http.client; import org.apache.log4j.Level; import org.jboss.jrunit.harness.BenchmarkTestDriver; import org.jboss.logging.Logger; import java.io.IOException; /** * @author Tom Elrod */ public class SpringHttpPerformanceTestCase extends BenchmarkTestDriver { protected int numberOfClients = 1; public static final String REMOTING_TRANSPORT = "remoting.transport"; public static final String REMOTING_METADATA = "remoting.metadata"; public static final String REMOTING_SERIALIZATION = "remoting.serialization"; public static final String PAYLOAD_SIZE = "remoting.payload.size"; public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients"; public static final String NUMBER_OF_CALLS = "remoting.number_of_calls"; public static final String JVM_MAX_HEAP_SIZE = "jvm.mx"; public static final String RESULT_TIMEOUT = "jrunit.result_timeout"; public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout"; public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout"; public static final String REMOTING_HOST = "remoting.host"; private static Logger log = Logger.getLogger(SpringHttpPerformanceTestCase.class); public void declareTestClasses() { //**************** LOGGING *********************** 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.SimpleLayout layout = new org.apache.log4j.SimpleLayout(); try { org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log"); fileAppender.setThreshold(Level.DEBUG); fileAppender.setAppend(false); org.apache.log4j.Category.getRoot().addAppender(fileAppender); } catch(IOException e) { e.printStackTrace(); } //*************** END LOGGING *********************** String numOfClients = System.getProperty(NUMBER_OF_CLIENTS); if(numOfClients != null && numOfClients.length() > 0) { try { numberOfClients = Integer.parseInt(numOfClients); } catch(NumberFormatException e) { e.printStackTrace(); } } addTestClasses(getClientTestClass(), numberOfClients, SpringHttpPerformanceDummyServer.class.getName()); } protected String getClientTestClass() { return SpringHttpPerformanceClient.class.getName(); } protected Level getTestHarnessLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * The log level to run as for the test case. * * @return */ protected Level getTestLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness). * The default value is null. * * @return */ protected String getClientJVMArguments() { return getJVMArguments(); // String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 "; // args = args + getJVMArguments(); // return args; } /** * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness). * The default value is null. * * @return */ protected String getServerJVMArguments() { return getJVMArguments(); } /** * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness). * The default value is null. * * @return */ private String getJVMArguments() { String vmArgs = ""; String transport = System.getProperty(REMOTING_TRANSPORT); if(transport != null && transport.length() > 0) { vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport; } String host = System.getProperty(REMOTING_HOST); if(host != null && host.length() > 0) { vmArgs = "-D" + REMOTING_HOST + "=" + host; } String serialization = System.getProperty(REMOTING_SERIALIZATION); if(serialization != null && serialization.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization; } String metadata = System.getProperty(REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata; } String payloadSize = System.getProperty(PAYLOAD_SIZE); if(payloadSize != null && payloadSize.length() > 0) { vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize; } String numOfCalls = System.getProperty(NUMBER_OF_CALLS); if(numOfCalls != null && numOfCalls.length() > 0) { vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls; } String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE); if(jvmMx != null && jvmMx.length() > 0) { vmArgs = vmArgs + " -Xmx" + jvmMx + "m"; } log.info(vmArgs); return vmArgs; } /** * 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() { long defaultTimeout = 6000000; // default to 100 minutes String timeout = System.getProperty(RESULT_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 6000000; // default to 100 minutes String timeout = System.getProperty(TEAR_DOWN_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 6000000; // default to 100 minutes String timeout = System.getProperty(RUN_TEST_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/client/SpringHttpClientService.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/clie0000644000175000017500000000334510475434617033474 0ustar twernertwerner ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/client/SpringHttpPerformanceClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/clie0000644000175000017500000001641510476462222033470 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.http.client; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.spring.http.web.SpringHttpServer; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.remoting.rmi.RmiServiceExporter; import java.rmi.server.UID; import java.util.Map; /** * @author Tom Elrod */ public class SpringHttpPerformanceClient extends PerformanceClientTest { private SpringHttpServer springHttpServerService; private String clientSessionId = new UID().toString(); protected static final Logger log = Logger.getLogger(SpringHttpPerformanceClient.class); public static Test suite() { return new ThreadLocalDecorator(SpringHttpPerformanceClient.class, 1); } public SpringHttpServer getSpringHttpServerService() { return springHttpServerService; } public void setSpringHttpServerService(SpringHttpServer springHttpServerService) { this.springHttpServerService = springHttpServerService; } public void init() { Resource res = new ClassPathResource("SpringHttpClientService.xml", SpringHttpPerformanceClient.class); BeanFactory factory = new XmlBeanFactory(res); springHttpServerService = (SpringHttpServer)factory.getBean("springHttpServerService"); /* try { // HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); BurlapProxyFactoryBean factory = new BurlapProxyFactoryBean(); factory.setServiceInterface(SpringHttpServer.class); factory.setServiceUrl("http://localhost:8080/remoting/springHessianServerService"); factory.afterPropertiesSet(); springHessianServerService = (SpringHttpServer) factory.getObject(); } catch (MalformedURLException e) { e.printStackTrace(); } */ } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { return null; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { String springServiceXml = this.getClass().getResource("SpringHttpClientService.xml").getFile(); ApplicationContext context = null; for (int i = 0; i < 10; i++) { try { context = new FileSystemXmlApplicationContext(springServiceXml); if (context != null) break; } catch (Exception e) { Thread.sleep(2000); } } if (context == null) { log.error("unable to create FileSystemXmlApplicationContext from SpringHttpClientService.xml"); throw new Exception("unable to create FileSystemXmlApplicationContext from SpringHttpClientService.xml"); } SpringHttpCallbackServer callbackServer = (SpringHttpCallbackServer) context.getBean("springHttpCallbackServerService"); callbackServer.setClientSessionId(clientSessionId); callbackServer.setServerDoneLock(serverDoneLock); /* Instead of exporting callback servers by injection, the following xml declaration is carried out programmatically. Each callback server is registered under a name ending in the sessionId. */ for (int i = 0; i < 10; i++) { try { RmiServiceExporter exporter = new RmiServiceExporter(); exporter.setServiceName("SpringHttpCallbackServerService:" + clientSessionId); exporter.setService(callbackServer); exporter.setServiceInterface(org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer.class); exporter.setRegistryPort(1299); exporter.afterPropertiesSet(); log.info("exported SpringHttpCallbackServerService:" + clientSessionId); break; } catch (Exception e) { Thread.sleep(2000); } } return callbackServer; // RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock); // callbackServer.start(); // return callbackServer; } protected void populateMetadata(Map metadata) { super.populateMetadata(metadata); metadata.put("transport", "spring_http"); metadata.put("serialization", "java"); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = "spring_http" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java"; } } return config; } protected Object makeInvocation(String method, Object param) throws Throwable { while (true) { try { if(method.equals(NUM_OF_CALLS)) { return springHttpServerService.sendNumberOfCalls(clientSessionId, param); } else if(method.equals(TEST_INVOCATION)) { return springHttpServerService.makeCall(clientSessionId, param); } else { throw new Exception("Was not able to find remote method call for " + method); } } catch (Exception e) { log.error("invocation error: " + e); } } } public static void main(String[] args) { SpringHttpPerformanceClient test = new SpringHttpPerformanceClient(); try { test.setUp(); test.testClientCalls(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/client/SpringHttpPerformanceDummyServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/clie0000644000175000017500000000327510475434747033502 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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. */ /* * Created on Aug 30, 2006 */ package org.jboss.test.remoting.performance.spring.http.client; import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest; /** * The real server for the spring http performance test runs in tomcat. This class is just * a dummy class passed to jrunit TestDriver. * * @author Ron Sigal * @version $Revision: 1424 $ *

          * Copyright (c) Aug 30, 2006 *

          */ public class SpringHttpPerformanceDummyServer extends PerformanceServerTest { public static void main(String[] args) { try { Thread.sleep(3600000); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000755000175000017500000000000011632407042033371 5ustar twernertwerner././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpServerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000644000175000017500000000441510475435263033411 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.http.web; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; import org.jboss.test.remoting.performance.synchronous.CallTracker; import org.jboss.test.remoting.performance.synchronous.Payload; import java.util.Map; /** * @author Tom Elrod */ public class SpringHttpServerImpl implements SpringHttpServer { private Map callTrackers = new ConcurrentHashMap(); public Object sendNumberOfCalls(Object obj, Object param) { System.out.println("sent number of calls " + obj + " " + param); String sessionId = (String) obj; Integer totalCountInteger = (Integer) param; int totalCount = totalCountInteger.intValue(); System.out.println("received totalCallCount call with total count of " + totalCount + " from " + sessionId); CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if (tracker != null) { tracker.createTotalCount(totalCount); } else { SpringHttpHandler callbackHandler = new SpringHttpHandler(sessionId); callbackHandler.start(); tracker = new CallTracker(sessionId, callbackHandler); callTrackers.put(sessionId, tracker); tracker.createTotalCount(totalCount); } return totalCountInteger; } public Object makeCall(Object obj, Object param) { Payload payload = (Payload) param; int clientInvokeCallCount = payload.getCallNumber(); String sessionId = (String) obj; CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if (tracker != null) { tracker.verifyClientInvokeCount(clientInvokeCallCount); } else { System.err.println("No call tracker exists for session id " + sessionId); throw new RuntimeException("No call tracker exists for session id " + sessionId); } return new Integer(clientInvokeCallCount); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpCallbackServerService.xml.savelibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000644000175000017500000000144210475435110033375 0ustar twernertwerner ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000644000175000017500000000114210470171753033377 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.http.web; /** * @author Tom Elrod */ public interface SpringHttpServer { public Object makeCall(Object obj, Object param); public Object sendNumberOfCalls(Object obj, Object param); } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000755000175000017500000000000011632407042033371 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000644000175000017500000000312310470171753033400 0ustar twernertwerner Spring HTTP Test Spring HTTP performance benchmark test webAppRootKey remoting.root org.springframework.web.context.ContextLoaderListener remoting org.springframework.web.servlet.DispatcherServlet remoting /* ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/WEB-INF/applicationContext.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000644000175000017500000000024210470171753033377 0ustar twernertwerner ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/WEB-INF/remoting-servlet.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000644000175000017500000000151710470171753033405 0ustar twernertwerner 1 ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/SpringHttpHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/http/web/0000644000175000017500000000663210475435203033406 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.http.web; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer; import org.jboss.test.remoting.performance.spring.rmi.SpringRMICallbackServer; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.remoting.rmi.RmiProxyFactoryBean; /** * @author Tom Elrod */ public class SpringHttpHandler implements InvokerCallbackHandler { private SpringHttpCallbackServer springHttpCallbackServer; private String sessionId; public SpringHttpHandler(String sessionId) { this.sessionId = sessionId; } public void start() { // Resource res = new ClassPathResource("SpringHttpCallbackServerService.xml", SpringHttpHandler.class); // BeanFactory factory = new XmlBeanFactory(res); // springHttpCallbackServer = (SpringHttpCallbackServer)factory.getBean("springHttpCallbackServerService"); /* Instead of creating callback server proxies by injection, the following xml declaration is replaced by programmatic creation. Each callback server is registered under a name ending in the sessionId. */ RmiProxyFactoryBean factory = new RmiProxyFactoryBean(); factory.setServiceUrl("rmi://localhost:1299/SpringHttpCallbackServerService:" + sessionId); factory.setServiceInterface(org.jboss.test.remoting.performance.spring.http.client.SpringHttpCallbackServer.class); try { factory.afterPropertiesSet(); } catch (Exception e) { System.out.println("unable to create callback proxy"); System.out.println(e); } springHttpCallbackServer = (SpringHttpCallbackServer)factory.getObject(); } public SpringHttpCallbackServer getSpringHttpCallbackServer() { return springHttpCallbackServer; } public void setSpringHttpCallbackServer(SpringHttpCallbackServer springHttpCallbackServer) { this.springHttpCallbackServer = springHttpCallbackServer; } public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("Need to make call on SpringRMICallbackServer with results. " + callback); try { springHttpCallbackServer.finishedProcessing(callback); } catch(Exception e) { e.printStackTrace(); throw new HandleCallbackException(e.getMessage()); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/0000755000175000017500000000000011632407042033267 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/readme.txtlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/r0000644000175000017500000000457310470171753033472 0ustar twernertwernerThis text covers how to run the spring hessian performance benchmark test. This test can not be run automatically within remoting testsuite since requires deploying a web app. So in order to run this test, will have to do it manually. First step is to get a web container to deploy within. Any web container will do, but I have been using Tomcat 5.5.17. Am also using Spring framework 1.2.8. Steps to run tests: 1. Run remoting build with tests.jars target. This will build the jboss-remoting.jar and jboss-remoting-tests.jar that will be needed within web deployment file. 2. Create web deployment file. This currently has to be done manually. Create new directory and copy src/tests/org/jboss/test/remoting/performance/spring/hessian/web/WEB-INF into this new directory. Should then have WEB-INF directory with contents applicationContext.xml, remoting-servlet.xml, and web.xml under root directory. Now create a lib directory under the WEB-INF directory. Copy the jboss-remoting.jar and jboss-remoting-tests.jar into the lib directory. Also copy all the jars under the remoting project's lib/spring directory into this new lib directory. Will also need to copy /lib/oswego-concurrent/concurrent.jar into the lib directory. Now zip up the WEB-INF directory into a file called remoting.war. This will be the web deployment file. Its contents should be: remoting.war - WEB-INF - applicationContext.xml - remoting-servlet.xml - web.xml - lib - concurrent.jar - jboss-remoting-tests.jar - spring-aop.jar - spring-context.jar - spring-dao.jar - spring-support.jar - hessian-2.1.12.jar - jboss-remoting.jar - spring-beans.jar - spring-core.jar - spring-remoting.jar - spring.jar 3. Deploy remoting.war to web container (i.e. copy to apache-tomcat-5.5.17\webapps directory). 4. Start web container (i.e. apache-tomcat-5.5.17\bin\startup.bat/sh) 5. Run the benchmark client. Currently this can not be done via running an ant target, so will need to do this via IDE. Will need run org.jboss.test.remoting.performance.spring.hessian.client.SpringHessianPerformanceClient, which has a main() method. Important Note: Was NEVER able to get this to work. Apparently Hessian and Burlap version 2.1.12 does not support sending objects that implement Externalizable, which the performance test Payload object does. And frankly got tired of trying to make it work.././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/client/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/c0000755000175000017500000000000011632407042033432 5ustar twernertwerner././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/client/SpringHessianPerformanceClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/c0000644000175000017500000001206610763051155033445 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.hessian.client; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.test.remoting.performance.spring.hessian.web.SpringHessianServer; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; import org.jboss.test.remoting.performance.synchronous.PerformanceClientTest; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.remoting.caucho.HessianProxyFactoryBean; import java.net.MalformedURLException; import java.rmi.server.UID; import java.util.Map; /** * @author Tom Elrod */ public class SpringHessianPerformanceClient extends PerformanceClientTest { private SpringHessianServer springHessianServerService; private String clientSessionId = new UID().toString(); protected static final Logger log = Logger.getLogger(SpringHessianPerformanceClient.class); public static Test suite() { return new ThreadLocalDecorator(SpringHessianPerformanceClient.class, 1); } public SpringHessianServer getSpringHessianServerService() { return springHessianServerService; } public void setSpringHessianServerService(SpringHessianServer springHessianServerService) { this.springHessianServerService = springHessianServerService; } public void init() { // Resource res = new ClassPathResource("SpringRMIClientService.xml", SpringHessianPerformanceClient.class); // BeanFactory factory = new XmlBeanFactory(res); // springHessianServerService = (SpringHessianServer)factory.getBean("springRMIServerService"); try { HessianProxyFactoryBean factory = new HessianProxyFactoryBean(); factory.setServiceInterface(SpringHessianServer.class); factory.setServiceUrl("http://localhost:8080/remoting/springHessianServerService"); factory.afterPropertiesSet(); springHessianServerService = (SpringHessianServer) factory.getObject(); if (false) throw new MalformedURLException("xxx"); } catch (MalformedURLException e) { e.printStackTrace(); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { return null; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { String springServiceXml = this.getClass().getResource("SpringHessianClientService.xml").getFile(); ApplicationContext context = new FileSystemXmlApplicationContext(springServiceXml); SpringHessianCallbackServer callbackServer = (SpringHessianCallbackServer) context.getBean("springHessianCallbackServerService"); callbackServer.setClientSessionId(clientSessionId); callbackServer.setServerDoneLock(serverDoneLock); return callbackServer; // RMICallbackServer callbackServer = new RMICallbackServer(clientSessionId, serverDoneLock); // callbackServer.start(); // return callbackServer; } protected void populateMetadata(Map metadata) { super.populateMetadata(metadata); metadata.put("transport", "spring_hessian"); metadata.put("serialization", "java"); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = "spring_hessian" + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + "java"; } } return config; } protected Object makeInvocation(String method, Object param) throws Throwable { if(method.equals(NUM_OF_CALLS)) { return springHessianServerService.sendNumberOfCalls(clientSessionId, param); } else if(method.equals(TEST_INVOCATION)) { return springHessianServerService.makeCall(clientSessionId, param); } else { throw new Exception("Was not able to find remote method call for " + method); } } public static void main(String[] args) { SpringHessianPerformanceClient test = new SpringHessianPerformanceClient(); try { test.setUp(); test.testClientCalls(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/client/SpringHessianClientService.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/c0000644000175000017500000000252110470171753033442 0ustar twernertwerner ././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/client/SpringHessianCallbackServerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/c0000644000175000017500000000471210467676676033472 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.hessian.client; import EDU.oswego.cs.dl.util.concurrent.Latch; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; /** * @author Tom Elrod */ public class SpringHessianCallbackServerImpl implements SpringHessianCallbackServer { private String sessionId; private Latch lock; private int numberOfCallsProcessed = 0; private int numberOfDuplicates = 0; // public SpringRMICallbackServerImpl(String sessionId, Latch lock) // { // this.sessionId = sessionId; // this.lock = lock; // } public void finishedProcessing(Object obj) { System.out.println("finishedProcessing called with " + obj); Callback callback = (Callback)obj; try { handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } public void setClientSessionId(String clientSessionId) { this.sessionId = clientSessionId; } public void setServerDoneLock(Latch serverDoneLock) { this.lock = serverDoneLock; } public int getNumberOfCallsProcessed() { return numberOfCallsProcessed; } public int getNumberOfDuplicates() { return numberOfDuplicates; } public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); Integer[] handledArray = (Integer[])ret; Integer numOfCallsHandled = (Integer) handledArray[0]; Integer numOfDuplicates = (Integer) handledArray[1]; System.out.println("Server is done. Number of calls handled: " + numOfCallsHandled); numberOfCallsProcessed = numOfCallsHandled.intValue(); System.out.println("Number of duplicate calls: " + numOfDuplicates); numberOfDuplicates = numOfDuplicates.intValue(); Object obj = callback.getCallbackHandleObject(); //String handbackObj = (String) obj; //System.out.println("Handback object should be " + sessionId + " and server called back with " + handbackObj); lock.release(); } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/client/SpringHessianCallbackServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/c0000644000175000017500000000161410467676676033470 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.hessian.client; import EDU.oswego.cs.dl.util.concurrent.Latch; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.test.remoting.performance.synchronous.PerformanceCallbackKeeper; /** * @author Tom Elrod */ public interface SpringHessianCallbackServer extends PerformanceCallbackKeeper, InvokerCallbackHandler { public void finishedProcessing(Object obj); void setClientSessionId(String clientSessionId); void setServerDoneLock(Latch serverDoneLock); } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000755000175000017500000000000011632407042033456 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/SpringHessianHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000644000175000017500000000410510467676676033512 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.hessian.web; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.test.remoting.performance.spring.hessian.client.SpringHessianCallbackServer; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; /** * @author Tom Elrod */ public class SpringHessianHandler implements InvokerCallbackHandler { private SpringHessianCallbackServer springHessianCallbackServer; public void start() { Resource res = new ClassPathResource("SpringHessianCallbackServerService.xml", SpringHessianHandler.class); BeanFactory factory = new XmlBeanFactory(res); springHessianCallbackServer = (SpringHessianCallbackServer)factory.getBean("springHessianCallbackServerService"); } public SpringHessianCallbackServer getSpringHessianCallbackServer() { return springHessianCallbackServer; } public void setSpringHessianCallbackServer(SpringHessianCallbackServer springHessianCallbackServer) { this.springHessianCallbackServer = springHessianCallbackServer; } public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("Need to make call on SpringRMICallbackServer with results. " + callback); try { springHessianCallbackServer.finishedProcessing(callback); } catch(Exception e) { e.printStackTrace(); throw new HandleCallbackException(e.getMessage()); } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/WEB-INF/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000755000175000017500000000000011632407042033456 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/WEB-INF/web.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000644000175000017500000000313110467676676033510 0ustar twernertwerner Spring Hessian Test Spring Hessian performance benchmark test webAppRootKey remoting.root org.springframework.web.context.ContextLoaderListener remoting org.springframework.web.servlet.DispatcherServlet remoting /* ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/WEB-INF/applicationContext.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000644000175000017500000000024210467676676033510 0ustar twernertwerner ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/WEB-INF/remoting-servlet.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000644000175000017500000000153610467676676033517 0ustar twernertwerner 1 ././@LongLink0000000000000000000000000000021600000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/SpringHessianCallbackServerService.xmllibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000644000175000017500000000134010467676676033510 0ustar twernertwerner ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/SpringHessianServerImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000644000175000017500000000442310467676676033515 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.hessian.web; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; import org.jboss.test.remoting.performance.synchronous.CallTracker; import org.jboss.test.remoting.performance.synchronous.Payload; import java.util.Map; /** * @author Tom Elrod */ public class SpringHessianServerImpl implements SpringHessianServer { private Map callTrackers = new ConcurrentHashMap(); public Object sendNumberOfCalls(Object obj, Object param) { System.out.println("sent number of calls " + obj + " " + param); String sessionId = (String) obj; Integer totalCountInteger = (Integer) param; int totalCount = totalCountInteger.intValue(); System.out.println("received totalCallCount call with total count of " + totalCount + " from " + sessionId); CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if (tracker != null) { tracker.createTotalCount(totalCount); } else { SpringHessianHandler callbackHandler = new SpringHessianHandler(); callbackHandler.start(); tracker = new CallTracker(sessionId, callbackHandler); callTrackers.put(sessionId, tracker); tracker.createTotalCount(totalCount); } return totalCountInteger; } public Object makeCall(Object obj, Object param) { Payload payload = (Payload) param; int clientInvokeCallCount = payload.getCallNumber(); String sessionId = (String) obj; CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if (tracker != null) { tracker.verifyClientInvokeCount(clientInvokeCallCount); } else { System.err.println("No call tracker exists for session id " + sessionId); throw new RuntimeException("No call tracker exists for session id " + sessionId); } return new Integer(clientInvokeCallCount); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/web/SpringHessianServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/spring/hessian/w0000644000175000017500000000115010467676676033507 0ustar twernertwerner/*************************************** * * * JBoss: The OpenSource J2EE WebOS * * * * Distributable under LGPL license. * * See terms of license at gnu.org. * * * ***************************************/ package org.jboss.test.remoting.performance.spring.hessian.web; /** * @author Tom Elrod */ public interface SpringHessianServer { public Object makeCall(Object obj, Object param); public Object sendNumberOfCalls(Object obj, Object param); } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/0000755000175000017500000000000011632407043032726 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/PerformanceClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Perf0000644000175000017500000003315310471377750033565 0ustar twernertwerner/* * 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.performance.synchronous; import EDU.oswego.cs.dl.util.concurrent.Latch; import junit.framework.Test; import junit.framework.TestCase; import org.jboss.jrunit.controller.ThreadLocalBenchmark; import org.jboss.jrunit.decorators.ThreadLocalDecorator; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.performance.PerformanceReporter; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class PerformanceClientTest extends TestCase { private Client client; private Connector connector; private InvokerLocator locator; private Latch serverDoneLock = new Latch(); // default transport and port private String transport = "socket"; private String serialization = ""; private String metadata = null; private int port = 9090; // performance specific variables private int numberOfCalls = 500; private int sizeOfPayload = 1024; private String sessionId = null; // statics for the specific call methods public static final String NUM_OF_CALLS = "numOfCalls"; public static final String TEST_INVOCATION = "testInvocation"; protected static final Logger log = Logger.getLogger(PerformanceClientTest.class); protected String host = "localhost"; public static Test suite() { return new ThreadLocalDecorator(PerformanceClientTest.class, 1); } public InvokerLocator getInvokerLocator() { return locator; } public void init() { try { String locatorURI = getTransport() + "://" + host + ":" + getPort(); if(metadata != null) { locatorURI = locatorURI + "/?" + metadata; } InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("starting remoting client with locator of " + locator); log.debug("starting remoting client with locator of " + locator); client = new Client(locator, "performance"); client.connect(); log.info("Client connected to " + locator.getLocatorURI()); } catch(Exception e) { log.error(e.getMessage(), e); } sessionId = client.getSessionId(); } public String getTransport() { return transport; } public String getSerialization() { return serialization; } public int getPort() { return port; } protected String getBenchmarkName() { return "PerformanceClientTest"; } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { if(port < 0) { port = TestUtil.getRandomPort(); } log.debug("port = " + port); connector = new Connector(); String locatorURI = getTransport() + "://" + host + ":" + port; if(metadata != null) { locatorURI = locatorURI + "/?" + metadata; } InvokerLocator locator = new InvokerLocator(locatorURI); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.start(); log.info("Callback server started on " + locator.getLocatorURI()); return locator; } public void setUp() throws Exception { String newTransport = System.getProperty(PerformanceTestCase.REMOTING_TRANSPORT); if(newTransport != null && newTransport.length() > 0) { transport = newTransport; log.info("Using transport: " + transport); } String newHost = System.getProperty(PerformanceTestCase.REMOTING_HOST); if(newHost != null && newHost.length() > 0) { host = newHost; log.info("Using host: " + host); } String newSerialization = System.getProperty(PerformanceTestCase.REMOTING_SERIALIZATION); if(newSerialization != null && newSerialization.length() > 0) { serialization = newSerialization; log.info("Using serialization: " + serialization); } String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(newMetadata != null && newMetadata.length() > 0) { metadata = newMetadata; log.info("Using metadata: " + metadata); } newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA_CALLBACK); if(newMetadata != null && newMetadata.length() > 0) { if(metadata == null) { metadata = newMetadata; } else { metadata += newMetadata; } log.info("Using metadata: " + metadata); } String payloadSize = System.getProperty(PerformanceTestCase.PAYLOAD_SIZE); if(payloadSize != null && payloadSize.length() > 0) { try { sizeOfPayload = Integer.parseInt(payloadSize); log.info("Using payload size: " + sizeOfPayload); } catch(NumberFormatException e) { e.printStackTrace(); } } String numOfCallsParam = System.getProperty(PerformanceTestCase.NUMBER_OF_CALLS); if(numOfCallsParam != null && numOfCallsParam.length() > 0) { try { numberOfCalls = Integer.parseInt(numOfCallsParam); log.info("Using number of calls: " + numberOfCalls); } catch(NumberFormatException e) { e.printStackTrace(); } } locator = initServer(-1); init(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } protected int getNumberOfCalls() { return numberOfCalls; } protected int getPayloadSize() { return sizeOfPayload; } public void testClientCalls() throws Throwable { Map metadata = new HashMap(); populateMetadata(metadata); ThreadLocalBenchmark.openBench(getBenchmarkName(), metadata); log.debug("running testSynchronousCalls()"); log.info("This class is " + getBenchmarkName()); if(client != null) { log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); } ThreadLocalBenchmark.openBench("Adding callback listener"); PerformanceCallbackKeeper handler = addCallbackListener(sessionId, serverDoneLock); ThreadLocalBenchmark.closeBench("Adding callback listener"); ThreadLocalBenchmark.openBench("Simple invocation"); // simple invoke, should return bar Object ret = makeInvocation(NUM_OF_CALLS, new Integer(getNumberOfCalls())); ThreadLocalBenchmark.closeBench("Simple invocation"); // // create the payload object // byte[] payload = new byte[getPayloadSize()]; // Payload payloadWrapper = new Payload(payload); // THIS IS WHERE TO START THE TIMING ThreadLocalBenchmark.openBench("Client calls"); long startTime = System.currentTimeMillis(); for(int x = 0; x < getNumberOfCalls(); x++) { // create the payload object byte[] payload = new byte[getPayloadSize()]; Payload payloadWrapper = new Payload(payload); // payloadWrapper.setCallNumber(callCounter.increment()); payloadWrapper.setCallNumber(x); Object resp = makeClientCall(TEST_INVOCATION, payloadWrapper); verifyResults(x, resp); } long endCallTime = System.currentTimeMillis(); System.out.println("Time to make all " + getNumberOfCalls() + " is " + (endCallTime - startTime)); ThreadLocalBenchmark.closeBench("Client calls"); //TODO: -TME Should make this configurable? // will make timeout 2 seconds per call long timeoutPeriod = 2000 * getNumberOfCalls(); boolean didComplete = serverDoneLock.attempt(timeoutPeriod); long endProcessTime = System.currentTimeMillis(); if(didComplete) { int numProcessed = handler.getNumberOfCallsProcessed(); int numOfDuplicates = handler.getNumberOfDuplicates(); long totalTime = (endProcessTime - startTime); System.out.println("Time for server to process " + numProcessed + " is " + totalTime); if(getNumberOfCalls() == numProcessed) { System.out.println("PASSED - the server processed all calls."); } else { System.out.println("FAILED - the server did NOT process all calls."); } assertEquals("The total number of calls should equal total number processed.", getNumberOfCalls(), numProcessed); assertEquals("The number of duplicates should be 0.", 0, numOfDuplicates); //TODO: -TME - This needs to be replaced by benchmark code reporting // metadata.put("server total count", String.valueOf(numProcessed)); // // // PerformanceReporter.writeReport(this.getClass().getName(), // totalTime, getNumberOfCalls(), metadata); } else { System.out.println("FAILED - timed out waiting for server to call back when done processing. Waited for " + timeoutPeriod); PerformanceReporter.writeReport("Error in test. Server never replied that it finished processing.", 0, 0, null); } ThreadLocalBenchmark.closeBench(getBenchmarkName()); } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { PerformanceCallbackHandler handler = new PerformanceCallbackHandler(sessionId, serverDoneLock); // Need to add callback listener to get callback when the server is done client.addListener(handler, getInvokerLocator(), sessionId); return handler; } protected void populateMetadata(Map metadata) { metadata.put("alias", getBenchmarkAlias()); metadata.put("transport", getTransport()); metadata.put("number of client calls", String.valueOf(getNumberOfCalls())); metadata.put("payload size", String.valueOf(getPayloadSize())); metadata.put("serialization", serialization); } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = getTransport() + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + serialization; } } return config; } protected void verifyResults(int x, Object resp) { assertEquals("The call number should be same as the numbe returned.", x, ((Integer) resp).intValue()); } protected Object makeClientCall(String testInvocation, Payload payloadWrapper) throws Throwable { return makeInvocation(TEST_INVOCATION, payloadWrapper); } protected Object makeInvocation(String method, Object param) throws Throwable { Object ret = null; if(param != null) { ret = client.invoke(new NameBasedInvocation(method, new Object[]{param}, new String[]{param.getClass().getName()}), null); } else { throw new Exception("To make invocation, must pass a valid, non null, Object as parameter."); } return ret; } protected Object makeOnewayInvocation(String method, Object param, boolean isClientSide) throws Throwable { if(param != null) { client.invokeOneway(new NameBasedInvocation(method, new Object[]{param}, new String[]{param.getClass().getName()}), null, isClientSide); } else { throw new Exception("To make oneway invocation, must pass a valid, non null, Object as parameter."); } return null; } public static void main(String[] args) { PerformanceClientTest test = new PerformanceClientTest(); try { test.setUp(); test.testClientCalls(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/PerformanceCallbackHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Perf0000644000175000017500000000562410355142433033554 0ustar twernertwerner/* * 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.performance.synchronous; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import EDU.oswego.cs.dl.util.concurrent.Latch; /** * @author Tom Elrod */ public class PerformanceCallbackHandler implements InvokerCallbackHandler, PerformanceCallbackKeeper { private String sessionId; private Latch lock; private int numberOfCallsProcessed = 0; private int numberofDuplicates = 0; public PerformanceCallbackHandler(String sessionId, Latch lock) { this.sessionId = sessionId; this.lock = lock; } public int getNumberOfCallsProcessed() { return numberOfCallsProcessed; } public int getNumberOfDuplicates() { return numberofDuplicates; } /** * 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 { Object ret = callback.getCallbackObject(); Integer[] handledArray = (Integer[]) ret; Integer numOfCallsHandled = (Integer) handledArray[0]; Integer numOfDuplicates = (Integer) handledArray[1]; System.out.println("Server is done. Number of calls handled: " + numOfCallsHandled); numberOfCallsProcessed = numOfCallsHandled.intValue(); System.out.println("Number of duplicate calls: " + numOfDuplicates); numberofDuplicates = numOfDuplicates.intValue(); Object obj = callback.getCallbackHandleObject(); String handbackObj = (String) obj; System.out.println("Handback object should be " + sessionId + " and server called back with " + handbackObj); lock.release(); } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/MultiThreadPerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Mult0000644000175000017500000000244210355142433033574 0ustar twernertwerner/* * 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.performance.synchronous; /** * @author Tom Elrod */ public class MultiThreadPerformanceTestCase extends PerformanceTestCase { protected String getClientTestClass() { return MultiThreadedPerformanceClientTest.class.getName(); } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/CallTracker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Call0000644000175000017500000001137210355142433033530 0ustar twernertwerner/* * 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.performance.synchronous; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt; /** * @author Tom Elrod */ public class CallTracker { private String clientSessionId; private int totalCount = 0; private SynchronizedInt duplicateCount = new SynchronizedInt(0); private SynchronizedInt receivedCount = new SynchronizedInt(0); private boolean[] counterArray = null; private InvokerCallbackHandler callbackHandler; public CallTracker(String sessionId, InvokerCallbackHandler callbackHandler) { this.clientSessionId = sessionId; this.callbackHandler = callbackHandler; } public synchronized void createTotalCount(int totalCount) { counterArray = new boolean[totalCount + 1]; this.totalCount = totalCount; receivedCount.set(0); duplicateCount.set(0); } public void verifyClientInvokeCount(int clientInvokeCallCount) { boolean duplicate = addToReceivedCount(clientInvokeCallCount); if(duplicate) { duplicateCount.increment(); } else { receivedCount.increment(); } int currentDuplicateCount = duplicateCount.get(); int currentReceivedCount = receivedCount.get(); if((currentReceivedCount % 100) == 0) { System.out.println(clientSessionId + " -- Received count: " + currentReceivedCount); System.out.println(clientSessionId + " -- Duplicate count: " + currentDuplicateCount); System.out.println(clientSessionId + " -- Total count: " + totalCount); } if((currentReceivedCount + currentDuplicateCount) == totalCount) { System.out.println("\n\n*****************************\n" + " Test Finished\n" + "*****************************\n" + " " + clientSessionId + " -- Received Count = " + currentReceivedCount + "\n" + " " + clientSessionId + " -- Duplicate Count = " + currentDuplicateCount + "\n" + "*****************************\n\n"); // now call back on client to indicate finished server processing if(callbackHandler != null) { Callback callback = new Callback(new Integer[]{new Integer(currentReceivedCount), new Integer(currentDuplicateCount)}); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } } } private synchronized boolean addToReceivedCount(int localClientInvokeCount) { boolean isDuplicate = false; if(counterArray == null) { System.out.println("Error! Have not received invoke for method 'totalCallCount', so can not process count."); throw new RuntimeException("Error! Have not received invoke for method 'totalCallCount', so can not process count."); } else { try { isDuplicate = counterArray[localClientInvokeCount]; if(!isDuplicate) { counterArray[localClientInvokeCount] = true; } } catch(ArrayIndexOutOfBoundsException e) { System.err.println("Got ArrayIndexOutOfBoundsException"); System.err.println("Counter array size = " + counterArray.length); System.err.println("Received count = " + localClientInvokeCount); e.printStackTrace(); } } return isDuplicate; } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/PerformanceServerTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Perf0000644000175000017500000001260710471377750033566 0ustar twernertwerner/* * 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.performance.synchronous; 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 java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; /** * @author Tom Elrod */ public class PerformanceServerTest extends ServerTestCase { // default transport and port private String transport = "socket"; private int serverPort = 9090; protected String host = "localhost"; private Connector connector = null; private static final Logger log = Logger.getLogger(PerformanceServerTest.class); public void setHost(String host) { this.host = host; } public void init(Map metatdata) throws Exception { if(serverPort < 0) { //serverPort = Math.abs(new Random().nextInt(2000) + 2000); throw new Exception("port setting for server can not be null."); } log.debug("port = " + serverPort); connector = new Connector(); InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata)); System.out.println("starting remoting server using locator of " + locator); log.debug("starting remoting server using locator of " + locator); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler()); connector.start(); log.info("Server started on " + locator.getLocatorURI()); } private String buildLocatorURI(Map metadata) { if(metadata == null || metadata.size() == 0) { return transport + "://" + host + ":" + serverPort; } else { StringBuffer uriBuffer = new StringBuffer(transport + "://" + host + ":" + 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 String getSubsystem() { return "performance"; } protected ServerInvocationHandler getServerInvocationHandler() { return new PerformanceInvocationHandler(); } public void setUp() throws Exception { String newTransport = System.getProperty(PerformanceTestCase.REMOTING_TRANSPORT); if(newTransport != null && newTransport.length() > 0) { transport = newTransport; log.info("Using transport: " + transport); } String newHost = System.getProperty(PerformanceTestCase.REMOTING_HOST); if(newHost != null && newHost.length() > 0) { host = newHost; log.info("Using host: " + host); } Map metadata = new HashMap(); String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(newMetadata != null && newMetadata.length() > 0) { metadata.putAll(parseMetadataString(newMetadata)); log.info("Using metadata: " + metadata); } init(metadata); } public static Map parseMetadataString(String newMetadata) { StringTokenizer tok = new StringTokenizer(newMetadata, "&"); Map parameters = new HashMap(tok.countTokens()); while(tok.hasMoreTokens()) { String token = tok.nextToken(); int eq = token.indexOf("="); String name = (eq > -1) ? token.substring(0, eq) : token; String value = (eq > -1) ? token.substring(eq + 1) : ""; parameters.put(name, value); } return parameters; } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { PerformanceServerTest test = new PerformanceServerTest(); try { test.setUp(); Thread.currentThread().sleep(30000000); test.tearDown(); //System.exit(0); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/PerformanceCallbackKeeper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Perf0000644000175000017500000000232610355142433033550 0ustar twernertwerner/* * 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.performance.synchronous; /** * @author Tom Elrod */ public interface PerformanceCallbackKeeper { int getNumberOfCallsProcessed(); int getNumberOfDuplicates(); }././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/MultiThreadedPerformanceClientTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Mult0000644000175000017500000004045310471377750033613 0ustar twernertwerner/* * 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.performance.synchronous; import EDU.oswego.cs.dl.util.concurrent.Latch; import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt; import junit.framework.Test; import junit.framework.TestCase; import org.jboss.jrunit.controller.ThreadLocalBenchmark; import org.jboss.jrunit.decorators.ThreadLocalDecorator; 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 org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.transport.Connector; import org.jboss.test.remoting.TestUtil; import org.jboss.test.remoting.performance.PerformanceReporter; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class MultiThreadedPerformanceClientTest extends TestCase { private Client client; private Connector connector; private InvokerLocator locator; private Latch serverDoneLock = new Latch(); // default transport and port private String transport = "socket"; private String serialization = ""; private String metadata = null; private int port = 9090; // performance specific variables private int numberOfCalls = 500; private int sizeOfPayload = 1024; private String sessionId = null; // statics for the specific call methods public static final String NUM_OF_CALLS = "numOfCalls"; public static final String TEST_INVOCATION = "testInvocation"; private static final Logger log = Logger.getLogger(MultiThreadedPerformanceClientTest.class); private SynchronizedInt callCounter = new SynchronizedInt(0); private int numOfThreads = 10; protected String host = "localhost"; public static Test suite() { return new ThreadLocalDecorator(MultiThreadedPerformanceClientTest.class, 1); } public void init() { try { String locatorURI = getTransport() + "://" + host + ":" + getPort(); if(metadata != null) { locatorURI = locatorURI + "/?" + metadata; } InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("starting remoting client with locator of " + locator); log.debug("starting remoting client with locator of " + locator); client = new Client(locator, "performance"); client.connect(); log.info("Client connected to " + locator.getLocatorURI()); } catch(Exception e) { log.error(e.getMessage(), e); } sessionId = client.getSessionId(); } public String getTransport() { return transport; } public String getSerialization() { return serialization; } public int getPort() { return port; } protected Object getBenchmarkAlias() { String config = System.getProperty("alias"); if(config == null || config.length() == 0) { config = System.getProperty("jboss-junit-configuration"); if(config == null || config.length() == 0) { config = getTransport() + "_" + getNumberOfCalls() + "_" + getPayloadSize() + "_" + serialization; } } return config; } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ protected InvokerLocator initServer(int port) throws Exception { if(port < 0) { port = TestUtil.getRandomPort(); } log.debug("port = " + port); connector = new Connector(); String locatorURI = getTransport() + "://" + host + ":" + port; if(metadata != null) { locatorURI = locatorURI + "/?" + metadata; } InvokerLocator locator = new InvokerLocator(locatorURI); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); connector.start(); log.info("Callback server started on " + locator.getLocatorURI()); return locator; } public void setUp() throws Exception { String newTransport = System.getProperty(PerformanceTestCase.REMOTING_TRANSPORT); if(newTransport != null && newTransport.length() > 0) { transport = newTransport; log.info("Using transport: " + transport); } String newHost = System.getProperty(PerformanceTestCase.REMOTING_HOST); if(newHost != null && newHost.length() > 0) { host = newHost; log.info("Using host: " + host); } String newSerialization = System.getProperty(PerformanceTestCase.REMOTING_SERIALIZATION); if(newSerialization != null && newSerialization.length() > 0) { serialization = newSerialization; log.info("Using serialization: " + serialization); } String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA); if(newMetadata != null && newMetadata.length() > 0) { metadata = newMetadata; log.info("Using metadata: " + metadata); } newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA_CALLBACK); if(newMetadata != null && newMetadata.length() > 0) { if(metadata == null) { metadata = newMetadata; } else { metadata += newMetadata; } log.info("Using metadata: " + metadata); } String payloadSize = System.getProperty(PerformanceTestCase.PAYLOAD_SIZE); if(payloadSize != null && payloadSize.length() > 0) { try { sizeOfPayload = Integer.parseInt(payloadSize); log.info("Using payload size: " + sizeOfPayload); } catch(NumberFormatException e) { e.printStackTrace(); } } String numOfCallsParam = System.getProperty(PerformanceTestCase.NUMBER_OF_CALLS); if(numOfCallsParam != null && numOfCallsParam.length() > 0) { try { numberOfCalls = Integer.parseInt(numOfCallsParam); log.info("Using number of calls: " + numberOfCalls); } catch(NumberFormatException e) { e.printStackTrace(); } } locator = initServer(-1); init(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } protected int getNumberOfCalls() { return numberOfCalls; } protected int getPayloadSize() { return sizeOfPayload; } public void testClientCalls() throws Throwable { Map metadata = new HashMap(); populateMetadata(metadata); ThreadLocalBenchmark.openBench(getBenchmarkName(), metadata); log.debug("running testSynchronousCalls()"); if(client != null) { log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); } PerformanceCallbackKeeper handler = addCallbackListener(sessionId, serverDoneLock); ThreadLocalBenchmark.openBench("Adding callback listener"); // Need to add callback listener to get callback when the server is done // client.addListener(handler, locator, client.getSessionId()); ThreadLocalBenchmark.closeBench("Adding callback listener"); ThreadLocalBenchmark.openBench("Simple invocation"); // simple invoke, should return bar Object ret = makeInvocation(NUM_OF_CALLS, new Integer(getNumberOfCalls())); ThreadLocalBenchmark.closeBench("Simple invocation"); // create the payload object final byte[] payload = new byte[getPayloadSize()]; // THIS IS WHERE TO START THE TIMING ThreadLocalBenchmark.openBench("Client calls"); long startTime = System.currentTimeMillis(); Thread[] threads = new Thread[numOfThreads]; for(int x = 0; x < numOfThreads; x++) { Thread newThread = new Thread(new Runnable() { public void run() { try { makeTestInvocation(payload); } catch(Throwable throwable) { throwable.printStackTrace(); } } }); threads[x] = newThread; newThread.start(); } // will make timeout 2 seconds per call long timeoutPeriod = 2000 * getNumberOfCalls(); for(int i = 0; i < threads.length; i++) { threads[i].join(timeoutPeriod); } long endCallTime = System.currentTimeMillis(); System.out.println("Time to make all " + getNumberOfCalls() + " is " + (endCallTime - startTime)); ThreadLocalBenchmark.closeBench("Client calls"); //TODO: -TME Should make this configurable? boolean didComplete = serverDoneLock.attempt(timeoutPeriod); long endProcessTime = System.currentTimeMillis(); if(didComplete) { int numProcessed = handler.getNumberOfCallsProcessed(); int numOfDuplicates = handler.getNumberOfDuplicates(); long totalTime = (endProcessTime - startTime); System.out.println("Time for server to process " + numProcessed + " is " + totalTime); if(getNumberOfCalls() == numProcessed) { System.out.println("PASSED - the server processed all calls."); } else { System.out.println("FAILED - the server did NOT process all calls."); } assertEquals("The total number of calls should equal total number processed.", getNumberOfCalls(), numProcessed); assertEquals("The number of duplicates should be 0.", 0, numOfDuplicates); //TODO: -TME - This needs to be replaced by benchmark code reporting // metadata.put("server total count", String.valueOf(numProcessed)); // // PerformanceReporter.writeReport(this.getClass().getName(), // totalTime, getNumberOfCalls(), metadata); } else { System.out.println("FAILED - timed out waiting for server to call back when done processing. Waited for " + timeoutPeriod); PerformanceReporter.writeReport("Error in test. Server never replied that it finished processing.", 0, 0, null); } ThreadLocalBenchmark.closeBench(getBenchmarkName()); } public InvokerLocator getInvokerLocator() { return locator; } protected PerformanceCallbackKeeper addCallbackListener(String sessionId, Latch serverDoneLock) throws Throwable { org.jboss.test.remoting.performance.synchronous.PerformanceCallbackHandler handler = new org.jboss.test.remoting.performance.synchronous.PerformanceCallbackHandler(sessionId, serverDoneLock); // Need to add callback listener to get callback when the server is done client.addListener(handler, getInvokerLocator(), sessionId); return handler; } protected void populateMetadata(Map metadata) { metadata.put("alias", getBenchmarkAlias()); metadata.put("transport", getTransport()); metadata.put("number of client calls", String.valueOf(getNumberOfCalls())); metadata.put("payload size", String.valueOf(getPayloadSize())); metadata.put("serialization", serialization); } private String getBenchmarkName() { return "MultiThreadedPerformanceClientTest"; } private void makeTestInvocation(byte[] payload) throws Throwable { Payload payloadWrapper = new Payload(payload); while(callCounter.get() < getNumberOfCalls()) { int currentVal = callCounter.increment(); payloadWrapper.setCallNumber(currentVal); Object resp = makeClientCall(TEST_INVOCATION, payloadWrapper); assertEquals(currentVal, ((Integer) resp).intValue()); } } protected Object makeClientCall(String testInvocation, Payload payloadWrapper) throws Throwable { return makeInvocation(TEST_INVOCATION, payloadWrapper); } protected Object makeInvocation(String method, Object param) throws Throwable { Object ret = null; if(param != null) { ret = client.invoke(new NameBasedInvocation(method, new Object[]{param}, new String[]{param.getClass().getName()}), null); } else { throw new Exception("To make invocation, must pass a valid, non null, Object as parameter."); } return ret; } protected Object makeOnewayInvocation(String method, Object param, boolean isClientSide) throws Throwable { if(param != null) { client.invokeOneway(new NameBasedInvocation(method, new Object[]{param}, new String[]{param.getClass().getName()}), null, isClientSide); } else { throw new Exception("To make oneway invocation, must pass a valid, non null, Object as parameter."); } return null; } public static void main(String[] args) { MultiThreadedPerformanceClientTest test = new MultiThreadedPerformanceClientTest(); try { test.setUp(); test.testClientCalls(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } public static class PerformanceCallbackHandler implements InvokerCallbackHandler { private String sessionId; private Latch lock; private int numberOfCallsProcessed = 0; private int numberofDuplicates = 0; public PerformanceCallbackHandler(String sessionId, Latch lock) { this.sessionId = sessionId; this.lock = lock; } public int getNumberOfCallsProcessed() { return numberOfCallsProcessed; } public int getNumberOfDuplicates() { return numberofDuplicates; } /** * 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 { Object ret = callback.getCallbackObject(); Integer[] handledArray = (Integer[]) ret; Integer numOfCallsHandled = (Integer) handledArray[0]; Integer numOfDuplicates = (Integer) handledArray[1]; System.out.println("Server is done. Number of calls handled: " + numOfCallsHandled); numberOfCallsProcessed = numOfCallsHandled.intValue(); System.out.println("Number of duplicate calls: " + numOfDuplicates); numberofDuplicates = numOfDuplicates.intValue(); Object obj = callback.getCallbackHandleObject(); String handbackObj = (String) obj; System.out.println("Handback object should be " + sessionId + " and server called back with " + handbackObj); lock.release(); } } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/PerformanceInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Perf0000644000175000017500000001470310355142433033552 0ustar twernertwerner/* * 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.performance.synchronous; import java.util.ArrayList; import java.util.List; import java.util.Map; 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.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.invocation.RemoteInvocation; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; import EDU.oswego.cs.dl.util.concurrent.FIFOReadWriteLock; import EDU.oswego.cs.dl.util.concurrent.SyncList; /** * @author Tom Elrod */ public class PerformanceInvocationHandler implements ServerInvocationHandler { private ServerInvoker invoker; private List listeners = new SyncList(new ArrayList(), new FIFOReadWriteLock()); private Map callTrackers = new ConcurrentHashMap(); private static final Logger log = Logger.getLogger(PerformanceInvocationHandler.class); /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { this.invoker = invoker; } /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { Object param = invocation.getParameter(); String sessionId = invocation.getSessionId(); 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(PerformanceClientTest.NUM_OF_CALLS)) { Integer totalCountInteger = (Integer) params[0]; int totalCount = totalCountInteger.intValue(); System.out.println("received totalCallCount call with total count of " + totalCount + " from " + sessionId); CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if(tracker != null) { tracker.createTotalCount(totalCount); ret = totalCountInteger; } else { log.error("Calling " + methodName + " but no call tracker exists for session id " + sessionId); throw new Exception("Calling " + methodName + " but no call tracker exists for session id " + sessionId); } } else if(methodName.equals(PerformanceClientTest.TEST_INVOCATION)) { if(params != null) { Payload payload = (Payload) params[0]; //System.out.println(payload); int clientInvokeCallCount = payload.getCallNumber(); CallTracker tracker = (CallTracker) callTrackers.get(sessionId); if(tracker != null) { tracker.verifyClientInvokeCount(clientInvokeCallCount); } else { log.error("Calling " + methodName + " but no call tracker exists for session id " + sessionId); throw new Exception("Calling " + methodName + " but no call tracker exists for session id " + sessionId); } // just passing return, even though not needed ret = new Integer(clientInvokeCallCount); } else { log.error("no parameter passed for method call " + methodName); } } else { throw new Exception("Don't know what to do with call to " + methodName); } return ret; } private void createCallTracker(String sessionId, InvokerCallbackHandler callbackHandler) { CallTracker tracker = new CallTracker(sessionId, callbackHandler); callTrackers.put(sessionId, tracker); } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { ServerInvokerCallbackHandler handler = (ServerInvokerCallbackHandler) callbackHandler; String sessionId = handler.getClientSessionId(); System.out.println("Adding callback listener. Callback handler has session id: " + sessionId); createCallTracker(sessionId, 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) { //TODO: -TME Need to figure out how this should be handled. // Could look up CallTracker based on session id (as in addListener() method) // and then remove from tracker or kill tracker all together. listeners.remove(callbackHandler); } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/PerformanceTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Perf0000644000175000017500000002117210473061115033546 0ustar twernertwerner/* * 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.performance.synchronous; import org.apache.log4j.Level; import org.jboss.jrunit.harness.BenchmarkTestDriver; /** * @author Tom Elrod */ public class PerformanceTestCase extends BenchmarkTestDriver //TestDriver { protected int numberOfClients = 1; public static final String REMOTING_TRANSPORT = "remoting.transport"; public static final String REMOTING_METADATA = "remoting.metadata"; public static final String REMOTING_METADATA_CALLBACK = "remoting.metadata.callback"; public static final String REMOTING_SERIALIZATION = "remoting.serialization"; public static final String PAYLOAD_SIZE = "remoting.payload.size"; public static final String NUMBER_OF_CLIENTS = "remoting.number_of_clients"; public static final String NUMBER_OF_CALLS = "remoting.number_of_calls"; public static final String JVM_MAX_HEAP_SIZE = "jvm.mx"; public static final String RESULT_TIMEOUT = "jrunit.result_timeout"; public static final String TEAR_DOWN_TIMEOUT = "jrunit.tear_down_timeout"; public static final String RUN_TEST_TIMEOUT = "jrunit.run_test_timeout"; public static final String REMOTING_HOST = "remoting.host"; public void declareTestClasses() { //**************** LOGGING *********************** //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.SimpleLayout layout = new org.apache.log4j.SimpleLayout(); // try // { // org.apache.log4j.FileAppender fileAppender = new org.apache.log4j.FileAppender(layout, "debug_output.log"); // fileAppender.setThreshold(Level.DEBUG); // fileAppender.setAppend(false); // org.apache.log4j.Category.getRoot().addAppender(fileAppender); // } // catch(IOException e) // { // e.printStackTrace(); // } //*************** END LOGGING *********************** String numOfClients = System.getProperty(NUMBER_OF_CLIENTS); if(numOfClients != null && numOfClients.length() > 0) { try { numberOfClients = Integer.parseInt(numOfClients); } catch(NumberFormatException e) { e.printStackTrace(); } } addTestClasses(getClientTestClass(), numberOfClients, PerformanceServerTest.class.getName()); } protected String getClientTestClass() { return PerformanceClientTest.class.getName(); } protected Level getTestHarnessLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * The log level to run as for the test case. * * @return */ protected Level getTestLogLevel() { return Level.INFO; //return Level.DEBUG; } /** * Returns the VM arguments to be passed to the vm when creating the client test cases (actually their harness). * The default value is null. * * @return */ protected String getClientJVMArguments() { return getJVMArguments(); // String args = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5000 "; // args = args + getJVMArguments(); // return args; } /** * Returns the VM arguments to be passed to the vm when creating the server test cases (actually their harness). * The default value is null. * * @return */ protected String getServerJVMArguments() { return getJVMArguments(); } /** * Returns the VM arguments to be passed to the vm when creating the client and server test cases (actually their harness). * The default value is null. * * @return */ private String getJVMArguments() { String vmArgs = ""; String transport = System.getProperty(REMOTING_TRANSPORT); if(transport != null && transport.length() > 0) { vmArgs = "-D" + REMOTING_TRANSPORT + "=" + transport; } String host = System.getProperty(REMOTING_HOST); if(host != null && host.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_HOST + "=" + host; } String serialization = System.getProperty(REMOTING_SERIALIZATION); if(serialization != null && serialization.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_SERIALIZATION + "=" + serialization; } String metadata = System.getProperty(REMOTING_METADATA); if(metadata != null && metadata.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_METADATA + "=" + metadata; } String callbackMetadata = System.getProperty(REMOTING_METADATA_CALLBACK); if(callbackMetadata != null && callbackMetadata.length() > 0) { vmArgs = vmArgs + " -D" + REMOTING_METADATA_CALLBACK + "=" + callbackMetadata; } String payloadSize = System.getProperty(PAYLOAD_SIZE); if(payloadSize != null && payloadSize.length() > 0) { vmArgs = vmArgs + " -D" + PAYLOAD_SIZE + "=" + payloadSize; } String numOfCalls = System.getProperty(NUMBER_OF_CALLS); if(numOfCalls != null && numOfCalls.length() > 0) { vmArgs = vmArgs + " -D" + NUMBER_OF_CALLS + "=" + numOfCalls; } String jvmMx = System.getProperty(JVM_MAX_HEAP_SIZE); if(jvmMx != null && jvmMx.length() > 0) { vmArgs = vmArgs + " -Xmx" + jvmMx + "m"; } return vmArgs; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(RESULT_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(TEAR_DOWN_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } /** * 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() { long defaultTimeout = 600000; // default to 10 minutes String timeout = System.getProperty(RUN_TEST_TIMEOUT); if(timeout != null && timeout.length() > 0) { try { defaultTimeout = Long.parseLong(timeout); } catch(NumberFormatException e) { System.out.println("Can not use " + timeout + " as timeout value as is not a number"); } } return defaultTimeout; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Payload.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/performance/synchronous/Payl0000644000175000017500000000747111015166451033567 0ustar twernertwerner/* * 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.performance.synchronous; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; /** * @author Tom Elrod */ public class Payload implements Externalizable { private int callNumber = 0; private Object payload = null; public Payload() { } public Payload(Object payload) { this.payload = payload; } public void setCallNumber(int callNumber) { this.callNumber = callNumber; } public int getCallNumber() { return callNumber; } public Object getPayload() { return payload; } public String toString() { StringBuffer buffer = new StringBuffer("Payload (" + super.toString() + ") contains:\n"); buffer.append("call number: " + callNumber + "\n"); buffer.append("payload value: " + payload + "\n"); return buffer.toString(); } /** * The object implements the readExternal method to restore its * contents by calling the methods of DataInput for primitive * types and readObject for objects, strings and arrays. The * readExternal method must read the values in the same sequence * and with the same types as were written by writeExternal. * * @param in the stream to read data from in order to restore the object * @throws java.io.IOException if I/O errors occur * @throws ClassNotFoundException If the class for an object being * restored cannot be found. */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { //System.out.println("read new version"); callNumber = in.readInt(); int size = in.readInt(); byte[] bytes = new byte[size]; int n = 0; while (n < size) { n += in.read(bytes, n, size - n); } this.payload = bytes; } /** * The object implements the writeExternal method to save its contents * by calling the methods of DataOutput for its primitive values or * calling the writeObject method of ObjectOutput for objects, strings, * and arrays. * * @param out the stream to write the object to * @throws java.io.IOException Includes any I/O exceptions that may occur * @serialData Overriding methods should use this tag to describe * the data layout of this Externalizable object. * List the sequence of element types and, if possible, * relate the element to a public/protected field and/or * method of this Externalizable class. */ public void writeExternal(ObjectOutput out) throws IOException { //System.out.println("write new version"); out.writeInt(callNumber); byte[] bytes = (byte[]) payload; out.writeInt(bytes.length); out.write(bytes, 0, bytes.length); } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/0000755000175000017500000000000011632407032030700 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/ServerBindingTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/ServerBindingT0000644000175000017500000001526710356654466033544 0ustar twernertwerner/* * 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. */ /* * Created on Jan 3, 2006 */ package org.jboss.test.remoting.configuration; import java.net.InetAddress; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.Connector; /** * A ServerBindTest. * @author Ron Sigal * @version $Revision: 593 $ *

          * Copyright (c) 2005 *

          */ public class ServerBindingTestCase extends TestCase { protected static final Logger log = Logger.getLogger(ServerBindingTestCase.class); private Connector connector; public void setUp() throws Exception { connector = new Connector(); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public void testBindAddress() { String uri = "socket://192.0.0.1:8081/?serverBindAddress=localhost"; assertTrue(doOneBindingTest(uri, "localhost", 8081)); } public void testConnectAddress() { try { String uri = "socket://0.1.2.3:8082/?clientConnectAddress=1.2.3.4"; assertTrue(doOneBindingTest(uri, InetAddress.getLocalHost().getHostAddress(), 8082)); } catch (Exception e) { e.printStackTrace(); log.error(e); fail(); } } public void testBindAndConnectAddress() { try { String uri = "socket://0.1.2.3:8083/?serverBindAddress=localhost&clientConnectAddress=1.2.3.4"; assertTrue(doOneBindingTest(uri, "localhost", 8083)); } catch (Exception e) { e.printStackTrace(); log.error(e); fail(); } } public void testLocatorAddress() { try { String uri = "socket://localhost:8084"; assertTrue(doOneBindingTest(uri, "127.0.0.1", 8084)); } catch (Exception e) { e.printStackTrace(); log.error(e); fail(); } } public void testNullLocatorAddress() { try { String uri = "socket://:8085"; assertTrue(doOneBindingTest(uri, "127.0.0.1", 8085)); } catch (Exception e) { e.printStackTrace(); log.error(e); fail(); } } public void testBindPort() { String uri = "socket://localhost:1111/?serverBindPort=8086"; assertTrue(doOneBindingTest(uri, "127.0.0.1", 8086)); } public void testZeroBindPort() { String uri = "socket://localhost/?serverBindPort=0"; assertTrue(doOneAnonymousBindingTest(uri)); } public void testNegativeBindPort() { String uri = "socket://localhost/?serverBindPort=-1"; assertTrue(doOneAnonymousBindingTest(uri)); } public void testZeroConnectPort() { String uri = "socket://localhost/?clientConnectPort=0"; assertTrue(doOneAnonymousBindingTest(uri)); } public void testNegativeConnectPort() { String uri = "socket://localhost/?serverBindPort=-1"; assertTrue(doOneAnonymousBindingTest(uri)); } public void testZeroBindandConnectPort() { String uri = "socket://localhost/?serverBindPort=0&clientConnectPort=0"; assertTrue(doOneAnonymousBindingTest(uri)); } public void testNegativeBindandConnectPort() { String uri = "socket://localhost/?serverBindPort=-1&clientConnectPort=-1"; assertTrue(doOneAnonymousBindingTest(uri)); } public void testZeroLocatorPort() { String uri = "socket://localhost:0"; assertTrue(doOneAnonymousBindingTest(uri)); } public void testNegativeLocatorPort() { String uri = "socket://localhost:-1"; assertTrue(doOneAnonymousBindingTest(uri)); } protected boolean doOneBindingTest(String uri, String expectedHost, int expectedPort) { boolean success = true; try { connector.setInvokerLocator(uri); connector.create(); connector.start(); ServerInvoker[] serverInvokers = InvokerRegistry.getServerInvokers(); if (serverInvokers == null || serverInvokers.length == 0) { log.error("no invoker created: " + uri); success = false; } ServerInvoker serverInvoker = serverInvokers[0]; String bindHost = serverInvoker.getServerBindAddress(); int bindPort = serverInvoker.getServerBindPort(); if (!expectedHost.equals(bindHost)) { log.error("host (" + bindHost + ") != expected host (" + expectedHost); success = false; } if (expectedPort != bindPort) { log.error("port (" + bindPort + ") != expected port (" + expectedPort); success = false; } return success; } catch (Exception e) { e.printStackTrace(); log.error(e); return false; } } protected boolean doOneAnonymousBindingTest(String uri) { boolean success = true; try { connector.setInvokerLocator(uri); connector.create(); connector.start(); InvokerLocator locator = new InvokerLocator(connector.getInvokerLocator()); if (locator.getPort() <= 0) { log.error("port should be > 0: " + locator.getPort()); success = false; } return success; } catch (Exception e) { e.printStackTrace(); log.error(e); return false; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/0000755000175000017500000000000011632407032032156 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/local/0000755000175000017500000000000011632407032033250 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/local/ClientCountTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/local/C0000644000175000017500000000620610433770344033370 0ustar twernertwernerpackage org.jboss.test.remoting.configuration.client.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 ClientCountTestCase extends TestCase { private String locatorUri = "socket://localhost:9999"; 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 void testClientConnection() throws Throwable { InvokerLocator locator = new InvokerLocator(locatorUri); Client client1 = new Client(locator); Client client2 = new Client(locator); Client client3 = new Client(locator); client1.connect(); client1.invoke("foobar"); try { client2.invoke("foobar"); assertTrue("Should have thrown exception instead of reaching this line.", false); } catch (Throwable throwable) { assertTrue(true); } client2.connect(); client2.invoke("foobar"); client1.disconnect(); try { client1.invoke("foobar"); assertTrue("Should have thrown exception instead of reaching this line.", false); } catch (Throwable throwable) { assertTrue(true); } client2.invoke("foobar"); client3.connect(); client3.invoke("foobar"); client3.disconnect(); try { client3.invoke("foobar"); assertTrue("Should have thrown exception instead of reaching this line.", false); } catch (Throwable throwable) { assertTrue(true); } client2.invoke("foobar"); client2.disconnect(); try { client2.invoke("foobar"); assertTrue("Should have thrown exception instead of reaching this line.", false); } catch (Throwable throwable) { assertTrue(true); } } 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 null; //TODO: -TME Implement } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/0000755000175000017500000000000011632407032033451 5ustar twernertwerner././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/ClientCountTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/0000644000175000017500000000261110433770344033462 0ustar twernertwerner/* * 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.configuration.client.remote; import org.jboss.jrunit.harness.TestDriver; /** * @author Tom Elrod */ public class ClientCountTestCase extends TestDriver { public void declareTestClasses() { addTestClasses(ClientCountTestClient.class.getName(), 1, ClientCountTestServer.class.getName()); } }././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/ClientPingCountTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/0000644000175000017500000000552410554540344033467 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.configuration.client.remote; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.ConnectionValidator; /** * @author Ovidiu Feodorov * @version $Revision: 1941 $ * $Id: ClientPingCountTestClient.java 1941 2007-01-21 01:24:52Z ovidiu $ */ public class ClientPingCountTestClient extends TestCase { // Constants ------------------------------------------------------------------------------------ // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- // Constructors --------------------------------------------------------------------------------- // Public --------------------------------------------------------------------------------------- public void testGetPingPeriodOnDisconnectedClient() throws Throwable { Client client = new Client(new InvokerLocator(ClientPingCountTestServer.locatorURI)); assertEquals(-1, client.getPingPeriod()); } public void testGetPingPeriodOnConnectedClient() throws Throwable { Client client = new Client(new InvokerLocator(ClientPingCountTestServer.locatorURI)); client.connect(); assertEquals(-1, client.getPingPeriod()); } public void testGetPingPeriodOnClientWithListener() throws Throwable { Client client = new Client(new InvokerLocator(ClientPingCountTestServer.locatorURI)); client.connect(); client.addConnectionListener(new ConnectionListener() { public void handleConnectionException(Throwable throwable, Client client) {} }); assertEquals(ConnectionValidator.DEFAULT_PING_PERIOD, client.getPingPeriod()); } public void testGetPingPeriodOnClientWithListener2() throws Throwable { Client client = new Client(new InvokerLocator(ClientPingCountTestServer.locatorURI)); client.connect(); client.addConnectionListener(new ConnectionListener() { public void handleConnectionException(Throwable throwable, Client client) {} }, 7865); assertEquals(7865, client.getPingPeriod()); } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/ClientCountTestClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/0000644000175000017500000000545210433770344033470 0ustar twernertwerner/* * 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.configuration.client.remote; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * @author Tom Elrod */ public class ClientCountTestClient extends TestCase { private String locatorUri = "socket://localhost:9999"; public void testClientConnection() throws Throwable { InvokerLocator locator = new InvokerLocator(locatorUri); Client client1 = new Client(locator); Client client2 = new Client(locator); Client client3 = new Client(locator); client1.connect(); client1.invoke("foobar"); try { client2.invoke("foobar"); assertTrue("Should have thrown exception instead of reaching this line.", false); } catch (Throwable throwable) { assertTrue(true); } client2.connect(); client2.invoke("foobar"); client1.disconnect(); try { client1.invoke("foobar"); assertTrue("Should have thrown exception instead of reaching this line.", false); } catch (Throwable throwable) { assertTrue(true); } client2.invoke("foobar"); client3.connect(); client3.invoke("foobar"); client3.disconnect(); try { client3.invoke("foobar"); assertTrue("Should have thrown exception instead of reaching this line.", false); } catch (Throwable throwable) { assertTrue(true); } client2.invoke("foobar"); client2.disconnect(); try { client2.invoke("foobar"); assertTrue("Should have thrown exception instead of reaching this line.", false); } catch (Throwable throwable) { assertTrue(true); } } }././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/ClientCountTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/0000644000175000017500000000554510433770344033473 0ustar twernertwerner/* * 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.configuration.client.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 ClientCountTestServer extends ServerTestCase { private String locatorUri = "socket://localhost:9999"; 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) { ClientCountTestServer server = new ClientCountTestServer(); try { server.setUp(); Thread.sleep(600000); } 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 null; //TODO: -TME Implement } public void addListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } public void removeListener(InvokerCallbackHandler callbackHandler) { //TODO: -TME Implement } } }././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/ClientPingCountTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/0000644000175000017500000000321410554540344033461 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.configuration.client.remote; import org.jboss.jrunit.harness.TestDriver; /** * @author Ovidiu Feodorov * @version $Revision: 1941 $ * $Id: ClientPingCountTestCase.java 1941 2007-01-21 01:24:52Z ovidiu $ */ public class ClientPingCountTestCase extends TestDriver { // Constants ------------------------------------------------------------------------------------ // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- // Constructors --------------------------------------------------------------------------------- // TestDriver overrides ------------------------------------------------------------------------- public void declareTestClasses() { addTestClasses(ClientPingCountTestClient.class.getName(), 1, ClientPingCountTestServer.class.getName()); } // Public --------------------------------------------------------------------------------------- // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/ClientPingCountTestServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/client/remote/0000644000175000017500000000356610554540344033473 0ustar twernertwerner/** * JBoss, Home of Professional Open Source * * Distributable under LGPL license. * See terms of license at gnu.org. */ package org.jboss.test.remoting.configuration.client.remote; import org.jboss.jrunit.extensions.ServerTestCase; import org.jboss.remoting.transport.Connector; /** * @author Ovidiu Feodorov * @version $Revision: 1941 $ * $Id: ClientPingCountTestServer.java 1941 2007-01-21 01:24:52Z ovidiu $ */ public class ClientPingCountTestServer extends ServerTestCase { // Constants ------------------------------------------------------------------------------------ public static String locatorURI = "socket://localhost:9999"; // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- private Connector connector; // Constructors --------------------------------------------------------------------------------- // Public --------------------------------------------------------------------------------------- // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected void setUp() throws Exception { connector = new Connector(locatorURI); connector.create(); connector.start(); super.setUp(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } super.tearDown(); } // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/OnewayThreadPoolForConfigurationTest.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/OnewayThreadPo0000644000175000017500000000400510356654466033534 0ustar twernertwerner/* * 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. */ /* * Created on Jan 3, 2006 */ package org.jboss.test.remoting.configuration; import org.jboss.util.threadpool.BasicThreadPool; /** * A TestOnewayThreadPool. * @author Ron Sigal * @version $Revision: 593 $ *

          * Copyright (c) 2005 *

          */ public class OnewayThreadPoolForConfigurationTest extends BasicThreadPool { /** * Create a new TestOnewayThreadPool. * * */ public OnewayThreadPoolForConfigurationTest() { // FIXME TestOnewayThreadPool constructor super(); } /** * Create a new TestOnewayThreadPool. * * @param arg0 */ public OnewayThreadPoolForConfigurationTest(String arg0) { // FIXME TestOnewayThreadPool constructor super(arg0); } /** * Create a new TestOnewayThreadPool. * * @param arg0 * @param arg1 */ public OnewayThreadPoolForConfigurationTest(String arg0, ThreadGroup arg1) { // FIXME TestOnewayThreadPool constructor super(arg0, arg1); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/LocatorURITestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/LocatorURITest0000644000175000017500000000437710433770344033470 0ustar twernertwerner/* * 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.configuration; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientInvoker; /** * @author Tom Elrod */ public class LocatorURITestCase extends TestCase { private Client remotingClient1; private Client remotingClient2; public void testLocatorURI() throws Exception { String locatorURI1 = "http://satellite:8080/ws4ee-encstyle-rpc"; String locatorURI2 = "http://satellite:8080/ws4ee-encstyle-doc"; remotingClient1 = new Client(new InvokerLocator(locatorURI1), "test"); remotingClient1.connect(); ClientInvoker clientInvoker1 = remotingClient1.getInvoker(); remotingClient2 = new Client(new InvokerLocator(locatorURI2), "test"); remotingClient2.connect(); ClientInvoker clientInvoker2 = remotingClient2.getInvoker(); assertNotSame("Client invokers should NOT be the same since have different locator uri.", clientInvoker1, clientInvoker2); } public void tearDown() { if(remotingClient1 != null) { remotingClient1.disconnect(); } if(remotingClient2 != null) { remotingClient2.disconnect(); } } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/RMIConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/RMIConfigurati0000644000175000017500000001210610433770344033454 0ustar twernertwerner/* * 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.configuration; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.net.InetAddress; /** * @author Tom Elrod */ public class RMIConfigurationTestCase extends TestCase { private String transport = "rmi"; private int serverPort = 6666; private int clientPort = 7777; private int registryPort = 8888; private String hostName = null; private String hostIP = null; private Connector connector = null; public void setUp() throws Exception { hostName = InetAddress.getLocalHost().getHostName(); hostIP = InetAddress.getLocalHost().getHostAddress(); connector = new Connector(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + registryPort + ""); buf.append("" + hostName + ""); buf.append("" + serverPort + ""); buf.append("" + hostIP + ""); buf.append("" + clientPort + ""); buf.append(""); buf.append(""); buf.append(" " + MockServerInvocationHandler.class.getName() + "\n"); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.start(); } public void testClientConfiguration() throws Exception { // make sure the client's view of the locator will be as configured ServerInvoker[] serverInvokers = InvokerRegistry.getServerInvokers(); if(serverInvokers != null && serverInvokers.length > 0) { InvokerLocator locator = serverInvokers[0].getLocator(); String locatorHost = locator.getHost(); int locatorPort = locator.getPort(); System.out.println("locator host = " + locatorHost); System.out.println("locator port = " + locatorPort); assertEquals(hostIP, locatorHost); assertEquals(clientPort, locatorPort); } // check for server bind port (assume is the server since no exception thrown before) boolean portAvailable = PortUtil.checkPort(serverPort, hostName); assertTrue(!portAvailable); portAvailable = PortUtil.checkPort(registryPort, hostName); assertTrue(!portAvailable); // make sure can call ont Client client = new Client(new InvokerLocator(transport + "://" + hostName + ":" + serverPort + "/?registryPort=" + registryPort)); client.connect(); String param = "foobar"; Object ret = null; try { ret = client.invoke(param); } catch(Throwable throwable) { throw new Exception("Call on server failed.", throwable); } assertEquals(param, ret); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { RMIConfigurationTestCase testCase = new RMIConfigurationTestCase(); try { testCase.setUp(); testCase.testClientConfiguration(); testCase.tearDown(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/HTTPConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/HTTPConfigurat0000644000175000017500000001214510433770344033436 0ustar twernertwerner/* * 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.configuration; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.net.InetAddress; /** * @author Tom Elrod */ public class HTTPConfigurationTestCase extends TestCase { private String transport = "http"; private int serverPort = 6666; private int clientPort = 7777; private String hostName = null; private String hostIP = null; private String path = "foo/bar"; private Connector connector = null; public void setUp() throws Exception { hostName = InetAddress.getLocalHost().getHostName(); hostIP = InetAddress.getLocalHost().getHostAddress(); connector = new Connector(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + hostName + ""); buf.append("" + serverPort + ""); buf.append("" + hostIP + ""); buf.append("" + clientPort + ""); buf.append("" + path + ""); buf.append(""); buf.append(""); buf.append(" " + MockServerInvocationHandler.class.getName() + "\n"); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); //connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.start(); } public void testClientConfiguration() throws Exception { // make sure the client's view of the locator will be as configured ServerInvoker[] serverInvokers = InvokerRegistry.getServerInvokers(); if(serverInvokers != null && serverInvokers.length > 0) { InvokerLocator locator = serverInvokers[0].getLocator(); String locatorHost = locator.getHost(); int locatorPort = locator.getPort(); String locatorURIString = locator.getLocatorURI(); System.out.println("locator host = " + locatorHost); System.out.println("locator port = " + locatorPort); System.out.println("locator uri = " + locatorURIString); assertEquals(hostIP, locatorHost); assertEquals(clientPort, locatorPort); } // check for server bind port (assume is the server since no exception thrown before) boolean portAvailable = PortUtil.checkPort(serverPort, hostName); assertTrue(!portAvailable); // make sure can call ont Client client = new Client(new InvokerLocator(transport + "://" + hostName + ":" + serverPort)); client.connect(); String param = "foobar"; Object ret = null; try { ret = client.invoke(param); } catch(Throwable throwable) { throwable.printStackTrace(); } assertEquals(param, ret); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { HTTPConfigurationTestCase testCase = new HTTPConfigurationTestCase(); try { testCase.setUp(); testCase.testClientConfiguration(); testCase.tearDown(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/CustomSocketConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/CustomSocketCo0000644000175000017500000000402710457460065033544 0ustar twernertwerner/* * 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.configuration; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.RemoteClientInvoker; import org.jboss.remoting.Remoting; import javax.net.SocketFactory; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class CustomSocketConfigurationTestCase extends TestCase { public void testCustomSocketConfig() throws Exception { SocketFactory factory = SocketFactory.getDefault(); System.out.println("Factory: " + factory); InvokerLocator locator = new InvokerLocator("sslsocket://localhost:9000"); Map config = new HashMap(); config.put(Remoting.CUSTOM_SOCKET_FACTORY, factory); Client client = new Client(locator, config); client.connect(); RemoteClientInvoker invoker = (RemoteClientInvoker) client.getInvoker(); SocketFactory invokerFactory = invoker.getSocketFactory(); assertEquals(factory, invokerFactory); } }././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/MiscellaneousParametersTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/MiscellaneousP0000644000175000017500000000630710356654573033574 0ustar twernertwerner/* * 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. */ /* * Created on Jan 3, 2006 */ package org.jboss.test.remoting.configuration; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.Connector; import junit.framework.TestCase; /** * A MiscellaneousParametersTestCase. * @author Ron Sigal * @version $Revision: 594 $ *

          * Copyright (c) 2005 *

          */ public class MiscellaneousParametersTestCase extends TestCase { protected static final Logger log = Logger.getLogger(MiscellaneousParametersTestCase.class); public void testMiscellaneousParameters() { boolean success = true; try { Connector connector = new Connector(); String onewayThreadPoolClassName = OnewayThreadPoolForConfigurationTest.class.getName(); String uri = "socket://localhost/?maxNumThreadsOneway=3&onewayThreadPool=" + onewayThreadPoolClassName; connector.setInvokerLocator(uri); connector.create(); connector.start(); ServerInvoker[] serverInvokers = InvokerRegistry.getServerInvokers(); if (serverInvokers == null || serverInvokers.length == 0) { log.error("no invoker created: " + uri); success = false; } ServerInvoker serverInvoker = serverInvokers[0]; int maxNumThreadsOneWay = serverInvoker.getMaxNumberOfOnewayThreads(); String returnedClassName = serverInvoker.getOnewayThreadPool().getClass().getName(); if (maxNumThreadsOneWay != 3) { log.error("maxNumThreadsOneWay (" + maxNumThreadsOneWay + ") != expected value (" + 3); success = false; } if (returnedClassName != onewayThreadPoolClassName) { log.error("onewayThreadPool (" + returnedClassName + ") != expected value (" + onewayThreadPoolClassName); success = false; } connector.stop(); connector.destroy(); assertTrue(success); } catch (Exception e) { e.printStackTrace(); log.error(e); fail(); } } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/SocketClientConfigurationTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/SocketClientCo0000644000175000017500000001260310630213620033471 0ustar twernertwerner/* * 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.configuration; import junit.framework.TestCase; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilderFactory; import java.io.ByteArrayInputStream; import java.net.InetAddress; /** * @author Tom Elrod */ public class SocketClientConfigurationTestCase extends TestCase { private String transport = "socket"; private int serverPort = 6666; private int clientPort = 7777; private String hostName = null; private String hostIP = null; private Connector connector = null; public void setUp() throws Exception { hostName = InetAddress.getLocalHost().getHostName(); hostIP = InetAddress.getLocalHost().getHostAddress(); connector = new Connector(); StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("1"); buf.append("303"); buf.append("304"); buf.append("60000"); buf.append("" + hostName + ""); buf.append("" + serverPort + ""); buf.append("" + hostIP + ""); buf.append("" + clientPort + ""); buf.append("false"); buf.append("200"); buf.append(""); buf.append(""); buf.append(" " + MockServerInvocationHandler.class.getName() + "\n"); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); //connector.setInvokerLocator(locator.getLocatorURI()); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.start(); Thread.currentThread().sleep(2000); } public void testClientConfiguration() throws Exception { // make sure the client's view of the locator will be as configured ServerInvoker[] serverInvokers = InvokerRegistry.getServerInvokers(); if(serverInvokers != null && serverInvokers.length > 0) { InvokerLocator locator = serverInvokers[0].getLocator(); String locatorHost = locator.getHost(); int locatorPort = locator.getPort(); System.out.println("locator host = " + locatorHost); System.out.println("locator port = " + locatorPort); assertEquals(hostIP, locatorHost); assertEquals(clientPort, locatorPort); } // check for server bind port (assume is the server since no exception thrown before) boolean portAvailable = PortUtil.checkPort(serverPort, hostName); assertTrue(!portAvailable); // make sure can call ont Client client = new Client(new InvokerLocator(transport + "://" + hostName + ":" + serverPort)); client.connect(); String param = "foobar"; Object ret = null; try { ret = client.invoke(param); } catch(Throwable throwable) { throw new Exception("Call on server failed.", throwable); } assertEquals(param, ret); } public void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { SocketClientConfigurationTestCase testCase = new SocketClientConfigurationTestCase(); try { testCase.setUp(); testCase.testClientConfiguration(); testCase.tearDown(); } catch(Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/ConfigOverridesLocatorTestCase.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/configuration/ConfigOverride0000644000175000017500000004374611413660476033560 0ustar twernertwerner/* * 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.configuration; 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.Remoting; 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.socket.MicroSocketClientInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * Unit test for JBREM-1124. * * @author Ron Sigal * @version $Rev$ *

          * Copyright Apr 19, 2009 *

          */ public class ConfigOverridesLocatorTestCase extends TestCase { private static Logger log = Logger.getLogger(ConfigOverridesLocatorTestCase.class); private static boolean firstTime = true; private static int LOCATOR_VALUE_CONNECTION_WAIT = 123; private static String LOCATOR_VALUE_CONNECTION_WAIT_STRING = "123"; private static int CONFIG_VALUE_CONNECTION_WAIT = 789; private static String CONFIG_VALUE_CONNECTION_WAIT_STRING = "789"; private static int LOCATOR_VALUE_BACKLOG = 321; private static String LOCATOR_VALUE_BACKLOG_STRING = "321"; private static int CONFIG_VALUE_BACKLOG = 987; private static String CONFIG_VALUE_BACKLOG_STRING = "987"; 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 testDefault() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, false, "", ""); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(LOCATOR_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(LOCATOR_VALUE_BACKLOG, serverInvoker.getBacklog()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLocatorNoneConfigFalse() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, true, "", "false"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); clientConfig.put(Remoting.CONFIG_OVERRIDES_LOCATOR, "false"); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(LOCATOR_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(LOCATOR_VALUE_BACKLOG, serverInvoker.getBacklog()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLocatorNoneConfigTrue() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(false, true, "", "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); clientConfig.put(Remoting.CONFIG_OVERRIDES_LOCATOR, "true"); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(CONFIG_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(CONFIG_VALUE_BACKLOG, serverInvoker.getBacklog()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLocatorFalseConfigNone() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, false, "false", ""); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); clientConfig.put(Remoting.CONFIG_OVERRIDES_LOCATOR, "true"); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(LOCATOR_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(LOCATOR_VALUE_BACKLOG, serverInvoker.getBacklog()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLocatorFalseConfigFalse() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true, "false", "false"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); clientConfig.put(Remoting.CONFIG_OVERRIDES_LOCATOR, "false"); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(LOCATOR_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(LOCATOR_VALUE_BACKLOG, serverInvoker.getBacklog()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLocatorFalseConfigTrue() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true, "false", "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); clientConfig.put(Remoting.CONFIG_OVERRIDES_LOCATOR, "true"); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(LOCATOR_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(LOCATOR_VALUE_BACKLOG, serverInvoker.getBacklog()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLocatorTrueConfigNone() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, false, "true", ""); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(CONFIG_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(CONFIG_VALUE_BACKLOG, serverInvoker.getBacklog()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLocatorTrueConfigFalse() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true, "true", "false"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); clientConfig.put(Remoting.CONFIG_OVERRIDES_LOCATOR, "false"); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(CONFIG_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(CONFIG_VALUE_BACKLOG, serverInvoker.getBacklog()); client.disconnect(); shutdownServer(); log.info(getName() + " PASSES"); } public void testLocatorTrueConfigTrue() throws Throwable { log.info("entering " + getName()); // Start server. setupServer(true, true, "true", "true"); // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); HashMap clientConfig = new HashMap(); clientConfig.put(InvokerLocator.FORCE_REMOTE, "true"); clientConfig.put(MicroSocketClientInvoker.CONNECTION_WAIT, CONFIG_VALUE_CONNECTION_WAIT_STRING); clientConfig.put(Remoting.CONFIG_OVERRIDES_LOCATOR, "true"); addExtraClientConfig(clientConfig); log.info("client config: " + 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"); //Test configuration. MicroSocketClientInvoker clientInvoker = (MicroSocketClientInvoker) client.getInvoker(); SocketServerInvoker serverInvoker = (SocketServerInvoker) connector.getServerInvoker(); assertEquals(CONFIG_VALUE_CONNECTION_WAIT, clientInvoker.getConnectionWait()); assertEquals(CONFIG_VALUE_BACKLOG, serverInvoker.getBacklog()); 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(boolean addToLocator, boolean addToConfig, String locatorValue, String configValue) throws Exception { host = InetAddress.getLocalHost().getHostAddress(); port = PortUtil.findFreePort(host); locatorURI = getTransport() + "://" + host + ":" + port + "/?" + MicroSocketClientInvoker.CONNECTION_WAIT + "=" + LOCATOR_VALUE_CONNECTION_WAIT_STRING; String metadata = System.getProperty("remoting.metadata"); if (metadata != null) { locatorURI += "&" + metadata; } locatorURI += "&" + "backlog=" + LOCATOR_VALUE_BACKLOG_STRING; if (addToLocator) { locatorURI += "&" + Remoting.CONFIG_OVERRIDES_LOCATOR + "=" + locatorValue; } 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("backlog", CONFIG_VALUE_BACKLOG_STRING); addExtraServerConfig(config); if (addToConfig) { config.put(Remoting.CONFIG_OVERRIDES_LOCATOR, configValue); } log.info("server config: " + 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"); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/template/0000755000175000017500000000000011632407044027647 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/template/TestCaseTemplate.javalibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/remoting/template/TestCaseTemplate.ja0000644000175000017500000001243611413660476033407 0ustar twernertwerner/* * 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.template; 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.transport.Connector; import org.jboss.remoting.transport.PortUtil; public class TestCaseTemplate extends TestCase { private static Logger log = Logger.getLogger(TestCaseTemplate.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 testMethod() 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 connection. assertEquals("abc", client.invoke("abc")); log.info("connection is good"); 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 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"); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/security/0000755000175000017500000000000011632407044026057 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/tests/org/jboss/test/security/LoggingSecurityManager.java0000644000175000017500000001466611413660476033357 0ustar twernertwernerpackage org.jboss.test.security; import java.security.Permission; import java.io.FileDescriptor; import java.net.InetAddress; /** * */ public final class LoggingSecurityManager extends SecurityManager { public LoggingSecurityManager() { } private static SecurityException logged(SecurityException se) { se.printStackTrace(System.err); return se; } public void checkPermission(final Permission perm) { try { super.checkPermission(perm); } catch (SecurityException se) { throw logged(se); } } public void checkPermission(final Permission perm, final Object context) { try { super.checkPermission(perm, context); } catch (SecurityException se) { throw logged(se); } } public void checkCreateClassLoader() { try { super.checkCreateClassLoader(); } catch (SecurityException se) { throw logged(se); } } public void checkAccess(final Thread t) { try { super.checkAccess(t); } catch (SecurityException se) { throw logged(se); } } public void checkAccess(final ThreadGroup g) { try { super.checkAccess(g); } catch (SecurityException se) { throw logged(se); } } public void checkExit(final int status) { try { super.checkExit(status); } catch (SecurityException se) { throw logged(se); } } public void checkExec(final String cmd) { try { super.checkExec(cmd); } catch (SecurityException se) { throw logged(se); } } public void checkLink(final String lib) { try { super.checkLink(lib); } catch (SecurityException se) { throw logged(se); } } public void checkRead(final FileDescriptor fd) { try { super.checkRead(fd); } catch (SecurityException se) { throw logged(se); } } public void checkRead(final String file) { try { super.checkRead(file); } catch (SecurityException se) { throw logged(se); } } public void checkRead(final String file, final Object context) { try { super.checkRead(file, context); } catch (SecurityException se) { throw logged(se); } } public void checkWrite(final FileDescriptor fd) { try { super.checkWrite(fd); } catch (SecurityException se) { throw logged(se); } } public void checkWrite(final String file) { try { super.checkWrite(file); } catch (SecurityException se) { throw logged(se); } } public void checkDelete(final String file) { try { super.checkDelete(file); } catch (SecurityException se) { throw logged(se); } } public void checkConnect(final String host, final int port) { try { super.checkConnect(host, port); } catch (SecurityException se) { throw logged(se); } } public void checkConnect(final String host, final int port, final Object context) { try { super.checkConnect(host, port, context); } catch (SecurityException se) { throw logged(se); } } public void checkListen(final int port) { try { super.checkListen(port); } catch (SecurityException se) { throw logged(se); } } public void checkAccept(final String host, final int port) { try { super.checkAccept(host, port); } catch (SecurityException se) { throw logged(se); } } public void checkMulticast(final InetAddress maddr) { try { super.checkMulticast(maddr); } catch (SecurityException se) { throw logged(se); } } /** @noinspection deprecation*/ public void checkMulticast(final InetAddress maddr, final byte ttl) { try { super.checkMulticast(maddr, ttl); } catch (SecurityException se) { throw logged(se); } } public void checkPropertiesAccess() { try { super.checkPropertiesAccess(); } catch (SecurityException se) { throw logged(se); } } public void checkPropertyAccess(final String key) { try { super.checkPropertyAccess(key); } catch (SecurityException se) { throw logged(se); } } public boolean checkTopLevelWindow(final Object window) { try { return super.checkTopLevelWindow(window); } catch (SecurityException se) { throw logged(se); } } public void checkPrintJobAccess() { try { super.checkPrintJobAccess(); } catch (SecurityException se) { throw logged(se); } } public void checkSystemClipboardAccess() { try { super.checkSystemClipboardAccess(); } catch (SecurityException se) { throw logged(se); } } public void checkAwtEventQueueAccess() { try { super.checkAwtEventQueueAccess(); } catch (SecurityException se) { throw logged(se); } } public void checkPackageAccess(final String pkg) { try { super.checkPackageAccess(pkg); } catch (SecurityException se) { throw logged(se); } } public void checkPackageDefinition(final String pkg) { try { super.checkPackageDefinition(pkg); } catch (SecurityException se) { throw logged(se); } } public void checkSetFactory() { try { super.checkSetFactory(); } catch (SecurityException se) { throw logged(se); } } public void checkMemberAccess(final Class clazz, final int which) { try { super.checkMemberAccess(clazz, which); } catch (SecurityException se) { throw logged(se); } } public void checkSecurityAccess(final String target) { try { super.checkSecurityAccess(target); } catch (SecurityException se) { throw logged(se); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/0000755000175000017500000000000011632407044021104 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/0000755000175000017500000000000011632407044021673 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/0000755000175000017500000000000011632407044023013 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/0000755000175000017500000000000011632407052024636 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ServerInvoker.java0000644000175000017500000023443311422064466030323 0ustar twernertwerner/* * 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.remoting; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.invocation.InternalInvocation; import org.jboss.remoting.invocation.OnewayInvocation; import org.jboss.remoting.loading.ClassBytes; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.ServerSocketFactoryWrapper; import org.jboss.remoting.socketfactory.CreationListenerServerSocketFactory; import org.jboss.remoting.socketfactory.SocketCreationListener; import org.jboss.remoting.stream.StreamHandler; import org.jboss.remoting.stream.StreamInvocationHandler; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.util.SecurityUtility; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.util.threadpool.BasicThreadPool; import org.jboss.util.threadpool.BlockingMode; import org.jboss.util.threadpool.ThreadPool; import org.jboss.util.threadpool.ThreadPoolMBean; import org.jboss.logging.Logger; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; import javax.management.MBeanServer; import javax.management.MBeanServerInvocationHandler; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import java.io.IOException; import java.lang.reflect.Constructor; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; /** * ServerInvoker is the server-side part of a remote Invoker. The ServerInvoker implementation is * responsible for calling transport, depending on how the protocol receives the incoming data. * * @author Jeff Haynie * @author Tom Elrod * @author Ovidiu Feodorov * * @version $Revision: 5919 $ */ public abstract class ServerInvoker extends AbstractInvoker implements ServerInvokerMBean { // Constants ------------------------------------------------------------------------------------ protected static final Logger log = Logger.getLogger(ServerInvoker.class); /** * Key for the the maximum number of threads to be used in the thread pool for one way * invocations (server side). * This property is only used when the default oneway thread pool is used. */ public static final String MAX_NUM_ONEWAY_THREADS_KEY = "maxNumThreadsOneway"; /** * Key for setting the setting the oneway thread pool to use. * The value used with this key will first be checked to see if is a JMX ObjectName and if so, * try to look up associated mbean for the ObjectName given and cast to type * org.jboss.util.threadpool.ThreadPoolMBean * (via MBeanServerInvocationHandler.newProxyInstance()). If the value is not a JMX ObjectName, * will assume is a fully qualified classname and load the coresponding class and create a new * instance of it (which will require it to have a void constructor). The newly created instance * will then be cast to type of org.jboss.util.threadpool.ThreadPool. */ public static final String ONEWAY_THREAD_POOL_CLASS_KEY = "onewayThreadPool"; /** * Key for setting the address the server invoker should bind to. * The value can be either host name or IP. */ public static final String SERVER_BIND_ADDRESS_KEY = "serverBindAddress"; /** * Key for setting the addres the client invoker should connecto to. * This should be used when client will be connecting to server from outside the server's network * and the external address is different from that of the internal address the server invoker * will bind to (e.g. using NAT to expose different external address). This will mostly be useful * when client uses remoting detection to discover remoting servers. The value can be either host * name or IP. */ public static final String CLIENT_CONNECT_ADDRESS_KEY = "clientConnectAddress"; /** * Key for setting the port the server invoker should bind to. * If the value supplied is less than or equal to zero, the server invoker will randomly choose * a free port to use. */ public static final String SERVER_BIND_PORT_KEY = "serverBindPort"; /** * key for setting the port the client invoker should connect to. * This should be used when client will be connecting to server from outside the server's network * and the external port is different from that of the internal port the server invoker will bind * to (e.g. using NAT to expose different port routing). This will be mostly useful when client * uses remoting detection to discover remoting servers. */ public static final String CLIENT_CONNECT_PORT_KEY = "clientConnectPort"; /** * Key used for setting the amount of time (in milliseconds) that a client should renew its * lease. * If this value is not set, the default of five seconds (see DEFAULT_CLIENT_LEASE_PERIOD), will * be used. This value will also be what is given to the client when it initially querys server * for leasing information. */ public static final String CLIENT_LEASE_PERIOD = "clientLeasePeriod"; /** * Key for setting the timeout value (in milliseconds) for socket connections. */ public static final String TIMEOUT = "timeout"; /** * Key for setting the value for the server socket factory to be used by the server invoker. * The value can be either a JMX Object name, in which case will lookup the mbean and create * a proxy to it with type of org.jboss.remoting.security.ServerSocketFactoryMBean * (via MBeanServerInvocationHandler.newProxyInstance()). If not a JMX ObjectName, will assume * is the fully qualified classname to the implementation to be used and will load the class, * create a new instance of it (which requires it to have a void constructor). The instance will * then be cast to type javax.net.ServerSocketFactory. */ public static final String SERVER_SOCKET_FACTORY = "serverSocketFactory"; /** * The max number of worker threads to be used in the pool for processing one way calls on the * server side. Value is is 100. */ public static final int MAX_NUM_ONEWAY_THREADS = 100; /** * Key for the configuration map that determines the queue size for waiting asynchronous * invocations. */ public static final String MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE = "maxOnewayThreadPoolQueueSize"; /** * The default lease period for clients. This is the number of milliseconds that a client will be * required to renew their lease with the server. The default value is 5 seconds. */ public static final int DEFAULT_CLIENT_LEASE_PERIOD = 5000; /** * The default timeout period for socket connections. The default value is 60000 milliseconds. */ public static final int DEFAULT_TIMEOUT_PERIOD = 60000; /** * The key to be used to determine if pull callbacks should be obtained in * blocking or nonblocking mode */ public static final String BLOCKING_MODE = "blockingMode"; /** * The key value to use to specify timeout for getting callbacks in blocking mode */ public static final String BLOCKING_TIMEOUT = "blockingTimeout"; /** * The value associated with BLOCKING_MODE that indicates that pull callbacks * should be obtained in blocking mode; */ public static final String BLOCKING = "blocking"; /** * The value associated with BLOCKING_MODE that indicates that pull callbacks * should be obtained in nonblocking mode; */ public static final String NONBLOCKING = "nonblocking"; /** * Default timeout for getting callbacks in blocking mode. * Default is 5000 milliseconds. */ public static final int DEFAULT_BLOCKING_TIMEOUT = 5000; /** * The key to use to specify if ServerInvokerCallbackHandlers should be * registered as ConnectionListeners. */ public static final String REGISTER_CALLBACK_LISTENER = "registerCallbackListener"; public static final String ECHO = "$ECHO$"; public static final String INVOKER_SESSION_ID = "invokerSessionId"; public static final String CONNECTION_LISTENER = "connectionListener"; // Static --------------------------------------------------------------------------------------- private static boolean trace = log.isTraceEnabled(); private static final InetAddress LOCAL_HOST; static { try { LOCAL_HOST = (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } }); } catch (PrivilegedActionException e) { log.debug(ServerInvoker.class.getName() + " unable to get local host address", e.getCause()); throw new ExceptionInInitializerError(e.getCause()); } catch (SecurityException e) { log.debug(ServerInvoker.class.getName() + " unable to get local host address", e); throw e; } } // Attributes ----------------------------------------------------------------------------------- /** * Indicated the max number of threads used within oneway thread pool. */ private int maxNumberThreads = MAX_NUM_ONEWAY_THREADS; private int maxOnewayThreadPoolQueueSize = -1; private String onewayThreadPoolClass = null; private ThreadPool onewayThreadPool; private Object onewayThreadPoolLock = new Object(); private boolean created = false; private MBeanServer mbeanServer = null; private String dataType; private String serverBindAddress = null; private int serverBindPort = 0; private String clientConnectAddress = null; private int clientConnectPort = -1; protected List connectHomes = new ArrayList(); protected List homes = new ArrayList(); private int timeout = DEFAULT_TIMEOUT_PERIOD; // indicates the lease timeout period for clients private long leasePeriod = DEFAULT_CLIENT_LEASE_PERIOD; private boolean leaseManagement = false; private Map clientLeases = new ConcurrentHashMap(); protected Map handlers = new HashMap(); // If there is only one handler we store a direct reference to it, as an optimisation // to avoid lookup in this common case - TLF protected volatile ServerInvocationHandler singleHandler; // If there is only one callback container we store a direct reference to it, as an optimisation // to avoid lookup in this common case - TLF protected volatile CallbackContainer singleCallbackContainer; protected Map callbackHandlers = new HashMap(); protected Map clientCallbackListener = new HashMap(); protected boolean started = false; protected ConnectionNotifier connectionNotifier = new ConnectionNotifier(); protected ServerSocketFactory serverSocketFactory = null; protected boolean registerCallbackListeners = true; protected boolean useClientConnectionIdentity; // Constructors --------------------------------------------------------------------------------- public ServerInvoker(InvokerLocator locator) { super(locator); Map params = locator.getParameters(); if(configuration != null && params != null) { configuration.putAll(locator.getParameters()); } } public ServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } // Public --------------------------------------------------------------------------------------- public void setServerSocketFactory(ServerSocketFactory serverSocketFactory) { this.serverSocketFactory = serverSocketFactory; } public ServerSocketFactory getServerSocketFactory() { return serverSocketFactory; } /** * Sets timeout (in millseconds) to be used for the socket connection. */ public void setTimeout(int timeout) { this.timeout = timeout; } /** * The timeout (in milliseconds) used for the socket connection. */ public int getTimeout() { return timeout; } public ConnectionNotifier getConnectionNotifier() { return connectionNotifier; } public boolean isLeaseActivated() { return leaseManagement; } public void addConnectionListener(ConnectionListener listener) { if(listener != null) { connectionNotifier.addListener(listener); if(leasePeriod > 0) { leaseManagement = true; } } else { throw new IllegalArgumentException("Can not add null ConnectionListener."); } } public void setConnectionListener(Object listener) { if (listener == null) { log.error("ConnectionListener is null"); return; } if (listener instanceof ConnectionListener) { addConnectionListener((ConnectionListener) listener); return; } if (!(listener instanceof String)) { log.error("Object supplied as ConnectionListener is neither String nor ConnectionListener"); return; } ConnectionListener connectionListener = null; try { MBeanServer server = getMBeanServer(); ObjectName objName = new ObjectName((String) listener); Class c = ConnectionListener.class; Object o = MBeanServerInvocationHandler.newProxyInstance(server, objName, c, false); connectionListener = (ConnectionListener) o; } catch (MalformedObjectNameException e) { log.debug("Object supplied as ConnectionListener is not an object name."); } if (connectionListener == null) { try { Class listenerClass = ClassLoaderUtility.loadClass((String) listener, ServerInvoker.class); connectionListener = (ConnectionListener) listenerClass.newInstance(); } catch (Exception e) { log.error("Unable to instantiate " + listener + ": " + e.getMessage()); return; } } if (connectionListener == null) { log.error("Unable to create ConnectionListener from " + listener); return; } addConnectionListener(connectionListener); } public void removeConnectionListener(ConnectionListener listener) { if(connectionNotifier != null) { connectionNotifier.removeListener(listener); // turn off lease management if no listeners (since no one to tell client died) if(connectionNotifier.size() == 0) { leaseManagement = false; // go through any existing leases and terminate them Set clientKeys = clientLeases.keySet(); Iterator itr = clientKeys.iterator(); while(itr.hasNext()) { String sessionId = (String)itr.next(); Lease clientLease = (Lease)clientLeases.get(sessionId); clientLease.terminateLease(sessionId); } clientLeases.clear(); } } } /** * Sets the amount of time (in milliseconds) that a client should renew its lease. If this value * is not set, the default of five seconds (see DEFAULT_CLIENT_LEASE_PERIOD), will be used. This * value will also be what is given to the client when it initially querys server for leasing * information. If set after create() method called, this value will override value set by * CLIENT_LEASE_PERIOD key. */ public void setLeasePeriod(long leasePeriodValue) { this.leasePeriod = leasePeriodValue; if (leasePeriod <= 0) { this.leaseManagement = false; } else { if(connectionNotifier != null && connectionNotifier.size() > 0) { this.leaseManagement = true; } } } public Lease getLease(String sessionId) { return (Lease) clientLeases.get(sessionId); } /** * Gets the amount of time (in milliseconds) that a client should renew its lease. */ public long getLeasePeriod() { return leasePeriod; } /** * @jmx:managed-attribute */ public String getClientConnectAddress() { return clientConnectAddress; } public int getClientConnectPort() { return clientConnectPort; } public void setClientConnectPort(int clientConnectPort) { this.clientConnectPort = clientConnectPort; } /** * This method should only be called by the service controller when this invoker is specified * within the Connector configuration of a service xml. Calling this directly will have no * effect, as will be used in building the locator uri that is published for detection and this * happens when the invoker is first created and started (after that, no one will be aware of a * change). * * @jmx:managed-attribute */ public void setClientConnectAddress(String clientConnectAddress) { this.clientConnectAddress = clientConnectAddress; } public String getServerBindAddress() { return serverBindAddress; } public int getServerBindPort() { return serverBindPort; } public List getConnectHomes() { return new ArrayList(connectHomes); } public void setConnectHomes(List connectHomes) { this.connectHomes = new ArrayList(connectHomes); } public List getHomes() { return new ArrayList(homes); } public void setHomes(List homes) { this.homes = new ArrayList(homes); } /** * Sets the maximum number of thread to be used in the thread pool for one way invocations * (server side). This property is only used when the default oneway thread pool is used. If set * after create() method called, this value will override value set by MAX_NUM_ONEWAY_THREADS_KEY * key. */ public void setMaxNumberOfOnewayThreads(int numOfThreads) { this.maxNumberThreads = numOfThreads; } /** * Gets the maximum number of thread to be used in the thread pool for one way invocations * (server side). */ public int getMaxNumberOfOnewayThreads() { return this.maxNumberThreads; } /** * Gets the oneway thread pool to use. */ public ThreadPool getOnewayThreadPool() { synchronized (onewayThreadPoolLock) { if(onewayThreadPool == null) { // if no thread pool class set, then use default BasicThreadPool if(onewayThreadPoolClass == null || onewayThreadPoolClass.length() == 0) { BasicThreadPool pool = new BasicThreadPool("JBossRemoting Server Oneway"); pool.setMaximumPoolSize(maxNumberThreads); if (maxOnewayThreadPoolQueueSize > 0) pool.setMaximumQueueSize(maxOnewayThreadPoolQueueSize); pool.setBlockingMode(BlockingMode.RUN); onewayThreadPool = pool; log.debug(this + " created new thread pool"); } else { //first check to see if this is an ObjectName boolean isObjName = false; try { ObjectName objName = new ObjectName(onewayThreadPoolClass); onewayThreadPool = createThreadPoolProxy(objName); isObjName = true; } catch(MalformedObjectNameException e) { log.debug("Thread pool class supplied is not an object name."); } if(!isObjName) { try { onewayThreadPool = (ThreadPool)Class. forName(onewayThreadPoolClass, false, getClassLoader()).newInstance(); } catch(Exception e) { throw new RuntimeException("Error loading instance of ThreadPool based " + "on class name " + onewayThreadPoolClass); } } } } else { log.trace("reusing oneway thread pool"); } return onewayThreadPool; } } /** * Sets the oneway thread pool to use. */ public void setOnewayThreadPool(ThreadPool pool) { this.onewayThreadPool = pool; } public MBeanServer getMBeanServer() { return mbeanServer; } public void setMBeanServer(MBeanServer server) { // This has been added in order to support mbean service configuration. Now supporting // classes, such as the ServerInvokerCallbackHandler can find and use resources such as // CallbackStore, which can be run as a service mbean (and specified via object name within // config). The use of JMX throughout remoting is a problem as now have to tie it in all // throughout the code for service configuration as is being done here. When migrate to use // under new server model, which does not depend on JMX, can rip out code such as this. this.mbeanServer = server; } public boolean isRegisterCallbackListeners() { return registerCallbackListeners; } public void setRegisterCallbackListeners(boolean registerCallbackListeners) { this.registerCallbackListeners = registerCallbackListeners; } /** * @return true if a server invocation handler has been registered for this subsystem. */ public synchronized boolean hasInvocationHandler(String subsystem) { return handlers.containsKey(subsystem); } /** * @return an array of keys for each subsystem this invoker can handle. */ public synchronized String[] getSupportedSubsystems() { String subsystems [] = new String[handlers.size()]; return (String[]) handlers.keySet().toArray(subsystems); } /** * @return an array of the server invocation handlers. */ public synchronized ServerInvocationHandler[] getInvocationHandlers() { ServerInvocationHandler ih [] = new ServerInvocationHandler[handlers.size()]; return (ServerInvocationHandler[]) handlers.values().toArray(ih); } /** * Add a server invocation handler for a particular subsystem. Typically, subsystems are defined * in org.jboss.remoting.Subsystem, however, this can be any string that the caller knows about. * * @return previous ServerInvocationHandler with the same sybsystem value (case insensitive) or * null if a previous one did not exist. */ public synchronized ServerInvocationHandler addInvocationHandler(String subsystem, ServerInvocationHandler handler) { handler.setInvoker(this); ServerInvocationHandler oldHandler = (ServerInvocationHandler)handlers.put(subsystem.toUpperCase(), handler); log.debug(this + " added " + handler + " for subsystem '" + subsystem + "'" + (oldHandler == null ? "" : ", replacing old handler " + oldHandler)); if (handlers.size() == 1) { singleHandler = handler; } else { singleHandler = null; } return oldHandler; } /** * Remove a subsystem invocation handler. */ public synchronized ServerInvocationHandler removeInvocationHandler(String subsystem) { ServerInvocationHandler handler = (ServerInvocationHandler)handlers.remove(subsystem.toUpperCase()); log.debug(this + (handler == null ? " tried to remove handler for " + subsystem + " but no handler found" : " removed handler " + handler + " for subsystem '" + subsystem + "'")); if (handlers.size() == 1) { singleHandler = (ServerInvocationHandler)handlers.values().iterator().next(); } else { singleHandler = null; } return handler; } /** * Get a ServerInvocationHandler for a given subsystem type. */ public synchronized ServerInvocationHandler getInvocationHandler(String subsystem) { return (ServerInvocationHandler) handlers.get(subsystem.toUpperCase()); } protected boolean isUseClientConnectionIdentity() { return useClientConnectionIdentity; } protected void setUseClientConnectionIdentity(boolean useClientConnectionIdentity) { this.useClientConnectionIdentity = useClientConnectionIdentity; } public Object invoke(Object invoke) throws IOException { InvocationRequest request = null; InvocationResponse response = null; if(trace) { log.trace("server received invocation " + invoke); } if(invoke != null && invoke instanceof InvocationRequest) { request = (InvocationRequest) invoke; try { Object result = invoke(request); response = new InvocationResponse(request.getSessionId(), result, false, request.getReturnPayload()); } catch(Throwable throwable) { response = new InvocationResponse(request.getSessionId(), throwable, true, request.getReturnPayload()); } } else { log.error("server invoker received " + invoke + " as invocation. " + "Must not be null and must be of type InvocationRequest."); Exception e = new Exception("Error processing invocation request on " + getLocator() + ". Either invocation was null or of wrong type."); response = new InvocationResponse(request.getSessionId(), e, true, request.getReturnPayload()); } return response; } /** * Processes invocation request depending on the invocation type (internal, name based, oneway, * etc). Can be called on directly when client and server are local to one another (by-passing * serialization). */ public Object invoke(InvocationRequest invocation) throws Throwable { if (isStarted()) { Object param = invocation.getParameter(); Object result = null; if (trace) { log.trace(this + " received " + param); } if (ECHO.equals(param)) { return ECHO; } if (param instanceof String) { // check to see if this is a is alive ping if ("$PING$".equals(param)) { Map metadata = invocation.getRequestPayload(); if (metadata != null) { String invokerSessionId = (String) metadata.get(INVOKER_SESSION_ID); if (invokerSessionId != null) { // Comes from ConnectionValidator configured to tie validation with lease. boolean response = checkForClientLease(invokerSessionId); if (trace) log.trace(this + " responding " + response + " to $PING$ for invoker sessionId " + invokerSessionId); return new Boolean(response); } } if (leaseManagement) { // Otherwise, it's a normal PING. NOTE we only update the lease when we // receive a PING, not for all invocations. updateClientLease(invocation); } // if this is an invocation ping, just pong back Map responseMap = new HashMap(); responseMap.put(CLIENT_LEASE_PERIOD, new Long(leasePeriod)); InvocationResponse ir = new InvocationResponse(invocation.getSessionId(), new Boolean(leaseManagement), false, responseMap); if (trace) { log.trace(this + " returning " + ir); } return ir; } if ("$GET_CLIENT_LOCAL_ADDRESS$".equals(param)) { InetAddress address = null; if (invocation.getRequestPayload() != null) address = (InetAddress) invocation.getRequestPayload().get(Remoting.CLIENT_ADDRESS); return address; } if ("$DISCONNECT$".equals(param)) { if (leaseManagement) { terminateLease(invocation); } if (trace) { log.trace(this + " returning null"); } return null; } } //TODO: -TME both oneway and internal invocation will be broken since have not // deserialized the para yet (removed ClassUtil.deserialize() so would let handler do it). if (param instanceof OnewayInvocation) { // no point in delaying return to client if oneway handleOnewayInvocation((OnewayInvocation)param, invocation); return null; } else { String subsystem = invocation.getSubsystem(); String clientId = invocation.getSessionId(); //I have optimised this, so that if there is only one handler set (a very common case) //then it will just use that without having to do a lookup or HashMap iteration over //values ServerInvocationHandler handler = findInvocationHandler(subsystem); if (param instanceof InternalInvocation) { result = handleInternalInvocation((InternalInvocation)param, invocation, handler); } else { if (trace) { log.trace(this + " dispatching " + invocation + " from client " + clientId + " to subsystem '" + subsystem + "'"); } if (handler == null) { throw new InvalidConfigurationException( "Can not handle invocation request for subsystem '" + subsystem + "' because " + "there are no matching ServerInvocationHandlers registered. Please add via " + "xml configuration or via the Connector's addInvocationHandler() method."); } result = handler.invoke(invocation); } if (trace) { log.trace(this + " successfully dispatched invocation, returning " + result + " from subsystem '" + subsystem + "' to client " + clientId); } } return result; } else { log.warn(this + " can not process invocation requests since is not in started state!"); throw new InvalidStateException( "Can not process invocation request since is not in started state."); } } /** * Will get the data type for the marshaller factory so know which marshaller to get to marshal * the data. Will first check the locator uri for a 'datatype' parameter and take that value if * it exists. Otherwise, will use the default datatype for the client invoker, based on * transport. */ public String getDataType() { if(dataType == null) { dataType = getDataType(getLocator()); if(dataType == null) { dataType = getDefaultDataType(); } } return dataType; } public void create() { if(!created) { try { setup(); } catch(Exception e) { throw new RuntimeException("Error setting up server invoker " + this, e); } created = true; } } /** * Subclasses should override to provide any specific start logic. */ public void start() throws IOException { started = true; log.debug(this + " started for locator " + getLocator()); } /** * @return true if the server invoker is started, false if not. */ public boolean isStarted() { return started; } /** * Subclasses should override to provide any specific stop logic. */ public void stop() { started = false; for(Iterator i = callbackHandlers.values().iterator(); i.hasNext(); ) { ServerInvokerCallbackHandler callbackHandler = (ServerInvokerCallbackHandler)i.next(); callbackHandler.destroy(); } log.debug(this + " stopped"); } /** * Destory the invoker permanently. */ public void destroy() { if(classbyteloader != null) { classbyteloader.destroy(); } } /** * Sets the server invoker's transport specific configuration. Will need to set before calling * start() method (or at least stop() and start() again) before configurations will take affect. */ public void setConfiguration(Map configuration) { this.configuration = configuration; } /** * Gets the server invoker's transport specific configuration. */ public Map getConfiguration() { return configuration; } public void removeCallbackListener(String subsystem, InvokerCallbackHandler callbackHandler) { ServerInvocationHandler handler = null; if(subsystem != null) { handler = (ServerInvocationHandler) handlers.get(subsystem.toUpperCase()); } else { // subsystem not specified, so will hope for a default one being set if(!handlers.isEmpty()) { handler = (ServerInvocationHandler) handlers.values().iterator().next(); } } handler.removeListener(callbackHandler); } /** * @return the String for the object name to be used for the invoker. */ public String getMBeanObjectName() { InvokerLocator locator = getLocator(); StringBuffer buffer = new StringBuffer("jboss.remoting:service=invoker,transport=" + locator.getProtocol()); String host = locator.getHost(); boolean isIPv6 = host.indexOf("[") >= 0 | host.indexOf(":") >= 0; buffer.append(",host="); if (isIPv6) buffer.append("\""); buffer.append(locator.getHost()); if (isIPv6) buffer.append("\""); buffer.append(",port=").append(locator.getPort()); Map param = locator.getParameters(); if(param != null) { Iterator itr = param.keySet().iterator(); while(itr.hasNext()) { buffer.append(","); String key = (String) itr.next(); String value = (String) param.get(key); buffer.append(key); buffer.append("="); buffer.append(value); } } return buffer.toString(); } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected abstract String getDefaultDataType(); protected void setup() throws Exception { Map config = getConfiguration(); PortUtil.updateRange(config); setupHomes(config); String maxNumOfThreads = (String)config.get(MAX_NUM_ONEWAY_THREADS_KEY); if(maxNumOfThreads != null && maxNumOfThreads.length() > 0) { try { maxNumberThreads = Integer.parseInt(maxNumOfThreads); } catch(NumberFormatException e) { log.error("Can not convert max number of threads value (" + maxNumOfThreads + ") into a number."); } } String param = (String) configuration.get(MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE); if (param != null && param.length() > 0) { try { maxOnewayThreadPoolQueueSize = Integer.parseInt((String) param); } catch (NumberFormatException e) { log.error("maxOnewayThreadPoolQueueSize parameter has invalid format: " + param); } } onewayThreadPoolClass = (String)config.get(ONEWAY_THREAD_POOL_CLASS_KEY); // get timeout config String timeoutPeriod = (String)config.get(TIMEOUT); if(timeoutPeriod != null && timeoutPeriod.length() > 0) { try { timeout = Integer.parseInt(timeoutPeriod); } catch(NumberFormatException e) { throw new InvalidConfigurationException("Can not set timeout because can not " + "convert give value (" + timeoutPeriod + ") to a number."); } } // config for client lease period String clientLeasePeriod = (String)config.get(CLIENT_LEASE_PERIOD); if(clientLeasePeriod != null) { try { long leasePeriodValue = Long.parseLong(clientLeasePeriod); setLeasePeriod(leasePeriodValue); } catch(NumberFormatException e) { throw new InvalidConfigurationException("Can not set client lease period because " + "can not convert given value (" + clientLeasePeriod + ") to a number."); } } // config for useClientConnectionIdentity String useClientConnectionIdentityString = (String)config.get(Remoting.USE_CLIENT_CONNECTION_IDENTITY); if(useClientConnectionIdentityString != null) { useClientConnectionIdentity = Boolean.valueOf(useClientConnectionIdentityString).booleanValue(); } // Inject ConnectionListener String connectionListener = (String)config.get(CONNECTION_LISTENER); if (connectionListener != null) { setConnectionListener(connectionListener); } String registerCallbackListenersString = (String)config.get(REGISTER_CALLBACK_LISTENER); if(registerCallbackListenersString != null) { registerCallbackListeners = Boolean.valueOf(registerCallbackListenersString).booleanValue(); } createServerSocketFactory(); // need to check invoker locator to see if need to provide binding address (in the case 0.0.0.0 was used) final InvokerLocator originalLocator = locator; locator = InvokerLocator.validateLocator(locator); if (!locator.getLocatorURI().equals(originalLocator.getLocatorURI())) { log.debug(this + " original locator: " + originalLocator); log.debug(this + " new locator: " + locator); } // need to update the locator key used in the invoker registry AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.updateServerInvokerLocator(originalLocator, locator); return null; } }); } protected void setupHomes(Map config) throws Exception { // First try to find address(es) using the new multihome facility. if (locator.isMultihome()) { connectHomes = locator.getConnectHomeList(); Object o = config.get(InvokerLocator.CONNECT_HOMES_KEY); if (o != null) { if (o instanceof Collection) connectHomes.addAll((Collection) o); else if (o instanceof String) connectHomes.addAll(createHomeCollection((String) o)); else log.warn(this + ": " + InvokerLocator.CONNECT_HOMES_KEY + " must be a collection or String: " + o); } homes = locator.getHomeList(); o = config.get(InvokerLocator.HOMES_KEY); if (o != null) { if (o instanceof Collection) homes.addAll((Collection) o); else if (o instanceof String) homes.addAll(createHomeCollection((String) o)); else log.warn(this + ": " + InvokerLocator.HOMES_KEY + " must be a collection or String: " + o); } if (!homes.isEmpty() && connectHomes.isEmpty()) connectHomes.addAll(homes); assignPorts(); return; } // If no bind address(es) found, try the old way. String locatorhost = locator.getHost(); InetAddress addr = null; if(locatorhost != null) { addr = getAddressByName(locatorhost); } else { addr = getLocalHost(); } int port = locator.getPort(); if(port <= 0) { port = assignPort(); } // set the bind address serverBindAddress = (String)config.get(SERVER_BIND_ADDRESS_KEY); clientConnectAddress = (String)config.get(CLIENT_CONNECT_ADDRESS_KEY); if(serverBindAddress == null) { if(clientConnectAddress != null) { // can't use uri address, as is for client only serverBindAddress = getLocalHost().getHostAddress(); } else { serverBindAddress = addr.getHostAddress(); } } // set the bind port String serverBindPortString = (String)config.get(SERVER_BIND_PORT_KEY); String clientConnectPortString = (String)config.get(CLIENT_CONNECT_PORT_KEY); if(clientConnectPortString != null) { try { clientConnectPort = Integer.parseInt(clientConnectPortString); } catch(NumberFormatException e) { throw new InvalidConfigurationException("Can not set client bind port because can " + "not convert given value (" + clientConnectPortString + ") to a number."); } } if(serverBindPortString != null) { try { serverBindPort = Integer.parseInt(serverBindPortString); if(serverBindPort <= 0) { serverBindPort = assignPort(); } } catch(NumberFormatException e) { throw new InvalidConfigurationException("Can not set server bind port because can " + "not convert given value (" + serverBindPortString + ") to a number."); } } else { if(clientConnectPort > 0) { // can't use uri port, as is for client only serverBindPort = PortUtil.findFreePort(locator.getHost()); } else { serverBindPort = port; } } Home h = new Home(serverBindAddress, serverBindPort); homes.add(h); connectHomes.add(h); } protected Collection createHomeCollection(String s) { ArrayList homes = new ArrayList(); StringTokenizer st = new StringTokenizer(s, "!"); while (st.hasMoreTokens()) { String token = st.nextToken(); int p = token.indexOf(':'); String host = null; String portString = null; if (p < 0) { host = token; portString = "-1"; } else { host = token.substring(0, p); portString = token.substring(p + 1); } int port = -1; try { port = Integer.parseInt(portString); } catch (Exception e) { log.warn("invalid port value in Home: " + token + ", using -1"); } Home home = new Home(host, port); homes.add(home); } return homes; } protected int assignPort() throws IOException { int port; port = PortUtil.findFreePort(locator.getHost()); // re-write locator since the port is different final InvokerLocator newLocator = new InvokerLocator(locator.getProtocol(), locator.getHost(), port, locator.getPath(), locator.getParameters()); // need to update the locator key used in the invoker registry AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.updateServerInvokerLocator(locator, newLocator); return null; } }); this.locator = newLocator; return port; } protected void assignPorts() throws IOException { boolean changed = false; List list = homes; for (int i = 0; i < list.size(); i++) { Home home = (Home) list.get(i); if (home.port < 0) { changed = true; try { home.port = PortUtil.findFreePort(home.host); } catch (Exception e) { if (trace) log.trace(this + " unable to find free port for: " + home.host); } } } if (changed) locator.setHomeList(homes); if (connectHomes.size() == homes.size()) { changed = false; for (int i = 0; i < homes.size(); i++) { Home home = (Home) connectHomes.get(i); if (home.port < 0) { changed = true; home.port = ((Home) homes.get(i)).port; } } if (changed) locator.setConnectHomeList(connectHomes); } } protected ServerSocketFactory createServerSocketFactory() throws IOException { // only want to look at config if server socket factory has not already been set if(serverSocketFactory == null) { Object obj = configuration.get(Remoting.CUSTOM_SERVER_SOCKET_FACTORY); if (obj != null) { if (obj instanceof ServerSocketFactory) { serverSocketFactory = (ServerSocketFactory)obj; } else { throw new RuntimeException("Can not set custom server socket factory (" + obj + ") as is not of type javax.net.SocketFactory"); } } if (serverSocketFactory == null) { // TODO: -TME This is another big hack because of dependancy on JMX within configuration // Have to wait till the mbean server is set before can actually set the server socket // factory since it is an mbean (new server's DI will fix all this). Would prefer this // to be in the setup() method... // Also, I can't cast the mbean proxy directly to ServerSocketFactory because it is not // an interface. Therefore, have to require that ServerSocketFactoryMBean is used. String serverSocketFactoryString = (String)configuration.get(SERVER_SOCKET_FACTORY); if(serverSocketFactoryString != null && serverSocketFactoryString.length() > 0) { try { if(serverSocketFactoryString != null) { MBeanServer server = getMBeanServer(); ObjectName serverSocketFactoryObjName = new ObjectName(serverSocketFactoryString); if(server != null) { try { ServerSocketFactoryMBean serverSocketFactoryMBean = (ServerSocketFactoryMBean)MBeanServerInvocationHandler. newProxyInstance(server, serverSocketFactoryObjName, ServerSocketFactoryMBean.class, false); serverSocketFactory = new ServerSocketFactoryWrapper(serverSocketFactoryMBean); } catch(Exception e) { log.debug("Error creating mbean proxy for server socket factory " + "for object name " + serverSocketFactoryObjName + ". " + "Will try by class name."); } } else { log.debug("The 'serverSocketFactory' attribute was set with a value, " + "but the MBeanServer reference is null."); } } } catch(MalformedObjectNameException e) { log.debug("Attibute value (" + serverSocketFactoryString + ") passed is not a " + "valid ObjectName. Can not look up if is a mbean service. Will try by classname."); } catch(NullPointerException e) { log.debug("Could not set up the server socket factory as a mbean service " + "due to null pointer exception."); } // couldn't create from object name for mbean service, will try by class name if(serverSocketFactory == null) { try { Class cl = ClassLoaderUtility.loadClass(serverSocketFactoryString, getClass()); Constructor serverSocketConstructor = null; serverSocketConstructor = cl.getConstructor(new Class[]{}); serverSocketFactory = (ServerSocketFactory)serverSocketConstructor.newInstance(new Object[] {}); log.trace("ServerSocketFactory (" + serverSocketFactoryString + ") loaded"); } catch(Exception e) { log.debug("Could not create server socket factory by classname (" + serverSocketFactoryString + "). Error message: " + e.getMessage()); } } } } } if (serverSocketFactory == null && needsCustomSSLConfiguration(configuration)) { try { SSLSocketBuilder socketBuilder = new SSLSocketBuilder(configuration); socketBuilder.setUseSSLServerSocketFactory(false); serverSocketFactory = socketBuilder.createSSLServerSocketFactory(); } catch (IOException e) { throw new RuntimeException("Unable to create customized SSL socket factory", e); } } if(serverSocketFactory == null) { log.debug(this + " did not find server socket factory configuration as mbean service " + "or classname. Creating default server socket factory."); serverSocketFactory = getDefaultServerSocketFactory(); } log.debug(this + " created server socket factory " + serverSocketFactory); serverSocketFactory = wrapServerSocketFactory(serverSocketFactory, configuration); return serverSocketFactory; } protected boolean justNeedsSSLClientMode(Map configuration) { if (configuration.size() == 1 && configuration.containsKey(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE)) { String useClientModeString = (String)configuration.get(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE); return Boolean.valueOf(useClientModeString).booleanValue(); } if (configuration.size() == 1 && configuration.containsKey(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE)) { String useClientModeString = (String)configuration.get(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE); return Boolean.valueOf(useClientModeString).booleanValue(); } if (configuration.size() == 2 && configuration.containsKey(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE) && configuration.containsKey(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE)) { String useClientModeString = (String)configuration.get(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE); return Boolean.valueOf(useClientModeString).booleanValue(); } return false; } /** * Gets the default server socket factory to use for the server invoker. The intention is this * method will be overridden by sub-classes for their specific defaults. */ protected ServerSocketFactory getDefaultServerSocketFactory() throws IOException { return ServerSocketFactory.getDefault(); } protected ServerSocketFactory wrapServerSocketFactory(ServerSocketFactory ssf, Map config) { if (config == null) { return ssf; } Object o = config.get(Remoting.SOCKET_CREATION_SERVER_LISTENER); if (o == null) { return ssf; } if (o instanceof SocketCreationListener) { return new CreationListenerServerSocketFactory(ssf, (SocketCreationListener) o); } else if (o instanceof String) { try { Class c = ClassLoaderUtility.loadClass((String) o, ServerInvoker.class); SocketCreationListener listener = (SocketCreationListener)c.newInstance(); return new CreationListenerServerSocketFactory(ssf, listener); } catch (Exception e) { log.warn("unable to instantiate class: " + o, e); return ssf; } } else { log.warn("unrecognized type for socket creation server listener: " + o); return ssf; } } /** * Handles both internal and external invocations (internal meaning only to be used within * remoting and external for ones that go to handlers. */ protected Object handleInternalInvocation(InternalInvocation param, InvocationRequest invocation, ServerInvocationHandler handler) throws Throwable { Object result = null; String methodName = param.getMethodName(); if(trace) { log.trace("handling InternalInvocation where method name = " + methodName); } // check if the invocation is for callback handling if(InternalInvocation.HANDLECALLBACK.equals(methodName)) { String sessionId = ServerInvokerCallbackHandler.getId(invocation); if(trace) { log.trace("ServerInvoker (" + this + ") is being asked to deliver callback on client callback handler with session id of " + sessionId + "."); } CallbackContainer callbackContainer = null; if (singleCallbackContainer != null) { callbackContainer = singleCallbackContainer; } else { callbackContainer = (CallbackContainer)clientCallbackListener.get(sessionId); } if(callbackContainer != null && callbackContainer.getCallbackHandler() != null) { Object[] params = param.getParameters(); Callback callbackRequest = (Callback) params[0]; Object obj = callbackContainer.getCallbackHandleObject(); if (obj != null) { Map callbackHandleObject = callbackRequest.getReturnPayload(); if(callbackHandleObject == null) { callbackHandleObject = new HashMap(); } //We only want to add it if it is not null otherwise is a redundant operation callbackHandleObject.put(Callback.CALLBACK_HANDLE_OBJECT_KEY, obj); callbackRequest.setReturnPayload(callbackHandleObject); } InvokerCallbackHandler callbackHandler = callbackContainer.getCallbackHandler(); callbackHandler.handleCallback(callbackRequest); } else { log.error("Could not find callback handler to call upon for handleCallback " + "where session id equals " + sessionId); } } else if(InternalInvocation.ADDLISTENER.equals(methodName)) { if(handler == null) { throw new InvalidConfigurationException( "Can not accept a callback listener since there are no ServerInvocationHandlers " + "registered. Please add via xml configuration or via the Connector's " + "addInvocationHandler() method."); } ServerInvokerCallbackHandler callbackHandler = getCallbackHandler(invocation); if (registerCallbackListeners) { connectionNotifier.addListenerFirst(callbackHandler); if(leasePeriod > 0) { leaseManagement = true; } } handler.addListener(callbackHandler); } else if(InternalInvocation.REMOVELISTENER.equals(methodName)) { ServerInvokerCallbackHandler callbackHandler = removeCallbackHandler(invocation); if(callbackHandler != null) { if (registerCallbackListeners) { // connectionNotifier.removeListener(callbackHandler); removeConnectionListener(callbackHandler); } callbackHandler.destroy(); if(handler == null) { throw new InvalidConfigurationException( "Can not remove a callback listener since there are no ServerInvocationHandlers " + "registered. Please add via xml configuration or via the Connector's " + "addInvocationHandler() method."); } handler.removeListener(callbackHandler); if(trace) { log.trace("ServerInvoker (" + this + ") removing server callback handler " + callbackHandler + "."); } } else { String sessionId = ServerInvokerCallbackHandler.getId(invocation); throw new RuntimeException("Can not remove callback listener from target server with " + "id of " + sessionId + " as it does not exist as a registered callback listener."); } } else if(InternalInvocation.GETCALLBACKS.equals(methodName)) { ServerInvokerCallbackHandler callbackHandler = getCallbackHandler(invocation); if(trace) { log.trace("ServerInvoker (" + this + ") getting callbacks for callback handler " + callbackHandler + "."); } result = callbackHandler.getCallbacks(invocation.getRequestPayload()); } else if(InternalInvocation.ACKNOWLEDGECALLBACK.equals(methodName)) { ServerInvokerCallbackHandler callbackHandler = getCallbackHandler(invocation); if(trace) { log.trace("ServerInvoker (" + this + ") acknowledge callback on callback handler " + callbackHandler + "."); } callbackHandler.acknowledgeCallbacks(param); } else if(InternalInvocation.ADDCLIENTLISTENER.equals(methodName)) { String sessionId = ServerInvokerCallbackHandler.getId(invocation); Object[] params = param.getParameters(); // the only elements should be the callback handler and possibly the callback handle object if(params == null || params.length < 0 || params.length > 3) { log.debug("Received addClientListener InternalInvocation, but getParameters() " + "returned: " + params); throw new RuntimeException( "InvokerCallbackHandler and callback handle object (optional) must be supplied as " + "the only parameter objects within the InternalInvocation when calling " + "addClientListener."); } InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler)params[0]; Object callbackHandleObject = params[1]; CallbackContainer callbackContainer = new CallbackContainer(callbackHandler, callbackHandleObject); clientCallbackListener.put(sessionId, callbackContainer); //If there is only one CallbackContainer we store a direct reference to it to avoid //unnecessary lookups - TLF if (clientCallbackListener.size() == 1) { singleCallbackContainer = callbackContainer; } else { singleCallbackContainer = null; } log.debug("ServerInvoker (" + this + ") added client callback handler " + callbackHandler + " with session id of " + sessionId + " and callback handle object of " + callbackHandleObject + "."); } else if(InternalInvocation.REMOVECLIENTLISTENER.equals(methodName)) { String sessionId = ServerInvokerCallbackHandler.getId(invocation); log.debug("ServerInvoker (" + this + ") removing client callback handler with session " + "id of " + sessionId + "."); Object cbo = clientCallbackListener.remove(sessionId); if(cbo == null) { throw new RuntimeException( "Can not remove callback listener from callback server with id of " + sessionId + " as it does not exist as a registered callback listener."); } //If there is only one CallbackContainer we store a direct reference to it to avoid //unnecessary lookups - TLF if (clientCallbackListener.size() == 1) { singleCallbackContainer = (CallbackContainer)clientCallbackListener.values().iterator().next(); } else { singleCallbackContainer = null; } } else if(InternalInvocation.ADDSTREAMCALLBACK.equals(methodName)) { StreamHandler streamHandler = getStreamHandler(invocation); if(handler instanceof StreamInvocationHandler) { InternalInvocation inv = (InternalInvocation)invocation.getParameter(); // second parameter should be the param payload result = ((StreamInvocationHandler)handler). handleStream(streamHandler, (InvocationRequest)inv.getParameters()[1]); } else { log.debug("Client request is an InputStream, but the registered handlers do not " + "implement the StreamInvocationHandler interface, so could not process call."); throw new RuntimeException( "No handler registered of proper type (StreamInvocationHandler)."); } } else if (InternalInvocation.ECHO.equals(methodName)) { Object response = null; Object[] objects = param.getParameters(); if (objects != null && objects.length > 0) response = objects[0]; if (trace) { log.trace(this + " echoing " + response); } return response; } else { log.debug("Error processing InternalInvocation. Unable to process method " + methodName + ". Please make sure this should be an InternalInvocation."); throw new RuntimeException( "Error processing InternalInvocation. Unable to process method " + methodName); } return result; } protected ServerInvocationHandler findInvocationHandler(String subsystem) { ServerInvocationHandler handler = null; if (singleHandler != null) { handler = singleHandler; } else { if (subsystem != null) { handler = (ServerInvocationHandler)handlers.get(subsystem.toUpperCase()); } else { // subsystem not specified, so will hope for a default one being set if (!handlers.isEmpty()) { if (trace) { log.trace(this + " handling invocation with no subsystem explicitely specified, using the default handler"); } handler = (ServerInvocationHandler)handlers.values().iterator().next(); } } } return handler; } /** * Called prior to an invocation. * TODO is sending in the arg appropriate? */ protected void preProcess(String sessionId, ClassBytes arg, Map payload, InvokerLocator locator) { } /** * Called after an invocation. * TODO is sending in the arg appropriate? */ protected void postProcess(String sessionId, Object param, Map payload, InvokerLocator locator) { } // Private -------------------------------------------------------------------------------------- private ThreadPool createThreadPoolProxy(ObjectName objName) { ThreadPool pool; MBeanServer server = getMBeanServer(); if(server != null) { ThreadPoolMBean poolMBean = (ThreadPoolMBean)MBeanServerInvocationHandler. newProxyInstance(server, objName, ThreadPoolMBean.class, false); pool = poolMBean.getInstance(); } else { throw new RuntimeException("Can not register MBean ThreadPool as the ServerInvoker " + "has not been registered with a MBeanServer."); } return pool; } //TODO: -TME getting of datatype is duplicated in both the RemoteClientInvoker and the ServerInvoker private String getDataType(InvokerLocator locator) { String type = null; if(locator != null) { Map params = locator.getParameters(); if(params != null) { type = (String) params.get(InvokerLocator.DATATYPE); } } return type; } private void terminateLease(InvocationRequest invocation) { if (invocation != null) { // clientSessionId == MicroRemoteClientInvoker.invokerSessionID. String clientSessionId = invocation.getSessionId(); Lease clientLease = (Lease)clientLeases.get(clientSessionId); if (clientLease != null) { boolean clientOnlyTerminated = false; // now have to determine if is just Client that disconnected // or if all Clients disconnected, thus the client invoker // is also disconnected as well. Map reqMap = invocation.getRequestPayload(); if (reqMap != null) { Object holderObj = reqMap.get(ClientHolder.CLIENT_HOLDER_KEY); if (holderObj != null && holderObj instanceof ClientHolder) { // just a client that disconnected, so only need to terminate lease for // that particular client (by client session id). if (trace) log.trace("terminating client lease: " + clientSessionId); ClientHolder holder = (ClientHolder) holderObj; clientLease.terminateLease(holder.getSessionId()); clientOnlyTerminated = true; } } // now see if client invoker needs to be terminated if (!clientOnlyTerminated) { if (trace) log.trace("terminating invoker lease: " + clientSessionId); clientLease.terminateLease(clientSessionId); clientLeases.remove(clientSessionId); } } else { String type = "invoker"; Map reqMap = invocation.getRequestPayload(); if (reqMap != null) { Object holderObj = reqMap.get(ClientHolder.CLIENT_HOLDER_KEY); if (holderObj != null && holderObj instanceof ClientHolder) { type = "client"; } } log.debug("Asked to terminate " + type + " lease for invoker session id " + clientSessionId + ", but lease for this id could not be found." +"" + "Probably has been removed due to connection failure."); } } } private void updateClientLease(InvocationRequest invocation) { if(invocation != null) { String clientSessionId = invocation.getSessionId(); if (invocation.getRequestPayload() != null) { // Remove per invocation timeout. invocation.getRequestPayload().remove(TIMEOUT); } if(clientSessionId != null) { if(trace) { log.trace("Getting lease for invoker session id: " + clientSessionId); } Lease clientLease = (Lease)clientLeases.get(clientSessionId); if(clientLease == null) { Lease newClientLease = new Lease(clientSessionId, leasePeriod, locator.getLocatorURI(), invocation.getRequestPayload(), connectionNotifier, clientLeases); clientLeases.put(clientSessionId, newClientLease); newClientLease.startLease(); if(trace) { log.trace("No lease established for invoker session id (" + clientSessionId + "), so starting a new one:" + newClientLease); } } else { if (useClientConnectionIdentity) { String leasePingerId = (String) invocation.getRequestPayload().get(LeasePinger.LEASE_PINGER_ID);; if (leasePingerId == null || leasePingerId.equals(clientLease.getLeasePingerId())) { // including request payload from invocation as may contain updated list of clients. if (trace) log.trace(clientLease + " matches: leasePingerId: " + leasePingerId); clientLease.updateLease(leasePeriod, invocation.getRequestPayload()); if(trace) { log.trace("Updated lease for invoker session id (" + clientSessionId + ")"); } } else { if (trace) log.trace(clientLease + " does not match: leasePingerId: " + leasePingerId); if (trace) log.trace("terminating invoker lease: " + clientLease); clientLease.terminateLeaseUponFailure(clientSessionId); clientLeases.remove(clientSessionId); Lease newClientLease = new Lease(clientSessionId, leasePeriod, locator.getLocatorURI(), invocation.getRequestPayload(), connectionNotifier, clientLeases); clientLeases.put(clientSessionId, newClientLease); newClientLease.startLease(); if(trace) { log.trace("starting a new lease:" + newClientLease); } } } else { // including request payload from invocation as may contain updated list of clients. clientLease.updateLease(leasePeriod, invocation.getRequestPayload()); if(trace) { log.trace("Updated lease for client session id (" + clientSessionId + ")"); } } } } } } private boolean checkForClientLease(String invokerSessionId) { if(leaseManagement && invokerSessionId != null) { if(trace) { log.trace("Checking lease for invoker session id: " + invokerSessionId); } Lease clientLease = (Lease)clientLeases.get(invokerSessionId); if(clientLease == null) { if(trace) { log.trace("No lease established for invoker session id (" + invokerSessionId + ")"); } return false; } else { if(trace) { log.trace("Found lease for invoker session id (" + invokerSessionId + ")"); } return true; } } return false; } /** * Takes the real invocation from the client out of the OnewayInvocation and then executes the * invoke() with the real invocation on a seperate thread. */ private void handleOnewayInvocation(OnewayInvocation onewayInvocation, InvocationRequest invocation) throws Throwable { Object[] objs = onewayInvocation.getParameters(); // The oneway invocation should contain the real param as it's only param in parameter array Object realParam = objs[0]; invocation.setParameter(realParam); final InvocationRequest newInvocation = invocation; ThreadPool executor = getOnewayThreadPool(); Runnable onewayRun = new Runnable() { public void run() { try { invoke(newInvocation); } catch(Throwable e) { // throw away exception since can't get it back to original caller log.error("Error executing server oneway invocation request: " + newInvocation, e); } } }; if(trace) { log.trace(this + " placing " + invocation + " in onewayThreadPool"); } executor.run(onewayRun); } private StreamHandler getStreamHandler(InvocationRequest invocation) throws Exception { InternalInvocation inv = (InternalInvocation)invocation.getParameter(); String locator = (String)inv.getParameters()[0]; return new StreamHandler(locator); } private ServerInvokerCallbackHandler getCallbackHandler(InvocationRequest invocation) throws Exception { ServerInvokerCallbackHandler callbackHandler = null; String id = ServerInvokerCallbackHandler.getId(invocation); synchronized(callbackHandlers) { callbackHandler = (ServerInvokerCallbackHandler)callbackHandlers.get(id); // if does not exist, create it if(callbackHandler == null) { callbackHandler = new ServerInvokerCallbackHandler(invocation, getLocator(), this); callbackHandlers.put(id, callbackHandler); } } callbackHandler.connect(); if(trace) { log.trace("ServerInvoker (" + this + ") adding server callback handler " + callbackHandler + " with id of " + id + "."); } return callbackHandler; } public ServerInvokerCallbackHandler removeCallbackHandler(InvocationRequest invocation) { String id = ServerInvokerCallbackHandler.getId(invocation); ServerInvokerCallbackHandler callbackHandler = null; synchronized(callbackHandlers) { callbackHandler = (ServerInvokerCallbackHandler) callbackHandlers.remove(id); } log.debug(this + " removed " + callbackHandler); return callbackHandler; } public void shutdownCallbackHandler(ServerInvokerCallbackHandler callbackHandler, InvocationRequest invocation) { removeCallbackHandler(invocation); if (registerCallbackListeners) { removeConnectionListener(callbackHandler); } ServerInvocationHandler handler = findInvocationHandler(invocation.getSessionId()); if (handler != null) { handler.removeListener(callbackHandler); if(trace) { log.trace(this + " removing server callback handler " + callbackHandler + "."); } } else { log.debug(this + " cannot remove " + callbackHandler + ": associated ServerInvocationHandler not longer exists"); } } // Inner classes -------------------------------------------------------------------------------- public static class InvalidStateException extends Exception { public InvalidStateException(String msg) { super(msg); } } private class CallbackContainer { private InvokerCallbackHandler handler; private Object handleObject; public CallbackContainer(InvokerCallbackHandler handler, Object handleObject) { this.handler = handler; this.handleObject = handleObject; } public InvokerCallbackHandler getCallbackHandler() { return handler; } public Object getCallbackHandleObject() { return handleObject; } } static private InetAddress getLocalHost() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return doGetLocalHost(); } try { return (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { return doGetLocalHost(); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } static private InetAddress doGetLocalHost() throws UnknownHostException { if (LOCAL_HOST != null) { return LOCAL_HOST; } try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/SubsystemNotSupported.java0000644000175000017500000000343310452770174032100 0ustar twernertwerner/* * 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.remoting; /** * SubsystemNotSupported is raised by a ServerInvoker when the target subsystem is not * supported on the target VM. * * @author Jeff Haynie * @version $Revision: 1216 $ */ public class SubsystemNotSupported extends Exception { private String subsystem; private InvokerLocator locator; private static final long serialVersionUID = 7211573237413019835L; public SubsystemNotSupported(String subsystem, InvokerLocator locator) { super("Subsystem '" + subsystem + "' not supported on target VM (" + locator + ")"); this.subsystem = subsystem; this.locator = locator; } public String getSubsystem() { return subsystem; } public InvokerLocator getLocator() { return locator; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/0000755000175000017500000000000011632407052025613 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/socket/0000755000175000017500000000000011632407052027103 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/socket/RemotingKeyManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/socket/RemotingKeyManager.jav0000644000175000017500000000464610407622417033352 0ustar twernertwerner/* * 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.remoting.util.socket; import java.security.PrivateKey; import java.security.Principal; import java.security.cert.X509Certificate; import java.net.Socket; import javax.net.ssl.X509KeyManager; /** * @author Tom Elrod */ public class RemotingKeyManager implements X509KeyManager { private X509KeyManager targetManager = null; private String alias = null; public RemotingKeyManager(X509KeyManager x509KeyManager, String alias) { this.targetManager = x509KeyManager; this.alias = alias; } public PrivateKey getPrivateKey(String string) { return targetManager.getPrivateKey(string); } public X509Certificate[] getCertificateChain(String string) { return targetManager.getCertificateChain(string); } public String[] getClientAliases(String string, Principal[] principals) { return targetManager.getClientAliases(string, principals); } public String[] getServerAliases(String string, Principal[] principals) { return targetManager.getServerAliases(string, principals); } public String chooseServerAlias(String string, Principal[] principals, Socket socket) { return targetManager.chooseServerAlias(string, principals, socket); } public String chooseClientAlias(String[] strings, Principal[] principals, Socket socket) { // just returning supplied alias instead of searching return alias; } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/socket/HandshakeRepeater.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/socket/HandshakeRepeater.java0000644000175000017500000000434710426021232033324 0ustar twernertwerner/* * 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.remoting.util.socket; import javax.net.ssl.HandshakeCompletedEvent; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLException; /** * @author Tom Elrod */ public class HandshakeRepeater implements HandshakeCompletedListener { private HandshakeCompletedListener targetListener = null; private boolean handshakeCompleted = false; public HandshakeRepeater(HandshakeCompletedListener listener) { this.targetListener = listener; } public void waitForHandshake() throws SSLException { for (int x = 0; x < 120; x++) { if (handshakeCompleted) { break; } else { try { Thread.sleep(500); } catch (InterruptedException e) { } } } if (!handshakeCompleted) { throw new SSLException("Handshaked failed to complete in 60 seconds"); } } public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) { if (targetListener != null) { targetListener.handshakeCompleted(handshakeCompletedEvent); } handshakeCompleted = true; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/TimerUtil.java0000644000175000017500000000430410747571752030414 0ustar twernertwernerpackage org.jboss.remoting.util; import java.util.ArrayList; import java.util.Iterator; import java.util.Timer; import java.util.TimerTask; import org.apache.log4j.Logger; /** * @author Tom Elrod */ public class TimerUtil { private static Timer timer = null; private static ArrayList stoppableTasks = new ArrayList(); private static Logger log = Logger.getLogger(TimerUtil.class); private static synchronized void init() { TimerUtil.timer = new Timer(true); } public static synchronized void schedule(TimerTask task, long period) { if (TimerUtil.timer == null) { TimerUtil.init(); } if (task instanceof StoppableTimerTask) { stoppableTasks.add(task); } //schedule at fixed delay (not rate) try { TimerUtil.timer.schedule(task, period, period); } catch (IllegalStateException e) { log.debug("Unable to schedule TimerTask on existing Timer", e); timer = new Timer(true); timer.schedule(task, period, period); } } public static synchronized void unschedule(TimerTask task) { if (!(task instanceof StoppableTimerTask)) { log.warn("TimerUtil only remembers StoppableTimerTasks"); return; } StoppableTimerTask stoppableTask = (StoppableTimerTask) task; if (!stoppableTasks.remove(stoppableTask)) log.warn("unrecognized StoppableTimerTask: " + task); try { stoppableTask.stop(); } catch (Exception e) { log.warn("error calling stop() on: " + stoppableTask, e); } } public static synchronized void destroy() { if (TimerUtil.timer != null) { TimerUtil.timer.cancel(); TimerUtil.timer = null; } Iterator it = new ArrayList(stoppableTasks).iterator(); while (it.hasNext()) { StoppableTimerTask task = (StoppableTimerTask) it.next(); try { task.stop(); } catch (Exception e) { log.warn("unable to stop TimerTask: " + task); } } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/StoppableTimerTask.java0000644000175000017500000000367410554101571032244 0ustar twernertwerner/* * 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.remoting.util; /** * When a StoppableTimerTask is passed to TimerUtil.schedule(), TimerUtil will keep * track of it so that it can call StoppableTimerTask.stop() during TimerUtil.destroy(). * * Note that when a StoppableTimerTask is done, it should call TimerTask.unschedule(this) * so that the reference to it is removed. * * Note that there is a danger of an infinite loop because if StoppableTimerTask.stop() * calls TimerTask.unschedule(this), the TimerTask.unschedule(this) will call * this.StoppableTimerTask(). It follows that StoppableTimerTask.stop() should guard * against this danger. * * @author Ron Sigal * @version $Revision: 1913 $ *

          * Copyright Jan 18, 2007 *

          */ public interface StoppableTimerTask { /** * stop() will be called when TimerUtil.unschedule() or when TimerUtil.destroy() * are called. * * @throws Exception */ void stop() throws Exception; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/util/SecurityUtility.java0000644000175000017500000000413711413660476031666 0ustar twernertwerner/* * 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.remoting.util; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.jboss.remoting.Remoting; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Mar 31, 2008 *

          */ public class SecurityUtility { static boolean skipAccessControl; static { try { skipAccessControl = ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { boolean b1 = System.getSecurityManager() == null; boolean b2 = Boolean.getBoolean(Remoting.SKIP_ACCESS_CONTROL); // System.out.println("security manager: " + System.getSecurityManager()); return new Boolean(b1 || b2); } })).booleanValue(); } catch (PrivilegedActionException e) { e.getCause().printStackTrace(); } } static public boolean skipAccessControl() { return skipAccessControl; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/AbstractInvoker.java0000644000175000017500000004434311204102026030576 0ustar twernertwerner/* * 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.remoting; import org.jboss.logging.Logger; import org.jboss.remoting.loading.ClassByteClassLoader; import org.jboss.remoting.marshal.MarshallLoaderFactory; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.socketfactory.CreationListenerSocketFactory; import org.jboss.remoting.socketfactory.SocketCreationListener; import org.jboss.remoting.socketfactory.SocketFactoryWrapper; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.util.id.GUID; import javax.net.SocketFactory; import java.io.IOException; import java.lang.reflect.Constructor; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.ArrayList; import java.util.Set; /** * AbstractInvoker is an abstract handler part that contains common methods between both * client and server. * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5271 $ */ public abstract class AbstractInvoker implements Invoker { protected final static Logger log = Logger.getLogger(AbstractInvoker.class); protected ClassByteClassLoader classbyteloader; protected InvokerLocator locator; protected Map localServerLocators = new HashMap(); protected String serializationType; protected Map configuration = new HashMap(); protected SocketFactory socketFactory; protected int version; protected boolean passConfigMapToMarshalFactory; // Indicates if the serverSocketFactory was generated internally. protected boolean socketFactoryCreatedFromSSLParameters; public AbstractInvoker(InvokerLocator locator) { this(locator, null); } public AbstractInvoker(InvokerLocator locator, Map configuration) { try { this.classbyteloader = (ClassByteClassLoader)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new ClassByteClassLoader(AbstractInvoker.class.getClassLoader()); } }); } catch (PrivilegedActionException e) { log.debug(e.toString(), e); throw new RuntimeException("Can't create a ClassLoader", e); } this.locator = locator; if (checkConfigOverridesLocator(locator, configuration)) { if (locator.getParameters() != null) this.configuration.putAll(locator.getParameters()); if (configuration != null) this.configuration.putAll(configuration); } else { if (configuration != null) this.configuration.putAll(configuration); if (locator.getParameters() != null) this.configuration.putAll(locator.getParameters()); } try { InvokerLocator loaderLocator = MarshallLoaderFactory.convertLocator(locator); if(loaderLocator != null) { classbyteloader.setClientInvoker(new Client(loaderLocator)); } } catch(Exception e) { log.error("Could not create remote class loading for invoker.", e); } if(locator == null || locator.getParameters() == null) { this.setSerializationType(SerializationStreamFactory.JAVA); } else { this.setSerializationType(locator.findSerializationType()); } setVersion(Version.getDefaultVersion()); Object o = this.configuration.get(Remoting.REMOTING_VERSION); if (o instanceof String) { try { int v = Integer.valueOf((String)o).intValue(); if (Version.isValidVersion(v)) { log.debug(this + " setting version to " + v); setVersion(v); } else { log.debug(this + " invalid version: " + v + ". Using " + getVersion()); } } catch (Exception e) { log.warn(this + " could not convert " + Remoting.REMOTING_VERSION + " value of " + o + " to an int value. Using " + getVersion()); } } else if (o != null) { log.warn(this + " value of " + Remoting.REMOTING_VERSION + " must be a String: " + o + ". Using " + getVersion()); } o = this.configuration.get(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY); if (o instanceof String) { this.passConfigMapToMarshalFactory = Boolean.valueOf((String) o).booleanValue(); } else if (o != null) { log.warn("value of " + Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY + " must be a String: " + o); } } /** * return the locator this Invoker represents */ public InvokerLocator getLocator() { return locator; } /** * Generates a listener id for the callbackhandler and callback server locator combination * @param sessionId * @param locator */ public String addClientLocator(String sessionId, InvokerCallbackHandler callbackhandler, InvokerLocator locator) { String listenerId = null; synchronized(localServerLocators) { Collection holders = localServerLocators.values(); Iterator itr = holders.iterator(); while(itr.hasNext()) { CallbackHandlerHolder holder = (CallbackHandlerHolder)itr.next(); InvokerCallbackHandler holderhandler = holder.getHandler(); boolean handlersEqual = holderhandler.equals(callbackhandler); InvokerLocator handlerLocator = holder.getLocator(); boolean locatorsEqual = handlerLocator.equals(locator); if(handlersEqual && locatorsEqual) { // the entry already exists for this pair, so return null return null; } } // if got this far, the entry does not exist, so need to add it and create a listener id CallbackHandlerHolder holder = new CallbackHandlerHolder(callbackhandler, locator); listenerId = new GUID().toString(); String key = listenerId; if (sessionId != null) key = sessionId + "+" + listenerId; localServerLocators.put(key, holder); } return listenerId; } /** * Gets the client locator. This locator will be used by the server side * to make callbacks to the handler for this locator. */ public InvokerLocator getClientLocator(String listenerId) { InvokerLocator locator = null; if(listenerId != null) { CallbackHandlerHolder holder = (CallbackHandlerHolder) localServerLocators.get(listenerId); if(holder != null) { locator = holder.getLocator(); } } return locator; } public List getClientLocators(String sessionId, InvokerCallbackHandler handler) { List holderList = new ArrayList(); if(handler != null) { synchronized(localServerLocators) { Set entries = localServerLocators.entrySet(); Iterator itr = entries.iterator(); while(itr.hasNext()) { Map.Entry entry = (Map.Entry) itr.next(); String listenerId = (String) entry.getKey(); int index = listenerId.indexOf('+'); String prefix = listenerId.substring(0, index); if (!sessionId.equals(prefix)) continue; if (index >= 0) listenerId = listenerId.substring(index + 1); CallbackHandlerHolder holder = (CallbackHandlerHolder) entry.getValue(); InvokerCallbackHandler holderHandler = holder.getHandler(); if(holderHandler.equals(handler)) { CallbackLocatorHolder locatorHolder = new CallbackLocatorHolder(listenerId, holder.getLocator()); holderList.add(locatorHolder); } } // now remove holders if(holderList.size() > 0) { for(int x = 0; x < holderList.size(); x++) { String listenerId = ((CallbackLocatorHolder)holderList.get(x)).getListenerId(); String key = sessionId + "+" + listenerId; localServerLocators.remove(key); } } } } return holderList; } /** * set the classloader to use internally * * @param classloader */ public synchronized void setClassLoader(final ClassLoader classloader) { try { this.classbyteloader = (ClassByteClassLoader)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new ClassByteClassLoader(classloader); } }); } catch (PrivilegedActionException e) { log.debug(e.toString(), e); throw new RuntimeException("Can't create a ClassLoader", e); } } public synchronized ClassLoader getClassLoader() { return classbyteloader; } public String getSerializationType() { return serializationType; } public void setSerializationType(String serializationType) { this.serializationType = serializationType; } public SocketFactory getSocketFactory() { return socketFactory; } public void setSocketFactory(SocketFactory socketFactory) { this.socketFactory = socketFactory; } public boolean isSocketFactoryCreatedFromSSLParameters() { return socketFactoryCreatedFromSSLParameters; } public int getVersion() { return version; } public void setVersion(int version) { this.version = version; } /** * If any configuration parameters relate to the construction of a SSLSocketBuilder, create one. */ protected SocketFactory createSocketFactory(Map configuration) { if (configuration == null) return null; if (socketFactory != null) return socketFactory; SocketFactory factory = null; Object obj = configuration.get(Remoting.CUSTOM_SOCKET_FACTORY); if (obj != null) { if (obj instanceof SocketFactory) { factory = (SocketFactory) obj; } else { throw new RuntimeException("Can not set custom socket factory (" + obj + ") as is not of type javax.net.SocketFactory"); } } if(factory == null) { String socketFactoryString = (String)configuration.get(Remoting.SOCKET_FACTORY_NAME); if (socketFactoryString == null) { socketFactoryString = (String)configuration.get(Remoting.SOCKET_FACTORY_CLASS_NAME); } if(socketFactoryString != null && socketFactoryString.length() > 0) { try { Class cl = ClassLoaderUtility.loadClass(socketFactoryString, getClass()); Constructor socketFactoryConstructor = null; socketFactoryConstructor = cl.getConstructor(new Class[]{}); factory = (SocketFactory)socketFactoryConstructor.newInstance(new Object[] {}); log.trace("SocketFactory (" + socketFactoryString + ") loaded"); } catch(Exception e) { log.debug("Could not create socket factory by classname (" + socketFactoryString + "). Error message: " + e.getMessage()); } } } if (factory == null && needsCustomSSLConfiguration(configuration)) { try { SSLSocketBuilder socketBuilder = new SSLSocketBuilder(configuration); socketBuilder.setUseSSLSocketFactory( false ); factory = socketBuilder.createSSLSocketFactory(); socketFactoryCreatedFromSSLParameters = true; } catch (IOException e) { throw new RuntimeException("Unable to create customized SSL socket factory", e); } } return wrapSocketFactory(factory, configuration); } protected Map getConfiguration() { return configuration; } protected boolean checkConfigOverridesLocator(InvokerLocator locator, Map config) { boolean result = false; if (config != null) { Object o = config.get(Remoting.CONFIG_OVERRIDES_LOCATOR); if (o != null) { if (o instanceof String) { result = Boolean.valueOf((String) o).booleanValue(); } else { log.warn("value of " + Remoting.CONFIG_OVERRIDES_LOCATOR + " in configuration Map should be a String instead of: " + o); } } } Map map = locator.parameters; if (map != null) { Object o = map.get(Remoting.CONFIG_OVERRIDES_LOCATOR); if (o != null) { if (o instanceof String) { result = Boolean.valueOf((String) o).booleanValue(); } else { log.warn("value of " + Remoting.CONFIG_OVERRIDES_LOCATOR + " in " + locator + " should be a String"); } } } return result; } static public SocketFactory wrapSocketFactory(SocketFactory socketFactory, Map config) { if (config == null) return socketFactory; Object o = config.get(Remoting.SOCKET_CREATION_CLIENT_LISTENER); if (o == null) return socketFactory; if (o instanceof SocketCreationListener) { SocketCreationListener listener = (SocketCreationListener) o; return new CreationListenerSocketFactory(socketFactory, listener); } else if (o instanceof String) { try { Class c = ClassLoaderUtility.loadClass((String) o, AbstractInvoker.class); SocketCreationListener listener = (SocketCreationListener) c.newInstance(); return new CreationListenerSocketFactory(socketFactory, listener); } catch (Exception e) { log.warn("unable to instantiate class: " + o, e); return socketFactory; } } else { log.warn("unrecognized type for socket creation client listener: " + o); return socketFactory; } } static public boolean isCompleteSocketFactory(SocketFactory sf) { if (sf != null) { if (!(sf instanceof SocketFactoryWrapper) || ((SocketFactoryWrapper)sf).getSocketFactory() != null) return true; } return false; } public static boolean needsCustomSSLConfiguration(Map configuration) { if (configuration.get(SSLSocketBuilder.REMOTING_KEY_ALIAS) != null || configuration.get(SSLSocketBuilder.REMOTING_CLIENT_AUTH_MODE) != null || configuration.get(SSLSocketBuilder.REMOTING_SERVER_AUTH_MODE) != null || configuration.get(SSLSocketBuilder.REMOTING_SSL_PROTOCOL) != null || configuration.get(SSLSocketBuilder.REMOTING_SSL_PROVIDER_NAME) != null || configuration.get(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE) != null || configuration.get(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE) != null || configuration.get(SSLSocketBuilder.REMOTING_KEY_PASSWORD) != null || configuration.get(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM) != null || configuration.get(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH) != null || configuration.get(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD) != null || configuration.get(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE) != null || configuration.get(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM) != null || configuration.get(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH) != null || configuration.get(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD) != null || configuration.get(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE) != null ) return true; else return false; } private class CallbackHandlerHolder { private InvokerCallbackHandler handler; private InvokerLocator locator; private CallbackHandlerHolder(InvokerCallbackHandler handler, InvokerLocator locator) { this.handler = handler; this.locator = locator; } public InvokerCallbackHandler getHandler() { return handler; } public InvokerLocator getLocator() { return locator; } } public class CallbackLocatorHolder { private InvokerLocator locator; private String listenerId; public CallbackLocatorHolder(String listenerId, InvokerLocator locator) { this.listenerId = listenerId; this.locator = locator; } public String getListenerId() { return listenerId; } public InvokerLocator getLocator() { return locator; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ConnectionListener.java0000644000175000017500000000362710554623211031315 0ustar twernertwerner/* * 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.remoting; /** * Listener that can be registered with the Client to receive a callback if the target server for * said Client is determined to be unreachable at any point. *

          * Can also be registered with Connector to be notified when client disconnects (but only when * leasing is turned on). * * @author Tom Elrod */ public interface ConnectionListener { /** * Called when a target server or client found to be dead. * * @param throwable - original exception thrown when trying to connect to target server. If is * listener on server for client failure, the exception will be a * ClientDisconnectedException if the client disconnected normally, or null if the lease * expired. * @param client - the client from which this call was made. */ public void handleConnectionException(Throwable throwable, Client client); }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/InvalidConfigurationException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/InvalidConfigurationException.java0000644000175000017500000000242510452770174033510 0ustar twernertwerner/* * 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.remoting; /** * @author Tom Elrod */ public class InvalidConfigurationException extends Exception { private static final long serialVersionUID = -2806674808345932422L; public InvalidConfigurationException(String s) { super(s); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/0000755000175000017500000000000011632407044026330 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkRegistry.java0000644000175000017500000002456011171061123032354 0ustar twernertwerner/* * 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.remoting.network; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import javax.management.ListenerNotFoundException; import javax.management.MBeanNotificationInfo; import javax.management.MBeanServer; import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; import org.jboss.logging.Logger; import org.jboss.mx.util.JBossNotificationBroadcasterSupport; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.detection.ServerInvokerMetadata; import org.jboss.remoting.ident.Identity; import org.jboss.remoting.util.SecurityUtility; /** * NetworkRegistry is a concrete implemenation of the NetworkRegistryMBean * interface. The NetworkRegistry will keep a list of all the detected * JBoss servers on the network and provide a local facility for querying * for different servers. * * @author Jeff Haynie * @version $Revision: 5004 $ */ public class NetworkRegistry implements NetworkRegistryMBean { private static final Logger log = Logger.getLogger(NetworkRegistry.class); private MBeanServer mBeanServer; private ObjectName objectName; private final JBossNotificationBroadcasterSupport broadcaster = new JBossNotificationBroadcasterSupport(); private final Map servers = new HashMap(); private static NetworkRegistry singleton; public NetworkRegistry() { super(); singleton = this; } /** * return the singleton instance * * @return */ public static final NetworkRegistry getInstance() { if(singleton == null) { new NetworkRegistry(); } return singleton; } /** * add a server for a given identity that is available on the network * * @param identity * @param invokers */ public void addServer(final Identity identity, final ServerInvokerMetadata invokers[]) { boolean found = false; synchronized(servers) { if(servers.containsKey(identity) == false) { servers.put(identity, new NetworkInstance(identity, invokers)); found = true; } } if(found) { log.debug(this + " addServer - " + identity); // put this on a separate thread so we don't block further detection ... // TODO: this needs to go into a thread pool thread -JGH new Thread() { public void run() { broadcaster.sendNotification(new NetworkNotification(objectName, NetworkNotification.SERVER_ADDED, identity, invokers)); } }.start(); } } /** * update the invokers for a given server * * @param identity * @param invokers */ public void updateServer(final Identity identity, final ServerInvokerMetadata invokers[]) { boolean found = false; synchronized(servers) { if(servers.containsKey(identity)) { servers.put(identity, new NetworkInstance(identity, invokers)); found = true; } } if(found) { // TODO: let's put this in a thread pool thread -JGH // put this on a separate thread so we don't block further detection ... new Thread() { public void run() { broadcaster.sendNotification(new NetworkNotification(objectName, NetworkNotification.SERVER_UPDATED, identity, invokers)); } }.start(); } } /** * return the servers on the network * * @return */ public NetworkInstance[] getServers() { synchronized(servers) { return (NetworkInstance[]) servers.values().toArray(new NetworkInstance[servers.size()]); } } /** * returns true if the server with the identity is available * * @param identity * @return */ public boolean hasServer(Identity identity) { synchronized(servers) { return servers.containsKey(identity); } } /** * query the network registry for 0..* of servers based on a * filter. if the filter is null, it is considered a wildcard. * * @param filter * @return */ public NetworkInstance[] queryServers(NetworkFilter filter) { NetworkInstance servers[] = getServers(); if(servers == null || servers.length <= 0) { return new NetworkInstance[0]; } Set result = new HashSet(); for(int c = 0; c < servers.length; c++) { NetworkInstance instance = (NetworkInstance) this.servers.get(servers[c]); if(filter == null || filter.filter(servers[c].getIdentity(), instance.getLocators())) { if(result.contains(servers[c]) == false) { // the filter passed, add it result.add(servers[c]); } } } return (NetworkInstance[]) result.toArray(new NetworkInstance[result.size()]); } /** * remove a server no longer available on the network * * @param identity */ public void removeServer(final Identity identity) { NetworkInstance instance = null; synchronized(servers) { instance = (NetworkInstance) servers.remove(identity); } if(instance != null) { log.debug(this + " removeServer - " + identity); final ServerInvokerMetadata il[] = instance.getServerInvokers(); // put this on a separate thread so we don't block further detection ... // TODO: let's put this is a thread pool thread -JGH new Thread() { public void run() { broadcaster.sendNotification(new NetworkNotification(objectName, NetworkNotification.SERVER_REMOVED, identity, il)); } }.start(); } } public void addNotificationListener(NotificationListener notificationListener, NotificationFilter notificationFilter, Object o) throws IllegalArgumentException { broadcaster.addNotificationListener(notificationListener, notificationFilter, o); } public MBeanNotificationInfo[] getNotificationInfo() { MBeanNotificationInfo info[] = new MBeanNotificationInfo[3]; info[0] = new MBeanNotificationInfo(new String[]{NetworkNotification.SERVER_ADDED}, NetworkNotification.class.getName(), "Fired when Server is added"); info[1] = new MBeanNotificationInfo(new String[]{NetworkNotification.SERVER_UPDATED}, NetworkNotification.class.getName(), "Fired when Server is updated"); info[2] = new MBeanNotificationInfo(new String[]{NetworkNotification.SERVER_REMOVED}, NetworkNotification.class.getName(), "Fired when Server is removed"); return info; } public void removeNotificationListener(NotificationListener notificationListener) throws ListenerNotFoundException { broadcaster.removeNotificationListener(notificationListener); } public void postDeregister() { } public void postRegister(Boolean aBoolean) { } public void preDeregister() throws Exception { } public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws Exception { this.mBeanServer = mBeanServer; this.objectName = objectName; // make sure our identity system property is properly set Identity identity = Identity.get(this.mBeanServer); // this is a slight hack, but we have to have some way to know the main // JBoss MBeanServer data setSystemProperty("jboss.remoting.jmxid", identity.getJMXId()); setSystemProperty("jboss.remoting.instanceid", identity.getInstanceId()); setSystemProperty("jboss.remoting.domain", identity.getDomain()); return objectName; } /** * change the main domain of the local server * * @param newDomain */ public synchronized void changeDomain(String newDomain) { setSystemProperty("jboss.remoting.domain", newDomain); NetworkInstance servers[] = getServers(); if(servers == null || servers.length <= 0) { return; } // remove entries that don't match out new domain for(int c = 0; c < servers.length; c++) { NetworkInstance instance = (NetworkInstance) this.servers.get(servers[c]); if(newDomain.equals(instance.getIdentity().getDomain()) == false) { this.servers.remove(servers[c]); } } new Thread() { public void run() { broadcaster.sendNotification(new NetworkNotification(objectName, NetworkNotification.DOMAIN_CHANGED, Identity.get(mBeanServer), InvokerRegistry.getRegisteredServerLocators())); } }.start(); } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/filter/0000755000175000017500000000000011632407044027615 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/filter/IdentityFilter.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/filter/IdentityFilter.java0000644000175000017500000000344410355142433033423 0ustar twernertwerner/* * 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.remoting.network.filter; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ident.Identity; import org.jboss.remoting.network.NetworkFilter; /** * IdentityFilter * * @author Jeff Haynie * @version $Revision: 566 $ */ public class IdentityFilter implements NetworkFilter { static final long serialVersionUID = 480519754960605284L; private final Identity identity; public IdentityFilter(Identity identity) { this.identity = identity; } /** * called to apply a filter when selecting 0..* servers on the network * * @param identity * @param locators * @return */ public boolean filter(Identity identity, InvokerLocator locators[]) { return identity.equals(this.identity); } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/filter/InvokerProtocolFilter.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/filter/InvokerProtocolFilt0000644000175000017500000000430210355142433033514 0ustar twernertwerner/* * 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.remoting.network.filter; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ident.Identity; import org.jboss.remoting.network.NetworkFilter; /** * InvokerProtocolFilter will examine the protocol of the InvokerLocators on the * server and return true for the filter if the protocol matches our spec. * * @author Jeff Haynie * @version $Revision: 566 $ */ public class InvokerProtocolFilter implements NetworkFilter { static final long serialVersionUID = -4175168615629564295L; private final String protocol; public InvokerProtocolFilter(String protocol) { this.protocol = protocol; } /** * called to apply a filter when selecting 0..* servers on the network * * @param identity * @param locators * @return */ public boolean filter(Identity identity, InvokerLocator locators[]) { if(locators != null) { for(int c = 0; c < locators.length; c++) { // we found a transport that matches if(locators[c].getProtocol().equalsIgnoreCase(protocol)) { return true; } } } return false; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkRegistryFinder.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkRegistryFinder.java0000644000175000017500000000400610774602066033514 0ustar twernertwerner/* * 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.remoting.network; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Set; import javax.management.MBeanServer; import javax.management.ObjectInstance; import javax.management.ObjectName; /** * NetworkRegistryFinder is a utility class for finding the ObjectName to the NetworkRegistryMBean * * @author Jeff Haynie * @version $Revision: 3837 $ */ public class NetworkRegistryFinder { /** * find the ObjectName to the NetworkRegistryMBean instance on the MBeanServer * * @param server * @return */ public static ObjectName find(final MBeanServer server) { Set set = (Set)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return server.queryMBeans(null, new NetworkRegistryQuery()); } }); if(set.isEmpty()) { return null; } return ((ObjectInstance) set.iterator().next()).getObjectName(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkFilter.java0000644000175000017500000000316310355142433031774 0ustar twernertwerner/* * 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.remoting.network; import java.io.Serializable; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ident.Identity; /** * NetworkFilter can be used when selecting 0..* servers on the network * from the NetworkRegistry * * @author Jeff Haynie * @version $Revision: 566 $ */ public interface NetworkFilter extends Serializable { /** * called to apply a filter when selecting 0..* servers on the network * * @param identity * @param locators * @return */ public boolean filter(Identity identity, InvokerLocator locators[]); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkRegistryMBean.java0000644000175000017500000000534610355142433033267 0ustar twernertwerner/* * 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.remoting.network; import javax.management.MBeanRegistration; import javax.management.NotificationBroadcaster; import org.jboss.remoting.detection.ServerInvokerMetadata; import org.jboss.remoting.ident.Identity; /** * NetworkRegistryMBean is a managed bean that keeps track of all the servers on a * JBOSS network, and associates all the valid invokers on each server that are * available. * * @author Jeff Haynie * @version $Revision: 566 $ */ public interface NetworkRegistryMBean extends NotificationBroadcaster, MBeanRegistration { /** * return the servers on the network * * @return */ public NetworkInstance[] getServers(); /** * add a server for a given identity that is available on the network * * @param identity * @param invokers */ public void addServer(Identity identity, ServerInvokerMetadata invokers[]); /** * remove a server no longer available on the network * * @param identity */ public void removeServer(Identity identity); /** * update the invokers for a given server * * @param identity * @param invokers */ public void updateServer(Identity identity, ServerInvokerMetadata invokers[]); /** * returns true if the server with the identity is available * * @param identity * @return */ public boolean hasServer(Identity identity); /** * query the network registry for 0..* of servers based on a * filter * * @param filter * @return */ public NetworkInstance[] queryServers(NetworkFilter filter); /** * change the main domain of the local server * * @param newDomain */ public void changeDomain(String newDomain); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkInstance.java0000644000175000017500000000627610355142433032323 0ustar twernertwerner/* * 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.remoting.network; import java.io.Serializable; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.ServerInvokerMetadata; import org.jboss.remoting.ident.Identity; /** * NetworkInstance is an object that represents an Identity and its InvokerLocators. * * @author Jeff Haynie * @version $Revision: 566 $ */ public class NetworkInstance implements Serializable { static final long serialVersionUID = -1745108606611832280L; private final Identity identity; private final ServerInvokerMetadata serverInvokers[]; private final InvokerLocator locators[]; private final int hashCode; public NetworkInstance(Identity identity, InvokerLocator locators[]) { this.identity = identity; this.locators = locators; this.hashCode = this.identity.hashCode(); this.serverInvokers = null; } public NetworkInstance(Identity identity, ServerInvokerMetadata serverInvokers[]) { this.identity = identity; this.locators = null; this.hashCode = this.identity.hashCode(); this.serverInvokers = serverInvokers; } public final Identity getIdentity() { return identity; } public final InvokerLocator[] getLocators() { if(locators != null) { return locators; } else { InvokerLocator[] locators = new InvokerLocator[serverInvokers.length]; for(int x = 0; x < serverInvokers.length; x++) { locators[x] = serverInvokers[x].getInvokerLocator(); } return locators; } } /** * Gets all the server invoker metadata for the servers running on * specified server. Will include locator and supported subsystems * for that locator. * * @return */ public final ServerInvokerMetadata[] getServerInvokers() { return serverInvokers; } public String toString() { return "NetworkInstance [identity:" + identity + ",locator count:" + (serverInvokers == null ? 0 : serverInvokers.length) + "]"; } public boolean equals(Object obj) { return hashCode == obj.hashCode(); } public int hashCode() { return hashCode; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkNotification.java0000644000175000017500000000676610355142433033211 0ustar twernertwerner/* * 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.remoting.network; import javax.management.Notification; import javax.management.ObjectName; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.ServerInvokerMetadata; import org.jboss.remoting.ident.Identity; /** * NetworkNotification is a JMX Notification that is sent when changes occur to the network layout as * tracked by a NetworkRegistryMBean. * * @author Jeff Haynie * @version $Revision: 566 $ */ public class NetworkNotification extends Notification { static final long serialVersionUID = 987487760197074685L; public static final String SERVER_ADDED = "jboss.network.server.added"; public static final String SERVER_UPDATED = "jboss.network.server.updated"; public static final String SERVER_REMOVED = "jboss.network.server.removed"; public static final String DOMAIN_CHANGED = "jboss.network.domain.changed"; private final Identity identity; private final ServerInvokerMetadata serverInvokers[]; private final InvokerLocator locators[]; public NetworkNotification(ObjectName source, String type, Identity identity, ServerInvokerMetadata serverInvokers[]) { super(type, source, System.currentTimeMillis()); this.identity = identity; this.serverInvokers = serverInvokers; this.locators = null; } public NetworkNotification(ObjectName source, String type, Identity identity, InvokerLocator locators[]) { super(type, source, System.currentTimeMillis()); this.identity = identity; this.serverInvokers = null; this.locators = locators; } /** * return the identity of the notification * * @return */ public final Identity getIdentity() { return identity; } /** * return the locators affected by the notification * * @return */ public final InvokerLocator[] getLocator() { if(locators != null) { return locators; } else { InvokerLocator[] locators = new InvokerLocator[serverInvokers.length]; for(int x = 0; x < serverInvokers.length; x++) { locators[x] = serverInvokers[x].getInvokerLocator(); } return locators; } } /** * Gets all the server invoker metadata for the servers running on * specified server. Will include locator and supported subsystems * for that locator. * * @return */ public final ServerInvokerMetadata[] getServerInvokers() { return serverInvokers; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkRegistryWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkRegistryWrapper.jav0000644000175000017500000002107311413660476033567 0ustar twernertwerner /* * 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.remoting.network; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javax.management.ListenerNotFoundException; import javax.management.MBeanNotificationInfo; import javax.management.MBeanServer; import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; import org.jboss.remoting.detection.ServerInvokerMetadata; import org.jboss.remoting.ident.Identity; import org.jboss.remoting.util.SecurityUtility; /** * A NetworkRegistryWrapper is used to wrap an MBean proxy that implements * org.jboss.remoting.network.NetworkRegistryWrapper. If necessary, each call * will go through an AccessController.doPrivileged() call. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 6, 2008 *

          */ public class NetworkRegistryWrapper implements NetworkRegistryMBean { private NetworkRegistryMBean proxy; public NetworkRegistryWrapper(NetworkRegistryMBean proxy) { this.proxy = proxy; } public void addServer(final Identity identity, final ServerInvokerMetadata[] invokers) { if (SecurityUtility.skipAccessControl()) { proxy.addServer(identity, invokers); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.addServer(identity, invokers); return null; } }); } public void changeDomain(final String newDomain) { if (SecurityUtility.skipAccessControl()) { proxy.changeDomain(newDomain); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.changeDomain(newDomain); return null; } }); } public NetworkInstance[] getServers() { if (SecurityUtility.skipAccessControl()) { return proxy.getServers(); } return (NetworkInstance[]) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return proxy.getServers(); } }); } public boolean hasServer(final Identity identity) { if (SecurityUtility.skipAccessControl()) { return proxy.hasServer(identity); } return ((Boolean) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(proxy.hasServer(identity)); } })).booleanValue(); } public NetworkInstance[] queryServers(final NetworkFilter filter) { if (SecurityUtility.skipAccessControl()) { return proxy.queryServers(filter); } return (NetworkInstance[]) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return proxy.queryServers(filter); } }); } public void removeServer(final Identity identity) { if (SecurityUtility.skipAccessControl()) { proxy.removeServer(identity); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.removeServer(identity); return null; } }); } public void updateServer(final Identity identity, final ServerInvokerMetadata[] invokers) { if (SecurityUtility.skipAccessControl()) { proxy.updateServer(identity, invokers); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.updateServer(identity, invokers); return null; } }); } public void addNotificationListener(final NotificationListener listener, final NotificationFilter filter, final Object handback) throws IllegalArgumentException { if (SecurityUtility.skipAccessControl()) { proxy.addNotificationListener(listener, filter, handback); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IllegalArgumentException { proxy.addNotificationListener(listener, filter, handback); return null; } }); } catch (PrivilegedActionException e) { throw (IllegalArgumentException) e.getCause(); } } public MBeanNotificationInfo[] getNotificationInfo() { if (SecurityUtility.skipAccessControl()) { return proxy.getNotificationInfo(); } return (MBeanNotificationInfo[]) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return proxy.getNotificationInfo(); } }); } public void removeNotificationListener(final NotificationListener listener) throws ListenerNotFoundException { if (SecurityUtility.skipAccessControl()) { proxy.removeNotificationListener(listener); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws ListenerNotFoundException { proxy.removeNotificationListener(listener); return null; } }); } catch (PrivilegedActionException e) { throw (ListenerNotFoundException) e.getCause(); } } public void postDeregister() { if (SecurityUtility.skipAccessControl()) { proxy.postDeregister(); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.postDeregister(); return null; } }); } public void postRegister(final Boolean registrationDone) { if (SecurityUtility.skipAccessControl()) { proxy.postRegister(registrationDone); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.postRegister(registrationDone); return null; } }); } public void preDeregister() throws Exception { if (SecurityUtility.skipAccessControl()) { proxy.preDeregister(); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { proxy.preDeregister(); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } public ObjectName preRegister(final MBeanServer server, final ObjectName name) throws Exception { if (SecurityUtility.skipAccessControl()) { return proxy.preRegister(server, name); } try { return (ObjectName) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return proxy.preRegister(server, name); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/network/NetworkRegistryQuery.java0000644000175000017500000000611611171061123033377 0ustar twernertwerner/* * 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.remoting.network; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javax.management.BadAttributeValueExpException; import javax.management.BadBinaryOpValueExpException; import javax.management.BadStringOperationException; import javax.management.InstanceNotFoundException; import javax.management.InvalidApplicationException; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.QueryExp; import org.jboss.remoting.util.SecurityUtility; /** * NetworkRegistryQuery is a QueryExp that will filter on NetworkRegistryMBean mbeans. * * @author Jeff Haynie * @version $Revision: 5004 $ */ public class NetworkRegistryQuery implements QueryExp { private MBeanServer server; private static final long serialVersionUID = 2402056810602499064L; public boolean apply(final ObjectName objectName) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException { try { return isInstanceOf(server, objectName, NetworkRegistryMBean.class.getName()); } catch (InstanceNotFoundException e) { } return false; } public void setMBeanServer(MBeanServer mBeanServer) { this.server = mBeanServer; } static private boolean isInstanceOf(final MBeanServer server, final ObjectName objectName, final String className) throws InstanceNotFoundException { if (SecurityUtility.skipAccessControl()) { return server.isInstanceOf(objectName, className); } try { return ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new Boolean(server.isInstanceOf(objectName, className)); } })).booleanValue(); } catch (PrivilegedActionException e) { throw (InstanceNotFoundException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/InvocationFailureException.java0000644000175000017500000000341511413660476033014 0ustar twernertwerner /* * 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.remoting; import java.lang.Exception; import java.rmi.MarshalException; /** * Indicates a client invoker was unable to perform an invocation. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Dec 29, 2007 *

          */ public class InvocationFailureException extends MarshalException { /** The serialVersionUID */ private static final long serialVersionUID = -5852787672018746296L; public InvocationFailureException() { super(""); } public InvocationFailureException(Exception e) { super("", e); } public InvocationFailureException(String message) { super(message); } public InvocationFailureException(String message, Exception e) { super(message, e); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ServerInvokerMBean.java0000644000175000017500000000667110404171322031214 0ustar twernertwerner/* * 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.remoting; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public interface ServerInvokerMBean { /** * Will get the data type for the marshaller factory so know which marshaller to * get to marshal the data. Will first check the locator uri for a 'datatype' * parameter and take that value if it exists. Otherwise, will use the * default datatype for the client invoker, based on transport. * * @return */ String getDataType(); /** * returns true if the transport is bi-directional in nature, for example, * SOAP in unidirectional and SOCKETs are bi-directional (unless behind a firewall * for example). * * @return */ boolean isTransportBiDirectional(); void create(); /** * subclasses should override to provide any specific start logic * * @throws java.io.IOException */ void start() throws IOException; /** * return true if the server invoker is started, false if not * * @return */ boolean isStarted(); /** * subclasses should override to provide any specific stop logic */ void stop(); /** * destory the invoker permanently */ void destroy(); /** * Sets the server invoker's transport specific configuration. Will need to set before calling * start() method (or at least stop() and start() again) before configurations will take affect. * * @param configuration */ void setConfiguration(Map configuration); /** * Gets teh server invoker's transport specific configuration. * * @return */ Map getConfiguration(); /** * @jmx:managed-attribute */ String getClientConnectAddress(); int getClientConnectPort(); /** * This method should only be called by the service controller when this invoker is * specified within the Connector configuration of a service xml. Calling this directly * will have no effect, as will be used in building the locator uri that is published * for detection and this happens when the invoker is first created and started (after that, no one * will be aware of a change). * * @jmx:managed-attribute */ void setClientConnectAddress(String clientConnectAddress); String getServerBindAddress(); int getServerBindPort(); void setClientConnectPort(int clientConnectPort); void setTimeout(int timeout); int getTimeout(); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/Version.java0000644000175000017500000001422311422163247027132 0ustar twernertwerner/* * 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.remoting; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.jboss.remoting.util.SecurityUtility; /** * @author Tom Elrod */ public class Version { // possible remoting versions public static final byte VERSION_1 = 1; public static final byte VERSION_2 = 2; public static final byte VERSION_2_2 = 22; public static final String VERSION = "2.5.3.SP1 (Flounder)"; private static final byte byteVersion = VERSION_2_2; private static byte defaultByteVersion = byteVersion; private static boolean performVersioning = true; public static final String PRE_2_0_COMPATIBLE = "jboss.remoting.pre_2_0_compatible"; //TODO: -TME Is this the best system property key to use? May want to use something that // is more decscriptive that is user defined version. However, may want to make available // to users via system property the version of remoting? public static final String REMOTING_VERSION_TO_USE = "jboss.remoting.version"; // have a static block to load the user defined version to use static { try { ClassLoader cl = getClassLoader(); Class c = cl.loadClass("org.jboss.logging.Logger"); Method getLogger = c.getMethod("getLogger", new Class[]{String.class}); Object logger = getLogger.invoke(null, new Object[] {"org.jboss.remoting"}); Method debug = c.getMethod("debug", new Class[]{Object.class}); debug.invoke(logger, new Object[]{"Remoting version: " + VERSION}); } catch (Throwable t) { // ignore } boolean precompatibleFlag = false; String precompatible = getSystemProperty(PRE_2_0_COMPATIBLE); if(precompatible != null && precompatible.length() > 0) { precompatibleFlag = Boolean.valueOf(precompatible).booleanValue(); } // if is precompatible, no need to look for custom version, as there is only 1 precompatible version if(precompatibleFlag) { defaultByteVersion = 1; performVersioning = false; } else { String userDefinedVersion = getSystemProperty(REMOTING_VERSION_TO_USE); if(userDefinedVersion != null && userDefinedVersion.length() > 0) { byte userByteVersion = new Byte(userDefinedVersion).byteValue(); if(userByteVersion > 0) { defaultByteVersion = userByteVersion; if(defaultByteVersion < 2) { performVersioning = false; } } else { System.err.println("Can not set remoting version to value less than 1. " + "System property value set for '" + REMOTING_VERSION_TO_USE + "' was " + userDefinedVersion); } } else { setSystemProperty(REMOTING_VERSION_TO_USE, new Byte(defaultByteVersion).toString()); } } } public static void main(String arg[]) { System.out.println("JBossRemoting Version " + VERSION); } public static int getDefaultVersion() { return defaultByteVersion; } public static boolean performVersioning() { return performVersioning; } public static boolean performVersioning(int version) { return version >= 2; } public static boolean isValidVersion(int version) { return version == VERSION_1 || version == VERSION_2 || version == VERSION_2_2; } static private String getSystemProperty(final String name) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } static private ClassLoader getClassLoader() { if (SecurityUtility.skipAccessControl()) { return Version.class.getClassLoader(); } return (ClassLoader)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Version.class.getClassLoader(); } }); } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ClientHolder.java0000644000175000017500000000340310504141002030040 0ustar twernertwerner/* * 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.remoting; import java.io.Serializable; import java.util.Map; /** * @author Tom Elrod */ public class ClientHolder implements Serializable { private String sessionId; private Map config; private long leasePeriod; public static final String CLIENT_HOLDER_KEY = "ClientHolderKey"; public ClientHolder(String sessionId, Map config, long leasePeriod) { this.sessionId = sessionId; this.config = config; this.leasePeriod = leasePeriod; } public String getSessionId() { return sessionId; } public Map getConfig() { return config; } public long getLeasePeriod() { return leasePeriod; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ConnectionValidator.java0000644000175000017500000007430611413635702031462 0ustar twernertwerner/* * 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.remoting; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.Timer; import java.util.TimerTask; import org.jboss.logging.Logger; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.util.StoppableTimerTask; import org.jboss.remoting.util.TimerUtil; /** * @author Tom Elrod * @author Ovidiu Feodorov * @author Trustin Lee */ public class ConnectionValidator extends TimerTask implements StoppableTimerTask { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(ConnectionValidator.class.getName()); /** Configuration map key for ping period. */ public static final String VALIDATOR_PING_PERIOD = "validatorPingPeriod"; /** Default ping period. Value is 2 seconds. */ public static final long DEFAULT_PING_PERIOD = 2000; /** Configuration map key for ping timeout. */ public static final String VALIDATOR_PING_TIMEOUT = "validatorPingTimeout"; /** Default ping timeout period. Value is 1 second. */ public static final String DEFAULT_PING_TIMEOUT = "1000"; /** Default ping timeout period. Value is 1 second. */ public static final int DEFAULT_PING_TIMEOUT_INT = 1000; /** * Default number of ping retries. Value is 1. * Currently implemented only on socket transport family. */ public static final String DEFAULT_NUMBER_OF_PING_RETRIES = "1"; /** * Key to determine if ConnectionValidator should tie failure to presence * of active lease on server side. Default value is "true". */ public static final String TIE_TO_LEASE = "tieToLease"; /** * Key to determine whether to stop ConnectionValidator when PING fails. * Default value is "true". */ public static final String STOP_LEASE_ON_FAILURE = "stopLeaseOnFailure"; /** * Key to determine value of disconnectTimeout upon connection failure. */ public static final String FAILURE_DISCONNECT_TIMEOUT = "failureDisconnectTimeout"; // Static --------------------------------------------------------------------------------------- private static boolean trace = log.isTraceEnabled(); /** * Will make $PING$ invocation on server. If sucessful, will return true. Otherwise, will throw * an exception. * * @param locator - locator for the server to ping * @param config - any configuration needed for server * @return true if alive, false if not */ public static boolean checkConnection(final InvokerLocator locator, Map config) throws Throwable { boolean pingWorked = false; final Map configMap = createPingConfig(config, null); int pingTimeout = Integer.parseInt((String) configMap.get(ServerInvoker.TIMEOUT)); ClientInvoker innerClientInvoker = null; try { try { innerClientInvoker = (ClientInvoker) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return InvokerRegistry.createClientInvoker(locator, configMap); } }); } catch (PrivilegedActionException pae) { throw pae.getException(); } if (!innerClientInvoker.isConnected()) { if (trace) { log.trace("inner client invoker not connected, connecting ..."); } innerClientInvoker.connect(); } pingWorked = doCheckConnection(innerClientInvoker, pingTimeout); } catch (Throwable throwable) { log.debug("ConnectionValidator unable to connect to server " + innerClientInvoker.getLocator().getProtocol() + "://" + innerClientInvoker.getLocator().getHost() + ":" + innerClientInvoker.getLocator().getPort(), throwable); } finally { if (innerClientInvoker != null) { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.destroyClientInvoker(locator, configMap); return null; } }); } } return pingWorked; } private static boolean doCheckConnection(ClientInvoker clientInvoker, int pingTimeout) throws Throwable { boolean pingWorked = false; try { // Sending null client id as don't want to trigger lease on server side. This also means // that client connection validator will NOT impact client lease, so can not depend on it // to maintain client lease with the server. InvocationRequest ir; ir = new InvocationRequest(null, Subsystem.SELF, "$PING$", null, null, null); ConnectionCheckThread t = new ConnectionCheckThread(clientInvoker, ir); t.start(); Thread.sleep(pingTimeout); pingWorked = t.isValid(); } catch (Throwable t) { log.debug("ConnectionValidator failed to ping via " + clientInvoker, t); } return pingWorked; } private static Map createPingConfig(Map config, Map metadata) { Map localConfig = new HashMap(); localConfig.put("connection_checker", "true"); if (config != null) { Object o = config.get(VALIDATOR_PING_TIMEOUT); log.trace("config timeout: " + o); if (o != null) { try { Integer.parseInt((String) o); localConfig.put(ServerInvoker.TIMEOUT, o); } catch (NumberFormatException e) { log.warn("Need integer for value of parameter " + VALIDATOR_PING_TIMEOUT + ". Using default value " + DEFAULT_PING_TIMEOUT); } } o = config.get("NumberOfCallRetries"); if (o != null) { localConfig.put("NumberOfCallRetries", o); } } if (metadata != null) { metadata.remove(ServerInvoker.TIMEOUT); localConfig.putAll(metadata); Object o = metadata.get(VALIDATOR_PING_TIMEOUT); if (o != null) { try { Integer.parseInt((String) o); localConfig.put(ServerInvoker.TIMEOUT, o); } catch (NumberFormatException e) { log.warn("Need integer for value of parameter " + VALIDATOR_PING_TIMEOUT + ". Using default value " + DEFAULT_PING_TIMEOUT); } } } if (localConfig.get(ServerInvoker.TIMEOUT) == null) { localConfig.put(ServerInvoker.TIMEOUT, DEFAULT_PING_TIMEOUT); } if (localConfig.get("NumberOfCallRetries") == null) { localConfig.put("NumberOfCallRetries", DEFAULT_NUMBER_OF_PING_RETRIES); } return localConfig; } // Attributes ----------------------------------------------------------------------------------- private Client client; private long pingPeriod; private Map metadata; private InvokerLocator locator; private Map configMap; private Map listeners; private ClientInvoker clientInvoker; private Object lock = new Object(); private Object notificationLock = new Object(); private boolean started; private volatile boolean stopped; private volatile boolean stopping; private String invokerSessionId; private boolean tieToLease = true; private boolean stopLeaseOnFailure = true; private int pingTimeout; private int failureDisconnectTimeout = -1; private volatile boolean isValid; private Timer timer; private MicroRemoteClientInvoker sharedInvoker; private LeasePinger leasePinger; private boolean useClientConnectionIdentity; // Constructors --------------------------------------------------------------------------------- public ConnectionValidator(Client client) { this(client, DEFAULT_PING_PERIOD); } public ConnectionValidator(Client client, long pingPeriod) { this.client = client; this.locator = client.getInvoker().getLocator(); this.pingPeriod = pingPeriod; pingTimeout = DEFAULT_PING_TIMEOUT_INT; listeners = new HashMap(); stopped = false; getParameters(client, new HashMap()); log.debug(this + " created"); } public ConnectionValidator(Client client, Map metadata) { this.client = client; this.locator = client.getInvoker().getLocator(); pingPeriod = DEFAULT_PING_PERIOD; pingTimeout = DEFAULT_PING_TIMEOUT_INT; listeners = new HashMap(); stopped = false; this.metadata = new HashMap(metadata); getParameters(client, metadata); log.debug(this + " created"); } // StoppableTimerTask implementation ------------------------------------------------------------ public void stop() { if (stopped) { return; } doStop(); } // TimerTask overrides -------------------------------------------------------------------------- /** * The action to be performed by this timer task. */ public void run() { synchronized (lock) { if (!started) { throw new IllegalStateException( ConnectionValidator.class.getName() + ".run() should not be " + "called directly; use " + ConnectionValidator.class.getName() + ".addConnectionListener() instead."); } if (stopping) { return; } TimerTask tt = new WaitOnConnectionCheckTimerTask(); try { timer.schedule(tt, 0); } catch (IllegalStateException e) { log.debug("Unable to schedule TimerTask on existing Timer", e); timer = new Timer(true); timer.schedule(tt, 0); } } try { if(!stopping) { isValid = false; if (tieToLease && client.getLeasePeriod() > 0) { if (trace) { log.trace(this + " sending PING tied to lease"); } isValid = doCheckConnectionWithLease(); } else { if (trace) { log.trace(this + " pinging ..."); } isValid = doCheckConnectionWithoutLease(); } } } catch (Throwable thr) { log.debug(this + " got throwable while pinging", thr); if (stopLeaseOnFailure) { log.debug(this + " detected connection failure: stopping"); cancel(); } } finally { synchronized (notificationLock) { notificationLock.notifyAll(); } } } public boolean cancel() { return doStop(); } // Public --------------------------------------------------------------------------------------- public boolean addConnectionListener(Client client, ConnectionListener listener) { boolean doStart = false; if (listener != null) { synchronized (lock) { if (stopping) { if (trace) log.trace(this + " is stopped. Cannot add ConnectionListener: " + listener + " for " + client); return false; } if (listeners.size() == 0) { doStart = true; } Set s = (Set) listeners.get(listener); if (s == null) { s = new HashSet(); } s.add(client); listeners.put(listener, s); log.debug(this + " added ConnectionListener: " + listener + " for " + client); } if (doStart) { start(); } } return true; } public boolean removeConnectionListener(Client client, ConnectionListener listener) { if (listener == null) { if (trace) log.trace(this + " ConnectionListener is null"); return false; } synchronized (lock) { if (stopping) { if (trace) log.trace(this + " is stopped. It's too late to remove " + listener); return false; } Set s = (Set) listeners.get(listener); if (s == null) { log.debug(this + ": " + listener + " is not registered"); return false; } if (s.remove(client)) { log.debug(this + " removed ConnectionListener: " + listener + " for " + client); } else { log.debug(this + ": " + listener + " is not registered for " + client); return false; } if (s.size() == 0) { listeners.remove(listener); } if (listeners.size() == 0) { stop(); } } return true; } public long getPingPeriod() { if (stopping) { return -1; } return pingPeriod; } public String toString() { return "ConnectionValidator[" + Integer.toHexString(System.identityHashCode(this)) + ":" + clientInvoker + ", pingPeriod=" + pingPeriod + " ms]"; } public boolean isStopped() { return stopped; } // Package protected ---------------------------------------------------------------------------- void notifyListeners(Throwable thr) { final Throwable t = thr; synchronized (lock) { if (stopping) { return; } stopping = true; if (trace) log.trace(this + " is stopped. No more listeners will be accepted."); Iterator itr = listeners.keySet().iterator(); while (itr.hasNext()) { final ConnectionListener listener = (ConnectionListener) itr.next(); Set clients = (Set) listeners.get(listener); Iterator itr2 = clients.iterator(); while (itr2.hasNext()) { final Client client = (Client) itr2.next(); new Thread() { public void run() { log.debug(ConnectionValidator.this + " calling " + listener + ".handleConnectionException() for " + client); listener.handleConnectionException(t, client); } }.start(); } } listeners.clear(); } stop(); } // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- private void getParameters(Client client, Map metadata) { if (checkUseParametersFromLocator(client, metadata)) { getParametersFromMap(client.getInvoker().getLocator().getParameters()); } getParametersFromMap(client.getConfiguration()); getParametersFromMap(metadata); ClientInvoker clientInvoker = client.getInvoker(); if (clientInvoker instanceof MicroRemoteClientInvoker) { sharedInvoker = (MicroRemoteClientInvoker) clientInvoker; invokerSessionId = sharedInvoker.getSessionId(); } else { throw new RuntimeException("creating a ConnectionValidator on a local connection"); } if (stopLeaseOnFailure) { if (sharedInvoker != null) { leasePinger = sharedInvoker.getLeasePinger(); } } if (trace) log.trace(this + ": sharedInvoker = " + sharedInvoker + ", leasePinger = " + leasePinger); } private boolean checkUseParametersFromLocator(Client client, Map metadata) { if (client.getInvoker() == null) { return false; } Object o = client.getInvoker().getLocator().getParameters().get(Client.USE_ALL_PARAMS); if (o != null) { if (o instanceof String) { return Boolean.valueOf(((String) o)).booleanValue(); } else { log.warn(this + " could not convert " + Client.USE_ALL_PARAMS + " value" + " in InvokerLocator to a boolean: must be a String"); } } o = client.getConfiguration().get(Client.USE_ALL_PARAMS); if (o != null) { if (o instanceof String) { return Boolean.valueOf(((String) o)).booleanValue(); } else { log.warn(this + " could not convert " + Client.USE_ALL_PARAMS + " value" + " in Client configuration map to a boolean: must be a String"); } } o = metadata.get(Client.USE_ALL_PARAMS); if (o != null) { if (o instanceof String) { return Boolean.valueOf(((String) o)).booleanValue(); } else { log.warn(this + " could not convert " + Client.USE_ALL_PARAMS + " value" + " in metadata map to a boolean: must be a String"); } } return false; } private void getParametersFromMap(Map config) { if (config != null) { Object o = config.get(VALIDATOR_PING_PERIOD); if (o != null) { if (o instanceof String) { try { pingPeriod = Long.parseLong((String)o); } catch (Exception e) { log.warn(this + " could not convert " + VALIDATOR_PING_PERIOD + " value of " + o + " to a long value"); } } else { log.warn(this + " could not convert " + VALIDATOR_PING_PERIOD + " value of " + o + " to a long value: must be a String"); } } o = config.get(VALIDATOR_PING_TIMEOUT); if (o != null) { if (o instanceof String) { try { pingTimeout = Integer.parseInt((String)o); } catch (Exception e) { log.warn(this + " could not convert " + VALIDATOR_PING_TIMEOUT + " value of " + o + " to a long value"); } } else { log.warn(this + " could not convert " + VALIDATOR_PING_TIMEOUT + " value of " + o + " to a long value: must be a String"); } } o = config.get(TIE_TO_LEASE); if (o != null) { if (o instanceof String) { try { tieToLease = Boolean.valueOf(((String) o)).booleanValue(); } catch (Exception e) { log.warn(this + " could not convert " + TIE_TO_LEASE + " value" + " to a boolean: " + o); } } else { log.warn(this + " could not convert " + TIE_TO_LEASE + " value" + " to a boolean: must be a String"); } } o = config.get(STOP_LEASE_ON_FAILURE); if (o != null) { if (o instanceof String) { try { stopLeaseOnFailure = Boolean.valueOf(((String) o)).booleanValue(); } catch (Exception e) { log.warn(this + " could not convert " + STOP_LEASE_ON_FAILURE + " value" + " to a boolean: " + o); } } else { log.warn(this + " could not convert " + STOP_LEASE_ON_FAILURE + " value" + " to a boolean: must be a String"); } } o = config.get(FAILURE_DISCONNECT_TIMEOUT); if (trace) log.trace(this + " \"failureDisconnectTimeout\" set to " + o); if (o != null) { if (o instanceof String) { try { failureDisconnectTimeout = Integer.valueOf(((String) o)).intValue(); if (trace) log.trace(this + " setting failureDisconnectTimeout to " + failureDisconnectTimeout); } catch (Exception e) { log.warn(this + " could not convert " + FAILURE_DISCONNECT_TIMEOUT + " value" + " to an int: " + o); } } else { log.warn(this + " could not convert " + FAILURE_DISCONNECT_TIMEOUT + " value" + " to an int: must be a String"); } } o = config.get(Remoting.USE_CLIENT_CONNECTION_IDENTITY); if (o != null) { if (o instanceof String) { try { useClientConnectionIdentity = Boolean.valueOf(((String) o)).booleanValue(); } catch (Exception e) { log.warn(this + " could not convert " + Remoting.USE_CLIENT_CONNECTION_IDENTITY + " value" + " to a boolean: " + o); } } else { log.warn(this + " could not convert " + Remoting.USE_CLIENT_CONNECTION_IDENTITY + " value" + " to a boolean: must be a String"); } } } } private void start() { metadata.put(ServerInvoker.TIMEOUT, Integer.toString(pingTimeout)); configMap = createPingConfig(client.getConfiguration(), metadata); log.debug(this + ": pingPeriod: " + this.pingPeriod); log.debug(this + ": pingTimeout: " + this.pingTimeout); log.debug(this + ": ping retries: " + configMap.get("NumberOfCallRetries")); try { try { clientInvoker = (ClientInvoker) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return InvokerRegistry.createClientInvoker(locator, configMap); } }); } catch (PrivilegedActionException pae) { throw pae.getException(); } } catch (Exception e) { log.debug("Unable to create client invoker for locator: " + locator); throw new RuntimeException("Unable to create client invoker for locator: " + locator, e); } if (!clientInvoker.isConnected()) { if (trace) { log.trace("inner client invoker not connected, connecting ..."); } clientInvoker.connect(); } started = true; timer = new Timer(true); try { TimerUtil.schedule(this, pingPeriod); } catch (Exception e) { log.error(this + " unable to schedule on TimerUtil", e); started = false; timer = null; return; } log.debug(this + " started"); } private boolean doCheckConnectionWithLease() throws Throwable { boolean pingWorked = false; try { Map metadata = new HashMap(); metadata.put(ServerInvoker.INVOKER_SESSION_ID, invokerSessionId); InvocationRequest ir = new InvocationRequest(null, Subsystem.SELF, "$PING$", metadata, null, null); if (trace) { log.trace("pinging, sending " + ir + " over " + clientInvoker); } Object o = clientInvoker.invoke(ir); if (o instanceof Boolean && !((Boolean) o).booleanValue()) { // Server indicates lease has stopped. throw new Exception(); } if (trace) { log.trace("ConnectionValidator got successful ping using " + clientInvoker);} pingWorked = true; } catch (Throwable t) { log.debug("ConnectionValidator failed to ping via " + clientInvoker, t); } return pingWorked; } private boolean doCheckConnectionWithoutLease() throws Throwable { boolean pingWorked = false; try { // Sending null client id as don't want to trigger lease on server side. This also means // that client connection validator will NOT impact client lease, so can not depend on it // to maintain client lease with the server. InvocationRequest ir = new InvocationRequest(null, Subsystem.SELF, "$PING$", null, null, null); if (trace) { log.trace("pinging, sending " + ir + " over " + clientInvoker); } clientInvoker.invoke(ir); if (trace) { log.trace("ConnectionValidator got successful ping using " + clientInvoker);} pingWorked = true; } catch (Throwable t) { log.debug("ConnectionValidator failed to ping via " + clientInvoker, t); } return pingWorked; } private boolean doStop() { if (trace) log.trace("entering doStop()"); synchronized(lock) { if (stopped) { return false; } if (!listeners.isEmpty()) { listeners.clear(); } stopping = true; stopped = true; timer = null; } if (clientInvoker != null) { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.destroyClientInvoker(locator, configMap); return null; } }); } TimerUtil.unschedule(this); boolean result = super.cancel(); log.debug(this + " stopped, returning " + result); return result; } // Inner classes -------------------------------------------------------------------------------- private class WaitOnConnectionCheckTimerTask extends TimerTask { public void run() { long start = System.currentTimeMillis(); synchronized (notificationLock) { while (true) { int elapsed = (int) (System.currentTimeMillis() - start); int wait = pingTimeout - elapsed; if (wait <= 0) { break; } try { notificationLock.wait(wait); break; } catch (InterruptedException e) { continue; } } } if (!isValid) { log.debug(ConnectionValidator.this + "'s connection is invalid"); ConnectionValidator.super.cancel(); if (stopLeaseOnFailure) { if (trace) log.trace(ConnectionValidator.this + " detected connection failure: stopping LeasePinger"); if (leasePinger != null) { log.debug(ConnectionValidator.this + " shutting down lease pinger: " + leasePinger); int disconnectTimeout = (failureDisconnectTimeout == -1) ? client.getDisconnectTimeout() : failureDisconnectTimeout; if (trace) log.trace(ConnectionValidator.this + " disconnectTimeout: " + disconnectTimeout); sharedInvoker.terminateLease(null, disconnectTimeout, leasePinger); } else { if (trace) log.trace(ConnectionValidator.this + ": lease pinger == null: perhaps leasing is not enabled for this connection"); notifyListeners(new Exception("Could not connect to server!")); } cancel(); } if (!useClientConnectionIdentity) { notifyListeners(new Exception("Could not connect to server!")); } } } } private static class ConnectionCheckThread extends Thread { private InvocationRequest ir; private ClientInvoker clientInvoker; private boolean isValid; public ConnectionCheckThread(ClientInvoker clientInvoker, InvocationRequest ir) { this.clientInvoker = clientInvoker; this.ir = ir; setDaemon(true); } public void run() { try { if (trace) { log.trace("pinging, sending " + ir + " over " + clientInvoker); } clientInvoker.invoke(ir); isValid = true; if (trace) { log.trace("ConnectionValidator got successful ping using " + clientInvoker);} } catch (Throwable t) { log.debug("ConnectionValidator failed to ping via " + clientInvoker, t); } } public boolean isValid() { return isValid; } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/MicroRemoteClientInvoker.java0000644000175000017500000006674711377763324032464 0ustar twernertwernerpackage org.jboss.remoting; import org.jboss.logging.Logger; import org.jboss.remoting.loading.ClassByteClassLoader; import org.jboss.remoting.loading.RemotingClassLoader; import org.jboss.remoting.marshal.InvalidMarshallingResource; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.UpdateableClassloaderUnMarshaller; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.util.SecurityUtility; import org.jboss.util.id.GUID; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.WeakHashMap; /** * MicroRemoteClientInvoker is an abstract client part handler that implements the bulk of the heavy * lifting to process a remote method and dispatch it to a remote ServerInvoker and handle the result.

          *

          * Specialized Client/Server Invokers might add additional functionality as part of the invocation - such as * delivering queued notifcations from a remote server by adding the notification objects during each invocation * to the invocation result payload and then having the client re-dispatch the notifications locally upon * receiving the return invocation result. * * The reason for the name micro is that this class contains only api that can be run within a J2ME envrionment. * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5868 $ */ public abstract class MicroRemoteClientInvoker extends AbstractInvoker implements ClientInvoker { private static final Logger log = Logger.getLogger(MicroRemoteClientInvoker.class); private boolean trace = log.isTraceEnabled(); protected boolean connected = false; private Marshaller marshaller; private Map unmarshallers = new WeakHashMap(); private String dataType; private final Object clientLeaseLock = new Object(); private LeasePinger leasePinger = null; private String invokerSessionID = new GUID().toString(); protected boolean parentFirstClassLoading = true; private boolean changeInvalidStateToCannotConnect = false; protected List connectHomes; public MicroRemoteClientInvoker(InvokerLocator locator) { super(locator); init(); } public MicroRemoteClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); init(); } /** * Transport a request against a remote ServerInvoker. */ public Object invoke(InvocationRequest invocationReq) throws Throwable { Object returnValue = null; int invokeCount = 0; if (trace) { log.trace(this + "(" + (++invokeCount) + ") invoking " + invocationReq); } // Set up marshaller and unmarshaller. Marshaller marshaller = null; UnMarshaller unmarshaller = null; RemotingClassLoader rcl = null; synchronized (MicroRemoteClientInvoker.class) { marshaller = getMarshaller(); if (marshaller == null) { // try by locator (in case marshaller class name specified) Map map = passConfigMapToMarshalFactory ? configuration : null; marshaller = MarshalFactory.getMarshaller(getLocator(), getClassLoader(), map); if (marshaller == null) { // need to have a marshaller, so create a default one marshaller = MarshalFactory.getMarshaller(getDataType(), getSerializationType()); if (marshaller == null) { // went as far as possible to find a marshaller, will have to give up throw new InvalidMarshallingResource( "Can not find a valid marshaller for data type: " + getDataType()); } } setMarshaller(marshaller); } unmarshaller = getUnMarshaller(); if (unmarshaller == null) { // try by locator (in case unmarshaller class name specified) Map map = passConfigMapToMarshalFactory ? configuration : null; unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), getClassLoader(), map); if (unmarshaller == null) { unmarshaller = MarshalFactory.getUnMarshaller(getDataType(), getSerializationType()); if (unmarshaller == null) { // went as far as possible to find a unmarshaller, will have to give up throw new InvalidMarshallingResource( "Can not find a valid unmarshaller for data type: " + getDataType()); } } setUnMarshaller(unmarshaller); } // Each unmarshaller gets a RemotingClassloader classloader containing the // remoting class loader (for remote classloading) and the current thread's // class loader. This allows to load remoting classes as well as user's // classes. If possible, will simply reset context classloader on existing // RemotingClassLoader. final ClassLoader contextClassLoader = getContextClassLoader(Thread.currentThread()); if (unmarshaller instanceof UpdateableClassloaderUnMarshaller) { UpdateableClassloaderUnMarshaller uclum = (UpdateableClassloaderUnMarshaller) unmarshaller; ClassLoader cl = uclum.getClassLoader(); if (cl instanceof RemotingClassLoader) { rcl = (RemotingClassLoader) cl; rcl.setUserClassLoader(contextClassLoader); } else { rcl = createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading); unmarshaller.setClassLoader(rcl); } } else { rcl = createRemotingClassLoader(getClassLoader(), contextClassLoader, parentFirstClassLoading); unmarshaller.setClassLoader(rcl); } } // if raw, then send only param of invocation request Object payload = null; Map metadata = invocationReq.getRequestPayload(); if (metadata != null && metadata.get(Client.RAW) != null) { payload = invocationReq.getParameter(); } else { payload = invocationReq; } try { String sessionId = invocationReq.getSessionId(); returnValue = transport(sessionId, payload, metadata, marshaller, unmarshaller); } finally { // Delete reference to current thread's context classloader. synchronized (MicroRemoteClientInvoker.class) { rcl.unsetUserClassLoader(); } } // Now check if is remoting response and process if (returnValue instanceof InvocationResponse) { InvocationResponse response = (InvocationResponse)returnValue; returnValue = response.getResult(); // if is a server side exception, throw it if (response.isException()) { Throwable e = (Throwable)returnValue; if (trace) { log.trace(this + " received a server-side exception as response to the invocation: " + e); } StackTraceElement[] serverStackTrace; if (e.getCause() != null) { serverStackTrace = e.getCause().getStackTrace(); if (serverStackTrace == null || serverStackTrace.length == 0) { serverStackTrace = e.getStackTrace(); } } else { serverStackTrace = e.getStackTrace(); } // need to check that there is a server stack trace. If there is not, need to log // warning here so caller knows that error happened on server side and to look there, // as stack trace is just going to lead them to here, giving the impression that is // a client side exception from this point within remoting client. if (serverStackTrace == null || serverStackTrace.length == 0) { log.warn("An exception occurred on the server side when making remote invocation. " + "The exception returned from server does not include a stack trace. " + "Original server side exception message is " + e.getMessage(), e); } Exception clientException = new Exception(); StackTraceElement[] clientStackTrace = clientException.getStackTrace(); StackTraceElement[] completeStackTrace = new StackTraceElement[serverStackTrace.length + clientStackTrace.length]; System.arraycopy(serverStackTrace, 0, completeStackTrace, 0, serverStackTrace.length); System.arraycopy(clientStackTrace, 0, completeStackTrace, serverStackTrace.length, clientStackTrace.length); Throwable responseException = null; if (e instanceof ServerInvoker.InvalidStateException && changeInvalidStateToCannotConnect) { responseException = new CannotConnectException(e.getMessage(), e.getCause()); } else { responseException = e; } if (e.getCause() != null) { responseException.getCause().setStackTrace(completeStackTrace); } else { responseException.setStackTrace(completeStackTrace); } throw responseException; } if (trace) { log.trace(this + " received InvocationResponse so going to return response's return value of " + returnValue);} } return returnValue; } /** * this method is called prior to making the remote invocation to allow the subclass the ability * to provide additional data or modify the invocation * * @param sessionId * @param param * @param sendPayload * @param receivedPayload */ protected void preProcess(String sessionId, Object param, Map sendPayload, Map receivedPayload) { } /** * this method is called prior to returning the result for the invocation to allow the subclass the ability * to modify the result result * * @param sessionId * @param param * @param sendPayload * @param receivedPayload */ protected void postProcess(String sessionId, Object param, Map sendPayload, Map receivedPayload) { } protected abstract Object transport(String sessionId, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller) throws IOException, ConnectionFailedException, ClassNotFoundException; /** * Subclasses must provide this method to return true if their remote connection is connected and * false if disconnected. in some transports, such as SOAP, this method may always return true, * since the remote connectivity is done on demand and not kept persistent like other transports * (such as socket-based transport). * * @return boolean true if connected, false if not */ public boolean isConnected() { return connected; } /** * Connect to the remote invoker. */ public synchronized void connect() throws ConnectionFailedException { if (!connected) { log.debug(this + " connecting"); // In single home case, locator's connect homes list consists // locator's host:port. In multihome case, connect homes list // is empty unless explicitly defined. connectHomes = locator.getConnectHomeList(); if (locator.isMultihome() && connectHomes.isEmpty()) { connectHomes = locator.getHomeList(); } handleConnect(); connected = true; log.debug(this + " connected"); } } /** * Subclasses must implement this method to provide a hook to connect to the remote server, if * this applies to the specific transport. However, in some transport implementations, this may * not make must difference since the connection is not persistent among invocations, such as * SOAP. In these cases, the method should silently return without any processing. * * @throws ConnectionFailedException * */ protected abstract void handleConnect() throws ConnectionFailedException; /** * Subclasses must implement this method to provide a hook to disconnect from the remote server, * if this applies to the specific transport. However, in some transport implementations, this * may not make must difference since the connection is not persistent among invocations, such as * SOAP. In these cases, the method should silently return without any processing. */ protected abstract void handleDisconnect(); /** * disconnect from the remote invokere */ public synchronized void disconnect() { if (trace) { log.trace(this + " disconnecting ..."); } if (connected) { connected = false; handleDisconnect(); ClassLoader classLoader = getClassLoader(); if (classLoader != null && classLoader instanceof ClassByteClassLoader) { ((ClassByteClassLoader) classbyteloader).destroy(); } if (trace) { log.trace(this + " disconnected"); } } else { if (trace) { log.trace(this + " is not connected!"); } } } public void setMarshaller(Marshaller marshaller) { this.marshaller = marshaller; } public Marshaller getMarshaller() { return this.marshaller; } public void setUnMarshaller(UnMarshaller unmarshaller) { ClassLoader classLoader = getContextClassLoader(Thread.currentThread()); unmarshallers.put(classLoader, unmarshaller); } public UnMarshaller getUnMarshaller() { ClassLoader classLoader = getContextClassLoader(Thread.currentThread()); return (UnMarshaller)unmarshallers.get(classLoader); } public String getSessionId() { return this.invokerSessionID; } public void terminateLease(String sessionId, int disconnectTimeout) { terminateLease(sessionId, disconnectTimeout, null); } public void terminateLease(String sessionId, int disconnectTimeout, LeasePinger passedLeasePinger) { synchronized(clientLeaseLock) { if (passedLeasePinger != null && passedLeasePinger != leasePinger) { if (trace) log.trace(this + ": " + passedLeasePinger + " != " + leasePinger); return; } if (trace) log.trace(this + " entering terminateLease() for " + leasePinger); if(leasePinger != null) { leasePinger.setDisconnectTimeout(disconnectTimeout); if (sessionId == null) { if (trace) log.trace(this + " shutting down LeasePinger: " + leasePinger); // Independent of any particular Client - force LeasePinger shutdown. // Should be called only if there is a reasonable belief that the lease // has already stopped on the server side. try { leasePinger.stopPing(); } catch (Exception e) { log.debug("error shutting down lease pinger" + e.getMessage()); log.trace("error shutting down lease pinger", e); } leasePinger = null; } else { // Remove a particular Client. if (trace) log.trace(this + " removing client " + sessionId + " from LeasePinger: " + leasePinger); boolean isLastClientLease = leasePinger.removeClient(sessionId); if(isLastClientLease) { if (trace) log.trace(this + " shutting down LeasePinger, " + sessionId + " was last client lease: " + leasePinger); try { leasePinger.stopPing(); } catch (Exception e) { log.debug("error shutting down lease pinger"); } leasePinger = null; } } } else { if (trace) log.trace(this + " leasePinger is null: must have been shut down already"); } if (trace) log.trace(this + " leaving terminateLease() for " + leasePinger); } } public long getLeasePeriod(String sessionID) { synchronized(clientLeaseLock) { if(leasePinger == null) { return -1; } return leasePinger.getLeasePeriod(sessionID); } } public void establishLease(String clientSessionID, Map configuration, long leasePeriod) throws Throwable { Client client = (Client) configuration.get(Client.CLIENT); ConnectionListener listener = (ConnectionListener) configuration.remove(Client.CONNECTION_LISTENER); boolean useClientConnectionIdentity = false; if (configuration != null) { Object o = configuration.get(Remoting.USE_CLIENT_CONNECTION_IDENTITY); if (o instanceof String) { useClientConnectionIdentity = Boolean.valueOf((String) o).booleanValue(); } else if (o != null) { log.warn("value of " + Remoting.USE_CLIENT_CONNECTION_IDENTITY + " must be a String: " + o); } } synchronized (clientLeaseLock) { // if already have a lease pinger, then already have a client with an established // lease and just need to update the lease pinger if (leasePinger != null) { leasePinger.addClient(clientSessionID, configuration, leasePeriod); if (trace) log.trace(this + " added client with session ID " + clientSessionID + " to " + leasePinger); } else { try { if(trace) { log.trace(this + " sending initial lease ping to server to determine if server has leasing enabled."); } // configuration should NOT be passed as want ping to be specific to client invoker // and NOT to the client. String leasePingerId = new GUID().toString(); Map requestMap = new HashMap(); requestMap.put(LeasePinger.LEASE_PINGER_ID, leasePingerId); requestMap.put(LeasePinger.TIME_STAMP, Long.toString(System.currentTimeMillis())); if (trace) log.trace(this + " initiating lease for leasePingerId " + leasePingerId); InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestMap, new HashMap(), null); Object ret = invoke(ir); if (ret instanceof InvocationResponse) { InvocationResponse resp = (InvocationResponse) ret; Boolean shouldLease = (Boolean)resp.getResult(); if (shouldLease.booleanValue()) { long defaultLeasePeriod = LeasePinger.DEFAULT_LEASE_PERIOD; Map respMap = resp.getPayload(); if (respMap != null) { Long leaseTimeoutValue = (Long)respMap.get("clientLeasePeriod"); long serverDefaultLeasePeriod = leaseTimeoutValue.longValue(); if(serverDefaultLeasePeriod > 0) { defaultLeasePeriod = serverDefaultLeasePeriod; } } if(trace) { log.trace("server does have leasing enabled (with default lease period of " + defaultLeasePeriod + ") and will start a new lease pinger."); } leasePinger = new LeasePinger(this, invokerSessionID, defaultLeasePeriod, configuration); leasePinger.setLeasePingerId(leasePingerId); leasePinger.setUseClientConnectionIdentity(useClientConnectionIdentity); leasePinger.addClient(clientSessionID, configuration, leasePeriod); leasePinger.startPing(); } } } catch (Throwable throwable) { Exception e = new Exception("Error setting up client lease"); e.initCause(throwable); throw e; } } if (trace) log.trace(this + ": client = " + client + ", listener = " + listener); if (client != null && listener != null) { client.addConnectionListener(listener, configuration); } } } /** * Will get the data type for the marshaller factory so know which marshaller to * get to marshal the data. Will first check the locator uri for a 'datatype' * parameter and take that value if it exists. Otherwise, will use the * default datatype for the client invoker, based on transport. */ private String getDataType() { if (dataType == null) { String localDataType = getDataType(getLocator()); if (localDataType == null) { localDataType = getDefaultDataType(); } dataType = localDataType; } return dataType; } private String getDataType(InvokerLocator locator) { String type = null; if (locator != null) { Map params = locator.getParameters(); if (params != null) { type = (String) params.get(InvokerLocator.DATATYPE); if (type == null) { type = (String) params.get(InvokerLocator.DATATYPE_CASED); } } } return type; } protected void init() { // Get the parent delegation order flag, default is parent first Object flag = super.getConfiguration().get(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION); if(flag == null) { // Fallback to the system property flag = getSystemProperty(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PROP); } boolean parentFirst = true; if (flag != null) { String sflag = flag.toString(); parentFirst = Boolean.valueOf(sflag).booleanValue(); } parentFirstClassLoading = parentFirst; flag = configuration.get(Remoting.CHANGE_INVALID_STATE_TO_CANNOT_CONNECT); if (flag != null) { String sflag = flag.toString(); changeInvalidStateToCannotConnect = Boolean.valueOf(sflag).booleanValue(); } } /** * Each implementation of the remote client invoker should have * a default data type that is uses in the case it is not specified * in the invoker locator uri. */ protected abstract String getDefaultDataType(); protected List getConnectHomes() { return connectHomes; } /** * Called by the garbage collector on an object when garbage collection * determines that there are no more references to the object. * A subclass overrides the finalize method to dispose of * system resources or to perform other cleanup. *

          * The general contract of finalize is that it is invoked * if and when the JavaTM virtual * machine has determined that there is no longer any * means by which this object can be accessed by any thread that has * not yet died, except as a result of an action taken by the * finalization of some other object or class which is ready to be * finalized. The finalize method may take any action, including * making this object available again to other threads; the usual purpose * of finalize, however, is to perform cleanup actions before * the object is irrevocably discarded. For example, the finalize method * for an object that represents an input/output connection might perform * explicit I/O transactions to break the connection before the object is * permanently discarded. *

          * The finalize method of class Object performs no * special action; it simply returns normally. Subclasses of * Object may override this definition. *

          * The Java programming language does not guarantee which thread will * transport the finalize method for any given object. It is * guaranteed, however, that the thread that invokes finalize will not * be holding any user-visible synchronization locks when finalize is * invoked. If an uncaught exception is thrown by the finalize method, * the exception is ignored and finalization of that object terminates. *

          * After the finalize method has been invoked for an object, no * further action is taken until the Java virtual machine has again * determined that there is no longer any means by which this object can * be accessed by any thread that has not yet died, including possible * actions by other objects or classes which are ready to be finalized, * at which point the object may be discarded. *

          * The finalize method is never invoked more than once by a Java * virtual machine for any given object. *

          * Any exception thrown by the finalize method causes * the finalization of this object to be halted, but is otherwise * ignored. * * @throws Throwable the Exception raised by this method */ protected void finalize() throws Throwable { disconnect(); super.finalize(); } protected LeasePinger getLeasePinger() { synchronized(clientLeaseLock) { return leasePinger; } } static private String getSystemProperty(final String name) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private RemotingClassLoader createRemotingClassLoader(final ClassLoader remotingClassLoader, final ClassLoader userClassLoader, final boolean parentFirstDelegation) { if (SecurityUtility.skipAccessControl()) { return new RemotingClassLoader(remotingClassLoader, userClassLoader, parentFirstDelegation); } return (RemotingClassLoader)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new RemotingClassLoader(remotingClassLoader, userClassLoader, parentFirstDelegation); } }); } static private ClassLoader getContextClassLoader(final Thread thread) { if (SecurityUtility.skipAccessControl()) { return thread.getContextClassLoader(); } return (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return thread.getContextClassLoader(); } }); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/Invoker.java0000644000175000017500000000234310355142433027120 0ustar twernertwerner/* * 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.remoting; /** * @author Tom Elrod */ public interface Invoker { /** * return the locator this Invoker represents * * @return */ public InvokerLocator getLocator(); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ServerInvocationHandler.java0000644000175000017500000000544610555200773032314 0ustar twernertwerner/* * 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.remoting; import javax.management.MBeanServer; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * ServerInvocationHandler is the server side (remote) end handler which is registered for a given * ServerInvoker implementation. The ServerInvocationHandler does the actual implementation work * of invoking the method on the target object in the remote VM. The ServerInvoker will then * handle marshalling and returning the results via the appropriate transport back to the client invoker. * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 1963 $ */ public interface ServerInvocationHandler { /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server); /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker); /** * called to handle a specific invocation. Please take care to make sure * implementations are thread safe and can, and often will, receive concurrent * calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable; /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler); /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler); public String toString(); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/0000755000175000017500000000000011632407045026374 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackListener.java0000644000175000017500000000313310527010403032427 0ustar twernertwerner/* * 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. */ /** * Interface for listener to be informed when a Callback has been processed.. * * @author Ron Sigal *

          * Copyright (c) 2006 *

          */ package org.jboss.remoting.callback; /** * @author rsigal * */ public interface CallbackListener { /** * @param callbackHandler InvokerCallbackHandler that handled this callback * @param callbackId id of callback being acknowledged * @param response either (1) response sent with acknowledgement or (2) null */ void acknowledgeCallback(InvokerCallbackHandler callbackHandler, Object callbackId, Object response); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackStoreMBean.java0000644000175000017500000000357410355142433032662 0ustar twernertwerner/* * 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.remoting.callback; import org.jboss.remoting.SerializableStore; /** * The MBean interface to the CallbackStore implementation. * * @author Tom Elrod */ public interface CallbackStoreMBean extends SerializableStore { /** * Gets the file path for the directory where the objects will be stored. * * @return */ String getStoreFilePath(); /** * Sets teh file path for the directory where the objects will be stored. * * @param filePath */ void setStoreFilePath(String filePath); /** * Gets the file suffix for each of the files that objects will be persisted to. * * @return */ String getStoreFileSuffix(); /** * Sets the file suffix for each of the files that objects will be persisted to. * * @param fileSuffix */ void setStoreFileSuffix(String fileSuffix); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/InvokerCallbackHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/InvokerCallbackHandler.ja0000644000175000017500000000317010355142433033237 0ustar twernertwerner/* * 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.remoting.callback; /** * Should be used a receiver of asynchronous callbacks for registered listeners. * Upon being called with a callback message, will send back to the client. * * @author Tom Elrod * @version $Revision: 566 $ */ public interface InvokerCallbackHandler { /** * 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 HandleCallbackException */ public void handleCallback(Callback callback) throws HandleCallbackException; } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/AsynchInvokerCallbackHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/AsynchInvokerCallbackHand0000644000175000017500000000624510533064733033323 0ustar twernertwerner/* * 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.remoting.callback; /** * AsynchInvokerCallbackHandler extends InvokerCallbackHandler with * asynchronous callback handling. * * @author Ron Sigal * @version $Revision: 1633 $ *

          * Copyright Nov 28, 2006 *

          */ public interface AsynchInvokerCallbackHandler extends InvokerCallbackHandler { /** * For push callbacks, will send the callback to the server invoker on the * client side, hand off processing to a separate thread, and return.

          * * For pull callbacks, behaves the same as handleCallback(Callback callback).

          * * @param callback * @throws HandleCallbackException */ public void handleCallbackOneway(Callback callback) throws HandleCallbackException; /** * For push callbacks:

          * if serverSide == false, will send the callback to the server invoker on * the client side, hand off processing to a separate thread, and return.

          * * if serverside == true, will hand off to a separate thread the sending * of the callback and will then return.

          * * For pull callbacks, behaves the same as handleCallback(Callback callback).

          * * @param callback * @param serverSide * @throws HandleCallbackException */ public void handleCallbackOneway(Callback callback, boolean serverSide) throws HandleCallbackException; /** * For push callbacks:

          * if asynch == false, behaves the same as handleCallback(Callback callback).

          * * if asynch == true:

          * if serverSide == false, will send the callback to the server invoker on * the client side, hand off processing to a separate thread, and return.

          * * if serverside == true, will hand off to a separate thread the sending * of the callback and will then return.

          * * For pull callbacks, behaves the same as handleCallback(Callback callback).

          * * @param callback * @param asynch * @param serverSide * @throws HandleCallbackException */ public void handleCallback(Callback callback, boolean asynch, boolean serverSide) throws HandleCallbackException; } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackErrorHandlerWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackErrorHandlerWrapp0000644000175000017500000000763311413660476033354 0ustar twernertwerner /* * 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.remoting.callback; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Map; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.util.SecurityUtility; /** * A CallbackErrorHandlerWrapper is used to wrap an MBean proxy that implements * org.jboss.remoting.callback.CallbackErrorHandler. If necessary, each call * will go through an AccessController.doPrivileged() call. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 5, 2008 *

          */ public class CallbackErrorHandlerWrapper implements CallbackErrorHandler { private CallbackErrorHandler proxy; public CallbackErrorHandlerWrapper(CallbackErrorHandler proxy) { this.proxy = proxy; } public void handleError(final Throwable ex) throws Throwable { if (SecurityUtility.skipAccessControl()) { proxy.handleError(ex); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { try { proxy.handleError(ex); return null; } catch (Throwable e) { throw new Exception(ex); } } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause.getCause() == null) throw cause; throw cause.getCause(); } } public void setCallbackHandler(final ServerInvokerCallbackHandler serverInvokerCallbackHandler) { if (SecurityUtility.skipAccessControl()) { proxy.setCallbackHandler(serverInvokerCallbackHandler); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.setCallbackHandler(serverInvokerCallbackHandler); return null; } }); } public void setConfig(final Map errorHandlerConfig) { if (SecurityUtility.skipAccessControl()) { proxy.setConfig(errorHandlerConfig); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.setConfig(errorHandlerConfig); return null; } }); } public void setServerInvoker(final ServerInvoker owner) { if (SecurityUtility.skipAccessControl()) { proxy.setServerInvoker(owner); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.setServerInvoker(owner); return null; } }); } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHand0000644000175000017500000011411211171060613033325 0ustar twernertwerner/* * 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.remoting.callback; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.SerializableStore; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.invocation.InternalInvocation; import org.jboss.remoting.security.SSLServerSocketFactoryServiceMBean; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.SSLSocketBuilderMBean; import org.jboss.remoting.security.SSLSocketFactoryService; import org.jboss.remoting.util.SecurityUtility; import javax.management.InstanceNotFoundException; import javax.management.MBeanServer; import javax.management.MBeanServerInvocationHandler; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.net.SocketFactory; import javax.net.ssl.SSLServerSocketFactory; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * Responsible for all callbacks in remoting at invoker level (on the server side). * This is created within the ServerInvoker and passed to the server handler as a * proxy for the client's callback handler. *

          * Will determin internally if is using pull or push mechanism for delivering callbacks. * If is push, will create a Client to call back on the callback server. * * @author Tom Elrod */ public class ServerInvokerCallbackHandler implements AsynchInvokerCallbackHandler, ConnectionListener { private static final Logger log = Logger.getLogger(ServerInvokerCallbackHandler.class); private static boolean trace = log.isTraceEnabled(); private InvocationRequest invocation; private Client callBackClient; private ArrayList callbacks = new ArrayList(); private String sessionId; private String listenerId; private String clientSessionId; private InvokerLocator serverLocator; private int blockingTimeout = ServerInvoker.DEFAULT_BLOCKING_TIMEOUT; private boolean shouldPersist; private SerializableStore callbackStore = null; private CallbackErrorHandler callbackErrorHandler = null; private ServerInvoker serverInvoker; /** * The map key to use when looking up any callback store that * should be used. This key should be used when setting up * config in the invoker. */ public static final String CALLBACK_STORE_KEY = "callbackStore"; /** * The map key to use when looking up any callback error handler that * should be used. This key should be used when setting up * config in the invoker. */ public static final String CALLBACK_ERROR_HANDLER_KEY = "callbackErrorHandler"; /** * The map key to use when looking up the percentage of free memory * available before tiggering persistence. */ public static final String CALLBACK_MEM_CEILING = "callbackMemCeiling"; /** * The key used for storing a CallbackListener in the return metadata map of a Callback. */ public static final String CALLBACK_LISTENER = "callbackListener"; /* * The key used to indicate if callback acknowledgement should be handled by Remoting * or the application. If it is present in the callback's return payload and * set to true, Remoting will handle the acknowledgement for push callbacks. */ public static final String REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS = "remotingAcknowledgesPushCallbacks"; /** * This key used to identify a Callback to be acknowledged. */ public static final String CALLBACK_ID = "callbackId"; /** This key is used to identify the timeout used by a callback client */ public static final String CALLBACK_TIMEOUT = "callbackTimeout"; /** The key used to pass to the callback client a reference to ServerInvoker */ public static final String SERVER_INVOKER = "serverInvoker"; /** The key used to pass to the callback client a reference this ServerInvokerCallbackHandler */ public static final String SERVER_INVOKER_CALLBACK_HANDLER = "serverInvokerCallbackHandler"; /** * The percentage number of used memory before should persist messages. * For example, if 64MB available and only 30MB free mem and memPercentCeiling * is 50, then would trigger persisting of messages. */ private double memPercentCeiling = 20; // 20% by default /** * Maps an ID to a CallbackListener for a Callback waiting to be acknowledged. */ private Map idToListenerMap = Collections.synchronizedMap(new HashMap()); public ServerInvokerCallbackHandler(InvocationRequest invocation, InvokerLocator serverLocator, ServerInvoker owner) throws Exception { if(invocation == null) { throw new Exception("Can not construct ServerInvokerCallbackHandler with null InvocationRequest."); } this.invocation = invocation; this.serverLocator = serverLocator; init(invocation, owner); } public void connect() throws Exception { if (callBackClient != null) { if (callBackClient.isConnected()) return; callBackClient.connect(); } } private void init(InvocationRequest invocation, ServerInvoker owner) throws Exception { serverInvoker = owner; clientSessionId = invocation.getSessionId(); sessionId = invocation.getSessionId(); Map metadata = null; if (owner.getConfiguration() == null) { metadata = new HashMap(); } else { metadata = new HashMap(owner.getConfiguration()); } if(invocation.getRequestPayload() != null) { metadata.putAll(invocation.getRequestPayload()); } listenerId = (String) metadata.get(Client.LISTENER_ID_KEY); if(listenerId != null) { sessionId = sessionId + "+" + listenerId; } log.debug("Session id for callback handler is " + sessionId); if(invocation.getLocator() != null) { Object val = metadata.get(CALLBACK_TIMEOUT); if (val instanceof String) { try { Integer.parseInt((String) val); metadata.put(ServerInvoker.TIMEOUT, val); log.debug(this + " using callbackTimeout value " + val); } catch (NumberFormatException e) { log.warn("callbackTimeout value must have valid numeric format: " + val); } } else if (val != null) { log.warn("callbackTimeout value must be a String: " + val); } // need to configure callback client with ssl config if one exists for server configureSocketFactory(metadata, owner); metadata.put(SERVER_INVOKER, owner); metadata.put(SERVER_INVOKER_CALLBACK_HANDLER, this); callBackClient = new Client(invocation.getLocator(), invocation.getSubsystem(), metadata); callBackClient.setSessionId(sessionId); createCallbackErrorHandler(owner, invocation.getSubsystem()); } else { createCallbackStore(owner, sessionId); } Object val = metadata.get(ServerInvoker.BLOCKING_TIMEOUT); if (val != null) { if (val instanceof String) { try { blockingTimeout = Integer.parseInt((String) val); } catch (NumberFormatException e) { log.warn("Error converting " + ServerInvoker.BLOCKING_TIMEOUT + " to type long. " + e.getMessage()); } } else { log.warn("Value for " + ServerInvoker.BLOCKING_TIMEOUT + " configuration must be of type " + String.class.getName() + " and is " + val.getClass().getName()); } } } /** * Will check to see if the server invoker associated with this callback client * needs to have associated ssl config * @param clientConfig * @param serverInvoker */ private void configureSocketFactory(Map clientConfig, ServerInvoker serverInvoker) throws Exception { // If a SocketFactory already exists, then all we have to do is tell the // client invoker to use it. if (serverInvoker.getSocketFactory() != null) { clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, serverInvoker.getSocketFactory()); return; } if (clientConfig == null) clientConfig = new HashMap(); // If a constructed SocketFactory was passed in through config map, the client invoker // will use it. Also, we store it in server invoker for future use. if (clientConfig.containsKey(Remoting.CUSTOM_SOCKET_FACTORY)) { serverInvoker.setSocketFactory((SocketFactory) clientConfig.get(Remoting.CUSTOM_SOCKET_FACTORY)); return; } // If a SocketFactory has not been created already, we need to make sure that the client // invoker creates a suitable SocketFactory. // First, see if we can convert server socket factory into socket factory. String serverSocketFactoryString = (String) clientConfig.get(ServerInvoker.SERVER_SOCKET_FACTORY); if (serverSocketFactoryString != null && serverSocketFactoryString.length() > 0) { final MBeanServer server = serverInvoker.getMBeanServer(); try { final ObjectName serverSocketFactoryObjName = new ObjectName(serverSocketFactoryString); if (server != null) { String className = SSLServerSocketFactoryServiceMBean.class.getName(); boolean isCorrectType = isInstanceOf(server, serverSocketFactoryObjName, className); if (isCorrectType) { Object o = getMBeanAttribute(server, serverSocketFactoryObjName, "SSLSocketBuilder"); SSLSocketBuilderMBean sslSocketBuilder = (SSLSocketBuilderMBean) o; if (sslSocketBuilder != null) { SSLSocketBuilder clonedSSLSocketBuilder = (SSLSocketBuilder) sslSocketBuilder.clone(); boolean shouldUseDefault = sslSocketBuilder.getUseSSLServerSocketFactory(); clonedSSLSocketBuilder.setUseSSLSocketFactory(shouldUseDefault); boolean useClientMode = sslSocketBuilder.isServerSocketUseClientMode(); clonedSSLSocketBuilder.setSocketUseClientMode(useClientMode); SSLSocketFactoryService sslSocketFactoryService = new SSLSocketFactoryService(); sslSocketFactoryService.setSSLSocketBuilder(clonedSSLSocketBuilder); sslSocketFactoryService.start(); clientConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sslSocketFactoryService); clientConfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); // JBREM-536 clientConfig.put("hostnameVerifier", "org.jboss.test.remoting.transport.http.ssl.config.SelfIdentifyingHostnameVerifier"); serverInvoker.setSocketFactory(sslSocketFactoryService); return; } } } } catch (Exception ignored) { log.debug("error", ignored); } } // Otherwise, if we need an SSLSocketFactory, the client invoker will create it from // configuration parameters. Tell it to use client mode (unless explictly configured // otherwise). if (serverInvoker.getServerSocketFactory() instanceof SSLServerSocketFactory) { if (!clientConfig.containsKey(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE)) clientConfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); } } public String getCallbackSessionId() { return sessionId; } public String getClientSessionId() { return clientSessionId; } public String getSubsystem() { return invocation.getSubsystem(); } public void setMemPercentCeiling(Double ceiling) { if(ceiling != null) { memPercentCeiling = ceiling.doubleValue(); } } public Double getMemPercentCeiling() { return new Double(memPercentCeiling); } private void createCallbackStore(ServerInvoker owner, String sessionId) throws Exception { Map config = owner.getConfiguration(); if(config != null) { // should either be a fully qualified class name or a mbean object name String storeName = (String) config.get(CALLBACK_STORE_KEY); if(storeName != null) { // will first try as a MBean try { MBeanServer server = owner.getMBeanServer(); ObjectName storeObjectName = new ObjectName(storeName); if(server != null) { callbackStore = (SerializableStore) MBeanServerInvocationHandler.newProxyInstance(server, storeObjectName, SerializableStore.class, false); callbackStore = new CallbackStoreWrapper(callbackStore); } } catch(Exception ex) { log.debug("Could not create callback store from the configration value given (" + storeName + ") as an MBean."); if(trace) { log.trace("Error is: " + ex.getMessage(), ex); } callbackStore = null; } // now try by class name if(callbackStore == null) { try { Class storeClass = Class.forName(storeName); callbackStore = (SerializableStore) storeClass.newInstance(); } catch(Exception e) { log.debug("Could not create callback store from the configuration value given (" + storeName + ") as a fully qualified class name."); if(trace) { log.trace("Error is: " + e.getMessage(), e); } } } } } // if still null, then just use default if(callbackStore == null) { callbackStore = new NullCallbackStore(); } else { // need to modify configuration to include session id for the callback client. Map storeConfig = new HashMap(); storeConfig.putAll(owner.getConfiguration()); String filePath = (String) storeConfig.get(CallbackStore.FILE_PATH_KEY); if(filePath == null) { filePath = getSystemProperty("jboss.server.data.dir", "data"); } String separator = getSystemProperty("file.separator"); String newFilePath = filePath + separator + "remoting" + separator + sessionId; storeConfig.put(CallbackStore.FILE_PATH_KEY, newFilePath); callbackStore.setConfig(storeConfig); } callbackStore.create(); callbackStore.start(); configureMemCeiling(owner.getConfiguration()); } private void createCallbackErrorHandler(ServerInvoker owner, String subsystem) throws Exception { Map config = owner.getConfiguration(); if(config != null) { // should either be a fully qualified class name or a mbean object name String errorHandlerName = (String) config.get(CALLBACK_ERROR_HANDLER_KEY); if(errorHandlerName != null) { // will first try as a MBean try { MBeanServer server = owner.getMBeanServer(); ObjectName errorHandlerObjectName = new ObjectName(errorHandlerName); if(server != null) { callbackErrorHandler = (CallbackErrorHandler) MBeanServerInvocationHandler.newProxyInstance(server, errorHandlerObjectName, CallbackErrorHandler.class, false); callbackErrorHandler = new CallbackErrorHandlerWrapper(callbackErrorHandler); } } catch(Exception ex) { log.debug("Could not create callback error handler from the configration value " + "given (" + errorHandlerName + ") as an MBean."); if(trace) { log.trace("Error is: " + ex.getMessage(), ex); } callbackErrorHandler = null; } // now try by class name if(callbackErrorHandler == null) { try { Class errorHandlerClass = Class.forName(errorHandlerName); callbackErrorHandler = (CallbackErrorHandler) errorHandlerClass.newInstance(); } catch(Exception e) { log.debug("Could not create callback error handler from the configuration value " + "given (" + errorHandlerName + ") as a fully qualified class name."); if(trace) { log.trace("Error is: " + e.getMessage(), e); } } } } } // if still null, then just use default if(callbackErrorHandler == null) { callbackErrorHandler = new DefaultCallbackErrorHandler(); } // set configuration for the error handler. Map errorHandlerConfig = new HashMap(); errorHandlerConfig.putAll(owner.getConfiguration()); errorHandlerConfig.put(CallbackErrorHandler.HANDLER_SUBSYSTEM, subsystem); callbackErrorHandler.setConfig(errorHandlerConfig); callbackErrorHandler.setServerInvoker(owner); callbackErrorHandler.setCallbackHandler(this); } private void configureMemCeiling(Map configuration) { if(configuration != null) { String ceiling = (String) configuration.get(CALLBACK_MEM_CEILING); if(ceiling != null) { try { double newCeiling = Double.parseDouble(ceiling); setMemPercentCeiling(new Double(newCeiling)); } catch(NumberFormatException e) { log.warn("Found new store memory ceiling seting (" + ceiling + "), but can not convert to type double.", e); } } } } public Client getCallbackClient() { return callBackClient; } /** * Returns an id that can be used to identify this particular callback handler, which should be * representative of the client invoker it will make callbacks to. Currently, this is the * session id associated with the invocation request. */ public static String getId(InvocationRequest invocation) { String sessionId = invocation.getSessionId(); Map metadata = invocation.getRequestPayload(); if(metadata != null) { String listenerId = (String) metadata.get(Client.LISTENER_ID_KEY); if(listenerId != null) { sessionId = sessionId + "+" + listenerId; } } return sessionId; } /** * Returns an id that can be used to identify this particular callback handler, which should be * representative of the client invoker it will make callbacks to. */ public String getId() { return sessionId; } public List getCallbacks(Map metadata) { log.trace("entering getCallbacks()"); boolean blocking = false; int currentBlockingTimeout = blockingTimeout; if (metadata != null) { Object val = metadata.get(ServerInvoker.BLOCKING_MODE); if (ServerInvoker.BLOCKING.equals(val)) blocking = true; val = metadata.get(ServerInvoker.BLOCKING_TIMEOUT); if (val != null) { if (val instanceof String) { try { currentBlockingTimeout = Integer.parseInt((String) val); } catch (NumberFormatException e) { log.warn("Error converting " + ServerInvoker.BLOCKING_TIMEOUT + " to type long. " + e.getMessage()); } } else { log.warn("Value for " + ServerInvoker.BLOCKING_TIMEOUT + " configuration must be of type " + String.class.getName() + " and is " + val.getClass().getName()); } } } if (trace) { log.trace("block: " + blocking); log.trace("blocking timeout: " + currentBlockingTimeout); } synchronized (callbacks) { List callbackList = constructCallbackList(); if (blocking && callbackList.isEmpty()) { try { callbacks.wait(currentBlockingTimeout); callbackList = constructCallbackList(); } catch (InterruptedException e) { log.debug("unexpected interrupt"); } } if (trace) log.trace("callbackList.size(): " + callbackList.size()); return callbackList; } } private List constructCallbackList() { List callbackList = null; synchronized(callbacks) { callbackList = (List) callbacks.clone(); callbacks.clear(); } // get as many persisted callbacks as possible without over run on memory List persistedCallbacks = null; try { persistedCallbacks = getPersistedCallbacks(); } catch(IOException e) { log.debug("Can not get persisted callbacks.", e); throw new RuntimeException("Error getting callbacks", e); } callbackList.addAll(persistedCallbacks); return callbackList; } private List getPersistedCallbacks() throws IOException { List callbacks = new ArrayList(); int size = callbackStore.size(); for(int x = 0; x < size; x++) { callbacks.add(callbackStore.getNext()); // check the amount of mem in use as get callbacks out so // don't load so many callbacks from store, that run out of memory. if(isMemLow()) { new Thread() { public void run() { System.gc(); } }.start(); break; } } return callbacks; } public boolean isPullCallbackHandler() { return (callBackClient == null); } /** * 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 HandleCallbackException */ public void handleCallback(Callback callback) throws HandleCallbackException { handleCallback(callback, false, false); } /** * For push callbacks, will send the callback to the server invoker on the * client side, hand off processing to a separate thread, and return.

          * * For pull callbacks, behaves the same as handleCallback(Callback callback).

          * * @param callback * @throws HandleCallbackException */ public void handleCallbackOneway(Callback callback) throws HandleCallbackException { handleCallback(callback, true, false); } /** * For push callbacks:

          * if serverSide == false, will send the callback to the server invoker on * the client side, hand off processing to a separate thread, and return.

          * * if serverside == true, will hand off to a separate thread the sending * of the callback and will then return.

          * * For pull callbacks, behaves the same as handleCallback(Callback callback).

          * * @param callback * @param serverSide * @throws HandleCallbackException */ public void handleCallbackOneway(Callback callback, boolean serverSide) throws HandleCallbackException { handleCallback(callback, true, serverSide); } /** * For push callbacks:

          * * if asynch == false, behaves the same as handleCallback(Callback callback).

          * * if asynch == true:

          * * if serverSide == false, will send the callback to the server invoker on the client side, * hand off processing to a separate thread, and return.

          * * if serverside == true, will hand off to a separate thread the sending of the callback and * will then return.

          * * For pull callbacks, behaves the same as handleCallback(Callback callback).

          */ public void handleCallback(Callback callback, boolean asynch, boolean serverSide) throws HandleCallbackException { try { Object callbackId = checkForCallbackListener(callback); if(callBackClient == null) { // need to check if should persist callback instead of keeping in memory if(shouldPersist()) { try { persistCallback(callback); synchronized (callbacks) { callbacks.notify(); } callback = null; // try to help out with the amount of memory usuage new Thread() { public void run() { System.gc(); } }.start(); } catch(IOException e) { log.debug("Unable to persist callback", e); throw new HandleCallbackException("Unable to persist callback and will not " + "be able to deliver.", e); } } else { synchronized(callbacks) { if(trace){ log.debug(this + " got PULL callback. Adding to callback list ..."); } callbacks.add(callback); callbacks.notify(); } } } else { // non null callback client try { if(trace){ log.debug(this + " got PUSH callback " + callback); } boolean handleAcknowledgement = false; if(callback != null) { Map returnPayload = callback.getReturnPayload(); if(returnPayload == null) { returnPayload = new HashMap(); } else { Object o = returnPayload.remove(REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS); if (!asynch) { if (o instanceof String && Boolean.valueOf((String)o).booleanValue() || o instanceof Boolean && ((Boolean)o).booleanValue()) handleAcknowledgement = true; } } returnPayload.put(Callback.SERVER_LOCATOR_KEY, serverLocator); callback.setReturnPayload(returnPayload); } // Sending internal invocation so server invoker we are sending to will know how // pass onto it's client callback handler InternalInvocation internalInvocation = new InternalInvocation(InternalInvocation.HANDLECALLBACK, new Object[]{callback}); if (asynch) { if(trace){ log.debug(this + " sending ASYNCHRONOUSLY the callback to the client"); } callBackClient. invokeOneway(internalInvocation, callback.getRequestPayload(), serverSide); } else { if(trace){ log.debug(this + " sending SYNCHRONOUSLY the callback to the client"); } callBackClient.invoke(internalInvocation, callback.getRequestPayload()); } handlePushCallbackAcknowledgement(callbackId, handleAcknowledgement); } catch(Throwable ex) { if(callbackErrorHandler == null) { // no callback handler, rethrowing the exception throw ex; } if (trace) { log.trace(this + " handing the error over to " + callbackErrorHandler); } // a well behaved callback error handler will perform clean up and then rethrow the // exception so the client application has a chance to find out about the error // condition callbackErrorHandler.handleError(ex); } } } catch(Throwable t) { log.debug("Error handling callback", t); throw new HandleCallbackException("Error handling callback", t); } } private void persistCallback(InvocationRequest callback) throws IOException { callbackStore.add(callback); } /** * Calculates the percentage amount of free memory compared to max memory. The calculations for * this is not always acurate. The reason is that total memory used is usually less than the max * allowed. Thus, the amount of free memory is relative to the total amount allocated at that * point in time. It is not until the total amount of memory allocated is equal to the max it * will be allowed to allocate. At this point, the amount of free memory becomes relavent. * Therefore, if the memory percentage ceiling is high, it might not trigger until after free * memory percentage is well below the ceiling. */ private boolean shouldPersist() { if (shouldPersist) return true; return isMemLow(); } 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 && memPercentCeiling >= percentage) { return true; } else { return false; } } Object checkForCallbackListener(Callback callback) { Map returnPayload = callback.getReturnPayload(); if (returnPayload == null) return null; Object listenerObject = returnPayload.remove(CALLBACK_LISTENER); if (listenerObject == null) return null; Object callbackId = returnPayload.get(CALLBACK_ID); if (callbackId == null) { log.error("CALLBACK_ID is null: unable to acknowledge callback"); return null; } if (listenerObject instanceof CallbackListener) { if(listenerId != null) { returnPayload.put(Client.LISTENER_ID_KEY, listenerId); idToListenerMap.put(callbackId, listenerObject); return callbackId; } else { log.error("LISTENER_ID_KEY is null: unable to acknowledge callback"); return null; } } else { log.error("callback preprocess listener has wrong type: " + listenerObject); return null; } } private void handlePushCallbackAcknowledgement(Object callbackId, boolean handleAck) { if (!handleAck) return; if (callbackId == null) { log.error("Unable to acknowledge push callback: callback id is null"); return; } CallbackListener listener = (CallbackListener) idToListenerMap.get(callbackId); if (listener == null) { log.error("Unable to acknowledge push callback: listener is null"); return; } listener.acknowledgeCallback(this, callbackId, null); } /** * Calls listeners to acknowledge callbacks * @param invocation carries identities of Callbacks to acknowledge and, * optionally, responses */ public void acknowledgeCallbacks(InternalInvocation invocation) throws Exception { Object[] params = invocation.getParameters(); if (params == null) return; List callbackIds = (List) params[0]; List responses = (List) params[1]; if (callbackIds == null || callbackIds.size() == 0) return; Iterator idsIterator = callbackIds.iterator(); Iterator responseIterator = null; if (responses != null) responseIterator = responses.iterator(); Object callbackId = null; Object response = null; while(idsIterator.hasNext()) { callbackId = idsIterator.next(); if (responseIterator != null) response = responseIterator.next(); CallbackListener listener = (CallbackListener) idToListenerMap.remove(callbackId); if (listener == null) { log.warn("Cannot acknowledge callback: unrecognized id: " + callbackId); continue; } listener.acknowledgeCallback(this, callbackId, response); } } public String toString() { return "ServerInvokerCallbackHandler[" + getId() + "]"; } /** * This method is required to be called upon removing a callback listener * so can clean up resources used by the handler. In particular, should * call disconnect on internal Client. */ public synchronized void destroy() { if(callBackClient != null) { callBackClient.disconnect(); } if(callbackStore != null) { callbackStore.purgeFiles(); } } public void shutdown() { serverInvoker.shutdownCallbackHandler(this, invocation); destroy(); log.debug(this + " shut down"); } public void handleConnectionException(Throwable throwable, Client client) { if (clientSessionId.equals(client.getSessionId())) { shutdown(); } } public boolean isShouldPersist() { return shouldPersist; } public void setShouldPersist(boolean shouldPersist) { this.shouldPersist = shouldPersist; } static private Object getMBeanAttribute(final MBeanServer server, final ObjectName objectName, final String attribute) throws Exception { if (SecurityUtility.skipAccessControl()) { return server.getAttribute(objectName, attribute); } try { return AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return server.getAttribute(objectName, attribute); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } static private boolean isInstanceOf(final MBeanServer server, final ObjectName objectName, final String className) throws InstanceNotFoundException { if (SecurityUtility.skipAccessControl()) { return server.isInstanceOf(objectName, className); } try { return ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new Boolean(server.isInstanceOf(objectName, className)); } })).booleanValue(); } catch (PrivilegedActionException e) { throw (InstanceNotFoundException) e.getCause(); } } static private String getSystemProperty(final String name, final String defaultValue) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name, defaultValue); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name, defaultValue); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private String getSystemProperty(final String name) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackPoller.java0000644000175000017500000006300111162033553032106 0ustar twernertwerner/* * 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.remoting.callback; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Timer; import java.util.TimerTask; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ClientInvoker; /** * CallbackPoller is used to simulate push callbacks on transports that don't support * bidirectional connections. It will periodically pull callbacks from the server * and pass them to the InvokerCallbackHandler. * * @author Tom Elrod * @author Ron Sigal */ public class CallbackPoller extends TimerTask implements Runnable { /* * Implementation note. * * CallbackPoller uses two, or possibly three, threads. The first thread is the * Timer thread, which periodically pulls callbacks from the server and adds them * to toHandleList. The second thread takes callbacks from toHandleList, passes * them to the CallbackHandler, and, if an acknowledgement is requested for a * callback, it adds the callback to toAcknowledgeList. The third thread, which is * created in response to the first callback for which an acknowledgement is requested, * takes the contents of toAcknowledgeList and acknowledges them in a batch. * * CallbackPoller will not shut down until all received callbacks have been processed * by the CallbackHandler and acknowledgements have been sent for all callbacks for * which acknowledgements have been requested. */ /** * Default polling period for getting callbacks from the server. * Default is 5000 milliseconds. */ public static final long DEFAULT_POLL_PERIOD = 5000; /** * Default timeout for getting callbacks in blocking mode. * Default is 5000 milliseconds. */ public static final int DEFAULT_BLOCKING_TIMEOUT = 5000; /** * Default number of exceptions before callback polling wil be shut down. * Default is 5. */ public static final int DEFAULT_MAX_ERROR_COUNT = 5; /** * The key value to use to specify if stop() should wait for the call to * org.jboss.remoting.Client.getCallbacks() should return. The default * behavior is do a synchronized shutdown for nonblocking callbacks and * a nonsynchronized shutdown for blocking callbacks. */ public static final String SYNCHRONIZED_SHUTDOWN = "doSynchronizedShutdown"; /** * The key value to use to specify the desired poll period * within the metadata Map. */ public static final String CALLBACK_POLL_PERIOD = "callbackPollPeriod"; /** Use java.util.timer.schedule(). */ public static final String SCHEDULE_FIXED_RATE = "scheduleFixedRate"; /** Use java.util.timer.scheduleAtFixedRate(). */ public static final String SCHEDULE_FIXED_DELAY = "scheduleFixedDelay"; /** * The key to use to specify the number of errors before callback polling * will be shut down. */ public static final String MAX_ERROR_COUNT = "maxErrorCount"; /** The key to use in metadata Map to request statistics. The associated * is ignored. */ public static final String REPORT_STATISTICS = "reportStatistics"; private Client client = null; private InvokerCallbackHandler callbackHandler = null; private Map metadata = null; private Object callbackHandlerObject = null; private boolean blocking = false; private boolean synchronizedShutdown = false; private long pollPeriod = DEFAULT_POLL_PERIOD; private Timer timer; private String scheduleMode = SCHEDULE_FIXED_RATE; private boolean reportStatistics; private boolean running; private int maxErrorCount = -1; private int errorCount; private boolean useAllParams; private ArrayList toHandleList = new ArrayList(); private ArrayList toAcknowledgeList = new ArrayList(); private HandleThread handleThread; private AcknowledgeThread acknowledgeThread; private BlockingPollerThread blockingPollerThread; private static final Logger log = Logger.getLogger(CallbackPoller.class); public CallbackPoller(Client client, InvokerCallbackHandler callbackhandler, Map metadata, Object callbackHandlerObject) { this.client = client; this.callbackHandler = callbackhandler; this.metadata = new HashMap(metadata); this.callbackHandlerObject = callbackHandlerObject; } public void start() throws Exception { if (callbackHandler == null) { throw new NullPointerException("Can not poll for callbacks when InvokerCallbackHandler is null."); } if (client != null) { client.connect(); } else { throw new NullPointerException("Can not poll for callbacks when Client is null."); } configureParameters(); handleThread = new HandleThread("HandleThread"); handleThread.start(); if (log.isTraceEnabled()) log.trace("blocking: " + blocking); if (blocking) { if (maxErrorCount == -1) maxErrorCount = DEFAULT_MAX_ERROR_COUNT; running = true; metadata.put(Client.THROW_CALLBACK_EXCEPTION, "true"); blockingPollerThread = new BlockingPollerThread(); blockingPollerThread.start(); } else { timer = new Timer(true); if (SCHEDULE_FIXED_DELAY.equals(scheduleMode)) timer.schedule(this, pollPeriod, pollPeriod); else timer.scheduleAtFixedRate(this, pollPeriod, pollPeriod); } } public synchronized void run() { // need to pull callbacks from server and give them to callback handler try { if (log.isTraceEnabled()) log.trace(this + " getting callbacks for " + callbackHandler); List callbacks = client.getCallbacks(callbackHandler, metadata); if (log.isTraceEnabled()) log.trace(this + " callback count: " + (callbacks == null ? 0 : callbacks.size())); if (callbacks != null && callbacks.size() > 0) { synchronized (toHandleList) { toHandleList.addAll(callbacks); if (toHandleList.size() == callbacks.size()) toHandleList.notify(); } } if (reportStatistics) reportStatistics(callbacks); } catch (Throwable throwable) { if (!running) { stop(); return; } log.info(this + " Error getting callbacks from server."); log.debug(this + " Error getting callbacks from server.", throwable); String errorMessage = throwable.getMessage(); if (errorMessage != null) { if (errorMessage.startsWith("Could not find listener id")) { log.error("Client no longer has InvokerCallbackHandler (" + callbackHandler + ") registered. Shutting down callback polling"); stop(); return; } if (errorMessage.startsWith("Can not make remoting client invocation " + "due to not being connected to server.")) { log.error("Client no longer connected. Shutting down callback polling"); stop(); return; } } if (maxErrorCount >= 0) { if (++errorCount > maxErrorCount) { log.error("Error limit of " + maxErrorCount + " exceeded. Shutting down callback polling"); stop(); return; } } } } public void stop() { stop(-1); } /** * stop() will not return until all received callbacks have been processed * by the CallbackHandler and acknowledgements have been sent for all callbacks for * which acknowledgements have been requested. */ public void stop(int timeout) { log.debug(this + " is shutting down"); running = false; if (!blocking) { cancel(); if (timer != null) { timer.cancel(); timer = null; } } if (timeout == 0) return; if (synchronizedShutdown) { // run() and stop() are synchronized so that stop() will wait until run() has finished // adding any callbacks it has received to toHandleList. Therefore, once cancel() // returns, no more callbacks will arrive from the server. synchronized (this) { shutdown(); } } else { shutdown(); } log.debug(this + " has shut down"); } private void shutdown() { // HandleThread.shutdown() will not return until all received callbacks have been // processed and, if necessary, added to toAcknowledgeList. if (handleThread != null) { handleThread.shutdown(); handleThread = null; } // AcknowledgeThread.shutdown() will not return until acknowledgements have been sent // for all callbacks for which acknowledgements have been requested. if (acknowledgeThread != null) { acknowledgeThread.shutdown(); acknowledgeThread = null; } } class BlockingPollerThread extends Thread { public BlockingPollerThread() { String threadName = getName(); int i = threadName.indexOf('-'); String threadNumber = null; if (i >= 0) threadNumber = threadName.substring(i+1); else threadNumber = Long.toString(System.currentTimeMillis()); String pollerString = CallbackPoller.this.toString(); String address = pollerString.substring(pollerString.indexOf('@')); setName("CallbackPoller:" + threadNumber + "[" + address + "]"); setDaemon(true); } public void run() { while (running) { CallbackPoller.this.run(); } } } class HandleThread extends Thread { boolean running = true; boolean done; ArrayList toHandleListCopy = new ArrayList(); Callback callback; HandleThread(String name) { super(name); } public void run() { while (true) { synchronized (toHandleList) { if (toHandleList.isEmpty() && running) { try { toHandleList.wait(); } catch (InterruptedException e) { log.debug("unexpected interrupt"); continue; } } // If toHandleList is empty, then running must be false. We return // only when both conditions are true. if (toHandleList.isEmpty()) { done = true; toHandleList.notify(); return; } toHandleListCopy.addAll(toHandleList); toHandleList.clear(); } while (!toHandleListCopy.isEmpty()) { try { callback = (Callback) toHandleListCopy.remove(0); callback.setCallbackHandleObject(callbackHandlerObject); callbackHandler.handleCallback(callback); } catch (HandleCallbackException e) { log.error("Error delivering callback to callback handler (" + callbackHandler + ").", e); } checkForAcknowledgeRequest(callback); } } } /** * Once CallbackPoller.stop() has called HandleThread.shutdown(), CallbackPoller.run() * has terminated and no additional callbacks will be received. shutdown() will * not return until HandleThread has processed all received callbacks. * * Either run() or shutdown() will enter its own synchronized block first. * * case 1): run() enters its synchronized block first: * If toHandleList is empty, then run() will reach toHandleList.wait(), shutdown() * will wake up run(), and run() will exit. If toHandleList is not empty, then run() * will process all outstanding callbacks and return to its synchronized block. At * this point, either case 1) (with toHandleList empty) or case 2) applies. * * case 2): shutdown() enters its synchronized block first: * run() will process all outstanding callbacks and return to its synchronized block. * After shutdown() reaches toHandleList.wait(), run() will enter its synchronized * block, find running == false and toHandleList empty, and it will exit. */ protected void shutdown() { log.debug(this + " is shutting down"); synchronized (toHandleList) { running = false; toHandleList.notify(); while (!done) { try { toHandleList.wait(); } catch (InterruptedException ignored) {} } } log.debug(this + " has shut down"); return; } } class AcknowledgeThread extends Thread { boolean running = true; boolean done; ArrayList toAcknowledgeListCopy = new ArrayList(); AcknowledgeThread(String name) { super(name); } public void run() { while (true) { synchronized (toAcknowledgeList) { while (toAcknowledgeList.isEmpty() && running) { try { toAcknowledgeList.wait(); } catch (InterruptedException e) { log.debug("unexpected interrupt"); continue; } } // If toAcknowledgeList is empty, then running must be false. We return // only when both conditions are true. if (toAcknowledgeList.isEmpty()) { done = true; toAcknowledgeList.notify(); return; } toAcknowledgeListCopy.addAll(toAcknowledgeList); toAcknowledgeList.clear(); } try { if (log.isTraceEnabled()) { Iterator it = toAcknowledgeListCopy.iterator(); while (it.hasNext()) { Callback cb = (Callback) it.next(); Map map = cb.getReturnPayload(); log.trace("acknowledging: " + map.get(ServerInvokerCallbackHandler.CALLBACK_ID)); } } client.acknowledgeCallbacks(callbackHandler, toAcknowledgeListCopy); toAcknowledgeListCopy.clear(); } catch (Throwable t) { log.error("Error acknowledging callback for callback handler (" + callbackHandler + ").", t); } } } /** * Once CallbackPoller.stop() has called AcknowledgeThread.shutdown(), HandleThread * has terminated and no additional callbacks will be added to toAcknowledgeList. * shutdown() will not return until AcknowledgeThread has acknowledged all callbacks * in toAcknowledgeList. * * Either run() or shutdown() will enter its own synchronized block first. * * case 1): run() enters its synchronized block first: * If toAcknowledgeList is empty, then run() will reach toAcknowledgeList.wait(), * shutdown() will wake up run(), and run() will exit. If toAcknowledgeList is not * empty, then run() will process all callbacks in toAcknowledgeList and return to * its synchronized block. At this point, either case 1) (with toAcknowledgeList * empty) or case 2) applies. * * case 2): shutdown() enters its synchronized block first: * run() will process all callbacks in toAcknowledgeList and return to its * synchronized block. After shutdown() reaches toAcknowledgeList.wait(), run() * will enter its synchronized block, find running == false and toAcknowledgeList * empty, and it will exit. */ public void shutdown() { log.debug(this + " is shutting down"); synchronized (toAcknowledgeList) { running = false; toAcknowledgeList.notify(); while (!done) { try { toAcknowledgeList.wait(); } catch (InterruptedException ignored) {} } } log.debug(this + " has shut down"); return; } } private void checkForAcknowledgeRequest(Callback callback) { Map returnPayload = callback.getReturnPayload(); if (returnPayload != null) { Object callbackId = returnPayload.get(ServerInvokerCallbackHandler.CALLBACK_ID); if (callbackId != null) { Object o = returnPayload.get(ServerInvokerCallbackHandler.REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS); if (o instanceof String && Boolean.valueOf((String)o).booleanValue() || o instanceof Boolean && ((Boolean)o).booleanValue()) { synchronized (toAcknowledgeList) { toAcknowledgeList.add(callback); if (toAcknowledgeList.size() == 1) { if (acknowledgeThread == null) { acknowledgeThread = new AcknowledgeThread("AcknowledgeThread"); acknowledgeThread.start(); } else { toAcknowledgeList.notify(); } } } } } } } private void configureParameters() { Map config = new HashMap(); ClientInvoker invoker = client.getInvoker(); if (invoker != null) { config.putAll(invoker.getLocator().getParameters()); } config.putAll(client.getConfiguration()); config.putAll(metadata); Object val = config.get(Client.USE_ALL_PARAMS); if (val != null) { if (val instanceof String) { useAllParams = Boolean.valueOf((String) val).booleanValue(); } else { log.warn("Value for " + Client.USE_ALL_PARAMS + " must be of type " + String.class.getName() + " and is " + val.getClass().getName()); } } log.debug(this + ": useAllParams: " + useAllParams); if (!useAllParams) { config = metadata; } val = config.get(ServerInvoker.BLOCKING_MODE); if (val != null) { if (val instanceof String) { if (ServerInvoker.BLOCKING.equals(val)) { blocking = true; synchronizedShutdown = false; } else if (ServerInvoker.NONBLOCKING.equals(val)) { blocking = false; synchronizedShutdown = true; } else { log.warn("Value for " + ServerInvoker.BLOCKING_MODE + " configuration is " + val + ". Must be either " + ServerInvoker.BLOCKING + " or " + ServerInvoker.NONBLOCKING + ". Using " + ServerInvoker.BLOCKING + "."); } } else { log.warn("Value for " + ServerInvoker.BLOCKING_MODE + " configuration must be of type " + String.class.getName() + " and is of type " + val.getClass().getName()); } } // Default blocking mode on server is nonblocking. if (blocking) metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING); val = config.get(ServerInvoker.BLOCKING_TIMEOUT); if (val != null) { if (val instanceof String) { try { int blockingTimeout = Integer.parseInt((String) val); metadata.put(ServerInvoker.TIMEOUT, Integer.toString(blockingTimeout)); } catch (NumberFormatException e) { log.warn("Error converting " + ServerInvoker.BLOCKING_TIMEOUT + " to type long. " + e.getMessage()); } } else { log.warn("Value for " + ServerInvoker.BLOCKING_TIMEOUT + " configuration must be of type " + String.class.getName() + " and is " + val.getClass().getName()); } } val = config.get(SYNCHRONIZED_SHUTDOWN); if (val != null) { if (val instanceof String) { synchronizedShutdown = Boolean.valueOf((String) val).booleanValue(); } else { log.warn("Value for " + SYNCHRONIZED_SHUTDOWN + " must be of type " + String.class.getName() + " and is " + val.getClass().getName()); } } val = config.get(CALLBACK_POLL_PERIOD); if (val != null) { if (val instanceof String) { try { pollPeriod = Long.parseLong((String) val); } catch (NumberFormatException e) { log.warn("Error converting " + CALLBACK_POLL_PERIOD + " to type long. " + e.getMessage()); } } else { log.warn("Value for " + CALLBACK_POLL_PERIOD + " configuration must be of type " + String.class.getName() + " and is " + val.getClass().getName()); } } val = config.get(CALLBACK_SCHEDULE_MODE); if (val != null) { if (val instanceof String) { if (SCHEDULE_FIXED_DELAY.equals(val) || SCHEDULE_FIXED_RATE.equals(val)) { scheduleMode = (String) val; } else { log.warn("Unrecognized value for " + CALLBACK_SCHEDULE_MODE + ": " + val); log.warn("Using " + scheduleMode); } } else { log.warn("Value for " + CALLBACK_SCHEDULE_MODE + " must be of type " + String.class.getName() + " and is " + val.getClass().getName()); } } val = config.get(MAX_ERROR_COUNT); if (val != null) { if (val instanceof String) { try { maxErrorCount = Integer.parseInt((String) val); } catch (NumberFormatException e) { log.warn("Error converting " + MAX_ERROR_COUNT + " to type int. " + e.getMessage()); } } else { log.warn("Value for " + MAX_ERROR_COUNT + " configuration must be of type " + String.class.getName() + " and is " + val.getClass().getName()); } } if (config.get(REPORT_STATISTICS) != null) { reportStatistics = true; } } private void reportStatistics(List callbacks) { int toHandle; int toAcknowledge = 0; synchronized (toHandleList) { toHandle = toHandleList.size() + handleThread.toHandleListCopy.size(); } synchronized (toAcknowledgeList) { if (acknowledgeThread != null) toAcknowledge = toAcknowledgeList.size() + acknowledgeThread.toAcknowledgeListCopy.size(); } StringBuffer message = new StringBuffer("\n"); message.append("================================\n") .append(" retrieved " + callbacks.size() + " callbacks\n") .append(" callbacks waiting to be processed: " + toHandle + "\n") .append(" callbacks waiting to be acknowledged: " + toAcknowledge + "\n") .append("================================"); log.info(message); } /** * The key value to use in metadata Map to specify the desired scheduling mode. */ public static final String CALLBACK_SCHEDULE_MODE = "scheduleMode"; }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/NullCallbackStore.java0000644000175000017500000001116310766131767032621 0ustar twernertwerner/* * 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.remoting.callback; import java.io.IOException; import java.io.Serializable; import java.util.Map; import org.jboss.logging.Logger; import org.jboss.remoting.SerializableStore; /** * This implementation does nothing other than throw away persisted objects and throw exceptions. * This is to be use when don't have a proper store or don't care about throwing away callbacks when * starting to run out of memory. * * @author Tom Elrod */ public class NullCallbackStore implements SerializableStore, Serializable { static final long serialVersionUID = -8182007953992756845L; private boolean isCallbackLost = false; private static final Logger log = Logger.getLogger(NullCallbackStore.class); /** * Getst the number of objects stored and available. * * @return */ public int size() { return isCallbackLost ? 1 : 0; } /** * Will look through the files in the store directory for the oldest object serialized to disk, load it, * delete the file, and return the deserialized object. * Important to note that once this object is returned from this method, it is gone forever from this * store and will not be able to retrieve it again without adding it back. * * @return * @throws java.io.IOException */ public Object getNext() throws IOException { if(isCallbackLost) { isCallbackLost = false; return new FailedCallback("This is an invalid callback. The server ran out of memory, so callbacks were lost."); } else { return null; } } /** * Persists the serializable object passed to the directory specified. The file name will be the current time * in milliseconds (vis System.currentTimeMillis()) with the specified suffix. This object can later be * retrieved using the getNext() method, but objects will be returned in the order that they were added (FIFO). * * @param object * @throws java.io.IOException */ public void add(Serializable object) throws IOException { isCallbackLost = true; log.debug("Lost callback because not enough free memory available. Callback lost was " + object); throw new IOException("Callback has been lost because not enough free memory to hold object."); } /** * No op * * @param config */ public void setConfig(Map config) { } /** * No op * * @throws Exception */ public void start() throws Exception { } /** * No op */ public void stop() { } /** * This is a no op method, but needed in order to be used as a service within JBoss AS. * * @throws Exception */ public void create() throws Exception { } /** * This is a no op method, but needed in order to be used as a service within JBoss AS. */ public void destroy() { } /** * Sets if store should clean up persisted files when shutdown (destroy()). * * @param purgeOnShutdown */ public void setPurgeOnShutdown(boolean purgeOnShutdown) { } /** * Returns if store will clean up persisted files when shutdown (destroy()). * * @return */ public boolean getPurgeOnShutdown() { return false; } public void purgeFiles() { } public class FailedCallback extends Callback { public FailedCallback(Object callbackPayload) { super(callbackPayload); } public Object getCallbackObject() { throw new RuntimeException("This is an invalid callback. The server ran out of memory, so callbacks were lost."); } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackStoreWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackStoreWrapper.java0000644000175000017500000001453611413660476033330 0ustar twernertwerner /* * 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.remoting.callback; import java.io.IOException; import java.io.Serializable; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Map; import org.jboss.remoting.SerializableStore; import org.jboss.remoting.util.SecurityUtility; /** * A CallbackStoreWrapper is used to wrap an MBean proxy that implements * org.jboss.remoting.SerializableStore. If necessary, each call will go * through an AccessController.doPrivileged() call. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 5, 2008 *

          */ public class CallbackStoreWrapper implements SerializableStore { private SerializableStore proxy; public CallbackStoreWrapper(SerializableStore proxy) { this.proxy = proxy; } public void add(final Serializable object) throws IOException { if (SecurityUtility.skipAccessControl()) { proxy.add(object); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { proxy.add(object); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } public void create() throws Exception { if (SecurityUtility.skipAccessControl()) { proxy.create(); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { proxy.create(); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } public void destroy() { if (SecurityUtility.skipAccessControl()) { proxy.destroy(); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.destroy(); return null; } }); } public Object getNext() throws IOException { if (SecurityUtility.skipAccessControl()) { return proxy.getNext(); } try { return AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return proxy.getNext(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } public boolean getPurgeOnShutdown() { if (SecurityUtility.skipAccessControl()) { return proxy.getPurgeOnShutdown(); } return ((Boolean) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(proxy.getPurgeOnShutdown()); } })).booleanValue(); } public void purgeFiles() { if (SecurityUtility.skipAccessControl()) { proxy.purgeFiles(); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.purgeFiles(); return null; } }); } public void setConfig(final Map config) { if (SecurityUtility.skipAccessControl()) { proxy.setConfig(config); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.setConfig(config); return null; } }); } public void setPurgeOnShutdown(final boolean purgeOnShutdown) { if (SecurityUtility.skipAccessControl()) { proxy.setPurgeOnShutdown(purgeOnShutdown); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.setPurgeOnShutdown(purgeOnShutdown); return null; } }); } public int size() { if (SecurityUtility.skipAccessControl()) { return proxy.size(); } return ((Integer) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Integer(proxy.size()); } })).intValue(); } public void start() throws Exception { if (SecurityUtility.skipAccessControl()) { proxy.start(); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { proxy.start(); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } public void stop() { if (SecurityUtility.skipAccessControl()) { proxy.stop(); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.stop(); return null; } }); } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackErrorHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackErrorHandler.java0000644000175000017500000000314510556001276033246 0ustar twernertwerner/* * 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.remoting.callback; import java.util.Map; import org.jboss.remoting.ServerInvoker; /** * @author Tom Elrod */ public interface CallbackErrorHandler { static final String HANDLER_SUBSYSTEM = "handlerSubsystem"; /** * Sets the configuration for the error handler. This will be called per instance creation on the * server side. */ void setConfig(Map errorHandlerConfig); void handleError(Throwable ex) throws Throwable; void setServerInvoker(ServerInvoker owner); void setCallbackHandler(ServerInvokerCallbackHandler serverInvokerCallbackHandler); }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/BlockingCallbackStore.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/BlockingCallbackStore.jav0000644000175000017500000001034010433414054033252 0ustar twernertwerner/* * 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.remoting.callback; import org.jboss.logging.Logger; import org.jboss.remoting.SerializableStore; import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * This callback store does not persist callback messages when memory is * running low, but instead will block the thread making the handle callback * call from the server invoker. The intention is that this will throttle the * server invoker from generating/sending any more callbacks until client as * called to get the in-memory callbacks that have already been collected and * memory has been released. * @author Tom Elrod */ public class BlockingCallbackStore implements SerializableStore { private Object lockObject = new Object(); private List callbacks = new ArrayList(); private static final Logger log = Logger.getLogger(BlockingCallbackStore.class); /** * Gets the number of callbacks that are waiting * to be processed. * @return */ public int size() { return callbacks.size(); } /** * Will get the first callback that are being held for the * client. This will also release the lock that is holding * any threads that have called the add(Serializalbe) method. * @return * @throws IOException */ public Object getNext() throws IOException { Object callback = null; synchronized(lockObject) { if(callbacks.size() > 0) { callback = callbacks.remove(0); } lockObject.notify(); } return callback; } /** * To be used for adding a callback to the store. * The thread making the call will be held until the * getNext() method is called. * @param object * @throws IOException */ public void add(Serializable object) throws IOException { if(log.isTraceEnabled()) { log.trace("Adding " + object + " to blocking callback store. Calling thread " + Thread.currentThread() + " will be held until getNext() is called"); } synchronized(lockObject) { try { callbacks.add(object); lockObject.wait(); } catch (InterruptedException e) { log.debug("InterruptedException received while waiting for thread (" + Thread.currentThread() + ") to be released from BlockingCallbackStore.add(Serializable) call."); } } } /** * No op * @param config */ public void setConfig(Map config) { } /** * No op * @throws Exception */ public void start() throws Exception { } /** * No op */ public void stop() { } /** * No op * @throws Exception */ public void create() throws Exception { } /** * No op */ public void destroy() { } /** * No op * @param purgeOnShutdown */ public void setPurgeOnShutdown(boolean purgeOnShutdown) { } /** * No op. Always returns false. * @return */ public boolean getPurgeOnShutdown() { return false; } /** * No op. */ public void purgeFiles() { } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/DefaultCallbackErrorHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/DefaultCallbackErrorHandl0000644000175000017500000001466211203156312033302 0ustar twernertwerner/* * 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.remoting.callback; import org.jboss.logging.Logger; import org.jboss.remoting.ServerInvoker; import java.util.Map; /** * Default callback error handler if one not specified. This class will listen for exceptions that * occur when trying to deliver callback message to a callback listener from the server. By default, * after the fifth exception, it will remove that callback listener from the server invoker handler. * To set the number of exceptions it will allow before this happens, can set the * 'callbackErrorsAllowed' attribute within the invoker configuration. * * @author Tom Elrod * @author Ovidiu Feodorov */ public class DefaultCallbackErrorHandler implements CallbackErrorHandler { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(DefaultCallbackErrorHandler.class); /** * Key for setting the number of callback exceptions will be allowed when calling on * org.jboss.remoting.callback.InvokerCallbackHandler.handleCallback(Callback callback) * before cleaning up the callback listener. This only applies to push callback. The default if * this property is not set is five. */ public static final String CALLBACK_ERRORS_ALLOWED = "callbackErrorsAllowed"; // defaults to 5 errors before auto clean up private static final int DEFAULT_NUMBER_OF_ERRORS_ALLOWED = 5; // Static --------------------------------------------------------------------------------------- // Attributes ----------------------------------------------------------------------------------- private ServerInvoker serverInvoker; private ServerInvokerCallbackHandler callbackHandler; private int numOfErrorsAllowed; private int currentNumberOfErrors; private String handlerSubsystem; // Constructors --------------------------------------------------------------------------------- public DefaultCallbackErrorHandler() { numOfErrorsAllowed = DEFAULT_NUMBER_OF_ERRORS_ALLOWED; } // CallbackErrorHandler implementation ---------------------------------------------------------- public void setConfig(Map errorHandlerConfig) { if (errorHandlerConfig == null) { log.warn(this + " got null configuration"); return; } // need to get the handler subsystem for if we need to remove the callback listener handlerSubsystem = (String)errorHandlerConfig.get(HANDLER_SUBSYSTEM); Object value = errorHandlerConfig.get(CALLBACK_ERRORS_ALLOWED); if (value != null) { if (value instanceof String) { String stringValue = (String) value; try { numOfErrorsAllowed = Integer.parseInt(stringValue); } catch (NumberFormatException e) { log.warn(this + " could not convert configuration value for " + CALLBACK_ERRORS_ALLOWED + " (" + stringValue + ") into a numeric value."); } } else if (value instanceof Integer) { numOfErrorsAllowed = ((Integer)value).intValue(); } else { log.warn(this + " could not convert configuration value for " + CALLBACK_ERRORS_ALLOWED + " (" + value + ") into a numeric value. " + "Type of value should be either String or Integer."); } } } public synchronized void handleError(Throwable ex) throws Throwable { currentNumberOfErrors++; log.debug(this + " handling " + ex + ". Number of errors so far " + currentNumberOfErrors); if (currentNumberOfErrors < numOfErrorsAllowed) { log.debug(this + " ignoring the callback error"); throw ex; } log.debug(this + " reached maximum number of callback errors allowed (" + numOfErrorsAllowed + "). Will clean up callback hander now."); if (serverInvoker != null) { serverInvoker.removeCallbackListener(handlerSubsystem, callbackHandler); callbackHandler.destroy(); } // rethrowing the exception so the client application can catch it and handle it too throw ex; } public void setServerInvoker(ServerInvoker serverInvoker) { log.debug(this + " setting server invoker to " + serverInvoker); this.serverInvoker = serverInvoker; } public void setCallbackHandler(ServerInvokerCallbackHandler callbackHandler) { log.debug(this + " setting callback handler to " + callbackHandler); this.callbackHandler = callbackHandler; } // Public --------------------------------------------------------------------------------------- public String toString() { StringBuffer sb = new StringBuffer("DefaultCallbackErrorHandler["); if (serverInvoker == null) { sb.append("UNITIALIZED"); } else { sb.append(serverInvoker); } sb.append(']'); return sb.toString(); } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/HandleCallbackException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/HandleCallbackException.j0000644000175000017500000000300410452770174033240 0ustar twernertwerner/* * 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.remoting.callback; /** * This exception may be thrown if there is an error in dispatching * the callback to the intended handler. * * @author Tom Elrod */ public class HandleCallbackException extends Exception { private static final long serialVersionUID = 5007830854771520817L; public HandleCallbackException(String message) { super(message); } public HandleCallbackException(String message, Throwable cause) { super(message, cause); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/CallbackStore.java0000644000175000017500000004643311171060613031754 0ustar twernertwerner/* * 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.remoting.callback; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.util.SecurityUtility; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Arrays; import java.util.Map; /** * Acts as a persistent list which writes Serializable objects to disk and will retrieve them * in same order in which they were added (FIFO). Each file will be named according to the current * time (using System.currentTimeMillis() with the file suffix specified (see below). When the * object is read and returned by calling the getNext() method, the file on disk for that object will * be deleted. If for some reason the store VM crashes, the objects will still be available upon next startup. *

          * The attributes to make sure to configure are: *

          * file path - this determins which directory to write the objects. The default value is the property value * of 'jboss.server.data.dir' and if this is not set, then will be 'data'. For example, might * be /jboss/server/default/data.

          * file suffix - the file suffix to use for the file written for each object stored.

          *

          * This is also a service mbean, so can be run as a service within JBoss AS or stand alone. * * @author Tom Elrod */ public class CallbackStore implements CallbackStoreMBean { private static long previousTimestamp; private static int timestampCounter; private String filePath = null; private String fileSuffix = "ser"; private boolean isStarted = false; private boolean purgeOnShutdown = false; private String serializationType = "java"; /** * Key for setting which directory to write the callback objects. * The default value is the property value of 'jboss.server.data.dir' and if this is not set, * then will be 'data'. Will then append 'remoting' and the callback client's session id. * An example would be 'data\remoting\5c4o05l-9jijyx-e5b6xyph-1-e5b6xyph-2'. */ public static final String FILE_PATH_KEY = "StoreFilePath"; /** * Key for setting the file suffix to use for the callback objects written to disk. The default value is "ser". */ public static final String FILE_SUFFIX_KEY = "StoreFileSuffix"; private static final Logger log = Logger.getLogger(CallbackStore.class); /** * Default store constructor. */ public CallbackStore() { } /** * Store constructor. * * @param purgeOnDestroy if true, will remove all persisted objects from disk on when destroy() is called, else * will leave the files (which is the default behaviour). */ public CallbackStore(boolean purgeOnDestroy) { this.purgeOnShutdown = purgeOnDestroy; } /** * Will get the file path value (if not already set will just use the * default setting) and will create the directory specified by the file path * if it does not already exist. * * @throws Exception */ public void start() throws Exception { if (!isStarted) { // need to figure the best place to store on disk if (filePath == null) { try { filePath = getSystemProperty("jboss.server.data.dir", "data"); } catch (Exception e) { log.debug("error", e); filePath = "data"; } } File storeFile = new File(filePath); if (!storeFile.exists()) { boolean madeDir = mkdirs(storeFile); if (!madeDir) { throw new IOException("Can not create directory for store. Path given: " + filePath); } } isStarted = true; } } /** * Sets if store should clean up persisted files when shutdown (destroy()). * * @param purgeOnShutdown */ public void setPurgeOnShutdown(boolean purgeOnShutdown) { this.purgeOnShutdown = purgeOnShutdown; } /** * Returns if store will clean up persisted files when shutdown (destroy()). * * @return */ public boolean getPurgeOnShutdown() { return purgeOnShutdown; } /** * This is a no op method, but needed in order to be used as a service within JBoss AS. * * @throws Exception */ public void create() throws Exception { } /** * This will allow for change of file suffix and file path and then may start again * using these new values. However, any object already written out using the old * values will be lost as will not longer be accessible if these attributes are changed while stopped. */ public void stop() { isStarted = false; } /** * If purgeOnDestroy is true, will remove files upon shutdown. */ public void destroy() { if (purgeOnShutdown) { purgeFiles(); } } public void purgeFiles() { String[] fileList = getObjectFileList(); String fileToDelete = null; for (int x = 0; x < fileList.length; x++) { try { String separator = getSystemProperty("file.separator"); fileToDelete = filePath + separator + fileList[x]; final File currentFile = new File(fileToDelete); boolean deleted = ((Boolean)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(currentFile.delete()); } })).booleanValue(); if (!deleted) { log.warn("Error purging file " + fileToDelete); } } catch (Exception e) { log.warn("Error purging file " + fileToDelete); } } } /** * Will use the values in the map to set configuration. This will not change behaviour of store until * has been stopped and then started (if has not been started, will take effect upon start). * The keys for the map are FILE_PATH_KEY and FILE_SUFFIX_KEY. * * @param config */ public void setConfig(Map config) { if (config != null) { String newFilePath = (String) config.get(FILE_PATH_KEY); if (newFilePath != null) { filePath = newFilePath; } String newFileSuffix = (String) config.get(FILE_SUFFIX_KEY); if (newFileSuffix != null) { fileSuffix = newFileSuffix; } String newSerializationType = (String) config.get(InvokerLocator.SERIALIZATIONTYPE); if (newSerializationType != null) { serializationType = newSerializationType; } } } /** * Gets the file path for the directory where the objects will be stored. * * @return */ public String getStoreFilePath() { return filePath; } /** * Sets teh file path for the directory where the objects will be stored. * * @param filePath */ public void setStoreFilePath(String filePath) { this.filePath = filePath; } /** * Gets the file suffix for each of the files that objects will be persisted to. * * @return */ public String getStoreFileSuffix() { return fileSuffix; } /** * Sets the file suffix for each of the files that objects will be persisted to. * * @param fileSuffix */ public void setStoreFileSuffix(String fileSuffix) { this.fileSuffix = fileSuffix; } /** * Getst the number of objects stored and available. * * @return */ public int size() { verifyStarted(); String[] objectFileList = getObjectFileList(); if (objectFileList != null) { return objectFileList.length; } else { return 0; } } private void verifyStarted() { if (!isStarted) { throw new RuntimeException("Can not call upon this store method before it has been started."); } } /** * Will look through the files in the store directory for the oldest object serialized to disk, load it, * delete the file, and return the deserialized object. * Important to note that once this object is returned from this method, it is gone forever from this * store and will not be able to retrieve it again without adding it back. * * @return * @throws IOException */ public Object getNext() throws IOException { verifyStarted(); Object obj = null; String objectFilePath = null; synchronized (filePath) { String[] objectFileList = getObjectFileList(); FileInputStream inFile = null; ObjectInputStream in = null; if (objectFileList != null && objectFileList.length > 0) { try { // only getting the first one, which will be first one entered since the getting // of the list is automatically ordered by the OS and all file names are numeric by time. String separator = getSystemProperty("file.separator"); objectFilePath = filePath + separator + objectFileList[0]; inFile = getFileInputStream(objectFilePath); in = SerializationStreamFactory.getManagerInstance(serializationType).createRegularInput(inFile); try { obj = in.readObject(); } catch (ClassNotFoundException e) { throw new IOException("Error loading persisted object. Could not load class (" + e.getMessage() + ")."); } } finally { if (inFile != null) { try { inFile.close(); } catch (IOException ioe) { log.debug("Error closing FileInputStream.", ioe); } } if (in != null) { try { in.close(); } catch (IOException ioe) { log.debug("Error closing ObjectInputStream.", ioe); } } if (objectFilePath != null) { // now remove the file final File objectFile = new File(objectFilePath); boolean isDeleted = ((Boolean) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(objectFile.delete()); } })).booleanValue(); if (log.isTraceEnabled()) { log.trace("object file (" + objectFilePath + ") has been deleted - " + isDeleted); } } } } } return obj; } private String[] getObjectFileList() { final File storePath = new File(filePath); String[] objectFileList = (String[]) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return storePath.list(new StoreFileFilter()); } }); Arrays.sort(objectFileList); return objectFileList; } /** * Persists the serializable object passed to the directory specified. The file name will be the current time * in milliseconds (vis System.currentTimeMillis()) with the specified suffix. This object can later be * retrieved using the getNext() method, but objects will be returned in the order that they were added (FIFO). * * @param object * @throws IOException */ public void add(final Serializable object) throws IOException { verifyStarted(); synchronized (filePath) { long currentTimestamp = System.currentTimeMillis(); if (previousTimestamp == currentTimestamp) { timestampCounter++; } else { previousTimestamp = currentTimestamp; timestampCounter = 0; } StringBuffer path = new StringBuffer(filePath); String separator = getSystemProperty("file.separator"); path.append(separator).append(String.valueOf(currentTimestamp)); path.append("-").append(timestampCounter).append(".").append(fileSuffix); final File storeFile = new File(path.toString()); FileOutputStream outFile = null; ObjectOutputStream out = null; try { outFile = getFileOutputStream(storeFile, false); if (serializationType.indexOf("jboss") > 0) { out = SerializationStreamFactory.getManagerInstance(serializationType).createOutput(outFile); out.writeObject(object); out.flush(); } else { try { final FileOutputStream finalOutFile = outFile; out = (ObjectOutputStream) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { ObjectOutputStream out = SerializationStreamFactory.getManagerInstance(serializationType).createOutput(finalOutFile); out.writeObject(object); out.flush(); return out; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } } finally { if (outFile != null) { try { outFile.close(); } catch (IOException ioe) { log.debug("Error closing FileInputStream.", ioe); } } if (out != null) { try { out.close(); } catch (IOException ioe) { log.debug("Error closing ObjectInputStream.", ioe); } } } } } public class StoreFileFilter implements FilenameFilter { /** * Tests if a specified file should be included in a file list. * * @param dir the directory in which the file was found. * @param name the name of the file. * @return true if and only if the name should be included in the file list; false * otherwise. */ public boolean accept(File dir, String name) { if (name.endsWith(fileSuffix)) { return true; } else { return false; } } } static private boolean mkdirs(final File dir) { if (SecurityUtility.skipAccessControl()) { return dir.mkdirs(); } return ((Boolean) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(dir.mkdirs()); } })).booleanValue(); } static private FileInputStream getFileInputStream(final String path) throws FileNotFoundException { if (SecurityUtility.skipAccessControl()) { return new FileInputStream(path); } try { return (FileInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(path); } }); } catch (PrivilegedActionException e) { throw (FileNotFoundException) e.getCause(); } } static private FileOutputStream getFileOutputStream(final File file, final boolean append) throws FileNotFoundException { if (SecurityUtility.skipAccessControl()) { return new FileOutputStream(file, append); } try { return (FileOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileOutputStream(file, append); } }); } catch (PrivilegedActionException e) { throw (FileNotFoundException) e.getCause(); } } static private String getSystemProperty(final String name, final String defaultValue) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name, defaultValue); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name, defaultValue); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private String getSystemProperty(final String name) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/callback/Callback.java0000644000175000017500000000665310461473166030753 0ustar twernertwerner/* * 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.remoting.callback; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Version; import java.util.HashMap; import java.util.Map; /** * This is the class to use for sending callback payloads from the * server handler to the callback listener. * * @author Tom Elrod */ public class Callback extends InvocationRequest { static final long serialVersionUID; public final static String CALLBACK_HANDLE_OBJECT_KEY = "callback_handle_object"; public final static String SERVER_LOCATOR_KEY = "server_locator"; static { if(Version.getDefaultVersion() == Version.VERSION_1) { serialVersionUID = -4778964132014467531L; } else { serialVersionUID = -9196653590434634454L; } } /** * Constructs the callback object with any object payload. * * @param callbackPayload */ public Callback(Object callbackPayload) { super(callbackPayload); } /** * Returns the handle object originally specified when initially registering * the callback listener. This can be used to provide context upon callbacks. * * @return */ public Object getCallbackHandleObject() { Object handleObject = null; Map returnPayload = getReturnPayload(); if(returnPayload != null) { handleObject = returnPayload.get(CALLBACK_HANDLE_OBJECT_KEY); } return handleObject; } protected void setCallbackHandleObject(Object handleObject) { Map returnPayload = getReturnPayload(); if(returnPayload == null) { returnPayload = new HashMap(); setReturnPayload(returnPayload); } returnPayload.put(CALLBACK_HANDLE_OBJECT_KEY, handleObject); } /** * Gets the callback payload sent from the server handler. * * @return */ public Object getCallbackObject() { return getParameter(); } /** * Gets the locator for the target server where the callback was generated (this will be for * the same server that the callback client was registered). * * @return */ public InvokerLocator getServerLocator() { InvokerLocator locator = null; Map returnPayload = getReturnPayload(); if(returnPayload != null) { locator = (InvokerLocator) returnPayload.get(SERVER_LOCATOR_KEY); } return locator; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/RemoteClientInvoker.java0000644000175000017500000000564111173254622031442 0ustar twernertwerner/* * 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.remoting; import java.util.Map; import org.jboss.logging.Logger; /** * This class extends the MicroRemoteClientInvoker and adds extra * functionality that can not be included in a J2ME envrionment, such as * setting socket factories. * * @author Tom Elrod * @version $Revision: 5074 $ */ public abstract class RemoteClientInvoker extends MicroRemoteClientInvoker { private static Logger log = Logger.getLogger(RemoteClientInvoker.class); public RemoteClientInvoker(InvokerLocator locator) { super(locator); } public RemoteClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); Map parameters = locator.getParameters(); if (parameters != null) { String socketFactoryClassName = (String) locator.parameters.get(Remoting.SOCKET_FACTORY_CLASS_NAME); if (socketFactoryClassName != null) { configuration.put(Remoting.SOCKET_FACTORY_CLASS_NAME, socketFactoryClassName); } } if (useAllParams(getConfiguration())) { // getConfiguration() returns combination of InvokerLocator and configuration parameters. socketFactory = createSocketFactory(getConfiguration()); } else { socketFactory = createSocketFactory(configuration); } } protected boolean useAllParams(Map configuration) { boolean result = false; if (configuration != null) { Object o = configuration.get(Remoting.USE_ALL_SOCKET_FACTORY_PARAMS); if (o != null) { if (o instanceof String) { result = Boolean.valueOf((String) o).booleanValue(); } else { log.warn("Value of " + Remoting.USE_ALL_SOCKET_FACTORY_PARAMS + " must be a String: " + o); } } } return result; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ClientDisconnectedException.java0000644000175000017500000000105510452747001033122 0ustar twernertwernerpackage org.jboss.remoting; /** * Can expect this exception to be included as parameter to * handleConnectionException() method of org.jboss.remoting.ConnectionListener * when client disconnects from the server. Notice, this is not due to the * client failing, but due to normal client termination. * @author Tom Elrod * @see org.jboss.remoting.ConnectionListener */ public class ClientDisconnectedException extends Exception { private static final long serialVersionUID = 1665349772039533352L; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/0000755000175000017500000000000011632407045026616 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/util/0000755000175000017500000000000011632407045027573 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/util/DetectorUtil.java0000644000175000017500000002064311171060737033053 0ustar twernertwerner/* * 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.remoting.detection.util; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import org.apache.log4j.Level; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.Detector; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.util.SecurityUtility; /** * A simple utility class that will periodically print out remoting servers * running based on detections. Can specify to either use multicast or jndi * detection type. * * @author Tom Elrod * @version $Revision: 5001 $ */ public class DetectorUtil { /** * multicast * */ public static final String TYPE_MULTICAST = "multicast"; /** * jndi * */ public static final String TYPE_JNDI = "jndi"; /** * 2410 * */ public static final int DEFAULT_PORT = 2410; /** * localhost * */ public static final String DEFAULT_HOST = "localhost"; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; private String type = TYPE_MULTICAST; private int port = DEFAULT_PORT; private String host = DEFAULT_HOST; public DetectorUtil() { } public DetectorUtil(String type) { this(type, DEFAULT_PORT, DEFAULT_HOST); } public DetectorUtil(String type, int port) { this(type, port, DEFAULT_HOST); } public DetectorUtil(String type, int port, String host) { this.type = type; this.port = port; this.host = host; } public void start() { try { org.apache.log4j.BasicConfigurator.configure(); org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG); Logger log = Logger.getLogger(getClass()); setSystemProperty("jboss.identity", String.valueOf(System.currentTimeMillis())); MBeanServer server = createMBeanServer(); NetworkRegistry registry = NetworkRegistry.getInstance(); registerMBean(server, registry, new ObjectName("remoting:type=NetworkRegistry")); InvokerLocator locator = new InvokerLocator("socket://localhost"); //ClassLoader clsLoader = Thread.currentThread().getContextClassLoader(); //SocketServerInvoker invokerSvr = new SocketServerInvoker(clsLoader, locator); //ObjectName objName = new ObjectName("jboss.remoting:type=SocketServerInvoker"); //server.registerMBean(invokerSvr, objName); //invokerSvr.start(); Connector connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol()); registerMBean(server, connector, obj); //connector.create(); connector.start(); Detector detector = null; ObjectName objName = null; if(type.equals(TYPE_MULTICAST)) { MulticastDetector mdet = new MulticastDetector(); mdet.setPort(port); detector = mdet; objName = new ObjectName("remoting:type=Detector,transport=multicast"); } else if(type.equals(TYPE_JNDI)) { JNDIDetector jdet = new JNDIDetector(); jdet.setPort(port); jdet.setHost(host); jdet.setContextFactory(contextFactory); jdet.setURLPackage(urlPackage); detector = jdet; objName = new ObjectName("remoting:type=Detector,transport=jndi"); } registerMBean(server, detector, objName); detector.start(); System.err.println("Starting Detector"); while(true) { Thread.currentThread().sleep(3000); NetworkInstance[] instances = registry.getServers(); for(int x = 0; x < instances.length; x++) { log.debug(instances[x]); } } } catch(Exception ex) { System.err.println("Error creating and starting DetectorUtil."); ex.printStackTrace(); } } public static void main(String[] args) { DetectorUtil test = null; if(args.length == 1) { String type = args[0]; test = new DetectorUtil(type); } else if(args.length == 2) { String type = args[0]; int port = Integer.parseInt(args[1]); test = new DetectorUtil(type, port); } else if(args.length == 3) { String type = args[0]; int port = Integer.parseInt(args[1]); String host = args[2]; test = new DetectorUtil(type, port, host); } else { test = new DetectorUtil(); System.out.println("Using default type (" + test.getTransport() + ") and default port (" + test.getPort() + ") and " + "default host (" + test.getHost() + ")" + "\nCan enter type (multicast, jndi), port, and/or host via command line."); } test.start(); } private String getHost() { return host; } private int getPort() { return port; } private String getTransport() { return type; } static private MBeanServer createMBeanServer() throws Exception { if (SecurityUtility.skipAccessControl()) { return MBeanServerFactory.createMBeanServer(); } try { return (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } static private void registerMBean(final MBeanServer server, final Object o, final ObjectName name) throws Exception { if (SecurityUtility.skipAccessControl()) { server.registerMBean(o, name); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { server.registerMBean(o, name); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/ServerInvokerMetadata.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/ServerInvokerMetadata.ja0000644000175000017500000000433310437365254033411 0ustar twernertwerner/* * 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.remoting.detection; import org.jboss.remoting.InvokerLocator; import java.io.Serializable; /** * This is the meta data for a server invoker that is contained within * detection messages. * * @author Tom Elrod */ public class ServerInvokerMetadata implements Serializable { static final long serialVersionUID = 6971867047161027399L; private InvokerLocator locator; private String[] subSystems; public ServerInvokerMetadata(InvokerLocator locator, String[] supportedSubsystems) { this.locator = locator; this.subSystems = supportedSubsystems; } public InvokerLocator getInvokerLocator() { return locator; } public String[] getSubSystems() { return subSystems; } public String toString() { String subSystemStrings = ""; if(subSystems != null) { for(int x = 0; x < subSystems.length; x++) { subSystemStrings = subSystemStrings + subSystems[x] + ","; } subSystemStrings = subSystemStrings.substring(0, subSystemStrings.length()); } return "ServerInvokerMetadata:\n" + "locator: " + locator + "\nsubsystems: " + subSystemStrings; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/Detection.java0000644000175000017500000000652110437607122031403 0ustar twernertwerner/* * 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.remoting.detection; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ident.Identity; import java.io.Serializable; /** * Detection is an MBean Notification that is fired by * Detectors when remote servers are found or lost on the Network. * * @author Jeff Haynie * @version $Revision: 1104 $ */ public class Detection implements Serializable { static final long serialVersionUID = -7560953564286960592L; private final ServerInvokerMetadata[] serverInvokers; private final Identity identity; private final int hashCode; public Detection(Identity identity, ServerInvokerMetadata[] serverInvokers) { this.serverInvokers = serverInvokers; this.identity = identity; this.hashCode = identity.hashCode(); } public boolean equals(Object obj) { if(obj instanceof Detection) { return hashCode == obj.hashCode(); } return false; } public int hashCode() { return hashCode; } public String toString() { String serverInvokersInfo = ""; if(serverInvokers != null) { for(int x = 0; x < serverInvokers.length; x++) { serverInvokersInfo = serverInvokersInfo + serverInvokers[x] + "\n"; } serverInvokersInfo = serverInvokersInfo.substring(0, serverInvokersInfo.length()); } return "Detection (" + super.toString() + ")\n\tidentity:" + identity + "\n\tlocators:" + (serverInvokers == null ? " null" : serverInvokersInfo); } /** * return the jboss identity * * @return */ public final Identity getIdentity() { return identity; } /** * return the locators for the server * * @return */ public final InvokerLocator[] getLocators() { InvokerLocator[] locators = new InvokerLocator[serverInvokers == null ? 0 : serverInvokers.length]; for(int x = 0; x < serverInvokers.length; x++) { locators[x] = serverInvokers[x].getInvokerLocator(); } return locators; } /** * Gets all the server invoker metadata for the servers running on * specified server. Will include locator and supported subsystems * for that locator. * * @return */ public final ServerInvokerMetadata[] getServerInvokers() { return serverInvokers; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/AbstractDetectorMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/AbstractDetectorMBean.ja0000644000175000017500000000542010355142433033271 0ustar twernertwerner/* * 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.remoting.detection; import org.w3c.dom.Element; /** * This provides a MBean accessible interface for setting domain configuration * * @author Tom Elrod */ public interface AbstractDetectorMBean extends Detector { /** * set the configuration for the domains to be recognized by detector * * @param xml * @jmx.managed-attribute description="Domains is an xml element indicating domains to be recognized by detector" * access="read-write" */ public void setConfiguration(Element xml) throws Exception; /** * The getDomains method * * @return an Element value * @jmx.managed-attribute */ public Element getConfiguration(); /** * The amount of time to wait between sending (and sometimes receiving) detection messages. * * @param heartbeatTimeDelay * @throws IllegalArgumentException */ void setHeartbeatTimeDelay(long heartbeatTimeDelay); /** * The amount of time to wait between sending (and sometimes receiving) detection messages. * * @return */ long getHeartbeatTimeDelay(); /** * The amount of time which can elapse without receiving a detection event before a server * will be suspected as being dead and peroforming an explicit invocation on it to verify it is alive. * * @param defaultTimeDelay time in milliseconds * @throws IllegalArgumentException */ void setDefaultTimeDelay(long defaultTimeDelay) throws IllegalArgumentException; /** * @return The amount of time which can elapse without receiving a detection event before a server * will be suspected as being dead and peroforming an explicit invocation on it to verify it is alive. */ long getDefaultTimeDelay(); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/Detector.java0000644000175000017500000000300310355142433031224 0ustar twernertwerner/* * 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.remoting.detection; import javax.management.MBeanRegistration; /** * Detector * * @author Jeff Haynie * @version $Revision: 566 $ */ public interface Detector extends MBeanRegistration { /** * called by MBeanServer to start the mbean lifecycle * * @throws Exception */ public void start() throws Exception; /** * called by the MBeanServer to stop the mbean lifecycle * * @throws Exception */ public void stop() throws Exception; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/jndi/0000755000175000017500000000000011632407045027542 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/jndi/JNDIDetectorMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/jndi/JNDIDetectorMBean.j0000644000175000017500000000326410355142433033041 0ustar twernertwerner/* * 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.remoting.detection.jndi; import org.jboss.remoting.detection.AbstractDetectorMBean; /** * JNDIDetectorMBean * * @author Tom Elrod * @version $Revision: 566 $ */ public interface JNDIDetectorMBean extends AbstractDetectorMBean { public int getPort(); public void setPort(int port); public String getHost(); public void setHost(String host); public String getContextFactory(); public void setContextFactory(String contextFactory); public String getURLPackage(); public void setURLPackage(String urlPackage); public int getCleanDetectionNumber(); public void setCleanDetectionNumber(int cleanDetectionNumber); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java0000644000175000017500000005373111422064560032632 0ustar twernertwerner/* * 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.remoting.detection.jndi; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.detection.AbstractDetector; import org.jboss.remoting.detection.Detection; import org.jboss.remoting.ident.Identity; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.util.SecurityUtility; import org.jnp.interfaces.NamingContextFactory; import org.jnp.server.Main; import javax.naming.Binding; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NameAlreadyBoundException; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Map; import java.util.Properties; /** * This is a remoting detector for the remoting package which uses a JNDI server to * maintain the registeries for remote invoker servers (stored as Detection messages). * This detector is intended to be used in conjuntion with an external JNDI server that * is already running. This is done by passing all the information needed to connect * to the remote JNDI server via the setter methods. This can also be done within * the jboss-service.xml. An example of the entry is as follows:

          * <mbean code="org.jboss.remoting.detection.jndi.JNDIDetector" name="jboss.remoting:service=Detector,transport=jndi">
          * <attribute name="Port">5555</attribute>
          * <attribute name="Host">foo.bar.com</attribute>
          * <attribute name="ContextFactory">org.jnp.interfaces.NamingContextFactory</attribute>
          * <attribute name="URLPackage">org.jboss.naming:org.jnp.interfaces</attribute>
          * </mbean>

          * Note: The above xml is for the JBoss JNP JNDI server, and has not be tested (just an example).

          * Be aware that just because this detector is stopped (and the entry removed from the JNDI server) * remote JNDIDetectors may not recognize that the invoker servers are not available. This is because * once remote invoker servers (connectors) are detected, they will be pinged directly to determine * if they are no longer available. However, no new JNDIDetectors will detect your server once stopped. * Also, please note that currently the detection registries are bound at the root context and * not a sub context (which is on the todo list, but you know how that goes).

          * Important to also note that if any of the above attributes are set once the detector has * started, they will not be used in connecting to the JNDI server until the detector is stopped * and re-started (they do not change the JNDI server connection dynamically).

          * * @author Tom Elrod */ public class JNDIDetector extends AbstractDetector implements JNDIDetectorMBean { private int port; private String host; private String contextFactory = NamingContextFactory.class.getName(); ; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; ; private Identity id; private Context context; public static final String DETECTION_SUBCONTEXT_NAME = "detection"; private String subContextName = DETECTION_SUBCONTEXT_NAME; /** * Indicates the number of time will detect before doing check to see if server still alive. */ private int detectionNumber = 5; private int cleanDetectionCount = detectionNumber; protected static final Logger log = Logger.getLogger(JNDIDetector.class); public JNDIDetector() { } public JNDIDetector(Map config) { super(config); } /** * Gets the port used to connect to the JNDI Server. * * @return */ public int getPort() { return port; } /** * Sets the port to use when connecting to JNDI server * * @param port */ public void setPort(int port) { this.port = port; } /** * Gets the host to use when connecting to JNDI server * * @return */ public String getHost() { return host; } /** * Sets the host to use when connecting to JNDI server * * @param host */ public void setHost(String host) { this.host = host; } /** * The context factory string used when connecting to the JNDI server * * @return */ public String getContextFactory() { return contextFactory; } /** * Sets the sub context name under which detection messages will be bound * and looked up. * @param subContextName */ public void setSubContextName(String subContextName) { this.subContextName = subContextName; } /** * Gets the sub context name under which detection messages will be bound and * looked up. * @return */ public String getSubContextName() { return this.subContextName; } /** * The context factory string to use when connecting to the JNDI server. * Should be a qualified class name for JNDI client. * * @param contextFactory */ public void setContextFactory(String contextFactory) { this.contextFactory = contextFactory; } /** * The url package string used when connecting to JNDI server * * @return */ public String getURLPackage() { return urlPackage; } /** * The url package string to use when connecting to the JNDI server. * * @param urlPackage */ public void setURLPackage(String urlPackage) { this.urlPackage = urlPackage; } /** * Will establish the connection to the JNDI server and start detection of other servers. * * @throws Exception */ public void start() throws Exception { createContext(); id = Identity.get(mbeanserver); super.start(); } /** * Creates connection to JNDI server (which should have already happened in start() * method) and will begin checking for remote servers as well as registering itself * so will be visible by remote detectors. */ protected void heartbeat() { try { //Need to establish connection to server if(context == null) { createContext(); } checkRemoteDetectionMsg(); } catch(NamingException nex) { log.error("Can not connect to JNDI server to register local connectors.", nex); } } protected void forceHeartbeat() { heartbeat(); } /** * Gets the number of detection iterations before manually pinging remote * server to make sure still alive. * * @return */ public int getCleanDetectionNumber() { return detectionNumber; } /** * Sets the number of detection iterations before manually pinging remote * server to make sure still alive. This is needed since remote server * could crash and yet still have an entry in the JNDI server, thus * making it appear that it is still there. * * @param cleanDetectionNumber */ public void setCleanDetectionNumber(int cleanDetectionNumber) { detectionNumber = cleanDetectionNumber; cleanDetectionCount = detectionNumber; } private void checkRemoteDetectionMsg() { try { boolean localFound = false; cleanDetectionCount++; boolean cleanDetect = cleanDetectionCount > detectionNumber; String bindName = ""; NamingEnumeration enumeration = listBindings(context, bindName); while(enumeration.hasMore()) { Binding binding = (Binding) enumeration.next(); Detection regMsg = (Detection) binding.getObject(); // No need to detect myself here if(isRemoteDetection(regMsg)) { log.debug("Detected id: " + regMsg.getIdentity().getInstanceId() + ", message: " + regMsg); if(cleanDetect) { if(log.isTraceEnabled()) { log.trace("Doing clean detection."); } // Need to actually detect if servers registered in JNDI server // are actually there (since could die before unregistering) ClassLoader cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return JNDIDetector.class.getClassLoader(); } }); if(!checkInvokerServer(regMsg, cl)) { unregisterDetection(regMsg.getIdentity().getInstanceId()); } else { // Now, let parent handle detection detect(regMsg); } } else { // Now, let parent handle detection detect(regMsg); } } else { //verify local detection message is correct if(!verifyLocalDetectionMsg(regMsg)) { addLocalDetectionMsg(); } localFound = true; } } if(cleanDetect) { // did clean detect, now need to reset. cleanDetectionCount = 0; } if(!localFound) { // never found local detection message in list, so add it addLocalDetectionMsg(); } } catch(NamingException e) { log.error("Exception getting detection messages from JNDI server.", e); } } private boolean verifyLocalDetectionMsg(Detection regMsg) throws NamingException { boolean verified = false; InvokerLocator[] locators = InvokerRegistry.getRegisteredServerLocators(); Detection msg = createDetection(); String sId = id.getInstanceId(); InvokerLocator[] invokers = regMsg.getLocators(); // first do sanity check to make sure even local detection msg (just in case) if(sId.equals(regMsg.getIdentity().getInstanceId())) { // now see if invoker list changed boolean changed = false; if(locators.length != invokers.length) { changed = true; } else { // now need to make sure all the invokers are same now as in old detection msg // not the most efficient (or elegant) way to do this, but list is short boolean found = false; // flag for if current invoker in list found in old list for(int i = 0; i < locators.length; i++) { found = false; for(int x = 0; x < invokers.length; x++) { if(locators[i].equals(invokers[x])) { found = true; break; } } if(!found) { break; } } if(!found) { changed = true; } } if(changed) { registerDetectionMsg(sId, msg); } // are sure that local detection is correct in JNDI server now verified = true; } return verified; } private void addLocalDetectionMsg() throws NamingException { Detection msg = createDetection(); String sId = id.getInstanceId(); registerDetectionMsg(sId, msg); } private void registerDetectionMsg(String sId, Detection msg) throws NamingException { if(sId != null && msg != null) { try { rebind(context, sId, msg); log.info("Added " + sId + " to registry."); } catch(NameAlreadyBoundException nabex) { if(log.isTraceEnabled()) { log.trace(sId + " already bound to server."); } } } } /** * Convience method to see if given proper configuration to connect to an * existing JNDI server. If not, will create one via JBoss JNP. Should * really only be needed for testing. */ private void verifyJNDIServer() { if(host == null || host.length() == 0) { try { log.info("JNDI Server configuration information not present so will create a local server."); Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { log.debug("Cannot find NamingBeanImpl: must be running jdk 1.4"); } host = getLocalHostName(); port = PortUtil.findFreePort(host); log.info("Remoting JNDI detector starting JNDI server instance since none where specified via configuration."); log.info("Remoting JNDI server started on host + " + host + " and port " + port); //If no server information provided, then start one of our own by default Main server = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = server.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(server, new Object[] {namingBean}); } server.setPort(port); server.setBindAddress(host); server.start(); contextFactory = NamingContextFactory.class.getName(); urlPackage = "org.jboss.naming:org.jnp.interfaces"; } catch(Exception e) { log.error("Error starting up JNDI server since none was specified via configuration.", e); } } } /** * Will try to establish the initial context to the JNDI server based * on the configuration properties set. * * @throws NamingException */ private void createContext() throws NamingException { verifyJNDIServer(); Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory); env.put(Context.PROVIDER_URL, host + ":" + port); env.put(Context.URL_PKG_PREFIXES, urlPackage); InitialContext initialContext = createContext(env); try { context = initialContextLookup(initialContext, subContextName); } catch(NamingException e) { try { context = createSubcontext(initialContext, subContextName); } catch(NameAlreadyBoundException e1) { log.debug("The sub context " + subContextName + " was created before we could."); context = initialContextLookup(initialContext, subContextName); } } } public void stop() throws Exception { try { super.stop(); } finally // Need to cleanup JNDI, even if super's stop throws exception { String sId = id.getInstanceId(); try { unregisterDetection(sId); } catch(NamingException e) { log.warn("Could not unregister " + sId + " before shutdown. " + "Root cause is " + e.getMessage()); } } } private void unregisterDetection(String sId) throws NamingException { if(log.isTraceEnabled()) { log.trace("unregistering detector " + sId); } unbind(context, sId); } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } static private String getLocalHostName() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return doGetLocalHost().getHostName(); } try { return (String) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { return doGetLocalHost().getHostName(); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } static private Context createSubcontext(final InitialContext initialContext, final String subContextName) throws NamingException { if (SecurityUtility.skipAccessControl()) { return initialContext.createSubcontext(subContextName); } try { return (Context) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NamingException { return initialContext.createSubcontext(subContextName); } }); } catch (PrivilegedActionException e) { throw (NamingException) e.getCause(); } } static private Context initialContextLookup(final InitialContext initialContext, final String subContextName) throws NamingException { if (SecurityUtility.skipAccessControl()) { return (Context) initialContext.lookup(subContextName); } try { return (Context) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NamingException { return initialContext.lookup(subContextName); } }); } catch (PrivilegedActionException e) { throw (NamingException) e.getCause(); } } static private NamingEnumeration listBindings(final Context context, final String bindName) throws NamingException { if (SecurityUtility.skipAccessControl()) { return context.listBindings(bindName); } try { return (NamingEnumeration) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NamingException { return context.listBindings(bindName); } }); } catch (PrivilegedActionException e) { throw (NamingException) e.getCause(); } } static private void rebind(final Context context, final String name, final Object object) throws NamingException { if (SecurityUtility.skipAccessControl()) { context.rebind(name, object); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NamingException { context.rebind(name, object); return null; } }); } catch (PrivilegedActionException e) { throw (NamingException) e.getCause(); } } static private void unbind(final Context context, final String name) throws NamingException { if (SecurityUtility.skipAccessControl()) { context.unbind(name); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NamingException { context.unbind(name); return null; } }); } catch (PrivilegedActionException e) { throw (NamingException) e.getCause(); } } static private InitialContext createContext(final Properties env) throws NamingException { if (SecurityUtility.skipAccessControl()) { return new InitialContext(env); } try { return (InitialContext) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new InitialContext(env); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/multicast/0000755000175000017500000000000011632407045030623 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/multicast/MulticastDetector.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/multicast/MulticastDetec0000644000175000017500000002507211422064663033470 0ustar twernertwerner/* * 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.remoting.detection.multicast; import org.jboss.remoting.detection.AbstractDetector; import org.jboss.remoting.detection.Detection; import org.jboss.remoting.util.SecurityUtility; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.DatagramPacket; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.MulticastSocket; import java.net.SocketAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * MulticastDetector is a remoting detector that broadcasts detection messages using * muliticast. The default multicast ip is 224.1.9.1 and port 2410. * * @author Jeff Haynie * @author Adrian Brock * @author Tom Elrod * @version $Revision: 5922 $ */ public class MulticastDetector extends AbstractDetector implements MulticastDetectorMBean { private static int threadCounter = 0; private String defaultIP = "224.1.9.1"; private InetAddress addr; private InetAddress bindAddr; private int port = 2410; private MulticastSocket socket; private Listener listener = new Listener("Remoting Multicast Detector - Listener Thread: " + threadCounter++); private int bufferSize = 10000; /** * @return The IP that is used to broadcast detection messages on via multicast. */ public String getDefaultIP() { return defaultIP; } /** * @param defaultIP The IP that is used to broadcast detection messages on via multicast. */ public void setDefaultIP(String defaultIP) { this.defaultIP = defaultIP; } /** * return the multicast address of the detector * * @return */ public InetAddress getAddress() { return addr; } /** * set the interface address of the multicast * * @param ip */ public void setAddress(InetAddress ip) { this.addr = ip; } /** * return the bind address of the detector * * @return */ public InetAddress getBindAddress() { return bindAddr; } /** * set the bind address of the multicast * * @param ip */ public void setBindAddress(InetAddress ip) { this.bindAddr = ip; } /** * get the port that the detector is multicasting to * * @return */ public int getPort() { return port; } /** * set the port for detections to be multicast to * * @param port */ public void setPort(int port) { this.port = port; } public int getBufferSize() { return bufferSize; } public void setBufferSize(int bufferSize) { this.bufferSize = bufferSize; } /** * called by MBeanServer to start the mbean lifecycle * * @throws Exception */ public void start() throws Exception { if(addr == null) { addr = getAddressByName(defaultIP); } // check to see if we're running on a machine with loopback and no NIC InetAddress localHost = getLocalHost(); if(bindAddr == null && localHost.getHostAddress().equals("127.0.0.1")) { // use this to bind so multicast will work w/o network this.bindAddr = localHost; } try { final SocketAddress saddr = new InetSocketAddress(bindAddr, port); AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { socket = new MulticastSocket(saddr); socket.joinGroup(addr); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } super.start(); if(listener == null) { listener = new Listener("Remoting Multicast Detector - Listener Thread: " + threadCounter++); } listener.start(); } /** * called by the MBeanServer to stop the mbean lifecycle * * @throws Exception */ public void stop() throws Exception { super.stop(); if(listener != null) { try { listener.running = false; listener.interrupt(); } catch (Exception e) { { log.warn(this + " Error stopping multicast detector. " + e.getMessage()); } } listener = null; } if(socket != null) { try { socket.leaveGroup(addr); socket.close(); } catch (IOException e) { log.warn(this + " Error stopping multicast detector. " + e.getMessage()); } socket = null; } } /** * subclasses must implement to provide the specific heartbeat protocol * for this server to send out to other servers on the network */ protected void heartbeat() { if(socket != null) { Detection msg = createDetection(); if (msg == null) return; try { if(log.isTraceEnabled()) { log.trace(this + " sending heartbeat: " + msg); } ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream objectOut = new ObjectOutputStream(byteOut); objectOut.writeObject(msg); objectOut.flush(); byteOut.flush(); byte buf[] = byteOut.toByteArray(); DatagramPacket p = new DatagramPacket(buf, buf.length, addr, port); socket.send(p); } catch(Throwable ex) { // its failed log.debug(this + " heartbeat failed", ex); } } } protected void forceHeartbeat() { if(socket != null) { String msg = "Send heartbeat"; try { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); ObjectOutputStream objectOut = new ObjectOutputStream(byteOut); objectOut.writeObject(msg); objectOut.flush(); byteOut.flush(); byte buf[] = byteOut.toByteArray(); DatagramPacket p = new DatagramPacket(buf, buf.length, addr, port); socket.send(p); /** * This is a bit of a hack, but am going to wait a few seconds to * allow for any group members (other multicast detectors) to receive * the msg and then respond themselves with their detection messages. * Since don't know number of servers that are members of the group, * can't really wait until all detection messages, just hope they come * in before end of waiting. */ Thread.currentThread().sleep(2000); } catch(Throwable ex) { // its failed log.debug(this + " forced heartbeat failed", ex); } } } private void listen(DatagramPacket p, byte[] buf) { if(socket != null) { try { // should block until we get a multicast socket.receive(p); // take the multicast, and deserialize into the detection event ByteArrayInputStream byteInput = new ByteArrayInputStream(buf); ObjectInputStream objectInput = new ObjectInputStream(byteInput); Object obj = objectInput.readObject(); if(obj instanceof Detection) { Detection msg = (Detection)obj; if(log.isTraceEnabled()) { log.trace(this + " received detection: " + msg); } // let the subclass do the hard work off handling detection detect(msg); } else { // for now, assume anything *not* of type Detection // is a prompt to send out detection msg heartbeat(); } } catch(Throwable e) { if(e instanceof java.io.InvalidClassException) { return; } if(socket != null) { log.debug(this + " Error receiving detection", e); } } } } private final class Listener extends Thread { boolean running = true; public Listener(String name) { super(name); } public void run() { log.debug("using bufferSize: " + bufferSize); byte[] buf = new byte[bufferSize]; DatagramPacket p = new DatagramPacket(buf, 0, buf.length); //p.setAddress(addr); //p.setPort(port); while(running) { listen(p, buf); } } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/multicast/MulticastDetectorMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/multicast/MulticastDetec0000644000175000017500000000502011170243604033451 0ustar twernertwerner/* * 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.remoting.detection.multicast; import java.net.InetAddress; import org.jboss.remoting.detection.AbstractDetectorMBean; /** * MulticastDetectorMBean * * @author Jeff Haynie * @version $Revision: 4968 $ */ public interface MulticastDetectorMBean extends AbstractDetectorMBean { /** * return the multicast address of the detector * * @return */ public InetAddress getAddress(); /** * set the interface address of the multicast * * @param ip */ public void setAddress(InetAddress ip); /** * return the bind address of the detector * * @return */ public InetAddress getBindAddress(); /** * set the bind address * * @param ip */ public void setBindAddress(InetAddress ip); /** * set the port for detections to be multicast to * * @param port */ public void setPort(int port); /** * get the port that the detector is multicasting to * * @return */ public int getPort(); /** * @return The IP that is used to broadcast detection messages on via multicast. */ String getDefaultIP(); /** * @param defaultIP The IP that is used to broadcast detection messages on via multicast. */ void setDefaultIP(String defaultIP); /** * @return The size of the byte array in the DatagramPacket. */ int getBufferSize(); /** * @param bufferSize The size of the byte array in the DatagramPacket. */ void setBufferSize(int bufferSize); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/detection/AbstractDetector.java0000644000175000017500000006257111422064515032727 0ustar twernertwerner/* * 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.remoting.detection; import org.jboss.logging.Logger; import org.jboss.remoting.ConnectionValidator; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.ident.Identity; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkRegistryFinder; import org.jboss.remoting.network.NetworkRegistryMBean; import org.jboss.remoting.network.NetworkRegistryWrapper; import org.jboss.remoting.util.SecurityUtility; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.management.MBeanServer; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectName; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Timer; import java.util.TimerTask; /** * AbstractDetector * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5920 $ */ public abstract class AbstractDetector implements AbstractDetectorMBean { static protected final Logger log = Logger.getLogger(AbstractDetector.class); private long defaultTimeDelay = 5000; private long heartbeatTimeDelay = 1000; protected MBeanServer mbeanserver; protected ObjectName objectName; protected ObjectName registryObjectName; protected NetworkRegistryMBean networkRegistry; private Identity myself; private Timer heartbeatTimer; private Timer failureTimer; private Map servers = new HashMap(); private Element xml; private Set domains = new HashSet(); private boolean acceptLocal = false; private Map config; private static final InetAddress LOCAL_HOST; static { try { LOCAL_HOST = (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } }); } catch (PrivilegedActionException e) { log.debug(AbstractDetector.class.getName() + " unable to get local host address", e.getCause()); throw new ExceptionInInitializerError(e.getCause()); } catch (SecurityException e) { log.debug(AbstractDetector.class.getName() + " unable to get local host address", e); throw e; } } static protected InetAddress getLocalHost() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return doGetLocalHost(); } try { return (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { return doGetLocalHost(); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } static protected InetAddress doGetLocalHost() throws UnknownHostException { if (LOCAL_HOST != null) { return LOCAL_HOST; } try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } public AbstractDetector() { this(null); } public AbstractDetector(Map config) { this.config = new HashMap(); if (config != null) this.config.putAll(config); } /** * The amount of time to wait between sending (and sometimes receiving) detection messages. * * @param heartbeatTimeDelay * @throws IllegalArgumentException */ public void setHeartbeatTimeDelay(long heartbeatTimeDelay) { if(heartbeatTimeDelay > 0 && heartbeatTimeDelay < defaultTimeDelay) { this.heartbeatTimeDelay = heartbeatTimeDelay; } else { throw new IllegalArgumentException("Can not set heartbeat time delay (" + heartbeatTimeDelay + ") to a negative number or " + "to a number greater than the default time delay (" + defaultTimeDelay + ")."); } } /** * The amount of time to wait between sending (and sometimes receiving) detection messages. * * @return */ public long getHeartbeatTimeDelay() { return heartbeatTimeDelay; } /** * The amount of time which can elapse without receiving a detection event before a server * will be suspected as being dead and peroforming an explicit invocation on it to verify it is alive. * * @param defaultTimeDelay time in milliseconds * @throws IllegalArgumentException */ public void setDefaultTimeDelay(long defaultTimeDelay) { if(defaultTimeDelay >= heartbeatTimeDelay) { this.defaultTimeDelay = defaultTimeDelay; } else { throw new IllegalArgumentException("Can not set the default time delay (" + defaultTimeDelay + ") to be less" + " than that of the heartbeat time delay (" + heartbeatTimeDelay + ")."); } } /** * @return The amount of time which can elapse without receiving a detection event before a server * will be suspected as being dead and peroforming an explicit invocation on it to verify it is alive. */ public long getDefaultTimeDelay() { return defaultTimeDelay; } /** * Will create a detection message based on the server invokers registered within the local InvokerRegistry. * The detection message will contain the identity and array of server invoker metadata. * * @return */ public Detection createDetection() { Detection detection = null; ServerInvoker invokers[] = InvokerRegistry.getServerInvokers(); if(invokers == null || invokers.length <= 0) { return detection; } List l = new ArrayList(invokers.length); for(int c = 0; c < invokers.length; c++) { if(invokers[c].isStarted()) { ServerInvokerMetadata serverInvoker = new ServerInvokerMetadata(invokers[c].getLocator(), invokers[c].getSupportedSubsystems()); l.add(serverInvoker); } } if(l.isEmpty()) { return detection; } ServerInvokerMetadata metadata[] = (ServerInvokerMetadata[]) l.toArray(new ServerInvokerMetadata[l.size()]); detection = new Detection(Identity.get(mbeanserver), metadata); return detection; } /** * called by MBeanServer to start the mbean lifecycle * * @throws Exception */ public void start() throws Exception { // get our own identity myself = Identity.get(mbeanserver); // add my domain if domains empty and xml not set if(domains.isEmpty() && xml == null) { domains.add(myself.getDomain()); } // find our NetworkRegistry registryObjectName = NetworkRegistryFinder.find(mbeanserver); if(registryObjectName == null) { log.warn("Detector: " + getClass().getName() + " could not be loaded because the NetworkRegistry is not registered"); log.warn("This means that only the broadcasting of detection messages will be functional and will not be able to discover other servers."); } else { Object o = MBeanServerInvocationHandler.newProxyInstance(mbeanserver, registryObjectName, NetworkRegistryMBean.class, false); networkRegistry = new NetworkRegistryWrapper((NetworkRegistryMBean) o); } startPinger(getPingerDelay(), getPingerPeriod()); startHeartbeat(getHeartbeatDelay(), getHeartbeatPeriod()); } /** * return the delay in milliseconds between when the timer is created to when the first pinger thread runs. * defaults to 5000 * * @return */ protected long getPingerDelay() { return 5000; } /** * return the period in milliseconds between checking lost servers against the last detection timestamp. * defaults to 1500 * * @return */ protected long getPingerPeriod() { return 1500; } /** * start the pinger timer thread * * @param delay * @param period */ protected void startPinger(long delay, long period) { failureTimer = new Timer(false); failureTimer.schedule(new FailureDetector(), delay, period); } /** * stop the pinger timer thread */ protected void stopPinger() { if(failureTimer != null) { failureTimer.cancel(); failureTimer = null; } } /** * called by the MBeanServer to stop the mbean lifecycle * * @throws Exception */ public void stop() throws Exception { stopPinger(); stopHeartbeat(); stopPinger(); } public void postDeregister() { } public void postRegister(Boolean aBoolean) { } public void preDeregister() throws Exception { } public ObjectName preRegister(MBeanServer mBeanServer, ObjectName objectName) throws Exception { this.mbeanserver = mBeanServer; this.objectName = objectName; return objectName; } /** * set the configuration for the domains to be recognized by detector * * @param xml * @jmx.managed-attribute description="Configuration is an xml element indicating domains to be recognized by detector" * access="read-write" */ public void setConfiguration(Element xml) throws Exception { this.xml = xml; // check configuration xml if(xml != null) { // clearing collection of domains since have new ones to set domains.clear(); NodeList domainNodes = xml.getElementsByTagName("domain"); if(domainNodes == null || domainNodes.getLength() <= 0) { // no domains specified, so will accept all domains log.debug("No domains specified. Will accept all domains."); } int len = domainNodes.getLength(); for(int c = 0; c < len; c++) { Node node = domainNodes.item(c); String domain = node.getFirstChild().getNodeValue(); domains.add(domain); log.debug("Added domain " + domain + " to detector list."); } // now look to see if local server detection should be accepted NodeList localNode = xml.getElementsByTagName("local"); if(localNode != null) { acceptLocal = true; } } } /** * The getConfiguration method * * @return an Element value * @jmx.managed-attribute */ public Element getConfiguration() { return xml; } //----------------------- protected /** * start heartbeating * * @param delay * @param period */ protected void startHeartbeat(long delay, long period) { if(heartbeatTimer == null) { heartbeatTimer = new Timer(false); } try { heartbeatTimer.schedule(new Heartbeat(), delay, period); } catch (IllegalStateException e) { log.debug("Unable to schedule TimerTask on existing Timer", e); heartbeatTimer = new Timer(false); heartbeatTimer.schedule(new Heartbeat(), delay, period); } } /** * stop heartbeating */ protected void stopHeartbeat() { if(heartbeatTimer != null) { try { heartbeatTimer.cancel(); } catch(Exception eg) { } heartbeatTimer = null; } } /** * return the initial delay in milliseconds before the initial heartbeat is fired. * Defaults to 0 * * @return */ protected long getHeartbeatDelay() { return 0; } /** * return the period in milliseconds between subsequent heartbeats. Defaults to * 1000 * * @return */ protected long getHeartbeatPeriod() { return heartbeatTimeDelay; } /** * subclasses must implement to provide the specific heartbeat protocol * for this server to send out to other servers on the network */ protected abstract void heartbeat(); /** * To be used to force detection to occur in synchronouse manner * instead of being passive and waiting for detection messages to * come in from remote detectors. The servers returned should be * the remote servers that are online at this point in time. Note, calling this * method may take a few seconds to complete. * @return */ public NetworkInstance[] forceDetection() { forceHeartbeat(); if(networkRegistry != null) { return (NetworkInstance[]) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return networkRegistry.getServers(); } }); } else { return null; } } /** * Used to force detection messages to be sent by remoting servers * and consumed by detector and registered with network registry. */ protected abstract void forceHeartbeat(); /** * called when a remote detection from a peer is received by a detector * * @param detection */ protected void detect(final Detection detection) { if (detection != null) { if (log.isTraceEnabled()) { log.trace("Detection message received."); log.trace("Id = " + detection.getIdentity() != null ? detection.getIdentity().getInstanceId() : "null"); log.trace("isRemoteDetection() = " + isRemoteDetection(detection)); } // we only track detections within our own domain and not ourself if (isRemoteDetection(detection)) { try { boolean found = false; Server server = null; synchronized (servers) { server = (Server) servers.get(detection); found = server != null; if (!found) { // update either way the timestamp and the detection servers.put(detection, new Server(detection)); } else { server.lastDetection = System.currentTimeMillis(); } } if (found == false) { if (networkRegistry != null) { log.debug(this + " detected NEW server: " + detection); AccessController.doPrivileged( new PrivilegedAction() { public Object run() { networkRegistry.addServer(detection.getIdentity(), detection.getServerInvokers()); return null; } }); } } else { if (server.changed(detection)) { // update hash servers.put(detection, new Server(detection)); if (networkRegistry != null) { if (log.isTraceEnabled()) { log.trace(this + " detected UPDATE for server: " + detection); } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { networkRegistry.updateServer(detection.getIdentity(), detection.getServerInvokers()); return null; } }); } } } } catch (Exception e) { log.warn("Error during detection of: " + detection); log.debug("Error during detection of: " + detection, e); } } else if (log.isTraceEnabled()) { log.trace("detection from myself - ignored"); } } } protected boolean isRemoteDetection(Detection detection) { String domain = null; if(detection != null) { Identity identity = detection.getIdentity(); if(identity != null) { domain = identity.getDomain(); } } // is detection domain in accepted domain collection and not local // if domains empty, then accept all return (domain == null || domains.isEmpty() || domains.contains(domain)) && (acceptLocal ? true : (myself.isSameJVM(detection.getIdentity()) == false)); } protected boolean checkInvokerServer(final Detection detection, ClassLoader cl) { boolean ok = false; ServerInvokerMetadata[] invokerMetadataArray = detection.getServerInvokers(); ArrayList validinvokers = new ArrayList(); for(int c = 0; c < invokerMetadataArray.length; c++) { InvokerLocator locator = null; try { ServerInvokerMetadata invokerMetadata = invokerMetadataArray[c]; locator = invokerMetadata.getInvokerLocator(); boolean isValid = ConnectionValidator.checkConnection(locator, config); if(isValid) { // the transport was successful ok = true; validinvokers.add(invokerMetadata); if(log.isTraceEnabled()) { log.trace("Successful connection check for " + locator); } } } catch(Throwable ig) { log.debug("failed calling ping on " + detection + " due to " + ig.getMessage()); if(log.isTraceEnabled()) { log.trace(ig); } } } if(ok == false) { // the server is down! // would be nice to also remove from the invoker registry as well, but since // don't know all the possible entries for the config map passed when was created, // won't be able to identify it. This means that clients currently using that invoker // for the server will have to find out the hard way (by getting exception calling on it). try { if(networkRegistry != null) { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { networkRegistry.removeServer(detection.getIdentity()); return null; } }); log.debug("Removed detection " + detection); } } catch(Exception ex) { log.debug("Error removing server for detection (" + detection + "). Possible network registry does not exist."); } finally { // remove this server, it isn't available any more servers.remove(detection); } } else // at least one of the server invokers is still valid { if(log.isTraceEnabled()) { log.trace("Done checking all locators for suspected dead server. " + "There are " + validinvokers.size() + " out of original " + invokerMetadataArray.length + " still valid."); } // need to cause an update to be fired if any server invokers failed if(validinvokers.size() != invokerMetadataArray.length) { ServerInvokerMetadata[] newLocators = (ServerInvokerMetadata[])validinvokers.toArray(new ServerInvokerMetadata[validinvokers.size()]); Detection newDetection = new Detection(detection.getIdentity(), newLocators); if(log.isTraceEnabled()) { log.trace("Since at least one invoker failed while doing connection check, will be re-evaluating detection for:\n" + newDetection); } detect(newDetection); } } return ok; } private final class FailureDetector extends TimerTask { private int threadCounter = 0; public void run() { Thread.currentThread().setName("Remoting Detector - Failure Detector Thread: " + threadCounter++); synchronized (servers) { if (servers.isEmpty()) { return; } ClassLoader cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return AbstractDetector.class.getClassLoader(); } }); // walk through each detection and see if it needs checking up on ... Collection serverCollection = servers.values(); Server[] serverArray = (Server[])serverCollection.toArray(new Server[serverCollection.size()]); for(int x = 0; x < serverArray.length; x++) { Server svr = serverArray[x]; Detection detect = svr.detection; long lastDetection = svr.lastDetection; long duration = System.currentTimeMillis() - lastDetection; if (duration >= defaultTimeDelay) { if (log.isTraceEnabled()) { log.trace("detection for: " + detect + " has not been received in: " + defaultTimeDelay + " ms, contacting.."); } // OK, we've exceeded the time delay since the last time we've detected // this dude, he might be down, let's walk through each of his transports and // see if any of them lead to a valid invocation if (checkInvokerServer(detect, cl)) { if (log.isTraceEnabled()) { log.trace("detection for: " + detect + " recovered on ping"); } svr.lastDetection = System.currentTimeMillis(); } } } } } } private final class Server { Detection detection; private int hashCode = 0; long lastDetection = System.currentTimeMillis(); Server(Detection detection) { this.detection = detection; rehash(detection); } private void rehash(Detection d) { this.hashCode = hash(d); } private int hash(Detection d) { int hc = 0; InvokerLocator locators[] = d.getLocators(); if(locators != null) { for(int c = 0; c < locators.length; c++) { hc += locators[c].hashCode(); } } return hc; } boolean changed(Detection detection) { return hashCode != hash(detection); } public boolean equals(Object obj) { return obj instanceof Server && hashCode == obj.hashCode(); } public int hashCode() { return hashCode; } } private final class Heartbeat extends TimerTask { private int threadCounter = 0; public void run() { Thread.currentThread().setName("Remoting Detector - Heartbeat Thread: " + threadCounter++); heartbeat(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/InvocationResponse.java0000644000175000017500000000440610555353667031354 0ustar twernertwerner/* * 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.remoting; import java.io.Serializable; import java.util.Map; /** * InvocationResponse is a return object from a call to a remote Server Invoker. * The InvocationResponse may contain either an Exception or a result value (which may be null in * the case the user returns null) * * @author Tom Elrod * @version $Revision: 1972 $ */ public class InvocationResponse implements Serializable { static final long serialVersionUID = 1324503813652865685L; private final String sessionId; private final boolean isException; private final Object result; private Map payload; public InvocationResponse(String sessionId, Object result, boolean isException, Map payload) { this.sessionId = sessionId; this.isException = isException; this.result = result; this.payload = payload; } public String getSessionId() { return sessionId; } public Map getPayload() { return payload; } public boolean isException() { return isException; } public Object getResult() { return result; } public String toString() { return "InvocationResponse[" + Integer.toHexString(hashCode()) + ", " + (result == null ? "EMPTY" : result) + "]"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/Client.java0000644000175000017500000024175611422064371026736 0ustar twernertwerner/* * 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.remoting; import org.jboss.logging.Logger; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.CallbackPoller; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.invocation.InternalInvocation; import org.jboss.remoting.invocation.OnewayInvocation; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.stream.StreamServer; import org.jboss.remoting.transport.BidirectionalClientInvoker; 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; import org.jboss.remoting.util.SecurityUtility; import org.jboss.util.id.GUID; import org.jboss.util.threadpool.BasicThreadPool; import org.jboss.util.threadpool.BlockingMode; import org.jboss.util.threadpool.ThreadPool; import javax.net.SocketFactory; import java.io.Externalizable; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.StreamCorruptedException; import java.lang.ref.WeakReference; import java.net.InetAddress; import java.net.SocketTimeoutException; import java.net.UnknownHostException; import java.rmi.MarshalException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; 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 java.util.Timer; import java.util.TimerTask; /** * Client is a convience class for invoking remote methods for a given subsystem. It is intended to * be the main user interface for making remote invocation on the client side. * * @author Jeff Haynie * @author Tom Elrod * @author Ovidiu Feodorov * * @version $Revision: 5917 $ */ public class Client implements Externalizable { // Constants ------------------------------------------------------------------------------------ /** * Key to be used to determine if invocation is to be oneway (async). */ public static final String ONEWAY_FLAG = "oneway"; /** * Key to be used when tracking callback listeners. */ public static final String LISTENER_ID_KEY = "listenerId"; /** * Specifies the default number of work threads in the pool for executing one way invocations on * the client. Value is 10. */ public static final int MAX_NUM_ONEWAY_THREADS_DEFAULT = 10; /** * The key to use for the metadata Map passed when making a invoke() call and wish for the * invocation payload to be sent as is and not wrapped within a remoting invocation request * object. This should be used when want to make direct calls on systems outside of remoting * (e.g. making a http POST request to a web service). */ public static final String RAW = "rawPayload"; /** * Key for the configuration map passed to the Client constructor to indicate that client should * make initial request to establish lease with server. The value for this should be either a * String that java.lang.Boolean can evaluate or a java.lang.Boolean. Client leasing is turned * off by default, so would need to use this property to turn client leasing on. */ public static final String ENABLE_LEASE = "enableLease"; /** * Key for the configuration map passed to the Client constructor providing a ssl * javax.net.ssl.HandshakeCompletedListener implementation, which will be called on when ssl * handshake completed with server. */ public static final String HANDSHAKE_COMPLETED_LISTENER = "handshakeCompletedListener"; /** * Key for the configuration when adding a callback handler and internal callback server * connector is created. The value should be the transport protocol to be used. By default will * use the same protocol as being used by this client (e.g. http, socket, rmi, multiplex, etc.) */ public static final String CALLBACK_SERVER_PROTOCOL = "callbackServerProtocol"; /** * Key for the configuration when adding a callback handler and internal callback server * connector is created. The value should be the host name to be used. By default will use the * result of calling InetAddress.getLocalHost().getHostAddress(). */ public static final String CALLBACK_SERVER_HOST = "callbackServerHost"; /** * Key for the configuration when adding a callback handler and internal callback server * connector is created. The value should be the port to be used. By default will find a random * unused port. */ public static final String CALLBACK_SERVER_PORT = "callbackServerPort"; /** * Key for the configuration map that determines the threadpool size for asynchrouous invocations. */ public static final String MAX_NUM_ONEWAY_THREADS = "maxNumThreadsOneway"; /** * Key for the configuration map that determines the queue size for waiting asynchronous * invocations. */ public static final String MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE = "maxOnewayThreadPoolQueueSize"; /** * Default timeout period for network i/o in disconnect() and removeListener(). * -1 indicates that no special per invocation timeout will be set. */ public static final int DEFAULT_DISCONNECT_TIMEOUT = -1; /** * Key for setting delay before client invoker is destroyed by disconnect(). */ public static final String INVOKER_DESTRUCTION_DELAY = "invokerDestructionDelay"; public static final String THROW_CALLBACK_EXCEPTION = "throwCallbackException"; private static Map connectionValidators = new HashMap(); private static Object connectionValidatorLock = new Object(); static final String CLIENT = "client"; static final String CONNECTION_LISTENER = "connectionListener"; /** The key to use to specify that parameters for objects created by Client should be taken, * in addition to the metadata map, from the InvokerLocator and from the Client's configuration map. */ public static final String USE_ALL_PARAMS = "useAllParams"; private static final Logger log = Logger.getLogger(Client.class); private static boolean trace = log.isTraceEnabled(); private static final long serialVersionUID = 5679279425009837934L; private static Timer invokerDestructionTimer; private static Object invokerDestructionTimerLock = new Object(); private static int clientCounter; private static final InetAddress LOCAL_HOST; // Static --------------------------------------------------------------------------------------- static { try { LOCAL_HOST = (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } }); } catch (PrivilegedActionException e) { log.debug(Client.class.getName() + " unable to get local host address", e.getCause()); throw new ExceptionInInitializerError(e.getCause()); } catch (SecurityException e) { log.debug(Client.class.getName() + " unable to get local host address", e); throw e; } } static private InetAddress getLocalHost() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return doGetLocalHost(); } try { return (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { return doGetLocalHost(); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } static private InetAddress doGetLocalHost() throws UnknownHostException { if (LOCAL_HOST != null) { return LOCAL_HOST; } try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } // Attributes ----------------------------------------------------------------------------------- /** * Indicated the max number of threads used within oneway thread pool. */ private int maxNumberThreads = MAX_NUM_ONEWAY_THREADS_DEFAULT; private int maxOnewayThreadPoolQueueSize = -1; private ClientInvoker invoker; private ClassLoader classloader; private String subsystem; private String sessionId; private Object onewayThreadPoolLock = new Object(); private ThreadPool onewayThreadPool; private InvokerLocator locator; private ConnectionValidator connectionValidator = null; private ConnectionValidatorKey connectionValidatorKey; private Map configuration = new HashMap(); private Map callbackConnectors = new HashMap(); private Map callbackPollers = new HashMap(); private Map listeners = new HashMap(); private SocketFactory socketFactory; private int disconnectTimeout = DEFAULT_DISCONNECT_TIMEOUT; private boolean connected = false; private int invokerDestructionDelay = 0; private Set connectionListeners = new HashSet(); private boolean useClientConnectionIdentity; // Constructors --------------------------------------------------------------------------------- /** * PLEASE DO NOT USE THIS CONSTRUCTOR OR YOUR COMPUTER WILL BURST INTO FLAMES!!! * It is only here so can externalize object and will provide a dead object if invoker is not * explicitly set. Please use other contructors provided. */ public Client() { } /** * Constructs a remoting client with intended target server specified via the locator, without * specifing a remote subsystem or including any metadata. Same as calling Client(locator, null, * null). */ public Client(InvokerLocator locator) throws Exception { this(locator, null, null); } /** * Constructs a remoting client with intended target server specified via the locator and * configuration metadata. The metadata supplied will be used when creating client invoker (in * the case specific data is required) and also for passing along additional data to connection * listeners on the server side in the case that the client fails, will be able to use this extra * information when notified. */ public Client(InvokerLocator locator, Map configuration) throws Exception { this(locator, null, configuration); } /** * Constructs a remoting client with intended target server specified via the locator and * intended subsystem on server for invocations to be routed to. */ public Client(InvokerLocator locator, String subsystem) throws Exception { this(locator, subsystem, null); } /** * Constructs a remoting client with intended target server specified via the locator, intended * subsystem on the server for invocations to be routed to, and configuration metadata. The * metadata supplied will be used when creating client invoker (in the case specific data is * required) and also for passing along additional data to connection listeners on the server * side in the case that the client fails, will be able to use this extra information when * notified. */ public Client(InvokerLocator locator, String subsystem, Map configuration) throws Exception { this(null, locator, subsystem, configuration); } /** * Constructs a remoting client with intended target server specified via the locator, intended * subsystem on the server for invocations to be routed to, and configuration metadata. The * metadata supplied will be used when creating client invoker (in the case specific data is * required) and also for passing along additional data to connection listeners on the server * side in the case that the client fails, will be able to use this extra information when * notified (which will happen when connect() method is called. * * @param cl - the classloader that should be used by remoting. * @deprecated This constructor should not be used any more as will no longer take into account * the classloader specified as a parameter. */ public Client(ClassLoader cl, InvokerLocator locator, String subsystem, Map configuration) throws Exception { if (cl == null) { this.classloader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); } else { this.classloader = cl; } this.locator = locator; this.subsystem = subsystem == null ? null : subsystem.toUpperCase(); if (configuration != null) { this.configuration = new HashMap(configuration); } this.sessionId = new GUID().toString(); processParameters(); } /** * Constructs a remoting client with intended target server specified via the locator and * intended subsystem on server for invocations to be routed to. * * @deprecated This constructor should not be used any more as will no longer take into account * the classloader specified as a parameter. */ public Client(ClassLoader cl, ClientInvoker invoker, String subsystem) throws Exception { this.classloader = cl; this.subsystem = subsystem == null ? null : subsystem.toUpperCase(); this.invoker = invoker; this.sessionId = new GUID().toString(); } // Externalizable implementation ---------------------------------------------------------------- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int version = in.readInt(); switch (version) { case Version.VERSION_2: case Version.VERSION_2_2: { this.locator = (InvokerLocator) in.readObject(); this.subsystem = (String) in.readObject(); this.configuration = (Map) in.readObject(); boolean wasConnected = in.readBoolean(); this.classloader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); try { try { this.invoker = (ClientInvoker) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return InvokerRegistry.createClientInvoker(locator, configuration); } }); } catch (PrivilegedActionException pae) { throw pae.getException(); } if(wasConnected) { connect(); } } catch (Exception e) { log.debug(e); throw new IOException(e.getMessage()); } break; } default: throw new StreamCorruptedException("Unkown version seen: " + version); } } public void writeExternal(ObjectOutput out) throws IOException { out.writeInt(Version.getDefaultVersion()); out.writeObject(invoker != null ? invoker.getLocator() : locator); out.writeObject(subsystem); out.writeObject(configuration); out.writeBoolean(isConnected()); out.flush(); } // Public --------------------------------------------------------------------------------------- /** * Adds a connection listener that will be notified if/when the connection to the server fails * while the client is idle (no calls being made). The default behavior is to ping for connection * every two seconds. */ public void addConnectionListener(ConnectionListener listener) { HashMap metadata = new HashMap(); if (configuration.get(ConnectionValidator.VALIDATOR_PING_PERIOD) == null && locator.getParameters().get(ConnectionValidator.VALIDATOR_PING_PERIOD) == null) { String pingPeriod = Long.toString(ConnectionValidator.DEFAULT_PING_PERIOD); metadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, pingPeriod); } addConnectionListener(listener, metadata); } /** * Adds a connection listener that will be notified if/when the connection to the server fails * while the client is idle (no calls being made). The current behavior is to ping the server * periodically. The time period is defined by the pingPeriod (which should be in milliseconds). */ public void addConnectionListener(ConnectionListener listener, int pingPeriod) { HashMap metadata = new HashMap(); metadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, Integer.toString(pingPeriod)); addConnectionListener(listener, metadata); } /** * Adds a connection listener that will be notified if/when the connection to the server fails * while the client is idle (no calls being made). The current behavior is to ping the server * periodically. Various parameters may be specified in metadata. * * @see org.jboss.remoting.ConnectionValidator */ public void addConnectionListener(ConnectionListener listener, Map metadata) { if (invoker == null) { throw new RuntimeException("Can not add connection listener to remoting client " + "while client is not connected."); } else { // if local, then no point in having connection listener if (invoker instanceof LocalClientInvoker) { return; } } synchronized (connectionValidatorLock) { if (trace) log.trace(this + " in addConnectionListener()"); if (connectionValidator == null) { Map map = new HashMap(configuration); map.putAll(metadata); connectionValidatorKey = new ConnectionValidatorKey(invoker, map); WeakReference ref = (WeakReference) connectionValidators.get(connectionValidatorKey); if (ref == null) { connectionValidator = new ConnectionValidator(this, metadata); connectionValidators.put(connectionValidatorKey, new WeakReference(connectionValidator)); connectionValidator.addConnectionListener(this, listener); if (trace) log.trace(this + ": created " + connectionValidator); } else { connectionValidator = (ConnectionValidator) ref.get(); if (connectionValidator.addConnectionListener(this, listener)) { if (trace) log.trace(this + ": reusing from static table: " + connectionValidator); } else { if (trace) log.trace(this + ": unable to reuse existing ConnectionValidator in static map: " + connectionValidator); connectionValidator = new ConnectionValidator(this, metadata); connectionValidators.put(connectionValidatorKey, new WeakReference(connectionValidator)); connectionValidator.addConnectionListener(this, listener); if (trace) log.trace(this + ": current ConnectionValidator is stopped: created " + connectionValidator); } } } else { if (connectionValidator.addConnectionListener(this, listener)) { if (trace) log.trace(this + ": reusing from local reference: " + connectionValidator); } else { if (trace) log.trace(this + ": unable to reuse ConnectionValidator from local reference: " + connectionValidator); connectionValidator = new ConnectionValidator(this, metadata); connectionValidators.put(connectionValidatorKey, new WeakReference(connectionValidator)); connectionValidator.addConnectionListener(this, listener); if (trace) log.trace(this + ": current ConnectionValidator is stopped: created " + connectionValidator); } } connectionListeners.add(listener); } } /** * Removes specified connection listener. Will return true if it has already been registered, * false otherwise. */ public boolean removeConnectionListener(ConnectionListener listener) { if (trace) log.trace(this + ".removeConnectionListener(" + listener + ")"); boolean isRemoved = false; synchronized (connectionValidatorLock) { if (connectionValidator == null) { return false; } isRemoved = connectionValidator.removeConnectionListener(this, listener); if (connectionValidator.isStopped()) { if (connectionValidators.remove(connectionValidatorKey) != null) { log.debug(this + ".removeConnectionListener() removed from static map: " + connectionValidator); } connectionValidator = null; connectionValidatorKey = null; } connectionListeners.remove(listener); if (connectionListeners.isEmpty()) { connectionValidator = null; connectionValidatorKey = null; } if (connectionValidator == null) { if (trace) log.trace(this + " set connectionValidator to null"); } } return isRemoved; } /** * This will set the session id used when making invocations on server invokers. There is a * default unique id automatically generated for each Client instance, so unless you have a good * reason to set this, do not set this. */ public void setSessionId(String sessionId) { this.sessionId = sessionId; } /** * Gets the configuration map passed when constructing this object. */ public Map getConfiguration() { return configuration; } /** * Gets the session id used when making invocations on server invokers. This is the id that will * be used for tracking client connections on the server side, to include client failures that * are sent to connection listeners on the server side. */ public String getSessionId() { return this.sessionId; } /** * Indicates if the underlying transport has been connected to the target server. */ public boolean isConnected() { return connected; } /** * Will cause the underlying transport to make connection to the target server. This is * important for any stateful transports, like socket or multiplex. This is also when a client * lease with the server is started. */ public void connect() throws Exception { connect(null, null); } /** * Will cause the underlying transport to make connection to the target server. This is * important for any stateful transports, like socket or multiplex. This is also when a client * lease with the server is started. If listener is not null, it will be registered to * receive a callback if the connection fails. */ public void connect(ConnectionListener listener) throws Exception { connect(listener, null); } /** * Will cause the underlying transport to make connection to the target server. This is * important for any stateful transports, like socket or multiplex. This is also when a client * lease with the server is started. If listener is not null, it will be registered to * receive a callback if the connection fails. *

          * * If this version of connect() is used, and leasing is enabled, the concept of "connection * identity" is enforced. That is, the ConnectionValidator used by this Client will be * tied to the LeasePinger currently used by the MicroRemoteClientInvoker created or reused * in this method, and that LeasePinger will be tied to this Client and its ConnectionValidator. * If the ConnectionValidator used by any of the Clients associated with the MicroRemoteClientInvoker * used by this Client detects a broken connection, it will shut down that LeasePinger. * Moreover, each ConnectionValidator associated with that LeasePinger will notify its * ConnectionListeners of the broken connection. At that point, the LeasePinger will be * destroyed, and all of the associated Clients will be disconnected. */ public void connect(ConnectionListener listener, Map metadata) throws Exception { log.debug(this + ".connect(" + listener + ")"); if (trace) log.trace(this + ": metadata = " + metadata); if (isConnected()) return; if (locator == null) { throw new IllegalStateException("Cannot connect a client with a null locator"); } if (invoker == null) { if (socketFactory != null) { configuration.put(Remoting.CUSTOM_SOCKET_FACTORY, socketFactory); this.socketFactory = null; } try { invoker = (ClientInvoker) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return InvokerRegistry.createClientInvoker(locator, configuration); } }); } catch (PrivilegedActionException pae) { throw pae.getException(); } } connect(invoker, listener, metadata); connected = true; log.debug(this + " is connected"); } /** * Disconnects the underlying transport from the target server. Also notifies the target server * to terminate client lease. Is important that this method is called when no longer using the * remoting client. Otherwise resource will not be cleaned up and if the target server requires * a lease, it will be maintained in the background. */ public void disconnect() { if (trace) log.trace(this + " entering disconnect()"); connected = false; if (invoker != null) { // this is a noop if no lease is active invoker.terminateLease(sessionId, disconnectTimeout); // Need to remove myself from registry so will not keep reference to me since I am of no // use now. Will have to create a new one. if (invokerDestructionDelay > 0) { synchronized (invokerDestructionTimerLock) { InvokerDestructionTimerTask task = new InvokerDestructionTimerTask(invoker, configuration); if (invokerDestructionTimer == null) { invokerDestructionTimer = new Timer(true); } try { invokerDestructionTimer.schedule(task, invokerDestructionDelay); } catch (IllegalStateException e) { log.debug("Unable to schedule InvokerDestructionTimerTask on existing Timer", e); invokerDestructionTimer = new Timer(true); invokerDestructionTimer.schedule(task, invokerDestructionDelay); } if (trace) log.trace(this + " scheduled destruction of " + invoker); } } else { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.destroyClientInvoker(invoker.getLocator(), configuration); return null; } }); } invoker = null; } synchronized (connectionValidatorLock) { if (connectionValidator != null) { Iterator it = connectionListeners.iterator(); while (it.hasNext()) { ConnectionListener listener = (ConnectionListener) it.next(); connectionValidator.removeConnectionListener(this, listener); } if (connectionValidator.isStopped()) { if (connectionValidators.remove(connectionValidatorKey) != null) { if (trace) log.trace(this + ".disconnect() removed from static map: " + connectionValidator); } } connectionValidator = null; connectionValidatorKey = null; } } log.debug(this + " is disconnected"); } /** * Get the client invoker (transport implementation). */ public ClientInvoker getInvoker() { return invoker; } /** * Set the client invoker (transport implementation). */ public void setInvoker(ClientInvoker invoker) { this.invoker = invoker; } /** * Gets the subsystem being used when routing invocation request on the server side. */ public String getSubsystem() { return subsystem; } /** * Sets the subsystem being used when routing invocation requests on the server side. Specifing * a subsystem is only needed when server has multiple handlers registered (which will each have * their own associated subsystem). */ public void setSubsystem(String subsystem) { this.subsystem = subsystem; } /** * Invokes the server invoker handler with the payload parameter passed. Same as calling * invoke(param, null); */ public Object invoke(Object param) throws Throwable { return invoke(param, null); } /** * Invoke the method remotely. * * @param param - payload for the server invoker handler. * @param metadata - any extra metadata that may be needed by the transport (i.e. GET or POST if * using http invoker) or if need to pass along extra data to the server invoker handler. */ public Object invoke(Object param, Map metadata) throws Throwable { return invoke(param, metadata, null); } /** * Will invoke a oneway call to server without a return object. This should be used when not * expecting a return value from the server and wish to achieve higher performance, since the * client will not wait for a return. * * This is done one of two ways. The first is to pass true as the clientSide param. This will * cause the execution of the remote call to be executed in a new thread on the client side and * will return the calling thread before making call to server side. *

          * The second, is to pass false as the clientSide param. This will allow the current calling * thread to make the call to the remote server, at which point, the server side processing of * the thread will be executed on the remote server in a new executing thread. *

          * NOTE: The treatment of server side oneway invocations may vary with the transport. The * client side transport is not required to wait for a reply from the server. In particular, * the socket and bisocket transports return immediately after writing the invocation. */ public void invokeOneway(final Object param, final Map sendPayload, boolean clientSide) throws Throwable { final Map internalSendPayload = sendPayload == null ? new HashMap() : sendPayload; internalSendPayload.put(ONEWAY_FLAG, "true"); if (clientSide) { ThreadPool threadPool = getOnewayThreadPool(); Runnable onewayRun = new Runnable() { public void run() { try { invoke(param, internalSendPayload); } catch (Throwable e) { // throw away exception since can't get it back to original caller log.error("Error executing client oneway invocation request: " + param, e); } } }; threadPool.run(onewayRun); } else { OnewayInvocation invocation = new OnewayInvocation(param); invoke(invocation, internalSendPayload); } } /** * Returns the callback Connectors with which callbackHandler is registered. */ public Set getCallbackConnectors(InvokerCallbackHandler callbackHandler) { return (Set) callbackConnectors.get(callbackHandler); } /** * Gets the timeout used for network i/o in disconnect() and removeListener(). */ public int getDisconnectTimeout() { return disconnectTimeout; } /** * Sets the timeout used for network i/o in disconnect() and removeListener(). */ public void setDisconnectTimeout(int disconnectTimeout) { this.disconnectTimeout = disconnectTimeout; } /** * Sets the maximum queue size to use within client pool for one way invocations on the client * side (meaning oneway invocation is handled by thread in this pool and user's call returns * immediately). Default value is MAX_NUM_ONEWAY_THREADS. */ public void setMaxOnewayThreadPoolQueueSize(int maxOnewayThreadPoolQueueSize) { this.maxOnewayThreadPoolQueueSize = maxOnewayThreadPoolQueueSize; } /** * Gets the maximum queue size to use within client pool for one way invocations on the client * side (meaning oneway invocation is handled by thread in this pool and user's call returns * immediately). Default value is MAX_NUM_ONEWAY_THREADS. */ public int getMaxOnewayThreadPoolQueueSize() { return this.maxOnewayThreadPoolQueueSize; } /** * Sets the maximum number of threads to use within client pool for one way invocations on the * client side (meaning oneway invocation is handled by thread in this pool and user's call * returns immediately). Default value is MAX_NUM_ONEWAY_THREADS. */ public void setMaxNumberOfThreads(int numOfThreads) { this.maxNumberThreads = numOfThreads; } /** * Gets the maximum number of threads to use within client pool for one way invocations on the * client side (meaning oneway invocation is handled by thread in this pool and user's call * returns immediately). Default value is MAX_NUM_ONEWAY_THREADS. */ public int getMaxNumberOfThreads() { return this.maxNumberThreads; } /** * Gets the thread pool being used for making one way invocations on the client side. If one has * not be specifically set via configuration or call to set it, will always return instance of * org.jboss.util.threadpool.BasicThreadPool. */ public ThreadPool getOnewayThreadPool() { synchronized (onewayThreadPoolLock) { if (onewayThreadPool == null) { BasicThreadPool pool = new BasicThreadPool("JBossRemoting Client Oneway"); log.debug("created new thread pool: " + pool); Object param = configuration.get(MAX_NUM_ONEWAY_THREADS); if (param instanceof String) { try { maxNumberThreads = Integer.parseInt((String) param); } catch (NumberFormatException e) { log.error("maxNumberThreads parameter has invalid format: " + param); } } else if (param != null) { log.error("maxNumberThreads parameter must be a string in integer format: " + param); } param = configuration.get(MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE); if (param instanceof String) { try { maxOnewayThreadPoolQueueSize = Integer.parseInt((String) param); } catch (NumberFormatException e) { log.error("maxOnewayThreadPoolQueueSize parameter has invalid format: " + param); } } else if (param != null) { log.error("maxOnewayThreadPoolQueueSize parameter must be a string in integer format: " + param); } pool.setMaximumPoolSize(maxNumberThreads); if (maxOnewayThreadPoolQueueSize > 0) { pool.setMaximumQueueSize(maxOnewayThreadPoolQueueSize); } pool.setBlockingMode(BlockingMode.RUN); onewayThreadPool = pool; } } return onewayThreadPool; } /** * Sets the thread pool to be used for making one way invocations on the client side. */ public void setOnewayThreadPool(ThreadPool pool) { this.onewayThreadPool = pool; } /** * The socket factory can only be set on the Client before the connect() method has been called. * Otherwise, a runtime exception will be thrown. */ public void setSocketFactory(SocketFactory socketFactory) { if(isConnected()) { throw new RuntimeException("Cannot set socket factory on Client after " + "the connect() method has been called."); } if (invoker != null) { invoker.setSocketFactory(socketFactory); } else { this.socketFactory = socketFactory; } } public SocketFactory getSocketFactory() { if (invoker != null) { return invoker.getSocketFactory(); } else { return socketFactory; } } /** * Same as calling invokeOneway(Object param, Map sendPayload, boolean clientSide) with * clientSide param being false and a null sendPayload. */ public void invokeOneway(Object param) throws Throwable { invokeOneway(param, null); } /** * Same as calling invokeOneway(Object param, Map sendPayload, boolean clientSide) with * clientSide param being false. */ public void invokeOneway(Object param, Map sendPayload) throws Throwable { invokeOneway(param, sendPayload, false); } /** * Adds the specified handler as a callback listener for push (async) callbacks. If the transport * is uni-directional (e.g. http), remoting will automatically poll for callbacks from the server * and deliver them to the callback handler. If the transport is bi-directional (e.g. multiplex), * remoting will automatically create a callback server internally and receive and deliver to * callback handler the callbacks as they are generated on the server. The metadata map passed * will control configuration for how the callbacks are processed, such as the polling frequency. */ public void addListener(InvokerCallbackHandler callbackhandler, Map metadata) throws Throwable { addListener(callbackhandler, metadata, null); } /** * Adds the specified handler as a callback listener for push (async) callbacks. If the transport * is uni-directional (e.g. http), remoting will automatically poll for callbacks from the server * and deliver them to the callback handler. If the transport is bi-directional (e.g. multiplex), * remoting will automatically create a callback server internally and receive and deliver to * callback handler the callbacks as they are generated on the server. The metadata map passed * will control configuration for how the callbacks are processed, such as the polling frequency. * * @param callbackHandlerObject - this object will be included in the Callback object instance * passed to the InvokerCallbackHandler specified. */ public void addListener(InvokerCallbackHandler callbackhandler, Map metadata, Object callbackHandlerObject) throws Throwable { addListener(callbackhandler, metadata, callbackHandlerObject, false); } /** * Adds the specific handler as a callback listener for async callbacks. If the transport * supports bi-directional calls (meaning server can call back to client over same connection * that was established by the client) or if the serverToClient flag is set to true, a callback * server will be created internally and the target server will actually send callbacks to the * client's internal server. Otherwise, the client will simulate push callbacks by internally * polling for callbacks on the server and then deliver them to the callback handler. * * @param serverToClient - if true, will allow server to connect to the client directly (which * must be allowed by firewall in front of client unless transport is bi-directional, such * as the multiplex transport). If false (and not bi-directional transport), server will * not create any new connection to the client. */ public void addListener(InvokerCallbackHandler callbackhandler, Map metadata, Object callbackHandlerObject, boolean serverToClient) throws Throwable { InvokerLocator callbackLocator = null; if (isConnected()) { if (callbackhandler != null) { boolean isBidirectional = invoker instanceof BidirectionalClientInvoker; if (isBidirectional || serverToClient) { // setup callback server String transport = null; String host = null; int port = -1; // look for config values if (metadata != null) { transport = (String) metadata.get(CALLBACK_SERVER_PROTOCOL); host = (String) metadata.get(CALLBACK_SERVER_HOST); String sPort = (String) metadata.get(CALLBACK_SERVER_PORT); if (sPort != null) { try { port = Integer.parseInt(sPort); } catch (NumberFormatException e) { log.warn("Could not set the internal callback server port as " + "configuration value (" + sPort + ") is not a number."); } } } else { metadata = new HashMap(); } if (transport == null) { transport = invoker.getLocator().getProtocol(); metadata.put(CALLBACK_SERVER_PROTOCOL, transport); } if (host == null) { host = getLocalHost().getHostAddress(); metadata.put(CALLBACK_SERVER_HOST, host); } if (port == -1) { port = PortUtil.findFreePort(host); metadata.put(CALLBACK_SERVER_PORT, String.valueOf(port)); } if(isBidirectional) { callbackLocator = ((BidirectionalClientInvoker)invoker).getCallbackLocator(metadata); } else { callbackLocator = new InvokerLocator(transport, host, port, null, metadata); } log.debug("starting callback Connector: " + callbackLocator); Map callbackConfig = new HashMap(configuration); if (locator.getParameters() != null) { callbackConfig.putAll(locator.getParameters()); } configureCallbackServerSocketFactory(callbackConfig); Connector callbackServerConnector = new Connector(callbackLocator, callbackConfig); synchronized (callbackConnectors) { Set connectors = (Set) callbackConnectors.get(callbackhandler); if (connectors == null) { connectors = new HashSet(); } connectors.add(callbackServerConnector); callbackConnectors.put(callbackhandler, connectors); } callbackServerConnector.start(); // have to use the locator from the server as can be modified internally callbackLocator = callbackServerConnector.getServerInvoker().getLocator(); addCallbackListener(callbackhandler, metadata, callbackLocator, callbackHandlerObject); } else { if (callbackPollers.get(callbackhandler) != null) { log.debug(callbackhandler + " already registered"); return; } //need to setup poller to get callbacks from the server CallbackPoller poller = new CallbackPoller(this, callbackhandler, metadata, callbackHandlerObject); callbackPollers.put(callbackhandler, poller); addCallbackListener(callbackhandler, metadata, callbackLocator, callbackHandlerObject); poller.start(); } } else { throw new NullPointerException("InvokerCallbackHandler to be added as " + "a listener can not be null."); } } else { throw new Exception("Can not add callback listener because " + "remoting client is not connected to server."); } } /** * Adds the specified handler as a callback listener for pull (sync) callbacks. Using this method * will require the programatic getting of callbacks from the server (they will not be pushed to * the callback handler automatically). */ public void addListener(InvokerCallbackHandler callbackHandler) throws Throwable { addListener(callbackHandler, (InvokerLocator) null); } /** * Adds the specified handler as a callback listener for push (async) callbacks. The invoker * server will then callback on this handler (via the server invoker specified by the * clientLocator) when it gets a callback from the server handler. * * Note: passing a null clientLocator will cause the client invoker's client locator to be set to * null, which basically converts the mode to be pull (sync) where will require call to get * callbacks (as will not automatically be pushed to callback handler). */ public void addListener(InvokerCallbackHandler callbackHandler, InvokerLocator clientLocator) throws Throwable { addListener(callbackHandler, clientLocator, null); } /** * Adds the specified handler as a callback listener for push (async) callbacks. The invoker * server will then callback on this handler (via the server invoker specified by the * clientLocator) when it gets a callback from the server handler. * * Note: passing a null clientLocator will cause the client invoker's client locator to be set to * null, which basically converts the mode to be pull (sync) where will require call to get * callbacks (as will not automatically be pushed to callback handler). * * @param callbackHandlerObject will be included in the callback object passed upon callback. */ public void addListener(InvokerCallbackHandler callbackHandler, InvokerLocator clientLocator, Object callbackHandlerObject) throws Throwable { if (callbackHandler != null) { if (isConnected()) { addCallbackListener(callbackHandler, null, clientLocator, callbackHandlerObject); } else { throw new Exception("Can not add callback listener as " + "remoting client is not connected to server."); } } else { throw new NullPointerException("InvokerCallbackHandler to be added as " + "a listener can not be null."); } } /** * Removes callback handler as a callback listener from the server (and client in the case that * it was setup to receive async callbacks). See addListener(). */ public void removeListener(InvokerCallbackHandler callbackHandler) throws Throwable { if (isConnected()) { if (callbackHandler != null) { // first need to see if is push or pull callback (i.e. does have locator associated // with it) String listenerId = (String)listeners.get(callbackHandler); if(listenerId != null) { // have a pull callback handler // If disconnectTimeout == 0, skip network i/o. if (disconnectTimeout != 0) { Map metadata = new HashMap(); metadata.put(LISTENER_ID_KEY, listenerId); if (disconnectTimeout > 0) metadata.put(ServerInvoker.TIMEOUT, Integer.toString(disconnectTimeout)); try { invoke(new InternalInvocation(InternalInvocation.REMOVELISTENER, null), metadata); } catch (Exception e) { log.debug("unable to remove remote callback handler", e); } } // clean up callback poller if one exists CallbackPoller callbackPoller = (CallbackPoller) callbackPollers.remove(callbackHandler); if (callbackPoller != null) { callbackPoller.stop(); } listeners.remove(callbackHandler); } else { // have a push callback handler List holderList = invoker.getClientLocators(sessionId, callbackHandler); if(holderList != null && holderList.size() > 0) { for(int x = 0; x < holderList.size(); x++) { AbstractInvoker.CallbackLocatorHolder holder = (AbstractInvoker.CallbackLocatorHolder)holderList.get(x); listenerId = holder.getListenerId(); InvokerLocator locator = holder.getLocator(); Map metadata = new HashMap(); metadata.put(LISTENER_ID_KEY, listenerId); // If disconnectTimeout == 0, skip network i/o. if (disconnectTimeout != 0) { if (disconnectTimeout > 0) metadata.put(ServerInvoker.TIMEOUT, Integer.toString(disconnectTimeout)); try { // now call target server to remove listener InternalInvocation ii = new InternalInvocation(InternalInvocation.REMOVELISTENER, null); invoke(ii, metadata); } catch (Exception e) { log.debug("unable to remove remote callback handler", e); } } // call to callback server to remove listener Client client = new Client(locator, subsystem); client.setSessionId(getSessionId()); client.connect(); InternalInvocation ii = new InternalInvocation(InternalInvocation.REMOVECLIENTLISTENER, new Object[]{callbackHandler}); client.invoke(ii, metadata); client.disconnect(); } } } // clean up callback server connectors if any exist Set connectors = null; synchronized (callbackConnectors) { connectors = (Set) callbackConnectors.remove(callbackHandler); } if (connectors != null) { Iterator it = connectors.iterator(); while (it.hasNext()) { Connector callbackConnector = (Connector) it.next(); callbackConnector.stop(); callbackConnector.destroy(); } } } else { throw new NullPointerException("Can not remove null InvokerCallbackHandler listener."); } } else { throw new Exception("Can not remove callback listener as " + "remoting client is not connected to server."); } } /** * Gets the callbacks for specified callback handler. The handler is required because an id is * generated for each handler. So if have two callback handlers registered with the same server, * no other way to know for which handler to get the callbacks for. */ public List getCallbacks(InvokerCallbackHandler callbackHandler) throws Throwable { return getCallbacks(callbackHandler, null); } /** * Gets the callbacks for specified callback handler. The handler is required because an id is * generated for each handler. So if have two callback handlers registered with the same server, * no other way to know for which handler to get the callbacks for. * * The metadata map can be used to set callback blocking mode and blocking timeout * value. */ public List getCallbacks(InvokerCallbackHandler callbackHandler, Map metadata) throws Throwable { if (callbackHandler != null) { String listenerId = (String)listeners.get(callbackHandler); if(listenerId != null) { if (metadata == null) metadata = new HashMap(); metadata.put(LISTENER_ID_KEY, listenerId); InternalInvocation invocation = new InternalInvocation(InternalInvocation.GETCALLBACKS, null); try { List response = (List) invoke(invocation, metadata); return response; } catch (MarshalException e) { if (e.getCause() != null && e.getCause() instanceof SocketTimeoutException) { if (trace) log.trace(this + ": getCallbacks() timed out: returning empty list"); return new ArrayList(); } throw e; } finally { metadata.remove(LISTENER_ID_KEY); } } else { String errorMessage = "Could not find listener id for InvokerCallbackHandler (" + callbackHandler + "), please verify handler has been registered as listener."; String errorMode = (String) metadata.get(THROW_CALLBACK_EXCEPTION); boolean throwError = Boolean.valueOf(errorMode).booleanValue(); if (throwError) { throw new IOException(errorMessage); } else { log.error(errorMessage); return null; } } } else { throw new NullPointerException("Can not remove null InvokerCallbackHandler listener."); } } public int acknowledgeCallback(InvokerCallbackHandler callbackHandler, Callback callback) throws Throwable { return acknowledgeCallback(callbackHandler, callback, null); } public int acknowledgeCallback(InvokerCallbackHandler callbackHandler, Callback callback, Object response) throws Throwable { ArrayList callbacks = new ArrayList(1); callbacks.add(callback); ArrayList responses = null; if (response != null) { responses = new ArrayList(1); responses.add(response); } return acknowledgeCallbacks(callbackHandler, callbacks, responses); } public int acknowledgeCallbacks(InvokerCallbackHandler callbackHandler, List callbacks) throws Throwable { return acknowledgeCallbacks(callbackHandler, callbacks, null); } public int acknowledgeCallbacks(InvokerCallbackHandler callbackHandler, List callbacks, List responses) throws Throwable { if (callbackHandler == null) { throw new Exception("InvokerCallbackHandler parameter must not be null"); } if (callbacks == null) { throw new Exception("Callback List parameter must not be null"); } if (responses != null && responses.size() != callbacks.size()) { throw new Exception("Callback response list must be (1) null " + "or (2) the same size as callback list"); } if (callbacks.size() == 0) { return 0; } if (isConnected()) { ArrayList callbackIds = new ArrayList(callbacks.size()); Iterator idsIterator = callbacks.iterator(); ArrayList responseList = null; Iterator responseIterator = null; if (responses != null) { responseList = new ArrayList(responses.size()); responseIterator = responses.iterator(); } Callback callback = null; Object response = null; String listenerId = null; for (int i = 0; i < callbacks.size(); i++) { callback = (Callback) idsIterator.next(); if (responseIterator != null) { response = responseIterator.next(); } Map returnPayload = callback.getReturnPayload(); if (returnPayload != null) { Object callbackId = returnPayload.get(ServerInvokerCallbackHandler.CALLBACK_ID); if (callbackId != null) { callbackIds.add(callbackId); if (responseIterator != null) { responseList.add(response); } String nextListenerId = (String) returnPayload.get(LISTENER_ID_KEY); if (nextListenerId == null) { throw new Exception("Cannot acknowledge callbacks: " + "callback " + callbackId + " has null listener id"); } if (i == 0) { listenerId = nextListenerId; } else { if (!listenerId.equals(nextListenerId)) throw new Exception("Cannot acknowledge callbacks: " + "all must be from same server side callback handler"); } } else { log.error("Cannot acknowledge callback: callback id " + "is missing from return payload"); } } else { log.error("Cannot acknowledge callback: return payload is null"); } } if (callbackIds.size() == 0) { return 0; } Map metadata = new HashMap(); if(listenerId != null) { metadata.put(LISTENER_ID_KEY, listenerId); } else { throw new Exception("Could not find listener id for InvokerCallbackHandler (" + callbackHandler + "), please verify handler " + "has been registered as listener."); } Object[] params = new Object[] {callbackIds, responseList}; InternalInvocation invocation = new InternalInvocation(InternalInvocation.ACKNOWLEDGECALLBACK, params); invoke(invocation, metadata); return callbackIds.size(); } else { throw new Exception("Can not acknowledge Callback due to not being connected to server."); } } /** * Sets the marshaller implementation that should be used by the client invoker (transport). This * overrides the client's default marshaller (or any set within configuration). */ public void setMarshaller(Marshaller marshaller) { if (isConnected()) { if (marshaller != null) { invoker.setMarshaller(marshaller); } else { throw new NullPointerException("Can not set Marshaller with a null value."); } } else { throw new RuntimeException("Can not set remoting client Marshaller when not connected."); } } /** * Sets the unmarshaller implementation that should be used by the client invoker (transport). * This overrides the client's default unmarshaller (or any set within configuration). */ public void setUnMarshaller(UnMarshaller unmarshaller) { if (isConnected()) { if (unmarshaller != null) { invoker.setUnMarshaller(unmarshaller); } else { throw new NullPointerException("Can not set UnMarshaller to null value."); } } else { throw new RuntimeException("Can not set remoting client UnMarhshaller when not connected."); } } /** * Takes an inputstream and wraps a server around. Then calls the target remoting server and * passes a proxy for an inputstream to the server's handler. When the server handler calls on * this proxy, it will call back on this server wrapped around this inputstream. * * @param param - invocation payload. * * @return the return value from the invocation. * @throws Throwable */ public Object invoke(InputStream inputStream, Object param) throws Throwable { StreamServer streamServer = new StreamServer(inputStream); String locator = streamServer.getInvokerLocator(); // now call on target server and pass locator for stream callbacks InvocationRequest invocationRequest = new InvocationRequest(sessionId, subsystem, param, null, null, null); return invoke(new InternalInvocation(InternalInvocation.ADDSTREAMCALLBACK, new Object[]{locator, invocationRequest}), null); } /** * Takes an inputstream and wraps a server around. Then calls the target remoting server and * passes a proxy for an inputstream to the server's handler. When the server handler calls on * this proxy, it will call back on this server wrapped around this inputstream. The Connector * passed is expected to have already been started and will have the stream handler added with * subsystem of 'stream'. Also note that the Connector passed will not be stopped when/if the * server calls to close the input stream. * * @param param - invocation payload. * * @return the return value from the invocation */ public Object invoke(InputStream inputStream, Object param, Connector streamConnector) throws Throwable { StreamServer streamServer = new StreamServer(inputStream, streamConnector); String locator = streamServer.getInvokerLocator(); // now call on target server and pass locator for stream callbacks InvocationRequest invocationRequest = new InvocationRequest(sessionId, subsystem, param, null, null, null); return invoke(new InternalInvocation(InternalInvocation.ADDSTREAMCALLBACK, new Object[]{locator, invocationRequest}), null); } /** * Takes an inputstream and wraps a server around. Then calls the target remoting server and * passes proxy for an inputstream to the server's handler. When the server handle calls on this * proxy, it will call back on this server wrapped around this inputstream. The InvokerLocator * passed is used to create the internal Connector used to receive the calls from the server * side. */ public Object invoke(InputStream inputStream, Object param, InvokerLocator streamServerLocator) throws Throwable { StreamServer streamServer = new StreamServer(inputStream, streamServerLocator); String locator = streamServer.getInvokerLocator(); // now call on target server and pass locator for stream callbacks InvocationRequest invocationRequest = new InvocationRequest(sessionId, subsystem, param, null, null, null); return invoke(new InternalInvocation(InternalInvocation.ADDSTREAMCALLBACK, new Object[]{locator, invocationRequest}), null); } /** * @return the ping period (in ms) this client's connection validator is configured with. If the * client doesn't ping (on account of connection validator not being installed, or * stopped), returns -1. */ public long getPingPeriod() { if (connectionValidator == null) { return -1; } return connectionValidator.getPingPeriod(); } /** * @return the lease period (in ms) if the client has an active leasing mechanism with the server * or -1 otherwise. */ public long getLeasePeriod() { if (invoker == null) { return -1; } return invoker.getLeasePeriod(sessionId); } /** * Returns an InetAddress for the client machine as seen by the server machine. * @return an InetAddress for the client machine as seen by the server machine. * @throws Throwable */ public InetAddress getAddressSeenByServer() throws Throwable { return (InetAddress) invoke("$GET_CLIENT_LOCAL_ADDRESS$"); } public String toString() { return "Client[" + System.identityHashCode(this) + ":" + sessionId + "]"; } // Package protected ---------------------------------------------------------------------------- void notifyListeners() { synchronized (connectionValidatorLock) { log.debug(this + " entering notifyListeners(): " + connectionValidator); if (connectionValidator != null) { synchronized (connectionValidator) { if (connectionValidator.isStopped()) { if (trace) log.trace(this + ": " + connectionValidator + " is stopped"); } else { if (trace) log.trace(this + ": " + connectionValidator + " is not stopped"); if (trace) log.trace(this + " calling connectionValidator.notifyListeners()"); connectionValidator.notifyListeners(new Exception("Could not connect to server!")); Iterator it = connectionListeners.iterator(); while (it.hasNext()) { ConnectionListener listener = (ConnectionListener) it.next(); connectionValidator.removeConnectionListener(this, listener); } if (connectionValidators.remove(connectionValidatorKey) != null) { if (trace) log.trace(this + ".notifyAndDisconnect() removed from static map: " + connectionValidator); } } } connectionValidator = null; connectionValidatorKey = null; } log.debug(this + " leaving notifyListeners()"); } } // Protected ------------------------------------------------------------------------------------ // Private -------------------------------------------------------------------------------------- private void connect(ClientInvoker invoker, ConnectionListener listener, Map metadata) { if (invoker != null) { invoker.connect(); try { setupClientLease(invoker, listener, metadata); } catch (Throwable throwable) { RuntimeException e = new CannotConnectException("Error setting up client lease upon performing connect."); e.initCause(throwable); throw e; } log.debug(this + " connected to " + locator); if (invokerDestructionDelay > 0) { synchronized (invokerDestructionTimerLock) { clientCounter++; log.debug(this + " clientCounter: " + clientCounter); } } } else { throw new RuntimeException("Client invoker is null (may have used void constructor " + "for Client, which should only be used for Externalization."); } } private void setupClientLease(ClientInvoker invoker, ConnectionListener listener, Map metadata) throws Throwable { long leasePeriod = -1; boolean enableLease = false; // start with checking the locator URL for hint as to if should do initial lease ping if (invoker != null) { if (invoker instanceof LocalClientInvoker) { // no need to continue as won't do client lease when is local (JBREM-382) return; } InvokerLocator locator = invoker.getLocator(); Map locatorParams = locator.getParameters(); if (locatorParams != null) { String leaseValue = (String)locatorParams.get(InvokerLocator.CLIENT_LEASE); if (leaseValue != null && leaseValue.length() > 0) { enableLease = Boolean.valueOf(leaseValue).booleanValue(); } String leasePeriodValue = (String)locatorParams.get(InvokerLocator.CLIENT_LEASE_PERIOD); if (leasePeriodValue != null && leasePeriodValue.length() > 0) { try { leasePeriod = Long.parseLong(leasePeriodValue); } catch (NumberFormatException e) { log.warn("Could not convert client lease period value (" + leasePeriodValue + ") to a number."); } } } } else { throw new RuntimeException("Can not set up client lease as client invoker is null."); } if (configuration != null) { Object val = configuration.get(ENABLE_LEASE); if (val != null) { if (val instanceof Boolean) { enableLease = ((Boolean)val).booleanValue(); } else if (val instanceof String) { enableLease = Boolean.valueOf((String)val).booleanValue(); } else { log.warn("Can not evaluate " + ENABLE_LEASE + " value (" + val + ") as a boolean type."); } } String leasePeriodValue = (String)configuration.get(InvokerLocator.CLIENT_LEASE_PERIOD); if (leasePeriodValue != null && leasePeriodValue.length() > 0) { try { leasePeriod = Long.parseLong(leasePeriodValue); } catch (NumberFormatException e) { log.warn("Could not convert client lease period value (" + leasePeriodValue + ") to a number."); } } } if (trace) log.trace(this + " enableLease: " + enableLease); if (enableLease) { Map temp = new HashMap(configuration); if (metadata != null) { temp.putAll(metadata); } if (useClientConnectionIdentity) { temp.put(CLIENT, this); temp.put(CONNECTION_LISTENER, listener); } if (trace) log.trace(this + " calling MicroRemoteClientInvoker.establishLease()"); invoker.establishLease(sessionId, temp, leasePeriod); } else if (listener != null) { addConnectionListener(listener, metadata); } } private Object invoke(Object param, Map metadata, InvokerLocator callbackServerLocator) throws Throwable { if (isConnected()) { return invoker.invoke(new InvocationRequest(sessionId, subsystem, param, metadata, null, callbackServerLocator)); } else { throw new Exception("Can not make remoting client invocation " + "due to not being connected to server."); } } private void addCallbackListener(InvokerCallbackHandler callbackhandler, Map metadata, InvokerLocator callbackLocator, Object callbackHandlerObject) throws Throwable { // if callback locator is null, then is pull callbacks and need to track callback handler // per Client (not by client invoker). if (callbackLocator == null) { String listenerId = generateListenerId(callbackhandler); // if listenerId is null, means this Client has already had the callbackhanler reference // registered as a listener, so no need to add it again. if (listenerId != null) { Map internalMetadata = new HashMap(); internalMetadata.put(LISTENER_ID_KEY, listenerId); if(metadata != null) { internalMetadata.putAll(metadata); } // now call server to add listener invoke(new InternalInvocation(InternalInvocation.ADDLISTENER, null), internalMetadata, callbackLocator); } } else { // is going to be push callbacks which means callback server locator involved. // will have to delegate to client invoker. String listenerId = invoker.addClientLocator(sessionId, callbackhandler, callbackLocator); if (listenerId != null) { Map internalMetadata = new HashMap(); internalMetadata.put(LISTENER_ID_KEY, listenerId); if(metadata != null) { internalMetadata.putAll(metadata); } Client client = new Client(callbackLocator, subsystem); client.setSessionId(getSessionId()); client.connect(); try { InternalInvocation i = new InternalInvocation(InternalInvocation.ADDCLIENTLISTENER, new Object[]{callbackhandler, callbackHandlerObject}); client.invoke(i, internalMetadata); } finally { client.disconnect(); } // now call server to add listener invoke(new InternalInvocation(InternalInvocation.ADDLISTENER, null), internalMetadata, callbackLocator); } } } private String generateListenerId(InvokerCallbackHandler callbackhandler) { String listenerId = null; Object obj = listeners.get(callbackhandler); if(obj == null) { listenerId = new GUID().toString(); listeners.put(callbackhandler, listenerId); } return listenerId; } private void processParameters() { Map params = new HashMap(); if (configuration != null) params.putAll(configuration); if (locator.getParameters() != null) params.putAll(locator.getParameters()); Object param = params.get(INVOKER_DESTRUCTION_DELAY); if (param instanceof String) { try { invokerDestructionDelay = Integer.parseInt((String) param); log.debug(this + " setting invokerDestructionDelay to " + invokerDestructionDelay); } catch (NumberFormatException e) { log.error("invokerDestructionDelay parameter has invalid format: " + param); } } else if (param != null) { log.error("invokerDestructionDelay parameter must be a string in integer format: " + param); } param = configuration.get(Remoting.USE_CLIENT_CONNECTION_IDENTITY); if (param instanceof String) { useClientConnectionIdentity = Boolean.valueOf((String) param).booleanValue(); } else if (param != null) { log.warn("value of " + Remoting.USE_CLIENT_CONNECTION_IDENTITY + " must be a String: " + param); } else { if (locator.getParameters() != null) { param = locator.getParameters().get(Remoting.USE_CLIENT_CONNECTION_IDENTITY); if (param != null) { useClientConnectionIdentity = Boolean.valueOf((String) param).booleanValue(); this.configuration.put(Remoting.USE_CLIENT_CONNECTION_IDENTITY, param); } } } PortUtil.updateRange(params); } private void configureCallbackServerSocketFactory(Map map) throws Exception { Boolean supportsSSL = null; try { supportsSSL = (Boolean) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new Boolean(InvokerRegistry.isSSLSupported(locator.getProtocol())); } }); } catch (PrivilegedActionException pae) { throw pae.getException(); } if (supportsSSL.booleanValue() && !map.containsKey(Remoting.CUSTOM_SERVER_SOCKET_FACTORY) && !map.containsKey(ServerInvoker.SERVER_SOCKET_FACTORY) && !map.containsKey(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE)) map.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); } // Inner classes -------------------------------------------------------------------------------- static class InvokerDestructionTimerTask extends TimerTask { private ClientInvoker invoker; private Map config; public InvokerDestructionTimerTask(ClientInvoker invoker, Map config) { this.invoker = invoker; this.config = config; } public void run() { log.debug(this + " calling InvokerRegistry.destroyClientInvoker() for " + invoker); AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.destroyClientInvoker(invoker.getLocator(), config); return null; } }); synchronized (invokerDestructionTimerLock) { if (--clientCounter == 0) { invokerDestructionTimer.cancel(); invokerDestructionTimer = null; log.debug(this + " stopped invokerDestructionTimer"); } log.debug(this + " clientCounter: " + clientCounter); } log.debug(this + "done"); } } static class ConnectionValidatorKey { private ClientInvoker invoker; private Map metadata; ConnectionValidatorKey(ClientInvoker invoker, Map metadata) { this.invoker = invoker; this.metadata = metadata; } public boolean equals(Object o) { if (o == null) return false; if (! (o instanceof ConnectionValidatorKey)) return false; ConnectionValidatorKey holder = (ConnectionValidatorKey) o; boolean metadataEquals = (metadata == null && holder.metadata == null) || metadata.equals(holder.metadata); return invoker == holder.invoker && metadataEquals; } public int hashCode() { return invoker.hashCode() * metadata.hashCode(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/invocation/0000755000175000017500000000000011632407044027010 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/invocation/OnewayInvocation.java0000644000175000017500000000260710554334044033155 0ustar twernertwerner/* * 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.remoting.invocation; /** * @author Tom Elrod */ public class OnewayInvocation extends RemoteInvocation { static final long serialVersionUID = -5957766205400999538L; public OnewayInvocation(Object param) { super(null, new Object[]{param}); } public String toString() { return "OnewayInvocation[" + params[0] + "]"; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/invocation/InternalInvocation.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/invocation/InternalInvocation.java0000644000175000017500000000453210642111005033452 0ustar twernertwerner/* * 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.remoting.invocation; /** * InternalInvocation.java is an invocation object for use in the * remoting layer for callbacks etc. We are responsible for assuring * that each method name has a unique arg list. *

          *

          * Created: Mon Apr 28 09:14:46 2003 * * @author David Jencks * @author Tom Elrod * @version 1.0 */ public class InternalInvocation extends RemoteInvocation { static final long serialVersionUID = 2629656457294678240L; public static final String ADDCLIENTLISTENER = "addClientListener"; public static final String ADDLISTENER = "addListener"; public static final String REMOVELISTENER = "removeListener"; public static final String REMOVECLIENTLISTENER = "removeClientListener"; public static final String GETCALLBACKS = "getCallbacks"; public static final String HANDLECALLBACK = "handleCallback"; public static final String ADDSTREAMCALLBACK = "addStreamCallback"; public static final String ACKNOWLEDGECALLBACK = "acknowledgeCallback"; public static final String ECHO = "echo"; public InternalInvocation(final String methodName, final Object[] params) { super(methodName, params); } public String toString() { return "InternalInvocation[" + Integer.toHexString(hashCode()) + "]"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/invocation/RemoteInvocation.java0000644000175000017500000000343510355142433033144 0ustar twernertwerner/* * 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.remoting.invocation; import java.io.Serializable; /** * Serves as the base invocation object for the different types of remoting invocations. * All remoting invocations should extend this class (i.e. InternalInvocation, NameBasedInvocation, etc.) * * @author Tom Elrod */ public class RemoteInvocation implements Serializable { static final long serialVersionUID = -5420149048705763388L; protected final String methodName; protected final Object[] params; public RemoteInvocation(final String methodName, final Object[] params) { this.methodName = methodName; this.params = params; } public String getMethodName() { return methodName; } public Object[] getParameters() { return params; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/invocation/NameBasedInvocation.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/invocation/NameBasedInvocation.jav0000644000175000017500000000457410552151674033402 0ustar twernertwerner/* * 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.remoting.invocation; import java.lang.reflect.Method; /** * NameBasedInvocation.java is an invocation object in jmx style. *

          *

          * Created: Mon Apr 28 09:14:46 2003 * * @author David Jencks * @version 1.0 */ public class NameBasedInvocation extends RemoteInvocation { /** * @since 4.0.1 */ static final long serialVersionUID = -6507163932605308471L; private final String[] sig; public NameBasedInvocation(final Method method, final Object[] params) { super(method.getName(), params); sig = generateSignatureFromMethod(method); } private String[] generateSignatureFromMethod(final Method method) { Class[] parameterTypes = method.getParameterTypes(); String[] signature = new String[parameterTypes.length]; for(int i = 0; i < parameterTypes.length; i++) { Class parameterType = parameterTypes[i]; signature[i] = parameterType.getName(); } return signature; } public NameBasedInvocation(final String methodName, final Object[] params, final String[] sig) { super(methodName, params); this.sig = sig; } // NameBasedInvocation constructor public String[] getSignature() { return sig; } public String toString() { return "NameBasedInvocation[" + methodName + "]"; } } // NameBasedInvocation libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/Remoting.java0000644000175000017500000001247511203656211027273 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.remoting; public class Remoting { private Remoting() {} /** * Key for the configuration map passed to a Connector to indicate the server * socket factory to be used. This will override the creation of any other socket factory. */ public static final String CUSTOM_SERVER_SOCKET_FACTORY = "customServerSocketFactory"; /** * Key for the configuration map passed to a Client to indicate the socket factory to * be used. This will override the creation of any other socket factory. */ public static final String CUSTOM_SOCKET_FACTORY = "customSocketFactory"; /** * Key for the configuration map passed to a Client to indicate the classname of * the socket factory to be used. */ public static final String SOCKET_FACTORY_NAME = "socketFactory"; /** * Key for the configuration map passed to a Client to indicate the classname of * the socket factory to be used. This one is distinct from the bean property "socketFactory". */ public static final String SOCKET_FACTORY_CLASS_NAME = "socketFactoryClassName"; /** * Key for the configuration map passed to a Client or Connector to indicate * a socket creation listener for sockets created by a SocketFactory. */ public static final String SOCKET_CREATION_CLIENT_LISTENER = "socketCreationClientListener"; /** * Key for the configuration map passed to a Client or Connector to indicate * a socket creation listener for sockets created by a ServerSocket. */ public static final String SOCKET_CREATION_SERVER_LISTENER = "socketCreationServerListener"; /** * Key with which host address of client will be associated in InvocationRequest * request payload. */ public static final String CLIENT_ADDRESS = "clientAddress"; /** * Key for configuring Remoting wire version. */ public static final String REMOTING_VERSION = "remotingVersion"; /** * Key for telling Remoting to execute security sensitive code outside of * java.security.AccessController.doPrivileged() calls. */ public static final String SKIP_ACCESS_CONTROL = "skipAccessControl"; /** * A flag indicating whether the RemotingClassLoader uses parent first (=true) * or user class loader first delegation. */ public static final String CLASSLOADING_PARENT_FIRST_DELEGATION = "classloadingParentFirstDelegation"; public static final String CLASSLOADING_PARENT_FIRST_DELEGATION_PROP = "org.jboss.remoting.classloadingParentFirstDelegation"; /** * Key for injecting into Connector a list of classloaders for remote * classloading facility. */ public static final String REMOTE_CLASS_LOADERS = "remoteClassLoaders"; /** * A flag indicating whether org.jboss.remoting.MicroRemoteClientInvoker should translate an * org.jboss.remoting.ServerInvoker.InvalidStateException to an org.jboss.remoting.CannotConnectException. */ public static final String CHANGE_INVALID_STATE_TO_CANNOT_CONNECT = "changeInvalidStateToCannotConnect"; /** * A flag indicating that AbstractInvoker should give priority to values in InvokerLocator over * values in configuration map. */ public static final String CONFIG_OVERRIDES_LOCATOR = "configOverridesLocator"; /** * A flag indicating that RemoteClientInvoker should use parameters in the InvokerLocator as * well as the configuration map when creating a SocketFactory. */ public static final String USE_ALL_SOCKET_FACTORY_PARAMS = "useAllSocketFactoryParams"; /** * Flags indicating that connection monitoring should treat a connection as being defined * by one or two of its endpoints. I.e., if a [client invoker or] server invoker stops and restarts, then * all connections it participated in are now gone. */ public static final String USE_CLIENT_CONNECTION_IDENTITY = "useClientConnectionIdentity"; // public static final String USE_SERVER_CONNECTION_IDENTITY = "useServerConnectionIdentity"; /** * A flag for indicating that the Client configuration map should be used to configure * marshallers and unmarshallers. If set to false (the default value), then parameters * will be taken only from the InvokerLocator. */ public static final String PASS_CONFIG_MAP_TO_MARSHAL_FACTORY = "passConfigMapToMarshalFactory"; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ident/0000755000175000017500000000000011632407044025742 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ident/Identity.java0000644000175000017500000004075111422064717030410 0ustar twernertwerner/* * 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.remoting.ident; import org.jboss.logging.Logger; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.util.SecurityUtility; import javax.management.MBeanServer; import javax.management.ObjectName; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Serializable; import java.net.InetAddress; import java.net.UnknownHostException; import java.rmi.dgc.VMID; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Iterator; import java.util.Map; import java.util.Random; import java.util.WeakHashMap; /** * Identity is used to uniquely identify a JBoss server instance on the network. * * @author Jeff Haynie * @version $Revision: 5923 $ */ public class Identity implements Serializable { static final long serialVersionUID = -2788084303665751253L; private static transient Random random = new Random(System.currentTimeMillis()); public static transient String DEFAULT_DOMAIN = "JBOSS"; private static transient String _domain = DEFAULT_DOMAIN; static { _domain = getSystemProperty("jboss.identity.domain", DEFAULT_DOMAIN); } private static transient Map identities = new WeakHashMap(2); private static final Logger log = Logger.getLogger(Identity.class); private static final InetAddress LOCAL_HOST; static { try { LOCAL_HOST = (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } }); } catch (PrivilegedActionException e) { log.debug(Identity.class.getName() + " unable to get local host address", e.getCause()); throw new ExceptionInInitializerError(e.getCause()); } catch (SecurityException e) { log.debug(Identity.class.getName() + " unable to get local host address", e); throw e; } } static private InetAddress getLocalHost() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return doGetLocalHost(); } try { return (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { return doGetLocalHost(); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } static private InetAddress doGetLocalHost() throws UnknownHostException { if (LOCAL_HOST != null) { return LOCAL_HOST; } try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } private final String instanceid; private final InetAddress ip; private final String serverid; private String domain; private int hashCode; private Identity(InetAddress addr, String instanceid, String serverid) { this.ip = addr; this.instanceid = instanceid; this.serverid = serverid; this.domain = ((_domain == null || _domain.equals("")) ? DEFAULT_DOMAIN : _domain); calcHashCode(); } private void calcHashCode() { this.hashCode = (ip.hashCode() + instanceid.hashCode() + serverid.hashCode() - domain.hashCode()); } /** * set the domain for all active mbean servers */ public static void setDomain(String domain) { Iterator iter = identities.keySet().iterator(); while(iter.hasNext()) { Identity ident = (Identity) identities.get(iter.next()); if(ident != null) { ident.domain = domain; } ident.calcHashCode(); } setSystemProperty("jboss.identity.domain", domain); _domain = domain; NetworkRegistry.getInstance().changeDomain(domain); } public int hashCode() { return hashCode; } public String toString() { return "JBOSS Identity\n\taddress:" + ip + "\n\tinstanceid:" + instanceid + "\n\tJMX id:" + serverid + "\n\tdomain:" + domain + "\n"; } /** * return the domain for the server * * @return */ public final String getDomain() { return domain; } /** * return the JBOSS Instance ID, which is the same between reboots of the same * JBOSS server instance. * * @return */ public String getInstanceId() { return this.instanceid; } /** * return the JBOSS IP Address of the instance * * @return */ public InetAddress getAddress() { return this.ip; } /** * return the JMX server ID for the JBoss instance, which is different between * reboots of the same JBOSS server instance. * * @return */ public String getJMXId() { return this.serverid; } /** * returns true if the identity represents the same JVM * * @param identity * @return */ public boolean isSameJVM(Identity identity) { return identity.equals(this); } /** * returns true if the identity represents the same JBOSS Instance, although * may not be the exact same process space since the JVM process space might be * different (such as a reboot). * * @param identity * @return */ public boolean isSameInstance(Identity identity) { return identity.getInstanceId().equals(instanceid); } /** * returns true if the identity is on the same JBOSS machine, represented by the * same IP address (this may not work in the case several physically different * machines have the same IP Address). * * @param identity * @return */ public boolean isSameMachine(Identity identity) { return identity.getAddress().equals(ip); } public boolean equals(Object obj) { if(obj instanceof Identity) { return hashCode == obj.hashCode(); } return false; } public static synchronized final Identity get(final MBeanServer server) { if(identities.containsKey(server)) { return (Identity) identities.get(server); } try { InetAddress localHost = getLocalHost(); ObjectName objectName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); String serverid = (String) getMBeanAttribute(server, objectName, "MBeanServerId"); Identity identity = new Identity(localHost, createId(server), serverid); identities.put(server, identity); return identity; } catch(Exception ex) { String type = ex.getClass().getName(); final RuntimeException rex = new RuntimeException("Exception creating identity: " + type + ": " + ex.getMessage()); rex.setStackTrace(ex.getStackTrace()); throw rex; } } private static final synchronized String createId(final MBeanServer server) { // we can set as a system property String myid = getSystemProperty("jboss.identity"); if(myid != null) { return myid; } String id = null; File file = null; try { // FIRST TRY THE JBOSS guy to determine our data directory final ObjectName obj = new ObjectName("jboss.system:type=ServerConfig"); File dir = (File) getMBeanAttribute(server, obj, "ServerDataDir"); if(dir != null) { if(fileExists(dir) == false) { mkdirs(dir); } file = new File(dir, "jboss.identity"); } } catch(Exception ex) { } if(file == null) { // we may not have that mbean, which is OK String fl = getSystemProperty("jboss.identity.dir", "."); File dir = new File(fl); if(fileExists(dir) == false) { mkdirs(dir); } file = new File(dir, "jboss.identity"); } boolean canRead = canRead(file); if(fileExists(file) && canRead) { InputStream is = null; try { is = getFileInputStream(file); byte buf[] = new byte[800]; int c = is.read(buf); id = new String(buf, 0, c); } catch(Exception ex) { throw new RuntimeException("Error loading jboss.identity: " + ex.toString()); } finally { if(is != null) { try { is.close(); } catch(Exception ig) { } } } } else { OutputStream out = null; try { id = createUniqueID(); if(fileExists(file) == false) { createNewFile(file); } out = getFileOutputStream(file); out.write(id.getBytes()); } catch(Exception ex) { throw new RuntimeException("Error creating Instance ID: " + ex.toString()); } finally { if(out != null) { try { out.flush(); out.close(); } catch(Exception ig) { } } } } setSystemProperty("jboss.identity", id); return id; } public static final String createUniqueID() { String id = new VMID().toString(); // colons don't work in JMX return id.replace(':', 'x') + random.nextInt(1000); } static private boolean fileExists(final File file) { if (file == null) return false; if (SecurityUtility.skipAccessControl()) { return file.exists(); } return ((Boolean)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(file.exists()); } })).booleanValue(); } static private boolean mkdirs(final File dir) { if (SecurityUtility.skipAccessControl()) { return dir.mkdirs(); } return ((Boolean) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(dir.mkdirs()); } })).booleanValue(); } static private FileInputStream getFileInputStream(final File file) throws FileNotFoundException { if (SecurityUtility.skipAccessControl()) { return new FileInputStream(file); } try { return (FileInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(file); } }); } catch (PrivilegedActionException e) { throw (FileNotFoundException) e.getCause(); } } static private FileOutputStream getFileOutputStream(final File file) throws FileNotFoundException { if (SecurityUtility.skipAccessControl()) { return new FileOutputStream(file); } try { return (FileOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileOutputStream(file); } }); } catch (PrivilegedActionException e) { throw (FileNotFoundException) e.getCause(); } } static private boolean canRead(final File file) { if (SecurityUtility.skipAccessControl()) { return file.canRead(); } return ((Boolean)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(file.canRead()); } })).booleanValue(); } static private boolean createNewFile(final File file) throws IOException { if (SecurityUtility.skipAccessControl()) { return file.createNewFile(); } try { return ((Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new Boolean(file.createNewFile()); } })).booleanValue(); } catch (Exception e) { throw (IOException) e.getCause(); } } static private Object getMBeanAttribute(final MBeanServer server, final ObjectName objectName, final String attribute) throws Exception { if (SecurityUtility.skipAccessControl()) { return server.getAttribute(objectName, attribute); } try { return AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return server.getAttribute(objectName, attribute); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } static private String getSystemProperty(final String name, final String defaultValue) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name, defaultValue); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name, defaultValue); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private String getSystemProperty(final String name) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/CannotConnectException.java0000644000175000017500000000340510452770174032125 0ustar twernertwerner/* * 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.remoting; /** * This exception is generated when the remoting layer cannot connect to the remote server * It means that the client cannot send the request to the server. *

          * Clustering layers can rely this exception to failover. * * @author Bill Burke * @version $Revision: 1216 $ */ public class CannotConnectException extends RuntimeException { private static final long serialVersionUID = 5890504116293908936L; public CannotConnectException() { } public CannotConnectException(String message) { super(message); } public CannotConnectException(String message, Throwable cause) { super(message, cause); } public CannotConnectException(Throwable cause) { super(cause); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/0000755000175000017500000000000011632407045027223 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/InternalTransporterServices.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/InternalTransporterSer0000644000175000017500000003607311171062275033651 0ustar twernertwerner/* * JBoss, Home of Professional Open Source */ package org.jboss.remoting.transporter; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.jboss.mx.util.ObjectNameFactory; import org.jboss.remoting.detection.Detector; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.util.SecurityUtility; import javax.management.MBeanServer; import javax.management.ObjectName; /** * This is a singleton that maintains internal services required for all transporter servers and clients. The * transporter server and client use these services to perform their functions. These "services" include an * MBeanServer, a Detector to detect other servers on the network and a Network Registry used to maintain a list of * known servers that have been detected. *

          *

          End-users do not have to interface with this singleton unless they want to customize the services used by the * transporter framework. Call {@link #setup(MBeanServer)} to setup this singleton with an MBeanServer that is to * be used to house all the internal services. You can then * {@link #assignDetector(Detector, ObjectName, boolean) assign a detector} and/or * {@link #assignNetworkRegistry(NetworkRegistry, ObjectName, boolean) assign a network registry} to this singleton. * You can setup and assign those services all in one call via * {@link #setup(MBeanServer, Detector, ObjectName, NetworkRegistry, ObjectName, boolean, boolean)}.

          *

          *

          The Network Registry and Detector objects are only needed if you want the transporter server/client to use * their clustering feature.

          *

          *

          Note that once this singleton is setup, it cannot be setup again. You must first {@link #reset()} it in order * to re-setup the singleton.

          * * @author John Mazzitelli * @version $Revision: 5023 $ */ public class InternalTransporterServices { /** * The default detector name if one is not provided. */ public static final ObjectName DEFAULT_DETECTOR_OBJECTNAME = ObjectNameFactory.create("remoting:type=Detector"); /** * The default network registry name if one is not provided. */ public static final ObjectName DEFAULT_NETWORKREGISTRY_OBJECTNAME = ObjectNameFactory.create("remoting:type=NetworkRegistry"); /** * The singleton instance. */ private static final InternalTransporterServices SINGLETON = new InternalTransporterServices(); /** * Returns the singleton instance containing the services used by all {@link TransporterServer} and * {@link TransporterClient} instances. * * @return the singleton */ public static InternalTransporterServices getInstance() { return SINGLETON; } /** * The MBeanServer that will house all the internal services. */ private MBeanServer m_mBeanServer; /** * The detector that will be used to auto-detect other servers out on the network. */ private Detector m_detector; /** * The name of the detector as it is registered in the {@link #getMBeanServer()}. */ private ObjectName m_detectorName; /** * The network registry to keep the list of servers found on the network. */ private NetworkRegistry m_networkRegistry; /** * The name of the network registry as it is registered in the {@link #getMBeanServer()}. */ private ObjectName m_networkRegistryName; /** * The singleton's constructor. */ private InternalTransporterServices() { m_mBeanServer = null; m_detector = null; m_detectorName = null; m_networkRegistry = null; m_networkRegistryName = null; } /** * Returns the MBeanServer that will house all the internal services. * * @return mBeanServer */ public MBeanServer getMBeanServer() { return m_mBeanServer; } /** * Returns the detector used to auto-detect other servers on the network. * * @return detector */ public Detector getDetector() { return m_detector; } /** * Returns the name of the {@link #getDetector() detector} used to auto-detect other servers on the network. * * @return detector name */ public ObjectName getDetectorName() { return m_detectorName; } /** * Returns the network registry used to maintain the list of known servers. * * @return network registry */ public NetworkRegistry getNetworkRegistry() { return m_networkRegistry; } /** * Returns the name of the {@link #getNetworkRegistry() network registry} used to maintain the list of known * servers. * * @return network registry name */ public ObjectName getNetworkRegistryName() { return m_networkRegistryName; } /** * Returns true if the internal transporter services singleton has been setup. When this returns * true, you can be guaranteed that a non-null {@link #getMBeanServer() MBeanServer} * has been given to this singleton. A detector and/or network registry may or may not be registered - it all * depends on how the singleton was set up and if those services were assigned to this singleton. * * @return true if this singleton has already been setup; false if it has not been * setup yet */ public boolean isSetup() { synchronized (this) { return m_mBeanServer != null; } } /** * If the caller wants to reset this singleton (e.g. a new MBeanServer is to be installed), this method must be * called before calling one of the setup methods again. Calling this method wipes the original MBeanServer and * unassigns any detector or network registry references this singleton has. */ public void reset() { synchronized (this) { m_mBeanServer = null; m_detector = null; m_detectorName = null; m_networkRegistry = null; m_networkRegistryName = null; } } /** * This will assign a detector to this singleton if one has not yet been setup. If there is no * {@link #getMBeanServer() MBean Server} yet, this will throw an exception. If a * {@link #getDetector() detector} has already been assigned, this will throw an exception. If * registerDetector is true, the given detector will be registered on the * {@link #getMBeanServer() MBeanServer} under the given name; if it is false, it will be assumed * the detector is already registered under that name and does not have to be registered here. * * @param detector the detector to assign to this singleton (must not be null) * @param detectorName the name the detector will be registered as (if null, a default name is * used) * @param registerDetector if true, will register the detector with the given name in the * MBeanServer * @throws IllegalStateException if the MBeanServer is not setup yet or there is already a detector assigned * @throws IllegalArgumentException if detector is null * @throws Exception any other exception means the detector failed to get registered in the * MBeanServer */ public void assignDetector(Detector detector, ObjectName detectorName, boolean registerDetector) throws IllegalArgumentException, IllegalStateException, Exception { synchronized (this) { if (detector == null) { throw new IllegalArgumentException("Detector was null"); } if (m_mBeanServer == null) { throw new IllegalStateException("There is no MBeanServer setup yet"); } if (m_detector != null) { throw new IllegalStateException("A detector is already assigned"); } if (detectorName == null) { detectorName = DEFAULT_DETECTOR_OBJECTNAME; } m_detector = detector; m_detectorName = detectorName; if (registerDetector) { registerMBean(m_mBeanServer, m_detector, m_detectorName); } } return; } /** * This will assign a network registry to this singleton if one has not yet been setup. If there is no * {@link #getMBeanServer() MBean Server} yet, this will throw an exception. If a * {@link #getNetworkRegistry() registry} has already been assigned, this will throw an exception. If * registerRegistry is true, the given registry will be registered on the * {@link #getMBeanServer() MBeanServer} with the given name; if it is false, it will be assumed * the registry is already registered under that name and does not have to be registered here. * * @param registry the network registry to assign to this singleton (must not be null) * @param registryName the name the registry will be registered as (if null a default name is * used) * @param registerRegistry if true, will register the network registry with the given name in the * MBeanServer * @throws IllegalStateException if the MBeanServer is not setup yet or there is already a registry assigned * @throws IllegalArgumentException if registry is null * @throws Exception any other exception means the registry failed to get registered in the * MBeanServer */ public void assignNetworkRegistry(NetworkRegistry registry, ObjectName registryName, boolean registerRegistry) throws IllegalArgumentException, IllegalStateException, Exception { synchronized (this) { if (registry == null) { throw new IllegalArgumentException("Registry was null"); } if (m_mBeanServer == null) { throw new IllegalStateException("There is no MBeanServer setup yet"); } if (m_networkRegistry != null) { throw new IllegalStateException("A network registry is already assigned"); } if (registryName == null) { registryName = DEFAULT_NETWORKREGISTRY_OBJECTNAME; } m_networkRegistry = registry; m_networkRegistryName = registryName; if (registerRegistry) { registerMBean(m_mBeanServer, m_networkRegistry, m_networkRegistryName); } } return; } /** * Sets the MBeanServer used to house the transporter services. Use this method if the transporter * servers/clients do not need clustering and therefore do not need to assign a detector service or the network * registry. * * @param mbs the MBeanServer that will house the internal services * @throws IllegalArgumentException if mbs is null * @throws IllegalStateException if the singleton was already setup */ public void setup(MBeanServer mbs) throws IllegalArgumentException, IllegalStateException { synchronized (this) { if (m_mBeanServer != null) { throw new IllegalStateException("The internal transporter services have already been setup"); } if (mbs == null) { throw new IllegalArgumentException("MBeanServer must not be null"); } m_mBeanServer = mbs; m_detector = null; m_detectorName = null; m_networkRegistry = null; m_networkRegistryName = null; } return; } /** * Sets the MBeanServer used to house the transporter services, assigns the detector used to auto-detect * other servers on the network and assigns the network registry that maintains the list of known servers on the * network. If the detector or registry already exist in the MBeanServer and their respective * registerXXX parameter is true, an exception is thrown. * * @param mbs the MBeanServer that will house the internal services (must not be * null) * @param detector the detector that will listen for other servers on the network * @param detectorName the name of the detector as it is or will be registered in the MBeanServer (if * null, a default name will be used) * @param registry the network registry that will maintain the list of known servers on the network * @param registryName the name of the network registry as it is or will be registered in the MBeanServer * (if null, a default name will be used) * @param registerDetector if true, will register the detector with the given name * @param registerRegistry if true, will register the network registry with the given name * @throws IllegalStateException if the singleton was already setup * @throws IllegalArgumentException if the MBeanServer is null or detector is null but * its name is not or registry is null but its name is not * @throws Exception if this method failed to register the detector or registry * @see #assignDetector(Detector, ObjectName, boolean) * @see #assignNetworkRegistry(NetworkRegistry, ObjectName, boolean) */ public void setup(MBeanServer mbs, Detector detector, ObjectName detectorName, NetworkRegistry registry, ObjectName registryName, boolean registerDetector, boolean registerRegistry) throws Exception { synchronized (this) { setup(mbs); if (detector != null) { assignDetector(detector, detectorName, registerDetector); } if (registry != null) { assignNetworkRegistry(registry, registryName, registerRegistry); } } return; } static private void registerMBean(final MBeanServer server, final Object o, final ObjectName name) throws Exception { if (SecurityUtility.skipAccessControl()) { server.registerMBean(o, name); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { server.registerMBean(o, name); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/TransporterClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/TransporterClient.java0000644000175000017500000003711611171062275033560 0ustar twernertwerner/* * 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.remoting.transporter; import org.jboss.logging.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.ServerInvokerMetadata; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.invocation.NameBasedInvocation; import org.jboss.remoting.network.NetworkInstance; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.util.SecurityUtility; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import java.io.Serializable; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; /** * Class to be used as a factory via static method calls to get * remote proxy to POJO that exists within a external process. * Note, if using clustered, will use the multicast detector by default. * * @author Tom Elrod */ public class TransporterClient implements InvocationHandler, Serializable { private Client remotingClient = null; private boolean isClustered = false; private String subSystem = null; private LoadBalancer loadBalancer = new DefaultLoadBalancer(); private final Logger log = Logger.getLogger(TransporterClient.class); private static final long serialVersionUID = 7418567482011657189L; /** * Creates the remoting client to server POJO. * Is not clustered. * * @param locator * @throws Exception */ private TransporterClient(InvokerLocator locator) throws Exception { remotingClient = new Client(locator); remotingClient.connect(); } /** * Creates the remoting client to server POJO. * Is clustered * * @param locator * @param targetSubsystem * @throws Exception */ private TransporterClient(InvokerLocator locator, String targetSubsystem) throws Exception { remotingClient = new Client(locator, targetSubsystem); remotingClient.connect(); this.isClustered = true; this.subSystem = targetSubsystem; } /** * Creates the remoting client to server POJO. * Is clustered * * @param locator * @param targetSubsystem * @param loadbalancer policy * @throws Exception */ private TransporterClient(InvokerLocator locator, String targetSubsystem, LoadBalancer loadbalancer) throws Exception { this.loadBalancer = loadbalancer; remotingClient = new Client(locator, targetSubsystem); remotingClient.connect(); this.isClustered = true; this.subSystem = targetSubsystem; } /** * Disconnects the remoting client */ private void disconnect() { if (remotingClient != null) { remotingClient.disconnect(); } } /** * Will set up network registry and detector for clustering (to identify other * remoting servers running on network). * * @throws Exception */ private static void setupDetector() throws Exception { InternalTransporterServices services = InternalTransporterServices.getInstance(); // if no one has setup our internal services yet, let's do it now if (!services.isSetup()) { // we need an MBeanServer to store our network registry and multicast detector services MBeanServer server = createMBeanServer(); // multicast detector will detect new network registries that come online MulticastDetector detector = new MulticastDetector(); NetworkRegistry registry = NetworkRegistry.getInstance(); services.setup(server, detector, null, registry, null, true, true); detector.start(); } else { // the internal services singleton is already setup, but make sure it has the services we need if (services.getDetector() == null) { MulticastDetector detector = new MulticastDetector(); services.assignDetector(detector, null, true); detector.start(); } if (services.getNetworkRegistry() == null) { NetworkRegistry registry = NetworkRegistry.getInstance(); services.assignNetworkRegistry(registry, null, true); } } return; } /** * Create a remote proxy to a POJO on a remote server. * * @param locatorURI - the remoting locator uri to the target server where the target POJO exists. * @param targetClass - the interface class of the POJO will be calling upon. * @param clustered - true will cause the transporter to look for other remoting serves that have the POJO running * and include it in the client's target list. If a call on first target fails, will seamlessly fail over to one * of the other discovered targets. * @return dynamic remote proxy typed to the interface specified by the targetClass param. * @throws Exception */ public static Object createTransporterClient(String locatorURI, Class targetClass, boolean clustered) throws Exception { if (!clustered) { return createTransporterClient(locatorURI, targetClass); } else { if (InternalTransporterServices.getInstance().getNetworkRegistry() == null) { setupDetector(); } InvokerLocator locator = new InvokerLocator(locatorURI); TransporterClient client = new TransporterClient(locator, targetClass.getName()); ClassLoader tcl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); return Proxy.newProxyInstance(tcl, new Class[]{targetClass}, client); } } /** * Create a remote proxy to a POJO on a remote server. * * @param locatorURI - the remoting locator uri to the target server where the target POJO exists. * @param targetClass - the interface class of the POJO will be calling upon. * @param loadBalancer - policy for selecting which target server to use from list of available servers. * @return dynamic remote proxy typed to the interface specified by the targetClass param. * @throws Exception */ public static Object createTransporterClient(String locatorURI, Class targetClass, LoadBalancer loadBalancer) throws Exception { if (InternalTransporterServices.getInstance().getNetworkRegistry() == null) { setupDetector(); } InvokerLocator locator = new InvokerLocator(locatorURI); TransporterClient client = new TransporterClient(locator, targetClass.getName(), loadBalancer); ClassLoader tcl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); return Proxy.newProxyInstance(tcl, new Class[]{targetClass}, client); } /** * Create a remote proxy to a POJO on a remote server. * * @param locatorURI - the remoting locator uri to the target server where the target POJO exists. * @param targetClass - the interface class of the POJO will be calling upon. * @return dynamic remote proxy typed to the interface specified by the targetClass param. * @throws Exception */ public static Object createTransporterClient(String locatorURI, Class targetClass) throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); return createTransporterClient(locator, targetClass); } /** * Create a remote proxy to a POJO on a remote server. * * @param locator - the remoting locator to the target server where the target POJO exists. * @param targetClass - the interface class of the POJO will be calling upon. * @return dynamic remote proxy typed to the interface specified by the targetClass param. * @throws Exception */ public static Object createTransporterClient(InvokerLocator locator, Class targetClass) throws Exception { TransporterClient client = new TransporterClient(locator, targetClass.getName()); ClassLoader tcl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); return Proxy.newProxyInstance(tcl, new Class[]{targetClass}, client); } /** * Needs to be called by user when no longer need to make calls on remote POJO. Otherwise will * maintain remote connection until this is called. * * @param transporterClient */ public static void destroyTransporterClient(Object transporterClient) { if (transporterClient instanceof Proxy) { InvocationHandler handler = Proxy.getInvocationHandler(transporterClient); if (handler instanceof TransporterClient) { TransporterClient client = (TransporterClient) handler; client.disconnect(); } else { throw new IllegalArgumentException("Object is not a transporter client."); } } else { throw new IllegalArgumentException("Object is not a transporter client."); } } /** * The method called when anyone calls on the dynamic proxy returned by getProcessor(). * This method will simply convert the proxy call info into a remoting invocation on the * target remoting server (using a NameBaseInvocation). * * @param proxy * @param method * @param args * @return * @throws Throwable */ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); String[] paramSig = createParamSignature(method.getParameterTypes()); NameBasedInvocation request = new NameBasedInvocation(methodName, args, paramSig); Object response = null; boolean failOver = false; do { try { failOver = false; response = remotingClient.invoke(request); } catch (CannotConnectException cnc) { failOver = findAlternativeTarget(); if (!failOver) { throw cnc; } } catch (InvocationTargetException itex) { Throwable rootEx = itex.getCause(); throw rootEx; } } while (failOver); return response; } /** * Will check to see if the network registry has found any other remoting servers. Then will check * to see if any of them contain the subsystem we are interested in (which will corespond to the proxy type we * are using). If one is found, will try to create a remoting client and connect to it. * If can't find one, will return fasle. * * @return */ private boolean findAlternativeTarget() { boolean failover = false; ArrayList availableList = new ArrayList(); NetworkRegistry registry = InternalTransporterServices.getInstance().getNetworkRegistry(); if (registry != null) { NetworkInstance[] instances = registry.getServers(); if (instances != null) { for (int x = 0; x < instances.length; x++) { NetworkInstance netInstance = instances[x]; ServerInvokerMetadata[] metadata = netInstance.getServerInvokers(); for (int i = 0; i < metadata.length; i++) { ServerInvokerMetadata data = metadata[i]; String[] subsystems = data.getSubSystems(); for (int z = 0; z < subsystems.length; z++) { if (subSystem.equalsIgnoreCase(subsystems[z])) { availableList.add(data); } } } } //If alternative servers are found if (availableList.size() > 0) { int index = loadBalancer.selectServer(availableList); if (log.isDebugEnabled()) { log.debug("Total of " + availableList.size() + " available servers found."); log.debug("Using server number " + index); } //reconnect to the new server ServerInvokerMetadata data = (ServerInvokerMetadata) availableList.get(index); InvokerLocator newLocator = data.getInvokerLocator(); if (!remotingClient.getInvoker().getLocator().equals(newLocator)) { try { remotingClient = new Client(newLocator); remotingClient.connect(); return true; } catch (Exception e) { log.warn("Problem connecting to newly found alternate target.", e); } } } } } return failover; } /** * Converts the Class array supplied via the dynamic proxy to * a String array of the respective class names, which is need by * the NameBasedInvocation object. * * @param args * @return */ private String[] createParamSignature(Class[] args) { if (args == null || args.length == 0) { return new String[]{}; } String[] paramSig = new String[args.length]; for (int x = 0; x < args.length; x++) { paramSig[x] = args[x].getName(); } return paramSig; } static private MBeanServer createMBeanServer() throws Exception { if (SecurityUtility.skipAccessControl()) { return MBeanServerFactory.createMBeanServer(); } try { return (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/TransporterServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/TransporterServer.java0000644000175000017500000006113211171062275033603 0ustar twernertwerner/* * 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.remoting.transporter; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.util.SecurityUtility; import org.w3c.dom.Element; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * The remoting server to expose the target POJO. This should be called on as a factory via * static methods. * * @author Tom Elrod */ public class TransporterServer { private Connector connector = null; /** * Creates a remoting server using the provided locator and subsytem and creating a TransporterHandler which * takes the specified target object. * * @param locator * @param target * @param subsystem * @throws Exception */ public TransporterServer(InvokerLocator locator, Object target, String subsystem) throws Exception { connector = getConnector(locator, null, null); ServerInvocationHandler handler = new TransporterHandler(target); if (subsystem != null) { connector.addInvocationHandler(subsystem.toUpperCase(), handler); } else { addInterfaceSubsystems(connector, handler, target); } } /** * Creates a remoting server using the provided locator and subsytem and creating a TransporterHandler which * takes the specified target object. * * @param xmlConfig * @param target * @param subsystem * @throws Exception */ public TransporterServer(Element xmlConfig, Object target, String subsystem) throws Exception { connector = getConnector(null, null, xmlConfig); ServerInvocationHandler handler = new TransporterHandler(target); if (subsystem != null) { connector.addInvocationHandler(subsystem.toUpperCase(), handler); } else { addInterfaceSubsystems(connector, handler, target); } } /** * Creates a remoting server using the provided locator and subsytem and creating a TransporterHandler which * takes the specified target object. * * @param locator * @param target * @param subsystem * @param config - configuration data for Connector * @throws Exception */ public TransporterServer(InvokerLocator locator, Object target, String subsystem, Map config) throws Exception { connector = getConnector(locator, config, null); ServerInvocationHandler handler = new TransporterHandler(target); if (subsystem != null) { connector.addInvocationHandler(subsystem.toUpperCase(), handler); } else { addInterfaceSubsystems(connector, handler, target); } } private void addInterfaceSubsystems(Connector connector, ServerInvocationHandler handler, Object target) throws Exception { Class targetClass = target.getClass(); //first have to build list of interface names List interfaceNames = new ArrayList(); populateInterfaceNames(interfaceNames, targetClass); for (int i = 0; i < interfaceNames.size(); i++) { String interfaceClassName = (String) interfaceNames.get(i); connector.addInvocationHandler(interfaceClassName.toUpperCase(), handler); } } private void populateInterfaceNames(List interfaceNames, Class targetClass) { Class[] interfaces = targetClass.getInterfaces(); if (interfaces != null) { for (int x = 0; x < interfaces.length; x++) { interfaceNames.add(interfaces[x].getName()); populateInterfaceNames(interfaceNames, interfaces[x]); } } } /** * Returns the connector that this transporter server will use. Subclasses are free to override this method in order * to create a more customized connector. * * @param locator * @param config configuration data for connector * @param xmlConfig configuration data for connector (in xml form) * @return the connector to be used by this transporter server * @throws Exception */ protected Connector getConnector(InvokerLocator locator, Map config, Element xmlConfig) throws Exception { Connector c = new Connector(locator, config); if (xmlConfig != null) { c.setConfiguration(xmlConfig); } c.create(); return c; } /** * Adds a transporter handler to receive remote invocations on the target object passed. * * @param target the target implementation to call on * @param proxyclassname the fully qualified classname of the interface that clients will use to call on */ public void addHandler(Object target, String proxyclassname) throws Exception { if (connector != null) { connector.addInvocationHandler(proxyclassname, new TransporterHandler(target)); } else { throw new Exception("Can not add handler to transporter server as has not be initialized yet."); } } /** * Starts the remoting server. This is called automatically upon any of the static createTransporterServer() methods. * * @throws Exception */ public void start() throws Exception { connector.start(); } /** * Stops the remoting server. This must be called when no longer want to expose the target POJO for remote * method calls. */ public void stop() { connector.stop(); } /** * Creates a MBeanServer and MulticastDetector to start publishing detection messages so * other detectors will be aware this server is available. * * @throws Exception */ private static void setupDetector() throws Exception { InternalTransporterServices services = InternalTransporterServices.getInstance(); // if no one has setup our internal services yet, let's do it now if (!services.isSetup()) { // we need an MBeanServer to store our network registry and multicast detector services MBeanServer server = createMBeanServer(); // multicast detector will detect new network registries that come online MulticastDetector detector = new MulticastDetector(); services.setup(server, detector, null, null, null, true, false); detector.start(); } else if (services.getDetector() == null) { // the internal services singleton is already setup, make sure it has a detector because we need it MulticastDetector detector = new MulticastDetector(); services.assignDetector(detector, null, true); detector.start(); } return; } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param subsystem - the name under which to register the handler within the remoting server. This must be * the fully qualified name of the interface for clients to use a the remote proxy to the target POJO. Otherwise, * clustering will not work, as this is the value used to identifiy remote POJOs on the client side. If not clustered, * this is not as critical, and simply use the fully qualified class name of the POJO if desired. * @param isClustered - true indicates that would like this server to be considered available for * failover from clients calling on the same interface as exposed by the subsystem value. False will only allow * those client that explicitly targeting this server to make calls on it. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(InvokerLocator locator, Object target, String subsystem, boolean isClustered) throws Exception { return createTransporterServer(locator, target, subsystem, null, isClustered); } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param subsystem - the name under which to register the handler within the remoting server. This must be * the fully qualified name of the interface for clients to use a the remote proxy to the target POJO. Otherwise, * clustering will not work, as this is the value used to identifiy remote POJOs on the client side. If not clustered, * this is not as critical, and simply use the fully qualified class name of the POJO if desired. * @param config - the configuration to be used in setting up the Connector. * @param isClustered - true indicates that would like this server to be considered available for * failover from clients calling on the same interface as exposed by the subsystem value. False will only allow * those client that explicitly targeting this server to make calls on it. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(InvokerLocator locator, Object target, String subsystem, Map config, boolean isClustered) throws Exception { if (isClustered && (InternalTransporterServices.getInstance().getDetector() == null)) { setupDetector(); } TransporterServer server = new TransporterServer(locator, target, subsystem, config); server.start(); return server; } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locatorURI - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param subsystem - the name under which to register the handler within the remoting server. This must be * the fully qualified name of the interface for clients to use a the remote proxy to the target POJO. Otherwise, * clustering will not work, as this is the value used to identifiy remote POJOs on the client side. If not clustered, * this is not as critical, and simply use the fully qualified class name of the POJO if desired. * @param isClustered - true indicates that would like this server to be considered available for * failover from clients calling on the same interface as exposed by the subsystem value. False will only allow * those client that explicitly targeting this server to make calls on it. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(String locatorURI, Object target, String subsystem, boolean isClustered) throws Exception { return createTransporterServer(new InvokerLocator(locatorURI), target, subsystem, null, isClustered); } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locatorURI - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param subsystem - the name under which to register the handler within the remoting server. This must be * the fully qualified name of the interface for clients to use a the remote proxy to the target POJO. Otherwise, * clustering will not work, as this is the value used to identifiy remote POJOs on the client side. If not clustered, * this is not as critical, and simply use the fully qualified class name of the POJO if desired. * @param config - the configuration data for the Connector. * @param isClustered - true indicates that would like this server to be considered available for * failover from clients calling on the same interface as exposed by the subsystem value. False will only allow * those client that explicitly targeting this server to make calls on it. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(String locatorURI, Object target, String subsystem, Map config, boolean isClustered) throws Exception { return createTransporterServer(new InvokerLocator(locatorURI), target, subsystem, config, isClustered); } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object. Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param xmlconfig - specifies config for Connector * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param subsystem - the name under which to register the handler within the remoting server. This must be * the fully qualified name of the interface for clients to use a the remote proxy to the target POJO. Otherwise, * clustering will not work, as this is the value used to identifiy remote POJOs on the client side. If not clustered, * this is not as critical, and simply use the fully qualified class name of the POJO if desired. * @param isClustered - true indicates that would like this server to be considered available for * failover from clients calling on the same interface as exposed by the subsystem value. False will only allow * those client that explicitly targeting this server to make calls on it. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(Element xmlconfig, Object target, String subsystem, boolean isClustered) throws Exception { if (isClustered && (InternalTransporterServices.getInstance().getDetector() == null)) { setupDetector(); } TransporterServer server = new TransporterServer(xmlconfig, target, subsystem); server.start(); return server; } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param subsystem - the name under which to register the handler within the remoting server. Can * simply use the fully qualified class name of the POJO if desired. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(InvokerLocator locator, Object target, String subsystem) throws Exception { return createTransporterServer(locator, target, subsystem, false); } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(InvokerLocator locator, Object target) throws Exception { return createTransporterServer(locator, target, false); } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param isClustered - indicates if want automatic failover on calls to remote servers. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(InvokerLocator locator, Object target, boolean isClustered) throws Exception { if (isClustered && (InternalTransporterServices.getInstance().getDetector() == null)) { setupDetector(); } TransporterServer server = new TransporterServer(locator, target, null, null); server.start(); return server; } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(String locator, Object target) throws Exception { return createTransporterServer(new InvokerLocator(locator), target, false); } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locator - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param isClustered - indicates if want automatic failover on calls to remote servers. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(String locator, Object target, boolean isClustered) throws Exception { return createTransporterServer(new InvokerLocator(locator), target, isClustered); } /** * Creates a remoting server based on given locator. Will convert any remote invocation requests into * method calls on the given target object.Note: the TransporterServer instance returned will be a live (started) * instance. * * Once the TransporterServer has been returned, it will have already been started automatically, so is a live server * ready to receive requests. * * @param locatorURI - specifies what transport, host and port binding, etc. to use by the remoting server. * @param target - the target POJO to receive the method call upon getting remote invocation requests. * @param subsystem - the name under which to register the handler within the remoting server. Can * simply use the fully qualified class name of the POJO if desired. * @return TransporterServer. Note, it will already be started upon return. * @throws Exception */ public static TransporterServer createTransporterServer(String locatorURI, Object target, String subsystem) throws Exception { return createTransporterServer(new InvokerLocator(locatorURI), target, subsystem, false); } static private MBeanServer createMBeanServer() throws Exception { if (SecurityUtility.skipAccessControl()) { return MBeanServerFactory.createMBeanServer(); } try { return (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return MBeanServerFactory.createMBeanServer(); } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/TransporterHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/TransporterHandler.jav0000644000175000017500000001226611171062275033555 0ustar twernertwerner/* * 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.remoting.transporter; 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.NameBasedInvocation; import org.jboss.remoting.util.SecurityUtility; import javax.management.MBeanServer; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * Simple handler that uses reflection to make calls on target POJO (as supplied in the constructor) * when receive invocation requests. * * @author Tom Elrod */ public class TransporterHandler implements ServerInvocationHandler { private Object targetPOJO = null; public TransporterHandler(Object target) { this.targetPOJO = target; } /** * Takes the invocation request, which should have a internal parameter of NameBasedInvocation, * and convert that to a method call on the target POJO (using reflection). Then return the Object * returned from the method call on the target POJO. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { Object request = invocation.getParameter(); // Am expecting a NameBasedInvocation as the parameter NameBasedInvocation nbInvocation = (NameBasedInvocation) request; final String methodName = nbInvocation.getMethodName(); Object[] params = nbInvocation.getParameters(); String[] sig = nbInvocation.getSignature(); final Class[] classSig = new Class[sig.length]; for(int x = 0; x < sig.length; x++) { Class signature = getPrimitiveType(sig[x]); if(signature != null) { classSig[x] = signature; } else { classSig[x] = Class.forName(sig[x]); } } // use reflection to make the call Method method = getMethod(targetPOJO.getClass(), methodName, classSig); Object responseObject = method.invoke(targetPOJO, params); return responseObject; } private Class getPrimitiveType(String name) { if (name.equals("byte")) return Byte.TYPE; if (name.equals("short")) return Short.TYPE; if (name.equals("int")) return Integer.TYPE; if (name.equals("long")) return Long.TYPE; if (name.equals("char")) return Character.TYPE; if (name.equals("float")) return Float.TYPE; if (name.equals("double")) return Double.TYPE; if (name.equals("boolean")) return Boolean.TYPE; if (name.equals("void")) return Void.TYPE; return null; } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { //NOOP } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { //NOOP } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //NOOP } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //NOOP } static private Method getMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { return c.getMethod(name, parameterTypes); } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { return c.getMethod(name, parameterTypes); } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/LoadBalancer.java0000644000175000017500000000040010426176513032372 0ustar twernertwernerpackage org.jboss.remoting.transporter; import java.util.ArrayList; /** * Inferface definition for any LoadBalancer implementation * * @author Jeanette Cheng */ public interface LoadBalancer { public int selectServer(ArrayList serversList); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/DefaultLoadBalancer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transporter/DefaultLoadBalancer.ja0000644000175000017500000000103611247601222033346 0ustar twernertwernerpackage org.jboss.remoting.transporter; import java.io.Serializable; import java.util.ArrayList; import java.util.Random; public class DefaultLoadBalancer implements LoadBalancer, Serializable { private static final long serialVersionUID = -7219455363024542925L; public int selectServer(ArrayList servers) { int index = 0; if (servers != null) { int size = servers.size(); if (size > 1) { index = new Random().nextInt(size); } } return index; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/0000755000175000017500000000000011632407045027515 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/0000755000175000017500000000000011632407045030456 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/0000755000175000017500000000000011632407045031576 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/MarshalledValue.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/Marshalle0000644000175000017500000000260410424242135033426 0ustar twernertwerner/* * 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.remoting.serialization.impl.jboss; import java.io.IOException; import org.jboss.remoting.serialization.IMarshalledValue; import org.jboss.serial.io.MarshalledObject; public class MarshalledValue extends MarshalledObject implements IMarshalledValue { private static final long serialVersionUID = 6226352777827651658L; public MarshalledValue(Object obj) throws IOException { super(obj); } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/LocalMarshalledValue.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/LocalMars0000644000175000017500000001115710774603625033413 0ustar twernertwerner/* * 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.remoting.serialization.impl.jboss; import org.jboss.logging.Logger; import org.jboss.serial.objectmetamodel.DataContainer; import org.jboss.serial.objectmetamodel.safecloning.SafeCloningRepository; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.security.AccessController; import java.security.PrivilegedAction; /** * Does lazy serialization based on JBossSerialization. * I'm using JbossSerialization internal's API here, because DataContainer is a repository of final variables, * and in case we are only using this MarshalledValue to cross ClassLoader isolations, we don't need to convert * the repository to a byteArray. *

          * $Id: LocalMarshalledValue.java 3845 2008-04-02 04:12:05Z ron.sigal@jboss.com $ * * @author Clebert Suconic */ public class LocalMarshalledValue extends org.jboss.remoting.serialization.RemotingMarshalledValue implements Externalizable { protected static final Logger log = Logger.getLogger(JBossSerializationManager.class); DataContainer container; private static final long serialVersionUID = 6996297171147626666L; public LocalMarshalledValue() { } public LocalMarshalledValue(Object obj) throws IOException { container = new DataContainer(false); ObjectOutput output = container.getOutput(); output.writeObject(obj); output.flush(); container.flush(); } public LocalMarshalledValue(Object obj, SafeCloningRepository safeToReuse) throws IOException { container = new DataContainer(null, null, safeToReuse, false); ObjectOutput output = container.getOutput(); output.writeObject(obj); output.flush(); container.flush(); } /** * The object has to be unserialized only when the first get is executed. */ public Object get() throws IOException, ClassNotFoundException { try { ClassLoader tcl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); container.getCache().setLoader(tcl); return container.getInput().readObject(); } catch(RuntimeException e) { log.debug(e, e); throw e; } } public void writeExternal(ObjectOutput out) throws IOException { log.warn("LocalmarshalledValue writeExternal is deprecated. This version is best used on call-by-value operations"); ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); BufferedOutputStream buffOut = new BufferedOutputStream(byteOut); DataOutputStream dataOut = new DataOutputStream(buffOut); container.saveData(dataOut); dataOut.flush(); byte[] arrayBytes = byteOut.toByteArray(); out.writeInt(arrayBytes.length); out.write(arrayBytes); out.flush(); } public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { log.warn("LocalmarshalledValue readExternal is deprecated. This version is best used on call-by-value operations"); byte[] bytes = new byte[in.readInt()]; in.readFully(bytes); ByteArrayInputStream byteInput = new ByteArrayInputStream(bytes); DataInputStream input = new DataInputStream(byteInput); container = new DataContainer(false); container.loadData(input); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSerializationManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/JBossSeri0000644000175000017500000001560711000035506033361 0ustar twernertwerner/* * 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.remoting.serialization.impl.jboss; import org.jboss.logging.Logger; import org.jboss.remoting.loading.ObjectInputStreamWithClassLoader; import org.jboss.remoting.serialization.IMarshalledValue; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.util.SecurityUtility; import org.jboss.serial.io.JBossObjectInputStream; import org.jboss.serial.io.JBossObjectOutputStream; import org.jboss.serial.util.StringUtilBuffer; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * Instantiates the Streamings according to JbossObjectOutputStream and JBossObjectInputStream. * Also, it uses a different approach for MarshallValues as we don't need to convert objects in bytes. * $Id: JBossSerializationManager.java 3976 2008-04-12 04:32:06Z ron.sigal@jboss.com $ * * @author Clebert Suconic */ public class JBossSerializationManager extends SerializationManager { protected static final Logger log = Logger.getLogger(JBossSerializationManager.class); private static boolean trace = log.isTraceEnabled(); public ObjectInputStream createInput(final InputStream input, final ClassLoader loader) throws IOException { if (trace) { log.trace(this + " creating JBossObjectInputStream"); } if (SecurityUtility.skipAccessControl()) { return new JBossObjectInputStream(input, loader, new StringUtilBuffer(10024, 10024)); } try { return (ObjectInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new JBossObjectInputStream(input, loader, new StringUtilBuffer(10024, 10024)); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } public ObjectOutputStream createOutput(final OutputStream output) throws IOException { if (trace) { log.trace(this + " creating JBossObjectOutputStream"); } if (SecurityUtility.skipAccessControl()) { return new JBossObjectOutputStream(output, new StringUtilBuffer(10024, 10024)); } try { return (ObjectOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new JBossObjectOutputStream(output, new StringUtilBuffer(10024, 10024)); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } /** * Creates a MarshalledValue that does lazy serialization. */ public IMarshalledValue createdMarshalledValue(Object source) throws IOException { if (source instanceof IMarshalledValue) { return (IMarshalledValue) source; } else { return new MarshalledValue(source); } } public IMarshalledValue createMarshalledValueForClone(Object original) throws IOException { return new SmartCloningMarshalledValue(original); } public void sendObject(final ObjectOutputStream oos, final Object dataObject, int version) throws IOException { if (SecurityUtility.skipAccessControl()) { oos.writeObject(dataObject); oos.flush(); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { oos.writeObject(dataObject); oos.flush(); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } public Object receiveObject(InputStream inputStream, ClassLoader customClassLoader, int version) throws IOException, ClassNotFoundException { ObjectInputStream objInputStream = null; Object obj = null; if (inputStream instanceof ObjectInputStreamWithClassLoader) { ((ObjectInputStreamWithClassLoader) inputStream).setClassLoader(customClassLoader); objInputStream = (ObjectInputStream) inputStream; } else if (inputStream instanceof JBossObjectInputStream) { ((JBossObjectInputStream) inputStream).setClassLoader(customClassLoader); objInputStream = (ObjectInputStream) inputStream; } else if (inputStream instanceof ObjectInputStream) { objInputStream = (ObjectInputStream) inputStream; } else { if (customClassLoader != null) { objInputStream = SerializationStreamFactory.getManagerInstance(SerializationStreamFactory.JBOSS).createInput(inputStream, customClassLoader); } else { objInputStream = SerializationStreamFactory.getManagerInstance(SerializationStreamFactory.JBOSS).createRegularInput(inputStream); } } if (SecurityUtility.skipAccessControl()) { return objInputStream.readObject(); } try { final ObjectInputStream ois = objInputStream; obj = AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return ois.readObject(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } return obj; } public String toString() { return "JBossSerializationManager[" + Integer.toHexString(hashCode()) + "]"; } } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/JBossEncryptionSerializationManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/JBossEncr0000644000175000017500000000613510473663541033365 0ustar twernertwerner/* * 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.remoting.serialization.impl.jboss; import java.io.IOException; import java.io.InputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.crypto.SealedObject; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvocationResponse; import org.jboss.remoting.marshal.encryption.EncryptionUtil; //$Id: JBossEncryptionSerializationManager.java 1399 2006-08-25 21:10:57Z asaldhana $ /** * Encrypted version of JBoss Serialization Manager * @author Anil Saldhana * @since Aug 25, 2006 * @version $Revision: 1399 $ */ public class JBossEncryptionSerializationManager extends JBossSerializationManager { public Object receiveObject(InputStream inputStream, ClassLoader customClassLoader) throws IOException, ClassNotFoundException { Object object = super.receiveObject(inputStream, customClassLoader); if(object instanceof InvocationResponse) { InvocationResponse ir = (InvocationResponse)object; Object obj = ir.getResult(); if(obj instanceof SealedObject) { try { object = new InvocationResponse(ir.getSessionId(), (EncryptionUtil.unsealObject((SealedObject)obj)), ir.isException(), ir.getPayload()); } catch (Exception e) { e.printStackTrace(); } } } return object; } public void sendObject(ObjectOutputStream oos, Object dataObject) throws IOException { if(dataObject instanceof InvocationRequest) { InvocationRequest ir = (InvocationRequest)dataObject; Object obj = ir.getParameter(); if(obj instanceof Serializable) { try { ir.setParameter(EncryptionUtil.sealObject((Serializable)obj)); } catch (Exception e) { e.printStackTrace(); } } } super.sendObject(oos, dataObject); } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/SmartCloningMarshalledValue.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/jboss/SmartClon0000644000175000017500000000341510453542107033425 0ustar twernertwerner/* * 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.remoting.serialization.impl.jboss; import java.io.IOException; import org.jboss.remoting.serialization.IMarshalledValue; import org.jboss.serial.io.MarshalledObjectForLocalCalls; import org.jboss.serial.objectmetamodel.safecloning.SafeCloningRepository; /** * * IMarshalledValue used on smart cloning/call by value operations for JBoss Serialization * @author Clebert Suconic * */ public class SmartCloningMarshalledValue extends MarshalledObjectForLocalCalls implements IMarshalledValue { public SmartCloningMarshalledValue() { super(); } public SmartCloningMarshalledValue(Object arg0, SafeCloningRepository arg1) throws IOException { super(arg0, arg1); } public SmartCloningMarshalledValue(Object arg0) throws IOException { super(arg0); } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/0000755000175000017500000000000011632407045031377 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/MarshalledValueOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/Marshalled0000644000175000017500000000721410355142433033400 0ustar twernertwerner/* * 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.remoting.serialization.impl.java; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.rmi.Remote; import java.rmi.server.RemoteObject; import java.rmi.server.RemoteStub; import java.security.AccessController; import java.security.PrivilegedAction; /** * An ObjectOutputStream subclass used by the MarshalledValue class to * ensure the classes and proxies are loaded using the thread context * class loader. Currently this does not do anything as neither class or * proxy annotations are used. * * @author Scott.Stark@jboss.org * @author Clebert.suconic@jboss.org - refactored packages only * @version $Revision: 566 $ */ public class MarshalledValueOutputStream extends ObjectOutputStream { /** * Creates a new instance of MarshalledValueOutputStream * If there is a security manager installed, this method requires a * SerializablePermission("enableSubstitution") permission to ensure it's * ok to enable the stream to do replacement of objects in the stream. */ public MarshalledValueOutputStream(OutputStream os) throws IOException { super(os); EnableReplaceObjectAction.enableReplaceObject(this); } /** * @throws java.io.IOException Any exception thrown by the underlying OutputStream. */ protected void annotateClass(Class cl) throws IOException { super.annotateClass(cl); } /** * @throws java.io.IOException Any exception thrown by the underlying OutputStream. */ protected void annotateProxyClass(Class cl) throws IOException { super.annotateProxyClass(cl); } /** * Override replaceObject to check for Remote objects that are * not RemoteStubs. */ protected Object replaceObject(Object obj) throws IOException { if((obj instanceof Remote) && !(obj instanceof RemoteStub)) { Remote remote = (Remote) obj; try { obj = RemoteObject.toStub(remote); } catch(IOException ignore) { // Let the Serialization layer try with the orignal obj } } return obj; } private static class EnableReplaceObjectAction implements PrivilegedAction { MarshalledValueOutputStream os; EnableReplaceObjectAction(MarshalledValueOutputStream os) { this.os = os; } public Object run() { os.enableReplaceObject(true); return null; } static void enableReplaceObject(MarshalledValueOutputStream os) { EnableReplaceObjectAction action = new EnableReplaceObjectAction(os); AccessController.doPrivileged(action); } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/JavaSerializationManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/JavaSerial0000644000175000017500000002030311056163227033342 0ustar twernertwerner/* * 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.remoting.serialization.impl.java; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OptionalDataException; import java.io.OutputStream; import org.jboss.logging.Logger; import org.jboss.remoting.Version; import org.jboss.remoting.loading.ObjectInputStreamWithClassLoader; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.serialization.IMarshalledValue; /** * $Id: JavaSerializationManager.java 4519 2008-08-30 06:20:07Z ron.sigal@jboss.com $ * * @author Clebert Suconic */ public class JavaSerializationManager extends SerializationManager { protected static final Logger log = Logger.getLogger(JavaSerializationManager.class); public ObjectInputStream createInput(InputStream input, ClassLoader loader) throws IOException { if(log.isTraceEnabled()) { log.trace("Creating ObjectInputStreamWithClassLoader"); } return new ObjectInputStreamWithClassLoader(input, loader); } public ObjectOutputStream createOutput(OutputStream output) throws IOException { if(log.isTraceEnabled()) { log.trace("Creating ObjectOutputStream"); } return new ClearableObjectOutputStream(output); } /** * Creates a MarshalledValue that does lazy serialization. */ public IMarshalledValue createdMarshalledValue(Object source) throws IOException { if(source instanceof IMarshalledValue) { return (IMarshalledValue) source; } else { return new JavaMarshalledValue(source); } } public IMarshalledValue createMarshalledValueForClone(Object original) throws IOException { return createdMarshalledValue(original); } public void sendObject(ObjectOutputStream oos, Object dataObject, int version) throws IOException { switch (version) { case Version.VERSION_1: case Version.VERSION_2: sendObjectVersion1_2(oos, dataObject); break; case Version.VERSION_2_2: sendObjectVersion2_2(oos, dataObject); break; default: throw new IOException("Can not process version " + version + ". " + "Supported versions: " + Version.VERSION_1 + ", " + Version.VERSION_2 + ", " + Version.VERSION_2_2); } } protected void sendObjectVersion1_2(ObjectOutputStream oos, Object dataObject) throws IOException { oos.writeObject(dataObject); oos.reset(); // to make sure stream gets reset // Stupid ObjectInputStream holds object graph // can only be set by the client/server sending a TC_RESET oos.writeObject(Boolean.TRUE); oos.flush(); oos.reset(); } protected void sendObjectVersion2_2(ObjectOutputStream oos, Object dataObject) throws IOException { oos.reset(); oos.writeObject(dataObject); oos.flush(); if (oos instanceof ClearableObjectOutputStream) { ((ClearableObjectOutputStream) oos).clear(); } } public Object receiveObject(InputStream inputStream, ClassLoader customClassLoader, int version) throws IOException, ClassNotFoundException { switch (version) { case Version.VERSION_1: case Version.VERSION_2: return receiveObjectVersion1_2(inputStream, customClassLoader); case Version.VERSION_2_2: return receiveObjectVersion2_2(inputStream, customClassLoader); default: throw new IOException("Can not process version " + version + ". " + "Supported versions: " + Version.VERSION_1 + ", " + Version.VERSION_2 + ", " + Version.VERSION_2_2); } } protected Object receiveObjectVersion1_2(InputStream inputStream, ClassLoader customClassLoader) throws IOException, ClassNotFoundException { ObjectInputStream objInputStream = null; Object obj = null; if(inputStream instanceof ObjectInputStreamWithClassLoader) { ((ObjectInputStreamWithClassLoader) inputStream).setClassLoader(customClassLoader); objInputStream = (ObjectInputStream) inputStream; } /*else if(inputStream instanceof JBossObjectInputStream) { if(((JBossObjectInputStream) inputStream).getClassLoader() == null) { ((JBossObjectInputStream) inputStream).setClassLoader(customClassLoader); } objInputStream = (ObjectInputStream) inputStream; } -- for future reference */ else if(inputStream instanceof ObjectInputStream) { objInputStream = (ObjectInputStream) inputStream; } else { if(customClassLoader != null) { objInputStream = SerializationStreamFactory.getManagerInstance(SerializationStreamFactory.JAVA).createInput(inputStream, customClassLoader); } else { objInputStream = SerializationStreamFactory.getManagerInstance(SerializationStreamFactory.JAVA).createRegularInput(inputStream); } } try { obj = objInputStream.readObject(); } catch (IOException e) { log.debug("", e); throw e; } try { objInputStream.readObject(); // for stupid ObjectInputStream reset } catch(Exception e) { /** * Putting try catch around this because if using servlet sever invoker, the previous * call is not needed, so will throw EOFException and can ignore. */ } return obj; } protected Object receiveObjectVersion2_2(InputStream inputStream, ClassLoader customClassLoader) throws IOException, ClassNotFoundException { ObjectInputStream objInputStream = null; Object obj = null; if(inputStream instanceof ObjectInputStreamWithClassLoader) { ((ObjectInputStreamWithClassLoader) inputStream).setClassLoader(customClassLoader); objInputStream = (ObjectInputStream) inputStream; } /*else if(inputStream instanceof JBossObjectInputStream) { if(((JBossObjectInputStream) inputStream).getClassLoader() == null) { ((JBossObjectInputStream) inputStream).setClassLoader(customClassLoader); } objInputStream = (ObjectInputStream) inputStream; } -- for future reference */ else if(inputStream instanceof ObjectInputStream) { objInputStream = (ObjectInputStream) inputStream; } else { if(customClassLoader != null) { objInputStream = SerializationStreamFactory.getManagerInstance(SerializationStreamFactory.JAVA).createInput(inputStream, customClassLoader); } else { objInputStream = SerializationStreamFactory.getManagerInstance(SerializationStreamFactory.JAVA).createRegularInput(inputStream); } } obj = objInputStream.readObject(); if(inputStream instanceof ObjectInputStreamWithClassLoader) { ((ObjectInputStreamWithClassLoader) inputStream).clearCache(); } return obj; } }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/MarshalledValueInputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/Marshalled0000644000175000017500000001100410774603556033405 0ustar twernertwerner/* * 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.remoting.serialization.impl.java; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectStreamClass; import java.lang.reflect.Proxy; import java.security.AccessController; import java.security.PrivilegedAction; import org.jboss.logging.Logger; /** * An ObjectInputStream subclass used by the MarshalledValue class to * ensure the classes and proxies are loaded using the thread context * class loader. * * @author Scott.Stark@jboss.org * @author Clebert.suconic@jboss.org - refactored packages only * @version $Revision: 3844 $ */ public class MarshalledValueInputStream extends ObjectInputStream { private static Logger log = Logger.getLogger(MarshalledValueInputStream.class); static boolean useClassCache = false; /** * Creates a new instance of MarshalledValueOutputStream */ public MarshalledValueInputStream(InputStream is) throws IOException { super(is); } /** * Use the thread context class loader to resolve the class * * @throws java.io.IOException Any exception thrown by the underlying OutputStream. */ protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException { String className = v.getName(); Class resolvedClass = null; if(resolvedClass == null) { ClassLoader loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); try { resolvedClass = Class.forName(className, false, loader); } catch(ClassNotFoundException e) { /* Use the super.resolveClass() call which will resolve array classes and primitives. We do not use this by default as this can result in caching of stale values across redeployments. */ resolvedClass = super.resolveClass(v); } } return resolvedClass; } protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException { if(log.isTraceEnabled()) { StringBuffer tmp = new StringBuffer("["); for(int i = 0; i < interfaces.length; i ++) { if(i > 0) { tmp.append(','); } tmp.append(interfaces[i]); } tmp.append(']'); log.trace("resolveProxyClass called, ifaces=" + tmp.toString()); } // Load the interfaces from the cache or thread context class loader ClassLoader loader = null; Class[] ifaceClasses = new Class[interfaces.length]; for(int i = 0; i < interfaces.length; i++) { Class iface = null; String className = interfaces[i]; // Check the proxy cache if it exists // Load the interface class using the thread context ClassLoader if(iface == null) { if(loader == null) { loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); } iface = Class.forName(className, false, loader); } ifaceClasses[i] = iface; } return Proxy.getProxyClass(loader, ifaceClasses); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/JavaMarshalledValue.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/JavaMarsha0000644000175000017500000001354510355142433033345 0ustar twernertwerner/* * 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.remoting.serialization.impl.java; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.util.Arrays; import org.jboss.remoting.serialization.RemotingMarshalledValue; /** * A simple replacement for the RMI MarshalledObject that uses the thread * context class loader for resolving classes and proxies. This currently does * not support class annotations and dynamic class loading. * * @author Scott.Stark@jboss.org * @author Clebert.suconic@jboss.org (refactored packages and names only) * @version $Revision: 566 $ */ public class JavaMarshalledValue extends RemotingMarshalledValue implements java.io.Externalizable { /** * Serial Version Identifier. */ private static final long serialVersionUID = -1527598981234110311L; /** * The serialized form of the value. If serializedForm is * null then the object marshalled was a null * reference. */ private byte[] serializedForm; /** * The RMI MarshalledObject hash of the serializedForm array */ private int hashCode; /** * Exposed for externalization. */ public JavaMarshalledValue() { super(); } public JavaMarshalledValue(Object obj) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); MarshalledValueOutputStream mvos = new MarshalledValueOutputStream(baos); mvos.writeObject(obj); mvos.flush(); serializedForm = baos.toByteArray(); mvos.close(); // Use the java.rmi.MarshalledObject hash code calculation int hash = 0; for(int i = 0; i < serializedForm.length; i++) { hash = 31 * hash + serializedForm[i]; } hashCode = hash; } public Object get() throws IOException, ClassNotFoundException { if(serializedForm == null) { return null; } ByteArrayInputStream bais = new ByteArrayInputStream(serializedForm); MarshalledValueInputStream mvis = new MarshalledValueInputStream(bais); Object retValue = mvis.readObject(); mvis.close(); return retValue; } public byte[] toByteArray() { return serializedForm; } public int size() { int size = serializedForm != null ? serializedForm.length : 0; return size; } /** * Return a hash code for the serialized form of the value. * * @return the serialized form value hash. */ public int hashCode() { return hashCode; } public boolean equals(Object obj) { if(this == obj) { return true; } boolean equals = false; if(obj instanceof JavaMarshalledValue) { JavaMarshalledValue mv = (JavaMarshalledValue) obj; if(serializedForm == mv.serializedForm) { equals = true; } else { equals = Arrays.equals(serializedForm, mv.serializedForm); } } return equals; } /** * The object implements the readExternal method to restore its * contents by calling the methods of DataInput for primitive * types and readObject for objects, strings and arrays. The * readExternal method must read the values in the same sequence * and with the same types as were written by writeExternal. * * @param in the stream to read data from in order to restore the object * @throws IOException if I/O errors occur * @throws ClassNotFoundException If the class for an object being * restored cannot be found. */ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { int length = in.readInt(); serializedForm = null; if(length > 0) { serializedForm = new byte[length]; in.readFully(serializedForm); } hashCode = in.readInt(); } /** * The object implements the writeExternal method to save its contents * by calling the methods of DataOutput for its primitive values or * calling the writeObject method of ObjectOutput for objects, strings, * and arrays. * * @param out the stream to write the object to * @throws IOException Includes any I/O exceptions that may occur * @serialData Overriding methods should use this tag to describe * the data layout of this Externalizable object. * List the sequence of element types and, if possible, * relate the element to a public/protected field and/or * method of this Externalizable class. */ public void writeExternal(ObjectOutput out) throws IOException { int length = serializedForm != null ? serializedForm.length : 0; out.writeInt(length); if(length > 0) { out.write(serializedForm); } out.writeInt(hashCode); } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/JavaEncryptionSerializationManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/JavaEncryp0000644000175000017500000000473610623460053033373 0ustar twernertwerner/* * 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.remoting.serialization.impl.java; import java.io.IOException; import java.io.InputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.crypto.SealedObject; import org.jboss.remoting.marshal.encryption.EncryptionUtil; //$Id: JavaEncryptionSerializationManager.java 2412 2007-05-19 02:25:47Z rsigal $ /** * Seals/Unseals Serialized Objects * @author Anil Saldhana * @since Aug 25, 2006 * @version $Revision: 2412 $ */ public class JavaEncryptionSerializationManager extends JavaSerializationManager { public Object receiveObject(InputStream inputStream, ClassLoader customClassLoader, int version) throws IOException, ClassNotFoundException { Object obj = super.receiveObject(inputStream, customClassLoader, version); if(obj instanceof SealedObject) { try { obj = EncryptionUtil.unsealObject((SealedObject)obj); } catch (Exception e) { e.printStackTrace(); } } return obj; } public void sendObject(ObjectOutputStream oos, Object dataObject, int version) throws IOException { if(dataObject instanceof Serializable) try { dataObject = EncryptionUtil.sealObject((Serializable)dataObject); } catch (Exception e) { e.printStackTrace(); } super.sendObject(oos, dataObject, version); } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/ClearableObjectOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/impl/java/ClearableO0000644000175000017500000000620011413660476033317 0ustar twernertwerner /* * 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.remoting.serialization.impl.java; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.jboss.logging.Logger; import org.jboss.remoting.util.SecurityUtility; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Aug 27, 2008 *

          */ public class ClearableObjectOutputStream extends ObjectOutputStream { protected static Logger log = Logger.getLogger(ClearableObjectOutputStream.class); protected static Method clearMethod; protected static Object[] PARAMS = new Object[]{}; static { try { clearMethod = getDeclaredMethod(ObjectOutputStream.class, "clear", new Class[]{}); } catch (SecurityException e) { log.error(e.getMessage(), e); } catch (NoSuchMethodException e) { log.error(e.getMessage(), e); } } public ClearableObjectOutputStream(OutputStream out) throws IOException { super(out); } public void clear() { try { clearMethod.invoke(this, PARAMS); } catch (Throwable e) { log.error(e.getMessage(), e); } } static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/SerializationStreamFactoryMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/SerializationStreamF0000644000175000017500000000260510355142433033540 0ustar twernertwerner/* * 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.remoting.serialization; /** * $Id: SerializationStreamFactoryMBean.java 566 2005-12-30 05:26:51Z telrod $ * * @author Tom Elrod * @author Clebert Suconic */ public interface SerializationStreamFactoryMBean { public String getManager(); public void setManager(String manager) throws Exception; } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/RemotingMarshalledValue.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/RemotingMarshalledVa0000644000175000017500000000317710400663336033517 0ustar twernertwerner/* * 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.remoting.serialization; import java.io.IOException; /** * Empty implementation of a MarshalledValue, as {@link SerializationManager} is now managing creationg * of this object. * We need this class just as a hook for implementation on JBossAS * $Id: RemotingMarshalledValue.java 741 2006-02-27 20:53:50Z csuconic $ * * @author Clebert Suconic */ public abstract class RemotingMarshalledValue implements IMarshalledValue { /** * The object has to be unserialized only when the first get is executed. */ public abstract Object get() throws IOException, ClassNotFoundException; } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/IMarshalledValue.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/IMarshalledValue.jav0000644000175000017500000000241510400663336033402 0ustar twernertwerner/* * 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.remoting.serialization; import java.io.IOException; /** * Tag interface for MarshalledValues * @author Clebert Suconic */ public interface IMarshalledValue { public Object get() throws IOException, ClassNotFoundException; } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/SerializationManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/SerializationManager0000644000175000017500000000673710774603503033570 0ustar twernertwerner/* * 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.remoting.serialization; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.security.AccessController; import java.security.PrivilegedAction; import org.jboss.remoting.Version; /** * Controls the creation of ObjectInputStream, ObjectOutputStream. *

          * It is important that implementation of this class needs to be stateless. * $Id: SerializationManager.java 3843 2008-04-02 04:10:43Z ron.sigal@jboss.com $ * * @author Clebert Suconic */ public abstract class SerializationManager { public ObjectInputStream createRegularInput(InputStream input) throws IOException { ClassLoader tcl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); return createInput(input, tcl); } public abstract ObjectInputStream createInput(InputStream input, ClassLoader loader) throws IOException; public abstract ObjectOutputStream createOutput(OutputStream output) throws IOException; /** * Creates a MarshalledValue that does lazy serialization. */ public abstract IMarshalledValue createdMarshalledValue(Object source) throws IOException; public void sendObject(ObjectOutputStream output, Object dataObject) throws IOException { int version = Version.getDefaultVersion(); sendObject(output, dataObject, version); } public abstract void sendObject(ObjectOutputStream output, Object dataObject, int version) throws IOException; /** Used in call by value operations. * This will use the most effective way */ public abstract IMarshalledValue createMarshalledValueForClone(Object original) throws IOException; /** * This was a refactory of a method usually existent on {@link org.jboss.remoting.marshal.serializable.SerializableUnMarshaller}. * That's why we are using InputStream instead of ObjectInputStream as a parameter here. */ public Object receiveObject(InputStream input, ClassLoader customClassLoader) throws IOException, ClassNotFoundException { int version = Version.getDefaultVersion(); return receiveObject(input, customClassLoader, version); } public abstract Object receiveObject(InputStream input, ClassLoader customClassLoader, int version) throws IOException, ClassNotFoundException; } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/ClassLoaderUtility.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/ClassLoaderUtility.j0000644000175000017500000001156711011157620033452 0ustar twernertwerner/* * 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.remoting.serialization; import java.security.AccessController; import java.security.PrivilegedAction; /** * @author Clebert Suconic */ public class ClassLoaderUtility { /** * Tries to load the class from the current thread's context class loader. If * not successful, tries to load the class from the current instance. * * @param classname Desired class. * @param clazz Class object used to obtain a class loader * if no context class loader is available. * @return Class, or null on failure. */ public static Class loadClass(String classname, final Class clazz) throws ClassNotFoundException { ClassLoader loader; try { loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); if (loader != null) { return Class.forName(classname, false, loader); } } catch (Throwable t) { } if (clazz != null) { try { loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return clazz.getClassLoader(); } }); if (loader != null) { return Class.forName(classname, false, loader); } } catch (Throwable t) { } } try { loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return ClassLoader.getSystemClassLoader(); } }); if (loader != null) { return Class.forName(classname, false, loader); } } catch (Throwable t) { } throw new ClassNotFoundException(classname); } /** * Tries to load the class from the passed class' classloader, then current thread's context class loader. * * @param clazz Class object used to obtain a class loader * if no context class loader is available. * @param classname Desired class. * @return Class, or null on failure. */ public static Class loadClass(final Class clazz, String classname) throws ClassNotFoundException { ClassLoader loader; if (clazz != null) { try { loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return clazz.getClassLoader(); } }); if (loader != null) { return Class.forName(classname, false, loader); } } catch (Throwable t) { } } try { loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); if (loader != null) { return Class.forName(classname, false, loader); } } catch (Throwable t) { } try { loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return ClassLoader.getSystemClassLoader(); } }); if (loader != null) { return Class.forName(classname, false, loader); } } catch (Throwable t) { } throw new ClassNotFoundException(classname); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/SerializationStreamFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/serialization/SerializationStreamF0000644000175000017500000001702311171061302033530 0ustar twernertwerner/* * 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.remoting.serialization; import org.jboss.logging.Logger; import org.jboss.remoting.serialization.impl.java.JavaEncryptionSerializationManager; import org.jboss.remoting.serialization.impl.java.JavaSerializationManager; import org.jboss.remoting.serialization.impl.jboss.JBossEncryptionSerializationManager; import org.jboss.remoting.util.SecurityUtility; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; /** * This factory is for defining the Object stream implemenations to be used * along with creating those implemenations for use. The main function will * be to return instance of ObjectOutput and ObjectInput. By default, the implementations * will be java.io.ObjectOutputStream and java.io.ObjectInputStream. * * @author Tom Elrod * @author Clebert Suconic */ public class SerializationStreamFactory implements SerializationStreamFactoryMBean { protected static final Logger log = Logger.getLogger(SerializationStreamFactory.class); private static Map managers = new HashMap(); public static final String DEFAULT = "default"; public static final String JAVA = "java"; public static final String JBOSS = "jboss"; public static final String JAVA_ENCRYPT = "javaencrypt"; public static final String JBOSS_ENCRYPT = "jbossencrypt"; static { try { String defaultValue = JavaSerializationManager.class.getName(); String managerClassName = getSystemProperty("SERIALIZATION", defaultValue); setManagerClassName(DEFAULT, managerClassName); } catch(Exception e) { log.error(e.getMessage(), e); } try { setManagerClassName(JAVA, JavaSerializationManager.class.getName()); } catch(Exception e) { log.error(e.getMessage(), e); } try { setManagerClassName(JBOSS, "org.jboss.remoting.serialization.impl.jboss.JBossSerializationManager"); } catch(Throwable e) // catching throwable as if jboss serialization not on classpath, will throw NoClassDefFoundError { log.debug("Could not load JBoss Serialization. Use Java Serialization default."); log.trace(e); } try { setManagerClassName(JAVA_ENCRYPT, JavaEncryptionSerializationManager.class.getName()); } catch(Throwable e) // catching throwable as if jboss serialization not on classpath, will throw NoClassDefFoundError { log.debug("Could not load Java Encrypted Serialization. Use Java Serialization default."); log.trace(e); } try { setManagerClassName(JBOSS_ENCRYPT, JBossEncryptionSerializationManager.class.getName()); } catch(Throwable e) // catching throwable as if jboss serialization not on classpath, will throw NoClassDefFoundError { log.debug("Could not load JBoss Encrypted Serialization. Use Java Serialization default."); log.trace(e); } } /** * The fully qualified classname of the DefaultSerializationManager implementation. * * @param className */ public static void setManagerClassName(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException { setManagerClassName(DEFAULT, className); } /** * The fully qualified classname of the DefaultSerializationManager implementation. * * @param className */ public static void setManagerClassName(String key, String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException { loadObjectManagerClass(key, className); } public String getManager() { return getManager(DEFAULT); } public String getManager(String key) { SerializationManager manager = (SerializationManager) managers.get(key); if(manager == null) { return null; } else { return manager.getClass().getName(); } } public void setManager(String manager) throws Exception { setManager(DEFAULT, manager); } public void setManager(String key, String manager) throws Exception { setManagerClassName(key, manager); } /** * Loads the implementation class for ObjectOutput as specified by the object output class name. Will also load * the constructor and cache it to be used when creating the actual implementation instance. */ private static void loadObjectManagerClass(String key, String managerClassName) throws ClassNotFoundException, IllegalAccessException, InstantiationException { Class managerClass = ClassLoaderUtility.loadClass(SerializationStreamFactory.class, managerClassName); SerializationManager manager = (SerializationManager) managerClass.newInstance(); if(managers.get(key) != null) { managers.remove(key); } managers.put(key, manager); } /** * @return the SerializationManager instance corresponding to the given key. If key is null, * "java" is assumed. The method never returns null, if there's no SerializationManager * associated with the given key, the method throws exception. * * @throws IOException if there's no corresponding SerializationManager instance. */ public static SerializationManager getManagerInstance(String key) throws IOException { if(key == null) { key = JAVA; } SerializationManager manager = (SerializationManager) managers.get(key); if (manager == null) { throw new IOException("Unknown serialization type: " + key); } return manager; } public static SerializationManager getManagerInstance() throws IOException { return getManagerInstance(DEFAULT); } static private String getSystemProperty(final String name, final String defaultValue) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name, defaultValue); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name, defaultValue); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/0000755000175000017500000000000011632407052026302 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/oneway/0000755000175000017500000000000011632407051027603 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/oneway/OnewayServer.java0000644000175000017500000001207510363004341033077 0ustar twernertwerner/* * 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.remoting.samples.oneway; import javax.management.MBeanServer; 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; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class OnewayServer { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; public void setupServer(String locatorURI) throws Exception { // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); Connector connector = new Connector(locator); // creates all the connector's needed resources, such as the server invoker connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); connector.start(); } /** * 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; OnewayServer server = new OnewayServer(); try { server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); return null; } /** * 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 } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/oneway/OnewayClient.java0000644000175000017500000000673010433770344033063 0ustar twernertwerner/* * 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.remoting.samples.oneway; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * Simple test client to make oneway invocations on remoting server. * * @author Tom Elrod */ public class OnewayClient { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; public void makeInvocation(String locatorURI) throws Throwable { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); /** * Make oneway invocation. Since this is a oneway invocation, * the return is void. * * With this invokeOneway signature, it uses the current thread to execute * the invocation on the server and will not return until the invocation request * has been placed into a worker thread pool on the server. This ensures that * the call at least made it to the server. */ String payload1 = "Oneway call 1."; System.out.println("Making oneway invocation with payload of '" + payload1 + "'"); remotingClient.invokeOneway(payload1); /** * This call is the same as the one above, except the last parameter will * place the invocation request into a worker thread pool on the client and * return immediately. The worker thread will then make the invocation * on the remoting server (which means caller will not be aware if was a * problem making the actual invocation on the server). */ String payload2 = "Oneway call 2."; System.out.println("Making oneway invocation with payload of '" + payload2 + "'"); remotingClient.invokeOneway(payload2, null, true); } /** * 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; OnewayClient client = new OnewayClient(); try { client.makeInvocation(locatorURI); } catch(Throwable e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/http/0000755000175000017500000000000011632407051027260 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/http/WebInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/http/WebInvocationHandler.0000644000175000017500000001107710366322517033342 0ustar twernertwerner/* * 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.remoting.samples.http; import java.util.Map; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.remoting.callback.InvokerCallbackHandler; /** * Remoting handler implementation for http invocations to * show how to return different data to client. * * @author Tom Elrod */ public class WebInvocationHandler implements ServerInvocationHandler { // Pre-defined returns to be sent back to client based on type of request. public static final String RESPONSE_VALUE = "This is the return to simple text based http invocation."; public static final ComplexObject OBJECT_RESPONSE_VALUE = new ComplexObject(5, "dub", false); public static final String HTML_PAGE_RESPONSE = "Test HTML page" + "

          HTTP/Servlet Test HTML page

          This is a simple page served for test." + "

          Should show up in browser or via invoker client"; // Different request types that client may make public static final String NULL_RETURN_PARAM = "return_null"; public static final String OBJECT_RETURN_PARAM = "return_object"; public static final String STRING_RETURN_PARAM = "return_string"; /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request from client is: " + invocation.getParameter()); if(NULL_RETURN_PARAM.equals(invocation.getParameter())) { return null; } else if(invocation.getParameter() instanceof ComplexObject) { return OBJECT_RESPONSE_VALUE; } else if(STRING_RETURN_PARAM.equals(invocation.getParameter())) { Map responseMetadata = invocation.getReturnPayload(); responseMetadata.put(HTTPMetadataConstants.RESPONSE_CODE, new Integer(207)); responseMetadata.put(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE, "Custom response code and message from remoting server"); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } else { return HTML_PAGE_RESPONSE; } } /** * 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 } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/http/SimpleServer.java0000644000175000017500000000637410366044156032563 0ustar twernertwerner/* * 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.remoting.samples.http; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.transport.Connector; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class SimpleServer { // Default locator values private static String transport = "http"; private static String host = "localhost"; private static int port = 5400; public void setupServer(String locatorURI) throws Exception { // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); Connector connector = new Connector(locator); // creates all the connector's needed resources, such as the server invoker connector.create(); // create the handler to receive the invocation request from the client for processing ServerInvocationHandler invocationHandler = new WebInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } String locatorURI = transport + "://" + host + ":" + port; SimpleServer server = new SimpleServer(); try { server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/http/ComplexObject.java0000644000175000017500000000430310366044156032667 0ustar twernertwerner/* * 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.remoting.samples.http; import java.io.Serializable; /** * @author Tom Elrod */ public class ComplexObject implements Serializable { public int i = 42; public String s = "test"; public boolean b = true; public byte[] bytes = new byte[0]; public ComplexObject() { } public ComplexObject(int i, String s, boolean b) { this.i = i; this.s = s; this.b = b; } public ComplexObject(int i, String s, boolean b, int byteSize) { this(i, s, b); bytes = new byte[byteSize]; } public void setBytes(byte[] bytes) { this.bytes = bytes; } public int getSize() { return bytes.length; } public String toString() { return "ComplexObject (i = " + i + ", s = " + s + ", b = " + b + ", bytes.length = " + bytes.length + ")"; } public boolean equals(Object o) { if(o instanceof ComplexObject) { ComplexObject co = (ComplexObject) o; if(co.i == i && co.s.equals(s) && co.b == b) { return true; } else { return false; } } else { return false; } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/http/SimpleClient.java0000644000175000017500000001033210433770344032520 0ustar twernertwerner/* * 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.remoting.samples.http; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import java.util.HashMap; import java.util.Map; /** * Simple test client to make an invocation on remoting server. * * @author Tom Elrod */ public class SimpleClient { // Default locator values private static String transport = "http"; private static String host = "localhost"; private static int port = 5400; public void makeInvocation(String locatorURI) throws Throwable { // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); // make invocation on remoting server and send complex data object // by default, the remoting http client invoker will use method type of POST, // which is needed when ever sending objects to the server. So no metadata map needs // to be passed to the invoke() method. Object response = remotingClient.invoke(new ComplexObject(2, "foo", true), null); System.out.println("\nResponse from remoting http server when making http POST request and sending a complex data object:\n" + response); Map metadata = new HashMap(); // set the metadata so remoting client knows to use http GET method type metadata.put("TYPE", "GET"); // not actually sending any data to the remoting server, just want to get its response response = remotingClient.invoke((Object) null, metadata); System.out.println("\nResponse from remoting http server when making GET request:\n" + response); // now set type back to POST and send a plain text based request metadata.put("TYPE", "POST"); response = remotingClient.invoke(WebInvocationHandler.STRING_RETURN_PARAM, metadata); System.out.println("\nResponse from remoting http server when making http POST request and sending a text based request:\n" + response); // notice are getting custom response code and message set by web invocation handler Integer responseCode = (Integer) metadata.get(HTTPMetadataConstants.RESPONSE_CODE); String responseMessage = (String) metadata.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE); System.out.println("Response code from server: " + responseCode); System.out.println("Response message from server: " + responseMessage); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } String locatorURI = transport + "://" + host + ":" + port; SimpleClient client = new SimpleClient(); try { client.makeInvocation(locatorURI); } catch(Throwable e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/0000755000175000017500000000000011632407052030036 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/statistics/0000755000175000017500000000000011632407052032230 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/statistics/CallbackServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/statistics/Callba0000644000175000017500000001771710527174703033354 0ustar twernertwerner/* * 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.remoting.samples.callback.statistics; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; 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.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; 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, which will generate * callback messages upon callback listeners being added. * * @author Tom Elrod */ public class CallbackServer { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; // counter indicating the number of callbacks generated private static int callbackCounter = 1; // remoting server connector private Connector connector = null; // String to be returned from invocation handler upon client invocation calls. private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; /** * Sets up target remoting server. * * @param locatorURI * @throws Exception */ public void setupServer(String locatorURI) 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(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", invocationHandler); connector.start(); } /** * Shuts down the server */ public void shutdownServer() { connector.stop(); connector.destroy(); } /** * Can pass transport and port to be used as parameters. */ 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; CallbackServer server = new CallbackServer(); try { server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. When callback clients are registered, will * generate callbacks periodically. */ public static class SampleInvocationHandler implements ServerInvocationHandler, Runnable, CallbackListener { // list of callback listeners registered private List listeners = new ArrayList(); // flag to indicate when should generate callback messages private boolean shouldGenerateCallbacks = false; public SampleInvocationHandler() { // will start a new thread for generating callbacks. Thread callbackThread = new Thread(this); callbackThread.setDaemon(true); callbackThread.start(); } /** * Called by the remoting server to handle the invocation from client. */ public Object invoke(InvocationRequest invocation) throws Throwable { return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. */ public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("Adding callback listener."); listeners.add(callbackHandler); shouldGenerateCallbacks = true; } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. */ public void removeListener(InvokerCallbackHandler callbackHandler) { System.out.println("Removing callback listener."); listeners.remove(callbackHandler); if(listeners.size() == 0) { shouldGenerateCallbacks = false; } } /** * Will generate callback messages every second while shouldGenerateCallbacks * flag is true. */ public void run() { // keep looping while waiting to fire callbacks. while(true) { while(shouldGenerateCallbacks) { // create new callback message Callback callback = new Callback("Callback " + callbackCounter + ": This is the payload of callback invocation."); System.out.println("sending callback: " + callbackCounter); // Register as listener, pass callback id, and ask Remoting to handle acknowledgements. HashMap returnPayload = new HashMap(); returnPayload.put(ServerInvokerCallbackHandler.CALLBACK_LISTENER, this); returnPayload.put(ServerInvokerCallbackHandler.CALLBACK_ID, new Integer(callbackCounter++)); returnPayload.put(ServerInvokerCallbackHandler.REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS, "true"); callback.setReturnPayload(returnPayload); Iterator itr = listeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } } // sleep for a second before firing next callback message try { Thread.sleep(1000); } catch(InterruptedException e) { } } // sleep for a second before while waiting for flag to be set try { Thread.sleep(1000); } catch(InterruptedException e) { } } } public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} public void acknowledgeCallback(InvokerCallbackHandler callbackHandler, Object callbackId, Object response) { System.out.println("received acknowledgement for callback: " + callbackId); } } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/statistics/CallbackClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/statistics/Callba0000644000175000017500000000762110527174703033345 0ustar twernertwerner/* * 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.remoting.samples.callback.statistics; import java.util.HashMap; 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; /** * Sample client that demonstrates CallbackPoller tuning statistics. * * @author Ron Sigal * @author Tom Elrod */ public class CallbackClient { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; /** * Registers callback listener and asks CallbackPoller to print statistics. */ public void getPolledCallbacks(String locatorURI) throws Throwable { System.out.println("Calling remoting server with locator uri of: " + locatorURI); InvokerLocator locator = new InvokerLocator(locatorURI); Client client = new Client(locator); client.connect(); // Registter callback handler and tell CallbackPoller to report statistics. CallbackHandler callbackHandler = new CallbackHandler(); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.REPORT_STATISTICS, "true"); client.addListener(callbackHandler, metadata); // Wait for callbacks to received, processed, and acknowledged. Thread.sleep(20000); // remove callback handler from server client.removeListener(callbackHandler); client.disconnect(); } /** * Can pass transport and port to be used as parameters. */ 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; CallbackClient callbackClient = new CallbackClient(); try { callbackClient.getPolledCallbacks(locatorURI); } catch(Throwable e) { e.printStackTrace(); } } /** * Our implementation of the InvokerCallbackHandler. Simply * prints out the callback object's message upon receiving it. */ public class CallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { // Slow down callback handling so callbacks build up in CallbackPoller. try { Thread.sleep(1000); } catch (InterruptedException e) {} System.out.println("Received push callback."); System.out.println("Received callback value of: " + callback.getCallbackObject()); System.out.println("Received callback server invoker of: " + callback.getServerLocator()); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/acknowledgement/0000755000175000017500000000000011632407052033205 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/acknowledgement/CallbackAcknowledgeClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/acknowledgement/C0000644000175000017500000002315010527036161033314 0ustar twernertwerner/* * 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. */ /** * Demonstrates Callback acknowledgements. * * @author Ron Sigal *

          * Copyright (c) 2006 *

          */ package org.jboss.remoting.samples.callback.acknowledgement; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; 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; public class CallbackAcknowledgeClient { private static String transport = "socket"; private static String host; private static int port = 5401; private Client client; /** * 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]); } try { host = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e1) { System.err.println("cannot get local host name"); return; } String locatorURI = transport + "://" + host + ":" + port; CallbackAcknowledgeClient acknowledgeClient = new CallbackAcknowledgeClient(); try { acknowledgeClient.createRemotingClient(locatorURI); acknowledgeClient.testPullCallbackAcknowledgements(); acknowledgeClient.testPolledCallbackApplicationAcknowledgements(); acknowledgeClient.testPolledCallbackRemotingAcknowledgements(); acknowledgeClient.testPushCallbackApplicationAcknowledgements(); acknowledgeClient.testPushCallbackRemotingAcknowledgements(); acknowledgeClient.disconnectRemotingClient(); } catch(Throwable e) { e.printStackTrace(); } System.out.println("done."); } public void createRemotingClient(String locatorURI) throws Exception { client = new Client(new InvokerLocator(locatorURI)); client.connect(); } public void disconnectRemotingClient() { if (client != null) client.disconnect(); } /** * In this test, the connection is configured for pull callbacks, and * acknowledgements are made by an explicit call to Client.acknowledgeCallback() * after the callbacks have been received. */ public void testPullCallbackAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new NonAcknowledgingCallbackHandler(); client.addListener(callbackHandler); // Request callbacks from server. client.invoke(CallbackAcknowledgeServer.APPLICATION_ACKNOWLDEGEMENTS); // Get callbacks. List callbacks = client.getCallbacks(callbackHandler); // Create responses. ArrayList responses = new ArrayList(callbacks.size()); Iterator it = callbacks.iterator(); while (it.hasNext()) { Callback callback = (Callback) it.next(); System.out.println("received pull callback: " + callback.getParameter()); responses.add(callback.getParameter() + ": acknowledged"); } // Acknowledge callbacks. client.acknowledgeCallbacks(callbackHandler, callbacks, responses); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } } /** * 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. Acknowledgements are made from * TestCallbackHandler.handleCallback() by an explicit call to * Client.acknowledgeCallback() after the callbacks have been received. */ public void testPolledCallbackApplicationAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new AcknowledgingCallbackHandler(client); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "1000"); client.addListener(callbackHandler, metadata); // Request callbacks from server. client.invoke(CallbackAcknowledgeServer.APPLICATION_ACKNOWLDEGEMENTS); Thread.sleep(2000); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } } /** * 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. Acknowledgements are handled implicitly * by Remoting. */ public void testPolledCallbackRemotingAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new NonAcknowledgingCallbackHandler(); HashMap metadata = new HashMap(); metadata.put(CallbackPoller.CALLBACK_POLL_PERIOD, "1000"); client.addListener(callbackHandler, metadata); // Request callbacks from server. client.invoke(CallbackAcknowledgeServer.REMOTING_ACKNOWLDEGEMENTS); Thread.sleep(2000); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } } /** * In this test the connection is configured for true push callbacks. * Acknowledgements are made from TestCallbackHandler.handleCallback() * by an explicit call to Client.acknowledgeCallback() after the callbacks * have been received. */ public void testPushCallbackApplicationAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new AcknowledgingCallbackHandler(client); client.addListener(callbackHandler, null, null, true); // Request callbacks from servrr. client.invoke(CallbackAcknowledgeServer.APPLICATION_ACKNOWLDEGEMENTS); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } } /** * In this test the connection is configured for true push callbacks, and * Acknowledgements are handled implicitly by Remoting. */ public void testPushCallbackRemotingAcknowledgements() { try { // Register callback handler. InvokerCallbackHandler callbackHandler = new NonAcknowledgingCallbackHandler(); client.addListener(callbackHandler, null, null, true); // Request callbacks from server. client.invoke(CallbackAcknowledgeServer.REMOTING_ACKNOWLDEGEMENTS); // Unregister callback handler. client.removeListener(callbackHandler); } catch (Throwable e) { System.out.println("failure: " + e.getMessage()); } } static class NonAcknowledgingCallbackHandler implements InvokerCallbackHandler { public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("received push callback: " + callback.getParameter()); } } static class AcknowledgingCallbackHandler implements InvokerCallbackHandler { private Client client; public AcknowledgingCallbackHandler(Client client) { this.client = client; } public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("received push callback: " + callback.getParameter()); Object response = callback.getParameter() + ": acknowledged"; try { client.acknowledgeCallback(this, callback, response); } catch (Throwable e) { System.out.println("Unable to acknowledge callback: " + callback.getParameter()); } } } } ././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/acknowledgement/CallbackAcknowledgeServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/acknowledgement/C0000644000175000017500000001214410527036161033315 0ustar twernertwerner/* * 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. */ /** * Demonstrates Callback acknowledgements. * * @author Ron Sigal *

          * Copyright (c) 2006 *

          */ package org.jboss.remoting.samples.callback.acknowledgement; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.HashMap; import javax.management.MBeanServer; 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.InvokerCallbackHandler; import org.jboss.remoting.callback.ServerInvokerCallbackHandler; import org.jboss.remoting.transport.Connector; import org.jboss.util.id.GUID; public class CallbackAcknowledgeServer { public static final String APPLICATION_ACKNOWLDEGEMENTS = "applicationAcknowledgements"; public static final String REMOTING_ACKNOWLDEGEMENTS = "remotingAcknowledgements"; private static String transport = "socket"; private static String host; private static int port = 5401; private Connector connector; /** * Can pass transport and port to be used as parameters. * Default to "socket" and 5401. * * @param args */ public static void main(String[] args) { if(args != null && args.length == 2) { transport = args[0]; port = Integer.parseInt(args[1]); } try { host = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e1) { System.err.println("cannot get local host name"); return; } String locatorURI = transport + "://" + host + ":" + port; CallbackAcknowledgeServer server = new CallbackAcknowledgeServer(); try { server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } public void setupServer(String locatorURI) throws Exception { connector = new Connector(new InvokerLocator(locatorURI)); connector.start(); connector.addInvocationHandler("test", new TestInvoocationHandler()); } static class TestInvoocationHandler implements ServerInvocationHandler, CallbackListener { InvokerCallbackHandler callbackHandler; int counter; 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); Callback cb = new Callback("callback " + ++counter); // Register as listener and pass callback id. HashMap returnPayload = new HashMap(); returnPayload.put(ServerInvokerCallbackHandler.CALLBACK_LISTENER, this); returnPayload.put(ServerInvokerCallbackHandler.CALLBACK_ID, new GUID()); cb.setReturnPayload(returnPayload); if (REMOTING_ACKNOWLDEGEMENTS.equals(command)) { returnPayload.put(ServerInvokerCallbackHandler.REMOTING_ACKNOWLEDGES_PUSH_CALLBACKS, "true"); } callbackHandler.handleCallback(cb); return null; } public void addListener(InvokerCallbackHandler callbackHandler) { this.callbackHandler = callbackHandler; } public void removeListener(InvokerCallbackHandler callbackHandler) {} /** * callbackSent() is called to acknowledgement the sending of a callback. */ public void acknowledgeCallback(InvokerCallbackHandler callbackHandler, Object callbackId, Object response) { System.out.println("received acknowledgment for callback: " + callbackId); System.out.println("response: " + response); System.out.println(""); } } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/CallbackServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/CallbackServer.ja0000644000175000017500000001757210365771674033271 0ustar twernertwerner/* * 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.remoting.samples.callback; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; 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, which will generate * callback messages upon callback listeners being added. * * @author Tom Elrod */ public class CallbackServer { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; // counter indicating the number of callbacks generated private static int callbackCounter = 1; // remoting server connector private Connector connector = null; // String to be returned from invocation handler upon client invocation calls. private static final String RESPONSE_VALUE = "This is the return to SampleInvocationHandler invocation"; /** * Sets up target remoting server. * * @param locatorURI * @throws Exception */ public void setupServer(String locatorURI) 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(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); connector.start(); } /** * Shuts down the server */ public void shutdownServer() { connector.stop(); connector.destroy(); } /** * 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; CallbackServer server = new CallbackServer(); try { server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. When callback client's are registered, will * generate callbacks periodically. */ public static class SampleInvocationHandler implements ServerInvocationHandler, Runnable { // list of callback listeners registered private List listeners = new ArrayList(); // flag to indicate when should generate callback messages private boolean shouldGenerateCallbacks = false; public SampleInvocationHandler() { // will start a new thread for generating callbacks. Thread callbackThread = new Thread(this); callbackThread.setDaemon(true); callbackThread.start(); } /** * called by the remoting server to handle the invocation from client. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("Adding callback listener."); listeners.add(callbackHandler); shouldGenerateCallbacks = true; } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { System.out.println("Removing callback listener."); listeners.remove(callbackHandler); if(listeners.size() == 0) { shouldGenerateCallbacks = false; } } /** * Will generate callback messages every second while shouldGenerateCallbacks * flag is true. */ public void run() { // keep looping while waiting to fire callbacks. while(true) { while(shouldGenerateCallbacks) { // create new callback message Callback callback = new Callback("Callback " + callbackCounter++ + ": 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(); } } // sleep for a second before firing next callback message try { Thread.currentThread().sleep(1000); } catch(InterruptedException e) { } } // sleep for a second before while waiting for flag to be set try { Thread.currentThread().sleep(1000); } catch(InterruptedException e) { } } } /** * 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 } } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/CallbackClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/callback/CallbackClient.ja0000644000175000017500000001707110433770344033220 0ustar twernertwerner/* * 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.remoting.samples.callback; 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 java.util.Iterator; import java.util.List; /** * Sample client showing how to register for callbacks from remoting server. * The callback server we will make invocations to will generate random * callback messages that we can receive. * * @author Tom Elrod */ public class CallbackClient { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private Client remotingClient; // callback server, which receives push callbacks. private Connector callbackServerConnector; /** * Create the remoting client to use to make calls on the remoting server. * * @param locatorURI * @throws Exception */ public void createRemotingClient(String locatorURI) throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); } /** * Makes a call on the remoting server. * * @throws Throwable */ public void makeInvocation() throws Throwable { Object response = remotingClient.invoke("Do something", null); System.out.println("Invocation response: " + response); } /** * Shows how to register for pull callbacks and then get any callbacks * that are waiting on the server. * * @throws Throwable */ public void testPullCallback() throws Throwable { // our impplementation of the InvokerCallbackHandler interface, which // is defined as an inner class below. CallbackHandler callbackHandler = new CallbackHandler(); // by passing only the callback handler, will indicate pull callbacks remotingClient.addListener(callbackHandler); // the callback server generates callback messages on its own and need // to give a few seconds to generate them. Thread.currentThread().sleep(2000); // call also make regular invocations on the server at any time. makeInvocation(); // go get our callbacks residing on the server List callbacks = remotingClient.getCallbacks(callbackHandler); Iterator itr = callbacks.iterator(); while(itr.hasNext()) { Callback callbackObject = (Callback) itr.next(); System.out.println("Pull Callback value = " + callbackObject.getCallbackObject()); } // remove callback handler from server remotingClient.removeListener(callbackHandler); } /** * Shows how to register for push callbacks where the server will * callback on our callback handler when it generates a callback. * * @throws Throwable */ public void testPushCallback() throws Throwable { // First, need to create remoting server to receive callbacks. // Using loctor with port value one higher than the target server String callbackLocatorURI = transport + "://" + host + ":" + (port + 1); InvokerLocator callbackLocator = new InvokerLocator(callbackLocatorURI); // call to create remoting server to the // callbacks generated by the target remoting server. setupServer(callbackLocator); CallbackHandler callbackHandler = new CallbackHandler(); // Callback handle object will be passed back as part of the callback object // This can be used at the time the callback is received to identify context String callbackHandleObject = "myCallbackHandleObject"; // by passing the callback handler and callback locator, will indicate push callbacks // could also have not included callbackHandleObject as last parameter if did not care // callback handle (i.e. addListener(callbackHandler, callbackLocator); ) remotingClient.addListener(callbackHandler, callbackLocator, callbackHandleObject); // need to wait for brief moment so server can callback Thread.sleep(2000); // remove callback handler from server remotingClient.removeListener(callbackHandler); // shut down callback server callbackServerConnector.stop(); callbackServerConnector.destroy(); } /** * Sets up the callback server that the target remoting server can call on * with the callbacks that it generates. * * @param locator * @throws Exception */ public void setupServer(InvokerLocator locator) throws Exception { System.out.println("Starting remoting server with locator uri of: " + locator); callbackServerConnector = new Connector(); callbackServerConnector.setInvokerLocator(locator.getLocatorURI()); callbackServerConnector.start(); } /** * 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; CallbackClient client = new CallbackClient(); try { client.createRemotingClient(locatorURI); // make call to test pull callbacks client.testPullCallback(); // make call to test push callbacks client.testPushCallback(); } catch(Throwable e) { e.printStackTrace(); } } /** * Our implementation of the InvokerCallbackHandler. Simply * prints out the callback object's message upon receiving it. */ public class CallbackHandler implements InvokerCallbackHandler { /** * Will take the callback and print out its values. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("Received push 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()); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/bisocket/0000755000175000017500000000000011632407051030104 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/bisocket/BisocketSampleClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/bisocket/BisocketSampleCli0000644000175000017500000001350311413660476033377 0ustar twernertwerner/* * 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.remoting.samples.bisocket; import java.lang.reflect.Field; import java.net.InetAddress; import java.util.HashMap; import java.util.List; import java.util.Set; 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.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.bisocket.Bisocket; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.remoting.transport.socket.SocketServerInvoker; /** * This class and org.jboss.remoting.samples.bisocket.BisocketSampleServer * demonstrate how to how to make an invocation and how to set up push callbacks * over the bisocket transport. * * The reason for the existance of the bisocket transport, which is derived from the * socket transport, is to make it possible to do push callbacks to a client which * is unable to create a ServerSocket, either due to security restrictions or due * to the fact that it is behind a firewall. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 1, 2008 *

          */ public class BisocketSampleClient { private static Logger log = Logger.getLogger(BisocketSampleClient.class); public void makeInvocation(String locatorURI) throws Throwable { // Create client. InvokerLocator clientLocator = new InvokerLocator(locatorURI); Client client = new Client(clientLocator); client.connect(); log.info("client is connected"); // Test connection. if ("abc".equals(client.invoke("abc"))) log.info("connection is good"); else log.info("Should have gotten \"abc\" in reply"); // Set up push callbacks. Tell the Connector created by Client.addListener() // that it is a callback Connector, which tells the BisocketServerInvoker // not to create a ServerSocket. HashMap metadata = new HashMap(); metadata.put(Bisocket.IS_CALLBACK_SERVER, "true"); TestCallbackHandler callbackHandler = new TestCallbackHandler(); client.addListener(callbackHandler, metadata); // Use reflection to verify that the callback BisocketServerInvoker did not // create a ServerSocket. Set callbackConnectors = client.getCallbackConnectors(callbackHandler); if (callbackConnectors.size() != 1) { log.info("There should be one callback Connector"); } else { Connector callbackConnector = (Connector) callbackConnectors.iterator().next(); BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker(); Field field = SocketServerInvoker.class.getDeclaredField("serverSockets"); field.setAccessible(true); List serverSockets = (List) field.get(serverInvoker); log.info("number of ServerSockets held by callback BisocketServerInvoker: " + serverSockets.size()); } // Request callback. client.invoke("CALLBACK"); if (callbackHandler.getCounter() == 1) log.info("received callback"); else log.info("didn't receive callback"); client.removeListener(callbackHandler); client.disconnect(); } public static void main(String[] args) { // Configure logging. 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); try { String host = InetAddress.getLocalHost().getHostName(); int port = BisocketSampleServer.port; String locatorURI = "bisocket://" + host + ":" + port; BisocketSampleClient client = new BisocketSampleClient(); client.makeInvocation(locatorURI); } catch(Throwable e) { e.printStackTrace(); } } /** * An InvokerCallbackHandler is registered with the callback Connector, which * passes push callbacks to it by way of the handleCallback() method. *

          */ static class TestCallbackHandler implements InvokerCallbackHandler { private int counter; public void handleCallback(Callback callback) throws HandleCallbackException { counter++; } public int getCounter() { return counter; } } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/bisocket/BisocketSampleServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/bisocket/BisocketSampleSer0000644000175000017500000001317611413660476033427 0ustar twernertwerner/* * 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.remoting.samples.bisocket; import java.net.InetAddress; import java.util.HashSet; import java.util.Iterator; import javax.management.MBeanServer; 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.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; /** * This class and org.jboss.remoting.samples.bisocket.BisocketSampleClient * demonstrate how to how to make an invocation and how to set up push callbacks * over the bisocket transport. * * The reason for the existance of the bisocket transport, which is derived from the * socket transport, is to make it possible to do push callbacks to a client which * is unable to create a ServerSocket, either due to security restrictions or due * to the fact that it is behind a firewall. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 1, 2008 *

          */ public class BisocketSampleServer { public static int port = 4567; private static Logger log = Logger.getLogger(BisocketSampleServer.class); protected Connector connector; protected void setupServer(String locatorURI) throws Exception { // Create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator serverLocator = new InvokerLocator(locatorURI); connector = new Connector(serverLocator); // Creates all the connector's needed resources, such as the server invoker. connector.create(); // Create the handler to receive the invocation request from the client for processing. SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); connector.addInvocationHandler("test", invocationHandler); // Start server. connector.start(); log.info("Started remoting server with locator uri of: " + locatorURI); } protected void shutdownServer() throws Exception { if (connector != null) { connector.stop(); log.info("shut down server"); } } public static void main(String[] args) { try { // Configure logging. 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); // Create and start server. String host = InetAddress.getLocalHost().getHostAddress(); String locatorURI = "bisocket://" + host + ":" + port; BisocketSampleServer server = new BisocketSampleServer(); server.setupServer(locatorURI); // Wait until user types a character on command line. System.in.read(); // Shut down server. server.shutdownServer(); } catch(Exception e) { e.printStackTrace(); } } /** * Invocations are handled by the ServerInvocationHandler. */ static class SampleInvocationHandler implements ServerInvocationHandler { private HashSet callbackHandlers = new HashSet(); public void addListener(InvokerCallbackHandler callbackHandler) { callbackHandlers.add(callbackHandler); } public Object invoke(final InvocationRequest invocation) throws Throwable { Object param = invocation.getParameter(); if ("CALLBACK".equals(param)) { Iterator it = callbackHandlers.iterator(); while (it.hasNext()) { InvokerCallbackHandler handler = (InvokerCallbackHandler) it.next(); handler.handleCallback(new Callback("callback")); } } return param; } public void removeListener(InvokerCallbackHandler callbackHandler) { callbackHandlers.remove(callbackHandler); } public void setMBeanServer(MBeanServer server) {} public void setInvoker(ServerInvoker invoker) {} } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/0000755000175000017500000000000011632407052030260 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/0000755000175000017500000000000011632407052031204 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/SimpleDetectorServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/SimpleDetec0000644000175000017500000002030310513251744033325 0ustar twernertwernerpackage org.jboss.remoting.samples.detection.jndi; 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.detection.jndi.JNDIDetector; import org.jboss.remoting.transport.Connector; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; /** * A simple JBoss/Remoting remoting server. This uses an inner class SampleInvocationHandler as the invocation * target handler class. * * @author Tom Elrod * @author John Mazzitelli */ public class SimpleDetectorServer { // Default locator values - command line args can override transport and port protected static String transport = "socket"; protected static String host = "localhost"; protected static int port = 5400; private int detectorPort = 1099; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; /** * Sets up NetworkRegistry and JNDItDetector so will can register ourselves on the network. We could also * use these to listen ourselves for any additions or removals of remoting servers on the network. * * @throws Exception */ public void setupDetector() throws Exception { // we need an MBeanServer to store our network registry and multicast detector services MBeanServer server = MBeanServerFactory.createMBeanServer(); String detectorHost = InetAddress.getLocalHost().getHostName(); // multicast detector will detect new network registries that come online JNDIDetector detector = new JNDIDetector(getConfiguration()); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); detector.start(); println("JNDIDetector has been created and is listening for new NetworkRegistries to come online"); } /** * Sets up our JBoss/Remoting server by creating our Connector on the given locator URI and installing our * invocation handler that will handle incoming messages. * * @param locatorURI defines our server endpoing * @throws Exception */ public void setupServer(String locatorURI) throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); println("Starting remoting server with locator uri of: " + locatorURI); Connector connector = new Connector(getConfiguration()); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); println("Added our invocation handler; we are now ready to begin accepting messages from clients"); connector.start(); } /** * Can pass transport and port to be used as parameters. Valid transports are 'rmi' and 'socket'. * * @param args transport and port number */ public static void main(String[] args) { println("Starting JBoss/Remoting server... to stop this server, kill it manually via Control-C"); String locatorURI = getLocatorURI(args); println("This server's endpoint will be: " + locatorURI); SimpleDetectorServer server = new SimpleDetectorServer(); try { server.setupDetector(); server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } println("Stopping JBoss/Remoting server"); } /** * Outputs a message to stdout. * * @param msg the message to output */ public static void println(String msg) { System.out.println(new java.util.Date() + ": [SERVER]: " + msg); } protected static String getLocatorURI(String[] args) { // get system property -Dargs that is in format "transport:port" String prop = System.getProperty("args"); if(prop != null) { try { transport = prop.substring(0, prop.indexOf("-")); port = Integer.parseInt(prop.substring(prop.indexOf("-") + 1)); } catch(NumberFormatException nfe) { println("INVALID ARGUMENTS: Bad port from property args: " + prop); System.exit(1); } catch(Exception e) { println("INVALID ARGUMENTS: -Dargs property must be in the form '{socket|rmi}-{port#}': " + prop); System.exit(1); } } // command line args override defaults and system property if((args != null) && (args.length != 0)) { if(args.length == 2) { transport = args[0]; port = Integer.parseInt(args[1]); } else { println("INVALID ARGUMENTS: Usage: " + SimpleDetectorServer.class.getName() + " [rmi|socket ]"); System.exit(1); } } return transport + "://" + host + ":" + port; } /** * @return configuration map for Connector and JNDIDetector */ protected Map getConfiguration() { return new HashMap(); } protected SimpleDetectorServer getDetectorServer() { return new SimpleDetectorServer(); } /** * Simple invocation handler implementation. This is the handler that processes incoming messages from clients. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * This is the method that is called when a new message comes in from a client. * * @param invocation the incoming client invocation, encapsulates the message object * @return the response object we send back to the client. * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request String msg = invocation.getParameter().toString(); println("RECEIVED A CLIENT MESSAGE: " + msg); String response = "Server received your message that said [" + msg + "]"; if(msg.indexOf("Welcome") > -1) { response = "Received your welcome message. Thank you!"; } println("Returning the following message back to the client: " + response); return response; } /** * Adds a callback handler that will listen for callbacks from the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { // NO OP as we do not handle 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 we do not handle callback listeners in this example } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as we do not need a reference to the MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as we do not need a reference back to the server invoker } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/SimpleDetectorClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/SimpleDetec0000644000175000017500000001502610513251472033331 0ustar twernertwernerpackage org.jboss.remoting.samples.detection.jndi; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; import java.net.InetAddress; import java.util.Map; import java.util.HashMap; /** * Simple remoting client that uses detection to discover the remoting server to make invocation on. Note that this * class is a standard JMX NotificationListener so it can listen for discovery JMX notifications coming from the * NetworkRegistry. This is how the NetworkRegistry tells us when new servers have come online and when dead * servers go offline. * * @author Tom Elrod * @author John Mazzitelli */ public class SimpleDetectorClient implements NotificationListener { private int detectorPort = 1099; private String contextFactory = "org.jnp.interfaces.NamingContextFactory"; private String urlPackage = "org.jboss.naming:org.jnp.interfaces"; /** * Sets up NetworkRegistry and JNDIDetector so we can listen for any additions or removals of remoting * servers on the network. * * @throws Exception */ public void setupDetector() throws Exception { // we need an MBeanServer to store our network registry and jndi detector services MBeanServer server = MBeanServerFactory.createMBeanServer(); // the registry will house all remoting servers discovered NetworkRegistry registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); println("NetworkRegistry has been created"); // register class as listener, so know when new server found registry.addNotificationListener(this, null, null); println("NetworkRegistry has added the client as a listener"); String detectorHost = InetAddress.getLocalHost().getHostName(); // jndi detector will detect new network registries that come online JNDIDetector detector = new JNDIDetector(getConfiguration()); // set config info for detector and start it. detector.setPort(detectorPort); detector.setHost(detectorHost); detector.setContextFactory(contextFactory); detector.setURLPackage(urlPackage); server.registerMBean(detector, new ObjectName("remoting:type=JNDIDetector")); detector.start(); println("JNDIDetector has been created and is listening for new NetworkRegistries to come online"); return; } /** * Callback method from the broadcaster MBean this listener implementation is registered to. When a new server * is detected, a welcome message will immediately be sent to the newly discovered server. * * @param notification the notification object * @param handback the handback object given to the broadcaster upon listener registration */ public void handleNotification(Notification notification, Object handback) { // check to see if network notification if(notification instanceof NetworkNotification) { println("GOT A NETWORK-REGISTRY NOTIFICATION: " + notification.getType()); NetworkNotification networkNotification = (NetworkNotification) notification; if(NetworkNotification.SERVER_ADDED.equals(networkNotification.getType())) { // notification is for new servers being added println("New server(s) have been detected - getting locators and sending welcome messages"); InvokerLocator[] locators = networkNotification.getLocator(); for(int x = 0; x < locators.length; x++) { try { // get the new found server's locator and invoke a call InvokerLocator newServerLocator = locators[x]; makeInvocation(newServerLocator.getLocatorURI()); } catch(Throwable throwable) { throwable.printStackTrace(); } } } else if(NetworkNotification.SERVER_REMOVED.equals(networkNotification.getType())) { // notification is for old servers that have gone down InvokerLocator[] locators = networkNotification.getLocator(); for(int x = 0; x < locators.length; x++) { println("It has been detected that a server has gone down with a locator of: " + locators[x]); } } } return; } /** * Make call on remoting server based on locator uri provided. * * @param locatorURI the URI of the remote server we want to send the message to * @throws Throwable */ public void makeInvocation(String locatorURI) throws Throwable { InvokerLocator locator = new InvokerLocator(locatorURI); println("Sending welcome message to remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator, getConfiguration()); remotingClient.connect(); Object response = remotingClient.invoke("Welcome Aboard!", null); println("The newly discovered server sent this response to our welcome message: " + response); remotingClient.disconnect(); return; } /** * Starts the JBoss/Remoting client. * * @param args unused */ public static void main(String[] args) { println("Starting JBoss/Remoting client... to stop this client, kill it manually via Control-C"); SimpleDetectorClient client = new SimpleDetectorClient(); try { client.setupDetector(); // let this client run forever - welcoming new servers when then come online while(true) { Thread.sleep(1000); } } catch(Throwable e) { e.printStackTrace(); } println("Stopping JBoss/Remoting client"); } /** * Outputs a message to stdout. * * @param msg the message to output */ public static void println(String msg) { System.out.println(new java.util.Date() + ": [CLIENT]: " + msg); } /** * @return configuration map for JNDIDetector */ protected Map getConfiguration() { return new HashMap(); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/SimpleJNDIServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/SimpleJNDIS0000644000175000017500000001165411171061163033154 0ustar twernertwernerpackage org.jboss.remoting.samples.detection.jndi; import org.jboss.remoting.util.SecurityUtility; import org.jnp.server.Main; import java.lang.reflect.Method; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * A JNDI server that should be run before running the simple detector client/server. * Leave running while shutting down different server instances. * * @author Tom Elrod */ public class SimpleJNDIServer { // Default locator values - command line args can override transport and port private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private int detectorPort = 1099; /** * Can pass transport and port to be used as parameters. Valid transports are 'rmi' and 'socket'. * * @param args transport and port number */ public static void main(String[] args) { // get system property -Dargs that is in format "transport:port" String prop = System.getProperty("args"); if(prop != null) { try { SimpleJNDIServer.transport = prop.substring(0, prop.indexOf("-")); SimpleJNDIServer.port = Integer.parseInt(prop.substring(prop.indexOf("-") + 1)); } catch(NumberFormatException nfe) { SimpleJNDIServer.println("INVALID ARGUMENTS: Bad port from property args: " + prop); System.exit(1); } catch(Exception e) { SimpleJNDIServer.println("INVALID ARGUMENTS: -Dargs property must be in the form '{socket|rmi}-{port#}': " + prop); System.exit(1); } } // command line args override defaults and system property if((args != null) && (args.length != 0)) { if(args.length == 2) { SimpleJNDIServer.transport = args[0]; SimpleJNDIServer.port = Integer.parseInt(args[1]); } else { SimpleJNDIServer.println("INVALID ARGUMENTS: Usage: " + SimpleJNDIServer.class.getName() + " [rmi|socket ]"); System.exit(1); } } SimpleJNDIServer.println("Starting JNDI server... to stop this server, kill it manually via Control-C"); SimpleJNDIServer server = new SimpleJNDIServer(); try { server.setupJNDIServer(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } SimpleJNDIServer.println("Stopping JBoss/Remoting server"); } private void setupJNDIServer() throws Exception { Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } // start JNDI server String detectorHost = InetAddress.getLocalHost().getHostName(); Main JNDIServer = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = JNDIServer.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(JNDIServer, new Object[] {namingBean}); } JNDIServer.setPort(detectorPort); JNDIServer.setBindAddress(detectorHost); JNDIServer.start(); System.out.println("Started JNDI server on " + detectorHost + ":" + detectorPort); } /** * Outputs a message to stdout. * * @param msg the message to output */ public static void println(String msg) { System.out.println(new java.util.Date() + ": [SERVER]: " + msg); } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/0000755000175000017500000000000011632407052032005 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/keystorelibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/keystor0000644000175000017500000001376110513252056033437 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/trustst0000644000175000017500000000701310513252056033460 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žç././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/SimpleSSLDetectorServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/SimpleS0000644000175000017500000000513010513252056033302 0ustar twernertwerner/* * 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.remoting.samples.detection.jndi.ssl; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.samples.detection.jndi.SimpleDetectorServer; import org.jboss.remoting.security.SSLSocketBuilder; /** * @author Ron Sigal * @version $Revision: 1480 $ *

          * Copyright Oct 9, 2006 *

          */ public class SimpleSSLDetectorServer extends SimpleDetectorServer { public static void main(String[] args) { println("Starting JBoss/Remoting server... to stop this server, kill it manually via Control-C"); String locatorURI = getLocatorURI(args); println("This server's endpoint will be: " + locatorURI); SimpleDetectorServer server = new SimpleSSLDetectorServer(); try { server.setupDetector(); server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } println("Stopping JBoss/Remoting server"); } protected Map getConfiguration() { Map 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"); return config; } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/SimpleSSLDetectorClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/jndi/ssl/SimpleS0000644000175000017500000000262010513252056033303 0ustar twernertwernerpackage org.jboss.remoting.samples.detection.jndi.ssl; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.samples.detection.jndi.SimpleDetectorClient; import org.jboss.remoting.security.SSLSocketBuilder; /** * A SimpleDetectorSSLClient. * * @author Adrian Brock * @version $Revision: 1480 $ */ public class SimpleSSLDetectorClient extends SimpleDetectorClient { public static void main(String[] args) { println("Starting JBoss/Remoting client... to stop this client, kill it manually via Control-C"); SimpleDetectorClient client = new SimpleSSLDetectorClient(); try { client.setupDetector(); // let this client run forever - welcoming new servers when then come online while(true) { Thread.sleep(1000); } } catch(Throwable e) { e.printStackTrace(); } println("Stopping JBoss/Remoting client"); } protected Map getConfiguration() { Map config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getClass().getResource("truststore").getFile(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); return config; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/multicast/0000755000175000017500000000000011632407052032265 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/multicast/SimpleDetectorServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/multicast/Simple0000644000175000017500000002044410422057107033443 0ustar twernertwerner/* * 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.remoting.samples.detection.multicast; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; 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.detection.multicast.MulticastDetector; import org.jboss.remoting.transport.Connector; /** * A simple JBoss/Remoting remoting server. This uses an inner class SampleInvocationHandler as the invocation * target handler class. * * @author Tom Elrod * @author John Mazzitelli */ public class SimpleDetectorServer { // Default locator values - command line args can override transport and port private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; /** * Sets up NetworkRegistry and MulticastDetector so will can register ourselves on the network. We could also * use these to listen ourselves for any additions or removals of remoting servers on the network. * * @throws Exception */ public void setupDetector() throws Exception { // we need an MBeanServer to store our network registry and multicast detector services MBeanServer server = MBeanServerFactory.createMBeanServer(); // multicast detector will detect new network registries that come online MulticastDetector detector = new MulticastDetector(); server.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector")); detector.start(); println("MulticastDetector has been created and is listening for new NetworkRegistries to come online"); return; } /** * Sets up our JBoss/Remoting server by creating our Connector on the given locator URI and installing our * invocation handler that will handle incoming messages. * * @param locatorURI defines our server endpoing * @throws Exception */ public void setupServer(String locatorURI) throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); println("Starting remoting server with locator uri of: " + locatorURI); Connector connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); println("Added our invocation handler; we are now ready to begin accepting messages from clients"); connector.start(); return; } /** * Can pass transport and port to be used as parameters. Valid transports are 'rmi' and 'socket'. * * @param args transport and port number */ public static void main(String[] args) { // get system property -Dargs that is in format "transport:port" String prop = System.getProperty("args"); if(prop != null) { try { transport = prop.substring(0, prop.indexOf("-")); port = Integer.parseInt(prop.substring(prop.indexOf("-") + 1)); } catch(NumberFormatException nfe) { println("INVALID ARGUMENTS: Bad port from property args: " + prop); System.exit(1); } catch(Exception e) { println("INVALID ARGUMENTS: -Dargs property must be in the form '{socket|rmi}-{port#}': " + prop); System.exit(1); } } // command line args override defaults and system property if((args != null) && (args.length != 0)) { if(args.length == 2) { transport = args[0]; port = Integer.parseInt(args[1]); } else { println("INVALID ARGUMENTS: Usage: " + SimpleDetectorServer.class.getName() + " [rmi|socket ]"); System.exit(1); } } println("Starting JBoss/Remoting server... to stop this server, kill it manually via Control-C"); String locatorURI = transport + "://" + host + ":" + port; println("This server's endpoint will be: " + locatorURI); SimpleDetectorServer server = new SimpleDetectorServer(); try { server.setupDetector(); server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } println("Stopping JBoss/Remoting server"); } /** * Outputs a message to stdout. * * @param msg the message to output */ public static void println(String msg) { System.out.println(new java.util.Date() + ": [SERVER]: " + msg); } /** * Simple invocation handler implementation. This is the handler that processes incoming messages from clients. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * This is the method that is called when a new message comes in from a client. * * @param invocation the incoming client invocation, encapsulates the message object * @return the response object we send back to the client. * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request String msg = invocation.getParameter().toString(); println("RECEIVED A CLIENT MESSAGE: " + msg); String response = "Server received your message that said [" + msg + "]"; if(msg.indexOf("Welcome") > -1) { response = "Received your welcome message. Thank you!"; } println("Returning the following message back to the client: " + response); return response; } /** * Adds a callback handler that will listen for callbacks from the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { // NO OP as we do not handle 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 we do not handle callback listeners in this example } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { // NO OP as we do not need a reference to the MBeanServer for this handler } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { // NO OP as we do not need a reference back to the server invoker } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/multicast/SimpleDetectorClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/detection/multicast/Simple0000644000175000017500000001544410433770344033456 0ustar twernertwerner/* * 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.remoting.samples.detection.multicast; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.detection.multicast.MulticastDetector; import org.jboss.remoting.network.NetworkNotification; import org.jboss.remoting.network.NetworkRegistry; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; /** * Simple remoting client that uses detection to discover the remoting server to make invocation on. Note that this * class is a standard JMX NotificationListener so it can listen for discovery JMX notifications coming from the * NetworkRegistry. This is how the NetworkRegistry tells us when new servers have come online and when dead * servers go offline. * * @author Tom Elrod * @author John Mazzitelli */ public class SimpleDetectorClient implements NotificationListener { /** * Sets up NetworkRegistry and MulticastDetector so we can listen for any additions or removals of remoting * servers on the network. * * @throws Exception */ public void setupDetector() throws Exception { // we need an MBeanServer to store our network registry and multicast detector services MBeanServer server = MBeanServerFactory.createMBeanServer(); // the registry will house all remoting servers discovered NetworkRegistry registry = NetworkRegistry.getInstance(); server.registerMBean(registry, new ObjectName("remoting:type=NetworkRegistry")); println("NetworkRegistry has been created"); // register class as listener, so know when new server found registry.addNotificationListener(this, null, null); println("NetworkRegistry has added the client as a listener"); // multicast detector will detect new network registries that come online MulticastDetector detector = new MulticastDetector(); server.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector")); detector.start(); println("MulticastDetector has been created and is listening for new NetworkRegistries to come online"); return; } /** * Callback method from the broadcaster MBean this listener implementation is registered to. When a new server * is detected, a welcome message will immediately be sent to the newly discovered server. * * @param notification the notification object * @param handback the handback object given to the broadcaster upon listener registration */ public void handleNotification(Notification notification, Object handback) { // check to see if network notification if(notification instanceof NetworkNotification) { println("GOT A NETWORK-REGISTRY NOTIFICATION: " + notification.getType()); NetworkNotification networkNotification = (NetworkNotification) notification; if(NetworkNotification.SERVER_ADDED.equals(networkNotification.getType())) { // notification is for new servers being added println("New server(s) have been detected - getting locators and sending welcome messages"); InvokerLocator[] locators = networkNotification.getLocator(); for(int x = 0; x < locators.length; x++) { try { // get the new found server's locator and invoke a call InvokerLocator newServerLocator = locators[x]; makeInvocation(newServerLocator.getLocatorURI()); } catch(Throwable throwable) { throwable.printStackTrace(); } } } else if(NetworkNotification.SERVER_REMOVED.equals(networkNotification.getType())) { // notification is for old servers that have gone down InvokerLocator[] locators = networkNotification.getLocator(); for(int x = 0; x < locators.length; x++) { println("It has been detected that a server has gone down with a locator of: " + locators[x]); } } } return; } /** * Make call on remoting server based on locator uri provided. * * @param locatorURI the URI of the remote server we want to send the message to * @throws Throwable */ public void makeInvocation(String locatorURI) throws Throwable { InvokerLocator locator = new InvokerLocator(locatorURI); println("Sending welcome message to remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); Object response = remotingClient.invoke("Welcome Aboard!", null); println("The newly discovered server sent this response to our welcome message: " + response); return; } /** * Starts the JBoss/Remoting client. * * @param args unused */ public static void main(String[] args) { println("Starting JBoss/Remoting client... to stop this client, kill it manually via Control-C"); SimpleDetectorClient client = new SimpleDetectorClient(); try { client.setupDetector(); // let this client run forever - welcoming new servers when then come online while(true) { Thread.sleep(1000); } } catch(Throwable e) { e.printStackTrace(); } println("Stopping JBoss/Remoting client"); } /** * Outputs a message to stdout. * * @param msg the message to output */ public static void println(String msg) { System.out.println(new java.util.Date() + ": [CLIENT]: " + msg); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/0000755000175000017500000000000011632407052027547 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/factories/0000755000175000017500000000000011632407052031526 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/factories/FactoryConfigSSLSample.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/factories/FactoryCo0000644000175000017500000005771510463571631033367 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.remoting.samples.config.factories; import java.io.ByteArrayInputStream; import java.io.File; import java.util.HashMap; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.xml.parsers.DocumentBuilderFactory; import junit.framework.TestCase; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.samples.config.factories.FactoryConfigSample.CallbackHandler; import org.jboss.remoting.samples.config.factories.FactoryConfigSample.SampleInvocationHandler; import org.jboss.remoting.security.SSLServerSocketFactoryService; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.SSLSocketFactoryService; import org.jboss.remoting.transport.Connector; import org.jboss.remoting.transport.PortUtil; import org.w3c.dom.Document; /** * These methods illustrate configuring socket factories and server socket factories * on the server side and on the client side. The numbered * options mentioned refer to the lists of configuration options discussed in the * Remoting documentation in the subsections "Server side configuration" and * "Client side configuration" of the section called "Socket factories and server * socket factories". *

          * The configuration options illustrated in this class are specific to SSL * sockets and server sockets. The methods * getDefaultServerSocketFactory(), * getDefaultSocketFactory(), * getDefaultCallbackServerSocketFactory() and * getDefaultCallbackSocketFactory() * illustrate the use of the class SSLSocketBuilder to * create custom SSL socket factories and SSL server socket factories. *

          * @author Ron Sigal *

          * Copyright (c) Jul 20, 2006 *

          */ public class FactoryConfigSSLSample extends TestCase { private static Logger log = Logger.getLogger(FactoryConfigSSLSample.class); /** This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket4
          server sidesocket 4
          client sideserver socket1
          client sidesocket 1
          */ public void testFactoriesByPassingMBeanInXml() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create ServerSocketFactory MBean. ServerSocketFactory service = getDefaultServerSocketFactory(); String serverSocketFactoryName = "jboss:type=serversocketfactory"; ObjectName objName = new ObjectName(serverSocketFactoryName); MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); mbeanServer.registerMBean(service, objName); // Get Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(sconfig); mbeanServer.registerMBean(connector, new ObjectName("test:type=connector")); // Set xml configuration element. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append( ""); buf.append( "" + getHostName() + ""); buf.append( "" + freeport + ""); buf.append( "" ); buf.append( serverSocketFactoryName); buf.append( ""); buf.append( ""); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create Client. Client client = new Client(locator, cconfig); // Set SocketFactory in Client. // Note. There is no provision for using xml configuration on client side. SocketFactory sf = getDefaultSocketFactory(); client.setSocketFactory(sf); client.connect(); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Start callback Connector. // Note: there is no provision for using MBeanServer on client side. freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI()); ServerSocketFactory ssf = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new FactoryConfigSample.SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new FactoryConfigSample.CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } /** This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket6
          server sidesocket 5
          client sideserver socket1
          client sidesocket 1
          *

          * Note. There is no provision for using an MBeanServer on * the client side. */ public void testFactoriesByPassingMBeanInConfig() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Put ServerSocketFactory MBean name in config map. ServerSocketFactory service = getDefaultServerSocketFactory(); String serverSocketFactoryName = "jboss:type=serversocketfactory"; ObjectName objName = new ObjectName(serverSocketFactoryName); MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); mbeanServer.registerMBean(service, objName); sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, serverSocketFactoryName); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Start Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); mbeanServer.registerMBean(connector, new ObjectName("test:type=connector")); connector.create(); connector.addInvocationHandler("sample", new FactoryConfigSample.SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create Client. Client client = new Client(locator, cconfig); // Set server socket factory on Client. // Note: There is no provision for using MBeanServer on client side. SocketFactory sf = getDefaultSocketFactory(); client.setSocketFactory(sf); client.connect(); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Start callback Connector. // Note: there is no provision for using MBeanServer on client side. freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI()); ServerSocketFactory ssf = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new FactoryConfigSample.SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new FactoryConfigSample.CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } /** This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket8
          server sidesocket 8
          client sideserver socket6
          client sidesocket 5
          */ public void testFactoriesFromSSLParameters() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL keystore parameters in config map. sconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "false"); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); sconfig.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); // Start Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); connector.create(); connector.addInvocationHandler("sample", new FactoryConfigSample.SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Put SSL parameters in config map. cconfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "true"); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); // Create Client. Client client = new Client(locator, cconfig); client.connect(); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Start callback Connector. HashMap cbconfig = new HashMap(); // Put SSL parameters in config map. cbconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); cbconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); cbconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); cbconfig.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), cbconfig); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new FactoryConfigSample.SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } /** This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket9
          server sidesocket 9
          client sideserver socket7
          client sidesocket 6
          */ public void testFactoriesFromSystemSSLParameters() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Set SSL system properties. System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_FILE_PATH, keyStoreFilePath); System.setProperty(SSLSocketBuilder.STANDARD_KEY_STORE_PASSWORD, "unit-tests-server"); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_FILE_PATH, trustStoreFilePath); System.setProperty(SSLSocketBuilder.STANDARD_TRUST_STORE_PASSWORD, "unit-tests-client"); // Start Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); connector.create(); connector.addInvocationHandler("sample", new FactoryConfigSample.SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create Client. Client client = new Client(locator, cconfig); client.connect(); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Start callback Connector. HashMap cbconfig = new HashMap(); // Make callback Connector server socket run in client mode. cbconfig.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), cbconfig); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new FactoryConfigSample.SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } protected String getHostName() { return "localhost"; } protected String getTransport() { return "sslsocket"; } protected String getKeystoreFilePath() { File file = new File(FactoryConfigSSLSample.class.getResource("keystore").getFile()); return file.getPath(); } protected static String getTruststoreFilePath() { File file = new File(FactoryConfigSSLSample.class.getResource("truststore").getFile()); return file.getPath(); } protected ServerSocketFactory getDefaultServerSocketFactory() throws Exception { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SSLSocketBuilder(config); builder.setUseSSLServerSocketFactory(false); SSLServerSocketFactoryService service = new SSLServerSocketFactoryService(); service.setSSLSocketBuilder(builder); service.start(); return service; } protected SocketFactory getDefaultSocketFactory() throws Exception { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SSLSocketBuilder(config); builder.setUseSSLSocketFactory(false); SSLSocketFactoryService service = new SSLSocketFactoryService(); service.setSSLSocketBuilder(builder); service.start(); return service; } protected ServerSocketFactory getDefaultCallbackServerSocketFactory() throws Exception { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true"); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS"); String trustStoreFilePath = getTruststoreFilePath(); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath); config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client"); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SSLSocketBuilder(config); builder.setUseSSLServerSocketFactory(false); SSLServerSocketFactoryService service = new SSLServerSocketFactoryService(); service.setSSLSocketBuilder(builder); service.start(); return service; } protected SocketFactory getDefaultCallbackSocketFactory() throws Exception { HashMap config = new HashMap(); config.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS"); String keyStoreFilePath = getKeystoreFilePath(); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath); config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server"); config.put(SSLSocketBuilder.REMOTING_SSL_PROTOCOL, "SSL"); SSLSocketBuilder builder = new SSLSocketBuilder(config); builder.setUseSSLSocketFactory(false); SSLSocketFactoryService service = new SSLSocketFactoryService(); service.setSSLSocketBuilder(builder); service.start(); return builder.createSSLSocketFactory(); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/factories/FactoryConfigSample.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/factories/FactoryCo0000644000175000017500000006572210463571631033364 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.remoting.samples.config.factories; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.HashMap; import javax.management.MBeanServer; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.xml.parsers.DocumentBuilderFactory; 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.Remoting; 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; import org.w3c.dom.Document; /** * These methods illustrate configuring socket factories and server socket factories * on the server side and on the client side. The numbered * options mentioned refer to the lists of configuration options discussed in the * Remoting documentation in the subsections "Server side configuration" and * "Client side configuration" of the section called "Socket factories and server * socket factories". *

          * The configuration options illustrated in this class are applicable to any kind * of socket and server socket, so the SampleServerSocketFactory * and SampleSocketFactory classes create ordinary sockets and server * sockets. *

          * * @author Ron Sigal *

          * Copyright (c) Jul 20, 2006 *

          */ public class FactoryConfigSample extends TestCase { protected static Logger log = Logger.getLogger(FactoryConfigSample.class); /** * This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket1
          server sidesocket 1
          client sideserver socket1
          client sidesocket 1
          */ public void testFactoriesBySettingInvokers() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Get Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); connector.create(); // Set ServerSocketFactory and SocketFactory in ServerInvoker. ServerInvoker serverInvoker = connector.getServerInvoker(); ServerSocketFactory ssf1 = getDefaultServerSocketFactory(); serverInvoker.setServerSocketFactory(ssf1); SocketFactory sf1 = getDefaultCallbackSocketFactory(); serverInvoker.setSocketFactory(sf1); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create Client. Client client = new Client(locator, cconfig); client.connect(); // Set SocketFactory in ClientInvoker. SocketFactory sf2 = getDefaultSocketFactory(); ClientInvoker clientInvoker = client.getInvoker(); clientInvoker.setSocketFactory(sf2); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Start callback Connector. freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI()); callbackConnector.create(); ServerInvoker callbackServerInvoker = callbackConnector.getServerInvoker(); ServerSocketFactory ssf2 = getDefaultCallbackServerSocketFactory(); callbackServerInvoker.setServerSocketFactory(ssf2); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } /** This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket2
          server sidesocket 2
          client sideserver socket2
          client sidesocket 2
          */ public void testFactoriesBySettingConnectorAndClient() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Get Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); // Set ServerSocketFactory and SocketFactory in Connector. ServerSocketFactory ssf1 = getDefaultServerSocketFactory(); connector.setServerSocketFactory(ssf1); SocketFactory sf1 = getDefaultCallbackSocketFactory(); connector.setSocketFactory(sf1); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create Client. Client client = new Client(locator, cconfig); // Set SocketFactory in Client. SocketFactory sf2 = getDefaultSocketFactory(); client.setSocketFactory(sf2); client.connect(); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Get callback Connector. freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI()); // Set ServerSocketFactory in callback Connector ServerSocketFactory ssf2 = getDefaultCallbackServerSocketFactory(); callbackConnector.setServerSocketFactory(ssf2); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } /** This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket3
          server sidesocket 3
          client sideserver socket3
          client sidesocket 3
          */ public void testFactoriesByPassingInConfig() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Put ServerSocketFactory and SocketFactory in config map. ServerSocketFactory ssf1 = getDefaultServerSocketFactory(); sconfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf1); SocketFactory sf1 = getDefaultCallbackSocketFactory(); sconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf1); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Get Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory in config map. SocketFactory sf2 = getDefaultSocketFactory(); cconfig.put(Remoting.CUSTOM_SOCKET_FACTORY, sf2); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create Client. Client client = new Client(locator, cconfig); client.connect(); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Get callback Connector. HashMap cbconfig = new HashMap(); ServerSocketFactory ssf2 = getDefaultCallbackServerSocketFactory(); cbconfig.put(Remoting.CUSTOM_SERVER_SOCKET_FACTORY, ssf2); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), cbconfig); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } /** This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket5
          server sidesocket 6
          client sideserver socket4
          client sidesocket 1
          */ public void testFactoriesByPassingClassnameInXml() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Get Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(sconfig); // Set xml configuration element. StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append( ""); buf.append( "" + getHostName() + ""); buf.append( "" + freeport + ""); buf.append( "" ); buf.append( getDefaultServerSocketFactoryClass().getName()); buf.append( ""); buf.append( "" ); buf.append( getDefaultSocketFactoryClass().getName()); buf.append( ""); buf.append( ""); buf.append(""); ByteArrayInputStream bais = new ByteArrayInputStream(buf.toString().getBytes()); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); connector.setConfiguration(xml.getDocumentElement()); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create Client. Client client = new Client(locator, cconfig); // Set SocketFactory in Client. // Note. There is no provision for using xml configuration on client side. SocketFactory sf = getDefaultSocketFactory(); client.setSocketFactory(sf); client.connect(); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Get callback Connector. freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(); // Set xml configuration element. buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append( ""); buf.append( "" + getHostName() + ""); buf.append( "" + freeport + ""); buf.append( "" ); buf.append( getDefaultCallbackServerSocketFactoryClass().getName()); buf.append( ""); buf.append( ""); buf.append(""); bais = new ByteArrayInputStream(buf.toString().getBytes()); xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(bais); callbackConnector.setConfiguration(xml.getDocumentElement()); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } /** This test illustrates the following set of configuration options: *

          * * * * * * *
          sidefactoryoption
          server sideserver socket7
          server sidesocket 7
          client sideserver socket5
          client sidesocket 4
          */ public void testFactoriesByClassNameinConfig() { try { ///////////////////////////////////// ///// Set up server side. //// ///////////////////////////////////// HashMap sconfig = new HashMap(); // Put class names of ServerSocketFactory and SocketFactory in config map. sconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, getDefaultServerSocketFactoryClass().getName()); sconfig.put(Remoting.SOCKET_FACTORY_NAME, getDefaultCallbackSocketFactoryClass().getName()); // Make callback Client use remote invoker. sconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Get Connector. int freeport = PortUtil.findFreePort(getHostName()); InvokerLocator locator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector connector = new Connector(locator, sconfig); connector.create(); connector.addInvocationHandler("sample", new SampleInvocationHandler()); connector.start(); ///////////////////////////////////// ///// Set up client side. //// ///////////////////////////////////// HashMap cconfig = new HashMap(); // Put SocketFactory class name in config map. cconfig.put(Remoting.SOCKET_FACTORY_NAME, getDefaultSocketFactoryClass().getName()); // Make Client use remote invoker. cconfig.put(InvokerLocator.FORCE_REMOTE, "true"); // Create Client. Client client = new Client(locator, cconfig); client.connect(); System.out.println(getName() + ": " + client.invoke("test invoke()")); ////////////////////////////////////////////// ///// Set up callback handling. //// ////////////////////////////////////////////// // Get callback Connector. HashMap cbconfig = new HashMap(); cbconfig.put(ServerInvoker.SERVER_SOCKET_FACTORY, getDefaultCallbackServerSocketFactoryClass().getName()); freeport = PortUtil.findFreePort(getHostName()); InvokerLocator callbackLocator = new InvokerLocator(getTransport() + "://" + getHostName() + ":" + freeport); Connector callbackConnector = new Connector(callbackLocator.getLocatorURI(), cbconfig); callbackConnector.create(); callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler()); callbackConnector.start(); // Add callback handler. CallbackHandler callbackHandler = new CallbackHandler(); String callbackHandleObject = "myCallbackHandleObject"; client.addListener(callbackHandler, callbackLocator, callbackHandleObject); client.disconnect(); callbackConnector.stop(); connector.stop(); } catch (Throwable t) { log.error(t); t.printStackTrace(); fail(); } } protected String getTransport() { return "socket"; } protected String getHostName() { return "localhost"; } protected ServerSocketFactory getDefaultServerSocketFactory() throws Exception { return new SampleServerSocketFactory(); } protected SocketFactory getDefaultSocketFactory() throws Exception { return new SampleSocketFactory(); } protected ServerSocketFactory getDefaultCallbackServerSocketFactory() throws Exception { return new SampleServerSocketFactory(); } protected SocketFactory getDefaultCallbackSocketFactory() throws Exception { return new SampleSocketFactory(); } protected Class getDefaultServerSocketFactoryClass() throws Exception { return SampleServerSocketFactory.class; } protected Class getDefaultSocketFactoryClass() throws Exception { return SampleSocketFactory.class; } protected Class getDefaultCallbackServerSocketFactoryClass() throws Exception { return SampleServerSocketFactory.class; } protected Class getDefaultCallbackSocketFactoryClass() throws Exception { return SampleSocketFactory.class; } public static class SampleServerSocketFactory extends ServerSocketFactory { public ServerSocket createServerSocket(int arg0) throws IOException { return new ServerSocket(arg0); } public ServerSocket createServerSocket(int arg0, int arg1) throws IOException { return new ServerSocket(arg0, arg1); } public ServerSocket createServerSocket(int arg0, int arg1, InetAddress arg2) throws IOException { return new ServerSocket(arg0, arg1, arg2); } } public static class SampleSocketFactory extends SocketFactory { public Socket createSocket(String arg0, int arg1) throws IOException, UnknownHostException { return new Socket(arg0, arg1); } public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) throws IOException, UnknownHostException { return new Socket(arg0, arg1, arg2, arg3); } public Socket createSocket(InetAddress arg0, int arg1) throws IOException { return new Socket(arg0, arg1); } public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { return new Socket(arg0, arg1, arg2, arg3); } } public static class SampleInvocationHandler implements ServerInvocationHandler { private InvokerCallbackHandler callbackHandler; public SampleInvocationHandler() { } public Object invoke(InvocationRequest invocation) throws Throwable { return invocation.getParameter(); } public void addListener(InvokerCallbackHandler callbackHandler) { log.info("entering addListener()"); this.callbackHandler = callbackHandler; try { Callback callback = new Callback(new Integer(1)); callbackHandler.handleCallback(callback); log.info("sent first callback"); } catch(Exception e) { e.printStackTrace(); } } public void removeListener(InvokerCallbackHandler callbackHandler) { } public void setMBeanServer(MBeanServer server) { // NO OP as do not need reference to MBeanServer for this handler } public void setInvoker(ServerInvoker invoker) { // NO OP as do not need reference back to the server invoker } public InvokerCallbackHandler getCallbackHandler() { return callbackHandler; } } public static class CallbackHandler implements InvokerCallbackHandler { /** * Will take the callback and print out its values. * * @param callback * @throws org.jboss.remoting.callback.HandleCallbackException * */ public void handleCallback(Callback callback) throws HandleCallbackException { System.out.println("Received callback value of: " + callback.getCallbackObject()); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/factories/keystore0000644000175000017500000001376110460570353033331 0ustar twernertwernerþíþíunit-tests-clientxþ»õX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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-serverxül‡0‚‹0 +*‚w;¦[þ< YQ ¬†S„.%W(¼»ˆ#þZ rIãð¬; 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205414Z 321218205414Z0X1 0 UUS10U Washington10U  JBoss Inc.1 0 U QA10U 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 U00, `†H†øB OpenSSL Generated Certificate0U`b’¼Ò¨\‹àyÜyÔšç 30ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxûxïX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ0  *†H†÷  éÍyñÁåÒ™ð+‚+C9ŒmÞ(YŽ JiϽØmŠ=OÙˆ} ­ìekh«HxéàA±["|ÿÐûi9Tÿ¦ì(åø[rÎÄà‡¡sv°&oÉ3Vö?l¨ß®ÖcÐJK|Ïï@_^c}ÁEžåpÛ¦·â¾§…¹;T ¶w8Fcn=unit-tests-client, ou=jboss inc., o=jboss inc., st=washington, c=usy5^¶X.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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›†äö÷Ö././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/factories/truststorelibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/config/factories/truststor0000644000175000017500000000701310460570353033546 0ustar twernertwernerþíþíunit-tests-clientxüïS0‚‹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`OYJX.509¶0‚²0‚ 0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205439Z 321218205439Z0h1 0 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 U00, `†H†øB OpenSSL Generated Certificate0U€•û_%w³l½ZÎÉd\ñI&R0ÇU#¿0¼€K•Øbì:ÕÙô’+óJú~¡˜¤•0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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-caxüJX.509£0‚Ÿ0‚  «õRÿdMï0  *†H†÷ 0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com0 050802205208Z 321218205208Z0’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U 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’1 0 UUS10U Washington10USnoqualmie Pass10U  JBoss Inc.1 0 U QA10U jboss.com10 *†H†÷  admin@jboss.com‚ «õRÿdMï0 U0ÿ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žçlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/0000755000175000017500000000000011632407052030665 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/0000755000175000017500000000000011632407051032333 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/Doctor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/Doctor0000644000175000017500000000414610365120337033516 0ustar twernertwerner/* * 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.remoting.samples.transporter.complex; import java.util.ArrayList; import java.util.List; /** * @author Tom Elrod */ public class Doctor { private String fullName = null; private String specialty = null; private List patients = new ArrayList(); private Doctor() { } public Doctor(String name, String specialty) { this.fullName = name; this.specialty = specialty; } public String getSpecialty() { return specialty; } public void setSpecialty(String specialty) { this.specialty = specialty; } public String getFullName() { return fullName; } public String toString() { String ret = "Doctor:\n\tName: " + fullName + "\n\tSpecialty: " + specialty; int numOfPatients = patients.size(); if(numOfPatients > 0) { ret = ret + "\n\tPatients:\n"; for(int x = 0; x < numOfPatients; x++) { ret = ret + "\t" + patients.get(x); } } return ret; } public void addPatient(Patient pat1) { patients.add(pat1); } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/ProviderInterface.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/Provid0000644000175000017500000000272410365120337033527 0ustar twernertwerner/* * 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.remoting.samples.transporter.complex; import org.jboss.remoting.samples.transporter.complex.Doctor; import org.jboss.remoting.samples.transporter.complex.NoDoctorAvailableException; import org.jboss.remoting.samples.transporter.complex.Patient; /** * @author Tom Elrod */ public interface ProviderInterface { public Doctor findDoctor(Patient patient) throws NoDoctorAvailableException; public void retireDoctor(Doctor doctor); }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/client/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/client0000755000175000017500000000000011632407051033532 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/client/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/client0000644000175000017500000000747710365120337033554 0ustar twernertwerner/* * 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.remoting.samples.transporter.complex.client; import org.jboss.remoting.samples.transporter.complex.Doctor; import org.jboss.remoting.samples.transporter.complex.NoDoctorAvailableException; import org.jboss.remoting.samples.transporter.complex.Patient; import org.jboss.remoting.samples.transporter.complex.ProviderInterface; import org.jboss.remoting.transporter.TransporterClient; /** * @author Tom Elrod */ public class Client { private String locatorURI = "socket://localhost:5401/?serializationtype=jboss"; public void makeClientCall() throws Exception { // First create patient and populate with data Patient patient = new Patient("Bill", "Gates"); patient.setAilmentType("financial"); patient.setAilmentDescription("Money coming out the wazoo."); System.out.println("*** Have a new patient that needs a doctor. The patient is:\n" + patient); // now create remote provide interface to call on ProviderInterface providerProcessor = (ProviderInterface) TransporterClient.createTransporterClient(locatorURI, ProviderInterface.class); try { // find a doctor that can help our patient. Note, if none found, will throw an exception System.out.println("*** Looking for doctor that can help our patient...\n"); Doctor doctor = providerProcessor.findDoctor(patient); // notice that list of patients now includes our patient, Bill Gates System.out.println("*** Found doctor for our patient. Doctor found is:\n" + doctor); // assign doctor as patient's doctor patient.setDoctor(doctor); System.out.println("*** Set doctor as patient's doctor. Patient info is now:\n" + patient); // let's say our doctor made enough money to retire after helping out our patient, Bill. providerProcessor.retireDoctor(doctor); // let's create a new patient and find a doctor for him Patient patient2 = new Patient("Larry", "Page"); patient2.setAilmentType("financial"); patient2.setAilmentDescription("Money coming out the wazoo."); System.out.println("*** Have a new patient that we need to find a doctor for (remember, the previous one retired and there are no others)"); providerProcessor.findDoctor(patient2); } catch(NoDoctorAvailableException e) { System.out.println("*** Could not find doctor for patient. This is an expected exception when there are not doctors available."); e.printStackTrace(); } TransporterClient.destroyTransporterClient(providerProcessor); } static public void main(String[] args) { Client client = new Client(); try { client.makeClientCall(); } catch(Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/server/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/server0000755000175000017500000000000011632407051033562 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/server/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/server0000644000175000017500000000426510365120337033574 0ustar twernertwerner/* * 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.remoting.samples.transporter.complex.server; import org.jboss.remoting.samples.transporter.complex.ProviderInterface; import org.jboss.remoting.samples.transporter.complex.ProviderInterfaceImpl; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Server { public static String locatorURI = "socket://localhost:5401/?serializationtype=jboss"; private TransporterServer server = null; public void start() throws Exception { server = TransporterServer.createTransporterServer(getLocatorURI(), new ProviderInterfaceImpl(), ProviderInterface.class.getName(), true); } protected String getLocatorURI() { return locatorURI; } public void stop() { if(server != null) { server.stop(); } } public static void main(String[] args) { Server server = new Server(); try { server.start(); Thread.currentThread().sleep(60000); } catch(Exception e) { e.printStackTrace(); } finally { server.stop(); } } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/Information.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/Inform0000644000175000017500000000234710365120337033517 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.complex; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jboss.remoting.samples.transporter.complex.Doctor; /** * @author Tom Elrod */ public class Information { private static Information info = new Information(); private static Map providers = new HashMap(); private static List patients = new ArrayList(); static { Doctor p1 = new Doctor("Andy Jones", "financial"); providers.put("financial", p1); Doctor p2 = new Doctor("Joe Smith", "medical"); providers.put("medical", p2); Patient pat1 = new Patient("Larry", "Ellison"); pat1.setDoctor(p1); p1.addPatient(pat1); patients.add(pat1); Patient pat2 = new Patient("Steve", "Jobs"); pat2.setDoctor(p1); p1.addPatient(pat2); } public static Information getInstance() { return info; } public Doctor getProviderBySpecialty(String ailmentType) { return (Doctor) providers.get(ailmentType); } public void retireDoctor(Doctor doctor) { String specialty = doctor.getSpecialty(); providers.remove(specialty); } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/NoDoctorAvailableException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/NoDoct0000644000175000017500000000041410365120337033444 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.complex; /** * @author Tom Elrod */ public class NoDoctorAvailableException extends Throwable { public NoDoctorAvailableException(String s) { super(s); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/Patient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/Patien0000644000175000017500000000227310365120337033503 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.complex; import org.jboss.remoting.samples.transporter.complex.Doctor; /** * @author Tom Elrod */ public class Patient { private String firstName = null; private String lastName = null; private Doctor doctor = null; private String ailmentType = null; private String ailmentDescription = null; private Patient() { } public Patient(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public void setDoctor(Doctor doctor) { this.doctor = doctor; } public String toString() { return "\nPatient:\n\tName: " + firstName + " " + lastName + "\n\tAilment - Type: " + ailmentType + ", Description: " + ailmentDescription + (doctor != null ? ("\n\tDoctor - Name: " + doctor.getFullName()) : "") + "\n"; } public void setAilmentType(String ailmentType) { this.ailmentType = ailmentType; } public void setAilmentDescription(String ailmentDesc) { this.ailmentDescription = ailmentDesc; } public String getAilmentType() { return ailmentType; } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/ProviderInterfaceImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/complex/Provid0000644000175000017500000000427310365120337033530 0ustar twernertwerner/* * 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.remoting.samples.transporter.complex; import org.jboss.remoting.samples.transporter.complex.Doctor; import org.jboss.remoting.samples.transporter.complex.Information; import org.jboss.remoting.samples.transporter.complex.NoDoctorAvailableException; import org.jboss.remoting.samples.transporter.complex.Patient; import org.jboss.remoting.samples.transporter.complex.ProviderInterface; /** * @author Tom Elrod */ public class ProviderInterfaceImpl implements ProviderInterface { public Doctor findDoctor(Patient patient) throws NoDoctorAvailableException { // get the patient's ailment type and look for doctor that specializes String ailmentType = patient.getAilmentType(); Information info = Information.getInstance(); Doctor doc = info.getProviderBySpecialty(ailmentType); if(doc != null) { doc.addPatient(patient); return doc; } else { throw new NoDoctorAvailableException("No doctor available for ailment '" + ailmentType + "'"); } } public void retireDoctor(Doctor doctor) { Information info = Information.getInstance(); info.retireDoctor(doctor); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/0000755000175000017500000000000011632407052032520 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/client/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/clien0000755000175000017500000000000011632407052033533 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/client/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/clien0000644000175000017500000000432510425421525033541 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.multiple.client; import org.jboss.remoting.samples.transporter.multiple.Account; import org.jboss.remoting.samples.transporter.multiple.AccountProcessor; import org.jboss.remoting.samples.transporter.multiple.Address; import org.jboss.remoting.samples.transporter.multiple.Customer; import org.jboss.remoting.samples.transporter.multiple.CustomerProcessor; import org.jboss.remoting.transporter.TransporterClient; /** * @author Tom Elrod */ public class Client { private String locatorURI = "socket://localhost:5400"; public void makeClientCall() throws Exception { Customer customer = createCustomer(); CustomerProcessor customerProcessor = (CustomerProcessor) TransporterClient.createTransporterClient(locatorURI, CustomerProcessor.class); System.out.println("Customer to be processed: " + customer); Customer processedCustomer = customerProcessor.processCustomer(customer); System.out.println("Customer is now: " + processedCustomer); AccountProcessor accountProcessor = (AccountProcessor) TransporterClient.createTransporterClient(locatorURI, AccountProcessor.class); System.out.println("Asking for a new account to be created for customer."); Account account = accountProcessor.createAccount(processedCustomer); System.out.println("New account: " + account); TransporterClient.destroyTransporterClient(customerProcessor); TransporterClient.destroyTransporterClient(accountProcessor); } private Customer createCustomer() { Customer cust = new Customer(); cust.setFirstName("Bob"); cust.setLastName("Smith"); Address addr = new Address(); addr.setStreet("101 Oak Street"); addr.setCity("Atlanta"); addr.setState("GA"); addr.setZip(30249); cust.setAddr(addr); return cust; } public static void main(String[] args) { org.jboss.remoting.samples.transporter.multiple.client.Client client = new org.jboss.remoting.samples.transporter.multiple.client.Client(); try { client.makeClientCall(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Address.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Addre0000644000175000017500000000157610417616476033507 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.multiple; import java.io.Serializable; /** * Simple data object for mailing address. * * @author Tom Elrod */ public class Address implements Serializable { private String street = null; private String city = null; private String state = null; private int zip = -1; public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getState() { return state; } public void setState(String state) { this.state = state; } public int getZip() { return zip; } public void setZip(int zip) { this.zip = zip; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Account.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Accou0000644000175000017500000000331310417616476033511 0ustar twernertwerner/* * 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.remoting.samples.transporter.multiple; import java.io.Serializable; /** * Account holds account number and customer that belongs to account. * * @author Tom Elrod */ public class Account implements Serializable { private Customer customer; private int accountNumber; public Account(Customer customer, int accountNumber) { this.customer = customer; this.accountNumber = accountNumber; } public Customer getCustomer() { return customer; } public int getAccountNumber() { return accountNumber; } public String toString() { return "Account - account number: " + accountNumber + "\nCustomer: " + customer; } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/CustomerProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Custo0000644000175000017500000000112410417616476033552 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.multiple; /** * Interface to be implemented for classes that process * a customer object (which means basically setting customer * number). * * @author Tom Elrod */ public interface CustomerProcessor { /** * Process a customer object. Implementors * should ensure that the customer object * passed as parameter should have its internal * state changed somehow and returned. * * @param customer * @return */ public Customer processCustomer(Customer customer); } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/server/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/serve0000755000175000017500000000000011632407052033565 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/server/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/serve0000644000175000017500000000243110417616476033603 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.multiple.server; import org.jboss.remoting.samples.transporter.multiple.CustomerProcessorImpl; import org.jboss.remoting.samples.transporter.multiple.AccountProcessorImpl; import org.jboss.remoting.samples.transporter.multiple.CustomerProcessor; import org.jboss.remoting.samples.transporter.multiple.AccountProcessor; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Server { private String locatorURI = "socket://localhost:5400"; private TransporterServer server = null; public void start() throws Exception { server = TransporterServer.createTransporterServer(locatorURI, new CustomerProcessorImpl(), CustomerProcessor.class.getName()); server.addHandler(new AccountProcessorImpl(), AccountProcessor.class.getName()); } public void stop() { if(server != null) { server.stop(); } } public static void main(String[] args) { Server server = new Server(); try { server.start(); Thread.currentThread().sleep(60000); } catch(Exception e) { e.printStackTrace(); } finally { server.stop(); } } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Customer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Custo0000644000175000017500000000305610417616476033560 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.multiple; import java.io.Serializable; /** * Simple data object to represent customer data, to include * Address object. * * @author Tom Elrod */ public class Customer implements Serializable { private String firstName = null; private String lastName = null; private Address addr = null; private int customerId = -1; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Address getAddr() { return addr; } public void setAddr(Address addr) { this.addr = addr; } public int getCustomerId() { return customerId; } public void setCustomerId(int customerId) { this.customerId = customerId; } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("\nCustomer:\n"); buffer.append("customer id: " + customerId + "\n"); buffer.append("first name: " + firstName + "\n"); buffer.append("last name: " + lastName + "\n"); buffer.append("street: " + addr.getStreet() + "\n"); buffer.append("city: " + addr.getCity() + "\n"); buffer.append("state: " + addr.getState() + "\n"); buffer.append("zip: " + addr.getZip() + "\n"); return buffer.toString(); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/AccountProcessorImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Accou0000644000175000017500000000316210417616476033513 0ustar twernertwerner/* * 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.remoting.samples.transporter.multiple; /** * @author Tom Elrod */ public class AccountProcessorImpl implements AccountProcessor { private static int accountNumberCounter = 1; public Account createAccount(Customer customer) { Account account = new Account(customer, getNextAccountNumber()); System.out.println("Created new account with account number: " + account.getAccountNumber() + " and for customer:\n" + account.getCustomer()); return account; } private int getNextAccountNumber() { return accountNumberCounter++; } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/AccountProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Accou0000644000175000017500000000252310417616476033513 0ustar twernertwerner/* * 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.remoting.samples.transporter.multiple; /** * @author Tom Elrod */ public interface AccountProcessor { /** * Simply creates a new Account with a new account number * and the customer specified. * * @param customer * @return */ public Account createAccount(Customer customer); }././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/CustomerProcessorImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/multiple/Custo0000644000175000017500000000144710417616476033562 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.multiple; import java.util.Random; /** * @author Tom Elrod */ public class CustomerProcessorImpl implements CustomerProcessor { /** * Takes the customer passed, and if not null and customer id * is less than 0, will create a new random id and set it. * The customer object returned will be the modified customer * object passed. * * @param customer * @return */ public Customer processCustomer(Customer customer) { if(customer != null && customer.getCustomerId() < 0) { customer.setCustomerId(new Random().nextInt(1000)); } System.out.println("processed customer with new id of " + customer.getCustomerId()); return customer; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/0000755000175000017500000000000011632407051032045 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/client/0000755000175000017500000000000011632407051033323 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/client/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/client/C0000644000175000017500000000562410463461462033446 0ustar twernertwerner/* * 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.remoting.samples.transporter.proxy.client; import org.jboss.remoting.samples.transporter.proxy.Address; import org.jboss.remoting.samples.transporter.proxy.Customer; import org.jboss.remoting.samples.transporter.proxy.CustomerProcessor; import org.jboss.remoting.samples.transporter.proxy.ICustomer; import org.jboss.remoting.transporter.TransporterClient; /** * @author Tom Elrod */ public class Client { private String locatorURI = "socket://localhost:5400"; public void makeClientCall() throws Exception { Customer customer = createCustomer(); CustomerProcessor customerProcessor = (CustomerProcessor) TransporterClient.createTransporterClient(locatorURI, CustomerProcessor.class); System.out.println("Customer to be processed: " + customer); ICustomer processedCustomer = customerProcessor.processCustomer(customer); // processedCustomer returned is actually a proxy to the Customer instnace // that lives on the server. So when print it out below, will actually // be calling back to the server to get the string (vi toString() call). // Notice the output of 'Customer.toString() being called.' on the server side. System.out.println("Customer is now: " + processedCustomer); TransporterClient.destroyTransporterClient(customerProcessor); } private Customer createCustomer() { Customer cust = new Customer(); cust.setFirstName("Bob"); cust.setLastName("Smith"); Address addr = new Address(); addr.setStreet("101 Oak Street"); addr.setCity("Atlanta"); addr.setState("GA"); addr.setZip(30249); cust.setAddr(addr); return cust; } public static void main(String[] args) { Client client = new Client(); try { client.makeClientCall(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/Address.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/Address.0000644000175000017500000000353510426307310033436 0ustar twernertwerner/* * 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.remoting.samples.transporter.proxy; import java.io.Serializable; /** * Simple data object for mailing address. * * @author Tom Elrod */ public class Address implements Serializable { private String street = null; private String city = null; private String state = null; private int zip = -1; public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getState() { return state; } public void setState(String state) { this.state = state; } public int getZip() { return zip; } public void setZip(int zip) { this.zip = zip; } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/CustomerProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/Customer0000644000175000017500000000306410426307310033571 0ustar twernertwerner/* * 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.remoting.samples.transporter.proxy; /** * Interface to be implemented for classes that process * a customer object (which means basically setting customer * number). * * @author Tom Elrod */ public interface CustomerProcessor { /** * Process a customer object. Implementors * should ensure that the customer object * passed as parameter should have its internal * state changed somehow and returned. * * @param customer * @return */ public ICustomer processCustomer(Customer customer); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/server/0000755000175000017500000000000011632407051033353 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/server/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/server/S0000644000175000017500000000400610463461462033507 0ustar twernertwerner/* * 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.remoting.samples.transporter.proxy.server; import org.jboss.remoting.samples.transporter.proxy.CustomerProcessor; import org.jboss.remoting.samples.transporter.proxy.CustomerProcessorImpl; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Server { private String locatorURI = "socket://localhost:5400"; private TransporterServer server = null; public void start() throws Exception { server = TransporterServer.createTransporterServer(locatorURI, new CustomerProcessorImpl(), CustomerProcessor.class.getName()); } public void stop() { if (server != null) { server.stop(); } } public static void main(String[] args) { Server server = new Server(); try { server.start(); Thread.currentThread().sleep(60000); } catch (Exception e) { e.printStackTrace(); } finally { server.stop(); } } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/Customer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/Customer0000644000175000017500000000512710426307310033573 0ustar twernertwerner/* * 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.remoting.samples.transporter.proxy; import java.io.Serializable; /** * Simple data object to represent customer data, to include * Address object. * * @author Tom Elrod */ public class Customer implements Serializable, ICustomer { private String firstName = null; private String lastName = null; private Address addr = null; private int customerId = -1; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Address getAddr() { return addr; } public void setAddr(Address addr) { this.addr = addr; } public int getCustomerId() { return customerId; } public void setCustomerId(int customerId) { this.customerId = customerId; } public String toString() { System.out.println("Customer.toString() being called."); StringBuffer buffer = new StringBuffer(); buffer.append("\nCustomer:\n"); buffer.append("customer id: " + customerId + "\n"); buffer.append("first name: " + firstName + "\n"); buffer.append("last name: " + lastName + "\n"); buffer.append("street: " + addr.getStreet() + "\n"); buffer.append("city: " + addr.getCity() + "\n"); buffer.append("state: " + addr.getState() + "\n"); buffer.append("zip: " + addr.getZip() + "\n"); return buffer.toString(); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/ICustomer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/ICustome0000644000175000017500000000063710426307310033523 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.proxy; /** * @author Tom Elrod */ public interface ICustomer { String getFirstName(); void setFirstName(String firstName); String getLastName(); void setLastName(String lastName); Address getAddr(); void setAddr(Address addr); int getCustomerId(); void setCustomerId(int customerId); } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/CustomerProcessorImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/proxy/Customer0000644000175000017500000000446610426307310033600 0ustar twernertwerner/* * 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.remoting.samples.transporter.proxy; import org.jboss.remoting.transporter.TransporterClient; import org.jboss.remoting.transporter.TransporterServer; import java.util.Random; /** * @author Tom Elrod */ public class CustomerProcessorImpl implements CustomerProcessor { private String locatorURI = "socket://localhost:5401"; /** * Takes the customer passed, and if not null and customer id * is less than 0, will create a new random id and set it. * The customer object returned will be the modified customer * object passed. * * @param customer * @return */ public ICustomer processCustomer(Customer customer) { if (customer != null && customer.getCustomerId() < 0) { customer.setCustomerId(new Random().nextInt(1000)); } ICustomer customerProxy = null; try { TransporterServer server = TransporterServer.createTransporterServer(locatorURI, customer, ICustomer.class.getName()); customerProxy = (ICustomer) TransporterClient.createTransporterClient(locatorURI, ICustomer.class); } catch (Exception e) { e.printStackTrace(); } System.out.println("processed customer with new id of " + customerProxy.getCustomerId()); return customerProxy; } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/0000755000175000017500000000000011632407052033542 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/client/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/0000755000175000017500000000000011632407052033542 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/client/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/0000644000175000017500000000572410425421525033554 0ustar twernertwerner/* * 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.remoting.samples.transporter.serialization.client; import org.jboss.remoting.samples.transporter.basic.Address; import org.jboss.remoting.samples.transporter.basic.Customer; import org.jboss.remoting.samples.transporter.serialization.Order; import org.jboss.remoting.samples.transporter.serialization.OrderProcessor; import org.jboss.remoting.transporter.TransporterClient; import java.util.ArrayList; import java.util.List; /** * @author Tom Elrod */ public class Client { private String locatorURI = "socket://localhost:5400/?serializationtype=jboss"; public void makeClientCall() throws Exception { Order order = createOrder(); OrderProcessor orderProcessor = (OrderProcessor) TransporterClient.createTransporterClient(locatorURI, OrderProcessor.class); System.out.println("Order to be processed: " + order); Order changedOrder = orderProcessor.processOrder(order); System.out.println("Order now processed " + changedOrder); TransporterClient.destroyTransporterClient(orderProcessor); } private Order createOrder() { Order order = new Order(); Customer customer = createCustomer(); order.setCustomer(customer); List items = new ArrayList(); items.add("Xbox 360"); items.add("Wireless controller"); items.add("Ghost Recon 3"); order.setItems(items); return order; } private Customer createCustomer() { Customer cust = new Customer(); cust.setFirstName("Bob"); cust.setLastName("Smith"); Address addr = new Address(); addr.setStreet("101 Oak Street"); addr.setCity("Atlanta"); addr.setState("GA"); addr.setZip(30249); cust.setAddr(addr); return cust; } public static void main(String[] args) { Client client = new Client(); try { client.makeClientCall(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/server/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/0000755000175000017500000000000011632407052033542 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/server/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/0000644000175000017500000000405110424205673033547 0ustar twernertwerner/* * 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.remoting.samples.transporter.serialization.server; import org.jboss.remoting.samples.transporter.serialization.OrderProcessorImpl; import org.jboss.remoting.samples.transporter.serialization.OrderProcessor; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Server { private String locatorURI = "socket://localhost:5400/?serializationtype=jboss"; private TransporterServer server = null; public void start() throws Exception { server = TransporterServer.createTransporterServer(locatorURI, new OrderProcessorImpl(), OrderProcessor.class.getName()); } public void stop() { if(server != null) { server.stop(); } } public static void main(String[] args) { Server server = new Server(); try { server.start(); Thread.currentThread().sleep(60000); } catch(Exception e) { e.printStackTrace(); } finally { server.stop(); } } }././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/OrderProcessorImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/0000644000175000017500000000461210365120337033547 0ustar twernertwerner/* * 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.remoting.samples.transporter.serialization; import java.util.Iterator; import java.util.List; import java.util.Random; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.samples.transporter.basic.CustomerProcessorImpl; import org.jboss.remoting.samples.transporter.serialization.Order; import org.jboss.remoting.samples.transporter.serialization.OrderProcessor; /** * @author Tom Elrod */ public class OrderProcessorImpl implements OrderProcessor { private CustomerProcessor customerProcessor = null; public OrderProcessorImpl() { customerProcessor = new CustomerProcessorImpl(); } public Order processOrder(Order order) { System.out.println("Incoming order to process from customer.\n" + order.getCustomer()); // has this customer been processed? if(order.getCustomer().getCustomerId() < 0) { order.setCustomer(customerProcessor.processCustomer(order.getCustomer())); } List items = order.getItems(); System.out.println("Items ordered:"); Iterator itr = items.iterator(); while(itr.hasNext()) { System.out.println(itr.next()); } order.setOrderId(new Random().nextInt(1000)); order.setProcessed(true); System.out.println("Order processed. Order id now: " + order.getOrderId()); return order; } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/Order.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/0000644000175000017500000000464010365120337033550 0ustar twernertwerner/* * 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.remoting.samples.transporter.serialization; import java.util.Iterator; import java.util.List; import org.jboss.remoting.samples.transporter.basic.Customer; /** * @author Tom Elrod */ public class Order { private int orderId = -1; private boolean isProcessed = false; private Customer customer = null; private List items = null; public int getOrderId() { return orderId; } public void setOrderId(int orderId) { this.orderId = orderId; } public boolean isProcessed() { return isProcessed; } public void setProcessed(boolean processed) { isProcessed = processed; } public Customer getCustomer() { return customer; } public void setCustomer(Customer customer) { this.customer = customer; } public List getItems() { return items; } public void setItems(List items) { this.items = items; } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("\nOrder:\n"); buffer.append("\nIs processed: " + isProcessed); buffer.append("\nOrder id: " + orderId); buffer.append(customer.toString()); buffer.append("\nItems ordered:"); Iterator itr = items.iterator(); while(itr.hasNext()) { buffer.append("\n" + itr.next().toString()); } return buffer.toString(); } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/OrderProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/serialization/0000644000175000017500000000237210365120337033550 0ustar twernertwerner/* * 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.remoting.samples.transporter.serialization; import org.jboss.remoting.samples.transporter.serialization.Order; /** * @author Tom Elrod */ public interface OrderProcessor { public Order processOrder(Order order); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/0000755000175000017500000000000011632407051032656 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/client/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/clie0000755000175000017500000000000011632407051033513 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/client/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/clie0000644000175000017500000000571110425421525033522 0ustar twernertwerner/* * 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.remoting.samples.transporter.clustered.client; import org.jboss.remoting.samples.transporter.basic.Address; import org.jboss.remoting.samples.transporter.basic.Customer; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.samples.transporter.clustered.server.SocketServer; import org.jboss.remoting.transporter.TransporterClient; /** * @author Tom Elrod */ public class Client { private String locatorURI = SocketServer.locatorURI; private CustomerProcessor customerProcessor = null; public void makeClientCall() throws Exception { Customer customer = createCustomer(); System.out.println("Customer to be processed: " + customer); Customer processedCustomer = customerProcessor.processCustomer(customer); System.out.println("Customer is now: " + processedCustomer); //TransporterClient.destroyTransporterClient(customerProcessor); } public void getCustomerProcessor() throws Exception { customerProcessor = (CustomerProcessor) TransporterClient.createTransporterClient(locatorURI, CustomerProcessor.class, true); } private Customer createCustomer() { Customer cust = new Customer(); cust.setFirstName("Bob"); cust.setLastName("Smith"); Address addr = new Address(); addr.setStreet("101 Oak Stree"); addr.setCity("Atlanta"); addr.setZip(30249); cust.setAddr(addr); return cust; } public static void main(String[] args) { Client client = new Client(); try { client.getCustomerProcessor(); while (true) { try { client.makeClientCall(); Thread.currentThread().sleep(5000); } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/server/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/serv0000755000175000017500000000000011632407051033556 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/server/HTTPServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/serv0000644000175000017500000000315010365120337033560 0ustar twernertwerner/* * 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.remoting.samples.transporter.clustered.server; /** * @author Tom Elrod */ public class HTTPServer extends SocketServer { private String localLocatorURI = "http://localhost:5600"; protected String getLocatorURI() { return localLocatorURI; } public static void main(String[] args) { SocketServer server = new HTTPServer(); try { server.start(); Thread.currentThread().sleep(60000); } catch(Exception e) { e.printStackTrace(); } finally { server.stop(); } } }././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/server/SocketServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/serv0000644000175000017500000000425410365120337033566 0ustar twernertwerner/* * 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.remoting.samples.transporter.clustered.server; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.samples.transporter.basic.CustomerProcessorImpl; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class SocketServer { public static String locatorURI = "socket://localhost:5400"; private TransporterServer server = null; public void start() throws Exception { server = TransporterServer.createTransporterServer(getLocatorURI(), new CustomerProcessorImpl(), CustomerProcessor.class.getName(), true); } protected String getLocatorURI() { return locatorURI; } public void stop() { if(server != null) { server.stop(); } } public static void main(String[] args) { SocketServer server = new SocketServer(); try { server.start(); Thread.currentThread().sleep(60000); } catch(Exception e) { e.printStackTrace(); } finally { server.stop(); } } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/server/RMIServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/clustered/serv0000644000175000017500000000314510365120337033564 0ustar twernertwerner/* * 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.remoting.samples.transporter.clustered.server; /** * @author Tom Elrod */ public class RMIServer extends SocketServer { private String localLocatorURI = "rmi://localhost:5500"; protected String getLocatorURI() { return localLocatorURI; } public static void main(String[] args) { SocketServer server = new RMIServer(); try { server.start(); Thread.currentThread().sleep(60000); } catch(Exception e) { e.printStackTrace(); } finally { server.stop(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/0000755000175000017500000000000011632407051032155 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/Client.0000644000175000017500000000303410446027451033400 0ustar twernertwerner/* * 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.remoting.samples.transporter.simple; import org.jboss.remoting.transporter.TransporterClient; import java.util.Date; /** * @author Tom Elrod */ public class Client { public static void main(String[] args) throws Exception { DateProcessor dateProcessor = (DateProcessor) TransporterClient.createTransporterClient("socket://localhost:5400", DateProcessor.class); String formattedDate = dateProcessor.formatDate(new Date()); System.out.println("Current date: " + formattedDate); } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/DateProcessorImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/DatePro0000644000175000017500000000260610446027451033446 0ustar twernertwerner/* * 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.remoting.samples.transporter.simple; import java.text.DateFormat; import java.util.Date; /** * @author Tom Elrod */ public class DateProcessorImpl implements DateProcessor { public String formatDate(Date dateToConvert) { DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM); return dateFormat.format(dateToConvert); } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/Server.0000644000175000017500000000270510446027451033434 0ustar twernertwerner/* * 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.remoting.samples.transporter.simple; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Server { public static void main(String[] args) throws Exception { TransporterServer server = TransporterServer.createTransporterServer("socket://localhost:5400", new DateProcessorImpl(), DateProcessor.class.getName()); Thread.sleep(10000); server.stop(); } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/DateProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/simple/DatePro0000644000175000017500000000231310446027451033441 0ustar twernertwerner/* * 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.remoting.samples.transporter.simple; import java.util.Date; /** * @author Tom Elrod */ public interface DateProcessor { public String formatDate(Date dateToConvert); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/0000755000175000017500000000000011632407051031745 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/client/0000755000175000017500000000000011632407051033223 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/client/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/client/C0000644000175000017500000000502010425421525033326 0ustar twernertwerner/* * 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.remoting.samples.transporter.basic.client; import org.jboss.remoting.samples.transporter.basic.Address; import org.jboss.remoting.samples.transporter.basic.Customer; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.transporter.TransporterClient; /** * @author Tom Elrod */ public class Client { private String locatorURI = "socket://localhost:5400"; public void makeClientCall() throws Exception { Customer customer = createCustomer(); CustomerProcessor customerProcessor = (CustomerProcessor) TransporterClient.createTransporterClient(locatorURI, CustomerProcessor.class); System.out.println("Customer to be processed: " + customer); Customer processedCustomer = customerProcessor.processCustomer(customer); System.out.println("Customer is now: " + processedCustomer); TransporterClient.destroyTransporterClient(customerProcessor); } private Customer createCustomer() { Customer cust = new Customer(); cust.setFirstName("Bob"); cust.setLastName("Smith"); Address addr = new Address(); addr.setStreet("101 Oak Street"); addr.setCity("Atlanta"); addr.setState("GA"); addr.setZip(30249); cust.setAddr(addr); return cust; } public static void main(String[] args) { Client client = new Client(); try { client.makeClientCall(); } catch (Exception e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/Address.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/Address.0000644000175000017500000000353510365120337033342 0ustar twernertwerner/* * 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.remoting.samples.transporter.basic; import java.io.Serializable; /** * Simple data object for mailing address. * * @author Tom Elrod */ public class Address implements Serializable { private String street = null; private String city = null; private String state = null; private int zip = -1; public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getState() { return state; } public void setState(String state) { this.state = state; } public int getZip() { return zip; } public void setZip(int zip) { this.zip = zip; } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/CustomerProcessor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/Customer0000644000175000017500000000316210365120337033474 0ustar twernertwerner/* * 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.remoting.samples.transporter.basic; import org.jboss.remoting.samples.transporter.basic.Customer; /** * Interface to be implemented for classes that process * a customer object (which means basically setting customer * number). * * @author Tom Elrod */ public interface CustomerProcessor { /** * Process a customer object. Implementors * should ensure that the customer object * passed as parameter should have its internal * state changed somehow and returned. * * @param customer * @return */ public Customer processCustomer(Customer customer); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/server/0000755000175000017500000000000011632407051033253 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/server/Server.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/server/S0000644000175000017500000000400410424205673033402 0ustar twernertwerner/* * 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.remoting.samples.transporter.basic.server; import org.jboss.remoting.samples.transporter.basic.CustomerProcessorImpl; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.transporter.TransporterServer; /** * @author Tom Elrod */ public class Server { private String locatorURI = "socket://localhost:5400"; private TransporterServer server = null; public void start() throws Exception { server = TransporterServer.createTransporterServer(locatorURI, new CustomerProcessorImpl(), CustomerProcessor.class.getName()); } public void stop() { if(server != null) { server.stop(); } } public static void main(String[] args) { Server server = new Server(); try { server.start(); Thread.currentThread().sleep(60000); } catch(Exception e) { e.printStackTrace(); } finally { server.stop(); } } }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/Customer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/Customer0000644000175000017500000000511210365120337033471 0ustar twernertwerner/* * 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.remoting.samples.transporter.basic; import java.io.Serializable; import org.jboss.remoting.samples.transporter.basic.Address; /** * Simple data object to represent customer data, to include * Address object. * * @author Tom Elrod */ public class Customer implements Serializable { private String firstName = null; private String lastName = null; private Address addr = null; private int customerId = -1; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public Address getAddr() { return addr; } public void setAddr(Address addr) { this.addr = addr; } public int getCustomerId() { return customerId; } public void setCustomerId(int customerId) { this.customerId = customerId; } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("\nCustomer:\n"); buffer.append("customer id: " + customerId + "\n"); buffer.append("first name: " + firstName + "\n"); buffer.append("last name: " + lastName + "\n"); buffer.append("street: " + addr.getStreet() + "\n"); buffer.append("city: " + addr.getCity() + "\n"); buffer.append("state: " + addr.getState() + "\n"); buffer.append("zip: " + addr.getZip() + "\n"); return buffer.toString(); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/CustomerProcessorImpl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/basic/Customer0000644000175000017500000000361210365120337033474 0ustar twernertwerner/* * 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.remoting.samples.transporter.basic; import java.util.Random; import org.jboss.remoting.samples.transporter.basic.Customer; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; /** * @author Tom Elrod */ public class CustomerProcessorImpl implements CustomerProcessor { /** * Takes the customer passed, and if not null and customer id * is less than 0, will create a new random id and set it. * The customer object returned will be the modified customer * object passed. * * @param customer * @return */ public Customer processCustomer(Customer customer) { if(customer != null && customer.getCustomerId() < 0) { customer.setCustomerId(new Random().nextInt(1000)); } System.out.println("processed customer with new id of " + customer.getCustomerId()); return customer; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/0000755000175000017500000000000011632407052032177 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/client/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/client/0000755000175000017500000000000011632407052033455 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/client/Client.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/client/0000644000175000017500000000704410425421525033464 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.custom.client; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.samples.transporter.basic.Address; import org.jboss.remoting.samples.transporter.basic.Customer; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.samples.transporter.custom.server.JNDIServer; import org.jboss.remoting.samples.transporter.custom.server.SocketServer; import org.jboss.remoting.transporter.InternalTransporterServices; import org.jboss.remoting.transporter.TransporterClient; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.net.InetAddress; /** * @author Tom Elrod */ public class Client { private String locatorURI = SocketServer.locatorURI; private CustomerProcessor customerProcessor = null; public void makeClientCall() throws Exception { Customer customer = createCustomer(); System.out.println("Customer to be processed: " + customer); Customer processedCustomer = customerProcessor.processCustomer(customer); System.out.println("Customer is now: " + processedCustomer); //TransporterClient.destroyTransporterClient(customerProcessor); } public void getCustomerProcessor() throws Exception { initTransporterServices(); customerProcessor = (CustomerProcessor) TransporterClient.createTransporterClient(locatorURI, CustomerProcessor.class, true); } private void initTransporterServices() throws Exception { // create MBeanServer MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); NetworkRegistry registry = NetworkRegistry.getInstance(); String host = InetAddress.getLocalHost().getHostAddress(); JNDIDetector jndiDetector = new JNDIDetector(); jndiDetector.setPort(JNDIServer.JNDI_PORT); jndiDetector.setHost(host); jndiDetector.setContextFactory("org.jnp.interfaces.NamingContextFactory"); jndiDetector.setURLPackage("org.jboss.naming:org.jnp.interfaces"); InternalTransporterServices transporterService = InternalTransporterServices.getInstance(); transporterService.setup(mbeanServer, jndiDetector, new ObjectName("remoting:type=Detector,transport=jndi"), registry, new ObjectName("remoting:type=NetworkRegistry"), true, true); //TODO: -TME Have to start the detector after setup() call? jndiDetector.start(); } private Customer createCustomer() { Customer cust = new Customer(); cust.setFirstName("Bob"); cust.setLastName("Smith"); Address addr = new Address(); addr.setStreet("101 Oak Stree"); addr.setCity("Atlanta"); addr.setZip(30249); cust.setAddr(addr); return cust; } public static void main(String[] args) { org.jboss.remoting.samples.transporter.custom.client.Client client = new org.jboss.remoting.samples.transporter.custom.client.Client(); try { client.getCustomerProcessor(); while (true) { try { client.makeClientCall(); Thread.currentThread().sleep(5000); } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/0000755000175000017500000000000011632407052033505 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/JNDIServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/0000644000175000017500000000715411171061206033511 0ustar twernertwerner/* * 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.remoting.samples.transporter.custom.server; import org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer; import org.jboss.remoting.util.SecurityUtility; import org.jnp.server.Main; import java.lang.reflect.Method; import java.net.InetAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * @author Tom Elrod */ public class JNDIServer { public static final int JNDI_PORT = 2410; public static void main(String[] args) { try { Object namingBean = null; Class namingBeanImplClass = null; try { namingBeanImplClass = Class.forName("org.jnp.server.NamingBeanImpl"); namingBean = namingBeanImplClass.newInstance(); Method startMethod = namingBeanImplClass.getMethod("start", new Class[] {}); setSystemProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); startMethod.invoke(namingBean, new Object[] {}); } catch (Exception e) { SimpleJNDIServer.println("Cannot find NamingBeanImpl: must be running jdk 1.4"); } String host = InetAddress.getLocalHost().getHostAddress(); Main jserver = new Main(); if (namingBean != null) { Class namingBeanClass = Class.forName("org.jnp.server.NamingBean"); Method setNamingInfoMethod = jserver.getClass().getMethod("setNamingInfo", new Class[] {namingBeanClass}); setNamingInfoMethod.invoke(jserver, new Object[] {namingBean}); } int port = JNDI_PORT; jserver.setPort(port); jserver.setBindAddress(host); jserver.setRmiPort(31000); jserver.start(); System.out.println("Started JNDI server on " + host + ":" + port); while (true) { Thread.sleep(5000); } } catch (Exception e) { e.printStackTrace(); } } static private void setSystemProperty(final String name, final String value) { if (SecurityUtility.skipAccessControl()) { System.setProperty(name, value); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.setProperty(name, value); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/HTTPServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/0000644000175000017500000000701310425421525033510 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.custom.server; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.samples.transporter.basic.CustomerProcessorImpl; import org.jboss.remoting.transporter.InternalTransporterServices; import org.jboss.remoting.transporter.TransporterServer; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.InetAddress; /** * @author Tom Elrod */ public class HTTPServer { private TransporterServer server = null; public void start() throws Exception { initTransporterServices(); Element xmlConfig = getXmlConfig(); server = TransporterServer.createTransporterServer(xmlConfig, new CustomerProcessorImpl(), CustomerProcessor.class.getName(), true); } private Element getXmlConfig() throws ParserConfigurationException, IOException, SAXException { String transport = "http"; String host = "localhost"; int port = 5600; StringBuffer buf = new StringBuffer(); buf.append("\n"); buf.append(""); buf.append(""); buf.append("" + host + ""); buf.append("" + port + ""); buf.append(""); buf.append(""); Document xml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(buf.toString().getBytes())); return xml.getDocumentElement(); } public void stop() { if (server != null) { server.stop(); } } private void initTransporterServices() throws Exception { // create MBeanServer MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); NetworkRegistry registry = NetworkRegistry.getInstance(); String host = InetAddress.getLocalHost().getHostAddress(); JNDIDetector jndiDetector = new JNDIDetector(); jndiDetector.setPort(JNDIServer.JNDI_PORT); jndiDetector.setHost(host); jndiDetector.setContextFactory("org.jnp.interfaces.NamingContextFactory"); jndiDetector.setURLPackage("org.jboss.naming:org.jnp.interfaces"); InternalTransporterServices transporterService = InternalTransporterServices.getInstance(); transporterService.setup(mbeanServer, jndiDetector, new ObjectName("remoting:type=Detector,transport=jndi"), registry, new ObjectName("remoting:type=NetworkRegistry"), true, true); //TODO: -TME Have to start the detector after setup() call? jndiDetector.start(); } public static void main(String[] args) { HTTPServer server = new HTTPServer(); try { server.start(); Thread.currentThread().sleep(60000); } catch (Exception e) { e.printStackTrace(); } finally { server.stop(); } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/SocketServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/0000644000175000017500000000560010425421525033510 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.custom.server; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.samples.transporter.basic.CustomerProcessorImpl; import org.jboss.remoting.transporter.InternalTransporterServices; import org.jboss.remoting.transporter.TransporterServer; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.net.InetAddress; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class SocketServer { public static String locatorURI = "socket://localhost:5400"; private TransporterServer server = null; public void start() throws Exception { initTransporterServices(); Map config = getConnectorConfig(); server = TransporterServer.createTransporterServer(getLocatorURI(), new CustomerProcessorImpl(), CustomerProcessor.class.getName(), config, true); } private Map getConnectorConfig() { Map config = new HashMap(); // setting socket timeout to 5 seconds config.put("timeout", "5000"); return config; } protected String getLocatorURI() { return SocketServer.locatorURI; } public void stop() { if (server != null) { server.stop(); } } private void initTransporterServices() throws Exception { // create MBeanServer MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); NetworkRegistry registry = NetworkRegistry.getInstance(); String host = InetAddress.getLocalHost().getHostAddress(); JNDIDetector jndiDetector = new JNDIDetector(); jndiDetector.setPort(JNDIServer.JNDI_PORT); jndiDetector.setHost(host); jndiDetector.setContextFactory("org.jnp.interfaces.NamingContextFactory"); jndiDetector.setURLPackage("org.jboss.naming:org.jnp.interfaces"); InternalTransporterServices transporterService = InternalTransporterServices.getInstance(); transporterService.setup(mbeanServer, jndiDetector, new ObjectName("remoting:type=Detector,transport=jndi"), registry, new ObjectName("remoting:type=NetworkRegistry"), true, true); //TODO: -TME Have to start the detector after setup() call? jndiDetector.start(); } public static void main(String[] args) { SocketServer server = new SocketServer(); try { server.start(); Thread.currentThread().sleep(60000); } catch (Exception e) { e.printStackTrace(); } finally { server.stop(); } } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/RMIServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/transporter/custom/server/0000644000175000017500000000500610425421525033510 0ustar twernertwernerpackage org.jboss.remoting.samples.transporter.custom.server; import org.jboss.remoting.detection.jndi.JNDIDetector; import org.jboss.remoting.network.NetworkRegistry; import org.jboss.remoting.samples.transporter.basic.CustomerProcessor; import org.jboss.remoting.samples.transporter.basic.CustomerProcessorImpl; import org.jboss.remoting.transporter.InternalTransporterServices; import org.jboss.remoting.transporter.TransporterServer; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; import java.net.InetAddress; /** * @author Tom Elrod */ public class RMIServer { private String localLocatorURI = "rmi://localhost:5500"; private TransporterServer server = null; public void start() throws Exception { initTransporterServices(); server = TransporterServer.createTransporterServer(localLocatorURI, new CustomerProcessorImpl(), CustomerProcessor.class.getName(), true); } public void stop() { if (server != null) { server.stop(); } } private void initTransporterServices() throws Exception { // create MBeanServer MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); NetworkRegistry registry = NetworkRegistry.getInstance(); String host = InetAddress.getLocalHost().getHostAddress(); JNDIDetector jndiDetector = new JNDIDetector(); jndiDetector.setPort(JNDIServer.JNDI_PORT); jndiDetector.setHost(host); jndiDetector.setContextFactory("org.jnp.interfaces.NamingContextFactory"); jndiDetector.setURLPackage("org.jboss.naming:org.jnp.interfaces"); InternalTransporterServices transporterService = InternalTransporterServices.getInstance(); transporterService.setup(mbeanServer, jndiDetector, new ObjectName("remoting:type=Detector,transport=jndi"), registry, new ObjectName("remoting:type=NetworkRegistry"), true, true); //TODO: -TME Have to start the detector after setup() call? jndiDetector.start(); } public static void main(String[] args) { RMIServer server = new RMIServer(); try { server.start(); Thread.currentThread().sleep(60000); } catch (Exception e) { e.printStackTrace(); } finally { server.stop(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/serialization/0000755000175000017500000000000011632407052031157 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/serialization/SerializationServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/serialization/Serializatio0000644000175000017500000001361010363346025033544 0ustar twernertwerner/* * 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.remoting.samples.serialization; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.samples.simple.SimpleServer; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.transport.Connector; /** * Simple remoting server that uses JBoss Serialization instead of standard java serialization. * Will receive and return a non-serializable payload. Uses inner class SampleInvocationHandler * as the invocation target handler class. *

          * NOTE: This requires jdk 1.5 *

          * * @author Tom Elrod */ public class SerializationServer { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; // String to be returned from invocation handler upon client invocation calls. private static final NonSerializablePayload RESPONSE_VALUE = new NonSerializablePayload("bar", 2); public void setupServer(String locatorURI) throws Exception { // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); Connector connector = new Connector(locator); // creates all the connector's needed resources, such as the server invoker connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } // NOTE: HAVE TO HAVE SERIALIZATION TYPE SET TO JBOSS FOR THIS SAMPLE String locatorURI = transport + "://" + host + ":" + port + "/?serializationtype=jboss"; SerializationServer server = new SerializationServer(); try { server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); System.out.println("Returning response of: " + RESPONSE_VALUE); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } /** * 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 } } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/serialization/NonSerializablePayload.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/serialization/NonSerializa0000644000175000017500000000357010363346025033507 0ustar twernertwerner/* * 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.remoting.samples.serialization; /** * @author Tom Elrod */ public class NonSerializablePayload { private String name = null; private int id = -1; /** * Is important that if using JBoss Serialization and non-serializable * payload objects, must have a void parameter contructor. It can * be a private method that is not used externally, but is needed * by JBoss Serialization when reconstructing the object instance * when sent over the network. */ private NonSerializablePayload() { } public NonSerializablePayload(String name, int id) { this.name = name; this.id = id; } public String getName() { return name; } public int getId() { return id; } public String toString() { return "NonSerializablePayload - name: " + name + ", id: " + id; } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/serialization/SerializationClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/serialization/Serializatio0000644000175000017500000000574410433770344033560 0ustar twernertwerner/* * 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.remoting.samples.serialization; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * Simple test client to make an invocation on remoting server using JBoss Serialization * instead of standard java serialization (with a non-serializable payload). *

          * NOTE: This requires jdk 1.5 *

          * @author Tom Elrod */ public class SerializationClient { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; public void makeInvocation(String locatorURI) throws Throwable { // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); NonSerializablePayload payload = new NonSerializablePayload("foo", 1); System.out.println("Invoking server with request of '" + payload + "'"); Object response = remotingClient.invoke(payload); System.out.println("Invocation response: " + response); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } // NOTE: HAVE TO HAVE SERIALIZATION TYPE SET TO JBOSS FOR THIS SAMPLE String locatorURI = transport + "://" + host + ":" + port + "/?serializationtype=jboss"; SerializationClient client = new SerializationClient(); try { client.makeInvocation(locatorURI); } catch(Throwable e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/0000755000175000017500000000000011632407051030324 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/0000755000175000017500000000000011632407051032001 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Client2Server2.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Client2S0000644000175000017500000001163210433521724033354 0ustar twernertwerner/* * 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. */ /* * Created on Oct 4, 2005 */ package org.jboss.remoting.samples.multiplex.invoker; /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ import java.util.HashMap; import java.util.Map; 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.Multiplex; /** * @author Ron Sigal */ public class Client2Server2 { private Client client; private SampleCallbackHandler handler; private Connector connector; private InvokerLocator locator; /** * This will create the Client. */ public void init() { try { String locatorURI = "multiplex://localhost:9090"; InvokerLocator locator = new InvokerLocator(locatorURI); Map configuration = new HashMap(); configuration.put(Multiplex.MULTIPLEX_BIND_HOST, "localhost"); configuration.put(Multiplex.MULTIPLEX_BIND_PORT, "8080"); client = new Client(locator, "sample", configuration); client.connect(); System.out.println("Connected client to server at: " + client.getInvoker().getLocator().getLocatorURI()); } catch(Exception e) { e.printStackTrace(); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ private InvokerLocator initServer() throws Exception { String locatorURI = "multiplex://localhost:8080"; InvokerLocator locator = new InvokerLocator(locatorURI); Map configuration = new HashMap(); configuration.put(Multiplex.MULTIPLEX_CONNECT_HOST, "localhost"); configuration.put(Multiplex.MULTIPLEX_CONNECT_PORT, "9090"); connector = new Connector(locator.getLocatorURI(), configuration); connector.create(); connector.start(); System.out.println("Started callback server at: " + connector.getInvokerLocator()); return connector.getLocator(); } public void setUp() throws Exception { init(); locator = initServer(); } public void tearDown() throws Throwable { while (!handler.gotCallbacks) Thread.sleep(1000); client.removeListener(handler); if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); } public static void main(String[] args) { Client2Server2 test = new Client2Server2(); try { test.setUp(); test.makeClientCall(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } public static class SampleCallbackHandler implements InvokerCallbackHandler { int callbackCounter; boolean gotCallbacks; public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); System.out.println("callback value: " + ret); if (++callbackCounter == 2) gotCallbacks = true; } public boolean gotCallbacks() { return gotCallbacks; } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Client3Server1.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Client3S0000644000175000017500000001142510433521724033355 0ustar twernertwerner/* * 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. */ /* * Created on Oct 4, 2005 */ package org.jboss.remoting.samples.multiplex.invoker; /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ import java.util.HashMap; import java.util.Map; 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.Multiplex; /** * @author Ron Sigal */ public class Client3Server1 { private Client client; private SampleCallbackHandler handler; private Connector connector; private InvokerLocator locator; /** * This will create the Client. */ public void init() { try { String locatorURI = "multiplex://localhost:9090"; InvokerLocator locator = new InvokerLocator(locatorURI); Map configuration = new HashMap(); configuration.put(Multiplex.CLIENT_MULTIPLEX_ID, "client3server1"); client = new Client(locator, "sample", configuration); } catch(Exception e) { e.printStackTrace(); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ private InvokerLocator initServer() throws Exception { String locatorURI = "multiplex://localhost:8080"; InvokerLocator locator = new InvokerLocator(locatorURI); Map configuration = new HashMap(); configuration.put(Multiplex.SERVER_MULTIPLEX_ID, "client3server1"); connector = new Connector(locator.getLocatorURI(), configuration); connector.create(); connector.start(); System.out.println("Started callback server at: " + connector.getInvokerLocator()); return connector.getLocator(); } public void setUp() throws Exception { init(); locator = initServer(); client.connect(); System.out.println("Connected client to server at: " + client.getInvoker().getLocator().getLocatorURI()); } public void tearDown() throws Throwable { while (!handler.gotCallbacks) Thread.sleep(1000); client.removeListener(handler); if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); } public static void main(String[] args) { Client3Server1 test = new Client3Server1(); try { test.setUp(); test.makeClientCall(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } public static class SampleCallbackHandler implements InvokerCallbackHandler { int callbackCounter; boolean gotCallbacks; public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); System.out.println("callback value: " + ret); if (++callbackCounter == 2) gotCallbacks = true; } public boolean gotCallbacks() { return gotCallbacks; } } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/MultiplexInvokerServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Multiple0000644000175000017500000001556310365365307033542 0ustar twernertwerner/* * 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. */ /* * Created on Oct 4, 2005 */ package org.jboss.remoting.samples.multiplex.invoker; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import javax.management.MBeanServer; 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; /** * @author Ron Sigal */ public class MultiplexInvokerServer { private SampleInvocationHandler handler; private Connector connector = null; public void init() throws Exception { connector = new Connector(); InvokerLocator locator = new InvokerLocator("multiplex://localhost:9090"); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); handler = new SampleInvocationHandler(); connector.addInvocationHandler("sample", handler); connector.start(); System.out.println("Started server at: " + connector.getInvokerLocator()); } public boolean isDone() { return handler.isDone(); } protected void setUp() throws Exception { init(); } protected void tearDown() throws Exception { if(connector != null) { connector.stop(); connector.destroy(); } } public static void main(String[] args) { MultiplexInvokerServer test = new MultiplexInvokerServer(); try { test.setUp(); while (!test.isDone()) Thread.sleep(1000); test.tearDown(); } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. When callback client's are registered, will * generate callbacks periodically. */ public static class SampleInvocationHandler implements ServerInvocationHandler, Runnable { // list of callback listeners registered private List listeners = new ArrayList(); private boolean didCallbacks = false; public SampleInvocationHandler() { // will start a new thread for generating callbacks. Thread callbackThread = new Thread(this); callbackThread.setDaemon(true); callbackThread.start(); } /** * called by the remoting server to handle the invocation from client. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Return invocation parameter return invocation.getParameter(); } /** * Adds a callback handler that will listen for callbacks from * the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { System.out.println("Adding callback listener."); listeners.add(callbackHandler); } /** * Removes the callback handler that was listening for callbacks * from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { System.out.println("Removing callback listener."); listeners.remove(callbackHandler); } /** * Will generate callback messages every second while shouldGenerateCallbacks * flag is true. */ public void run() { // wait for a callback listener to be registered while (listeners.isEmpty()) { try { Thread.sleep(1000); } catch(InterruptedException e) { } } for (int i = 0; i < 2; i++) { // create new callback message Callback callback = new Callback(new Integer(29 * (i + 1))); System.out.println("generating callback value: " + callback.getCallbackObject()); // get a copy of the listener list to avoid ConcurrentModificationException List localListeners= new ArrayList(listeners); // send callback to all registered listeners Iterator itr = localListeners.iterator(); while(itr.hasNext()) { InvokerCallbackHandler callbackHandler = (InvokerCallbackHandler) itr.next(); try { callbackHandler.handleCallback(callback); } catch(HandleCallbackException e) { e.printStackTrace(); } try { Thread.sleep(2000); } catch (InterruptedException ignored) { } } } didCallbacks = true; } /** * 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 boolean isDone() { return didCallbacks; } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Server3Client1.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Server3C0000644000175000017500000001110410365365307033366 0ustar twernertwerner/* * 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. */ /* * Created on Oct 4, 2005 */ package org.jboss.remoting.samples.multiplex.invoker; /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ 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; /** * @author Ron Sigal */ public class Server3Client1 { private Client client; private SampleCallbackHandler handler; private Connector connector; private InvokerLocator locator; /** * This will create the Client. */ public void init() { try { String parameters = "/?clientMultiplexId=server3client1"; String locatorURI = "multiplex://localhost:9090" + parameters; InvokerLocator locator = new InvokerLocator(locatorURI); client = new Client(locator, "sample"); client.connect(); System.out.println("Connected client to server at: " + client.getInvoker().getLocator().getLocatorURI()); } catch(Exception e) { e.printStackTrace(); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ private InvokerLocator initServer() throws Exception { String parameters = "/?serverMultiplexId=server3client1"; String locatorURI = "multiplex://localhost:8080" + parameters; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(locator.getLocatorURI()); connector.create(); connector.start(); System.out.println("Started callback server at: " + connector.getInvokerLocator()); return connector.getLocator(); } public void setUp() throws Exception { locator = initServer(); init(); } public void tearDown() throws Throwable { while (!handler.gotCallbacks) Thread.sleep(1000); client.removeListener(handler); if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); } public static void main(String[] args) { Server3Client1 test = new Server3Client1(); try { test.setUp(); test.makeClientCall(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } public static class SampleCallbackHandler implements InvokerCallbackHandler { int callbackCounter; boolean gotCallbacks; public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); System.out.println("callback value: " + ret); if (++callbackCounter == 2) gotCallbacks = true; } public boolean gotCallbacks() { return gotCallbacks; } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Server2Client1.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Server2C0000644000175000017500000001116710365365307033376 0ustar twernertwerner/* * 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. */ /* * Created on Oct 4, 2005 */ package org.jboss.remoting.samples.multiplex.invoker; /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ 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; /** * @author Ron Sigal */ public class Server2Client1 { private Client client; private SampleCallbackHandler handler; private Connector connector; private InvokerLocator locator; /** * This will create the Client. */ public void init() { try { String parameters = "/?multiplexBindHost=localhost&multiplexBindPort=8080&clientMultiplexId=server2client1"; String locatorURI = "multiplex://localhost:9090" + parameters; InvokerLocator locator = new InvokerLocator(locatorURI); client = new Client(locator, "sample"); client.connect(); System.out.println("Connected client to server at: " + client.getInvoker().getLocator().getLocatorURI()); } catch(Exception e) { e.printStackTrace(); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ private InvokerLocator initServer() throws Exception { String parameters = "/?serverMultiplexId=server2client1"; String locatorURI = "multiplex://localhost:8080" + parameters; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(locator.getLocatorURI()); connector.create(); connector.start(); System.out.println("Started callback server at: " + connector.getInvokerLocator()); return connector.getLocator(); } public void setUp() throws Exception { locator = initServer(); init(); } public void tearDown() throws Throwable { while (!handler.gotCallbacks) Thread.sleep(1000); client.removeListener(handler); if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); } public static void main(String[] args) { Server2Client1 test = new Server2Client1(); try { test.setUp(); test.makeClientCall(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } public static class SampleCallbackHandler implements InvokerCallbackHandler { int callbackCounter; boolean gotCallbacks; public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); System.out.println("callback value: " + ret); if (++callbackCounter == 2) gotCallbacks = true; } public boolean gotCallbacks() { return gotCallbacks; } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Client2Server1.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Client2S0000644000175000017500000001164610433521724033361 0ustar twernertwerner/* * 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. */ /* * Created on Oct 4, 2005 */ package org.jboss.remoting.samples.multiplex.invoker; /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ import java.util.HashMap; import java.util.Map; 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.Multiplex; /** * @author Ron Sigal */ public class Client2Server1 { private Client client; private SampleCallbackHandler handler; private Connector connector; private InvokerLocator locator; /** * This will create the Client. */ public void init() { try { String locatorURI = "multiplex://localhost:9090"; InvokerLocator locator = new InvokerLocator(locatorURI); Map configuration = new HashMap(); configuration.put(Multiplex.MULTIPLEX_BIND_HOST, "localhost"); configuration.put(Multiplex.MULTIPLEX_BIND_PORT, "8080"); configuration.put(Multiplex.CLIENT_MULTIPLEX_ID, "client2server2"); client = new Client(locator, "sample", configuration); client.connect(); System.out.println("Connected client to server at: " + client.getInvoker().getLocator().getLocatorURI()); } catch(Exception e) { e.printStackTrace(); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ private InvokerLocator initServer() throws Exception { String locatorURI = "multiplex://localhost:8080"; InvokerLocator locator = new InvokerLocator(locatorURI); Map configuration = new HashMap(); configuration.put(Multiplex.SERVER_MULTIPLEX_ID, "client2server2"); connector = new Connector(locator.getLocatorURI(), configuration); connector.create(); connector.start(); System.out.println("Started callback server at: " + connector.getInvokerLocator()); return connector.getLocator(); } public void setUp() throws Exception { init(); locator = initServer(); } public void tearDown() throws Throwable { while (!handler.gotCallbacks) Thread.sleep(1000); client.removeListener(handler); if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); } public static void main(String[] args) { Client2Server1 test = new Client2Server1(); try { test.setUp(); test.makeClientCall(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } public static class SampleCallbackHandler implements InvokerCallbackHandler { int callbackCounter; boolean gotCallbacks; public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); System.out.println("callback value: " + ret); if (++callbackCounter == 2) gotCallbacks = true; } public boolean gotCallbacks() { return gotCallbacks; } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Server2Client2.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/Server2C0000644000175000017500000001102510365365307033367 0ustar twernertwerner/* * 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. */ /* * Created on Oct 4, 2005 */ package org.jboss.remoting.samples.multiplex.invoker; /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. * See terms of license at gnu.org. */ 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; /** * @author Ron Sigal */ public class Server2Client2 { private Client client; private SampleCallbackHandler handler; private Connector connector; private InvokerLocator locator; /** * This will create the Client. */ public void init() { try { String locatorURI = "multiplex://localhost:9090/?multiplexBindHost=localhost&multiplexBindPort=8080"; InvokerLocator locator = new InvokerLocator(locatorURI); client = new Client(locator, "sample"); client.connect(); System.out.println("Connected client to server at: " + client.getInvoker().getLocator().getLocatorURI()); } catch(Exception e) { e.printStackTrace(); } } /** * This will be used to create callback server * * @param port * @return * @throws Exception */ private InvokerLocator initServer() throws Exception { String locatorURI = "multiplex://localhost:8080/?multiplexConnectHost=localhost&multiplexConnectPort=9090"; InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(locator.getLocatorURI()); connector.create(); connector.start(); System.out.println("Started callback server at: " + connector.getInvokerLocator()); return connector.getLocator(); } public void setUp() throws Exception { locator = initServer(); init(); } public void tearDown() throws Throwable { while (!handler.gotCallbacks) Thread.sleep(1000); client.removeListener(handler); if(connector != null) { connector.stop(); connector.destroy(); connector = null; } locator = null; if(client != null) { client.disconnect(); client = null; } } public void makeClientCall() throws Throwable { handler = new SampleCallbackHandler(); // Need to add callback listener to get callback client.addListener(handler, locator, client.getSessionId()); // make invocation Object answer = client.invoke(new Integer(17)); System.out.println("invocation returns: " + ((Integer) answer).intValue()); } public static void main(String[] args) { Server2Client2 test = new Server2Client2(); try { test.setUp(); test.makeClientCall(); test.tearDown(); } catch(Throwable throwable) { throwable.printStackTrace(); } } public static class SampleCallbackHandler implements InvokerCallbackHandler { int callbackCounter; boolean gotCallbacks; public void handleCallback(Callback callback) throws HandleCallbackException { Object ret = callback.getCallbackObject(); System.out.println("callback value: " + ret); if (++callbackCounter == 2) gotCallbacks = true; } public boolean gotCallbacks() { return gotCallbacks; } } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/.cvsignorelibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/invoker/.cvsigno0000644000175000017500000000003310365365307033457 0ustar twernertwernerClient3Client1Server1.java ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/FactoryExample.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/FactoryExample.j0000644000175000017500000000576110356416565033447 0ustar twernertwerner/* * 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. */ /* * Created on Sep 12, 2005 */ package org.jboss.remoting.samples.multiplex; import java.net.ServerSocket; import java.net.Socket; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import org.jboss.remoting.transport.multiplex.VirtualServerSocketFactory; import org.jboss.remoting.transport.multiplex.VirtualSocketFactory; /** * A FactoryExample. * @author Ron Sigal * @version $Revision: 590 $ *

          * Copyright (c) 2005 *

          */ public class FactoryExample { void runFactoryExample() { ServerSocketFactory serverSocketFactory = VirtualServerSocketFactory.getDefault(); ((VirtualServerSocketFactory) serverSocketFactory).setOnServer(); SocketFactory socketFactory = VirtualSocketFactory.getDefault(); useServerSocketFactory(serverSocketFactory); useSocketFactory(socketFactory); } void useServerSocketFactory(final ServerSocketFactory serverSocketFactory) { new Thread() { public void run() { try { ServerSocket serverSocket = serverSocketFactory.createServerSocket(5555); Socket socket = serverSocket.accept(); int b = socket.getInputStream().read(); socket.getOutputStream().write(b); socket.close(); serverSocket.close(); } catch (Exception e) { e.printStackTrace(); } } }.start(); } public void useSocketFactory(SocketFactory socketFactory) { try { Thread.sleep(1000); Socket socket = socketFactory.createSocket("localhost", 5555); socket.getOutputStream().write(7); System.out.println(socket.getInputStream().read()); socket.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { new FactoryExample().runFactoryExample(); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/N_SocketScenarioServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/N_SocketScenario0000644000175000017500000000617610356416565033466 0ustar twernertwerner/* * 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. */ /* * Created on Sep 8, 2005 */ package org.jboss.remoting.samples.multiplex; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import org.jboss.remoting.transport.multiplex.MasterServerSocket; import org.jboss.remoting.transport.multiplex.VirtualSocket; /** * A ManyToOneServer. * @author Ron Sigal * @version $Revision: 590 $ *

          * Copyright (c) 2005 *

          */ public class N_SocketScenarioServer { static int bindPort = 6666; static String connectHost = "localhost"; static int connectPort = 5555; public void runN_SocketScenario() { try { // Create and bind a MasterServerSocket. MasterServerSocket serverSocket = new MasterServerSocket(bindPort); // Accept connection request from VirtualServerSocket. serverSocket.setSoTimeout(10000); serverSocket.acceptServerSocketConnection(); // Create 3 virtual sockets Thread.sleep(2000); Socket socket1 = new VirtualSocket(connectHost, connectPort); Socket socket2 = new VirtualSocket(connectHost, connectPort); Socket socket3 = new VirtualSocket(connectHost, connectPort); // Do some i/o. InputStream is1 = socket1.getInputStream(); OutputStream os1 = socket1.getOutputStream(); InputStream is2 = socket2.getInputStream(); OutputStream os2 = socket2.getOutputStream(); InputStream is3 = socket3.getInputStream(); OutputStream os3 = socket3.getOutputStream(); os1.write(is1.read()); os2.write(is2.read()); os3.write(is3.read()); socket1.close(); socket2.close(); socket3.close(); serverSocket.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { if (args.length == 3) { bindPort = Integer.parseInt(args[0]); connectHost = args[1]; connectPort = Integer.parseInt(args[2]); } new N_SocketScenarioServer().runN_SocketScenario(); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/PrimeScenarioExampleClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/PrimeScenarioExa0000644000175000017500000000662710356416565033474 0ustar twernertwerner/* * 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. */ /* Created on Jul 24, 2005 * */ package org.jboss.remoting.samples.multiplex; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.ServerSocket; import java.net.Socket; import org.jboss.remoting.transport.multiplex.VirtualServerSocket; import org.jboss.remoting.transport.multiplex.VirtualSocket; /** * *

          * Copyright (c) 2005 *

          * @author Ron Sigal */ public class PrimeScenarioExampleClient { public void runPrimeScenario() { try { // create a VirtualSocket and connect it to MasterServerSocket Socket v1 = new VirtualSocket("localhost", 5555); // do some asynchronous input in a separate thread new AsynchronousThread(v1).start(); // do some synchronous communication ObjectOutputStream oos = new ObjectOutputStream(v1.getOutputStream()); ObjectInputStream ois = new ObjectInputStream(v1.getInputStream()); oos.writeObject(new Integer(3)); Integer i1 = (Integer) ois.readObject(); System.out.println("synch: " + i1); v1.close(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } class AsynchronousThread extends Thread { private Socket virtualSocket; AsynchronousThread(Socket virtualSocket) { this.virtualSocket = virtualSocket; } public void run() { try { // create a VirtualServerSocket that shares a port with socket ServerSocket serverSocket = new VirtualServerSocket(virtualSocket.getLocalPort()); // create a VirtualSocket that shares a port with socket serverSocket.setSoTimeout(10000); Socket v4 = serverSocket.accept(); ObjectInputStream ois = new ObjectInputStream(v4.getInputStream()); // get an object from the server v4.setSoTimeout(10000); Object o = ois.readObject(); System.out.println("asynch: " + ((Integer) o)); serverSocket.close(); v4.close(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } } public static void main(String[] args) { new PrimeScenarioExampleClient().runPrimeScenario(); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/PrimeScenarioExampleServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/PrimeScenarioExa0000644000175000017500000000705010356416565033463 0ustar twernertwerner/* * 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. */ /* * Created on Jul 24, 2005 */ package org.jboss.remoting.samples.multiplex; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.net.ServerSocket; import java.net.Socket; import org.jboss.remoting.transport.multiplex.MasterServerSocket; import org.jboss.remoting.transport.multiplex.VirtualSocket; /** * *

          * Copyright (c) 2005 *

          * @author Ron Sigal */ public class PrimeScenarioExampleServer { public void runPrimeScenario() { try { // create a MasterServerSocket and get a VirtualSocket ServerSocket serverSocket = new MasterServerSocket(5555); serverSocket.setSoTimeout(10000); Socket v2 = serverSocket.accept(); // do some asynchronous communication in a separate thread Thread asynchronousThread = new AsynchronousThread(v2); asynchronousThread.start(); // do some synchronous communication ObjectInputStream ois = new ObjectInputStream(v2.getInputStream()); ObjectOutputStream oos = new ObjectOutputStream(v2.getOutputStream()); v2.setSoTimeout(10000); Object o = ois.readObject(); oos.writeObject(o); asynchronousThread.join(); serverSocket.close(); v2.close(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } class AsynchronousThread extends Thread { private Socket virtualSocket; public AsynchronousThread(Socket socket) throws IOException { this.virtualSocket = socket; } public void run() { try { // Give VirtualServerSocket a chance to start. Thread.sleep(2000); // connect to VirtualServerSocket String hostName = virtualSocket.getInetAddress().getHostName(); int port = virtualSocket.getPort(); Socket v3 = new VirtualSocket(hostName, port); // send an object to the client ObjectOutputStream oos = new ObjectOutputStream(v3.getOutputStream()); oos.writeObject(new Integer(7)); oos.flush(); v3.close(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } } } public static void main(String[] args) { new PrimeScenarioExampleServer().runPrimeScenario(); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/SymmetricScenarioClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/SymmetricScenari0000644000175000017500000000731510356416565033552 0ustar twernertwerner/* * 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. */ /* * Created on Sep 9, 2005 */ package org.jboss.remoting.samples.multiplex; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.Socket; import org.jboss.remoting.transport.multiplex.VirtualServerSocket; import org.jboss.remoting.transport.multiplex.VirtualSocket; /** * A SymmetricScenarioClient. * @author Ron Sigal * @version $Revision: 590 $ *

          * Copyright (c) 2005 *

          */ public class SymmetricScenarioClient { static int bindPort = 5555; static String connectHost = "localhost"; static int connectPort = 6666; public void runSymmetricScenario() { try { // Get a virtual socket to use for synchronizing client and server. Socket syncSocket = new Socket(connectHost, connectPort); InputStream is_sync = syncSocket.getInputStream(); OutputStream os_sync = syncSocket.getOutputStream(); // Create a VirtualServerSocket and connect it to MasterServerSocket // running on the server. VirtualServerSocket serverSocket = new VirtualServerSocket(bindPort); InetSocketAddress address1 = new InetSocketAddress(connectHost, connectPort + 1); is_sync.read(); serverSocket.setSoTimeout(5000); serverSocket.connect(address1); // Call constructor to create a virtual socket and connect it to the port on the server // to which the VirtualServerSocket is connected. os_sync.write(5); is_sync.read(); int port = serverSocket.getRemotePort(); Socket virtualSocket1 = new VirtualSocket(connectHost, port); InputStream is1 = virtualSocket1.getInputStream(); OutputStream os1 = virtualSocket1.getOutputStream(); // Create a virtual socket by way of VirtualServerSocket.accept(). Socket virtualSocket2 = serverSocket.accept(); InputStream is2 = virtualSocket2.getInputStream(); OutputStream os2 = virtualSocket2.getOutputStream(); // Do some i/o and close sockets. os1.write(9); System.out.println(is1.read()); os2.write(11); System.out.println(is2.read()); virtualSocket1.close(); virtualSocket2.close(); syncSocket.close(); serverSocket.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { if (args.length == 3) { bindPort = Integer.parseInt(args[0]); connectHost = args[1]; connectPort = Integer.parseInt(args[2]); } new SymmetricScenarioClient().runSymmetricScenario(); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/N_SocketScenarioClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/N_SocketScenario0000644000175000017500000000624610356416565033464 0ustar twernertwerner/* * 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. */ /* * Created on Sep 8, 2005 */ package org.jboss.remoting.samples.multiplex; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.Socket; import org.jboss.remoting.transport.multiplex.VirtualServerSocket; /** * A ManyToOneClient. * @author Ron Sigal * @version $Revision: 590 $ *

          * Copyright (c) 2005 *

          */ public class N_SocketScenarioClient { static int bindPort = 5555; static String connectHost = "localhost"; static int connectPort = 6666; public void runN_SocketScenario() { try { // Create a VirtualServerSocket and connect it to the server. VirtualServerSocket serverSocket = new VirtualServerSocket(bindPort); InetSocketAddress connectAddress = new InetSocketAddress(connectHost, connectPort); serverSocket.setSoTimeout(10000); serverSocket.connect(connectAddress); // Accept connection requests for 3 virtual sockets. Socket socket1 = serverSocket.accept(); Socket socket2 = serverSocket.accept(); Socket socket3 = serverSocket.accept(); // Do some i/o. InputStream is1 = socket1.getInputStream(); OutputStream os1 = socket1.getOutputStream(); InputStream is2 = socket2.getInputStream(); OutputStream os2 = socket2.getOutputStream(); InputStream is3 = socket3.getInputStream(); OutputStream os3 = socket3.getOutputStream(); os1.write(3); os2.write(7); os3.write(11); System.out.println(is1.read()); System.out.println(is2.read()); System.out.println(is3.read()); socket1.close(); socket2.close(); socket3.close(); serverSocket.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { if (args.length == 3) { bindPort = Integer.parseInt(args[0]); connectHost = args[1]; connectPort = Integer.parseInt(args[2]); } new N_SocketScenarioClient().runN_SocketScenario(); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/SymmetricScenarioServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/multiplex/SymmetricScenari0000644000175000017500000001034410356416565033546 0ustar twernertwerner/* * 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. */ /* * Created on Sep 9, 2005 */ package org.jboss.remoting.samples.multiplex; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import org.jboss.remoting.transport.multiplex.MasterServerSocket; import org.jboss.remoting.transport.multiplex.VirtualServerSocket; import org.jboss.remoting.transport.multiplex.VirtualSocket; /** * A SymmetricScenarioServer. * @author Ron Sigal * @version $Revision: 590 $ *

          * Copyright (c) 2005 *

          */ public class SymmetricScenarioServer { static int bindPort = 6666; static String connectHost = "localhost"; static int connectPort = 5555; public void runSymmetricScenario() { try { // Create ServerSocket and get synchronizing socket. ServerSocket ss = new ServerSocket(bindPort); Socket syncSocket = ss.accept(); ss.close(); InputStream is_sync = syncSocket.getInputStream(); OutputStream os_sync = syncSocket.getOutputStream(); // Create MasterServerSocket, accept connection request from remote // VirtualServerSocket, and get the bind port of the local actual socket // to which the VirtualServerSocket is connected. MasterServerSocket mss = new MasterServerSocket(bindPort + 1); os_sync.write(3); mss.setSoTimeout(5000); int port = mss.acceptServerSocketConnection(); mss.close(); // Wait until remote VirtualServerSocket is running, then create local // VirtualServerSocket, bind it to the local port to which the remote // VirtualServerSocket is connected, and connect it to the remote // VirtualServerSocket. is_sync.read(); VirtualServerSocket vss = new VirtualServerSocket(port); InetSocketAddress address = new InetSocketAddress(connectHost, connectPort); vss.setSoTimeout(5000); vss.connect(address); // Indicate that the local VirtualServerSocket is running. os_sync.write(7); // Create a virual socket by way of VirtualServerSocket.accept(); Socket virtualSocket1 = vss.accept(); InputStream is1 = virtualSocket1.getInputStream(); OutputStream os1 = virtualSocket1.getOutputStream(); // Create a virtual socket connected to the remote VirtualServerSocket. Socket virtualSocket2 = new VirtualSocket(connectHost, connectPort); InputStream is2 = virtualSocket2.getInputStream(); OutputStream os2 = virtualSocket2.getOutputStream(); // Do some i/o and close sockets. os1.write(is1.read()); os2.write(is2.read()); virtualSocket1.close(); virtualSocket2.close(); syncSocket.close(); vss.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { if (args.length == 3) { bindPort = Integer.parseInt(args[0]); connectHost = args[1]; connectPort = Integer.parseInt(args[2]); } new SymmetricScenarioServer().runSymmetricScenario(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/simple/0000755000175000017500000000000011632407052027573 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/simple/SimpleServer.java0000644000175000017500000001304010363004341033046 0ustar twernertwerner/* * 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.remoting.samples.simple; import javax.management.MBeanServer; 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; /** * Simple remoting server. Uses inner class SampleInvocationHandler * as the invocation target handler class. * * @author Tom Elrod */ public class SimpleServer { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; // 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(String locatorURI) throws Exception { // create the InvokerLocator based on url string format // to indicate the transport, host, and port to use for the // server invoker. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Starting remoting server with locator uri of: " + locatorURI); Connector connector = new Connector(locator); // creates all the connector's needed resources, such as the server invoker connector.create(); // create the handler to receive the invocation request from the client for processing SampleInvocationHandler invocationHandler = new SampleInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("sample", invocationHandler); // start with a new non daemon thread so // server will wait for request and not exit connector.start(); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } String locatorURI = transport + "://" + host + ":" + port; SimpleServer server = new SimpleServer(); try { server.setupServer(locatorURI); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. * This is the code that will be called with the invocation payload from the client. */ public static class SampleInvocationHandler implements ServerInvocationHandler { /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); System.out.println("Returning response of: " + RESPONSE_VALUE); // Just going to return static string as this is just simple example code. return RESPONSE_VALUE; } /** * 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 } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/simple/SimpleClient.java0000644000175000017500000000530310433770344033034 0ustar twernertwerner/* * 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.remoting.samples.simple; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; /** * Simple test client to make an invocation on remoting server. * * @author Tom Elrod */ public class SimpleClient { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; public void makeInvocation(String locatorURI) throws Throwable { // create InvokerLocator with the url type string // indicating the target remoting server to call upon. InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling remoting server with locator uri of: " + locatorURI); Client remotingClient = new Client(locator); remotingClient.connect(); String request = "Do something"; System.out.println("Invoking server with request of '" + request + "'"); Object response = remotingClient.invoke(request); remotingClient.disconnect(); System.out.println("Invocation response: " + response); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } String locatorURI = transport + "://" + host + ":" + port; SimpleClient client = new SimpleClient(); try { client.makeInvocation(locatorURI); } catch(Throwable e) { e.printStackTrace(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/0000755000175000017500000000000011632407051027220 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/0000755000175000017500000000000011632407051031401 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/ConnectionException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/Connection0000644000175000017500000000026010400175262033417 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class ConnectionException extends Exception implements java.io.Serializable { public ConnectionException() {} } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/DatabaseException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/DatabaseEx0000644000175000017500000000042310400175262033322 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class DatabaseException extends Exception implements java.io.Serializable { public DatabaseException() {} public DatabaseException(Throwable t) { super(t); } public DatabaseException(String s) { super(s); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/CreateConnectionException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/CreateConn0000644000175000017500000000027410400175262033346 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class CreateConnectionException extends Exception implements java.io.Serializable { public CreateConnectionException() {} } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/InfoConnectionException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/InfoConnec0000644000175000017500000000027010400175262033342 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class InfoConnectionException extends Exception implements java.io.Serializable { public InfoConnectionException() {} } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/TalkConnectionException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/TalkConnec0000644000175000017500000000027010400175262033342 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class TalkConnectionException extends Exception implements java.io.Serializable { public TalkConnectionException() {} } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/ListConnectionException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/ListConnec0000644000175000017500000000027010400175262033362 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class ListConnectionException extends Exception implements java.io.Serializable { public ListConnectionException() {} } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/JoinConnectionException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/JoinConnec0000644000175000017500000000027010400175262033346 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class JoinConnectionException extends Exception implements java.io.Serializable { public JoinConnectionException() {} } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/ShuttingDownException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/ShuttingDo0000644000175000017500000000026410400175262033414 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class ShuttingDownException extends Exception implements java.io.Serializable { public ShuttingDownException() {} } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/NameInUseException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/NameInUseE0000644000175000017500000000025710400175262033257 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class NameInUseException extends Exception implements java.io.Serializable { public NameInUseException() {} } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/RemoteConnectionException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/RemoteConn0000644000175000017500000000027510400175262033377 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class RemoteConnectionException extends Exception implements java.io.Serializable { public RemoteConnectionException() {} } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/NotConnectedException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/NotConnect0000644000175000017500000000026410400175262033376 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class NotConnectedException extends Exception implements java.io.Serializable { public NotConnectedException() {} } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/InitializeException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/Initialize0000644000175000017500000000026010400175262033421 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class InitializeException extends Exception implements java.io.Serializable { public InitializeException() {} } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/InvalidArgumentException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/exceptions/InvalidArg0000644000175000017500000000027210400175262033343 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.exceptions; public class InvalidArgumentException extends Exception implements java.io.Serializable { public InvalidArgumentException() {} } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/0000755000175000017500000000000011632407051030476 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/Closeable.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/Closeable.java0000644000175000017500000000020210400175262033222 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.*; interface Closeable { void notifyOnClose(Component c); } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatFrame.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatFrame.java0000644000175000017500000001273110400175262033175 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.AWTEvent; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.WindowEvent; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingConstants; import org.jboss.remoting.samples.chat.exceptions.ConnectionException; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ public class ChatFrame extends CloseableFrame { public static void main(String[] args) { try { ChatFrame frame = new ChatFrame(new DummyConnectionStrategy()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.show(); } catch (ConnectionException ce) { System.out.println("unable to create chat frame"); } } JPanel contentPane; JLabel statusBar = new JLabel(); JLabel LeChat = new JLabel(); JButton ListButton = new JButton(); JButton CreateButton = new JButton(); JButton ExitButton = new JButton(); GridBagLayout gridBagLayout1 = new GridBagLayout(); private ConnectionStrategy cs; //Construct the frame public ChatFrame(ConnectionStrategy cs) { enableEvents(AWTEvent.WINDOW_EVENT_MASK); this.cs = cs; try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(gridBagLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("Le Chat"); statusBar.setText(" "); LeChat.setFont(new java.awt.Font("Serif", 1, 36)); LeChat.setHorizontalAlignment(SwingConstants.CENTER); LeChat.setHorizontalTextPosition(SwingConstants.CENTER); LeChat.setText("Le Chat"); ListButton.setFont(new java.awt.Font("SansSerif", 1, 14)); ListButton.setText("List"); ListButton.addActionListener(new ChatFrame_ListButton_actionAdapter(this)); CreateButton.setFont(new java.awt.Font("SansSerif", 1, 14)); CreateButton.setText("Create"); CreateButton.addActionListener(new ChatFrame_CreateButton_actionAdapter(this)); ExitButton.setFont(new java.awt.Font("SansSerif", 1, 14)); ExitButton.setText("Exit"); ExitButton.addActionListener(new ChatFrame_ExitButton_actionAdapter(this)); contentPane.add(statusBar, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(80, 0, 0, 0), 397, 0)); contentPane.add(LeChat, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(106, 80, 0, 85), 111, -10)); contentPane.add(ListButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(38, 57, 0, 0), 14, -4)); contentPane.add(ExitButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(36, 24, 0, 64), 12, -4)); contentPane.add(CreateButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(38, 24, 0, 0), 4, -4)); center(); pack(); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void ListButton_actionPerformed(ActionEvent e) { try { cs.list(); } catch (ConnectionException ce) { System.out.println("list button catches exception:"); System.out.println(ce); } } void CreateButton_actionPerformed(ActionEvent e) { try { cs.create(); } catch (ConnectionException ce) { System.out.println("create button catches exception:"); System.out.println(ce); } } void ExitButton_actionPerformed(ActionEvent e) { TalkFrame.exit(); } } class ChatFrame_ListButton_actionAdapter implements java.awt.event.ActionListener { ChatFrame adaptee; ChatFrame_ListButton_actionAdapter(ChatFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.ListButton_actionPerformed(e); } } class ChatFrame_CreateButton_actionAdapter implements java.awt.event.ActionListener { ChatFrame adaptee; ChatFrame_CreateButton_actionAdapter(ChatFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.CreateButton_actionPerformed(e); } } class ChatFrame_ExitButton_actionAdapter implements java.awt.event.ActionListener { ChatFrame adaptee; ChatFrame_ExitButton_actionAdapter(ChatFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.ExitButton_actionPerformed(e); } } class DummyConnectionStrategy implements ConnectionStrategy { public DummyConnectionStrategy() throws ConnectionException { System.out.println("DummyConnectionStrategy()"); } public void list() throws ConnectionException { System.out.println("DummyConnectionStrategy.list()"); } public void create() throws ConnectionException { System.out.println("DummyConnectionStrategy.create()"); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/JoinFrame.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/JoinFrame.java0000644000175000017500000001126710400175262033220 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.util.Date; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JTextField; import org.jboss.remoting.samples.chat.exceptions.JoinConnectionException; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ interface JoinConnectionStrategy { void join(ChatInfo chatInfo, ChatMember newMember) throws JoinConnectionException; } public class JoinFrame extends CloseableFrame { JLabel jLabel1 = new JLabel(); JTextField IDField = new JTextField(); JButton OKButton = new JButton(); JButton CancelButton = new JButton(); private ChatInfo chatInfo; private JoinConnectionStrategy jcs; GridBagLayout gridBagLayout1 = new GridBagLayout(); public JoinFrame( ChatInfo chatInfo, JoinConnectionStrategy jcs, Closeable parent) { super(parent); this.chatInfo = chatInfo; this.jcs = jcs; try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { jLabel1.setFont(new java.awt.Font("SansSerif", 1, 12)); jLabel1.setText("Your ID:"); this.getContentPane().setLayout(gridBagLayout1); IDField.setText(""); OKButton.setFont(new java.awt.Font("SansSerif", 1, 12)); OKButton.setText("OK"); OKButton.addActionListener(new JoinFrame_OKButton_actionAdapter(this)); CancelButton.setFont(new java.awt.Font("SansSerif", 1, 12)); CancelButton.setText("Cancel"); CancelButton.addActionListener(new JoinFrame_CancelButton_actionAdapter(this)); this.setTitle("Join a Chat Room"); this.getContentPane().add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(96, 82, 0, 0), 22, 5)); this.getContentPane().add(IDField, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(96, 0, 0, 39), 215, 0)); this.getContentPane().add(CancelButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(47, 16, 43, 139), 0, 0)); this.getContentPane().add(OKButton, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(49, 108, 43, 0), 22, 0)); pack(); center(); } public static void main(String[] args) { try { ChatMember chatMember = new ChatMember(); chatMember.set_name("xyz"); ChatInfo chatInfo = new ChatInfo(); chatInfo.set_currentMembers(3); chatInfo.set_description("abc"); chatInfo.set_origin(new Date()); JoinFrame joinFrame = new JoinFrame( chatInfo, new DummyJoinConnectionStrategy(), null); joinFrame.show(); } catch (JoinConnectionException ce) { System.out.println("unable to create chat frame"); } } void OKButton_actionPerformed(ActionEvent e) { try { notifyOnClose(this); ChatMember chatMember = new ChatMember(); chatMember.set_name(IDField.getText()); jcs.join(chatInfo, chatMember); } catch (JoinConnectionException jce) { System.out.println("OK button catches exception:"); System.out.println(jce); } } void CancelButton_actionPerformed(ActionEvent e) { notifyOnClose(this); } } class DummyJoinConnectionStrategy implements JoinConnectionStrategy { public DummyJoinConnectionStrategy() throws JoinConnectionException { System.out.println("DummyJoinConnectionStrategy()"); } public void join(ChatInfo chatInfo, ChatMember newMember) throws JoinConnectionException { System.out.println("DummyJoinConnectionStrategy.getId(" + chatInfo.get_key() + ", " + newMember.get_name() + ")"); } } class JoinFrame_OKButton_actionAdapter implements java.awt.event.ActionListener { JoinFrame adaptee; JoinFrame_OKButton_actionAdapter(JoinFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.OKButton_actionPerformed(e); } } class JoinFrame_CancelButton_actionAdapter implements java.awt.event.ActionListener { JoinFrame adaptee; JoinFrame_CancelButton_actionAdapter(JoinFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.CancelButton_actionPerformed(e); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ListFrame.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ListFrame.java0000644000175000017500000002120410400175262033224 0ustar twernertwerner package org.jboss.remoting.samples.chat.client; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.util.ArrayList; import javax.swing.JButton; import javax.swing.JList; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import org.jboss.remoting.samples.chat.exceptions.ConnectionException; import org.jboss.remoting.samples.chat.exceptions.ListConnectionException; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ interface ListConnectionStrategy { void getId(ChatInfo chatInfo) throws ConnectionException; void getInfo(ArrayList chatInfoList, int key) throws ListConnectionException; } public class ListFrame extends CloseableFrame { JButton joinButton = new JButton(); JButton getInfoButton = new JButton(); JButton closeButton = new JButton(); JButton exitButton = new JButton(); private ListConnectionStrategy lcs; private ArrayList chatRoomInfo; JScrollPane jScrollPane1 = new JScrollPane(); JList chatRoomList = new JList(); GridBagLayout gridBagLayout1 = new GridBagLayout(); public ListFrame( ListConnectionStrategy lcs, ArrayList chatRoomInfo, Closeable parent) { super(parent); this.chatRoomInfo = chatRoomInfo; this.lcs = lcs; try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { this.getContentPane().setLayout(gridBagLayout1); joinButton.setFont(new java.awt.Font("SansSerif", 1, 12)); joinButton.setMaximumSize(new Dimension(77, 25)); joinButton.setMinimumSize(new Dimension(77, 25)); joinButton.setText("Join"); joinButton.addActionListener(new ListFrame_joinButton_actionAdapter(this)); getInfoButton.setText("Get info"); getInfoButton.addActionListener(new ListFrame_getInfoButton_actionAdapter(this)); getInfoButton.setFont(new java.awt.Font("SansSerif", 1, 12)); getInfoButton.setMinimumSize(new Dimension(77, 25)); closeButton.setText("Close"); closeButton.addActionListener(new ListFrame_closeButton_actionAdapter(this)); closeButton.setFont(new java.awt.Font("SansSerif", 1, 12)); closeButton.setMaximumSize(new Dimension(77, 25)); closeButton.setMinimumSize(new Dimension(77, 25)); closeButton.setFocusPainted(true); exitButton.setText("Exit"); exitButton.addActionListener(new ListFrame_exitButton_actionAdapter(this)); exitButton.setFont(new java.awt.Font("SansSerif", 1, 12)); exitButton.setMaximumSize(new Dimension(77, 25)); exitButton.setMinimumSize(new Dimension(77, 25)); this.setTitle("Current chat rooms"); chatRoomList = makeChatRoomList(chatRoomInfo); chatRoomList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.getContentPane().add(exitButton, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(36, 7, 22, 11), 40, 0)); this.getContentPane().add(closeButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(35, 21, 22, 0), 16, 0)); this.getContentPane().add(joinButton, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(36, 9, 22, 0), 32, 0)); this.getContentPane().add(getInfoButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(33, 6, 22, 0), 0, 4)); this.getContentPane().add(jScrollPane1, new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(57, 21, 0, 12), -106, 27)); jScrollPane1.getViewport().add(chatRoomList, null); pack(); center(); } protected JList makeChatRoomList(ArrayList chatRoomInfo) { String[] chats = new String[chatRoomInfo.size()]; for (int i = 0; i < chatRoomInfo.size(); i++) { chats[i] = ((ChatInfo)chatRoomInfo.get(i)).get_description(); if (chats[i].equals("")) // empty string will not generate chats[i] = "*no name*"; // line on listbox } JList chatList = new JList(chats); chatList.setSelectedIndex(0); return chatList; } public static void main(String[] args) { try { ChatMember chatMember0 = new ChatMember(); ChatMember chatMember1 = new ChatMember(); ChatMember chatMember2 = new ChatMember(); chatMember0.set_name("m1"); chatMember1.set_name("m2"); chatMember2.set_name("m3"); ChatInfo chatInfo0 = new ChatInfo(); ChatInfo chatInfo1 = new ChatInfo(); ChatInfo chatInfo2 = new ChatInfo(); chatInfo0.set_currentMembers(0); chatInfo0.set_description("Lord of the Rings"); chatInfo0.set_owner(chatMember0); chatInfo1.set_currentMembers(1); chatInfo1.set_description("Cat's Cradle"); chatInfo1.set_owner(chatMember1); chatInfo2.set_currentMembers(2); chatInfo2.set_description("Siddhartha"); chatInfo2.set_owner(chatMember2); ArrayList chats = new ArrayList(3); chats.add(chatInfo0); chats.add(chatInfo1); chats.add(chatInfo2); // new ChatInfo(0, "Lord of the Rings", new ChatMember("m1"), new Date()), // new ChatInfo(1, "Cat's Cradle", new ChatMember("m2"), new Date()), // new ChatInfo(2, "Siddhartha", new ChatMember("m3"), new Date())}; ListFrame frame = new ListFrame( new DummyListConnectionStrategy(), chats, null); frame.show(); } catch (ListConnectionException lce) { System.out.println("ListFrameTest: unable to create chat frame"); } } void joinButton_actionPerformed(ActionEvent e) { try { notifyOnClose(this); if (chatRoomList.getModel().getSize() <= chatRoomList.getSelectedIndex()) { System.out.println("there are no chat rooms to join"); return; } ChatInfo chatInfo = (ChatInfo)chatRoomInfo.get(chatRoomList.getSelectedIndex()); lcs.getId(chatInfo); } catch (ConnectionException ce) { System.out.println("Join button catches exception:"); System.out.println(ce); } } void getInfoButton_actionPerformed(ActionEvent e) { try { notifyOnClose(this); if (chatRoomList.getModel().getSize() <= chatRoomList.getSelectedIndex()) { System.out.println("there are no chat rooms"); return; } lcs.getInfo(chatRoomInfo, chatRoomList.getSelectedIndex()); } catch (ListConnectionException lce) { System.out.println("Info button catches exception:"); System.out.println(lce); } } void closeButton_actionPerformed(ActionEvent e) { notifyOnClose(this); } void exitButton_actionPerformed(ActionEvent e) { System.exit(0); } } class DummyListConnectionStrategy implements ListConnectionStrategy { public DummyListConnectionStrategy() throws ListConnectionException { System.out.println("DummyListConnectionStrategy()"); } public void getId(ChatInfo chatInfo) { System.out.println("DummyListConnectionStrategy.getId(" + chatInfo.get_key() + ")"); } public void getInfo(ArrayList chatInfoList, int key) throws ListConnectionException { System.out.println("DummyListConnectionStrategy.getInfo(" + key + ")"); } } class ListFrame_joinButton_actionAdapter implements java.awt.event.ActionListener { ListFrame adaptee; ListFrame_joinButton_actionAdapter(ListFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.joinButton_actionPerformed(e); } } class ListFrame_getInfoButton_actionAdapter implements java.awt.event.ActionListener { ListFrame adaptee; ListFrame_getInfoButton_actionAdapter(ListFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.getInfoButton_actionPerformed(e); } } class ListFrame_closeButton_actionAdapter implements java.awt.event.ActionListener { ListFrame adaptee; ListFrame_closeButton_actionAdapter(ListFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.closeButton_actionPerformed(e); } } class ListFrame_exitButton_actionAdapter implements java.awt.event.ActionListener { ListFrame adaptee; ListFrame_exitButton_actionAdapter(ListFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.exitButton_actionPerformed(e); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/InfoFrame.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/InfoFrame.java0000644000175000017500000001432510400175262033212 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.util.Date; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import org.jboss.remoting.samples.chat.exceptions.ConnectionException; import org.jboss.remoting.samples.chat.exceptions.InfoConnectionException; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ interface InfoConnectionStrategy { void getId(ChatInfo chatInfo) throws ConnectionException; } public class InfoFrame extends CloseableFrame implements Closeable{ JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); JTextField jTextField1 = new JTextField(); JTextField jTextField2 = new JTextField(); JTextField numberOfMessages = new JTextField(); JButton joinButton = new JButton(); JButton closeButton = new JButton(); GridBagLayout gridBagLayout1 = new GridBagLayout(); InfoConnectionStrategy ics; ChatInfo chatInfo; public InfoFrame( InfoConnectionStrategy ics, ChatInfo chatInfo, Closeable parent) { super(parent); this.ics = ics; this.chatInfo = chatInfo; try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { jLabel1.setFont(new java.awt.Font("SansSerif", 1, 12)); jLabel1.setText("Description:"); this.getContentPane().setLayout(gridBagLayout1); jLabel2.setFont(new java.awt.Font("SansSerif", 1, 12)); jLabel2.setText("Current members:"); jLabel3.setFont(new java.awt.Font("SansSerif", 1, 12)); jLabel3.setAlignmentX((float) 0.0); jLabel3.setText("Number of messages:"); jTextField1.setEditable(false); jTextField1.setText(chatInfo.get_description()); jTextField2.setEditable(false); jTextField2.setText(Integer.toString(chatInfo.get_currentMembers())); numberOfMessages.setEditable(false); numberOfMessages.setText(Integer.toString(chatInfo.get_size())); joinButton.setFont(new java.awt.Font("SansSerif", 1, 12)); joinButton.setText("Join"); joinButton.addActionListener(new InfoFrame_joinButton_actionAdapter(this)); closeButton.setFont(new java.awt.Font("SansSerif", 1, 12)); closeButton.setText("Close"); closeButton.addActionListener(new InfoFrame_closeButton_actionAdapter(this)); this.getContentPane().setBackground(SystemColor.control); this.setLocale(java.util.Locale.getDefault()); this.setTitle("Chat room information"); this.getContentPane().add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(11, 43, 0, 0), 11, 2)); this.getContentPane().add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(44, 43, 10, 40), 7, 2)); this.getContentPane().add(jLabel3, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(21, 43, 0, 0), 15, 2)); this.getContentPane().add(jTextField1, new GridBagConstraints(2, 0, 2, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(44, 0, 0, 38), 304, 7)); this.getContentPane().add(jTextField2, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(9, 0, 0, 0), 51, 0)); this.getContentPane().add(numberOfMessages, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(18, 0, 0, 0), 50, 0)); this.getContentPane().add(closeButton, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 17, 50, 201), 6, 0)); this.getContentPane().add(joinButton, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0 ,GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(42, 0, 93, 8), 14, 0)); pack(); // added by hand center(); // added by hand } public static void main(String[] args) { try { Date gc = new Date(); ChatMember chatMember = new ChatMember(); chatMember.set_name("jj"); ChatInfo chatInfo = new ChatInfo(); chatInfo.set_currentMembers(3); chatInfo.set_description("Black holes"); chatInfo.set_origin(gc); InfoFrame infoFrame = new InfoFrame( new DummyInfoConnectionStrategy(), chatInfo, null); infoFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); infoFrame.show(); } catch (InfoConnectionException ce) { System.out.println("unable to create chat frame"); } } void joinButton_actionPerformed(ActionEvent e) { try { ics.getId(chatInfo); notifyOnClose(this); } catch (ConnectionException ce) { System.out.println("Join button catches exception:"); System.out.println(ce); } } void closeButton_actionPerformed(ActionEvent e) { notifyOnClose(this); } } class DummyInfoConnectionStrategy implements InfoConnectionStrategy { public DummyInfoConnectionStrategy() throws InfoConnectionException { System.out.println("DummyInfoConnectionStrategy()"); } public void getId(ChatInfo chatInfo) { System.out.println("DummyInfoConnectionStrategy.getId(" + chatInfo.get_key() + ")"); } } class InfoFrame_joinButton_actionAdapter implements java.awt.event.ActionListener { InfoFrame adaptee; InfoFrame_joinButton_actionAdapter(InfoFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.joinButton_actionPerformed(e); } } class InfoFrame_closeButton_actionAdapter implements java.awt.event.ActionListener { InfoFrame adaptee; InfoFrame_closeButton_actionAdapter(InfoFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.closeButton_actionPerformed(e); } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatReceiverHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatReceiverHa0000644000175000017500000000355710400175262033246 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ import java.util.*; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.invocation.RemoteInvocation; public class ChatReceiverHandler implements InvokerCallbackHandler { private TalkFrame talkFrame; public ChatReceiverHandler(TalkFrame tf) { talkFrame = tf; } public void handleCallback(Callback callback) throws HandleCallbackException { if (!(callback.getParameter() instanceof RemoteInvocation)) throw new HandleCallbackException("invalid request format: expecting RemoteInvocation"); RemoteInvocation request = (RemoteInvocation) callback.getParameter(); String methodName = request.getMethodName(); Object[] args = request.getParameters(); if (methodName.equals("send")) send(args); else if (methodName.equals("sendMultiple")) sendMultiple(args); else if (methodName.equals("setKey")) setKey(args); else if (methodName.equals("shuttingDown")) shuttingDown(args); else throw new HandleCallbackException("unrecognized method name: " + methodName); } protected void send(Object[] args) { ChatMessage mesg = (ChatMessage) args[0]; talkFrame.appendMessage(mesg); } protected void sendMultiple(Object[] args) { ArrayList messages = (ArrayList) args[0]; talkFrame.appendMessages(messages); } protected void setKey(Object[] args) { String key = (String) args[0]; talkFrame.registerChatKey(key); } protected void shuttingDown(Object[] args) { } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ShutDownDialog.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ShutDownDialog0000644000175000017500000000417410400175262033320 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.*; import javax.swing.*; import java.awt.event.*; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ public class ShutDownDialog extends JDialog { JPanel panel1 = new JPanel(); JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JButton OKButton = new JButton(); GridBagLayout gridBagLayout1 = new GridBagLayout(); public ShutDownDialog(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch(Exception ex) { ex.printStackTrace(); } } public ShutDownDialog() { this(null, "", false); } private void jbInit() throws Exception { panel1.setLayout(gridBagLayout1); jLabel1.setFont(new java.awt.Font("Dialog", 1, 12)); jLabel1.setText("Chat system is shutting down."); jLabel2.setFont(new java.awt.Font("Dialog", 1, 12)); jLabel2.setText("Please try again later."); OKButton.setFont(new java.awt.Font("Dialog", 1, 14)); OKButton.setText("OK"); OKButton.addActionListener(new ShutDownDialog_OKButton_actionAdapter(this)); getContentPane().add(panel1); panel1.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(71, 109, 0, 84), 37, 15)); panel1.add(jLabel2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(12, 134, 0, 100), 43, 3)); panel1.add(OKButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(46, 156, 96, 171), 18, -4)); } void OKButton_actionPerformed(ActionEvent e) { hide(); } } class ShutDownDialog_OKButton_actionAdapter implements java.awt.event.ActionListener { ShutDownDialog adaptee; ShutDownDialog_OKButton_actionAdapter(ShutDownDialog adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.OKButton_actionPerformed(e); } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/RemoteStrategyRemoting.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/RemoteStrategy0000644000175000017500000002513710400175262033405 0ustar twernertwerner/* * 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. */ /* * Created on Feb 21, 2006 */ package org.jboss.remoting.samples.chat.client; import java.net.MalformedURLException; import java.util.ArrayList; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.invocation.RemoteInvocation; import org.jboss.remoting.samples.chat.exceptions.NameInUseException; import org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException; import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; import org.jboss.remoting.samples.chat.server.ChatServer; import org.jboss.remoting.samples.chat.utility.Parameters; import org.jboss.remoting.samples.chat.utility.ReadWriteArrayList; import org.jboss.remoting.transport.Connector; /** * A RemoteStrategyRemoting. * @author Ron Sigal * @version $Revision: 735 $ *

          * Copyright (c) 2005 *

          */ public class RemoteStrategyRemoting implements RemoteStrategy { protected static final Logger log = Logger.getLogger(RemoteStrategyRemoting.class); private static String chatClientLocatorDefault = "socket://localhost:0"; private static String chatManagerLocatorDefault = "socket://localhost:1969"; private Client managerClient; private Connector receiverConnector; private boolean locallyShuttingDown = false; private boolean remotelyShuttingDown = false; public RemoteStrategyRemoting() throws Exception { String chatManagerUriString = Parameters.getParameter("chatManagerUri"); if (chatManagerUriString == null) chatManagerUriString = chatManagerLocatorDefault; InvokerLocator chatManagerLocator = new InvokerLocator(chatManagerUriString); managerClient = new Client(chatManagerLocator); managerClient.connect(); } public ArrayList list() throws RemoteConnectionException, ShuttingDownException { RemoteInvocation invocation = new RemoteInvocation("list", null); try { return (ArrayList) managerClient.invoke(invocation); } catch (Throwable t) { log.error(t); t.printStackTrace(); throw new RemoteConnectionException(); } } public ChatServer createChat(String description, ChatMember owner, TalkFrame talkFrame, ReadWriteArrayList outgoingLines) throws NameInUseException, RemoteConnectionException, ShuttingDownException { Client serverClient = null; // Create new chat room and create Client for new chat room server. try { Object[] args = new Object[] {description, owner}; RemoteInvocation invocation = new RemoteInvocation("createChat", args); InvokerLocator serverLocator = (InvokerLocator) managerClient.invoke(invocation); serverClient = new Client(serverLocator); serverClient.connect(); } catch (Throwable e) { log.error(e); e.printStackTrace(); throw new RemoteConnectionException(); } // Create callback handler to process incoming messages. try { receiverConnector = new Connector(); String receiverLocatorString = Parameters.getParameter("clientUriString", chatClientLocatorDefault); InvokerLocator receiverLocator = new InvokerLocator(receiverLocatorString); receiverConnector.setInvokerLocator(receiverLocator.getLocatorURI()); log.info(receiverLocator.getLocatorURI()); receiverConnector.start(); receiverLocator = receiverConnector.getLocator(); log.info(receiverConnector.getInvokerLocator()); InvokerCallbackHandler receiverHandler = new ChatReceiverHandler(talkFrame); serverClient.addListener(receiverHandler, receiverLocator, owner); } catch (MalformedURLException e) { log.error(e); e.printStackTrace(); throw new RemoteConnectionException(); } catch (Throwable e) { log.error(e); e.printStackTrace(); throw new RemoteConnectionException(); } // Create stub for new chat room server. ChatServer chatServer = new ChatServerStub(serverClient); // Create thread to send new outgoing messages to chat room server. SendThread sendThread = new SendThread(chatServer, outgoingLines); sendThread.start(); return chatServer; } public ChatServer join(String key, ChatMember newMember, TalkFrame talkFrame, ReadWriteArrayList outgoingLines) throws NameInUseException, RemoteConnectionException, ShuttingDownException { Client serverClient = null; // Join chat room and create Client for chat room server. try { Object[] args = new Object[] {key, newMember}; RemoteInvocation invocation = new RemoteInvocation("join", args); managerClient.invoke(invocation); InvokerLocator serverLocator = new InvokerLocator(key); serverClient = new Client(serverLocator); serverClient.connect(); } catch (Throwable e) { log.error(e); e.printStackTrace(); throw new RemoteConnectionException(); } // Create callback handler to process incoming messages. try { receiverConnector = new Connector(); String receiverLocatorString = Parameters.getParameter("clientUriString", chatClientLocatorDefault); InvokerLocator receiverLocator = new InvokerLocator(receiverLocatorString); receiverConnector.setInvokerLocator(receiverLocator.getLocatorURI()); log.info(receiverLocator.getLocatorURI()); receiverConnector.start(); receiverLocator = receiverConnector.getLocator(); InvokerCallbackHandler receiverHandler = new ChatReceiverHandler(talkFrame); serverClient.addListener(receiverHandler, receiverLocator, newMember); } catch (MalformedURLException e) { log.error(e); e.printStackTrace(); throw new RemoteConnectionException(); } catch (Throwable e) { log.error(e); e.printStackTrace(); throw new RemoteConnectionException(); } // Create stub for new chat room server. ChatServer chatServer = new ChatServerStub(serverClient); // Create thread to send new outgoing messages to chat room server. SendThread sendThread = new SendThread(chatServer, outgoingLines); sendThread.start(); return chatServer; } public void setShuttingDown() { locallyShuttingDown = true; } class SendThread extends Thread { private ChatServer chatServer; private ReadWriteArrayList outgoingLines; SendThread(ChatServer chatServer, ReadWriteArrayList outgoingLines) { this.chatServer = chatServer; this.outgoingLines = outgoingLines; } public void run() { while (!locallyShuttingDown && !remotelyShuttingDown) { try { chatServer.send( (ChatMessage) outgoingLines.firstElement()); outgoingLines.remove(0); } catch (RemoteConnectionException re) { System.out.println("RemoteStrategyImpl.createChat(): unable to send next line:"); // System.out.println(" " + (String) outgoingLines.firstElement()); } catch (ShuttingDownException sde) { System.out.println("RemoteStrategyImpl.createChat(): ChatServer is shutting down"); remotelyShuttingDown = true; } } } } class ChatServerStub implements ChatServer { private Client serverClient; public ChatServerStub(Client serverClient) { this.serverClient = serverClient; } public ArrayList getBackChat() throws RemoteConnectionException, ShuttingDownException { RemoteInvocation invocation = new RemoteInvocation("getBackChat", null); try { return (ArrayList) serverClient.invoke(invocation); } catch (Throwable e) { log.error(e); throw new RemoteConnectionException(); } } public ChatInfo getChatInfo() throws RemoteConnectionException, ShuttingDownException { RemoteInvocation invocation = new RemoteInvocation("getChatInfo", null); try { return (ChatInfo) serverClient.invoke(invocation); } catch (Throwable e) { log.error(e); throw new RemoteConnectionException(); } } public void leave(ChatMember member) throws RemoteConnectionException, ShuttingDownException { RemoteInvocation invocation = new RemoteInvocation("leave", new Object[] {member}); try { serverClient.invoke(invocation); } catch (Throwable e) { log.error(e); throw new RemoteConnectionException(); } } public void send(ChatMessage mesg) throws RemoteConnectionException, ShuttingDownException { RemoteInvocation invocation = new RemoteInvocation("send", new Object[] {mesg}); try { serverClient.invoke(invocation); } catch (Throwable e) { log.error(e); throw new RemoteConnectionException(); } } } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatReceiver.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatReceiver.j0000644000175000017500000000065710400175262033223 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException; public interface ChatReceiver { void setKey(Integer key) throws RemoteConnectionException; void send(ChatMessage mesg) throws RemoteConnectionException; void sendMultiple(java.util.ArrayList messages) throws RemoteConnectionException; void shuttingDown() throws RemoteConnectionException; } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/CloseableFrame.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/CloseableFrame0000644000175000017500000000247510400175262033273 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.*; import javax.swing.*; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ public class CloseableFrame extends JFrame implements Closeable { private Closeable parent; public CloseableFrame(Closeable parent) { setParent(parent); } public CloseableFrame() { setParent(null); } public void notifyOnClose(Component c) { setVisible(false); if (parent != null) { parent.notifyOnClose(this); } } protected void setParent(Closeable parent) { this.parent = parent; } protected Closeable parent() { return parent; } protected void center() { //Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); } public static void main(String[] args) { Closeable CloseableFrame = new CloseableFrame(); } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/RemoteStrategyXmlRmi_Impl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/RemoteStrategy0000644000175000017500000001761610400175262033410 0ustar twernertwerner//package org.jboss.remoting.samples.chat.client; // //import java.rmi.RemoteException; //import java.util.*; //import java.net.*; //import org.apache.xmlrpc.*; //import org.jboss.remoting.samples.chat.exceptions.NameInUseException; //import org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException; //import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; //import org.jboss.remoting.samples.chat.utility.ReadWriteArrayList; // //import xmlrmi.*; //import xmlrmi.exceptions.*; //import xmlrmi.xmlrpc.XmlrmiNativeClient; //import chat.server.ChatManager; //import chat.server.ChatServer; //import chat.server.ejb.*; //import chat.utility.*; //import chat.utility.Parameters; //import chat.exceptions.*; // ///** // *

          Title: Chat // *

          Description:

          // *

          Copyright: Copyright (c) 2003

          // *

          Company:

          // * @author not attributable // * @version 1.0 // */ // //public class RemoteStrategyXmlRmi_Impl implements RemoteStrategy { // // private ChatManager chatManager; // private XmlrmiClient xmlrmiClient; // private ChatServer chatServer; // private ArrayList messages; // private ChatInfo chatInfo; // private int key; // private ChatMember member; // private boolean locallyShuttingDown = false; // private boolean remotelyShuttingDown = false; // private WebServer webServer; // // public RemoteStrategyXmlRmi_Impl() throws RemoteConnectionException // { // System.out.println("RemoteStrategy: version RemoteStrategy_XmlRmi_Impl"); // // messages = new ArrayList(); // key = -1; // // String clientUriString = Parameters.getParameter("clientUri"); // if (clientUriString == null) // clientUriString = "http://localhost:1970"; // // URI clientUri = null; // try { // clientUri = new URI(clientUriString); // } catch (URISyntaxException e) // { // System.out.println("RemoteStrategyXmlRmi_Impl(): invalid client uri: " + clientUri); // System.out.println(e); // System.exit(-1); // } // // System.out.println("RemoteStrategy: client uri = " + clientUri); // try { // xmlrmiClient = new XmlrmiNativeClient(XmlrmiNativeClient.STANDALONE, clientUri); // } catch (XmlrmiException xre) // { // System.out.println("unable to create XmlrmiClient"); // System.out.println(xre); // throw new RemoteConnectionException(); // } // // String chatManagerUriString = Parameters.getParameter("chatManagerUri"); // if (chatManagerUriString == null) // chatManagerUriString="http://localhost:1969/chat/chat/chatManager"; // // URI chatManagerUri = null; // try { // chatManagerUri = new URI(chatManagerUriString); // } catch (URISyntaxException e) // { // System.out.println("RemoteStrategyXmlRmi_Impl(): invalid chatManagerUri property: " + chatManagerUriString); // System.out.println(e); // System.exit(-1); // } // // System.out.println("RemoteStrategy: chat manager uri = " + chatManagerUri); // // try { // Object o = xmlrmiClient.lookup(chatManagerUri); // chatManager = (ChatManager) o; // } catch (Exception e) // { // System.out.println("RemoteStrategy: unable to connect to chat manager at: " + chatManagerUri); // throw new RemoteConnectionException(); // } // // System.out.println("RemoteStrategy: chatManager found"); // } // // // public static void main(String[] args) // { // try // { // RemoteStrategyXmlRmi_Impl remoteStrategyImplXmlRmi = new RemoteStrategyXmlRmi_Impl(); // // ArrayList chats = null; // try { // chats = remoteStrategyImplXmlRmi.list(); // // for (int i = 0; i < chats.size(); i++) // System.out.println(chats.get(i)); // // } catch (Exception e) { // System.out.println("RemoteStrategy: cannot list chats"); // System.out.println(e); // } // } catch (RemoteConnectionException rce) // { // System.out.println("RemoteStrategy: uable to create remoteStrategyImpl: " + rce); // } // } // // public void setShuttingDown() // { // locallyShuttingDown = true; // } // // public ArrayList list() throws RemoteConnectionException, ShuttingDownException // { // ArrayList chats; // // try { // chats = chatManager.list(); // } catch (RemoteConnectionException re) // { // System.out.println("RemoteStrategyImpl: unable to get list of chat rooms"); // System.out.println(re.toString()); // throw new RemoteConnectionException(); // } // // return chats; // } // // public ChatServer createChat(String description, // ChatMember owner, // TalkFrame talkFrame, // final ReadWriteArrayList outgoingLines) // throws NameInUseException,RemoteConnectionException, ShuttingDownException // { // ChatReceiver chatReceiver = new ChatReceiver_Impl(talkFrame); // // final ChatServer chatServer; // chatServer = chatManager.createChat(description, owner, chatReceiver); // // Thread sendThread = new Thread() { // public void run() { // while (!locallyShuttingDown && !remotelyShuttingDown) // { // try { // chatServer.send( (ChatMessage) outgoingLines.firstElement()); // outgoingLines.remove(0); // } catch (RemoteConnectionException re) // { // System.out.println("RemoteStrategyImpl.createChat(): unable to send next line:"); // System.out.println(" " + (String) outgoingLines.firstElement()); // } catch (ShuttingDownException sde) { // System.out.println("RemoteStrategyImpl.createChat(): ChatServer is shutting down"); // remotelyShuttingDown = true; // } // } // } // }; // // sendThread.start(); // return chatServer; //// return null; // dummy statement - should never reach here // } // // // public ChatServer join(int key, // ChatMember newMember, // TalkFrame talkFrame, // final ReadWriteArrayList outgoingLines) // throws NameInUseException, RemoteConnectionException, ShuttingDownException // { // ChatReceiver chatReceiver = new ChatReceiver_Impl(talkFrame); // // final ChatServer chatServer; // // chatServer = chatManager.join(new Integer(key), newMember, chatReceiver); // // Thread sendThread = new Thread() { // public void run() { // while (!locallyShuttingDown && !remotelyShuttingDown) { // try { // chatServer.send( (ChatMessage) outgoingLines.remove(0)); // } // catch (RemoteConnectionException re) { // System.out.println("RemoteStrategyImpl.createChat(): unable to send next line:"); // System.out.println(" " + (String) outgoingLines.firstElement()); // } // catch (ShuttingDownException sde) { // System.out.println("RemoteStrategyImpl.createChat(): ChatServer is shutting down"); // remotelyShuttingDown = true; // } //// catch (InterruptedException ie) { //// System.out.println("RemoteStrategyXmlRmi_Impl.createChat(): unexpected InterruptedException"); //// } // } // } // }; // // sendThread.start(); // // return chatServer; // } // ///* public void leave() throws RemoteConnectionException, ShuttingDownException // { // if (chatServer == null) { // throw new RemoteConnectionException(); // } // // try // { // chatManager.leave(key, member); // } // catch (RemoteConnectionException re) // { // System.out.println("createChat(): unable to leave chatroom"); // System.out.println(re.toString()); // throw new RemoteConnectionException(); // } // finally // { // chatServer = null; // key = -1; // } // } //*/ //} ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ConnectionStrategy.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ConnectionStra0000644000175000017500000000037310400175262033353 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import org.jboss.remoting.samples.chat.exceptions.ConnectionException; public interface ConnectionStrategy { void list() throws ConnectionException; void create() throws ConnectionException; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/Chat.java0000644000175000017500000000476110400175262032226 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.UIManager; import org.jboss.remoting.samples.chat.utility.Debug; import org.jboss.remoting.samples.chat.utility.Parameters; /** *

          Title: Chat

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author Ron Sigal * @version 1.0 */ public class Chat extends CloseableFrame { boolean packFrame = false; //Construct the application public Chat(String[] args) { for (int i=0; i< args.length; i++) { System.out.println(args[i]); } Parameters.initParameters(args); String debug = Parameters.getParameter("debug"); if (debug != null && debug.charAt(0) == 'y') { Debug.turnOn(); // xmlrmi.utility.Debug.turnOn(); } RemoteStrategy remoteStrategy = null; ChatFrame frame = null; String remoteStrategyName = remoteStrategyName = Parameters.getParameter("remoteStrategy"); if (remoteStrategyName == null) remoteStrategyName = "chat.client.RemoteStrategyXmlRmi_Impl"; try { remoteStrategy = (RemoteStrategy) Class.forName(remoteStrategyName).newInstance(); System.out.println("chat: created remote strategy: " + remoteStrategyName); } catch (Exception e) { System.out.println("chat: unable to create RemoteStrategyImpl: " + remoteStrategyName); System.out.println(e.toString()); System.exit(-1); } LocalStrategy localStrategy = new LocalStrategy(this, remoteStrategy); frame = new ChatFrame(localStrategy); frame.show(); //Validate frames that have preset sizes //Pack frames that have useful preferred size info, e.g. from their layout if (packFrame) { frame.pack(); } else { frame.validate(); } //Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); } //Main method public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) { e.printStackTrace(); } new Chat(args); } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatMember.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatMember.jav0000644000175000017500000000055010400175262033205 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; public class ChatMember implements java.io.Serializable { public ChatMember() {} public ChatMember(String name) { super(); this.name = name; } private String name; public String get_name() { return name; } public void set_name(String name) { this.name = name; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/CreateFrame.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/CreateFrame.ja0000644000175000017500000001235210400175262033171 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import org.jboss.remoting.samples.chat.exceptions.CreateConnectionException; /** *

          Title: Chat

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ interface CreateConnectionStrategy { void createChat(String description, ChatMember owner) throws CreateConnectionException; } public class CreateFrame extends CloseableFrame { JLabel jDescriptionLabel = new JLabel(); JLabel IDLabel = new JLabel(); JTextField descriptionField = new JTextField(); JTextField idField = new JTextField(); JButton OKButton = new JButton(); JButton CancelButton = new JButton(); GridBagLayout gridBagLayout1 = new GridBagLayout(); private CreateConnectionStrategy ccs; public CreateFrame( CreateConnectionStrategy ccs, Closeable parent) { super(parent); this.ccs = ccs; try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { jDescriptionLabel.setFont(new java.awt.Font("SansSerif", 1, 12)); jDescriptionLabel.setText("Description:"); this.getContentPane().setLayout(gridBagLayout1); IDLabel.setFont(new java.awt.Font("SansSerif", 1, 12)); IDLabel.setText("Your ID:"); descriptionField.setText(""); idField.setText(""); OKButton.setFont(new java.awt.Font("SansSerif", 1, 14)); OKButton.setText("OK"); OKButton.addActionListener(new CreateFrame_OKButton_actionAdapter(this)); CancelButton.setFont(new java.awt.Font("SansSerif", 1, 14)); CancelButton.setText("Cancel"); CancelButton.addActionListener(new CreateFrame_CancelButton_actionAdapter(this)); this.setLocale(java.util.Locale.getDefault()); this.setResizable(false); this.setTitle("Create a chat room"); this.setSize(new Dimension(00, 300)); this.getContentPane().add(jDescriptionLabel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(25, 21, 0, 0), 11, 4)); this.getContentPane().add(IDLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(11, 21, 0, 0), 27, 0)); this.getContentPane().add(descriptionField, new GridBagConstraints(2, 0, 2, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(25, 0, 0, 16), 270, 1)); this.getContentPane().add(OKButton, new GridBagConstraints(1, 2, 2, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(81, 0, 115, 0), 30, -5)); this.getContentPane().add(CancelButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(81, 27, 115, 103), 11, -2)); this.getContentPane().add(idField, new GridBagConstraints(2, 1, 2, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(9, 0, 0, 22), 272, 2)); center(); pack(); } void OKButton_actionPerformed(ActionEvent e) { try { notifyOnClose(this); ChatMember chatMember = new ChatMember(); chatMember.set_name(idField.getText()); ccs.createChat(descriptionField.getText(),chatMember); } catch (CreateConnectionException cce) { System.out.println("OK button catches exception:"); System.out.println(cce); } } void CancelButton_actionPerformed(ActionEvent e) { notifyOnClose(this); } public static void main(String[] args) { CreateFrame createFrame; try { createFrame = new CreateFrame( new DummyCreateConnectionStrategy(), null); createFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); createFrame.show(); } catch (CreateConnectionException ce) { System.out.println("unable to create create frame"); } } } class CreateFrame_OKButton_actionAdapter implements java.awt.event.ActionListener { CreateFrame adaptee; CreateFrame_OKButton_actionAdapter(CreateFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.OKButton_actionPerformed(e); } } class CreateFrame_CancelButton_actionAdapter implements java.awt.event.ActionListener { CreateFrame adaptee; CreateFrame_CancelButton_actionAdapter(CreateFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.CancelButton_actionPerformed(e); } } class DummyCreateConnectionStrategy implements CreateConnectionStrategy { public DummyCreateConnectionStrategy() throws CreateConnectionException { System.out.println("DummyCreateConnectionStrategy()"); } public void createChat(String description, ChatMember owner) throws CreateConnectionException { System.out.println("description: " + description); System.out.println("nickName: " + owner.get_name()); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/WindowOwner.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/WindowOwner.ja0000644000175000017500000000020410400175262033266 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.*; interface WindowOwner { void notifyOnClose(Component c); } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/TalkFrame.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/TalkFrame.java0000644000175000017500000002056210400175262033212 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.Color; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.util.ArrayList; import java.util.Iterator; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import org.jboss.remoting.samples.chat.exceptions.TalkConnectionException; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ interface TalkConnectionStrategy { void send(ChatMessage message) throws TalkConnectionException; void leave() throws TalkConnectionException; } public class TalkFrame extends CloseableFrame { JScrollPane jScrollPane1 = new JScrollPane(); JButton closeButton = new JButton(); JButton exitButton = new JButton(); JTextArea backChatTextArea = new JTextArea(); JTextField newMessage = new JTextField(); JLabel talkLabel = new JLabel(); GridBagLayout gridBagLayout1 = new GridBagLayout(); private String description; private String nickname; private String[] backChat; private TalkConnectionStrategy tcs; private Font plainFont; private Font boldFont; private String chatKey; private static ArrayList talkWindows = new ArrayList(); public final boolean NEW_CHAT = true; public final boolean OLD_CHAT = false; public TalkFrame(String description, String nickname, Closeable parent) { super(parent); this.description = description; this.nickname = nickname; try { jbInit(); } catch (Exception e) { e.printStackTrace(); } plainFont = new Font("SanSerif", Font.PLAIN, 12); boldFont = new Font("SanSerif", Font.BOLD, 12); talkWindows.add(this); } private void jbInit() throws Exception { this.getContentPane().setLayout(gridBagLayout1); closeButton.setFont(new java.awt.Font("SansSerif", 1, 12)); closeButton.setText("Close"); closeButton.addActionListener(new TalkFrame_closeButton_actionAdapter(this)); exitButton.setFont(new java.awt.Font("SansSerif", 1, 12)); exitButton.setText("Exit"); exitButton.addActionListener(new TalkFrame_exitButton_actionAdapter(this)); backChatTextArea.setFont(new java.awt.Font("Monospaced", 0, 13)); backChatTextArea.setDisabledTextColor(Color.white); backChatTextArea.setEditable(false); backChatTextArea.setText(""); newMessage.setText(""); newMessage.addActionListener(new TalkFrame_newMessage_actionAdapter(this)); newMessage.requestFocus(); talkLabel.setFont(new java.awt.Font("SansSerif", 1, 12)); talkLabel.setText("Talk:"); jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane1.getViewport().setBackground(Color.white); jScrollPane1.setAutoscrolls(true); this.getContentPane().setBackground(SystemColor.control); this.getContentPane().add(closeButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(28, 204, 21, 0), 6, 0)); this.getContentPane().add(exitButton, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(28, 17, 21, 280), 18, 0)); this.getContentPane().add(jScrollPane1, new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0 ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 8, 0, 33), 602, 264)); this.getContentPane().add(talkLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(34, 15, 0, 0), 7, -1)); this.getContentPane().add(newMessage, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0 ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(25, 10, 0, 33), 602, 6)); jScrollPane1.getViewport().add(backChatTextArea, null); setTitle(description); pack(); center(); } public void registerStrategy(TalkConnectionStrategy tcs) { this.tcs = tcs; } public void registerChatKey(String chatKey) { System.out.println("TalkFrame: registering chat key: " + chatKey); this.chatKey = chatKey; } public void appendMessage(ChatMessage chatMessage) { String message = chatMessage.get_message(); int mark = message.indexOf(':'); int boundedMark = java.lang.Math.max(0, mark); // if ':' is missing, mark == -1 boundedMark = java.lang.Math.min(8, boundedMark); // restrict names to 8 characters String name = message.substring(0, boundedMark) + ":" + " ".substring(0, 8 - boundedMark); String content = message.substring(mark + 1) + "\n"; backChatTextArea.append(name + content); // backChatTextArea.append(message); /* // System.out.println("****appendMessage: scrollbar position: " + jScrollPane1.getViewport().getViewPosition()); int value = jScrollPane1.getVerticalScrollBar().getModel().getMaximum() - jScrollPane1.getVerticalScrollBar().getModel().getExtent(); value = (int) Math.round(.9 * value); // System.out.println("****appendMessage: setting scrollbar value to " + value); jScrollPane1.getVerticalScrollBar().getModel().setValue(value); */ } public void appendMessages(ArrayList messages) { for (int i = 0; i < messages.size(); i++) { appendMessage((ChatMessage) messages.get(i)); } } public static void main(String[] args) { String[] backChat = { "roger: take this", "mike: take that"}; TalkFrame talkFrame = new TalkFrame( "dummy title", "h_brewski", null); talkFrame.show(); } void close() { if (tcs == null) throw new Error("TalkFrame '" + description + "' close(): no TalkStrategy registered"); try { tcs.leave(); } catch (TalkConnectionException rce) { System.out.println("TalkFrame: unable to close"); } hide(); System.out.println("member '" + nickname + "' is leaving chat room '" + description + "'"); talkWindows.remove(this); notifyOnClose(this); } void closeButton_actionPerformed(ActionEvent e) { close(); } public static void exit() { Iterator it = new ArrayList(talkWindows).iterator(); // close() modifies talkWindows while (it.hasNext()) { ((TalkFrame)it.next()).close(); } System.exit(0); } void exitButton_actionPerformed(ActionEvent e) { exit(); } void newMessage_actionPerformed(ActionEvent e) { if (tcs == null) throw new Error("TalkFrame exit button: no TalkStrategy registered"); try { tcs.send(new ChatMessage(chatKey, nickname + ": " + newMessage.getText())); } catch (TalkConnectionException rce) { System.out.println("TalkFrame: unable to send new chat line"); } newMessage.setText(""); } } class TalkFrame_closeButton_actionAdapter implements java.awt.event.ActionListener { TalkFrame adaptee; TalkFrame_closeButton_actionAdapter(TalkFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.closeButton_actionPerformed(e); } } class TalkFrame_exitButton_actionAdapter implements java.awt.event.ActionListener { TalkFrame adaptee; TalkFrame_exitButton_actionAdapter(TalkFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.exitButton_actionPerformed(e); } } class TalkFrame_newMessage_actionAdapter implements java.awt.event.ActionListener { TalkFrame adaptee; TalkFrame_newMessage_actionAdapter(TalkFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.newMessage_actionPerformed(e); } } class DummyTalkConnectionStrategy implements TalkConnectionStrategy { public DummyTalkConnectionStrategy() throws TalkConnectionException { System.out.println("DummyTalkConnectionStrategy()"); } public void getBackChat(TalkFrame talkFrame) throws TalkConnectionException { System.out.println("DummyTalkConnectionStrategy.getBackChat()"); } public void send(ChatMessage message) { System.out.println("DummyTalkConnectionStrategy.send()"); } public void leave() throws TalkConnectionException { System.out.println("DummyTalkConnectionStrategy.leave()"); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/LocalStrategy.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/LocalStrategy.0000644000175000017500000002251210400175262033254 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.awt.Component; import java.util.ArrayList; import javax.swing.SwingUtilities; import org.jboss.logging.Logger; import org.jboss.remoting.samples.chat.exceptions.ConnectionException; import org.jboss.remoting.samples.chat.exceptions.CreateConnectionException; import org.jboss.remoting.samples.chat.exceptions.JoinConnectionException; import org.jboss.remoting.samples.chat.exceptions.ListConnectionException; import org.jboss.remoting.samples.chat.exceptions.NameInUseException; import org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException; import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; import org.jboss.remoting.samples.chat.exceptions.TalkConnectionException; import org.jboss.remoting.samples.chat.server.ChatServer; import org.jboss.remoting.samples.chat.utility.ReadWriteArrayList; class Wrapper { private Object obj; public Wrapper() { } public Wrapper(Object o) { obj = o; } public void set(Object o) { obj = o; } public Object get() { return obj; } } // **************************************************************** public class LocalStrategy implements ConnectionStrategy, CreateConnectionStrategy, InfoConnectionStrategy, JoinConnectionStrategy, ListConnectionStrategy { protected static final Logger log = Logger.getLogger(LocalStrategy.class); private RemoteStrategy remoteStrategy; private CloseableFrame parent; private CreateFrame createFrame; private InfoFrame infoFrame; private JoinFrame joinFrame; private ListFrame listFrame; private TalkFrame talkFrame; private Thread readThread; private boolean isChatting; private ShutDownDialog shuttingDownDialog = new ShutDownDialog(); public LocalStrategy(CloseableFrame parent, RemoteStrategy remoteStrategy) { this.parent = parent; this.remoteStrategy = remoteStrategy; } // **************************************************************** // ConnectionStrategy public void list() { final Wrapper chatRoomDescriptions = new Wrapper(); Thread t = new Thread() { public void run() { try { chatRoomDescriptions.set(remoteStrategy.list()); } catch (ShuttingDownException e) { SwingUtilities.invokeLater(shuttingDownDialogRunnable); } catch (RemoteConnectionException e) { log.error(e); } Runnable r = new Runnable() { public void run() { new ListFrame(LocalStrategy.this, (ArrayList) chatRoomDescriptions.get(), parent).show(); } }; SwingUtilities.invokeLater(r); } }; t.start(); } public void create() throws ConnectionException { createFrame = new CreateFrame(this, parent); createFrame.show(); } // **************************************************************** // CreateConnectionStrategy public void createChat(final String description, final ChatMember owner) throws CreateConnectionException { Thread t = new Thread() { TalkFrame talkFrame = new TalkFrame(description, owner.get_name(), parent); ReadWriteArrayList outgoingLines = new ReadWriteArrayList(); ChatServer chatServer = null; public void run() { try { chatServer = remoteStrategy.createChat(description, owner, talkFrame, outgoingLines); } catch (ShuttingDownException sde) { SwingUtilities.invokeLater(shuttingDownDialogRunnable); } catch (RemoteConnectionException e) { log.error("Cannot create chat room: " + description); log.error(e); } catch (NameInUseException e) { System.out.println("Pick a new name"); } Runnable r = new Runnable() { public void run() { talkFrame.registerStrategy(new TalkConnectionStrategyImpl(owner, chatServer, outgoingLines)); talkFrame.show(); } }; SwingUtilities.invokeLater(r); } }; t.start(); } // **************************************************************** // JoinConnectionStrategy public void join(final ChatInfo chatInfo, final ChatMember newMember) throws JoinConnectionException { Thread t = new Thread() { TalkFrame talkFrame = new TalkFrame(chatInfo.get_description(), newMember.get_name(), parent); ReadWriteArrayList outgoingLines = new ReadWriteArrayList(); Wrapper remoteChatServerWrapper = new Wrapper(); ChatServer chatServer = null; public void run() { try { chatServer = remoteStrategy.join(chatInfo.get_key(), newMember, talkFrame, outgoingLines); } catch (ShuttingDownException sde) { SwingUtilities.invokeLater(shuttingDownDialogRunnable); } catch (RemoteConnectionException e) { log.error("Cannot join chat room: " + chatInfo.get_description()); log.error(e); } catch (NameInUseException niue) { System.out.println("Pick a new name"); } Runnable r = new Runnable() { public void run() { talkFrame.registerStrategy(new TalkConnectionStrategyImpl(newMember, chatServer, outgoingLines)); talkFrame.registerChatKey(chatInfo.get_key()); talkFrame.show(); } }; SwingUtilities.invokeLater(r); } }; t.start(); } // **************************************************************** // InfoConnectionStrategy + ListConnectionStrategy public void getId(ChatInfo chatInfo) { joinFrame = new JoinFrame(chatInfo, this, parent); joinFrame.show(); } public void getInfo(ArrayList chatInfoList, int key) throws ListConnectionException { infoFrame = new InfoFrame(this, (ChatInfo) chatInfoList.get(key), parent); infoFrame.show(); } // **************************************************************** // TalkConnectionStrategy class TalkConnectionStrategyImpl implements TalkConnectionStrategy { private ChatServer chatServer; private ChatMember member; private ReadWriteArrayList outgoingLines; public TalkConnectionStrategyImpl(ChatMember member, ChatServer cs, ReadWriteArrayList outgoingLines) { chatServer = cs; this.member = member; this.outgoingLines = outgoingLines; } // getBackChat() is not currently used, since the ChatReceiverThread created by ChatManager_Impl // sends all existing lines in the chat room, starting with line 0. // public void getBackChat(final TalkFrame talkFrame) // { // Thread t = new Thread() { // public void run() { // try { // String[] backChat = remoteChatServer.getBackChat(); // if (backChat == null) // backChat = new String[0]; // talkFrame.setBackChat(backChat); // } // catch (ShuttingDownException sde) { // SwingUtilities.invokeLater(shuttingDownDialogRunnable); // } // catch (RemoteConnectionException rce) { // System.out.println("TalkConnectionStrategy: unable to get back chat"); // System.out.println(rce); // } // } // }; // // t.start(); // } public void send(ChatMessage message) throws TalkConnectionException { outgoingLines.add(message); } public void leave() { Thread t = new Thread() { public void run() { try { chatServer.leave(member); } catch (ShuttingDownException sde) { SwingUtilities.invokeLater(shuttingDownDialogRunnable); } catch (RemoteConnectionException e) { log.error("TalkConnectionStrategy.leave(): unable to leave chat room"); log.error(e); } chatServer = null; } }; t.start(); } } // **************************************************************** public void notifyOnClose(Component c) { c.setVisible(false); } protected boolean isChatting() { return isChatting; } protected void setIsChatting(boolean b) { isChatting = b; } // **************************************************************** private Runnable shuttingDownDialogRunnable = new Runnable() { public void run() { shuttingDownDialog.show(); } }; }././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/RemoteStrategy.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/RemoteStrategy0000644000175000017500000000243110400175262033375 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; import java.util.ArrayList; import org.jboss.remoting.samples.chat.exceptions.NameInUseException; import org.jboss.remoting.samples.chat.server.ChatServer; // **************************************************************** public interface RemoteStrategy { ArrayList list() throws org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException, org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; ChatServer createChat(String description, ChatMember owner, TalkFrame talkFrame, org.jboss.remoting.samples.chat.utility.ReadWriteArrayList outgoingLines) throws NameInUseException, org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException, org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; ChatServer join(String key, ChatMember newMember, TalkFrame talkFrame, org.jboss.remoting.samples.chat.utility.ReadWriteArrayList outgoingLines) throws NameInUseException, org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException, org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; void setShuttingDown(); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatInfo.java0000644000175000017500000000261610400175262033037 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.client; public class ChatInfo implements java.io.Serializable { public ChatInfo() {} public ChatInfo(String key, String description, ChatMember owner, java.util.Date origin, int size, int currentMembers) { super(); this.key = key; this.description = description; this.owner = owner; this.origin = origin; this.size = size; this.currentMembers = currentMembers; } private String key; public String get_key() { return key; } public void set_key(String key) { this.key = key; } private String description; public String get_description() { return description; } public void set_description(String description) { this.description = description; } private ChatMember owner; public ChatMember get_owner() { return owner; } public void set_owner(ChatMember owner) { this.owner = owner; } private java.util.Date origin; public java.util.Date get_origin() { return origin; } public void set_origin(java.util.Date origin) { this.origin = origin; } private int size; public int get_size() { return size; } public void set_size(int size) { this.size = size; } private int currentMembers; public int get_currentMembers() { return currentMembers; } public void set_currentMembers(int currentMembers) { this.currentMembers = currentMembers; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatMessage.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/client/ChatMessage.ja0000644000175000017500000000160610400175262033177 0ustar twernertwerner/* * Created on Mar 21, 2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package org.jboss.remoting.samples.chat.client; import java.io.Serializable; /** * @author sigal * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class ChatMessage implements Serializable { public ChatMessage(String chatId, String message) { super(); this.chatId = chatId; this.message = message; } public ChatMessage() { } private String chatId; public String get_chatId() { return chatId; } public void set_chatId(String chatId) { this.chatId = chatId; } private String message; public String get_message() { return message; } public void set_message(String message) { this.message = message; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/0000755000175000017500000000000011632407051030526 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/CallbackThread.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/CallbackThread0000644000175000017500000000433210400175262033275 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.server; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ import java.util.ArrayList; import org.jboss.logging.Logger; import org.jboss.remoting.callback.Callback; import org.jboss.remoting.callback.HandleCallbackException; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.invocation.RemoteInvocation; import org.jboss.remoting.samples.chat.utility.ReadWriteArrayList; import org.jboss.remoting.samples.chat.utility.ShutDownGate; public class CallbackThread extends Thread { protected static final Logger log = Logger.getLogger(CallbackThread.class); private InvokerCallbackHandler callbackHandler; private ShutDownGate shutDownGate; private boolean memberLeaving; private ReadWriteArrayList messages; private int backChatSize; public CallbackThread(InvokerCallbackHandler callbackHandler, ShutDownGate shutDownGate, ReadWriteArrayList messages) { this.callbackHandler = callbackHandler; this.memberLeaving = false; this.shutDownGate = shutDownGate; this.messages = messages; backChatSize = messages.size(); ArrayList backChat = new ArrayList(backChatSize); backChat = messages.copy(); RemoteInvocation invocation = new RemoteInvocation("sendMultiple", new Object[] {backChat}); Callback callback = new Callback(invocation); try { callbackHandler.handleCallback(callback); } catch (HandleCallbackException e) { log.error(e); } } public void setMemberLeaving() { memberLeaving = true; } public void run() { int i = backChatSize; while (!shutDownGate.isShuttingDown() && !memberLeaving) { RemoteInvocation invocation = new RemoteInvocation("send", new Object[] {messages.get(i)}); Callback callback = new Callback(invocation); try { callbackHandler.handleCallback(callback); } catch (HandleCallbackException e) { log.error(e); } i++; } } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatServer_Impl.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatServer_Imp0000644000175000017500000001050510400175262033323 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.server; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; 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; import org.jboss.remoting.samples.chat.client.ChatInfo; import org.jboss.remoting.samples.chat.client.ChatMember; import org.jboss.remoting.samples.chat.client.ChatMessage; import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; import org.jboss.remoting.samples.chat.utility.ReadWriteArrayList; import org.jboss.remoting.samples.chat.utility.ShutDownGate; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ public class ChatServer_Impl implements ServerInvocationHandler { protected static final Logger log = Logger.getLogger(ChatServer_Impl.class); private ExtendedChatInfo extendedChatInfo; private Map callbackThreadMap = new HashMap(); private ShutDownGate shutDownGate; private boolean shuttingDown = false; public ChatServer_Impl(ExtendedChatInfo eci, ShutDownGate sdg) { extendedChatInfo = eci; shutDownGate = sdg; } public Object invoke(InvocationRequest invocation) throws Throwable { if (!(invocation.getParameter() instanceof RemoteInvocation)) throw new Exception("invalid request format: expecting NameBasedInvocation"); RemoteInvocation request = (RemoteInvocation) invocation.getParameter(); String methodName = request.getMethodName(); Object[] args = request.getParameters(); if (methodName.equals("getBackChat")) return getBackChat(args); if (methodName.equals("getChatInfo")) return getChatInfo(args); if (methodName.equals("leave")) { leave(args); return null; } if (methodName.equals("send")) { send(args); return null; } log.error("unrecognized method name: " + methodName); throw new Exception("unrecognized method name: " + methodName); } protected ArrayList getBackChat(Object[] args) throws ShuttingDownException { shutDownGate.enter(); ReadWriteArrayList messages = extendedChatInfo.getMessages(); if (messages == null) { System.out.println("messages == null"); messages = new ReadWriteArrayList(); } ArrayList returnMessages = messages.toArrayList(); shutDownGate.leave(); return returnMessages; } protected ChatInfo getChatInfo(Object[] args) throws ShuttingDownException { shutDownGate.check(); ChatInfo chatInfo = extendedChatInfo.getChatInfo(); chatInfo.set_currentMembers(extendedChatInfo.getMembers().size()); chatInfo.set_size(extendedChatInfo.getMessages().size()); return chatInfo; } protected void leave(Object[] args) throws ShuttingDownException { ChatMember member = (ChatMember) args[0]; shutDownGate.enter(); System.out.println("ChatServer.leave(): member leaving: " + member.get_name()); extendedChatInfo.removeMember(member); shutDownGate.leave(); } protected void send(Object[] args) throws ShuttingDownException { ChatMessage mesg = (ChatMessage) args[0]; shutDownGate.enter(); ReadWriteArrayList messages = extendedChatInfo.getMessages(); messages.add(mesg); shutDownGate.leave(); } public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public void addListener(InvokerCallbackHandler callbackHandler) { CallbackThread t = new CallbackThread(callbackHandler, shutDownGate, extendedChatInfo.getMessages()); callbackThreadMap.put(callbackHandler, t); t.start(); } public void removeListener(InvokerCallbackHandler callbackHandler) { CallbackThread t = (CallbackThread) callbackThreadMap.remove(callbackHandler); if (t != null) t.setMemberLeaving(); } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatStore.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatStore.java0000644000175000017500000000736410400175262033275 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.server; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; import org.jboss.logging.Logger; import org.jboss.remoting.samples.chat.client.ChatInfo; import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; import org.jboss.remoting.samples.chat.utility.ShutDownGate; public class ChatStore implements Serializable { private static final long serialVersionUID = 1; protected static final Logger log = Logger.getLogger(ChatStore.class); private Hashtable extendedChatInfoMap; private ShutDownGate shutDownGate; public ChatStore() { extendedChatInfoMap = new Hashtable(); shutDownGate = new ShutDownGate(); // try // { // databaseManager = new DatabaseManager(); // // System.out.println("ChatStore(): created DatabaseManager"); // // if (databaseManager.chatDBExists()) // { // restoreExtendedChatInfoMap(); // System.out.println("ChatStore(): restored chat store"); // } // else // { // databaseManager.createChatDB(); // System.out.println("ChatStore(): created new data base"); // } // } // catch (DatabaseException e) // { // e.printStackTrace(); // } } public ShutDownGate getShutDownGate() { return shutDownGate; } public void addChat(ExtendedChatInfo eci) throws ShuttingDownException { shutDownGate.enter(); String key = eci.getChatInfo().get_key(); extendedChatInfoMap.put(key, eci); log.info("adding chat " + key); shutDownGate.leave(); } /* fail-fast iterator*/ ArrayList listChats() throws ShuttingDownException { shutDownGate.check(); Collection c = extendedChatInfoMap.values(); ArrayList chatArrayList = new ArrayList(); Iterator it = c.iterator(); while (it.hasNext()) { ExtendedChatInfo eci = (ExtendedChatInfo) it.next(); ChatInfo ci = eci.getChatInfo(); ci.set_currentMembers(eci.getMembers().size()); ci.set_size(eci.getMessages().size()); chatArrayList.add(ci); log.debug("eci.getMembers(): " + eci.getMembers()); } return chatArrayList; } public ExtendedChatInfo getChat(String key) throws ShuttingDownException { shutDownGate.check(); ExtendedChatInfo eci = (ExtendedChatInfo) extendedChatInfoMap.get(key); return eci; } public Collection getChatKeySet() { return extendedChatInfoMap.keySet(); } // private void restoreExtendedChatInfoMap() // { // ArrayList chats = null; // // try // { // chats = databaseManager.getChats(); // } // catch (DatabaseException e) // { // e.printStackTrace(); // } // Iterator it = chats.iterator(); // // while (it.hasNext()) // { // ChatInfo chatInfo = (ChatInfo) it.next(); // ExtendedChatInfo eci = new ExtendedChatInfo(chatInfo); // //// ArrayList members = databaseManager.getChatMembers(chatInfo.get_key()); //// Iterator mit = members.iterator(); //// //// while (mit.hasNext()) //// { // // eci.addMember((ChatMember) it.next(), null); // // } // // ArrayList messages; // try // { // messages = databaseManager.getChatMessages(chatInfo.get_key()); // eci.addMessages(messages); // } // catch (DatabaseException e1) // { // e1.printStackTrace(); // } // // // // try { // addChat(eci); // } catch (ShuttingDownException sde) {} // ignore: we're just starting up // } // } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatManager.ja0000644000175000017500000001507610400175262033223 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.server; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.Date; import javax.management.MBeanServer; import org.jboss.logging.Logger; 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.RemoteInvocation; import org.jboss.remoting.samples.chat.client.ChatInfo; import org.jboss.remoting.samples.chat.client.ChatMember; import org.jboss.remoting.samples.chat.exceptions.InitializeException; import org.jboss.remoting.samples.chat.exceptions.NameInUseException; import org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException; import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; import org.jboss.remoting.transport.Connector; /** */ public class ChatManager implements ServerInvocationHandler { protected static final Logger log = Logger.getLogger(ChatManager.class); private static final String chatServerLocator = "socket://localhost"; private ChatStore chatStore; private final File chatStoreFile = new File("chatStore.ser"); private boolean chatStoreSaved = false; private boolean shuttingDown = false; public ChatManager() { try { initialize(); } catch (InitializeException ie) { log.error("ChatManager_Impl: cannot initialize: " + ie); System.exit(1); } } protected void initialize() throws InitializeException { if (chatStoreFile.exists()) { try { log.info("ChatManager_Impl: reading existing ChatStore"); FileInputStream file = new FileInputStream(chatStoreFile); ObjectInputStream input = new ObjectInputStream(file); chatStore = (ChatStore) input.readObject(); chatStore.getShutDownGate().reset(); log.info("ChatManager_Impl: read existing ChatStore"); } catch (java.io.IOException ioe) { log.error("ChatManager_Impl: i/o error reading chatStore: " + ioe); System.exit(1); } catch (java.lang.ClassNotFoundException cnfe) { log.error("ChatManager_Impl: ChatStore class not found: " + cnfe); System.exit(2); } } else { chatStore = new ChatStore(); log.info("ChatManager_Impl: created new ChatStore"); } // Runtime.getRuntime().addShutdownHook( // new Thread() { // public void run() { // System.out.println("ShutDownHook: shutting down"); //// new ShutDownDialog().show(); // shutdown(); // } // }); } public void shutdown() { log.info("shutdown(): shutting down"); if (chatStoreSaved) { log.info("shutdown(): chatStore already saved"); return; } chatStore.getShutDownGate().shutDown(); ObjectOutputStream out = null; try { out = new ObjectOutputStream(new FileOutputStream(chatStoreFile)); out.writeObject(chatStore); out.flush(); } catch (java.io.IOException ioe) { log.error("ChatManager_Impl: i/o error writing chatStore" + ioe); } finally { try { out.close(); } catch (java.io.IOException ioe) { log.error("ChatManager_Impl: i/o error closing chatStore" + ioe); } } chatStoreSaved = true; log.info("shutdown(): shut down"); } public Object invoke(InvocationRequest invocation) throws Throwable { if (!(invocation.getParameter() instanceof RemoteInvocation)) throw new Exception("invalid request format: expecting RemoteInvocation"); RemoteInvocation request = (RemoteInvocation) invocation.getParameter(); String methodName = request.getMethodName(); Object[] args = request.getParameters(); if (methodName.equals("createChat")) return createChat(args); else if (methodName.equals("join")) { join(args); return null; } else if (methodName.equals("leave")) { leave(args); return null; } else if (methodName.equals("list")) return list(args); else throw new Exception("unrecognized method name: " + methodName); } protected ArrayList list(Object[] args) throws RemoteConnectionException, ShuttingDownException { return chatStore.listChats(); } protected InvokerLocator createChat(Object[] args) throws Exception { String description = (String) args[0]; ChatMember owner = (ChatMember) args[1]; ChatInfo chatInfo = new ChatInfo(); ExtendedChatInfo extendedChatInfo = new ExtendedChatInfo(chatInfo); Connector connector = new Connector(); connector.setInvokerLocator(chatServerLocator); connector.create(); connector.addInvocationHandler("chatServer", new ChatServer_Impl(extendedChatInfo, chatStore.getShutDownGate())); connector.start(); InvokerLocator chatLocator = connector.getLocator(); String key = chatLocator.getLocatorURI(); chatInfo.set_key(key); chatInfo.set_description(description); chatInfo.set_owner(owner); chatInfo.set_origin(new Date()); extendedChatInfo.addMember(owner); chatStore.addChat(extendedChatInfo); return chatLocator; } protected void join(Object[] args) throws NameInUseException, ShuttingDownException { String key = (String) args[0]; ChatMember newMember = (ChatMember) args[1]; ExtendedChatInfo eci = chatStore.getChat(key); eci.addMember(newMember); } protected void leave(Object[] args) throws ShuttingDownException { String key = (String) args[0]; ChatMember member = (ChatMember) args[1]; ExtendedChatInfo eci = chatStore.getChat(key); eci.getMembers().remove(member); } public void setMBeanServer(MBeanServer server) { } public void setInvoker(ServerInvoker invoker) { } public void addListener(InvokerCallbackHandler callbackHandler) { } public void removeListener(InvokerCallbackHandler callbackHandler) { } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ExtendedChatInfo.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ExtendedChatIn0000644000175000017500000000470110400175262033300 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.server; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; import org.jboss.remoting.samples.chat.client.ChatInfo; import org.jboss.remoting.samples.chat.client.ChatMember; import org.jboss.remoting.samples.chat.exceptions.NameInUseException; import org.jboss.remoting.samples.chat.utility.ReadWriteArrayList; public class ExtendedChatInfo implements Serializable { private static final long serialVersionUID = 3; private ChatInfo chatInfo; private ReadWriteArrayList messages; private Collection members; transient private Hashtable threadMap; transient private Collection chatReceivers; public ExtendedChatInfo(ChatInfo chatInfo) { this.chatInfo = chatInfo; messages = new ReadWriteArrayList(); members = Collections.synchronizedCollection(new HashSet()); threadMap = new Hashtable(); chatReceivers = Collections.synchronizedCollection(new HashSet()); } private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); threadMap = new Hashtable(); chatReceivers = Collections.synchronizedCollection(new HashSet()); } public ChatInfo getChatInfo() {return chatInfo;} public Collection getMembers() {return members;} public ReadWriteArrayList getMessages() {return messages;} public Collection getChatReceivers() {return chatReceivers;} public CallbackThread getChatReceiverThread(ChatMember member) { return (CallbackThread) threadMap.get(member.get_name()); } public void addMember(ChatMember member) throws NameInUseException { String name = member.get_name(); if (members.contains(name)) throw new NameInUseException(); members.add(name); } public void removeMember(ChatMember member) { String name = member.get_name(); threadMap.remove(name); members.remove(name); } public void addMessages(ArrayList messages) { Iterator it = messages.iterator(); while (it.hasNext()) { this.messages.add(it.next()); } } public void addMessage(String message) { messages.add(message); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatServer.jav0000644000175000017500000000137410400175262033301 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.server; import org.jboss.remoting.samples.chat.client.ChatInfo; import org.jboss.remoting.samples.chat.client.ChatMember; import org.jboss.remoting.samples.chat.client.ChatMessage; import org.jboss.remoting.samples.chat.exceptions.RemoteConnectionException; import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; public interface ChatServer { void send(ChatMessage mesg) throws RemoteConnectionException, ShuttingDownException; ChatInfo getChatInfo() throws RemoteConnectionException, ShuttingDownException; java.util.ArrayList getBackChat() throws RemoteConnectionException, ShuttingDownException; void leave(ChatMember member) throws RemoteConnectionException, ShuttingDownException; } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatManagerLauncher.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/server/ChatManagerLau0000644000175000017500000001325610400175262033272 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.server; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.net.MalformedURLException; import javax.swing.JButton; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.samples.chat.client.CloseableFrame; import org.jboss.remoting.samples.chat.utility.Parameters; import org.jboss.remoting.transport.Connector; /** *

          Title: Chat

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ public class ChatManagerLauncher extends CloseableFrame { protected static final Logger log = Logger.getLogger(ChatManagerLauncher.class); private static final int PORT = 1969; private ChatManager chatManager; private InvokerLocator managerLocator; private Connector managerConnector; private JButton launchButton = new JButton(); private JButton shutDownButton = new JButton(); private JButton exitButton = new JButton(); private GridBagLayout gridBagLayout1 = new GridBagLayout(); public ChatManagerLauncher() { try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { Parameters.initParameters(args); ChatManagerLauncher chatManagerLauncher = new ChatManagerLauncher(); } private void jbInit() throws Exception { launchButton.setFont(new java.awt.Font("SansSerif", 1, 12)); launchButton.setActionCommand("startButton"); launchButton.setText("Launch"); launchButton.addActionListener(new ChatManagerLauncher_launchButton_actionAdapter(this)); this.getContentPane().setLayout(gridBagLayout1); shutDownButton.setFont(new java.awt.Font("SansSerif", 1, 12)); shutDownButton.setText("Shut down"); shutDownButton.addActionListener(new ChatManagerLauncher_shutDownButton_actionAdapter(this)); exitButton.setFont(new java.awt.Font("SansSerif", 1, 12)); exitButton.setText("Exit"); exitButton.addActionListener(new ChatManagerLauncher_exitButton_actionAdapter(this)); this.getContentPane().add( launchButton, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(188, 102, 0, 0), 0, 0)); this.getContentPane().add( shutDownButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(188, 23, 0, 103), 0, 0)); this.getContentPane().add( exitButton, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(23, 154, 39, 173), 0, 0)); center(); pack(); show(); } void launchButton_actionPerformed(ActionEvent ae) { String managerUriString = Parameters.getParameter("chatManagerUri"); try { managerLocator = new InvokerLocator(managerUriString); log.info("ChatManagerLauncher: manager uri = " + managerUriString); } catch (MalformedURLException e) { log.error("ChatManagerLauncher(): invalid locator uri: " + managerUriString); e.printStackTrace(); System.exit(-1); } managerConnector = new Connector(); try { managerConnector.setInvokerLocator(managerLocator.getLocatorURI()); managerConnector.create(); chatManager = new ChatManager(); managerConnector.addInvocationHandler("chatManager", chatManager); managerConnector.start(); } catch (Exception e) { log.error("Unable to start Connector for chat manager: " + e.getMessage()); e.printStackTrace(); } log.info("ChatManagerLauncher: created chat manager"); } void shutDownButton_actionPerformed(ActionEvent ae) { if (chatManager == null) { System.out.println("ChatManagerLauncher: chat manager has not been launched"); return; } try { chatManager.shutdown(); System.out.println("ChatManagerLauncher: shut down chatManager"); } catch (Exception e) { System.out.println("ChatManagerLauncher: unable to shut down"); return; } // xmlrmiServer.getWebServer().shutdown(); System.out.println("ChatManagerLauncher: shut down web server"); } void exitButton_actionPerformed(ActionEvent e) { System.exit(0); } } class ChatManagerLauncher_launchButton_actionAdapter implements java.awt.event.ActionListener { ChatManagerLauncher adaptee; ChatManagerLauncher_launchButton_actionAdapter(ChatManagerLauncher adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.launchButton_actionPerformed(e); } } class ChatManagerLauncher_shutDownButton_actionAdapter implements java.awt.event.ActionListener { ChatManagerLauncher adaptee; ChatManagerLauncher_shutDownButton_actionAdapter(ChatManagerLauncher adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.shutDownButton_actionPerformed(e); } } class ChatManagerLauncher_exitButton_actionAdapter implements java.awt.event.ActionListener { ChatManagerLauncher adaptee; ChatManagerLauncher_exitButton_actionAdapter(ChatManagerLauncher adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.exitButton_actionPerformed(e); } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/utility/0000755000175000017500000000000011632407051030723 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/utility/Parameters.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/utility/Parameters.ja0000644000175000017500000001420110400340340033325 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.utility; import java.util.*; import java.io.*; import javax.servlet.*; /** *

          Title: chat.utility.Parameters

          *

          Description: Manages parameters to the application.

          *

          A parameter's value is taken from: *

          1. the primary source, which is
            • the command line if the program is standalone
            • the web.conf file if the program is a servlet
            or, if the parameter is not given in the primary source,
          2. a configuration file property with the same name, or, if there is no such configuration file property
          3. the default value given in this file, or, if a default value is not given in this file,
          4. null
          *

          *

          Copyright: Copyright (c) 2004

          * @author Ron Sigal * @version 1.0 */ public class Parameters { static Hashtable parameterValues = new Hashtable(); static Hashtable primaryParameterValues = new Hashtable(); static Hashtable defaultParameterValues = new Hashtable(); static { defaultParameterValues.put("serverUri", "http://localhost:8000"); // URI of chat server defaultParameterValues.put("clientUri", "http://localhost:8002"); // URI used by ChatReceiver's } /** * initParameters() puts parameters into a Hashtable. *

          * For each element of args of the form "string1=string2", * the value "string2" is a parameter with key "string1". * * @param args: an array of Strings. These are meant to be the command line parameters. */ public static void initParameters(String[] args) { // get command line parameters for (int i = 0; i < args.length; i++) { int mark = args[i].indexOf('='); if (mark >= 0) { primaryParameterValues.put(args[i].substring(0, mark), args[i].substring(mark + 1)); } } getSecondaryParameterSources(); } /** * initParameters() puts parameters into a Hashtable. *

          * * @param servletConfig/code>: the primary source of parameters */ public static void initParameters(ServletConfig servletConfig) { Enumeration e = servletConfig.getInitParameterNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); primaryParameterValues.put(key, servletConfig.getInitParameter(key)); } getSecondaryParameterSources(); } /** * getSecondaryParameterSources() *

          • reads parameters from a parameter file named chat.conf, if it exists, *
          • gets default parameter values, and *
          • merges these with the parameter values from the primary source *
          */ private static void getSecondaryParameterSources() { // check if chat.conf parameter file has a non-standard location String configurationFilePath = "chat.conf"; if (primaryParameterValues.containsKey("chat.conf")) configurationFilePath = (String) primaryParameterValues.get("chat.conf"); File configurationFile = new File(configurationFilePath); // get properties from the configuration file if (configurationFile.exists()) { try { FileInputStream fis = new FileInputStream(configurationFile); Properties properties = new Properties(); properties.load(fis); Enumeration e = properties.propertyNames(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); parameterValues.put(key, properties.getProperty(key)); System.out.println(key + ":" + properties.getProperty(key)); } } catch (FileNotFoundException fnfe) { System.err.println("configuration file not found: " + configurationFilePath); System.err.println("using default properties"); } catch (IOException ioe) { System.err.println("error reading configuration file: " + configurationFilePath); System.err.println("using default properties"); System.out.println(ioe.getMessage()); } String debug = getParameter("debug"); if (debug.charAt(0) == 'y') { System.out.println("properties:"); Iterator it = parameterValues.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); System.out.println(" " + key + ": " + parameterValues.get(key)); } } } // override properties from configuration file with command line parameters Iterator it = primaryParameterValues.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); parameterValues.put(key, primaryParameterValues.get(key)); } } /** * getParameter() returns stored parameter values * * @param name name of parameter whose value is requested * @return if name is a key in parameters, returns the value associated with name. * Otherwise, returns null. */ public static String getParameter(String name) { return getParameter(name, null); } /** * getParameter() returns stored parameter values * * @param name name of parameter whose value is requested * @return if name is a key in parameters, returns the value associated with name. * Otherwise, returns null. */ public static String getParameter(String name, String defaultValue) { String value = null; value = (String) parameterValues.get(name); if (value == null) value = System.getProperty(name); if (value == null) value = (String) defaultParameterValues.get(name); if (value == null) value = defaultValue; return value; } /** * main() implements unit tests. */ public static void main(String[] args) { initParameters(args); System.out.println("clientUri: " + getParameter("clientUri")); System.out.println("serverUri: " + getParameter("serverUri")); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/utility/Debug.java0000644000175000017500000000131710400175262032614 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.utility; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ public class Debug { private static boolean on = false; public static void turnOn() { on = true; System.out.println("Debug: chat debugging turned on"); } public static void turnOff() { on = false; System.out.println("Debug: chat debugging turned on"); } public static boolean isOn() { return on; } public static void println(String str) { if (on) if (str != null) System.out.println(str); else System.out.println("null"); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/utility/ShutDownGate.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/utility/ShutDownGate.0000644000175000017500000000300110400175262033270 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.utility; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ import java.io.Serializable; import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException; public class ShutDownGate implements Serializable { private static final long serialVersionUID = 2; private int numberOfUsers; private boolean shuttingDown; public ShutDownGate() { reset(); } public void reset() { numberOfUsers = 0; shuttingDown = false; } public synchronized void check() throws ShuttingDownException { if (shuttingDown == true) throw new ShuttingDownException(); } public synchronized boolean isShuttingDown() { return shuttingDown; } public synchronized void enter() throws ShuttingDownException { if (shuttingDown == true) throw new ShuttingDownException(); numberOfUsers++; } public synchronized void leave() { if (numberOfUsers <= 0) throw new Error("ShutDownGate: number of Users <= 0"); if (--numberOfUsers == 0) notifyAll(); } public synchronized void shutDown() { shuttingDown = true; while (numberOfUsers > 0) { try { System.out.println("shutdown(): numberOfUsers == " + numberOfUsers); wait(); } catch (InterruptedException ie) {} } } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/utility/ReadWriteArrayList.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/chat/utility/ReadWriteArra0000644000175000017500000000514510400175262033345 0ustar twernertwernerpackage org.jboss.remoting.samples.chat.utility; /** *

          Title: Chat4

          *

          Description:

          *

          Copyright: Copyright (c) 2003

          *

          Company:

          * @author not attributable * @version 1.0 */ import java.util.*; import java.io.*; public class ReadWriteArrayList implements Serializable { private ArrayList arrayList; private static final long serialVersionUID = 6; private Gate gate = new Gate(); public ReadWriteArrayList() { arrayList = new ArrayList(); } public boolean add(Object o) { gate.enterWrite(); arrayList.add(o); gate.leaveWrite(); return true; } public Object get(int i) { gate.enterRead(i); Object o = arrayList.get(i); gate.leaveRead(); return o; } public ArrayList copy() { return (ArrayList) subList(0, arrayList.size()); } public List subList(int from, int to) { gate.enterRead(to - 1); List list = new ArrayList(arrayList.subList(from, to)); gate.leaveRead(); return list; } public Object firstElement() { return get(0); } public Object remove(int i) { gate.enterRead(i); Object o = arrayList.remove(i); gate.leaveRead(); return o; } public int size() { return arrayList.size(); } public Object[] toArray() { return arrayList.toArray(); } public Object[] toArray(Object[] a) { return arrayList.toArray(a); } public ArrayList toArrayList() { return arrayList; } //////////////////////////////////////////////////////////////////////////////// class Gate implements Serializable { private static final long serialVersionUID = 7; private int numberOfReaders; private int numberOfWriters; public synchronized void enterRead(int i) { while (numberOfWriters > 0 || i > arrayList.size() - 1) { try { wait(); } catch (InterruptedException ie) { } } numberOfReaders++; } public synchronized void enterWrite() { while (numberOfWriters > 0 || numberOfReaders > 0) { try { wait(); } catch (InterruptedException ie) { } } numberOfWriters++; } public synchronized void leaveRead() { if (numberOfReaders <= 0) throw new Error("number of readers <= 0"); numberOfReaders--; notifyAll(); } public synchronized void leaveWrite() { if (numberOfWriters <= 0) throw new Error("number of writers <= 0"); numberOfWriters--; notifyAll(); } } //////////////////////////////////////////////////////////////////////////////// }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/stream/0000755000175000017500000000000011632407052027575 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/stream/sample.txt0000644000175000017500000000173310255621770031630 0ustar twernertwernerThis is a test file to be streamed. The rest is filler. Carl Spackler: So I jump ship in Hong Kong and make my way over to Tibet, and I get on as a looper at a course over in the Himalayas. A looper, you know, a caddy, a looper, a jock. So, I tell them I'm a pro jock, and who do you think they give me? The Dalai Lama, himself. Twelfth son of the Lama. The flowing robes, the grace, bald... striking. So, I'm on the first tee with him. I give him the driver. He hauls off and whacks one -- big hitter, the Lama -- long, into a ten-thousand foot crevice, right at the base of this glacier. And do you know what the Lama says? Gunga galunga...gunga -- gunga galunga. So we finish the eighteenth and he's gonna stiff me. And I say, "Hey, Lama, hey, how about a little something, you know, for the effort, you know." And he says, "Oh, uh, there won't be any money, but when you die, on your deathbed, you will receive total consiousness." So I got that goin' for me, which is nice.././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/stream/StreamingClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/stream/StreamingClient.jav0000644000175000017500000001032010433770344033370 0ustar twernertwerner/* * 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.remoting.samples.stream; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.net.URL; /** * This samples shows how the client can send an InputStream to * the server. * * @author Tom Elrod */ public class StreamingClient { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port; private String localFileName = "sample.txt"; private String remoteFileName = "server_sample.txt"; public void sendStream() throws Throwable { FileInputStream fileInput = null; Client remotingClient = null; try { InvokerLocator locator = new InvokerLocator(locatorURI); System.out.println("Calling on remoting server with locator uri of: " + locatorURI); remotingClient = new Client(locator); remotingClient.connect(); URL fileURL = this.getClass().getResource(localFileName); System.out.println("looking for file at " + fileURL); if(fileURL == null) { throw new Exception("Can not find file " + localFileName); } File testFile = new File(fileURL.getFile()); fileInput = new FileInputStream(testFile); System.out.println("Sending input stream for file " + localFileName + " to server."); Object ret = remotingClient.invoke(fileInput, remoteFileName); long fileLength = testFile.length(); System.out.println("Size of file sample.txt is " + fileLength); System.out.println("Server returned " + ret + " as the size of the file read."); } finally { if(remotingClient != null) { remotingClient.disconnect(); } if(fileInput != null) { try { fileInput.close(); } catch(IOException e) { e.printStackTrace(); } } } } public void setRemoteFileName(String remoteFileName) { this.remoteFileName = remoteFileName; } /** * Can pass transport and port to be used as parameters. * Valid transports are 'rmi' and 'socket'. * * @param args */ public static void main(String[] args) { String newFileName = null; if(args != null && args.length == 1) { newFileName = args[0]; } if(args != null && args.length == 2) { transport = args[0]; port = Integer.parseInt(args[1]); } if(args != null && args.length == 3) { transport = args[0]; port = Integer.parseInt(args[1]); newFileName = args[2]; } String locatorURI = transport + "://" + host + ":" + port; StreamingClient client = new StreamingClient(); if(newFileName != null) { client.setRemoteFileName(newFileName); } try { client.sendStream(); } catch(Throwable e) { e.printStackTrace(); } } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/stream/StreamingServer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/samples/stream/StreamingServer.jav0000644000175000017500000001511210423204067033415 0ustar twernertwerner/* * 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.remoting.samples.stream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.FileOutputStream; import javax.management.MBeanServer; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.stream.StreamInvocationHandler; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class StreamingServer { // Default locator values private static String transport = "socket"; private static String host = "localhost"; private static int port = 5400; private String locatorURI = transport + "://" + host + ":" + port; private Connector connector = null; 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(); TestStreamInvocationHandler invocationHandler = new TestStreamInvocationHandler(); // first parameter is sub-system name. can be any String value. connector.addInvocationHandler("test_stream", invocationHandler); connector.start(true); } /** * 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 == 3) { transport = args[0]; host = args[1]; port = Integer.parseInt(args[2]); } StreamingServer server = new StreamingServer(); try { server.setupServer(); // wait forever, let the user kill us at any point (at which point, the client will detect we went down) while(true) { Thread.sleep(1000); } } catch(Exception e) { e.printStackTrace(); } } /** * Simple invocation handler implementation. */ public static class TestStreamInvocationHandler implements StreamInvocationHandler { private long streamSize = 0; /** * takes the incoming stream and writes out to a file specified by the other param specified. * will return the size of the file. * * @param stream * @param param * @return */ public Object handleStream(InputStream stream, InvocationRequest param) { try { String fileName = (String)param.getParameter(); System.out.println("Received input stream from client to write out to file " + fileName); File newFile = new File(fileName); if(!newFile.exists()) { newFile.createNewFile(); } FileOutputStream out = new FileOutputStream(newFile, false); byte buf[] = new byte[4096]; while(true) { int c = stream.read(buf); if(c < 0) { break; } out.write(buf, 0, c); } out.flush(); out.close(); streamSize = newFile.length(); System.out.println("New file " + fileName + " has been written out to " + newFile.getAbsolutePath()); System.out.println("Size of " + newFile.getAbsolutePath() + " is " + streamSize); } catch(Throwable e) { e.printStackTrace(); } finally { try { stream.close(); } catch(IOException e) { e.printStackTrace(); } } return new Long(streamSize); } /** * called to handle a specific invocation * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { // Print out the invocation request System.out.println("Invocation request is: " + invocation.getParameter()); // Return the size of the file already streamed to the server (and written to disk). return new Long(streamSize); } /** * 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 } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/Subsystem.java0000644000175000017500000000343310355142433027502 0ustar twernertwerner/* * 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.remoting; /** * Predefined subsystem types. These are strings since you could support a proprietary * subsystem or new specification by just adding the new subsystem string name on the server/client. * * @author Jeff Haynie * @version $Revision: 566 $ */ public interface Subsystem { // special subsystem defined as self, which is the transport layer - used when the transport // wants to send messages to itself, such as ping, synching data on both sides, etc. which // don't actually get propograted up the transport layer public static final String SELF = "self"; public static final String JMX = "jmx"; public static final String JMS = "jms"; public static final String EJB = "ejb"; public static final String RMI = "rmi"; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/SerializableStore.java0000644000175000017500000000702410355142433031127 0ustar twernertwerner/* * 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.remoting; import java.io.IOException; import java.io.Serializable; import java.util.Map; /** * @author Tom Elrod */ public interface SerializableStore { /** * Getst the number of objects stored and available. * * @return */ int size(); /** * Will look through the files in the store directory for the oldest object serialized to disk, load it, * delete the file, and return the deserialized object. * Important to note that once this object is returned from this method, it is gone forever from this * store and will not be able to retrieve it again without adding it back. * * @return * @throws java.io.IOException */ Object getNext() throws IOException; /** * Persists the serializable object passed to the directory specified. The file name will be the current time * in milliseconds (vis System.currentTimeMillis()) with the specified suffix. This object can later be * retrieved using the getNext() method, but objects will be returned in the order that they were added (FIFO). * * @param object * @throws java.io.IOException */ void add(Serializable object) throws IOException; /** * Will use the values in the map to set configuration. * * @param config */ void setConfig(Map config); /** * Will get the file path value (if not already set will just use the * default setting) and will create the directory specified by the file path * if it does not already exist. * * @throws Exception */ void start() throws Exception; /** * This will allow for change of file suffix and file path and then may start again * using these new values. However, any object already written out using the old * values will be lost as will not longer be accessible if these attributes are changed while stopped. */ void stop(); /** * This is a no op method, but needed in order to be used as a service within JBoss AS. * * @throws Exception */ void create() throws Exception; /** * This is a no op method, but needed in order to be used as a service within JBoss AS. */ void destroy(); /** * Sets if store should clean up persisted files when shutdown (destroy()). * * @param purgeOnShutdown */ void setPurgeOnShutdown(boolean purgeOnShutdown); /** * Returns if store will clean up persisted files when shutdown (destroy()). * * @return */ boolean getPurgeOnShutdown(); void purgeFiles(); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/0000755000175000017500000000000011632407052026505 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLSocketBuilderMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLSocketBuilderMBean.jav0000644000175000017500000004451210465726755033262 0ustar twernertwerner/* * 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.remoting.security; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.SSLContext; import java.io.IOException; import java.net.URL; import java.security.Provider; import java.security.SecureRandom; /** * The service interface of the socket builder. * * @author John Mazzitelli * @author Tom Elrod * @version $Revision: 1348 $ */ public interface SSLSocketBuilderMBean { /** * Setting the flag that indicates if this class should use SSLServerSocketFactory.getDefault() * when creating the ServerSocketFactory to use (when calling {@link #createSSLServerSocketFactory()}). If * true, will allow for setting key store location (via javax.net.ssl.keyStore system * property) and setting of the key store password (via javax.net.ssl.keyStorePassword system * property) and no other configuration is needed (none of the other setters will need to be called and are in * fact ignored). If set to false, will allow the custom setting of secure socket protocol, key * store management algorithm, file location, password among other things. * *

          The default value is true. * *

          NOTE: If this is not explicitly set to false, no customizations can be made and the * default implementation provided by the JVM vendor being used will be executed. * * @param shouldUse */ void setUseSSLServerSocketFactory( boolean shouldUse ); /** * Return whether SSLServerSocketFactory.getDefault() will be used or not. See * {@link #setUseSSLServerSocketFactory(boolean)} for more information on what this means. * * @return the flag to indicate if the default server socket factory is used */ boolean getUseSSLServerSocketFactory(); /** * Setting the flag that indicates if this class should use SSLSocketFactory.getDefault() when * creating the SocketFactory to use (when calling {@link #createSSLSocketFactory()}). If true, * will allow for setting trust store location (via javax.net.ssl.trustStore system property) and * setting of the key store password (via javax.net.ssl.trustStorePassword system property) and no * other configuration is needed (none of the other setters will need to be called and are in fact ignored). If * set to false, will allow the custom setting of secure socket protocol, key store management * algorithm, file location, password among other things. * *

          The default value is true. * *

          NOTE: If this is not explicitly set to false, no customizations can be made and the * default implementation provided by the JVM vendor being used will be executed. * * @param shouldUse */ void setUseSSLSocketFactory( boolean shouldUse ); /** * Return whether SSLSocketFactory.getDefault() will be used or not. See * {@link #setUseSSLSocketFactory(boolean)} for more information on what this means. * * @return the flag to indicate if the default socket factory is used */ boolean getUseSSLSocketFactory(); /** * Will create a SSLServerSocketFactory. If the {@link #getUseSSLServerSocketFactory()} property is * set to true (which is the default), it will use SSLServerSocketFactory.getDefault() * to get the server socket factory. Otherwise, if property is false, will use all the other custom * properties that have been set to create a custom server socket factory. * * @return the server socket factory that has been created * * @throws IOException */ ServerSocketFactory createSSLServerSocketFactory() throws IOException; /** * Will create a SSLServerSocketFactory. If the {@link #getUseSSLServerSocketFactory()} property is * set to true (which is the default), it will use SSLServerSocketFactory.getDefault() * to get the server socket factory. Otherwise, if property is false, will use all the other custom * properties that have been set to create a custom server socket factory. The given custom factory will be used * as the wrapper around the factory created by this method and will be the factory returned. If it is * null, one will be created and returned. * * @param wrapper the wrapper that will contain the created factory - used so the caller can further customize * the factory and its sockets as desired (may be null) * * @return the server socket factory that has been created (may be wrapper if it was not null) * * @throws IOException */ ServerSocketFactory createSSLServerSocketFactory( CustomSSLServerSocketFactory wrapper ) throws IOException; /** * Will create a SSLSocketFactory. If the {@link #getUseSSLSocketFactory()} property is set to * true (which is the default), it will use SSLSocketFactory.getDefault() to get the * socket factory. Otherwise, if property is false, will use all the other custom properties that * have been set to create a custom server socket factory. * * @return the server socket factory that has been created * * @throws IOException */ SocketFactory createSSLSocketFactory() throws IOException; /** * Will create a SSLSocketFactory. If the {@link #getUseSSLSocketFactory()} property is set to * true (which is the default), it will use SSLSocketFactory.getDefault() to get the * socket factory. Otherwise, if property is false, will use all the other custom properties that * have been set to create a custom server socket factory. The given custom factory will be used as the wrapper * around the factory created by this method and will be the factory returned. If it is null, one * will be created and returned. * * @param wrapper the wrapper that will contain the created factory - used so the caller can further customize * the factory and its sockets as desired (may be null) * * @return the server socket factory that has been created (may be wrapper if it was not null) * * @throws IOException */ SocketFactory createSSLSocketFactory( CustomSSLSocketFactory wrapper ) throws IOException; /** * Returns the SSL context that will create the server socket factories. This returns null until * the context is initialized. * * @return the SSL context or null if it hasn't been initialized yet */ SSLContext getServerSocketFactorySSLContext(); /** * Returns the SSL context that will create the socket factories. This returns null until the * context is initialized. * * @return the SSL context or null if it hasn't been initialized yet */ SSLContext getSocketFactorySSLContext(); /** * Returns the name of the secure socket protocol to be used by the sockets created by our factories. * * @return the secure socket protocol name (e.g. TLS) */ String getSecureSocketProtocol(); /** * Sets the name of the secure socket protocol to be used by the sockets created by our factories. * * @param protocol the secure socket protocol name (e.g. TLS) */ void setSecureSocketProtocol( String protocol ); /** * Returns the Cryptographic Service Provider which supplies a concrete implementation of a subset of the Java 2 * SDK Security API cryptography features. * * @return the provider (will be null if not specifically {@link #setProvider(Provider) set}) */ Provider getProvider(); /** * Sets the Cryptographic Service Provider which supplies a concrete implementation of a subset of the Java 2 * SDK Security API cryptography features. * * @param provider the provider this object's SSL context should use */ void setProvider( Provider provider ); /** * Returns the name of the Cryptographic Service Provider which refers to a package or set of packages that * supply a concrete implementation of a subset of the Java 2 SDK Security API cryptography features. * * @return identifies by name the provider this object's SSL context should use (will be null * if not specifically {@link #setProviderName(String) set} or found in the configuration) */ String getProviderName(); /** * Sets the name of the Cryptographic Service Provider which refers to a package or set of packages that supply * a concrete implementation of a subset of the Java 2 SDK Security API cryptography features. * * @param providerName identifies by name the provider this object's SSL context should use */ void setProviderName( String providerName ); /** * Returns the secure random used by this object's SSL context. If this object does not yet have a secure random * object, one is created here. * * @return the secure random object */ SecureRandom getSecureRandom(); /** * Provides this class with the SecureRandom object to use when initializing the SSL contexts. * * @param secureRandom */ void setSecureRandom( SecureRandom secureRandom ); /** * Returns the path to the key store as a URL. * * @return path to keystore */ URL getKeyStore(); /** * Returns the path to the key store as a String. * @return path to keystore */ String getKeyStoreURL(); /** * Sets the path to the keystore file. This can be relative to the classloader or can be an absolute path to * someplace on the file system or can be a URL string. If the path is not valid, a runtime exception is thrown. * * @param keyStoreFilePath */ void setKeyStoreURL( String keyStoreFilePath ); /** * Sets the path to the keystore file as a URL * @param keyStoreURL */ void setKeyStore(URL keyStoreURL); /** * Returns the keystore's file type. This is typically "JKS". * * @return keystore file type. */ String getKeyStoreType(); /** * Sets the keystore's file type. Typically this is "JKS". * * @param keyStoreType */ void setKeyStoreType( String keyStoreType ); /** * Returns the algorithm used to manage the keys in the keystore. * * @return the key management algorithm */ String getKeyStoreAlgorithm(); /** * Sets the algorithm used to manage the keys in the keystore. * * @param algorithm */ void setKeyStoreAlgorithm( String algorithm ); /** * Sets the password used to gain access to the keystore. * * @param keyStorePassword */ void setKeyStorePassword( String keyStorePassword ); /** * Gets the path to the truststore file. * * @return path to truststore */ URL getTrustStore(); /** * Gets the path to the truststore file. * * @return path to truststore */ String getTrustStoreURL(); /** * Sets the path to the truststore file. This can be relative to the classloader or can be an absolute path to * someplace on the file system or can be a URL string. If the path is not valid, a runtime exception is thrown. * * @param trustStoreFilePath path to truststore */ void setTrustStoreURL( String trustStoreFilePath ); /** * Sets the path to the truststore file. This can be relative to the classloader or can be an absolute path to * someplace on the file system or can be a URL string. If the path is not valid, a runtime exception is thrown. * * @param trustStore path to truststore */ void setTrustStore( URL trustStore ); /** * Gets the truststore's file type. Typically this is "JKS". If not set, the key store file type is used or the * default if that isn't set. * * @return the truststore file type */ String getTrustStoreType(); /** * Sets the truststore's file type. Typically this is "JKS". * * @param trustStoreType */ void setTrustStoreType( String trustStoreType ); /** * Returns the algorithm used to manage the keys in the truststore. * * @return the key management algorithm */ String getTrustStoreAlgorithm(); /** * Sets the algorithm used to manage the keys in the truststore. * * @param algorithm */ void setTrustStoreAlgorithm( String algorithm ); /** * Sets the password used to gain access to the truststore. * * @param trustStorePassword */ void setTrustStorePassword( String trustStorePassword ); /** * Returns the key alias used to identify the client's key in the keystore. * * @return the client key alias */ String getKeyAlias(); /** * Sets the key alias used to identify the client's key in the keystore. * * @param alias the client key alias */ void setKeyAlias( String alias ); /** * Sets the password to use for the keys within the key store. * * @param keyPassword */ void setKeyPassword( String keyPassword ); /** * Returns the flag to indicate if the sockets created by the factories should be in client mode. * * @return true if sockets should be in client mode */ boolean isSocketUseClientMode(); /** * Returns the flag to indicate if the server sockets created by the factories should be in client mode. * * @return true if sockets should be in client mode */ boolean isServerSocketUseClientMode(); /** * Sets the flag to indicate if the sockets created by the factories should be in client mode. * * @param useClientMode true if sockets should be in client mode */ void setSocketUseClientMode( boolean useClientMode ); /** * Sets the flag to indicate if the server sockets created by the factories should be in client mode. * * @param useClientMode true if sockets should be in client mode */ void setServerSocketUseClientMode( boolean useClientMode ); /** * Determines if there should be no client authentication. This is only used for sockets in * server mode (see SSLSocket.getUseClientMode). * * @return true if client authentication should be disabled. */ boolean isClientAuthModeNone(); /** * Determines if there should be client authentication but it isn't required. This is only used for sockets in * server mode (see SSLSocket.getUseClientMode). * * @return true if client authentication should be enabled but isn't required. */ boolean isClientAuthModeWant(); /** * Determines if there must be client authentication - it is required. This is only used for sockets in * server mode (see SSLSocket.getUseClientMode). * * @return true if client authentication is required */ boolean isClientAuthModeNeed(); /** * Returns the client authentication mode to say if sockets will not require client authentication, will want * client auth but not require it or to require it. This is only used for sockets in * server mode (see SSLSocket.getUseClientMode). * *

          If not set, {@link SSLSocketBuilder#CLIENT_AUTH_MODE_NONE} is returned.

          * * @return client auth mode * * @see SSLSocketBuilder#CLIENT_AUTH_MODE_NONE * @see SSLSocketBuilder#CLIENT_AUTH_MODE_WANT * @see SSLSocketBuilder#CLIENT_AUTH_MODE_NEED */ String getClientAuthMode(); /** * Sets the client authentication mode to say if sockets will not require client authentication, will want * client auth but not require it or to require it. This is only used for sockets in * server mode (see SSLSocket.getUseClientMode). * *

          If mode is invalid or null, will default to * {@link SSLSocketBuilder#CLIENT_AUTH_MODE_NONE}.

          * * @param mode client auth mode * * @see SSLSocketBuilder#CLIENT_AUTH_MODE_NONE * @see SSLSocketBuilder#CLIENT_AUTH_MODE_WANT * @see SSLSocketBuilder#CLIENT_AUTH_MODE_NEED */ void setClientAuthMode( String mode ); /** * Returns the server authentication mode to say if a client socket will require to authenticate a server certificate * as trustworthy. * * @return server auth mode */ boolean isServerAuthMode(); /** * Sets the server authentication mode to say if a client socket will require to authenticate a server certificate * as trustworthy. * * @param mode server auth mode */ void setServerAuthMode( boolean mode ); /** * Creates a clone. * * @return */ Object clone(); /** * No-op - just needed for MBean service API. * * @throws Exception */ void create() throws Exception; /** * No-op - just needed for MBean service API. Create already called at this point. * * @throws Exception */ void start() throws Exception; /** * No-op - just needed for MBean server API. */ void stop(); /** * No-op - just needed for MBean server API. */ void destroy(); }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/ServerSocketFactoryMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/ServerSocketFactoryMBean.0000644000175000017500000000611710355142433033365 0ustar twernertwerner/* * 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.remoting.security; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; /** * This interface is due to the constraint added by using JMX based configuration. * If want to inject a custom server socket factory (or the one provided by JBossRemoting), * it has to implement this interface. This is due to the fact that concrete objects can not * be injected at this point, only interfaces (and the java language ServerSocketFactory * class does not implement any interface). * * @author Tom Elrod */ public interface ServerSocketFactoryMBean { /** * Returns an unbound server socket. The socket is configured with the socket * options (such as accept timeout) given to this factory. * * @return * @throws IOException */ ServerSocket createServerSocket() throws IOException; /** * Returns a server socket bound to the specified port. The socket is configured * with the socket options (such as accept timeout) given to this factory. * * @param i * @return * @throws IOException */ ServerSocket createServerSocket(int i) throws IOException; /** * Returns a server socket bound to the specified port, * and uses the specified connection backlog. The socket is configured * with the socket options (such as accept timeout) given to this factory. * * @param i * @param i1 * @return * @throws IOException */ ServerSocket createServerSocket(int i, int i1) throws IOException; /** * Returns a server socket bound to the specified port, with a specified * listen backlog and local IP. The bindAddr argument can be used on a multi-homed * host for a ServerSocket that will only accept connect requests to one of its addresses. * The socket is configured with the socket options (such as accept timeout) given to this factory. * * @param i * @param i1 * @param inetAddress * @return * @throws IOException */ ServerSocket createServerSocket(int i, int i1, InetAddress inetAddress) throws IOException; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLSocketBuilder.java0000644000175000017500000014730411336370732032507 0ustar twernertwerner/* * 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.remoting.security; import org.jboss.logging.Logger; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.util.SecurityUtility; import org.jboss.remoting.util.socket.RemotingKeyManager; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLServerSocketFactory; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509KeyManager; import javax.net.ssl.X509TrustManager; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.security.AccessController; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.security.Provider; import java.security.SecureRandom; import java.security.UnrecoverableKeyException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Map; /** * A class that contains code that remoting factories need to build customized server and client SSL sockets. * * @author John Mazzitelli * @author Tom Elrod * * @version $Revision: 5689 $ */ public class SSLSocketBuilder implements SSLSocketBuilderMBean, Cloneable { /** * Constant defining the config property used to define the SSL provider to use. */ public static final String REMOTING_SSL_PROVIDER_NAME = "org.jboss.remoting.sslProviderName"; /** * Constant defining the config property used to define the SSL socket protocol to use. */ public static final String REMOTING_SSL_PROTOCOL = "org.jboss.remoting.sslProtocol"; /** * If the protocol isn't specified, this will be the default. * Value is "TLS". */ public static final String DEFAULT_SSL_PROTOCOL = "TLS"; /** * Constant defining the config property used to define if the sockets will be in * client or server mode. */ public static final String REMOTING_SOCKET_USE_CLIENT_MODE = "org.jboss.remoting.socket.useClientMode"; /** * Constant defining the config property used to define if the server sockets will be in * client or server mode. */ public static final String REMOTING_SERVER_SOCKET_USE_CLIENT_MODE = "org.jboss.remoting.serversocket.useClientMode"; /** * Constant defining the config property used to define if sockets need or want * client authentication. This configuration option is only useful for sockets in the server mode. * The value of such a property is one of the CLIENT_AUTH_MODE_XXX constants. */ public static final String REMOTING_CLIENT_AUTH_MODE = "org.jboss.remoting.clientAuthMode"; /** * Client auth mode that indicates client authentication will not be peformed. */ public static final String CLIENT_AUTH_MODE_NONE = "none"; /** * Client auth mode that indicates that we want client authentication but it isn't required. */ public static final String CLIENT_AUTH_MODE_WANT = "want"; /** * Client auth mode that indicates that client authentication is required. */ public static final String CLIENT_AUTH_MODE_NEED = "need"; /** * Constant defining the config property used to define if a client should attempt to * authenticate a server certificate as one it trusts. The value of such a property is * a boolean. */ public static final String REMOTING_SERVER_AUTH_MODE = "org.jboss.remoting.serverAuthMode"; /** * Constant defining the config property used to define where JBoss/Remoting will * look for the keystore file. This can be relative to the thread's * classloader or can be an absolute path on the file system or can be a URL. */ public static final String REMOTING_KEY_STORE_FILE_PATH = "org.jboss.remoting.keyStore"; /** * Constant defining the config property that defines the keystore's type. */ public static final String REMOTING_KEY_STORE_TYPE = "org.jboss.remoting.keyStoreType"; /** * Constant defining the config property that defines the key management algorithm * used by the keystore. */ public static final String REMOTING_KEY_STORE_ALGORITHM = "org.jboss.remoting.keyStoreAlgorithm"; /** * Constant defining the config property that defines the password of the keystore. */ public static final String REMOTING_KEY_STORE_PASSWORD = "org.jboss.remoting.keyStorePassword"; /** * Constant defining the config property that indicates the client's alias as found in the keystore. */ public static final String REMOTING_KEY_ALIAS = "org.jboss.remoting.keyAlias"; /** * Constant defining the config property that indicates the key password for the keys in the key store. */ public static final String REMOTING_KEY_PASSWORD = "org.jboss.remoting.keyPassword"; /** * Constant that defines the standard system property that the javax.net.ssl * classes look for when locating the keystore file. */ public static final String STANDARD_KEY_STORE_FILE_PATH = "javax.net.ssl.keyStore"; /** * Constant that defines the standard system property that the javax.net.ssl * classes look for when needing to know what type the keystore file is. */ public static final String STANDARD_KEY_STORE_TYPE = "javax.net.ssl.keyStoreType"; /** * Constant that defines the standard system property that the javax.net.ssl * classes look for when needing the keystore password. */ public static final String STANDARD_KEY_STORE_PASSWORD = "javax.net.ssl.keyStorePassword"; /** * Default key/trust store type if one not set as bean property, via config, or via system property. * Value is 'JKS'. */ public static final String DEFAULT_KEY_STORE_TYPE = "JKS"; /** * Default key/trust store algorithm if one net set as bean property or via config. * Value is 'SunX509'. */ public static final String DEFAULT_KEY_STORE_ALGORITHM = "SunX509"; /** * Constant defining the config property used to define where JBoss/Remoting * will look for the truststore file. This can be relative to the thread's * classloader or can be an absolute path on the file system. */ public static final String REMOTING_TRUST_STORE_FILE_PATH = "org.jboss.remoting.trustStore"; /** * Constant defining the config property that defines the truststore's type. */ public static final String REMOTING_TRUST_STORE_TYPE = "org.jboss.remoting.trustStoreType"; /** * Constant defining the config property that defines the key management * algorithm used by the truststore. */ public static final String REMOTING_TRUST_STORE_ALGORITHM = "org.jboss.remoting.trustStoreAlgorithm"; /** * Constant defining the config property that defines the password of the keystore. */ public static final String REMOTING_TRUST_STORE_PASSWORD = "org.jboss.remoting.trustStorePassword"; /** * Constant that defines the standard system property that the javax.net.ssl * classes look for when locating the truststore file. */ public static final String STANDARD_TRUST_STORE_FILE_PATH = "javax.net.ssl.trustStore"; /** * Constant that defines the standard system property that the javax.net.ssl * classes look for when needing to know what type the truststore file is. */ public static final String STANDARD_TRUST_STORE_TYPE = "javax.net.ssl.trustStoreType"; /** * Constant that defines the standard system property that the javax.net.ssl * classes look for when needing the truststore password. */ public static final String STANDARD_TRUST_STORE_PASSWORD = "javax.net.ssl.trustStorePassword"; /** * System property key to define the fully qualified class name of default socket factory to use * when not using custom config. */ public static final String REMOTING_DEFAULT_SOCKET_FACTORY_CLASS = "org.jboss.remoting.defaultSocketFactory"; public static final String NONE_STORE = "NONE"; private SSLContext sslContextServerSocketFactory = null; // context that builds the server socket factories private SSLContext sslContextSocketFactory = null; // context that builds the socket factories private Provider provider = null; private String providerName = null; private String secureSocketProtocol = null; private KeyManager[] keyManagers = null; private TrustManager[] trustManagers = null; private SecureRandom secureRandom = null; private URL keyStoreFilePath = null; private String keyStoreType = null; private String keyStoreAlgorithm = null; private String keyStorePassword = null; private String keyAlias = null; private String keyPassword = null; private URL trustStoreFilePath = null; private String trustStoreType = null; private String trustStoreAlgorithm = null; private String trustStorePassword = null; private Map config = null; private Boolean socketUseClientMode = null; private Boolean serverSocketUseClientMode = null; private String clientAuthMode = null; private Boolean serverAuthMode = null; private boolean useSSLServerSocketFactory = true; private boolean useSSLSocketFactory = true; private static final Logger log = Logger.getLogger(SSLSocketBuilder.class); private static URL NONE_STORE_URL; static { try { NONE_STORE_URL = new URL("file:NONE"); } catch (MalformedURLException e) { log.info("unexpected URL exception", e); } } /** * Constructor for {@link SSLSocketBuilder} that does not have * any configuration so it falls back to all defaults. */ public SSLSocketBuilder() { this(null); } /** * Constructor for {@link SSLSocketBuilder} that allows the caller to * override the default settings for the various SSL configuration * properties. * * @param config configuration with properties defining things like where the * keystore and truststore files are, their types, etc. */ public SSLSocketBuilder(Map config) { this.config = config; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setUseSSLServerSocketFactory(boolean) */ public void setUseSSLServerSocketFactory(boolean shouldUse) { this.useSSLServerSocketFactory = shouldUse; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getUseSSLServerSocketFactory() */ public boolean getUseSSLServerSocketFactory() { return useSSLServerSocketFactory; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setUseSSLSocketFactory(boolean) */ public void setUseSSLSocketFactory(boolean shouldUse) { this.useSSLSocketFactory = shouldUse; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getUseSSLSocketFactory() */ public boolean getUseSSLSocketFactory() { return useSSLSocketFactory; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#createSSLServerSocketFactory() */ public ServerSocketFactory createSSLServerSocketFactory() throws IOException { return createSSLServerSocketFactory( null ); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#createSSLServerSocketFactory(org.jboss.remoting.security.CustomSSLServerSocketFactory) */ public ServerSocketFactory createSSLServerSocketFactory(CustomSSLServerSocketFactory wrapper) throws IOException { ServerSocketFactory ssf = null; if( getUseSSLServerSocketFactory() ) { ssf = SSLServerSocketFactory.getDefault(); } else { if (wrapper == null) { wrapper = new CustomSSLServerSocketFactory(null, this); } ssf = createCustomServerSocketFactory(wrapper); } return ssf; } /** * This creates a fully custom SSL server socket factory using this object's configuration. * * @param wrapper the wrapper where the created factory will be stored * * @return the SSLServerSocketFactory * * @throws IOException */ protected ServerSocketFactory createCustomServerSocketFactory(CustomSSLServerSocketFactory wrapper) throws IOException { if (sslContextServerSocketFactory == null) { createServerSocketFactorySSLContext(); initializeServerSocketFactorySSLContext(); } ServerSocketFactory ssf = sslContextServerSocketFactory.getServerSocketFactory(); wrapper.setFactory((SSLServerSocketFactory) ssf); return wrapper; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#createSSLSocketFactory() */ public SocketFactory createSSLSocketFactory() throws IOException { return createSSLSocketFactory(null); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#createSSLSocketFactory(org.jboss.remoting.security.CustomSSLSocketFactory) */ public SocketFactory createSSLSocketFactory(CustomSSLSocketFactory wrapper) throws IOException { SocketFactory sf = null; if (getUseSSLSocketFactory()) { String defaultFactoryName = getSystemProperty(REMOTING_DEFAULT_SOCKET_FACTORY_CLASS); if (defaultFactoryName != null) { try { final Class sfClass = ClassLoaderUtility.loadClass(defaultFactoryName, SSLSocketBuilder.class); Method m = getMethod(sfClass, "getDefault", null); if (m == null) { throw new RuntimeException( "Could not create the socket factory " + defaultFactoryName + " because the class " + sfClass + " doesn't provide the getDefault method."); } sf = (SocketFactory) m.invoke(null, null); } catch (Exception ex) { throw new RuntimeException( "Could not create the socket factory " + defaultFactoryName, ex); } } if (sf == null) { sf = SSLSocketFactory.getDefault(); } } else { if (wrapper == null) { wrapper = new CustomSSLSocketFactory(null, this); } sf = createCustomSocketFactory(wrapper); } return sf; } /** * This creates a fully custom SSL socket factory using this object's configuration. * * @param wrapper the wrapper where the created factory will be stored * * @return the wrapper with the new factory stored in it * * @throws IOException */ protected SocketFactory createCustomSocketFactory(CustomSSLSocketFactory wrapper) throws IOException { if (sslContextSocketFactory == null) { createSocketFactorySSLContext(); initializeSocketFactorySSLContext(); } SocketFactory sf = sslContextSocketFactory.getSocketFactory(); wrapper.setFactory((SSLSocketFactory) sf); return wrapper; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getServerSocketFactorySSLContext() */ public SSLContext getServerSocketFactorySSLContext() { return sslContextServerSocketFactory; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSocketFactorySSLContext() */ public SSLContext getSocketFactorySSLContext() { return sslContextSocketFactory; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureSocketProtocol() */ public String getSecureSocketProtocol() { if (secureSocketProtocol == null) { if(config != null) { secureSocketProtocol = (String) config.get(REMOTING_SSL_PROTOCOL); } if (secureSocketProtocol == null) { secureSocketProtocol = DEFAULT_SSL_PROTOCOL; } } return secureSocketProtocol; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureSocketProtocol(String) */ public void setSecureSocketProtocol(String protocol) { if(protocol != null && protocol.length() > 0) { this.secureSocketProtocol = protocol; } else { throw new IllegalArgumentException("Can not set remoting socket factory with null protocol"); } } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getProvider() */ public Provider getProvider() { return provider; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setProvider(java.security.Provider) */ public void setProvider(Provider provider) { this.provider = provider; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getProviderName() */ public String getProviderName() { if (providerName == null) { if(config != null) { providerName = (String) config.get(REMOTING_SSL_PROVIDER_NAME); } } return providerName; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setProviderName(java.lang.String) */ public void setProviderName(String providerName) { this.providerName = providerName; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureRandom() */ public SecureRandom getSecureRandom() { if(secureRandom != null) { return secureRandom; } secureRandom = new SecureRandom(); return secureRandom; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureRandom(java.security.SecureRandom) */ public void setSecureRandom(SecureRandom secureRandom) { this.secureRandom = secureRandom; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreURL() */ public String getKeyStoreURL() { URL keyStore = getKeyStore(); if(keyStore != null) { return keyStore.toString(); } else { return null; } } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStore() */ public URL getKeyStore() { if(keyStoreFilePath != null) { return keyStoreFilePath; } if(config != null) { String path = (String) config.get(REMOTING_KEY_STORE_FILE_PATH); if(path != null && path.length() > 0) { setKeyStoreURL( path ); } } if(keyStoreFilePath == null) { String path = getSystemProperty(STANDARD_KEY_STORE_FILE_PATH);; if(path != null && path.length() > 0) { setKeyStoreURL( path ); } } return keyStoreFilePath; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreURL(java.lang.String) */ public void setKeyStoreURL(String keyStoreFilePath) { try { this.keyStoreFilePath = validateStoreURL(keyStoreFilePath); } catch (IOException e) { throw new RuntimeException( "Cannot validate the store URL: " + keyStoreFilePath , e ); } } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStore(java.net.URL) */ public void setKeyStore(URL keyStore) { this.keyStoreFilePath = keyStore; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreType() */ public String getKeyStoreType() { if(keyStoreType != null) { return keyStoreType; } if(config != null) { String type = (String)config.get(REMOTING_KEY_STORE_TYPE); if(type != null && type.length() > 0) { keyStoreType = type; } } if(keyStoreType == null) { keyStoreType = getSystemProperty(STANDARD_KEY_STORE_TYPE); if(keyStoreType == null) { keyStoreType = DEFAULT_KEY_STORE_TYPE; } } return keyStoreType; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreType(java.lang.String) */ public void setKeyStoreType(String keyStoreType) { this.keyStoreType = keyStoreType; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreAlgorithm() */ public String getKeyStoreAlgorithm() { if(keyStoreAlgorithm != null) { return keyStoreAlgorithm; } if(config != null) { String alg = (String)config.get(REMOTING_KEY_STORE_ALGORITHM); if(alg != null && alg.length() > 0) { keyStoreAlgorithm = alg; } } if(keyStoreAlgorithm == null) { keyStoreAlgorithm = DEFAULT_KEY_STORE_ALGORITHM; } return keyStoreAlgorithm; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreAlgorithm(java.lang.String) */ public void setKeyStoreAlgorithm(String algorithm) { this.keyStoreAlgorithm = algorithm; } /** * Returns the password used to gain access to the keystore. * * @return keystore password */ public String getKeyStorePassword() { if(keyStorePassword != null) { return keyStorePassword; } if(config != null) { String passwd = (String)config.get(REMOTING_KEY_STORE_PASSWORD); if(passwd != null && passwd.length() > 0) { keyStorePassword = passwd; } } if(keyStorePassword == null) { keyStorePassword = getSystemProperty(STANDARD_KEY_STORE_PASSWORD); } return keyStorePassword; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStorePassword(java.lang.String) */ public void setKeyStorePassword(String keyStorePassword) { this.keyStorePassword = keyStorePassword; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreURL() */ public String getTrustStoreURL() { URL trustStore = getTrustStore(); if(trustStore != null) { return trustStore.toString(); } else { return null; } } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStore() */ public URL getTrustStore() { if(trustStoreFilePath != null) { return trustStoreFilePath; } if(config != null) { String path = (String)config.get(REMOTING_TRUST_STORE_FILE_PATH); if(path != null && path.length() > 0) { setTrustStoreURL( path ); } } if(trustStoreFilePath == null) { String path = getSystemProperty(STANDARD_TRUST_STORE_FILE_PATH); if(path != null && path.length() > 0) { setTrustStoreURL( path ); } } return trustStoreFilePath; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStore(java.net.URL) */ public void setTrustStore(URL trustStore) { this.trustStoreFilePath = trustStore; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreURL(java.lang.String) */ public void setTrustStoreURL(String trustStoreFilePath) { try { this.trustStoreFilePath = validateStoreURL(trustStoreFilePath); } catch (IOException e) { throw new RuntimeException( "Cannot validate the store URL: " + trustStoreFilePath , e ); } } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreType() */ public String getTrustStoreType() { if(trustStoreType != null) { return trustStoreType; } if(config != null) { String type = (String)config.get(REMOTING_TRUST_STORE_TYPE); if(type != null && type.length() > 0) { trustStoreType = type; } } if(trustStoreType == null) { trustStoreType = getSystemProperty(STANDARD_TRUST_STORE_TYPE); if(trustStoreType == null) { trustStoreType = getKeyStoreType(); } } return trustStoreType; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreType(java.lang.String) */ public void setTrustStoreType(String trustStoreType) { this.trustStoreType = trustStoreType; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreAlgorithm() */ public String getTrustStoreAlgorithm() { if(trustStoreAlgorithm != null) { return trustStoreAlgorithm; } if(config != null) { String alg = (String)config.get(REMOTING_TRUST_STORE_ALGORITHM); if(alg != null && alg.length() > 0) { trustStoreAlgorithm = alg; } } if(trustStoreAlgorithm == null) { trustStoreAlgorithm = getKeyStoreAlgorithm(); } return trustStoreAlgorithm; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreAlgorithm(java.lang.String) */ public void setTrustStoreAlgorithm(String algorithm) { this.trustStoreAlgorithm = algorithm; } /** * Returns the password used to gain access to the truststore. * * @return truststore password */ public String getTrustStorePassword() { if(trustStorePassword != null) { return trustStorePassword; } if(config != null) { String passwd = (String)config.get(REMOTING_TRUST_STORE_PASSWORD); if(passwd != null && passwd.length() > 0) { trustStorePassword = passwd; } } if(trustStorePassword == null) { trustStorePassword = getSystemProperty(STANDARD_TRUST_STORE_PASSWORD); if(trustStorePassword == null) { trustStorePassword = getKeyStorePassword(); } } return trustStorePassword; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStorePassword(java.lang.String) */ public void setTrustStorePassword(String trustStorePassword) { this.trustStorePassword = trustStorePassword; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyAlias() */ public String getKeyAlias() { if(keyAlias != null) { return keyAlias; } if(config != null) { keyAlias = (String)config.get(REMOTING_KEY_ALIAS); } return keyAlias; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyAlias(java.lang.String) */ public void setKeyAlias(String alias) { this.keyAlias = alias; } /** * Returns the password to use for the keys within the key store. * If this value is not set, this will return null but * when this value is needed by this class, the value for the key store * password will be used instead. * * @return key password */ public String getKeyPassword() { if(keyPassword != null) { return keyPassword; } if(config != null) { String passwd = (String)config.get(REMOTING_KEY_PASSWORD); if(passwd != null && passwd.length() > 0) { keyPassword = passwd; } } return keyPassword; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyPassword(java.lang.String) */ public void setKeyPassword(String keyPassword) { this.keyPassword = keyPassword; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isSocketUseClientMode() */ public boolean isSocketUseClientMode( ) { if (socketUseClientMode == null) { if (config != null && config.containsKey(REMOTING_SOCKET_USE_CLIENT_MODE)) { socketUseClientMode = Boolean.valueOf((String) config.get(REMOTING_SOCKET_USE_CLIENT_MODE)); } else { socketUseClientMode = Boolean.TRUE; } } return socketUseClientMode.booleanValue(); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isServerSocketUseClientMode() */ public boolean isServerSocketUseClientMode( ) { if (serverSocketUseClientMode == null) { if (config != null && config.containsKey(REMOTING_SERVER_SOCKET_USE_CLIENT_MODE)) { serverSocketUseClientMode = Boolean.valueOf((String) config.get(REMOTING_SERVER_SOCKET_USE_CLIENT_MODE)); } else { serverSocketUseClientMode = Boolean.FALSE; } } return serverSocketUseClientMode.booleanValue(); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setSocketUseClientMode(boolean) */ public void setSocketUseClientMode( boolean useClientMode ) { this.socketUseClientMode = Boolean.valueOf(useClientMode); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setServerSocketUseClientMode(boolean) */ public void setServerSocketUseClientMode( boolean useClientMode ) { this.serverSocketUseClientMode = Boolean.valueOf(useClientMode); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isClientAuthModeNone() */ public boolean isClientAuthModeNone() { return CLIENT_AUTH_MODE_NONE.equals(getClientAuthMode()); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isClientAuthModeWant() */ public boolean isClientAuthModeWant() { return CLIENT_AUTH_MODE_WANT.equals(getClientAuthMode()); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isClientAuthModeNeed() */ public boolean isClientAuthModeNeed() { return CLIENT_AUTH_MODE_NEED.equals(getClientAuthMode()); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#getClientAuthMode() */ public String getClientAuthMode() { if (clientAuthMode == null) { if (config != null && config.containsKey(REMOTING_CLIENT_AUTH_MODE)) { setClientAuthMode( (String) config.get(REMOTING_CLIENT_AUTH_MODE) ); } else { clientAuthMode = CLIENT_AUTH_MODE_NONE; } } return clientAuthMode; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setClientAuthMode(java.lang.String) */ public void setClientAuthMode(String mode) { if ( mode == null || (!mode.equalsIgnoreCase(CLIENT_AUTH_MODE_NONE) && !mode.equalsIgnoreCase(CLIENT_AUTH_MODE_WANT) && !mode.equalsIgnoreCase(CLIENT_AUTH_MODE_NEED))) { log.warn("Client authentication mode is invalid [" + mode + "]; falling back to NEED mode"); clientAuthMode = CLIENT_AUTH_MODE_NEED; } else { clientAuthMode = mode; } return; } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#isServerAuthMode() */ public boolean isServerAuthMode() { if (serverAuthMode == null) { if (config != null && config.containsKey(REMOTING_SERVER_AUTH_MODE)) { serverAuthMode = Boolean.valueOf( (String) config.get(REMOTING_SERVER_AUTH_MODE) ); } else { serverAuthMode = Boolean.TRUE; } } return serverAuthMode.booleanValue(); } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#setServerAuthMode(boolean) */ public void setServerAuthMode(boolean mode) { serverAuthMode = Boolean.valueOf(mode); } /** * Creates (but does not initialize) the SSL context used by this object * to create server socket factories. * The provider/protocol is used to determine what SSL context to use. * Call {@link #initializeServerSocketFactorySSLContext()} if you want * to create and initialize in one method call. * If the server socket factory SSL context was already created, this will create * a new one and remove the old one. * * @throws IOException */ protected void createServerSocketFactorySSLContext() throws IOException { try { if(getProvider() != null) { sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProvider()); } else if(getProviderName() != null) { sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProviderName()); } else { sslContextServerSocketFactory = SSLContext.getInstance(getSecureSocketProtocol()); } } catch(Exception e) { IOException ioe = new IOException("Error creating server socket factory SSL context: " + e.getMessage()); ioe.setStackTrace(e.getStackTrace()); throw ioe; } return; } /** * Creates (but does not initialize) the SSL context used by this object * to create socket factories. * The provider/protocol is used to determine what SSL context to use. * Call {@link #initializeSocketFactorySSLContext()} if you want * to create and initialize in one method call. * If the socket factory SSL context was already created, this will create * a new one and remove the old one. * * @throws IOException */ protected void createSocketFactorySSLContext() throws IOException { try { if(getProvider() != null) { sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProvider()); } else if(getProviderName() != null) { sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol(), getProviderName()); } else { sslContextSocketFactory = SSLContext.getInstance(getSecureSocketProtocol()); } } catch(Exception e) { IOException ioe = new IOException("Error creating socket factory SSL context: " + e.getMessage()); ioe.setStackTrace(e.getStackTrace()); throw ioe; } return; } /** * Initializes the SSL context used by this object that will create the server socket factories. * If the SSL context is not yet created, this method will also create it. * The provider/protocol is used to determine what SSL context to use. Key and trust managers * are loaded and a secure random object is created and the SSL context for the * protocol/provider is initialized with them. * * @throws IOException */ protected void initializeServerSocketFactorySSLContext() throws IOException { try { if (sslContextServerSocketFactory == null) { createServerSocketFactorySSLContext(); } try { keyManagers = loadKeyManagers(); } catch (NullStoreURLException e) { if (isServerSocketUseClientMode()) { keyManagers = null; log.debug("Could not find keytore url. " + e.getMessage()); } else { // because this ssl context will create server socket factories, will throw if can not find keystore IOException ioe = new IOException("Can not find keystore url."); ioe.initCause(e); throw ioe; } } try { boolean isClientMode = isServerSocketUseClientMode(); trustManagers = loadTrustManagers(isClientMode); } catch (NullStoreURLException e) { trustManagers = null; log.debug("Could not find truststore url. " + e.getMessage()); } secureRandom = getSecureRandom(); sslContextServerSocketFactory.init(keyManagers, trustManagers, secureRandom); } catch(Exception e) { IOException ioe = new IOException("Error initializing server socket factory SSL context: " + e.getMessage()); ioe.setStackTrace(e.getStackTrace()); throw ioe; } return; } /** * Initializes the SSL context used by this object that will create the socket factories. * If the SSL context is not yet created, this method will also create it. * The provider/protocol is used to determine what SSL context to use. Key and trust managers * are loaded and a secure random object is created and the SSL context for the * protocol/provider is initialized with them. * * @throws IOException */ protected void initializeSocketFactorySSLContext() throws IOException { try { if (sslContextSocketFactory == null) { createSocketFactorySSLContext(); } try { keyManagers = loadKeyManagers(); } catch (NullStoreURLException e) { if (isSocketUseClientMode()) { // this is allowable since would be the normal scenario keyManagers = null; log.debug("Could not find keystore url. " + e.getMessage()); } else { IOException ioe = new IOException("Can not find keystore url."); ioe.initCause(e); throw ioe; } } try { boolean isClientMode = isSocketUseClientMode(); trustManagers = loadTrustManagers(isClientMode); } catch (NullStoreURLException e) { // If the keyManagers is not null, could possibly be using in client mode // so want to allow it. Otherwise, need to throw exception as will not be able // to use in client mode or not if(keyManagers != null) { trustManagers = null; log.debug("Could not find truststore url. " + e.getMessage()); } else { IOException ioe = new IOException("Can not find truststore url."); ioe.initCause(e); throw ioe; } } secureRandom = getSecureRandom(); sslContextSocketFactory.init(keyManagers, trustManagers, secureRandom); } catch(Exception e) { IOException ioe = new IOException("Error initializing socket factory SSL context: " + e.getMessage()); ioe.setStackTrace(e.getStackTrace()); throw ioe; } return; } /** * Loads the trust managers based on this object's truststore. * * @return array of trust managers that should be loaded in this object's SSL context * * @throws NoSuchProviderException * @throws NoSuchAlgorithmException * @throws IOException * @throws CertificateException * @throws KeyStoreException * @throws NullStoreURLException */ protected TrustManager[] loadTrustManagers(boolean isClientMode) throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException, KeyStoreException, NullStoreURLException { if(isClientMode && !isServerAuthMode()) { // we are in client mode and do not want to perform server cert authentication // return a trust manager that trusts all certs trustManagers = new TrustManager[] { new X509TrustManager() { public void checkClientTrusted( X509Certificate[] chain, String authType ) {} public void checkServerTrusted( X509Certificate[] chain, String authType ) {} public X509Certificate[] getAcceptedIssuers() { return null; } }}; } else { String tsType = getTrustStoreType(); String tsPasswd = getTrustStorePassword(); URL tsPathURL = getTrustStore(); String tsAlg = getTrustStoreAlgorithm(); TrustManagerFactory trustMgrFactory; KeyStore trustStore = loadKeyStore(tsType, tsPathURL, tsPasswd); if (getProvider() != null) { trustMgrFactory = TrustManagerFactory.getInstance(tsAlg, getProvider()); } else if (getProviderName() != null) { trustMgrFactory = TrustManagerFactory.getInstance(tsAlg, getProviderName()); } else { trustMgrFactory = TrustManagerFactory.getInstance(tsAlg); } if (trustStore != null) { trustMgrFactory.init(trustStore); trustManagers = trustMgrFactory.getTrustManagers(); } } return trustManagers; } /** * Loads the key managers based on this object's truststore. * * @return array of key managers that should be loaded in this object's SSL context * * @throws NoSuchProviderException * @throws NoSuchAlgorithmException * @throws IOException * @throws CertificateException * @throws KeyStoreException * @throws UnrecoverableKeyException * @throws NullStoreURLException */ protected KeyManager[] loadKeyManagers() throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException, KeyStoreException, UnrecoverableKeyException, NullStoreURLException { String ksPasswd = getKeyStorePassword(); String ksType = getKeyStoreType(); URL ksPathURL = getKeyStore(); KeyStore keyStore = loadKeyStore(ksType, ksPathURL, ksPasswd); if(keyStore != null) { String alias = getKeyAlias(); // check that keystore contains supplied alias (if there is one) if(alias != null) { boolean containsAlias = keyStore.isKeyEntry(alias); if(!containsAlias) { // can not continue as supplied alias does not exist as key entry throw new IOException("Can not find key entry for key store (" + ksPathURL + ") with given alias (" + alias + ")"); } } KeyManagerFactory keyMgrFactory = null; String alg = getKeyStoreAlgorithm(); if(getProvider() != null) { keyMgrFactory = KeyManagerFactory.getInstance(alg, getProvider()); } else if(getProviderName() != null) { keyMgrFactory = KeyManagerFactory.getInstance(alg, getProviderName()); } else { keyMgrFactory = KeyManagerFactory.getInstance(alg); } // get they key password, if it isn't defined, use the key store password String keyPasswd = getKeyPassword(); if (keyPasswd == null || keyPasswd.length() == 0) { keyPasswd = ksPasswd; } char[] keyPasswdCharArray = keyPasswd == null ? null : keyPasswd.toCharArray(); keyMgrFactory.init(keyStore, keyPasswdCharArray); keyManagers = keyMgrFactory.getKeyManagers(); // if alias provided, use helper impl to hard wire alias name to be used if(alias != null) { //TODO: -TME Need careful review of if this is really needed or not. for(int x = 0; x < keyManagers.length; x++) { keyManagers[x] = new RemotingKeyManager((X509KeyManager)keyManagers[x], alias); } } } return keyManagers; } /** * Loads a key store file and returns it. * * @param storeType the type of store file * @param storePathURL the URL to the file - may be relative to the current thread's classloader * or may be absolute path to a file on the file system. * @param storePassword password to gain access to the store file * * @return the key store * * @throws KeyStoreException * @throws NoSuchProviderException * @throws IOException * @throws NoSuchAlgorithmException * @throws CertificateException * @throws NullStoreURLException */ protected KeyStore loadKeyStore(String storeType, URL storePathURL, String storePassword) throws KeyStoreException, NoSuchProviderException, IOException, NoSuchAlgorithmException, CertificateException, NullStoreURLException { KeyStore keyStore = null; if(getProvider() != null) { keyStore = KeyStore.getInstance(storeType, getProvider()); } else if(getProviderName() != null) { keyStore = KeyStore.getInstance(storeType, getProviderName()); } else { keyStore = KeyStore.getInstance(storeType); } if ( storePathURL == null ) { throw new NullStoreURLException("Can not find store file for url because store url is null."); } URL url = storePathURL == NONE_STORE_URL ? null : storePathURL; // now that keystore instance created, need to load data from file InputStream keyStoreInputStream = null; try { if (url != null) { keyStoreInputStream = url.openStream(); } // is ok for password to be null, as will just be used to check integrity of store char[] password = storePassword != null ? storePassword.toCharArray() : null; keyStore.load(keyStoreInputStream, password); } finally { if(keyStoreInputStream != null) { try { keyStoreInputStream.close(); } catch(IOException e) { // no op } keyStoreInputStream = null; } } return keyStore; } /** * Given a store file path, this will verify that the store actually exists. * First, it checks to see if its a valid URL, then it checks to see if the * file path is found in the file system and finally will be checked to see * if it can be found as a resource within the current thread's classloader. * An exception is thrown if the store cannot be found. * * @param storePath the path which can be a URL, path to a resource in classloader * or a file path on the file system. * * @return the URL of the file that was found * * @throws IOException if the store could not be found */ protected URL validateStoreURL(String storePath) throws IOException { if (NONE_STORE.equals(storePath)) { return NONE_STORE_URL; } URL url = null; // First see if this is a URL try { url = new URL(storePath); } catch(MalformedURLException e) { // Not a URL or a protocol without a handler so... // next try to locate this as file path final File tst = new File(storePath); Boolean exists = (Boolean) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(tst.exists()); } }); if(exists.booleanValue()) { url = tst.toURL(); } else { // not a file either, lastly try to locate this as a classpath resource if(url == null) { ClassLoader loader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); url = loader.getResource(storePath); } } } // Fail if no valid key store was located if(url == null) { String msg = "Failed to find url=" + storePath + " as a URL, file or resource"; throw new MalformedURLException(msg); } return url; } public Object clone() { try { return super.clone(); } catch (CloneNotSupportedException e) { return null; } } //******************************************************************* // START // The following are just needed in order to make it a service mbean. // They are just NOOPs (no implementation). //******************************************************************* /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#create() */ public void create() throws Exception { return; // no-op } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#start() */ public void start() throws Exception { return; // no-op } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#stop() */ public void stop() { return; // no-op } /** * @see org.jboss.remoting.security.SSLSocketBuilderMBean#destroy() */ public void destroy() { return; // no-op } //******************************************************************* // END //******************************************************************* /** * Used to indicate a store URL was not specified and thus the store is not available. */ protected class NullStoreURLException extends Exception { private static final long serialVersionUID = 1L; /** * @see Exception#Exception(String) */ public NullStoreURLException(String message) { super(message); } } static private String getSystemProperty(final String name) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private Method getMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { return c.getMethod(name, parameterTypes); } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { return c.getMethod(name, parameterTypes); } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/CustomSSLSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/CustomSSLSocketFactory.ja0000644000175000017500000001412210437330157033361 0ustar twernertwerner/* * JBoss, Home of Professional Open Source */ package org.jboss.remoting.security; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; /** * SSL socket factory whose configuration is customized. * * @author John Mazzitelli * @version $Revision: 1099 $ */ public class CustomSSLSocketFactory extends SSLSocketFactory { private SSLSocketFactory theDelegate; private SSLSocketBuilderMBean theBuilder; /** * Constructor for {@link CustomSSLSocketFactory}. The factory can be null - call * {@link #setFactory(SSLSocketFactory)} to set it later. * * @param factory the true factory this class delegates to * @param builder the class that built this custom factory - contains all the configuration for this factory */ public CustomSSLSocketFactory( SSLSocketFactory factory, SSLSocketBuilder builder ) { super(); theBuilder = builder; theDelegate = factory; } public CustomSSLSocketFactory() { } /** * Sets the builder that created the factory. * @param sslSocketBuilder */ public void setSSLSocketBuilder(SSLSocketBuilderMBean sslSocketBuilder) { this.theBuilder = sslSocketBuilder; } /** * Returns the builder that created this factory. You can obtain the configuration of this factory * by examining the returned object's configuration. * * @return the builder */ public SSLSocketBuilderMBean getSSLSocketBuilder() { return theBuilder; } /** * Sets a new factory in this object - this is the factory that this object will use to create new sockets. * * @param factory the new factory * * @throws IllegalArgumentException if factory is null */ public void setFactory( SSLSocketFactory factory ) { if ( factory == null ) { throw new IllegalArgumentException( "Factory cannot be null" ); } theDelegate = factory; } /** * @see javax.net.ssl.SSLSocketFactory#createSocket(java.net.Socket, java.lang.String, int, boolean) */ public Socket createSocket( Socket s, String host, int port, boolean autoClose ) throws IOException { SSLSocket sock = (SSLSocket) theDelegate.createSocket( s, host, port, autoClose ); setSocketModes( sock ); return sock; } /** * @see javax.net.SocketFactory#createSocket() */ public Socket createSocket() throws IOException { SSLSocket sock = (SSLSocket) theDelegate.createSocket(); setSocketModes( sock ); return sock; } /** * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int, java.net.InetAddress, int) */ public Socket createSocket( InetAddress address, int port, InetAddress localAddress, int localPort ) throws IOException { SSLSocket sock = (SSLSocket) theDelegate.createSocket( address, port, localAddress, localPort ); setSocketModes( sock ); return sock; } /** * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int) */ public Socket createSocket( InetAddress host, int port ) throws IOException { SSLSocket sock = (SSLSocket) theDelegate.createSocket( host, port ); setSocketModes( sock ); return sock; } /** * @see javax.net.SocketFactory#createSocket(java.lang.String, int, java.net.InetAddress, int) */ public Socket createSocket( String host, int port, InetAddress localHost, int localPort ) throws IOException, UnknownHostException { SSLSocket sock = (SSLSocket) theDelegate.createSocket( host, port, localHost, localPort ); setSocketModes( sock ); return sock; } /** * @see javax.net.SocketFactory#createSocket(java.lang.String, int) */ public Socket createSocket( String host, int port ) throws IOException, UnknownHostException { SSLSocket sock = (SSLSocket) theDelegate.createSocket( host, port ); setSocketModes( sock ); return sock; } /** * @see javax.net.ssl.SSLSocketFactory#getDefaultCipherSuites() */ public String[] getDefaultCipherSuites() { return theDelegate.getDefaultCipherSuites(); } /** * @see javax.net.ssl.SSLSocketFactory#getSupportedCipherSuites() */ public String[] getSupportedCipherSuites() { return theDelegate.getSupportedCipherSuites(); } /** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals( Object obj ) { return theDelegate.equals( obj ); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return theDelegate.hashCode(); } /** * @see java.lang.Object#toString() */ public String toString() { return theDelegate.toString(); } /** * Sets the socket modes according to the custom configuration. * * @param sock the socket whose modes are to be set */ private void setSocketModes( SSLSocket sock ) { if ( theBuilder != null ) { sock.setUseClientMode( theBuilder.isSocketUseClientMode() ); if ( theBuilder.isClientAuthModeWant() ) { sock.setNeedClientAuth( false ); sock.setWantClientAuth( true ); } else if ( theBuilder.isClientAuthModeNeed() ) { sock.setWantClientAuth( false ); sock.setNeedClientAuth( true ); } else { sock.setWantClientAuth( false ); sock.setNeedClientAuth( false ); } } return; } }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/ServerSocketFactoryWrappe0000644000175000017500000001214611171061255033561 0ustar twernertwerner/* * 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.remoting.security; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javax.net.ServerSocketFactory; import org.jboss.remoting.util.SecurityUtility; /** * @author Tom Elrod */ public class ServerSocketFactoryWrapper extends ServerSocketFactory { private ServerSocketFactoryMBean serverSocketFactory = null; public ServerSocketFactoryWrapper(ServerSocketFactoryMBean serverSocketFactory) { this.serverSocketFactory = serverSocketFactory; } public ServerSocket createServerSocket(final int i) throws IOException { return createServerSocket(serverSocketFactory, i); } public ServerSocket createServerSocket(final int i, final int i1) throws IOException { return createServerSocket(serverSocketFactory, i, i1); } public ServerSocket createServerSocket(final int i, final int i1, final InetAddress inetAddress) throws IOException { return createServerSocket(serverSocketFactory, i, i1, inetAddress); } public ServerSocket createServerSocket() throws IOException { return createServerSocket(serverSocketFactory); } public ServerSocketFactoryMBean getDelegate() { return serverSocketFactory; } static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf) throws IOException { if (SecurityUtility.skipAccessControl()) { return ssf.createServerSocket(); } try { return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return ssf.createServerSocket(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf, final int port) throws IOException { if (SecurityUtility.skipAccessControl()) { return ssf.createServerSocket(port); } try { return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return ssf.createServerSocket(port); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf, final int port, final int backlog) throws IOException { if (SecurityUtility.skipAccessControl()) { return ssf.createServerSocket(port, backlog); } try { return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return ssf.createServerSocket(port, backlog); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf, final int port, final int backlog, final InetAddress inetAddress) throws IOException { if (SecurityUtility.skipAccessControl()) { return ssf.createServerSocket(port, backlog, inetAddress); } try { return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return ssf.createServerSocket(port, backlog, inetAddress); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLServerSocketFactoryServiceMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLServerSocketFactorySer0000644000175000017500000000315510435240455033441 0ustar twernertwerner/* * 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.remoting.security; /** * @author Tom Elrod */ public interface SSLServerSocketFactoryServiceMBean extends ServerSocketFactoryMBean { /** * create the service, do expensive operations etc */ void create() throws Exception; /** * start the service, create is already called */ void start() throws Exception; /** * stop the service */ void stop(); /** * destroy the service, tear down */ void destroy(); void setSSLSocketBuilder(SSLSocketBuilderMBean sslSocketBuilder); SSLSocketBuilderMBean getSSLSocketBuilder(); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLServerSocketFactoryService.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLServerSocketFactorySer0000644000175000017500000000615310437330157033443 0ustar twernertwerner/* * 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.remoting.security; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLServerSocketFactory; /** * This is a basic wrapper around the SSLSocketBuilder which is needed * because it extneds the javax.net.ServerSocketFactory class and * implements the SSLServerSocketFactoryServiceMBean. It has no other function. * * @author Tom Elrod */ public class SSLServerSocketFactoryService extends CustomSSLServerSocketFactory implements SSLServerSocketFactoryServiceMBean { public SSLServerSocketFactoryService() { super(); } /** * Constructor for {@link CustomSSLServerSocketFactory}. The factory can be null - call * {@link #setFactory(javax.net.ssl.SSLServerSocketFactory)} to set it later. * * @param factory the true factory this class delegates to * @param builder the class that built this custom factory - contains all the configuration for this factory */ public SSLServerSocketFactoryService(SSLServerSocketFactory factory, SSLSocketBuilderMBean builder) { super(factory, builder); } /** * start the service, create is already called */ public void start() throws Exception { if(getSSLSocketBuilder() != null) { ServerSocketFactory svrSocketFactory = getSSLSocketBuilder().createSSLServerSocketFactory(); if(svrSocketFactory instanceof SSLServerSocketFactory) { setFactory(((SSLServerSocketFactory)svrSocketFactory)); } else { throw new Exception("Can not start server socket factory service as server socket factory produces is not SSL based."); } } else { throw new Exception("Can not create server socket factory due to the SSLSocketBuilder not being set."); } } /** * create the service, do expensive operations etc */ public void create() throws Exception { //NOOP } /** * stop the service */ public void stop() { //NOOP } /** * destroy the service, tear down */ public void destroy() { //NOOP } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLSocketFactoryService.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLSocketFactoryService.j0000644000175000017500000000403310437330157033346 0ustar twernertwernerpackage org.jboss.remoting.security; import javax.net.SocketFactory; import javax.net.ssl.SSLSocketFactory; /** * This is a basic wrapper around the SSLSocketBuilder which is needed * because it extneds the javax.net.ServerSocketFactory class and * implements the SSLServerSocketFactoryServiceMBean. It has no other function. * * @author Tom Elrod */ public class SSLSocketFactoryService extends CustomSSLSocketFactory implements SSLSocketFactoryServiceMBean { public SSLSocketFactoryService() { super(); } /** * Constructor for {@link CustomSSLSocketFactory}. The factory can be null - call * {@link #setFactory(javax.net.ssl.SSLSocketFactory)} to set it later. * * @param factory the true factory this class delegates to * @param builder the class that built this custom factory - contains all the configuration for this factory */ public SSLSocketFactoryService(SSLSocketFactory factory, SSLSocketBuilder builder) { super(factory, builder); } /** * start the service, create is already called */ public void start() throws Exception { if(getSSLSocketBuilder() != null) { SocketFactory socketFactory = getSSLSocketBuilder().createSSLSocketFactory(); if(socketFactory instanceof SSLSocketFactory) { setFactory((SSLSocketFactory)socketFactory); } else { throw new Exception("Can not start SSLSocketFactoryService because socket factory produced does not support SSL."); } } else { throw new Exception("Can not create socket factory due to the SSLSocketBuilder not being set."); } } /** * create the service, do expensive operations etc */ public void create() throws Exception { //NOOP } /** * stop the service */ public void stop() { //NOOP } /** * destroy the service, tear down */ public void destroy() { //NOOP } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/CustomSSLServerSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/CustomSSLServerSocketFact0000644000175000017500000001411610774602552033435 0ustar twernertwerner/* * JBoss, Home of Professional Open Source */ package org.jboss.remoting.security; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.security.AccessController; import java.security.PrivilegedAction; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; /** * SSL server socket factory whose configuration is customized. * * @author John Mazzitelli * @version $Revision: 3839 $ */ public class CustomSSLServerSocketFactory extends SSLServerSocketFactory { private SSLServerSocketFactory theDelegate; private SSLSocketBuilderMBean theBuilder; /** * Constructor for {@link CustomSSLServerSocketFactory}. The factory can be null - call * {@link #setFactory(SSLServerSocketFactory)} to set it later. * * @param factory the true factory this class delegates to * @param builder the class that built this custom factory - contains all the configuration for this factory */ public CustomSSLServerSocketFactory( SSLServerSocketFactory factory, SSLSocketBuilderMBean builder ) { super(); theBuilder = builder; theDelegate = factory; } public CustomSSLServerSocketFactory() { } /** * Sets the builder that creates the true socket server factory. * @param sslSocketBuilder */ public void setSSLSocketBuilder(SSLSocketBuilderMBean sslSocketBuilder) { this.theBuilder = sslSocketBuilder; } /** * Returns the builder that created this factory. You can obtain the configuration of this factory * by examining the returned object's configuration. * * @return the builder */ public SSLSocketBuilderMBean getSSLSocketBuilder() { return theBuilder; } /** * Sets a new factory in this object - this is the factory that this object will use to create new sockets. * * @param factory the new factory * * @throws IllegalArgumentException if factory is null */ public void setFactory( SSLServerSocketFactory factory ) { if ( factory == null ) { throw new IllegalArgumentException( "Factory cannot be null" ); } theDelegate = factory; } /** * @see javax.net.ServerSocketFactory#createServerSocket() */ public ServerSocket createServerSocket() throws IOException { SSLServerSocket sock = (SSLServerSocket) theDelegate.createServerSocket(); setSocketModes( sock ); return sock; } /** * @see javax.net.ServerSocketFactory#createServerSocket(int) */ public ServerSocket createServerSocket( int port ) throws IOException { SSLServerSocket sock = (SSLServerSocket) theDelegate.createServerSocket( port ); setSocketModes( sock ); return sock; } /** * @see javax.net.ServerSocketFactory#createServerSocket(int, int) */ public ServerSocket createServerSocket( int port, int backlog ) throws IOException { SSLServerSocket sock = (SSLServerSocket) theDelegate.createServerSocket( port, backlog ); setSocketModes( sock ); return sock; } /** * @see javax.net.ServerSocketFactory#createServerSocket(int, int, java.net.InetAddress) */ public ServerSocket createServerSocket( int port, int backlog, InetAddress ifAddress ) throws IOException { SSLServerSocket sock = (SSLServerSocket) theDelegate.createServerSocket( port, backlog, ifAddress ); setSocketModes( sock ); return sock; } /** * @see javax.net.ssl.SSLServerSocketFactory#getDefaultCipherSuites() */ public String[] getDefaultCipherSuites() { return theDelegate.getDefaultCipherSuites(); } /** * @see javax.net.ssl.SSLServerSocketFactory#getSupportedCipherSuites() */ public String[] getSupportedCipherSuites() { return theDelegate.getSupportedCipherSuites(); } /** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals( Object obj ) { return theDelegate.equals( obj ); } /** * @see java.lang.Object#hashCode() */ public int hashCode() { return theDelegate.hashCode(); } /** * @see java.lang.Object#toString() */ public String toString() { return theDelegate.toString(); } /** * Sets the socket modes according to the custom configuration. * * @param sock the socket whose modes are to be set */ private void setSocketModes( SSLServerSocket sock ) { if ( theBuilder != null ) { boolean isServerSocketUseClientMode = ((Boolean)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(theBuilder.isServerSocketUseClientMode()); } })).booleanValue(); boolean isClientAuthModeWant = ((Boolean)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(theBuilder.isClientAuthModeWant()); } })).booleanValue(); boolean isClientAuthModeNeed = ((Boolean)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(theBuilder.isClientAuthModeNeed()); } })).booleanValue(); sock.setUseClientMode( isServerSocketUseClientMode ); if ( isClientAuthModeWant ) { sock.setNeedClientAuth( false ); sock.setWantClientAuth( true ); } else if ( isClientAuthModeNeed ) { sock.setWantClientAuth( false ); sock.setNeedClientAuth( true ); } else { sock.setWantClientAuth( false ); sock.setNeedClientAuth( false ); } } return; } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLSocketFactoryServiceMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SSLSocketFactoryServiceMB0000644000175000017500000000111510437330157033333 0ustar twernertwernerpackage org.jboss.remoting.security; /** * @author Tom Elrod */ public interface SSLSocketFactoryServiceMBean extends SocketFactoryMBean { /** * create the service, do expensive operations etc */ void create() throws Exception; /** * start the service, create is already called */ void start() throws Exception; /** * stop the service */ void stop(); /** * destroy the service, tear down */ void destroy(); void setSSLSocketBuilder(SSLSocketBuilderMBean sslSocketBuilder); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/security/SocketFactoryMBean.java0000644000175000017500000000132510437330157033037 0ustar twernertwernerpackage org.jboss.remoting.security; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; /** * @author Tom Elrod */ public interface SocketFactoryMBean { public Socket createSocket(String host, int port) throws IOException, UnknownHostException; public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException, UnknownHostException; public Socket createSocket(InetAddress host, int port) throws IOException; public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/Home.java0000644000175000017500000000345111413660476026404 0ustar twernertwerner /* * 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.remoting; import java.io.Serializable; /** * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jan 6, 2008 *

          */ public class Home implements Serializable { /** The serialVersionUID */ private static final long serialVersionUID = 8267821565540095027L; public String host; public int port; public Home(String host, int port) { this.host = host; this.port = port; } public String toString() { return host + ":" + port; } public boolean equals(Object o) { if (o == null || !(o instanceof Home)) return false; Home h = (Home) o; return host.equals(h.host) && port == h.port; } public int hashCode() { return host.hashCode() * port; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/InvokerRegistry.java0000644000175000017500000006456211413670341030664 0ustar twernertwerner/* * 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.remoting; import org.jboss.logging.Logger; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.local.LocalClientInvoker; import org.jboss.remoting.util.SecurityUtility; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; /** * InvokerRegistry is a simple registery for creating client and server side Invoker implementations, * getting information about the invokers and register as a invoker creator for one or more specific * transports. * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5886 $ */ public class InvokerRegistry { private static final Logger log = Logger.getLogger(InvokerRegistry.class); private static boolean trace = log.isTraceEnabled(); private static final Map clientLocators = new HashMap(); private static final Map serverLocators = new HashMap(); private static final Set registeredLocators = new HashSet(); private static final Object serverLock = new Object(); private static final Object clientLock = new Object(); private static final Map transportClientFactoryClasses = new HashMap(); private static final Map transportServerFactoryClasses = new HashMap(); private static final RuntimePermission INVOKER_REGISTRY_UPDATE_PERMISSION = new RuntimePermission("invokerRegistryUpdate"); /** * return an array of InvokerLocators that are local to this VM (server invokers) */ public static final InvokerLocator[] getRegisteredServerLocators() { synchronized (serverLock) { return (InvokerLocator[]) registeredLocators.toArray(new InvokerLocator[registeredLocators.size()]); } } /** * return a suitable local server invoker that can service the remote invoker locator based on * a compatible transport * * @param remote */ public static InvokerLocator getSuitableServerLocatorForRemote(InvokerLocator remote) { synchronized (serverLock) { Iterator iter = registeredLocators.iterator(); while(iter.hasNext()) { InvokerLocator l = (InvokerLocator) iter.next(); if(l.getProtocol().equals(remote.getProtocol())) { // we found a valid transport match return l; } } return null; } } /** * return an array of String of the registered transports */ public static final String[] getRegisteredInvokerTransports() { synchronized(clientLock) { Set set = transportClientFactoryClasses.keySet(); String transports[] = new String[set.size()]; return (String[]) set.toArray(transports); } } /** * return an array of ClientInvokers that are connected */ public static final ClientInvoker[] getClientInvokers() { synchronized(clientLock) { if(clientLocators.isEmpty()) { return new ClientInvoker[0]; } List clientInvokerList = new ArrayList(); Collection collection = clientLocators.values(); Iterator itr = collection.iterator(); while(itr.hasNext()) { List holderList = (List)itr.next(); if(holderList != null) { for(int x = 0; x < holderList.size(); x++) { ClientInvokerHolder holder = (ClientInvokerHolder)holderList.get(x); clientInvokerList.add(holder.getClientInvoker()); } } } return (ClientInvoker[]) clientInvokerList.toArray(new ClientInvoker[clientInvokerList.size()]); } } /** * return an array of ServerInvokers that are connected */ public static final ServerInvoker[] getServerInvokers() { synchronized(serverLock) { if(serverLocators.isEmpty()) { return new ServerInvoker[0]; } Collection collection = serverLocators.values(); return (ServerInvoker[]) collection.toArray(new ServerInvoker[collection.size()]); } } /** * register a client/server invoker factory Class pair for a given transport * * @param transport * @param clientFactory implementation of org.jboss.remoting.transport.ClientFactory * @param serverFactory implementation of org.jboss.remoting.transport.ServerFactory */ public static void registerInvokerFactories(String transport, Class clientFactory, Class serverFactory) { doSecurityCheck(); synchronized (clientLock) { transportClientFactoryClasses.put(transport, clientFactory); } synchronized (serverLock) { transportServerFactoryClasses.put(transport, serverFactory); } } /** * unregister a client/server invoker factory pair for the given transport * * @param transport */ public static void unregisterInvokerFactories(String transport) { doSecurityCheck(); synchronized (clientLock) { transportClientFactoryClasses.remove(transport); } synchronized (serverLock) { transportServerFactoryClasses.remove(transport); } } public static void unregisterLocator(InvokerLocator locator) { doSecurityCheck(); synchronized (serverLock) { serverLocators.remove(locator); registeredLocators.remove(locator); } } /** * returns true if the client invoker is registered in the local JVM for a given locator * * @param locator */ public static boolean isClientInvokerRegistered(InvokerLocator locator) { synchronized(clientLock) { return clientLocators.containsKey(locator); } } /** * Called to destroy any cached RemoteClientInvoker copies inside the registry. This method * must be called when it is determined that a remote server (via the locator) is no * longer available. */ public static void destroyClientInvoker(InvokerLocator locator, Map configuration) { doSecurityCheck(); synchronized(clientLock) { if (trace) { log.trace("destroying client invoker " + locator + ", config " + configuration); } ClientInvoker invoker = decrementClientInvokerCounter(locator, configuration); if(invoker != null) { if (trace) { log.trace("disconnecting " + invoker); } invoker.disconnect(); invoker = null; } } } /** * create a ClientInvoker instance, using the specific InvokerLocator, which is just a client-side * invoker to a remote server. Will use the default configuration values for the transport. * * @param locator * @return * @throws Exception */ public static ClientInvoker createClientInvoker(InvokerLocator locator) throws Exception { return createClientInvoker(locator, null); } /** * create a ClientInvoker instance, using the specific InvokerLocator, which is just a client-side * invoker to a remote server * * @param locator * @return * @throws Exception */ public static ClientInvoker createClientInvoker(InvokerLocator locator, Map configuration) throws Exception { doSecurityCheck(); if(locator == null) { throw new NullPointerException("locator cannot be null"); } synchronized(clientLock) { ClientInvoker invoker = getRegisteredClientInvoker(locator, configuration); if(invoker != null) { if(trace) { log.trace("Found and returning cached client invoker (" + invoker + ")"); } return invoker; } boolean isForceRemote = false; boolean isPassByValue = false; Map parameters = locator.getParameters(); if(parameters != null) { String value = (String) parameters.get(InvokerLocator.BYVALUE); if(value != null && Boolean.valueOf(value).booleanValue()) { isPassByValue = true; } value = (String) parameters.get(InvokerLocator.FORCE_REMOTE); if(value != null && Boolean.valueOf(value).booleanValue()) { isForceRemote = true; } } // configuration map will override locator params if(configuration != null) { String value = (String) configuration.get(InvokerLocator.BYVALUE); if(value != null && Boolean.valueOf(value).booleanValue()) { isPassByValue = true; } value = (String) configuration.get(InvokerLocator.FORCE_REMOTE); if(value != null && Boolean.valueOf(value).booleanValue()) { isForceRemote = true; } } // Check to see if server invoker is local // If in server locators map, then created locally by this class ServerInvoker svrInvoker = null; if (!isForceRemote) { synchronized (serverLock) { svrInvoker = (ServerInvoker) serverLocators.get(locator); } if(svrInvoker != null) { LocalClientInvoker localInvoker = new LocalClientInvoker(locator, configuration, isPassByValue); // have to set reference to local server invoker so client in invoke directly localInvoker.setServerInvoker(svrInvoker); invoker = localInvoker; InvokerLocator l = invoker.getLocator(); addRegisteredClientInvoker(invoker, l, configuration); } } if (svrInvoker == null) //not local { String protocol = locator.getProtocol(); if(protocol == null) { throw new NullPointerException("protocol cannot be null for the locator"); } invoker = loadClientInvoker(protocol, locator, configuration); InvokerLocator l = invoker.getLocator(); addRegisteredClientInvoker(invoker, l, configuration); } return invoker; } } private static void addRegisteredClientInvoker(ClientInvoker invoker, InvokerLocator locator, Map configuration) { ClientInvokerHolder holder = new ClientInvokerHolder(invoker, configuration); List holderList = (List) clientLocators.get(locator); if (holderList != null) { if(holderList.contains(holder)) { throw new RuntimeException("Registering new ClientInvoker (" + invoker + "), but it already exists."); } else { holderList.add(holder); } } else { holderList = new ArrayList(); holderList.add(holder); clientLocators.put(locator, holderList); } incrementClientInvokerCounter(holder); } /** * This will check the internal client invoker registry to see if there is a client invoker for * the specified locator that also has the same config map entries. Will return it if found, null otherwise. * Note, this will also increment the internal reference count for the invoker * @param locator * @param configuration */ private static ClientInvoker getRegisteredClientInvoker(InvokerLocator locator, Map configuration) { ClientInvoker invoker = null; List holderList = (List) clientLocators.get(locator); if (holderList != null) { for (int x = 0; x < holderList.size(); x++) { ClientInvokerHolder holder = (ClientInvokerHolder) holderList.get(x); if (sameInvoker(holder, configuration)) { incrementClientInvokerCounter(holder); invoker = holder.getClientInvoker(); } } } return invoker; } private static boolean sameInvoker(ClientInvokerHolder holder, Map configuration) { boolean isSame = false; if(holder != null && holder.getClientInvoker() != null) { Map config = holder.getConfig(); if(config == null && configuration == null) { isSame = true; } else if(config != null && configuration != null) { isSame = config.equals(configuration); } } return isSame; } private static void incrementClientInvokerCounter(ClientInvokerHolder holder) { holder.incrementCount(); } private static ClientInvoker loadClientInvoker(String protocol, InvokerLocator locator, Map configuration) throws Exception { ClientInvoker clientInvoker = null; Class transportFactoryClass = getTransportClientFactory(protocol); if(transportFactoryClass != null) { ClientFactory transportFactory = (ClientFactory)transportFactoryClass.newInstance(); Method getClientInvokerMethod = getMethod(transportFactoryClass, "createClientInvoker", new Class[] {InvokerLocator.class, Map.class}); clientInvoker = (ClientInvoker)getClientInvokerMethod.invoke(transportFactory, new Object[] {locator, configuration}); } else { throw new ClassNotFoundException("Could not find class " + transportFactoryClass); } return clientInvoker; } private static ServerInvoker loadServerInvoker(String protocol, InvokerLocator locator, Map configuration) throws Exception { ServerInvoker serverInvoker = null; Class transportFactoryClass = getTransportServerFactory(protocol); if(transportFactoryClass != null) { ServerFactory transportFactory = (ServerFactory)transportFactoryClass.newInstance(); Method getServerInvokerMethod = getMethod(transportFactoryClass, "createServerInvoker", new Class[] {InvokerLocator.class, Map.class}); serverInvoker = (ServerInvoker)getServerInvokerMethod.invoke(transportFactory, new Object[] {locator, configuration}); } else { throw new ClassNotFoundException("Could not find class " + transportFactoryClass); } return serverInvoker; } private static Class getTransportClientFactory(String protocol) throws ClassNotFoundException { Class transportFactoryClass = (Class)transportClientFactoryClasses.get(protocol); if(transportFactoryClass == null) { String transportFactoryClassName = "org.jboss.remoting.transport." + protocol + ".TransportClientFactory"; transportFactoryClass = ClassLoaderUtility.loadClass(InvokerRegistry.class, transportFactoryClassName); transportClientFactoryClasses.put(protocol, transportFactoryClass); } return transportFactoryClass; } private static Class getTransportServerFactory(String protocol) throws ClassNotFoundException { Class transportFactoryClass = (Class)transportServerFactoryClasses.get(protocol); if(transportFactoryClass == null) { String transportFactoryClassName = "org.jboss.remoting.transport." + protocol + ".TransportServerFactory"; transportFactoryClass = ClassLoaderUtility.loadClass(transportFactoryClassName, InvokerRegistry.class); transportServerFactoryClasses.put(protocol, transportFactoryClass); } return transportFactoryClass; } /** * returns true if the server invoker is registered in the local JVM for a given locator/handler pair * * @param locator */ public static boolean isServerInvokerRegistered(InvokerLocator locator) { synchronized(serverLock) { return serverLocators.containsKey(locator); } } /** * create a ServerInvoker instance, using the specific Invoker locator data and an implementation of the * ServerInvocationHandler interface. Will use the default configuration values for the transport. * * @param locator * @return * @throws Exception */ public static ServerInvoker createServerInvoker(InvokerLocator locator) throws Exception { return createServerInvoker(locator, null); } /** * create a ServerInvoker instance, using the specific Invoker locator data and an implementation of the * ServerInvocationHandler interface along with * * @param locator * @return * @throws Exception */ public static ServerInvoker createServerInvoker(InvokerLocator locator, Map configuration) throws Exception { doSecurityCheck(); ServerInvoker invoker = null; synchronized(serverLock) { invoker = (ServerInvoker) serverLocators.get(locator); if(invoker != null) { throw new InvalidConfigurationException("The invoker for locator (" + locator + ") is already " + "in use by another Connector. Either change the locator or " + "add new handlers to existing Connector."); } String protocol = locator.getProtocol(); invoker = loadServerInvoker(protocol, locator, configuration); serverLocators.put(locator, invoker); registeredLocators.add(invoker.getLocator()); } return invoker; } public static void destroyServerInvoker(ServerInvoker invoker) { doSecurityCheck(); if(invoker != null) { InvokerLocator locator = invoker.getLocator(); unregisterLocator(locator); } } private static ClientInvoker decrementClientInvokerCounter(InvokerLocator locator, Map configuration) { List holderList = (List)clientLocators.get(locator); if (holderList == null) { log.debug("Could not decrement client invoker counter for locator " + locator + " as does not exist in invoker registry."); return null; } ClientInvokerHolder holder = null; // now look for specific invoker by configuration map for(int x = 0; x < holderList.size(); x++) { holder = (ClientInvokerHolder)holderList.get(x); if(holder != null) { Map config = holder.getConfig(); if(config == null && configuration == null) { break; } else if(config != null && configuration != null) { if(config.equals(configuration)) { break; } } } } if (holder == null) { log.debug("Could not decrement client invoker counter for locator " + locator + "as does not exist in invoker registry with matching configuraion map."); return null; } ClientInvoker clientInvoker = null; holder.decrementCount(); if(holder.getCount() == 0) { clientInvoker = holder.getClientInvoker(); holderList.remove(holder); if(holderList.isEmpty()) { clientLocators.remove(locator); } log.debug("removed " + clientInvoker + " from registry"); } else { log.debug("decremented " + holder.getClientInvoker() + "'s count, current count " + holder.getCount()); } return clientInvoker; } /** * This is needed by the ServerInvoker since it may change the port being used (if port specified was <= 0) to * next available port. * * @param locator * @param newLocator */ public static void updateServerInvokerLocator(InvokerLocator locator, InvokerLocator newLocator) { doSecurityCheck(); synchronized (serverLock) { Object si = serverLocators.get(locator); serverLocators.remove(locator); registeredLocators.remove(locator); serverLocators.put(newLocator, si); registeredLocators.add(newLocator); } } /** * Indicates if a specific transport protocol type (e.g. socket, sslsocket, rmi, https) * supports ssl. Note: almost all transports are able to support ssl if socket/serversocket * factory is set with an ssl version, so this is really just a hint from the invoker implementation. * * @param transport * @return * @throws Exception */ public static boolean isSSLSupported(String transport) throws Exception { doSecurityCheck(); boolean isSSLSupported = false; Class transportFactoryClass = null; try { synchronized (clientLock) { transportFactoryClass = getTransportClientFactory(transport); } ClientFactory clientFactory = (ClientFactory)transportFactoryClass.newInstance(); Method meth = getMethod(transportFactoryClass, "supportsSSL", new Class[]{}); Boolean boolVal = (Boolean)meth.invoke(clientFactory, null); isSSLSupported = boolVal.booleanValue(); } catch (ClassNotFoundException e) { Exception ex = new Exception("Can not verify transport (" + transport + ") supports SSL because can not find invoker implementation matching transport."); ex.initCause(e); throw ex; } catch (NoSuchMethodException e) { Exception ex = new Exception("Can not call supportsSSL method on client factory class (" + transportFactoryClass + ") as there is no such method."); ex.initCause(e); throw ex; } catch (IllegalAccessException e) { Exception ex = new Exception("Can not call create instance of client factory class (" + transportFactoryClass + ")."); ex.initCause(e); throw ex; } catch (InvocationTargetException e) { Exception ex = new Exception("Can not call supportsSSL method on client factory class (" + transportFactoryClass + ")."); ex.initCause(e); throw ex; } catch (InstantiationException e) { Exception ex = new Exception("Can not call supportsSSL method on client factory class (" + transportFactoryClass + ")."); ex.initCause(e); throw ex; } return isSSLSupported; } public String toString() { return "InvokerRegistry[" + Integer.toHexString(hashCode()) + "]"; } private static class ClientInvokerHolder { private ClientInvoker invoker = null; private Map config = null; private int counter = 0; public ClientInvokerHolder(ClientInvoker invoker, Map config) { this.invoker = invoker; this.config = config; } public void incrementCount() { counter++; } public void decrementCount() { counter--; if(counter < 0) { throw new RuntimeException("ClientInvokerHolder decremented to negative number for client invoker " + invoker); } } public int getCount() { return counter; } public ClientInvoker getClientInvoker() { return invoker; } public Map getConfig() { return config; } public boolean equals(Object o) { boolean isEqual = false; if(o instanceof ClientInvokerHolder) { ClientInvokerHolder h = (ClientInvokerHolder)o; if(invoker.equals(h.getClientInvoker())) { Map configuration = h.getConfig(); if(config == null && configuration == null) { isEqual = true; } else if(config != null && configuration != null) { isEqual = config.equals(configuration); } } } return isEqual; } } static private Method getMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { return c.getMethod(name, parameterTypes); } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { return c.getMethod(name, parameterTypes); } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } static private void doSecurityCheck() { // If there is no Security Manager, the issue is moot. final SecurityManager sm = System.getSecurityManager(); if (sm == null) { return; } // If the calling code is not verifiably in Remoting, then require it to have InvokerRegistryUpdatePermission. sm.checkPermission(INVOKER_REGISTRY_UPDATE_PERMISSION); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/0000755000175000017500000000000011632407051026671 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/0000755000175000017500000000000011632407050027457 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RMIServerInvokerInf.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RMIServerInvokerInf.0000644000175000017500000000311310355142433033271 0ustar twernertwerner/* * 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.remoting.transport.rmi; import java.io.IOException; import java.rmi.Remote; import java.rmi.RemoteException; /** * RMIServerInvokerInf * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 566 $ */ public interface RMIServerInvokerInf extends Remote { /** * transport a buffer via RMI * * @param invocation * @return * @throws RemoteException * @throws IOException */ public Object transport(Object invocation) throws RemoteException, IOException; } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RemotingRMIServerSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RemotingRMIServerSoc0000644000175000017500000002637011171061711033400 0ustar twernertwerner/* * 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.remoting.transport.rmi; import org.jboss.logging.Logger; import org.jboss.remoting.util.SecurityUtility; import javax.net.ServerSocketFactory; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import java.net.UnknownHostException; import java.rmi.server.RMIServerSocketFactory; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * RemotingRMIServerSocketFactory provides two services to RMIServerInvoker. *
            *
          1. It can be parameterized by a host name, allowing RMIServerInvoker to supply RMI * with a factory which creates server sockets bound to a specified host name as well as port. *

            *

          2. It can be parameterized by a ServerSocketFactory allowing RMIServerInvoker * to supply RMI with a factory facility which creates specialized server sockets. *
          *

          * If the ServerSocketFactory parameter is specified, then the RemotingRMIServerSocketFactory * should be used with a matching instance of RemotingRMIClientSocketFactory with a compatible * SocketFactory. *

          * If the ServerSocketFactory parameter is not specified, an instance of java.net.ServerSocket * will be created by default. *

          * * @author Ron Sigal * @version $Revision: 5017 $ *

          * Copyright (c) 2005 *

          */ public class RemotingRMIServerSocketFactory implements RMIServerSocketFactory, Serializable { protected static final Logger log = Logger.getLogger(RemotingRMIServerSocketFactory.class); private ServerSocketFactory serverSocketFactory; private int backlog; private InetAddress bindAddress; private int timeout; private static final long serialVersionUID = -5851426317709480542L; // The commented code below is from an attempt to incorporate a java.lang.reflect.Constructor // parameter to provide a very general way to create server sockets. The problem is that // Constructor does not implement Serializable, which is necessary to // allow the RemotingRMIServerSocketFactory to be transmitted to the RMI Registry. The // code is left in place because it could be resurrected by passing in a class name and parameter // types to specify a constructor. Fortunately, java.lang.Class does implement // Serializable. // private Constructor constructor; // private Object[] args; // private int portPosition; /** * @param bindHost name of host to which all generated server sockets should be bound */ public RemotingRMIServerSocketFactory(String bindHost) throws UnknownHostException { this(null, -1, bindHost); } /** * @param backlog to be passed to all generated server sockets * @param bindHost name of host to which all generated server sockets should be bound * @throws UnknownHostException if an IP address for bindHost cannot be found */ public RemotingRMIServerSocketFactory(int backlog, String bindHost) throws UnknownHostException { this(null, backlog, bindHost); } /** * @param serverSocketFactory ServerSocketFactory for generating server sockets * @param backlog to be passed to all generated server sockets * @param bindHost name of host to which all generated server sockets should be bound * @throws UnknownHostException if an IP address for bindHost cannot be found */ public RemotingRMIServerSocketFactory(ServerSocketFactory serverSocketFactory, int backlog, String bindHost) throws UnknownHostException { this(serverSocketFactory, backlog, bindHost, 60000); // TODO: -TME This needs to be fixed so only comes from parent class } public RemotingRMIServerSocketFactory(ServerSocketFactory serverSocketFactory, int backlog, final String bindHost, int timeout) throws UnknownHostException { this.serverSocketFactory = serverSocketFactory; this.backlog = backlog; this.timeout = timeout; this.bindAddress = getAddressByName(bindHost); } public RemotingRMIServerSocketFactory(String bindHost, int timeout) throws UnknownHostException { this(null, -1, bindHost, timeout); } // public RemotingRMIServerSocketFactory(Constructor constructor, Object[] args, int portPosition) // { // this.constructor = constructor; // this.args = args; // this.portPosition = portPosition; // } /** * Creates a server socket bound to the host name passed to the constructor. If a * ServerSocketFactory was passed to the constructor, it will be used to create the * server socket. Otherwise, an instance of java.net.ServerSocket will be created. * * @param port the port to which the generated server socket should be bound * @return a new ServerSocket * @throws IOException if there is a problem creating a server socket */ public ServerSocket createServerSocket(final int port) throws IOException { ServerSocket svrSocket = null; if(serverSocketFactory != null) { svrSocket = createServerSocket(serverSocketFactory, port, backlog, bindAddress); } // if (constructor != null) // { // try // { // if (portPosition != -1) // args[portPosition] = new Integer(port); // // return (ServerSocket) constructor.newInstance(args); // } // catch (Exception e) // { // throw new IOException(e.getMessage()); // } // } else { svrSocket = createServerSocket(port, backlog, bindAddress); } svrSocket.setSoTimeout(timeout); return svrSocket; } /** * Overrides the equals() method provided by the Object class. It looks for * equality of binding host name and server socket factory parameters passed to constructor. * * @param o Object to which code is to be compared. * @return true if and only if o equals this */ public boolean equals(Object o) { if(! (o instanceof RemotingRMIServerSocketFactory)) { return false; } RemotingRMIServerSocketFactory ssf = (RemotingRMIServerSocketFactory) o; // This is for the version that uses a ServerSocketFactory if(serverSocketFactory != null) { if(ssf.serverSocketFactory == null || !serverSocketFactory.equals(ssf.serverSocketFactory) || backlog != ssf.backlog || !bindAddress.equals(ssf.bindAddress)) { return false; } return true; } // // This is for the version that uses a constructor // if (constructor != null) // { // if (ssf.constructor == null || // ! constructor.equals(ssf.constructor) || // portPosition != ssf.portPosition) // return false; // // for (int i = 0; i < args.length; i++) // { // if (! args[i].equals(ssf.args[i])) // return false; // } // // return true; // } // This is for the plain vanilla version if(ssf.serverSocketFactory != null || backlog != ssf.backlog || !bindAddress.equals(ssf.bindAddress)) { return false; } return true; } /** * Overrides hashCode() method provided by the Object class. * * @return a hashcode for this */ public int hashCode() { if(serverSocketFactory != null) { return serverSocketFactory.hashCode() * backlog * bindAddress.hashCode(); } // if (constructor != null) // { // int hash = portPosition; // // for (int i = 0; i < args.length; i++) // hash *= args[i].hashCode(); // // return hash; // } return backlog * bindAddress.hashCode(); } static private ServerSocket createServerSocket(final ServerSocketFactory ssf, final int port, final int backlog, final InetAddress inetAddress) throws IOException { if (SecurityUtility.skipAccessControl()) { return ssf.createServerSocket(port, backlog, inetAddress); } try { return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return ssf.createServerSocket(port, backlog, inetAddress); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private ServerSocket createServerSocket(final int port, final int backlog, final InetAddress inetAddress) throws IOException { if (SecurityUtility.skipAccessControl()) { return new ServerSocket(port, backlog, inetAddress); } try { return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return new ServerSocket(port, backlog, inetAddress); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/TransportClientFacto0000644000175000017500000000306710455077561033534 0ustar twernertwerner/* * 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.remoting.transport.rmi; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new RMIClientInvoker(locator, config); } public boolean supportsSSL() { return false; } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RMIClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RMIClientInvoker.jav0000644000175000017500000005564511171061711033322 0ustar twernertwerner/* * 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.remoting.transport.rmi; import org.jboss.logging.Logger; import org.jboss.remoting.AbstractInvoker; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.Home; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.RemoteClientInvoker; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.MarshallerDecorator; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.UnMarshallerDecorator; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.marshal.rmi.RMIMarshaller; import org.jboss.remoting.marshal.rmi.RMIUnMarshaller; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.util.SecurityUtility; import org.jboss.serial.io.JBossObjectInputStream; import org.jboss.util.threadpool.BasicThreadPool; import org.jboss.util.threadpool.BlockingMode; import org.jboss.util.threadpool.RunnableTaskWrapper; import org.jboss.util.threadpool.Task; import org.jboss.util.threadpool.ThreadPool; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.net.SocketTimeoutException; import java.rmi.NotBoundException; import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * RMIClientInvoker * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5017 $ */ public class RMIClientInvoker extends RemoteClientInvoker { /** * Key for the configuration map that determines the threadpool size for * simulated timeouts. */ public static final String MAX_NUM_TIMEOUT_THREADS = "maxNumTimeoutThreads"; /** * Key for the configuration map that determines the queue size for simulated * timeout threadpool. */ public static final String MAX_TIMEOUT_QUEUE_SIZE = "maxTimeoutQueueSize"; /** * Specifies the default number of work threads in the thread pool for * simulating timeouts. */ public static final int MAX_NUM_TIMEOUT_THREADS_DEFAULT = 10; private static final Logger log = Logger.getLogger(RMIClientInvoker.class); private static final boolean isTraceEnabled = log.isTraceEnabled(); private RMIServerInvokerInf server; private Object timeoutThreadPoolLock = new Object(); private ThreadPool timeoutThreadPool; protected boolean rmiOnewayMarshalling; /** * Need flag to indicate if have been able to lookup registry and set stub. * Can't do this in the constructor, as need to throw CannotConnectException so * for clustering capability. * * @param locator */ private boolean connected = false; public RMIClientInvoker(InvokerLocator locator) { super(locator); configureParameters(); } public RMIClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); configureParameters(); } protected void configureParameters() { Map params = configuration; if (params == null) { return; } // look for enableTcpNoDelay param Object val = params.get(RMIServerInvoker.RMI_ONEWAY_MARSHALLING); if (val instanceof String) { try { rmiOnewayMarshalling = Boolean.valueOf((String)val).booleanValue(); log.debug(this + " setting rmiOnewayMarshalling to " + rmiOnewayMarshalling); } catch (Exception e) { log.warn(this + " could not convert " + RMIServerInvoker.RMI_ONEWAY_MARSHALLING + " value of " + val + " to a boolean value. Defaulting to false"); } } else if (val != null) { log.warn(this + " value of " + RMIServerInvoker.RMI_ONEWAY_MARSHALLING + " (" + val + ") must be a String. Defaulting to false"); } } private int getRegistryPort(InvokerLocator locator) { int port = RMIServerInvoker.DEFAULT_REGISTRY_PORT; // See if locator contains a specific registry port Map params = locator.getParameters(); if(params != null) { String value = (String) params.get(RMIServerInvoker.REGISTRY_PORT_KEY); if(value != null) { try { port = Integer.parseInt(value); log.debug("Using port " + port + " for rmi registry."); } catch(NumberFormatException e) { log.error("Can not set the RMIServerInvoker RMI registry to port " + value + ". This is not a valid port number."); } } } return port; } /** * get the server stub * * @param server */ public void setServerStub(RMIServerInvokerInf server) { this.server = server; log.trace(this.server); } /** * return the RMI server stub * * @return */ public RMIServerInvokerInf getServerStub() { return this.server; } /** * subclasses must implement this method to provide a hook to connect to the remote server, if this applies * to the specific transport. However, in some transport implementations, this may not make must difference since * the connection is not persistent among invocations, such as SOAP. In these cases, the method should * silently return without any processing. * * @throws ConnectionFailedException */ protected void handleConnect() throws ConnectionFailedException { int registryPort = getRegistryPort(locator); Home home = null; Exception savedException = null; Iterator it = getConnectHomes().iterator(); while (it.hasNext()) { //TODO: -TME Need to figure this out a little better as am now dealing with // with 2 ports, the rmi server and the registry. try { home = (Home) it.next(); String host = home.host; final int port = home.port; locator.setHomeInUse(home); storeLocalConfig(configuration); log.debug(this + " looking up registry: " + host + "," + port); final Registry registry = LocateRegistry.getRegistry(host, registryPort); log.debug(this + " trying to connect to: " + home); Remote remoteObj = lookup(registry, "remoting/RMIServerInvoker/" + port); log.debug("Remote RMI Stub: " + remoteObj); setServerStub((RMIServerInvokerInf) remoteObj); connected = true; break; } catch(Exception e) { savedException = e; connected = false; RemotingRMIClientSocketFactory.removeLocalConfiguration(locator); log.trace("Unable to connect RMI invoker client to " + home, e); } } if (server == null) { String message = this + " unable to connect RMI invoker client"; log.debug(message); throw new CannotConnectException(message, savedException); } } protected Home getUsableAddress() { InvokerLocator savedLocator = locator; String protocol = savedLocator.getProtocol(); String path = savedLocator.getPath(); Map params = savedLocator.getParameters(); List homes = locator.getConnectHomeList(); Home home = null; Iterator it = homes.iterator(); while (it.hasNext()) { try { home = (Home) it.next(); locator = new InvokerLocator(protocol, home.host, home.port, path, params); invoke(new InvocationRequest(null, null, ServerInvoker.ECHO, null, null, null)); if (log.isTraceEnabled()) log.trace(this + " able to contact server at: " + home); return home; } catch (Throwable e) { log.debug(this + " unable to contact server at: " + home); } finally { locator = savedLocator; } } return home; } /** * subclasses must implement this method to provide a hook to disconnect from the remote server, if this applies * to the specific transport. However, in some transport implementations, this may not make must difference since * the connection is not persistent among invocations, such as SOAP. In these cases, the method should * silently return without any processing. */ protected void handleDisconnect() { RemotingRMIClientSocketFactory.removeLocalConfiguration(locator); } protected String getDefaultDataType() { return RMIMarshaller.DATATYPE; } protected void storeLocalConfig(Map config) { HashMap localConfig = new HashMap(config); // If a specific SocketFactory was passed in, use it. If a SocketFactory was // generated from SSL parameters, discard it. It will be recreated later by // SerializableSSLClientSocketFactory with any additional parameters sent // from server. if (socketFactory != null && !socketFactoryCreatedFromSSLParameters && AbstractInvoker.isCompleteSocketFactory(socketFactory)) localConfig.put(Remoting.CUSTOM_SOCKET_FACTORY, socketFactory); // Save configuration for SerializableSSLClientSocketFactory. RemotingRMIClientSocketFactory.addLocalConfiguration(locator, localConfig); } protected Object transport(String sessionId, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller) throws IOException, ConnectionFailedException { if(this.server == null) { log.debug("Server stub has not been set in RMI invoker client. See previous errors for details."); //throw new IOException("Server stub hasn't been set!"); throw new CannotConnectException("Server stub has not been set."); } try { Object payload = invocation; if(marshaller != null && !(marshaller instanceof RMIMarshaller)) { if(marshaller instanceof MarshallerDecorator) { payload = ((MarshallerDecorator) marshaller).addDecoration(payload); } else { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); if (marshaller instanceof VersionedMarshaller) ((VersionedMarshaller) marshaller).write(payload, byteOut, getVersion()); else marshaller.write(payload, byteOut); byteOut.close(); if (rmiOnewayMarshalling) { // Legacy treatment, pre 2.4.0. ByteArrayInputStream bais = new ByteArrayInputStream(byteOut.toByteArray()); SerializationManager manager = SerializationStreamFactory.getManagerInstance(getSerializationType()); ObjectInputStream ois = manager.createInput(bais, getClassLoader()); try { byteOut.close(); payload = readObject(ois); ois.close(); } catch(ClassNotFoundException e) { log.debug("Could not marshall invocation payload object " + payload, e); throw new IOException(e.getMessage()); } } else { payload = byteOut.toByteArray(); } } } int simulatedTimeout = getSimulatedTimeout(configuration, metadata); if (simulatedTimeout <= 0) { Object result = callTransport(server, payload); return unmarshal(result, unmarshaller, metadata); } else { if (log.isTraceEnabled()) log.trace("using simulated timeout: " + simulatedTimeout); class Holder {public Object value;} final Holder resultHolder = new Holder(); final Object finalPayload = payload; Runnable r = new Runnable() { public void run() { try { resultHolder.value = callTransport(server, finalPayload); if (log.isTraceEnabled()) log.trace("result: " + resultHolder.value); } catch (Exception e) { resultHolder.value = e; if (log.isTraceEnabled()) log.trace("exception: " + e); } } }; // BasicThreadPool timeout mechanism depends on the interrupted status of // the running thread. Thread.interrupted(); ThreadPool pool = getTimeoutThreadPool(); WaitingTaskWrapper wrapper = new WaitingTaskWrapper(r, simulatedTimeout); if (log.isTraceEnabled()) log.trace("starting task in thread pool"); pool.runTaskWrapper(wrapper); if (log.isTraceEnabled()) log.trace("task finished in thread pool"); Object result = unmarshal(resultHolder.value, unmarshaller, metadata); if (result == null) { if (log.isTraceEnabled()) log.trace("invocation timed out"); Exception cause = new SocketTimeoutException("timed out"); throw new CannotConnectException("Can not connect http client invoker.", cause); } else if (result instanceof IOException) { throw (IOException) result; } else if (result instanceof RuntimeException) { throw (RuntimeException) result; } else { if (log.isTraceEnabled()) log.trace("returning result: " + result); return result; } } } catch(RemoteException e) { log.debug("Error making invocation in RMI client invoker.", e); throw new CannotConnectException("Error making invocation in RMI client invoker.", e); } } private int getSimulatedTimeout(Map configuration, Map metadata) { int timeout = -1; String connectionTimeout = (String) configuration.get("timeout"); String invocationTimeout = null; if (metadata != null) invocationTimeout = (String) metadata.get("timeout"); if (invocationTimeout != null && invocationTimeout.length() > 0) { try { timeout = Integer.parseInt(invocationTimeout); } catch (NumberFormatException e) { log.warn("Could not set timeout for current invocation because value (" + invocationTimeout + ") is not a number."); } } if (timeout < 0 && connectionTimeout != null && connectionTimeout.length() > 0) { try { timeout = Integer.parseInt(connectionTimeout); } catch (NumberFormatException e) { log.warn("Could not set timeout for http client connection because value (" + connectionTimeout + ") is not a number."); } } if (timeout < 0) timeout = 0; return timeout; } protected Object unmarshal(Object o, UnMarshaller unmarshaller, Map metadata) throws IOException { Object result = o; if(unmarshaller != null && !(unmarshaller instanceof RMIUnMarshaller) && !rmiOnewayMarshalling) { if(unmarshaller instanceof UnMarshallerDecorator) { result = ((UnMarshallerDecorator) unmarshaller).removeDecoration(o); } else { byte[] byteIn = (byte[]) o; ByteArrayInputStream is = new ByteArrayInputStream(byteIn); try { if (unmarshaller instanceof VersionedUnMarshaller) { result = ((VersionedUnMarshaller) unmarshaller).read(is, metadata, getVersion()); } else { result = unmarshaller.read(is, metadata); } } catch(ClassNotFoundException e) { log.debug("Could not unmarshall invocation response" + o, e); throw new IOException(e.getMessage()); } } } return result; } /** * Gets the thread pool being used for simulating timeouts. If one has * not been specifically set via configuration or call to set it, will always return * instance of org.jboss.util.threadpool.BasicThreadPool. */ public ThreadPool getTimeoutThreadPool() { synchronized (timeoutThreadPoolLock) { if (timeoutThreadPool == null) { int maxNumberThreads = MAX_NUM_TIMEOUT_THREADS_DEFAULT; int maxTimeoutQueueSize = -1; BasicThreadPool pool = new BasicThreadPool("HTTP timeout"); log.debug(this + " created new simulated timeout thread pool: " + pool); Object param = configuration.get(MAX_NUM_TIMEOUT_THREADS); if (param instanceof String) { try { maxNumberThreads = Integer.parseInt((String) param); } catch (NumberFormatException e) { log.warn("maxNumberThreads parameter has invalid format: " + param); } } else if (param != null) { log.warn("maxNumberThreads parameter must be a string in integer format: " + param); } param = configuration.get(MAX_TIMEOUT_QUEUE_SIZE); if (param instanceof String) { try { maxTimeoutQueueSize = Integer.parseInt((String) param); } catch (NumberFormatException e) { log.warn("maxTimeoutQueueSize parameter has invalid format: " + param); } } else if (param != null) { log.warn("maxTimeoutQueueSize parameter must be a string in integer format: " + param); } pool.setMaximumPoolSize(maxNumberThreads); if (maxTimeoutQueueSize > 0) { pool.setMaximumQueueSize(maxTimeoutQueueSize); } pool.setBlockingMode(BlockingMode.RUN); timeoutThreadPool = pool; } } return timeoutThreadPool; } /** * When a WaitingTaskWrapper is run in a BasicThreadPool, the calling thread * will block for the designated timeout period. */ static class WaitingTaskWrapper extends RunnableTaskWrapper { long completeTimeout; public WaitingTaskWrapper(Runnable runnable, long completeTimeout) { super(runnable, 0, completeTimeout); this.completeTimeout = completeTimeout; } public int getTaskWaitType() { return Task.WAIT_FOR_COMPLETE; } public String toString() { return "WaitingTaskWrapper[" + completeTimeout + "]"; } } static private Object readObject(final ObjectInputStream ois) throws IOException, ClassNotFoundException { if (SecurityUtility.skipAccessControl() || !(ois instanceof JBossObjectInputStream)) { return ois.readObject(); } try { return AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException, ClassNotFoundException { return ois.readObject(); } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) throw (IOException) cause; else if (cause instanceof ClassNotFoundException) throw (ClassNotFoundException) cause; else throw (RuntimeException) cause; } } static private Object callTransport(final RMIServerInvokerInf server, final Object payload) throws IOException { if (SecurityUtility.skipAccessControl()) { return server.transport(payload); } try { return AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return server.transport(payload); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private Remote lookup(final Registry registry, final String name) throws RemoteException, NotBoundException { if (SecurityUtility.skipAccessControl()) { return registry.lookup(name); } try { return (Remote) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return registry.lookup(name); } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof RemoteException) throw (RemoteException) cause; else throw (NotBoundException) cause; } } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RemotingRMIClientSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RemotingRMIClientSoc0000644000175000017500000003064711171061711033352 0ustar twernertwerner/* * 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.remoting.transport.rmi; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import java.rmi.server.RMIClientSocketFactory; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Collections; import java.util.HashMap; import java.util.Map; import javax.net.SocketFactory; import org.jboss.logging.Logger; import org.jboss.remoting.AbstractInvoker; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.Version; import org.jboss.remoting.util.SecurityUtility; /** * RemotingRMIClientSocketFactory provides two services to RMIServerInvoker. *
            *
          1. It can be parameterized by a host name, allowing RMIServerInvoker to supply RMI * with a factory which creates sockets connected to a specified host name. *

            *

          2. It can be parameterized by a SocketFactory allowing RMIServerInvoker * to supply RMI with a factory facility which creates specialized sockets. *
          *

          * if the SocketFactory parameter is specified, then the RemotingRMIClientSocketFactory * should be used with a matching instance of RemotingRMIServerSocketFactory with a compatible * ServerSocketFactory. *

          * If the SocketFactory parameter is not specified, an instance of java.net.Socket * will be created by default. *

          * Although there is no apparent need for the host name parameter, since the createSocket() * method receives a host name, it seems that for a server object bound to localhost, the RMI runtime will * pass to createSocket() one of the IP addresses for which the host is configured (other than * 127.0.0.1), resulting in a failure to retrieve the object from the Registry. If a host name is passed to * a RemotingRMIClientFactory constructor, it will override the host name passed to * createSocket() In particular, parameterizing RemotingRMIClientSocketFactory * with localhost will allow the retrieval of objects bound to localhost. * * @author Ron Sigal * @version $Revision: 5017 $ *

          * Copyright (c) 2005 *

          */ public class RemotingRMIClientSocketFactory implements RMIClientSocketFactory, Serializable { static final long serialVersionUID; protected static Logger log = Logger.getLogger(RemotingRMIClientSocketFactory.class); protected static Map configMaps = Collections.synchronizedMap(new HashMap()); protected static Map socketFactories = Collections.synchronizedMap(new HashMap()); protected Map configuration; protected InvokerLocator invokerLocator; transient protected SocketFactory socketFactory; private int timeout = 60000; // The commented code below is from an attempt to incorporate a java.lang.reflect.Constructor // parameter to provide a very general way to create sockets. The problem is that // Constructor does not implement Serializable, which is necessary to // allow the RemotingRMIClientSocketFactory to be transmitted to the client. The // code is left in place because it could be resurrected by passing in a class name and parameter // types to specify a constructor. Fortunately, java.lang.Class does implement // Serializable. // private Constructor constructor; // private Object[] args; // private int hostPosition; // private int portPosition; protected String hostName; static { if(Version.getDefaultVersion() == Version.VERSION_1) { serialVersionUID = -7491556589517716155L; } else { serialVersionUID = -3039839695840773968L; } } public static void addLocalConfiguration(InvokerLocator invokerLocator, Map localConfig) { log.debug("adding local configuration for: " + invokerLocator); configMaps.put(new ComparableHolder(invokerLocator), localConfig); } public static void removeLocalConfiguration(InvokerLocator invokerLocator) { log.debug("removing local configuration for: " + invokerLocator); Object o = configMaps.remove(new ComparableHolder(invokerLocator)); if (o == null) log.warn("trying to delete unknown key: " + invokerLocator); ComparableHolder holder = new ComparableHolder(invokerLocator); socketFactories.remove(holder); } /** * @param locator * @param hostName * @param timeout * @param config */ public RemotingRMIClientSocketFactory(InvokerLocator locator, String hostName, int timeout, Map config) { this.invokerLocator = locator; this.hostName = hostName; this.timeout = timeout; this.configuration = new HashMap(config); } // public RemotingRMISocketFactory(Constructor constructor, Object[] args, int hostPosition, int portPosition) // throws ClassNotFoundException, NoSuchMethodException // { // this.constructor = constructor; // this.args = args; // this.portPosition = portPosition; // } /** * Creates a new socket. If a SocketFactory was passed to the constructor, it will be used. * Otherwise, a java.net.Socket will be created by default. * * @param host host to which socket should be connected * @param port port to which socket should be connected * @return new socket * @throws IOException if there is a problem creating a socket */ public Socket createSocket(String host, final int port) throws IOException { // If invokerLocator isn't in configMaps, an RMICLientInvoker has not been created // yet. This call was probably made by an RMI thread, and is premature. Best attempt // is to return a vanilla socket. final String effectiveHost = hostName != null ? hostName : host; if (log.isTraceEnabled()) log.trace("host: " + host + ", effective host: " + effectiveHost + ", port: " + port); if (invokerLocator != null) { ComparableHolder holder = new ComparableHolder(invokerLocator); if (!configMaps.containsKey(holder)) { if (Thread.currentThread().getName().indexOf("RMI") >= 0) { log.debug("unrecognized invoker locator: " + invokerLocator); log.debug("unable to retrieve socket factory: returning plain socket"); } else { log.warn(Thread.currentThread().getName() + " unrecognized invoker locator: " + invokerLocator); log.warn("unable to retrieve socket factory: returning plain socket"); } return createSocketPrivate(effectiveHost, port); } socketFactory = retrieveSocketFactory(holder); } Socket socket = null; if(socketFactory != null) { socket = createSocketPrivate(socketFactory, effectiveHost, port); } else { socket = createSocketPrivate(effectiveHost, port); } socket.setSoTimeout(timeout); socketFactory = null; return socket; } public SocketFactory retrieveSocketFactory(ComparableHolder holder) throws IOException { SocketFactory sf = (SocketFactory) socketFactories.get(holder); if (sf == null) { // We want to keep the local configuration map, which might contain a // SocketFactory, separate from the configuration map, which is meant // to contain only serializable objects. Map tempConfig = new HashMap(configuration); Map localConfig = (Map) configMaps.get(holder); if (localConfig != null) tempConfig.putAll(localConfig); if (tempConfig.containsKey(Remoting.CUSTOM_SOCKET_FACTORY)) { sf = (SocketFactory) tempConfig.get(Remoting.CUSTOM_SOCKET_FACTORY); } if (sf == null) { sf = SocketFactory.getDefault(); sf = AbstractInvoker.wrapSocketFactory(sf, tempConfig); } socketFactories.put(holder, sf); } return sf; } public void clear() { configuration = null; invokerLocator = null; socketFactory = null; } protected static class ComparableHolder { private String protocol; private InetAddress host; private int port; private int hashCode; public ComparableHolder(final InvokerLocator invokerLocator) { protocol = invokerLocator.getProtocol().toLowerCase(); try { host = getAddressByName(invokerLocator.getHost()); } catch (UnknownHostException e) { log.error("unable to resolve host: " + invokerLocator.getHost(), e); } port = invokerLocator.getPort(); hashCode = protocol.hashCode() * host.hashCode() * port; } public boolean equals(Object obj) { if (obj == null || !(obj instanceof ComparableHolder)) return false; ComparableHolder holder = (ComparableHolder) obj; return protocol.equals(holder.protocol.toLowerCase()) && host.equals(holder.host) && port == holder.port; } public int hashCode() { return hashCode; } } static private Socket createSocketPrivate(final String host, final int port) throws IOException { if (SecurityUtility.skipAccessControl()) { return new Socket(host, port); } try { return (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return new Socket(host, port); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private Socket createSocketPrivate(final SocketFactory sf, final String host, final int port) throws IOException { if (SecurityUtility.skipAccessControl()) { return sf.createSocket(host, port); } try { return (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return sf.createSocket(host, port); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/TransportServerFacto0000644000175000017500000000103510455077561033555 0ustar twernertwernerpackage org.jboss.remoting.transport.rmi; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new RMIServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.jav0000644000175000017500000005141711203656244033352 0ustar twernertwerner/* * 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.remoting.transport.rmi; import org.jboss.remoting.Home; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.MarshallerDecorator; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.UnMarshallerDecorator; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.marshal.rmi.RMIMarshaller; import org.jboss.remoting.marshal.rmi.RMIUnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.util.SecurityUtility; import org.jboss.serial.io.JBossObjectOutputStream; import org.jboss.util.propertyeditor.PropertyEditors; import org.jboss.logging.Logger; import javax.net.SocketFactory; import java.beans.IntrospectionException; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.net.InetAddress; import java.net.UnknownHostException; import java.rmi.AccessException; import java.rmi.NotBoundException; import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.ExportException; import java.rmi.server.RMIClientSocketFactory; import java.rmi.server.RMIServerSocketFactory; import java.rmi.server.RemoteServer; import java.rmi.server.ServerNotActiveException; import java.rmi.server.UnicastRemoteObject; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; /** * RMIServerInvoker * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5255 $ */ public class RMIServerInvoker extends ServerInvoker implements RMIServerInvokerInf, Cloneable { public static String RMI_ONEWAY_MARSHALLING = "rmiOnewayMarshalling"; private static final Logger log = Logger.getLogger(RMIServerInvoker.class); protected boolean isPrimaryServer = true; protected Set secondaryServers = new HashSet(); protected boolean rmiOnewayMarshalling; private Remote stub; private RemotingRMIClientSocketFactory csf; /** * Default for how many connections are queued. Value is 200. */ public static final int BACKLOG_DEFAULT = 200; /** * Default port on which rmi registry will be started. Value is 3455. */ public static final int DEFAULT_REGISTRY_PORT = 3455; /** * Key for port on which rmi registry should be started on. */ public static final String REGISTRY_PORT_KEY = "registryPort"; private Marshaller marshaller = null; private UnMarshaller unmarshaller = null; public RMIServerInvoker(InvokerLocator locator) { super(locator); } public void start() throws IOException { super.start(); if (isPrimaryServer) { List connectHomes = getConnectHomes(); List homes = getHomes(); if (connectHomes.size() != homes.size()) throw new IOException("number of connect homes and bind homes must match in RMI transport"); Home bindHome = (Home) homes.get(0); Home connectHome = (Home) connectHomes.get(0); initRMI(bindHome, connectHome); for (int i = 1; i < homes.size(); i++) { bindHome = (Home) homes.get(i); connectHome = (Home) connectHomes.get(i); RMIServerInvoker copy = copy(); secondaryServers.add(copy); copy.initRMI(bindHome, connectHome); } } } protected void setup() throws Exception { Properties props = new Properties(); props.putAll(getConfiguration()); mapJavaBeanProperties(RMIServerInvoker.this, props, false); super.setup(); } protected RMIServerInvoker copy() throws IOException { Object o = null; try { o = clone(); } catch (CloneNotSupportedException e) { log.error("This should not happen", e); return this; } RMIServerInvoker server = (RMIServerInvoker) o; server.locator = locator; server.locator = new InvokerLocator(locator.getLocatorURI()); server.locator.setHomeInUse(locator.getHomeInUse()); server.isPrimaryServer = false; server.start(); return server; } protected void initRMI(Home bindHome, Home connectHome) throws IOException { Registry registry = null; try { registry = getRegistry(); } catch (Exception e) { throw new IOException(e.getMessage()); } String bindHost = bindHome.host; int bindPort = bindHome.port; String clientConnectHost = connectHome.host; if(clientConnectHost == null) { clientConnectHost = bindHost; } locator.setHomeInUse(bindHome); RMIServerSocketFactory ssf = new RemotingRMIServerSocketFactory(getServerSocketFactory(), BACKLOG_DEFAULT, bindHost, getTimeout()); csf = getRMIClientSocketFactory(clientConnectHost); stub = exportObject(this, bindPort, csf, ssf); log.debug("Binding server to \"remoting/RMIServerInvoker/" + bindPort + "\" in registry"); rebind(registry, "remoting/RMIServerInvoker/" + bindPort, this); ClassLoader classLoader = getClassLoader(RMIServerInvoker.class); Map map = passConfigMapToMarshalFactory ? configuration : null; unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), classLoader, map); marshaller = MarshalFactory.getMarshaller(getLocator(), classLoader, map); } protected RemotingRMIClientSocketFactory getRMIClientSocketFactory(String clientConnectHost) { // Remove server side socket creation listeners. HashMap remoteConfig = new HashMap(configuration); remoteConfig.remove(Remoting.CUSTOM_SERVER_SOCKET_FACTORY); remoteConfig.remove(Remoting.SOCKET_CREATION_CLIENT_LISTENER); remoteConfig.remove(Remoting.SOCKET_CREATION_SERVER_LISTENER); return new RemotingRMIClientSocketFactory(locator, clientConnectHost, getTimeout(), remoteConfig); } protected SocketFactory getDefaultSocketFactory() { // return SocketFactory.getDefault(); /** * Returning null because by default, this socket factory * will be need to be serialized when exported. Since the * default factory implementation returned from SocketFactory.getDefault() * is not serializable, it will not work. Therefore, if return null, * will delay the creation of the socket factory until the RMIClientSocketFactory is * exported. */ return null; } public RMIServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } private Registry getRegistry() throws Exception { Registry registry = null; int port = DEFAULT_REGISTRY_PORT; // See if locator contains a specific registry port Map params = getConfiguration(); if(params != null) { String value = (String) params.get(REGISTRY_PORT_KEY); if(value != null) { try { port = Integer.parseInt(value); log.debug("Using port " + port + " for rmi registry."); } catch(NumberFormatException e) { throw new Exception("Can not set the RMIServerInvoker RMI registry to port " + value + ". This is not a valid port number."); } } } try { log.debug("Creating registry for " + port); registry = createRegistry(port); } catch(ExportException exportEx) { log.debug("Locating registry for " + port); // Probably means that the registry already exists, so just get it. registry = getRegistry(port); } if(log.isTraceEnabled()) { log.trace("Got registry: " + registry); } return registry; } protected String getDefaultDataType() { return SerializableMarshaller.DATATYPE; } /** * destroy the RMI Server Invoker, which will unexport the RMI server */ public void destroy() { super.destroy(); try { try { log.debug("locator: " + locator + ", home: " + locator.getHomeInUse()); log.debug(this + " primary: " + isPrimaryServer + " unbinding " + "remoting/RMIServerInvoker/" + locator.getPort() + " from registry"); Registry registry = getRegistry(); unbind(registry, "remoting/RMIServerInvoker/" + locator.getPort()); log.debug("unbound " + "remoting/RMIServerInvoker/" + locator.getPort() + " from registry"); } catch(Exception e) { if ("Finalizer".equalsIgnoreCase(Thread.currentThread().getName())) log.debug("thread: " + Thread.currentThread().getName() + " Error unbinding RMIServerInvoker from RMI registry.", e); else log.error("thread: " + Thread.currentThread().getName() + " Error unbinding RMIServerInvoker from RMI registry.", e); } UnicastRemoteObject.unexportObject(this, true); } catch(java.rmi.NoSuchObjectException e) { } if (csf != null) csf.clear(); if (isPrimaryServer) { Iterator it = secondaryServers.iterator(); while (it.hasNext()) { RMIServerInvoker server = (RMIServerInvoker) it.next(); it.remove(); server.destroy(); } } } protected void finalize() throws Throwable { destroy(); super.finalize(); } /** * returns true if the transport is bi-directional in nature, for example, * SOAP in unidirectional and SOCKETs are bi-directional (unless behind a firewall * for example). */ public boolean isTransportBiDirectional() { return true; } public final Remote getStub() { return stub; } public Object transport(Object invocation) throws RemoteException, IOException { Object payload = invocation; if(unmarshaller != null && !(unmarshaller instanceof RMIUnMarshaller)) { if(unmarshaller instanceof UnMarshallerDecorator) { payload = ((UnMarshallerDecorator) unmarshaller).removeDecoration(payload); } else { ByteArrayInputStream is = null; if (rmiOnewayMarshalling) { // Legacy treatment, pre 2.4.0 ByteArrayOutputStream baos = new ByteArrayOutputStream(); SerializationManager manager = SerializationStreamFactory.getManagerInstance(getSerializationType()); ObjectOutputStream oos = manager.createOutput(baos); writeObject(oos, payload); oos.flush(); oos.close(); is = new ByteArrayInputStream(baos.toByteArray()); } else { is = new ByteArrayInputStream((byte[]) payload); } try { if (unmarshaller instanceof VersionedUnMarshaller) { payload = ((VersionedUnMarshaller) unmarshaller).read(is, null, getVersion()); is.close(); } else { payload = unmarshaller.read(is, null); is.close(); } } catch(ClassNotFoundException e) { log.debug("Could not unmarshall invocation request" + payload, e); throw new IOException(e.getMessage()); } } } if (payload instanceof InvocationRequest) { InvocationRequest ir = (InvocationRequest) payload; Map metadata = ir.getRequestPayload(); if (metadata == null) { metadata = new HashMap(); ir.setRequestPayload(metadata); } try { String clientHost = RemoteServer.getClientHost(); InetAddress clientAddress = getAddressByName(clientHost); metadata.put(Remoting.CLIENT_ADDRESS, clientAddress); } catch (ServerNotActiveException e) { throw new RemoteException(e.getMessage()); } } Object response = invoke(payload); if(marshaller != null && !(marshaller instanceof RMIMarshaller) && !rmiOnewayMarshalling) { if(marshaller instanceof MarshallerDecorator) { response = ((MarshallerDecorator) marshaller).addDecoration(response); } else { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); if (marshaller instanceof VersionedMarshaller) ((VersionedMarshaller) marshaller).write(response, byteOut, getVersion()); else marshaller.write(response, byteOut); byteOut.close(); response = byteOut.toByteArray(); } } return response; } public boolean isRmiOnewayMarshalling() { return rmiOnewayMarshalling; } public void setRmiOnewayMarshalling(boolean rmiOnewayMarshalling) { this.rmiOnewayMarshalling = rmiOnewayMarshalling; } static private ClassLoader getClassLoader(final Class c) { if (SecurityUtility.skipAccessControl()) { return c.getClassLoader(); } return (ClassLoader)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return c.getClassLoader(); } }); } static private void mapJavaBeanProperties(final Object o, final Properties props, final boolean isStrict) throws IntrospectionException { if (SecurityUtility.skipAccessControl()) { PropertyEditors.mapJavaBeanProperties(o, props, isStrict); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IntrospectionException { PropertyEditors.mapJavaBeanProperties(o, props, isStrict); return null; } }); } catch (PrivilegedActionException e) { throw (IntrospectionException) e.getCause(); } } static private void writeObject(final ObjectOutputStream oos, final Object o) throws IOException { if (SecurityUtility.skipAccessControl() || !(oos instanceof JBossObjectOutputStream)) { oos.writeObject(o); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { oos.writeObject(o); return null; } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof IOException) throw (IOException) cause; else throw (RuntimeException) cause; } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } static private Registry createRegistry(final int port) throws RemoteException { if (SecurityUtility.skipAccessControl()) { return LocateRegistry.createRegistry(port); } try { return (Registry) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws RemoteException { return LocateRegistry.createRegistry(port); } }); } catch (PrivilegedActionException e) { throw (RemoteException) e.getCause(); } } static private Remote exportObject(final Remote object, final int port, final RMIClientSocketFactory csf, final RMIServerSocketFactory ssf) throws RemoteException { if (SecurityUtility.skipAccessControl()) { return UnicastRemoteObject.exportObject(object, port, csf, ssf); } try { return (Remote) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws RemoteException { return UnicastRemoteObject.exportObject(object, port, csf, ssf); } }); } catch (PrivilegedActionException e) { throw (RemoteException) e.getCause(); } } static private Registry getRegistry(final int port) throws RemoteException { if (SecurityUtility.skipAccessControl()) { return LocateRegistry.getRegistry(port); } try { return (Registry) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws RemoteException { return LocateRegistry.getRegistry(port); } }); } catch (PrivilegedActionException e) { throw (RemoteException) e.getCause(); } } static private void rebind(final Registry registry, final String name, final Remote object) throws IOException { if (SecurityUtility.skipAccessControl()) { registry.rebind(name, object); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { registry.rebind(name, object); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private void unbind(final Registry registry, final String name) throws AccessException, RemoteException, NotBoundException { if (SecurityUtility.skipAccessControl()) { registry.unbind(name); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws AccessException, RemoteException, NotBoundException { registry.unbind(name); return null; } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof AccessException) throw (AccessException) cause; else if (cause instanceof RemoteException) throw (RemoteException) cause; else throw (NotBoundException) cause; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/0000755000175000017500000000000011632407050030160 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/SocketWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/SocketWrapper.jav0000644000175000017500000001057111173727500033464 0ustar twernertwerner/* * 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.remoting.transport.socket; import org.jboss.logging.Logger; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.net.SocketException; /** * @author Tom Elrod */ public abstract class SocketWrapper { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(SocketWrapper.class); public static final String MARSHALLER = "marshaller"; public static final String UNMARSHALLER = "unmarshaller"; public static final String TEMP_TIMEOUT = "temptimeout"; public static final String WRITE_TIMEOUT = "writeTimeout"; protected static final int CLOSING = 254; // Static --------------------------------------------------------------------------------------- private static boolean trace = log.isTraceEnabled(); // Attributes ----------------------------------------------------------------------------------- protected Socket socket; private int timeout; // Constructors --------------------------------------------------------------------------------- protected SocketWrapper(Socket socket) { if (trace) { log.trace("constructing " + getClass().getName() + " instance for " + socket); } this.socket = socket; } protected SocketWrapper(Socket socket, Integer timeoutInt) throws SocketException { if (trace) { log.trace("constructing " + getClass().getName() + " instance for " + socket + ", using timeout " + timeoutInt); } this.socket = socket; if(timeoutInt != null) { this.timeout = timeoutInt.intValue(); setTimeout(this.timeout); } } // Public --------------------------------------------------------------------------------------- public void setTimeout(int timeout) throws SocketException { if (trace) { log.trace(this + " setting timeout to " + timeout); } this.timeout = timeout; if(socket != null) { socket.setSoTimeout(timeout); } } public int getTimeout() { return timeout; } public void close() throws IOException { if(socket != null) { log.trace(this + " closing socket"); socket.close(); log.trace(this + " closed socket"); } } public boolean isClosed() { if (socket == null) return false; return socket.isClosed(); } public Socket getSocket() { return socket; } public abstract OutputStream getOutputStream() throws IOException; public abstract InputStream getInputStream() throws IOException; public abstract void checkConnection() throws IOException; // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected void finalize() { if(socket != null) { try { socket.close(); } catch(Exception e) { log.debug(this + " failed to close socket", e); } } } // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/ClientSocketWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/ClientSocketWrapp0000644000175000017500000001700011173727175033517 0ustar twernertwerner/* * 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.remoting.transport.socket; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.util.Map; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.PreferredStreamMarshaller; import org.jboss.remoting.marshal.PreferredStreamUnMarshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.logging.Logger; /** * @author Tom Elrod */ public class ClientSocketWrapper extends SocketWrapper implements OpenConnectionChecker { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(ClientSocketWrapper.class); // Static --------------------------------------------------------------------------------------- private static boolean trace = log.isTraceEnabled(); // Attributes ----------------------------------------------------------------------------------- private InputStream in; private OutputStream out; private int writeTimeout = -1; // Constructors --------------------------------------------------------------------------------- public ClientSocketWrapper(Socket socket) throws IOException { super(socket); createStreams(socket, null); } public ClientSocketWrapper(Socket socket, Map metadata, Integer timeout) throws Exception { super(socket, timeout); createStreams(socket, metadata); } // SocketWrapper overrides ---------------------------------------------------------------------- public OutputStream getOutputStream() { return out; } public InputStream getInputStream() { return in; } public int getWriteTimeout() { return writeTimeout; } public void setWriteTimeout(int writeTimeout) { this.writeTimeout = writeTimeout; } public void checkConnection() throws IOException { // Test to see if socket is alive by send ACK message final byte ACK = 1; // out.reset(); // out.writeByte(ACK); // out.flush(); // in.readByte(); out.write(ACK); out.flush(); int i = in.read(); if (trace) { log.trace(this + " got " + i + " while checking connection"); } } // OpenConnectionChecker implementation --------------------------------------------------------- public void checkOpenConnection() throws IOException { if (trace) log.trace("checking open connection"); if (in.available() > 1) { log.trace("remote endpoint has closed"); throw new IOException("remote endpoint has closed"); } } // Public --------------------------------------------------------------------------------------- public String toString() { Socket socket = getSocket(); return "ClientSocketWrapper[" + socket + "." + Integer.toHexString(System.identityHashCode(socket)) + "]"; } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected void createStreams(Socket socket, Map metadata) throws IOException { String serializationType = "java"; // hardcoding to default to java serialization if(metadata != null) { String serializationTypeParam = (String) metadata.get(InvokerLocator.SERIALIZATIONTYPE); if(serializationTypeParam == null || serializationTypeParam.length() == 0) { serializationTypeParam = (String) metadata.get(InvokerLocator.SERIALIZATIONTYPE_CASED); } if(serializationTypeParam != null && serializationTypeParam.length() > 0) { serializationType = serializationTypeParam; } } Marshaller marshaller = null; UnMarshaller unmarshaller = null; int tempTimeout = -1; int savedTimeout = getTimeout(); if (metadata != null) { marshaller = (Marshaller) metadata.get(MARSHALLER); unmarshaller = (UnMarshaller) metadata.get(UNMARSHALLER); Object o = metadata.get(TEMP_TIMEOUT); if (o instanceof Integer) { tempTimeout = ((Integer) o).intValue(); if (tempTimeout != -1) { socket.setSoTimeout(tempTimeout); log.trace("set temp timeout to: " + tempTimeout); } } o = metadata.get(WRITE_TIMEOUT); if (o instanceof Integer) { writeTimeout = ((Integer) o).intValue(); if (writeTimeout != -1) { log.trace("set writeTimeout to: " + writeTimeout); } } } out = createOutputStream(serializationType, socket, marshaller); in = createInputStream(serializationType, socket, unmarshaller); setTimeout(savedTimeout); log.trace("reset timeout: " + savedTimeout); } protected InputStream createInputStream(String serializationType, Socket socket, UnMarshaller unmarshaller) throws IOException { if (trace) { log.trace(this + " getting input stream from " + socket + ", " + unmarshaller); } if (unmarshaller == null) log.warn("got null unmarshaller"); InputStream is = socket.getInputStream(); if (unmarshaller instanceof PreferredStreamUnMarshaller) { PreferredStreamUnMarshaller psum = (PreferredStreamUnMarshaller) unmarshaller; is = psum.getMarshallingStream(is); } return is; } protected OutputStream createOutputStream(String serializationType, Socket socket, Marshaller marshaller) throws IOException { if (trace) { log.trace(this + " getting output stream from " + socket + ", " + marshaller); } if (marshaller == null) log.warn("got null marshaller"); OutputStream os = socket.getOutputStream(); if (writeTimeout > 0) { os = new TimedOutputStream(os, writeTimeout); } if (marshaller instanceof PreferredStreamMarshaller) { PreferredStreamMarshaller psm = (PreferredStreamMarshaller) marshaller; os = psm.getMarshallingStream(os); } return os; } // Private -------------------------------------------------------------------------------------- // Inner classes -------------------------------------------------------------------------------- } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/LRUPool.java0000644000175000017500000000532710735350176032337 0ustar twernertwerner/* * 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.remoting.transport.socket; import java.util.ArrayList; import java.util.Set; import org.jboss.util.LRUCachePolicy; /** * This class is an extention of LRUCachePolicy. On a entry removal * it makes sure to call shutdown on the pooled ServerThread * * @author Bill Burke */ public class LRUPool extends LRUCachePolicy { private Object needEvictionLock = new Object(); private boolean needEviction; public LRUPool(int min, int max) { super(min, max); } protected void entryRemoved(LRUCacheEntry entry) { ServerThread thread = (ServerThread) entry.m_object; thread.evict(); } /** * Will evict oldest ServerThread that allows itself to be evicted. */ public void evict() { // the entry will be removed by ageOut LRUCacheEntry entry = m_list.m_tail; while (entry != null) { ServerThread thread = (ServerThread) entry.m_object; if (thread.evict()) { return; } entry = entry.m_prev; } synchronized (needEvictionLock) { needEviction = true; } } public Set getContents() { return m_map.keySet(); } public ArrayList getContentsByAscendingAge() { ArrayList list = new ArrayList(size()); LRUCacheEntry entry = m_list.m_head; while (entry != null) { list.add(entry.m_object); entry = entry.m_next; } return list; } public boolean getEvictionNeeded() { synchronized (needEvictionLock) { boolean answer = needEviction; needEviction = false; return answer; } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/MicroSocketClient0000644000175000017500000012631711253550746033510 0ustar twernertwernerpackage org.jboss.remoting.transport.socket; import org.jboss.logging.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.Home; import org.jboss.remoting.InvocationFailureException; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.RemoteClientInvoker; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.Version; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.util.SecurityUtility; import org.jboss.remoting.invocation.OnewayInvocation; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.util.propertyeditor.PropertyEditors; import java.beans.IntrospectionException; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Constructor; import java.net.InetAddress; import java.net.Socket; import java.net.InetSocketAddress; import java.net.SocketException; import java.net.UnknownHostException; import java.rmi.MarshalException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.regex.Pattern; import EDU.oswego.cs.dl.util.concurrent.Semaphore; /** * SocketClientInvoker uses Sockets to remotely connect to the a remote ServerInvoker, which must be * a SocketServerInvoker. * * @author Jeff Haynie * @author Tom Elrod * @author Ovidiu Feodorov * * @version $Revision: 5476 $ */ public class MicroSocketClientInvoker extends RemoteClientInvoker { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(MicroSocketClientInvoker.class); /** * Can be either true or false and will indicate if client socket should have TCP_NODELAY turned * on or off. TCP_NODELAY is for a specific purpose; to disable the Nagle buffering algorithm. * It should only be set for applications that send frequent small bursts of information without * getting an immediate response; where timely delivery of data is required (the canonical * example is mouse movements). The default is false. */ public static final String TCP_NODELAY_FLAG = "enableTcpNoDelay"; /** * The client side maximum number of threads. The default is MAX_POOL_SIZE. */ public static final String MAX_POOL_SIZE_FLAG = "clientMaxPoolSize"; /** * Specifies the fully qualified class name for the custom SocketWrapper implementation to use on * the client. Note, will need to make sure this is marked as a client parameter (using the * 'isParam' attribute). Making this change will not affect the marshaller/unmarshaller that is * used, which may also be a requirement. */ public static final String CLIENT_SOCKET_CLASS_FLAG = "clientSocketClass"; /** Key for setting timeout used by OnewayConnectionTask */ public static final String ONEWAY_CONNECTION_TIMEOUT = "onewayConnectionTimeout"; /** Key to determine if client side oneway invocations should wait to read version. * See JBREM-706. */ public static final String USE_ONEWAY_CONNECTION_TIMEOUT = "useOnewayConnectionTimeout"; /** Key for setting time to wait to get permission to get a connection */ public static final String CONNECTION_WAIT = "connectionWait"; /** Key for setting socket write timeout */ public static final String WRITE_TIMEOUT = "writeTimeout"; /** * Default value for enable TCP nodelay. Value is false. */ public static final boolean TCP_NODELAY_DEFAULT = false; /** * Default maximum number of times a invocation will be made when it gets a SocketException. * Default is 3. */ public static final int MAX_CALL_RETRIES = 3; /** * Default maximum number of socket connections allowed at any point in time. Default is 50. */ public static final int MAX_POOL_SIZE = 50; /** Default timeout value used by OnewayConnectionTask. Value is 2 seconds. */ public static final int ONEWAY_CONNECTION_TIMEOUT_DEFAULT = 2000; /** Default time to wait to get permission to get a connection */ public static final int CONNECTION_WAIT_DEFAULT = 30000; // Static --------------------------------------------------------------------------------------- private static boolean trace = log.isTraceEnabled(); /** * Used for debugging (tracing) connections leaks */ static int counter = 0; protected static final Map connectionPools = new HashMap(); protected static final Map semaphores = new HashMap(); // Performance measurements public static long getSocketTime = 0; public static long readTime = 0; public static long writeTime = 0; public static long serializeTime = 0; public static long deserializeTime = 0; private static final String patternString = "^.*(?:connection.*reset|connection.*closed|broken.*pipe).*$"; private static final Pattern RETRIABLE_ERROR_MESSAGE = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE); /** * Close all sockets in a specific pool. */ public static void clearPool(LinkedList thepool) { try { if (thepool == null) { return; } synchronized (thepool) { int size = thepool.size(); for (int i = 0; i < size; i++) { SocketWrapper socketWrapper = (SocketWrapper)thepool.removeFirst(); try { socketWrapper.close(); socketWrapper = null; } catch (Exception ignored) { } } } } catch (Exception ex) { log.debug("Failure", ex); } } /** * Close all sockets in all pools. */ public static void clearPools() { synchronized (connectionPools) { for(Iterator i = connectionPools.keySet().iterator(); i.hasNext();) { ServerAddress sa = (ServerAddress) i.next(); if (trace) { log.trace("clearing pool for " + sa); } clearPool((LinkedList) connectionPools.get(sa)); i.remove(); } semaphores.clear(); } } // Attributes ----------------------------------------------------------------------------------- private Constructor clientSocketConstructor; private boolean reuseAddress; protected InetAddress addr; protected int port; // flag being set on true by a disconnect request. If trying to create a connection goes on in a // loop and a disconnect request arrives, this flag will be used to sent this information into // the connect loop // private volatile boolean bailOut; /** * Indicates if will check the socket connection when getting from pool by sending byte over the * connection to validate is still good. */ protected boolean shouldCheckConnection; /** * If the TcpNoDelay option should be used on the socket. */ protected boolean enableTcpNoDelay; protected String clientSocketClassName; protected Class clientSocketClass; protected int numberOfCallRetries; protected int maxPoolSize; protected int onewayConnectionTimeout; protected boolean useOnewayConnectionTimeout = true; protected int connectionWait = CONNECTION_WAIT_DEFAULT; /** * Pool for this invoker. This is shared between all instances of proxies attached to a specific * invoker. */ protected LinkedList pool; //Semaphore is also shared between all proxies - must 1-1 correspondence between pool and semaphore protected Semaphore semaphore; /** * connection information */ protected ServerAddress address; protected Home home; /** * Socket configuration parameters. */ protected boolean keepAlive; protected boolean keepAliveSet; protected boolean oOBInline; protected boolean oOBInlineSet; protected int receiveBufferSize = - 1; protected int sendBufferSize = -1; protected boolean soLinger; protected boolean soLingerSet; protected int soLingerDuration = -1; protected int trafficClass = -1; /** * If true, an IOException with message such as "Connection reset by peer: socket write error" will * be treated like a SocketException. */ protected boolean generalizeSocketException; protected int writeTimeout = -1; // Constructors --------------------------------------------------------------------------------- public MicroSocketClientInvoker(InvokerLocator locator) { this(locator, null); } public MicroSocketClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); clientSocketConstructor = null; reuseAddress = true; shouldCheckConnection = false; enableTcpNoDelay = TCP_NODELAY_DEFAULT; clientSocketClassName = ClientSocketWrapper.class.getName(); clientSocketClass = null; numberOfCallRetries = MAX_CALL_RETRIES; pool = null; maxPoolSize = MAX_POOL_SIZE; onewayConnectionTimeout = ONEWAY_CONNECTION_TIMEOUT_DEFAULT; try { setup(); } catch (Exception ex) { log.debug("Error setting up " + this, ex); throw new RuntimeException(ex.getMessage(), ex); } log.debug(this + " constructed"); } // Public --------------------------------------------------------------------------------------- /** * Indicates if will check socket connection when returning from pool by sending byte to the * server. Default value will be false. */ public boolean checkingConnection() { return shouldCheckConnection; } /** * Returns if newly created sockets will have SO_REUSEADDR enabled. Default is for this to be * true. */ public boolean getReuseAddress() { return reuseAddress; } /** * Sets if newly created socket should have SO_REUSEADDR enable. Default is true. */ public void setReuseAddress(boolean reuse) { reuseAddress = reuse; } public boolean isKeepAlive() { return keepAlive; } public void setKeepAlive(boolean keepAlive) { this.keepAlive = keepAlive; keepAliveSet = true; } public boolean isOOBInline() { return oOBInline; } public void setOOBInline(boolean inline) { oOBInline = inline; oOBInlineSet = true; } public int getReceiveBufferSize() { return receiveBufferSize; } public void setReceiveBufferSize(int receiveBufferSize) { this.receiveBufferSize = receiveBufferSize; } public int getSendBufferSize() { return sendBufferSize; } public void setSendBufferSize(int sendBufferSize) { this.sendBufferSize = sendBufferSize; } public boolean isSoLinger() { return soLinger; } public int getSoLingerDuration() { return soLingerDuration; } public void setSoLinger(boolean soLinger) { this.soLinger = soLinger; soLingerSet = true; } public void setSoLingerDuration(int soLingerDuration) { this.soLingerDuration = soLingerDuration; } public int getTrafficClass() { return trafficClass; } public void setTrafficClass(int trafficClass) { this.trafficClass = trafficClass; } public int getWriteTimeout() { return writeTimeout; } public void setWriteTimeout(int writeTimeout) { this.writeTimeout = writeTimeout; } public boolean isGeneralizeSocketException() { return generalizeSocketException; } public void setGeneralizeSocketException(boolean generalizeSocketException) { this.generalizeSocketException = generalizeSocketException; } public synchronized void disconnect() { log.debug(this + " disconnecting ..."); // bailOut = true; super.disconnect(); } public void flushConnectionPool() { synchronized (pool) { while (pool != null && pool.size() > 0) { SocketWrapper socketWrapper = (SocketWrapper)pool.removeFirst(); try { socketWrapper.close(); } catch (IOException e) { log.debug("Failed to close socket wrapper", e); } } } } public int getConnectionWait() { return connectionWait; } public void setConnectionWait(int connectionWait) { this.connectionWait = connectionWait; } public Home getHomeInUse() { return home; } /** * Sets the number of times an invocation will retry based on getting SocketException. */ public void setNumberOfCallRetries(int numberOfCallRetries) { if (numberOfCallRetries < 1) { this.numberOfCallRetries = MAX_CALL_RETRIES; } else { this.numberOfCallRetries = numberOfCallRetries; } } public int getNumberOfCallRetries() { return numberOfCallRetries; } /** * Sets the number of retries to get a socket connection. * * @param numberOfRetries Must be a number greater than 0. */ public void setNumberOfRetries(int numberOfRetries) { log.warn("numberOfRetries is no longer used"); } public int getNumberOfRetries() { log.warn("numberOfRetries is no longer used"); return -1; } /** * The name of of the server. */ public String getServerHostName() throws Exception { return address.address; } public int getNumberOfUsedConnections() { if (semaphore == null) return 0; return maxPoolSize - (int) semaphore.permits(); } public int getNumberOfAvailableConnections() { if (semaphore == null) return 0; return (int) semaphore.permits(); } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected void setup() throws Exception { Properties props = new Properties(); props.putAll(configuration); mapJavaBeanProperties(MicroSocketClientInvoker.this, props, false); configureParameters(); if (!InvokerLocator.MULTIHOME.equals(locator.getHost())) { addr = getAddressByName(locator.getHost()); port = locator.getPort(); address = createServerAddress(addr, port); } else { List homes = locator.getConnectHomeList(); if (homes.size() == 1) { // Treat as in non MULTIHOME case. Home home = (Home) homes.iterator().next(); addr = getAddressByName(home.host); address = createServerAddress(addr, home.port); } } } protected void configureParameters() { Map params = configuration; if (params == null) { return; } // look for enableTcpNoDelay param Object val = params.get(TCP_NODELAY_FLAG); if (val != null) { try { enableTcpNoDelay = Boolean.valueOf((String)val).booleanValue(); log.debug(this + " setting enableTcpNoDelay to " + enableTcpNoDelay); } catch (Exception e) { log.warn(this + " could not convert " + TCP_NODELAY_FLAG + " value of " + val + " to a boolean value."); } } // look for maxPoolSize param val = params.get(MAX_POOL_SIZE_FLAG); if (val != null) { try { maxPoolSize = Integer.valueOf((String)val).intValue(); log.debug(this + " setting maxPoolSize to " + maxPoolSize); } catch (Exception e) { log.warn(this + " could not convert " + MAX_POOL_SIZE_FLAG + " value of " + val + " to a int value"); } } // look for client socket class name val = params.get(CLIENT_SOCKET_CLASS_FLAG); if (val != null) { String value = (String)val; if (value.length() > 0) { clientSocketClassName = value; log.debug(this + " setting client socket wrapper class name to " + clientSocketClassName); } } val = params.get(SocketServerInvoker.CHECK_CONNECTION_KEY); if (val != null && ((String)val).length() > 0) { String value = (String) val; shouldCheckConnection = Boolean.valueOf(value).booleanValue(); log.debug(this + " setting shouldCheckConnection to " + shouldCheckConnection); } else if (getVersion() == Version.VERSION_1) { shouldCheckConnection = true; log.debug(this + " setting shouldCheckConnection to " + shouldCheckConnection); } // look for onewayConnectionTimeout param val = params.get(ONEWAY_CONNECTION_TIMEOUT); if (val != null) { try { onewayConnectionTimeout = Integer.valueOf((String)val).intValue(); log.debug(this + " setting onewayConnectionTimeout to " + onewayConnectionTimeout); } catch (Exception e) { log.warn(this + " could not convert " + ONEWAY_CONNECTION_TIMEOUT + " value of " + val + " to an int value"); } } // look for useOnewayConnectionTimeout param val = params.get(USE_ONEWAY_CONNECTION_TIMEOUT); if (val != null) { try { useOnewayConnectionTimeout = Boolean.valueOf((String)val).booleanValue(); log.debug(this + " setting useOnewayConnectionTimeout to " + useOnewayConnectionTimeout); } catch (Exception e) { log.warn(this + " could not convert " + USE_ONEWAY_CONNECTION_TIMEOUT + " value of " + val + " to a boolean value"); } } // look for writeTimeout param val = params.get(WRITE_TIMEOUT); if (val != null) { try { writeTimeout = Integer.valueOf((String)val).intValue(); log.debug(this + " setting writeTimeout to " + writeTimeout); } catch (Exception e) { log.warn(this + " could not convert " + WRITE_TIMEOUT + " value of " + val + " to an int value"); } } } protected ServerAddress createServerAddress(InetAddress addr, int port) { return new ServerAddress(addr.getHostAddress(), port, enableTcpNoDelay, -1, maxPoolSize); } protected void finalize() throws Throwable { disconnect(); super.finalize(); } protected synchronized void handleConnect() throws ConnectionFailedException { initPool(); if (InvokerLocator.MULTIHOME.equals(locator.getHost())) { home = getUsableAddress(locator); if (home == null) { throw new ConnectionFailedException(this + " unable to find a usable address for: " + home); } locator.setHomeInUse(home); } else { home = new Home(locator.getHost(), locator.getPort()); } } protected Home getUsableAddress(InvokerLocator locator) { List homes = getConnectHomes(); Iterator it = homes.iterator(); Home home = null; while (it.hasNext()) { try { home = (Home) it.next(); addr = getAddressByName(home.host); address = createServerAddress(addr, home.port); invoke(new InvocationRequest(null, null, ServerInvoker.ECHO, null, null, null)); if (trace) log.trace(this + " able to contact server at: " + home); return home; } catch (Throwable e) { log.debug(this + " unable to contact server at: " + home); } } return null; } protected synchronized void handleDisconnect() { clearPools(); clearPool(pool); } /** * Each implementation of the remote client invoker should have a default data type that is used * in the case it is not specified in the invoker locator URI. */ protected String getDefaultDataType() { return SerializableMarshaller.DATATYPE; } protected Object transport(String sessionID, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller) throws IOException, ConnectionFailedException, ClassNotFoundException { SocketWrapper socketWrapper = null; Object response = null; boolean oneway = false; // tempTimeout < 0 will indicate there is no per invocation timeout. int tempTimeout = -1; int timeLeft = -1; int savedTimeout = -1; long start = -1; if(metadata != null) { // check to see if is one way invocation and return after writing invocation if is Object val = metadata.get(org.jboss.remoting.Client.ONEWAY_FLAG); if(val != null && val instanceof String && Boolean.valueOf((String)val).booleanValue()) { oneway = true; } // look for temporary timeout values String tempTimeoutString = (String) metadata.get(ServerInvoker.TIMEOUT); { if (tempTimeoutString != null) { try { tempTimeout = Integer.valueOf(tempTimeoutString).intValue(); log.debug(this + " setting timeout to " + tempTimeout + " for this invocation"); } catch (Exception e) { log.warn(this + " could not convert " + ServerInvoker.TIMEOUT + " value of " + tempTimeoutString + " to an integer value."); } } } } if (tempTimeout >= 0) { start = System.currentTimeMillis(); } boolean serverSideOneway = false; if (oneway && invocation instanceof InvocationRequest) { InvocationRequest ir = (InvocationRequest) invocation; if (ir.getParameter() instanceof OnewayInvocation) serverSideOneway = true; } int retryCount = 0; Exception sockEx = null; for (; retryCount < numberOfCallRetries; retryCount++) { if (trace) log.trace(this + " retryCount: " + retryCount); if (0 < tempTimeout) { // If a per invocation timeout has been set, the time spent retrying // should count toward the elapsed time. timeLeft = (int) (tempTimeout - (System.currentTimeMillis() - start)); if (timeLeft <= 0) break; } try { boolean tryPool = retryCount < (numberOfCallRetries - 1) || maxPoolSize == 1 || numberOfCallRetries == 1; socketWrapper = getConnection(marshaller, unmarshaller, tryPool, timeLeft); log.trace(this + " got socketWrapper: " + socketWrapper); } catch (InterruptedException e) { semaphore.release(); if (trace) log.trace(this + " released semaphore: " + semaphore.permits(), e); throw new RuntimeException(e); } catch (Exception e) { // if (bailOut) // return null; semaphore.release(); if (trace) log.trace(this + " released semaphore: " + semaphore.permits(), e); sockEx = new CannotConnectException( "Can not get connection to server. Problem establishing " + "socket connection for " + locator, e); continue; } if (tempTimeout >= 0) { timeLeft = (int) (tempTimeout - (System.currentTimeMillis() - start)); if (timeLeft <= 0) break; savedTimeout = socketWrapper.getTimeout(); socketWrapper.setTimeout(timeLeft); } try { int version = getVersion(); boolean performVersioning = Version.performVersioning(version); OutputStream outputStream = socketWrapper.getOutputStream(); log.trace(this + "got outputStream: " + outputStream); if (performVersioning) { log.trace(this + " writing version"); writeVersion(outputStream, version); log.trace(this + " wrote version"); } //TODO: -TME so this is messed up as now ties remoting versioning to using a marshaller type versionedWrite(outputStream, marshaller, invocation, version); if (serverSideOneway) { if(trace) { log.trace(this + " sent oneway invocation, so not waiting for response, returning null"); } } else if (oneway) { if (performVersioning && useOnewayConnectionTimeout) { int onewaySavedTimeout = socketWrapper.getTimeout(); socketWrapper.setTimeout(onewayConnectionTimeout); InputStream inputStream = socketWrapper.getInputStream(); version = readVersion(inputStream); if (version == -1) { throw new EOFException("end of file"); } if (version == SocketWrapper.CLOSING) { log.trace(this + " received version 254: treating as end of file"); throw new EOFException("end of file"); } // Note that if an exception is thrown, the socket is thrown away, // so there's no need to reset the timeout value. socketWrapper.setTimeout(onewaySavedTimeout); } } else { InputStream inputStream = socketWrapper.getInputStream(); if (performVersioning) { version = readVersion(inputStream); if (version == -1) { throw new EOFException("end of file"); } if (version == SocketWrapper.CLOSING) { log.trace(this + " received version 254: treating as end of file"); throw new EOFException("end of file"); } } response = versionedRead(inputStream, unmarshaller, version); } // Note that resetting the timeout value after closing the socket results // in an exception, so the reset is not done in a finally clause. However, // if a catch clause is ever added that does not close the socket, care // must be taken to reset the timeout in that case. if (tempTimeout >= 0) { socketWrapper.setTimeout(savedTimeout); } } catch (SocketException sex) { handleRetriableException(socketWrapper, sex, retryCount); sockEx = sex; continue; } catch (EOFException ex) { handleRetriableException(socketWrapper, ex, retryCount); sockEx = ex; continue; } catch (IOException e) { if (isGeneralizeSocketException() && e.getMessage() != null && RETRIABLE_ERROR_MESSAGE.matcher(e.getMessage()).matches()) { handleRetriableException(socketWrapper, e, retryCount); sockEx = new SocketException(e.getMessage()); continue; } else { return handleOtherException(e, semaphore, socketWrapper, oneway); } } catch (Exception ex) { return handleOtherException(ex, semaphore, socketWrapper, oneway); } // call worked, so no need to retry break; } // need to check if ran out of retries if (retryCount >= numberOfCallRetries) { handleException(sockEx, socketWrapper); } if (response == null && tempTimeout > 0 && timeLeft <= 0) { if (sockEx == null) { sockEx = new CannotConnectException( "Can not get connection to server. Timed out establishing " + "socket connection for " + locator); } handleException(sockEx, socketWrapper); } // Put socket back in pool for reuse synchronized (pool) { if (pool.size() < maxPoolSize) { pool.add(socketWrapper); if (trace) { log.trace(this + " returned " + socketWrapper + " to pool"); } } else { if (trace) { log.trace(this + "'s pool is full, will close the connection"); } try { socketWrapper.close(); } catch (Exception ignored) { } } semaphore.release(); if (trace) log.trace(this + " released semaphore: " + semaphore.permits()); } if (trace && !oneway) { log.trace(this + " received response " + response); } return response; } protected Object handleException(Exception ex, SocketWrapper socketWrapper) throws ClassNotFoundException, InvocationFailureException { if (ex instanceof ClassNotFoundException) { //TODO: -TME Add better exception handling for class not found exception log.debug("Error loading classes from remote call result.", ex); throw (ClassNotFoundException)ex; } if (ex instanceof CannotConnectException) { log.debug(this, ex); throw (CannotConnectException) ex; } if (ex instanceof InterruptedException) { log.debug(this, ex); throw new RuntimeException(ex); } throw new InvocationFailureException("Unable to perform invocation", ex); } protected void handleRetriableException(SocketWrapper socketWrapper, Exception e, int retryCount) { if (trace) log.trace(this + "(" + socketWrapper + ") got Exception: " + e); try { semaphore.release(); if (trace) log.trace(this + " released semaphore: " + semaphore.permits()); socketWrapper.close(); } catch (Exception ex) { if (trace) { log.trace(this + " couldn't successfully close its socketWrapper", ex); } } /** * About to run out of retries and * pool may be full of timed out sockets, * so want to flush the pool and try with * fresh socket as a last effort. */ if (retryCount == (numberOfCallRetries - 2)) { flushConnectionPool(); } if (trace) { if (retryCount < (numberOfCallRetries - 1)) { log.trace(this + " will try again, retries: " + retryCount + " < " + numberOfCallRetries); } else { log.trace(this + " retries exhausted"); } } } protected Object handleOtherException(Exception ex, Semaphore semaphore, SocketWrapper socketWrapper, boolean oneway) throws ClassNotFoundException, InvocationFailureException { log.debug(this + " got exception: " + socketWrapper, ex); try { semaphore.release(); if (trace) log.trace(this + " released semaphore: " + semaphore.permits()); socketWrapper.close(); } catch (Exception ignored) { } if (oneway) return null; else return handleException(ex, socketWrapper); } protected void initPool() { synchronized (connectionPools) { pool = (LinkedList)connectionPools.get(address); semaphore = (Semaphore)semaphores.get(address); if (pool == null) { pool = new LinkedList(); connectionPools.put(address, pool); log.debug("Creating semaphore with size " + maxPoolSize); semaphore = new Semaphore(maxPoolSize); semaphores.put(address, semaphore); if (trace) { synchronized (pool) { log.trace(this + " added new pool (" + pool + ") as " + address); } } } else { if (trace) { synchronized (pool) { log.trace(this + " using pool (" + pool + ") already defined for " + address); } } } } } protected SocketWrapper getConnection(Marshaller marshaller, UnMarshaller unmarshaller, boolean tryPool, int timeAllowed) throws Exception { long start = System.currentTimeMillis(); long timeToWait = (timeAllowed > 0) ? timeAllowed : connectionWait; boolean timedout = !semaphore.attempt(timeToWait); if (trace) log.trace(this + " obtained semaphore: " + semaphore.permits()); if (timedout) { throw new IllegalStateException("Timeout waiting for a free socket"); } SocketWrapper pooled = null; if (tryPool) { synchronized (pool) { // if connection within pool, use it if (pool.size() > 0) { pooled = getPooledConnection(); if (trace) log.trace(this + " reusing pooled connection: " + pooled); } } } else { if (trace) log.trace(this + " avoiding connection pool, creating new socket"); } if (pooled == null) { //Need to create a new one Socket socket = null; if (trace) { log.trace(this + " creating socket "); } // timeAllowed < 0 indicates no per invocation timeout has been set. int timeRemaining = -1; if (0 <= timeAllowed) { timeRemaining = (int) (timeAllowed - (System.currentTimeMillis() - start)); } socket = createSocket(address.address, address.port, timeRemaining); if (trace) log.trace(this + " created socket: " + socket); socket.setTcpNoDelay(address.enableTcpNoDelay); Map metadata = getLocator().getParameters(); if (metadata == null) { metadata = new HashMap(2); } else { metadata = new HashMap(metadata); } metadata.put(SocketWrapper.MARSHALLER, marshaller); metadata.put(SocketWrapper.UNMARSHALLER, unmarshaller); if (writeTimeout > 0) { metadata.put(SocketWrapper.WRITE_TIMEOUT, new Integer(writeTimeout)); } if (timeAllowed > 0) { timeRemaining = (int) (timeAllowed - (System.currentTimeMillis() - start)); if (timeRemaining <= 0) throw new IllegalStateException("Timeout creating a new socket"); metadata.put(SocketWrapper.TEMP_TIMEOUT, new Integer(timeRemaining)); } pooled = createClientSocket(socket, address.timeout, metadata); } return pooled; } protected SocketWrapper createClientSocket(Socket socket, int timeout, Map metadata) throws Exception { if (clientSocketConstructor == null) { if(clientSocketClass == null) { clientSocketClass = ClassLoaderUtility.loadClass(clientSocketClassName, getClass()); } Class[] args = new Class[]{Socket.class, Map.class, Integer.class}; clientSocketConstructor = clientSocketClass.getConstructor(args); } SocketWrapper clientSocketWrapper = null; clientSocketWrapper = (SocketWrapper)clientSocketConstructor. newInstance(new Object[]{socket, metadata, new Integer(timeout)}); return clientSocketWrapper; } protected Socket createSocket(String address, int port, int timeout) throws IOException { Socket s = new Socket(); configureSocket(s); InetSocketAddress inetAddr = new InetSocketAddress(address, port); connect(s, inetAddr); return s; } protected void configureSocket(Socket s) throws SocketException { s.setReuseAddress(getReuseAddress()); if (keepAliveSet) s.setKeepAlive(keepAlive); if (oOBInlineSet) s.setOOBInline(oOBInline); if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize); if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize); if (soLingerSet && soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration); if (trafficClass > -1) s.setTrafficClass(trafficClass); } protected SocketWrapper getPooledConnection() { SocketWrapper socketWrapper = null; while (pool.size() > 0) { socketWrapper = (SocketWrapper)pool.removeFirst(); try { if (socketWrapper != null) { if (socketWrapper instanceof OpenConnectionChecker) { ((OpenConnectionChecker) socketWrapper).checkOpenConnection(); } if (shouldCheckConnection) { socketWrapper.checkConnection(); return socketWrapper; } else { return socketWrapper; } } } catch (Exception ex) { if (trace) { log.trace(this + " couldn't reuse connection from pool"); } try { socketWrapper.close(); } catch (Exception e) { log.debug("Failed to close socket wrapper", e); } } } return null; } // Private -------------------------------------------------------------------------------------- private Object versionedRead(InputStream inputStream, UnMarshaller unmarshaller, int version) throws IOException, ClassNotFoundException { //TODO: -TME - is switch required? switch (version) { case Version.VERSION_1: case Version.VERSION_2: case Version.VERSION_2_2: { if (trace) { log.trace(this + " reading response from unmarshaller"); } if (unmarshaller instanceof VersionedUnMarshaller) return((VersionedUnMarshaller)unmarshaller).read(inputStream, null, version); else return unmarshaller.read(inputStream, null); } default: { throw new IOException("Can not read data for version " + version + ". " + "Supported versions: " + Version.VERSION_1 + ", " + Version.VERSION_2 + ", " + Version.VERSION_2_2); } } } private void versionedWrite(OutputStream outputStream, Marshaller marshaller, Object invocation, int version) throws IOException { //TODO: -TME Should I worry about checking the version here? Only one way to do it at this point switch (version) { case Version.VERSION_1: case Version.VERSION_2: case Version.VERSION_2_2: { if (trace) { log.trace(this + " writing invocation to marshaller"); } if (marshaller instanceof VersionedMarshaller) ((VersionedMarshaller) marshaller).write(invocation, outputStream, version); else marshaller.write(invocation, outputStream); if (trace) { log.trace(this + " done writing invocation to marshaller"); } return; } default: { throw new IOException("Can not write data for version " + version + ". " + "Supported versions: " + Version.VERSION_1 + ", " + Version.VERSION_2 + ", " + Version.VERSION_2_2); } } } //TODO: -TME Exact same method in ServerThread private int readVersion(InputStream inputStream) throws IOException { if (trace) { log.trace(this + " reading version from input stream"); } int version = inputStream.read(); if (trace) { log.trace(this + " read version " + version + " from input stream"); } return version; } //TODO: -TME Exact same method in ServerThread private void writeVersion(OutputStream outputStream, int version) throws IOException { if (trace) { log.trace(this + " writing version " + version + " on output stream"); } outputStream.write(version); } static private void mapJavaBeanProperties(final Object o, final Properties props, final boolean isStrict) throws IntrospectionException { if (SecurityUtility.skipAccessControl()) { PropertyEditors.mapJavaBeanProperties(o, props, isStrict); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IntrospectionException { PropertyEditors.mapJavaBeanProperties(o, props, isStrict); return null; } }); } catch (PrivilegedActionException e) { throw (IntrospectionException) e.getCause(); } } static private void connect(final Socket socket, final InetSocketAddress address) throws IOException { if (SecurityUtility.skipAccessControl()) { socket.connect(address); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { socket.connect(address); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } // Inner classes -------------------------------------------------------------------------------- } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/ServerThread.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/ServerThread.java0000644000175000017500000011141711336671614033440 0ustar twernertwerner/* * 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.remoting.transport.socket; import org.jboss.logging.Logger; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvocationResponse; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.Version; import org.jboss.remoting.Client; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.util.SecurityUtility; import org.jboss.remoting.invocation.OnewayInvocation; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.serial.io.JBossObjectInputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.io.OutputStream; import java.lang.reflect.Constructor; import java.net.InetAddress; import java.net.Socket; import java.net.SocketAddress; import java.net.SocketException; import java.net.SocketTimeoutException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; /** * This Thread object hold a single Socket connection to a client * and is kept alive until a timeout happens, or it is aged out of the * SocketServerInvoker's LRU cache. *

          * There is also a separate thread pool that is used if the client disconnects. * This thread/object is re-used in that scenario and that scenario only. *

          * This is a customization of the same ServerThread class used witht the PookedInvoker. * The custimization was made to allow for remoting marshaller/unmarshaller. * * @author Bill Burke * @author Tom Elrod * @author Ovidiu Feodorov * * @version $Revision: 5712 $ */ public class ServerThread extends Thread { // Constants ------------------------------------------------------------------------------------ /** Used to configure period during which ServerThread is not evictable on first * invocation even when in evictable state. */ public static final String EVICTABILITY_TIMEOUT = "evictabilityTimeout"; public static final int EVICTABILITY_TIMEOUT_DEFAULT = 10000; /** Key used to determine if thread should return to threadpool after * SocketTimeoutException */ public static final String CONTINUE_AFTER_TIMEOUT = "continueAfterTimeout"; final static private Logger log = Logger.getLogger(ServerThread.class); // Static --------------------------------------------------------------------------------------- private static boolean trace = log.isTraceEnabled(); private static int idGenerator = 0; public static synchronized int nextID() { return idGenerator++; } private static ClassLoader classLoader = getClassLoader(ServerThread.class); // Attributes ----------------------------------------------------------------------------------- protected volatile boolean running; protected volatile boolean shutdown; protected boolean evictable; protected long enteredEvictable; protected Object evictionLock = new Object(); protected LRUPool clientpool; protected LinkedList threadpool; protected String serverSocketClassName; protected Class serverSocketClass; private Socket socket; private int timeout; private int writeTimeout; protected SocketServerInvoker invoker; private Constructor serverSocketConstructor; protected SocketWrapper socketWrapper; protected Marshaller marshaller; protected UnMarshaller unmarshaller; protected int version; protected boolean performVersioning; // the unique identity of the thread, which won't change during the life of the thread. The // thread may get associated with different IP addresses though. private int id = Integer.MIN_VALUE; // Indicates if will check the socket connection when getting from pool by sending byte over the // connection to validate is still good. private boolean shouldCheckConnection; // Will indicate when the last request has been processed (used in determining idle // connection/thread timeout) private long lastRequestHandledTimestamp = System.currentTimeMillis(); // Used to prevent eviction before first invocation has been completed. private int invocationCount; // Period during which ServerThread is not evictable on first // invocation even when in evictable state. */ private int evictabilityTimeout = EVICTABILITY_TIMEOUT_DEFAULT; private boolean reuseAfterTimeout; private boolean useOnewayConnectionTimeout = true; // Constructors --------------------------------------------------------------------------------- public ServerThread(Socket socket, SocketServerInvoker invoker, LRUPool clientpool, LinkedList threadpool, int timeout, int writeTimeout, String serverSocketClassName) throws Exception { super(); running = true; setName(getWorkerThreadName(socket)); this.socket = socket; this.timeout = timeout; this.writeTimeout = writeTimeout; this.serverSocketClassName = serverSocketClassName; this.invoker = invoker; this.clientpool = clientpool; this.threadpool = threadpool; if (invoker != null) { version = invoker.getVersion(); performVersioning = Version.performVersioning(version); Map configMap = invoker.getConfiguration(); String checkValue = (String)configMap.get(SocketServerInvoker.CHECK_CONNECTION_KEY); if (checkValue != null && checkValue.length() > 0) { shouldCheckConnection = Boolean.valueOf(checkValue).booleanValue(); } else if (invoker.getVersion() == Version.VERSION_1) { shouldCheckConnection = true; } Object o = configMap.get(EVICTABILITY_TIMEOUT); if (o != null) { try { evictabilityTimeout = Integer.valueOf((String)o).intValue(); log.debug(this + " setting evictabilityTimeout to " + evictabilityTimeout); } catch (Exception e) { log.warn(this + " could not convert " + EVICTABILITY_TIMEOUT + " value of " + o + " to a int value"); } } o = configMap.get(MicroSocketClientInvoker.USE_ONEWAY_CONNECTION_TIMEOUT); if (o != null) { try { useOnewayConnectionTimeout = Boolean.valueOf((String)o).booleanValue(); log.debug(this + " setting useOnewayConnectionTimeout to " + useOnewayConnectionTimeout); } catch (Exception e) { log.warn(this + " could not convert " + MicroSocketClientInvoker.USE_ONEWAY_CONNECTION_TIMEOUT + " value of " + o + " to a boolean value"); } } } } // Thread overrides ----------------------------------------------------------------------------- public void run() { try { processNewSocket(); while (true) { dorun(); // The following code has been changed to eliminate a race condition with // SocketServerInvoker.cleanup(). // // A ServerThread can shutdown for two reasons: // 1. the client shuts down, and // 2. the server shuts down. // // If both occur around the same time, a problem arises. If a ServerThread starts to // shut down because the client shut down, it will test shutdown, and if it gets to the // test before SocketServerInvoker.cleanup() calls ServerThread.shutdown() to set shutdown // to true, it will return itself to threadpool. If it moves from clientpool to // threadpool at just the right time, SocketServerInvoker could miss it in both places // and never call shutdown(), leaving it alive, resulting in a memory leak. The solution is // to synchronize parts of ServerThread.run() and SocketServerInvoker.cleanup() so that // they interact atomically. synchronized (clientpool) { if(trace) { log.trace(this + " removing itself from clientpool"); } clientpool.remove(this); if (shutdown) { if (trace) log.trace(this + " exiting"); invoker = null; return; // exit thread } else { if(trace) { log.trace(this + " returning itself to threadpool"); } threadpool.add(this); clientpool.notifyAll(); Thread.interrupted(); // clear any interruption so that we can be pooled. } } synchronized (this) { // If running == true, then SocketServerInvoker has already removed this // ServerThread from threadpool and called wakeup(), in which case run() // should continue immediately. if (running) continue; while (true) { try { if(trace) { log.trace(this + " begins to wait"); } wait(); if(trace) { log.trace(this + " woke up after wait"); } if (shutdown) { invoker = null; if (trace) log.trace(this + " exiting"); return; // exit thread } break; } catch (InterruptedException e) { } } } } } catch (Exception e) { log.debug(this + " exiting run on exception, definitively thrown out of the threadpool", e); } } // Public --------------------------------------------------------------------------------------- public synchronized void wakeup(Socket socket, int timeout, SocketServerInvoker invoker) throws Exception { // rename the worker thread to reflect the new socket it is handling if (trace) log.trace(this + " restarting with " + socket); setName(getWorkerThreadName(socket)); this.socket = socket; this.timeout = timeout; this.invoker = invoker; invocationCount = 0; running = true; synchronized (evictionLock) { evictable = false; } notify(); if(trace) { log.trace(this + " has notified on mutex"); } } public long getLastRequestTimestamp() { return lastRequestHandledTimestamp; } public synchronized void shutdown() { if (trace) log.trace("attempting to shut down " + this); shutdown = true; try { if (socketWrapper != null) { String desc = socketWrapper.toString(); socketWrapper.close(); if (trace) log.trace(this + " closing socketWrapper: " + desc); } } catch (Exception ex) { log.debug("failed to close socket wrapper", ex); } if (trace) log.trace(this + " shutting down"); notifyAll(); } public void shutdownImmediately() { if (trace) log.trace("attempting to shut down immediately " + this); shutdown = true; try { if (socketWrapper != null) { String desc = socketWrapper.toString(); socketWrapper.close(); if (trace) log.trace(this + " closing socketWrapper: " + desc); } } catch (Exception ex) { log.debug("failed to close socket wrapper", ex); } if (trace) log.trace(this + " shutting down"); } /** * Sets if server thread should check connection before continue to process on next invocation * request. If is set to true, will send an ACK to client to verify client is still connected * on same socket. */ public void shouldCheckConnection(boolean checkConnection) { this.shouldCheckConnection = checkConnection; } /** * Indicates if server will check with client (via an ACK) to see if is still there. */ public boolean getCheckingConnection() { return this.shouldCheckConnection; } /** * If this ServerThread is in acknowledge() or readVersion(), evict() will close the * socket so that thread returns itself to threadpool. * * @return true if eviction is possible * @return false if eviction is not possible */ public boolean evict() { if (trace) log.trace(this + " eviction attempted"); synchronized (evictionLock) { if (!evictable || (invocationCount == 0 && System.currentTimeMillis() - enteredEvictable < evictabilityTimeout)) { if (trace) log.trace(this + " is not evictable: invocationCount = " + invocationCount); return false; } else if (!running) { if (trace) log.trace(this + " is not running - may have been evicted already"); return false; } running = false; try { if (socketWrapper != null) { String desc = socketWrapper.toString(); socketWrapper.close(); if (trace) log.trace(this + " evict() closed socketWrapper: " + desc); } } catch (Exception ex) { log.debug("failed to close socket wrapper", ex); } } // notifyAll(); return true; } // This is a race and there is a chance that a invocation is going on at the time of the // interrupt. But I see no way right now to protect for this. // NOTE ALSO!: Shutdown should never be synchronized. We don't want to hold up accept() // thread! (via LRUpool) // try // { // if (socketWrapper != null) // { // log.debug(this + " closing socketWrapper: " + socketWrapper); // socketWrapper.close(); // } // } // catch (Exception ex) // { // log.debug("failed to close socket wrapper", ex); // } // socketWrapper = null; // // if (trace) log.trace(this + " shutting down"); // notifyAll(); // } /** * This method is intended to be used when need to unblock I/O read, which the thread will * automatically loop back to do after processing a request. */ // public synchronized void unblock() // { // try // { // socketWrapper.close(); // } // catch (IOException e) // { // log.warn("Error closing socket when attempting to unblock I/O", e); // } // } public String toString() { return getName(); } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ /** * This is needed because Object*Streams leak */ protected void dorun() { running = true; InputStream inputStream = null; OutputStream outputStream = null; // lazy initialize the socketWrapper on the worker thread itself. We do this to avoid to have // it done on the acceptor thread (prone to lockup) try { if(trace) { log.trace(this + " creating the socket wrapper"); } socketWrapper = createServerSocketWrapper(socket, timeout, invoker.getLocator().getParameters()); inputStream = socketWrapper.getInputStream(); outputStream = socketWrapper.getOutputStream(); boolean valueSet = false; Map configMap = invoker.getConfiguration(); Object o = configMap.get(CONTINUE_AFTER_TIMEOUT); if (o != null) { try { reuseAfterTimeout = Boolean.valueOf((String)o).booleanValue(); valueSet = true; log.debug(this + " setting reuseAfterTimeout to " + reuseAfterTimeout); } catch (Exception e) { log.warn(this + " could not convert " + CONTINUE_AFTER_TIMEOUT + " value of " + o + " to a boolean value"); } } if (!valueSet) { if (socketWrapper.getInputStream() instanceof JBossObjectInputStream) { reuseAfterTimeout = true; } } // Always do first one without an ACK because its not needed if(trace) { log.trace("processing first invocation without acknowledging"); } processInvocation(socketWrapper, inputStream, outputStream); } catch (Exception ex) { if (running) { log.error(this + " exception occurred during first invocation", ex); running = false; } else { log.debug(this + " exception occurred during first invocation", ex); } } catch (Error e) { if (!shutdown) { log.error("error", e); } else { log.debug("error", e); } } // Re-use loop while (running) { try { if (clientpool.getEvictionNeeded()) { if (trace) log.trace(this + " found eviction needed"); throw new EvictionException(); } acknowledge(socketWrapper); processInvocation(socketWrapper, inputStream, outputStream); } catch (EvictionException e) { if (trace) log.trace(this + " has been evicted"); running = false; } catch (AcknowledgeFailure e) { if (!shutdown && trace) { log.trace("keep alive acknowledge failed!"); } running = false; } catch(SocketTimeoutException ste) { if(!shutdown) { if(trace) { log.trace(this + " timed out", ste); } } if (!reuseAfterTimeout) running = false; } catch (InterruptedIOException e) { if (!shutdown) { log.error(this + " Socket IO interrupted", e); } running = false; } catch (InterruptedException e) { if(trace) { log.trace(e); } if (!shutdown) { log.error(this + " interrupted", e); } } catch (EOFException eof) { if (!shutdown && true) { if (trace) log.trace(this + " EOFException received. This is likely due to client finishing communication.", eof); } running = false; } catch (SocketException sex) { if (!shutdown && trace) { if (trace) log.trace(this + " SocketException received. This is likely due to client disconnecting and resetting connection.", sex); } running = false; } catch (Exception ex) { if (!shutdown) { log.error(this + " failed", ex); } running = false; } catch (Error e) { if (!shutdown) { log.error("error", e); } else { log.debug("error", e); } } // clear any interruption so that thread can be pooled. Thread.interrupted(); } // Ok, we've been shutdown. Do appropriate cleanups. // The stream close code has been moved to SocketWrapper.close(). // try // { // if (socketWrapper != null) // { // InputStream in = socketWrapper.getInputStream(); // if (in != null) // { // in.close(); // } // OutputStream out = socketWrapper.getOutputStream(); // if (out != null) // { // out.close(); // } // } // } // catch (Exception ex) // { // log.debug("failed to close in/out", ex); // } try { if (socketWrapper != null) { String desc = socketWrapper.toString(); socketWrapper.close(); log.debug(this + " closed socketWrapper: " + desc); } } catch (Exception ex) { log.error(this + " failed to close socket wrapper", ex); } } protected void processInvocation(SocketWrapper socketWrapper, InputStream inputStream, OutputStream outputStream) throws Exception { if(trace) { log.trace("preparing to process next invocation"); } // Ok, now read invocation and invoke if (performVersioning) { version = readVersion(inputStream); //TODO: -TME Should I be checking for -1? // This is a best attempt to determine if is old version. Typically, the first byte will // be -1, so if is, will reset stream and process as though is older version. // Originally this code (now uncommented) and the other commented code was to try to make // so could automatically detect older version that would not be sending a byte for the // version. However, due to the way the serialization stream manager handles the stream, // resetting it does not work, so will probably have to throw away that idea. However, for // now, am uncommenting this section because if are using the flag to turn off connection // checking (ack back to client), then will get a -1 when the client closes connection. // Then when stream passed onto the versionedRead, will get EOFException thrown and will // process normally (as though came from the acknowledge, as would have happened if // connection checking was turned on). Am hoping this is not a mistake... if(version == -1) { // version = Version.VERSION_1; throw new EOFException(); } } completeInvocation(socketWrapper, inputStream, outputStream, performVersioning, version); } protected synchronized void completeInvocation( SocketWrapper socketWrapper, InputStream inputStream, OutputStream outputStream, boolean performVersioning, int version) throws Exception { Object obj = versionedRead(inputStream, invoker, classLoader, version); // setting timestamp since about to start processing lastRequestHandledTimestamp = System.currentTimeMillis(); InvocationRequest req = null; boolean createdInvocationRequest = false; boolean isError = false; if(obj instanceof InvocationRequest) { req = (InvocationRequest)obj; } else { req = createInvocationRequest(obj, socketWrapper); createdInvocationRequest = true; performVersioning = false; } boolean isServerSideOnewayRequest = isServerSideOneway(req); InetAddress clientAddress = socketWrapper.getSocket().getInetAddress(); Object resp = null; try { // Make absolutely sure thread interrupted is cleared. Thread.interrupted(); if(trace) { log.trace("about to call " + invoker + ".invoke()"); } if (req.getRequestPayload() == null) req.setRequestPayload(new HashMap()); req.getRequestPayload().put(Remoting.CLIENT_ADDRESS, clientAddress); // call transport on the subclass, get the result to handback resp = invoker.invoke(req); if(trace) { log.trace(invoker + ".invoke() returned " + resp); } } catch (Throwable ex) { resp = ex; isError = true; if (trace) log.trace(invoker + ".invoke() call failed", ex); } Thread.interrupted(); // clear interrupted state so we don't fail on socket writes if(isServerSideOnewayRequest) { if(trace) { log.trace("oneway request, writing no reply on the wire"); } } else if (isOneway(req)) { if (useOnewayConnectionTimeout && performVersioning) { writeVersion(outputStream, version); outputStream.flush(); } } else { if(!createdInvocationRequest) { // need to return invocation response if(trace) { log.trace("creating response instance"); } resp = new InvocationResponse(req.getSessionId(), resp, isError, req.getReturnPayload()); } if (performVersioning) { writeVersion(outputStream, version); } versionedWrite(outputStream, invoker, classLoader, resp, version); } // set the timestamp for last successful processed request lastRequestHandledTimestamp = System.currentTimeMillis(); invocationCount++; } protected void acknowledge(SocketWrapper socketWrapper) throws Exception { if (shouldCheckConnection) { // HERE IS THE RACE between ACK received and handlingResponse = true. We can't synchronize // because readByte blocks and client is expecting a response and we don't want to hang // client. See shutdown and evict for more details. There may not be a problem because // interrupt only effects threads blocking on IO. and this thread will just continue. try { if(trace) { log.trace("checking connection"); } synchronized (evictionLock) { evictable = true; enteredEvictable = System.currentTimeMillis(); } socketWrapper.checkConnection(); } catch (EOFException e) { throw new AcknowledgeFailure(); } catch (SocketException se) { throw new AcknowledgeFailure(); } catch (IOException ioe) { throw new AcknowledgeFailure(); } finally { synchronized (evictionLock) { evictable = false; if (!running) // In case evict() ran after SocketWrapper i/o. throw new EvictionException(); } } } } protected Object versionedRead(InputStream inputStream, ServerInvoker invoker, ClassLoader classLoader, int version) throws IOException, ClassNotFoundException { //TODO: -TME - Should I even botther to check for version here? Only one way to do processing // at this point, regardless of version. switch (version) { case Version.VERSION_1: case Version.VERSION_2: case Version.VERSION_2_2: { if(trace) { log.trace("blocking to read invocation from unmarshaller"); } Object o = null; if (unmarshaller instanceof VersionedUnMarshaller) o = ((VersionedUnMarshaller)unmarshaller).read(inputStream, null, version); else o = unmarshaller.read(inputStream, null); if(trace) { log.trace("read " + o + " from unmarshaller"); } return o; } default: { throw new IOException("Can not read data for version " + version + ". Supported versions: " + Version.VERSION_1 + "," + Version.VERSION_2 + "," + Version.VERSION_2_2); } } } // Private -------------------------------------------------------------------------------------- private SocketWrapper createServerSocketWrapper(Socket socket, int timeout, Map metadata) throws Exception { if (serverSocketConstructor == null) { if(serverSocketClass == null) { serverSocketClass = ClassLoaderUtility.loadClass(serverSocketClassName, getClass()); } try { serverSocketConstructor = serverSocketClass. getConstructor(new Class[]{Socket.class, Map.class, Integer.class}); } catch (NoSuchMethodException e) { serverSocketConstructor = serverSocketClass.getConstructor(new Class[]{Socket.class}); } } SocketWrapper serverSocketWrapper = null; if (serverSocketConstructor.getParameterTypes().length == 3) { Map localMetadata = null; if (metadata == null) { localMetadata = new HashMap(2); } else { localMetadata = new HashMap(metadata); } localMetadata.put(SocketWrapper.MARSHALLER, marshaller); localMetadata.put(SocketWrapper.UNMARSHALLER, unmarshaller); if (writeTimeout > 0) { localMetadata.put(SocketWrapper.WRITE_TIMEOUT, new Integer(writeTimeout)); } serverSocketWrapper = (SocketWrapper)serverSocketConstructor. newInstance(new Object[]{socket, localMetadata, new Integer(timeout)}); } else { serverSocketWrapper = (SocketWrapper)serverSocketConstructor.newInstance(new Object[]{socket}); serverSocketWrapper.setTimeout(timeout); } return serverSocketWrapper; } private boolean isServerSideOneway(InvocationRequest invocationRequest) { return invocationRequest.getParameter() instanceof OnewayInvocation; } private boolean isOneway(InvocationRequest invocationRequest) { boolean isOneway = false; Map metadata = invocationRequest.getRequestPayload(); if (metadata != null) { Object val = metadata.get(Client.ONEWAY_FLAG); if (val != null && val instanceof String && Boolean.valueOf((String) val).booleanValue()) { isOneway = true; } } return isOneway; } private InvocationRequest createInvocationRequest(Object obj, SocketWrapper socketWrapper) { if(obj instanceof InvocationRequest) { return (InvocationRequest)obj; } else { // need to wrap request with invocation request SocketAddress remoteAddress = socketWrapper.getSocket().getRemoteSocketAddress(); return new InvocationRequest(remoteAddress.toString(), invoker.getSupportedSubsystems()[0], obj, new HashMap(), null, null); } } private void processNewSocket() { InvokerLocator locator = invoker.getLocator(); String dataType = invoker.getDataType(); String serializationType = invoker.getSerializationType(); //TODO: -TME Need better way to get the unmarshaller (via config) Map configMap = null; if (invoker != null) { configMap = invoker.getConfiguration(); } boolean passConfigMapToMarshalFactory = false; if (configMap != null) { Object o = configMap.get(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY); if (o instanceof String) { passConfigMapToMarshalFactory = Boolean.valueOf((String) o).booleanValue(); } else if (o != null) { log.warn("Value of " + Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY + " should be of type String: " + o); } } Map map = passConfigMapToMarshalFactory ? configMap : null; if (unmarshaller == null) { unmarshaller = MarshalFactory.getUnMarshaller(locator, classLoader, map); } if (unmarshaller == null) { unmarshaller = MarshalFactory.getUnMarshaller(dataType, serializationType); } if (marshaller == null) { marshaller = MarshalFactory.getMarshaller(locator, classLoader, map); } if (marshaller == null) { marshaller = MarshalFactory.getMarshaller(dataType, serializationType); } } private void versionedWrite(OutputStream outputStream, SocketServerInvoker invoker, ClassLoader classLoader, Object resp, int version) throws IOException { //TODO: -TME - Should I ever worry about checking version here? Only one way to send data at this point. switch (version) { case Version.VERSION_1: case Version.VERSION_2: case Version.VERSION_2_2: { if (marshaller instanceof VersionedMarshaller) ((VersionedMarshaller) marshaller).write(resp, outputStream, version); else marshaller.write(resp, outputStream); if (trace) { log.trace("wrote response to the output stream"); } return; } default: { throw new IOException("Can not write data for version " + version + ". Supported version: " + Version.VERSION_1 + ", " + Version.VERSION_2 + ", " + Version.VERSION_2_2); } } } private int readVersion(InputStream inputStream) throws Exception { long start = -1; if(trace) { log.trace(this + " blocking to read version from input stream"); start = System.currentTimeMillis(); } synchronized (evictionLock) { evictable = true; enteredEvictable = System.currentTimeMillis(); } try { int version = inputStream.read(); if(trace) { log.trace(this + " read version " + version + " from input stream"); } return version; } finally { synchronized (evictionLock) { evictable = false; if (!running) // In case evict() ran after InputStream.read(). { if (trace) { long d = System.currentTimeMillis() - start; log.trace(this + " socketWrapper: " + socketWrapper + ", waited: " + d); } throw new EvictionException(); } } } } private void writeVersion(OutputStream outputStream, int version) throws IOException { outputStream.write(version); } private String getWorkerThreadName(Socket currentSocket) { if (id == Integer.MIN_VALUE) { id = nextID(); } StringBuffer sb = new StringBuffer("WorkerThread#"); sb.append(id).append('['); sb.append(currentSocket.getInetAddress().getHostAddress()); sb.append(':'); sb.append(currentSocket.getPort()); sb.append(']'); return sb.toString(); } // Inner classes -------------------------------------------------------------------------------- public static class AcknowledgeFailure extends Exception { } public static class EvictionException extends Exception { } static private ClassLoader getClassLoader(final Class c) { if (SecurityUtility.skipAccessControl()) { return c.getClassLoader(); } return (ClassLoader)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return c.getClassLoader(); } }); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/TimedOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/TimedOutputStream0000644000175000017500000001036011413660476033554 0ustar twernertwerner/* * 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.remoting.transport.socket; import java.io.IOException; import java.io.OutputStream; import java.util.Timer; import java.util.TimerTask; import org.jboss.logging.Logger; /** * @author Ron Sigal * @version $Rev$ *

          * Copyright April 22, 2009 *

          */ public class TimedOutputStream extends OutputStream { static private Timer timer = new Timer(true); static private Logger log = Logger.getLogger(TimedOutputStream.class); private OutputStream os; private int outputTimeout; private OutputTimerTask timerTask; private Object lock = new Object(); public TimedOutputStream(OutputStream os, int outputTimeout) { this.os = os; this.outputTimeout = outputTimeout; } public void close() throws IOException { os.close(); } public void write(int b) throws IOException { synchronized (lock) { if (timerTask == null) { try { timerTask = new OutputTimerTask(this); timer.schedule(timerTask, outputTimeout); if (log.isTraceEnabled()) log.trace("scheduled OutputTimerTask: " + outputTimeout); } catch (IllegalStateException e) { timer = new Timer(true); timer.schedule(new OutputTimerTask(this), outputTimeout); if (log.isTraceEnabled()) log.trace("scheduled OutputTimerTask: " + outputTimeout); } } } try { os.write(b); } finally { synchronized (lock) { timerTask.cancel(); timerTask = null; } } } public void write(byte b[], int off, int len) throws IOException { synchronized (lock) { if (timerTask == null) { try { timerTask = new OutputTimerTask(this); timer.schedule(timerTask, outputTimeout); if (log.isTraceEnabled()) log.trace(this + " scheduled " + timerTask + ": " + outputTimeout); } catch (IllegalStateException e) { // timer = new Timer("TimedOutputStreamTimer", true); timer = new Timer(true); timer.schedule(new OutputTimerTask(this), outputTimeout); if (log.isTraceEnabled()) log.trace(this + " scheduled " + timerTask + ": " + outputTimeout); } } } try { os.write(b, off, len); } finally { synchronized (lock) { timerTask.cancel(); timerTask = null; } } } static class OutputTimerTask extends TimerTask { private TimedOutputStream tos; public OutputTimerTask(TimedOutputStream tos) { this.tos = tos; } public void run() { try { log.debug(this + " closing: " + tos); tos.close(); tos = null; } catch (IOException e) { log.debug("unable to close " + tos); } } public boolean cancel() { tos = null; return super.cancel(); } } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/TransportClientFa0000644000175000017500000000310610455077561033521 0ustar twernertwerner/* * 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.remoting.transport.socket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new SocketClientInvoker(locator, config); } public boolean supportsSSL() { return false; } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/SocketServerInvok0000644000175000017500000010344211173727410033542 0ustar twernertwerner/* * 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.remoting.transport.socket; import org.jboss.remoting.Home; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.util.SecurityUtility; import org.jboss.remoting.util.TimerUtil; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.util.propertyeditor.PropertyEditors; import org.jboss.logging.Logger; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLException; import java.beans.IntrospectionException; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketAddress; import java.net.SocketException; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.TimerTask; /** * SocketServerInvoker is the server-side of a SOCKET based transport * * @author Jeff Haynie * @author Tom Elrod * @author Ovidiu Feodorov * * @version $Revision: 5082 $ * @jmx:mbean */ public class SocketServerInvoker extends ServerInvoker implements SocketServerInvokerMBean { private static final Logger log = Logger.getLogger(SocketServerInvoker.class); private static boolean trace = log.isTraceEnabled(); static int clientCount = 0; protected Properties props = new Properties(); private static int BACKLOG_DEFAULT = 200; protected static int MAX_POOL_SIZE_DEFAULT = 300; /** * Key for indicating if socket invoker should continue to keep socket connection between * client and server open after invocations by sending a ping on the connection * before being re-used. The default for this is false. */ public static final String CHECK_CONNECTION_KEY = "socket.check_connection"; /** * Specifies the fully qualified class name for the custom SocketWrapper implementation to use on the server. */ public static final String SERVER_SOCKET_CLASS_FLAG = "serverSocketClass"; protected String serverSocketClass = ServerSocketWrapper.class.getName(); protected List serverSockets = new ArrayList(); protected boolean running = false; protected int backlog = BACKLOG_DEFAULT; protected AcceptThread[] acceptThreads; protected int numAcceptThreads = 1; protected int maxPoolSize = MAX_POOL_SIZE_DEFAULT; protected LRUPool clientpool; protected LinkedList threadpool; protected boolean immediateShutdown; protected ServerSocketRefresh refreshThread; protected boolean newServerSocketFactory = false; protected Object serverSocketFactoryLock = new Object(); protected boolean reuseAddress = true; protected int receiveBufferSize = -1; /** * More socket configuration parameters. */ protected boolean keepAlive; protected boolean keepAliveSet; protected boolean oOBInline; protected boolean oOBInlineSet; protected int sendBufferSize = -1; protected boolean soLinger; protected boolean soLingerSet; protected int soLingerDuration = -1; protected int trafficClass = -1; // defaults to -1 as to not have idle timeouts protected int idleTimeout = -1; protected IdleTimerTask idleTimerTask = null; protected int writeTimeout = -1; public SocketServerInvoker(InvokerLocator locator) { super(locator); } public SocketServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } /** * after a truststore update use this to * set a new ServerSocketFactory to the invoker
          * then a new ServerSocket is created that accepts the new connections * @param serverSocketFactory */ public void setNewServerSocketFactory(ServerSocketFactory serverSocketFactory) { log.trace("entering setNewServerSocketFactory()"); synchronized (serverSocketFactoryLock) { newServerSocketFactory=true; setServerSocketFactory(serverSocketFactory); serverSocketFactoryLock.notify(); log.info("ServerSocketFactory has been updated"); } } /** * refreshes the serverSocket by closing old one and * creating a new ServerSocket from new ServerSocketFactory * @throws IOException */ protected void refreshServerSocket() throws IOException { log.trace("entering refreshServerSocket()"); synchronized (serverSocketFactoryLock) { for (int i = 0; i < acceptThreads.length; i++) { // If release() is able to enter its synchronized block and sees // serverSocket == null, then it knows that something went wrong. newServerSocketFactory=false; ServerSocket oldServerSocket = acceptThreads[i].getServerSocket(); InetAddress address = oldServerSocket.getInetAddress(); int port = oldServerSocket.getLocalPort(); oldServerSocket.close(); ServerSocket newServerSocket = null; for (int j = 0; j < 5; j++) { try { newServerSocket = createServerSocket(port, backlog, address); break; } catch (Exception e) { if (j < 4) { // Wait for end of TIME_WAIT state (1 to 4 minutes). log.warn("Unable to recreate ServerSocket: will try again in 65 seconds", e); try {Thread.sleep(65000);} catch (InterruptedException ignored) {} } else { log.error("Unable to recreate ServerSocket after 260 seconds", e); return; } } } acceptThreads[i].setServerSocket(newServerSocket); log.info(acceptThreads[i] + " has been updated with new ServerSocket"); } } log.trace("leaving refreshServerSocket()"); } protected void setup() throws Exception { props.putAll(getConfiguration()); mapJavaBeanProperties(this, props, false); super.setup(); String ssclass = props.getProperty(SERVER_SOCKET_CLASS_FLAG); if(ssclass != null) { serverSocketClass = ssclass; } } protected void finalize() throws Throwable { stop(); super.finalize(); } /** * Starts the invoker. * * @jmx.managed-operation description = "Start sets up the ServerInvoker we are wrapping." * impact = "ACTION" */ public synchronized void start() throws IOException { if(!running) { log.debug(this + " starting"); if(maxPoolSize <= 0) { //need to reset to default maxPoolSize = MAX_POOL_SIZE_DEFAULT; } clientpool = new LRUPool(2, maxPoolSize); clientpool.create(); threadpool = new LinkedList(); createServerSockets(); refreshThread = new ServerSocketRefresh(); refreshThread.setDaemon(true); refreshThread.start(); acceptThreads = new AcceptThread[numAcceptThreads * getHomes().size()]; int i = 0; Iterator it = serverSockets.iterator(); while (it.hasNext()) { ServerSocket ss = (ServerSocket) it.next(); for(int j = 0; j < numAcceptThreads; j++) { acceptThreads[i++] = new AcceptThread(ss, refreshThread); } } } try { super.start(); } catch(IOException e) { log.error("Error starting SocketServerInvoker.", e); cleanup(); } if(!running) { running = true; for(int i = 0; i < acceptThreads.length; i++) { acceptThreads[i].start(); } } if(idleTimeout > 0) { if(idleTimerTask != null) { idleTimerTask.cancel(); } idleTimerTask = new IdleTimerTask(); TimerUtil.schedule(idleTimerTask, idleTimeout * 1000); } else { if(idleTimerTask != null) { idleTimerTask.cancel(); } } log.debug(this + " started"); } protected ServerSocket createServerSocket(int serverBindPort, final int backlog, InetAddress bindAddress) throws IOException { ServerSocketFactory factory = getServerSocketFactory(); ServerSocket ss = null; try { ss = factory.createServerSocket(); } catch (SocketException e) { if (getReuseAddress()) log.warn("Unable to create unbound ServerSocket: cannot set reuseAddress to true",e); ss = factory.createServerSocket(serverBindPort, backlog, bindAddress); configureServerSocket(ss); return ss; } ss.setReuseAddress(getReuseAddress()); configureServerSocket(ss); InetSocketAddress address = new InetSocketAddress(bindAddress, serverBindPort); bind(ss, address, backlog); return ss; } protected void createServerSockets() throws IOException { ServerSocketFactory factory = getServerSocketFactory(); Iterator it = getHomes().iterator(); while (it.hasNext()) { Home home = (Home) it.next(); InetAddress inetAddress = getAddressByName(home.host); ServerSocket ss = null; try { ss = factory.createServerSocket(); ss.setReuseAddress(getReuseAddress()); configureServerSocket(ss); InetSocketAddress address = new InetSocketAddress(inetAddress, home.port); bind(ss, address, backlog); if (log.isDebugEnabled()) log.debug(this + " created " + ss); } catch (SocketException e) { if (getReuseAddress()) log.warn("Unable to create unbound ServerSocket: cannot set reuseAddress to true"); try { ss = factory.createServerSocket(home.port, backlog, inetAddress); configureServerSocket(ss); } catch (IOException e2) { String m = this + " error creating ServerSocket[" + home + "]: " + e2.getMessage(); IOException e3 = new IOException(m); log.debug(m, e3); throw e3; } } catch (IOException e) { String m = this + " error creating ServerSocket[" + home + "]: " + e.getMessage(); IOException e2 = new IOException(m); log.debug(m, e2); throw e2; } serverSockets.add(ss); } } protected void configureServerSocket(ServerSocket ss) throws SocketException { if (receiveBufferSize != -1) { ss.setReceiveBufferSize(receiveBufferSize); } } protected String getThreadName(int i) { return "AcceptorThread#" + i + ":" + getServerBindPort(); } public void destroy() { if(clientpool != null) { synchronized (clientpool) { clientpool.destroy(); } } super.destroy(); } /** * Stops the invoker. * * @jmx.managed-operation description = "Stops the invoker." * impact = "ACTION" */ public synchronized void stop() { if(running) { cleanup(); } super.stop(); } protected void cleanup() { running = false; if(acceptThreads != null) { for(int i = 0; i < acceptThreads.length; i++) { acceptThreads[i].shutdown(); } } if (refreshThread != null) refreshThread.shutdown(); if (idleTimerTask != null) { idleTimerTask.cancel(); } maxPoolSize = 0; // so ServerThreads don't reinsert themselves // The following code has been changed to avoid a race condition with ServerThread.run() which // can result in leaving ServerThreads alive, which causes a memory leak. if (clientpool != null) { synchronized (clientpool) { Set svrThreads = clientpool.getContents(); Iterator itr = svrThreads.iterator(); while(itr.hasNext()) { Object o = itr.next(); ServerThread st = (ServerThread) o; if (immediateShutdown) { st.shutdownImmediately(); } else { st.shutdown(); } } clientpool.flush(); clientpool.stop(); log.debug(this + " stopped threads in clientpool"); if (threadpool != null) { int threadsToShutdown = threadpool.size(); for(int i = 0; i < threadsToShutdown; i++) { ServerThread thread = (ServerThread) threadpool.removeFirst(); if (immediateShutdown) { thread.shutdownImmediately(); } else { thread.shutdown(); } } log.debug(this + " stopped threads in threadpool"); } } } log.debug(this + " exiting"); } public int getReceiveBufferSize() { return receiveBufferSize; } public void setReceiveBufferSize(int receiveBufferSize) { this.receiveBufferSize = receiveBufferSize; } /** * Indicates if SO_REUSEADDR is enabled on server sockets * Default is true. */ public boolean getReuseAddress() { return reuseAddress; } /** * Sets if SO_REUSEADDR is enabled on server sockets. * Default is true. * * @param reuse */ public void setReuseAddress(boolean reuse) { this.reuseAddress = reuse; } public boolean isKeepAlive() { return keepAlive; } public void setKeepAlive(boolean keepAlive) { this.keepAlive = keepAlive; keepAliveSet = true; } public boolean isOOBInline() { return oOBInline; } public void setOOBInline(boolean inline) { oOBInline = inline; oOBInlineSet = true; } public int getSendBufferSize() { return sendBufferSize; } public void setSendBufferSize(int sendBufferSize) { this.sendBufferSize = sendBufferSize; } public boolean isSoLinger() { return soLinger; } public int getSoLingerDuration() { return soLingerDuration; } public void setSoLinger(boolean soLinger) { this.soLinger = soLinger; soLingerSet = true; } public void setSoLingerDuration(int soLingerDuration) { this.soLingerDuration = soLingerDuration; } public int getTrafficClass() { return trafficClass; } public void setTrafficClass(int trafficClass) { this.trafficClass = trafficClass; } /** * @return Number of idle ServerThreads * @jmx:managed-attribute */ public int getCurrentThreadPoolSize() { return threadpool.size(); } /** * @return Number of ServerThreads current executing or waiting on an invocation * @jmx:managed-attribute */ public int getCurrentClientPoolSize() { return clientpool.size(); } /** * Getter for property numAcceptThreads * * @return The number of threads that exist for accepting client connections * @jmx:managed-attribute */ public int getNumAcceptThreads() { return numAcceptThreads; } /** * Setter for property numAcceptThreads * * @param size The number of threads that exist for accepting client connections * @jmx:managed-attribute */ public void setNumAcceptThreads(int size) { this.numAcceptThreads = size; } /** * Setter for max pool size. * The number of server threads for processing client. The default is 300. * * @return * @jmx:managed-attribute */ public int getMaxPoolSize() { return maxPoolSize; } /** * The number of server threads for processing client. The default is 300. * * @param maxPoolSize * @jmx:managed-attribute */ public void setMaxPoolSize(int maxPoolSize) { this.maxPoolSize = maxPoolSize; } /** * @jmx:managed-attribute */ public int getBacklog() { return backlog; } /** * @jmx:managed-attribute */ public void setBacklog(int backlog) { if(backlog < 0) { this.backlog = BACKLOG_DEFAULT; } else { this.backlog = backlog; } } public int getIdleTimeout() { return idleTimeout; } /** * Sets the timeout for idle threads to be removed from pool. * If the value is greater than 0, then idle timeout will be * activated, otherwise no idle timeouts will occur. By default, * this value is -1. * * @param idleTimeout number of seconds before a idle thread is timed out. */ public void setIdleTimeout(int idleTimeout) { this.idleTimeout = idleTimeout; if(isStarted()) { if(idleTimeout > 0) { if(idleTimerTask != null) { idleTimerTask.cancel(); } idleTimerTask = new IdleTimerTask(); TimerUtil.schedule(idleTimerTask, idleTimeout * 1000); } else { if(idleTimerTask != null) { idleTimerTask.cancel(); } } } } public boolean isImmediateShutdown() { return immediateShutdown; } public void setImmediateShutdown(boolean immediateShutdown) { this.immediateShutdown = immediateShutdown; } public int getWriteTimeout() { return writeTimeout; } public void setWriteTimeout(int writeTimeout) { this.writeTimeout = writeTimeout; } protected void configureSocket(Socket s) throws SocketException { s.setReuseAddress(getReuseAddress()); if (keepAliveSet) s.setKeepAlive(keepAlive); if (oOBInlineSet) s.setOOBInline(oOBInline); if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize); if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize); if (soLingerSet && soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration); if (trafficClass > -1) s.setTrafficClass(trafficClass); } /** * The acceptor thread should spend as little time as possbile doing any kind of operation, and * under no circumstances should perform IO on the new socket, which can potentially block and * lock up the server. For this reason, the acceptor thread should grab a worker thread and * delegate all subsequent work to it. */ protected void processInvocation(Socket socket) throws Exception { ServerThread worker = null; boolean newThread = false; synchronized(clientpool) { while(worker == null && running) { if(trace) { log.trace(this + " trying to get a worker thread from threadpool for processing"); } if(threadpool.size() > 0) { worker = (ServerThread)threadpool.removeFirst(); if(trace) { log.trace(this + (worker == null ? " found NO threads in threadpool" : " got " + worker + " from threadpool")); } } else if (trace) { { log.trace(this + " has an empty threadpool"); } } if(worker == null) { if(clientpool.size() < maxPoolSize) { if(trace) { log.trace(this + " creating new worker thread"); } worker = new ServerThread(socket, this, clientpool, threadpool, getTimeout(), writeTimeout, serverSocketClass); if(trace) { log.trace(this + " created " + worker); } newThread = true; } if(worker == null) { if(trace) {log.trace(this + " trying to evict a thread from clientpool"); } clientpool.evict(); clientpool.wait(1000); // Keep trying, in case all threads are not evictable. if(trace) { log.trace(this + " notified of clientpool thread availability"); } } } } if (!running) { return; } clientpool.insert(worker, worker); } if(newThread) { if(trace) {log.trace(this + " starting " + worker); } worker.start(); } else { if(trace) { log.trace(this + " reusing " + worker); } worker.wakeup(socket, getTimeout(), this); } } /** * returns true if the transport is bi-directional in nature, for example, * SOAP in unidirectional and SOCKETs are bi-directional (unless behind a firewall * for example). */ public boolean isTransportBiDirectional() { return true; } public String toString() { return "SocketServerInvoker[" + locator.getHomes() + "]"; } /** * Each implementation of the remote client invoker should have * a default data type that is uses in the case it is not specified * in the invoker locator uri. */ protected String getDefaultDataType() { return SerializableMarshaller.DATATYPE; } /** * this thread checks if a new ServerSocketFactory was set,
          * if so initializes a serversocket refresh * @author Michael Voss * */ public class ServerSocketRefresh extends Thread { private boolean running = true; public ServerSocketRefresh() { super("ServerSocketRefresh"); } public void run() { while(running) { synchronized (serverSocketFactoryLock) { if(newServerSocketFactory) { log.debug("got notice about new ServerSocketFactory"); try { log.debug("refreshing server socket"); refreshServerSocket(); log.debug("server socket refreshed"); } catch (IOException e) { log.error("could not refresh server socket", e); } } try { serverSocketFactoryLock.wait(); log.trace("ServerSocketRefresh thread woke up"); } catch (InterruptedException e) { } } } log.debug("ServerSocketRefresh shutting down"); } /** * Let SocketServerInvoker.run() resume when refresh is completed */ public void release() throws InvalidStateException { synchronized (serverSocketFactoryLock) { // if (serverSocket == null) // { // throw new InvalidStateException("error refreshing ServerSocket"); // } log.trace("passed through ServerSocketRefresh.release()"); } } public void shutdown() { running = false; synchronized (serverSocketFactoryLock) { serverSocketFactoryLock.notify(); } } } /** * The IdleTimerTask is used to periodically check the server threads to * see if any have been idle for a specified amount of time, and if so, * release those threads and their connections and clear from the server * thread pool. */ public class IdleTimerTask extends TimerTask { public void run() { Object[] svrThreadArray = null; Set threadsToShutdown = new HashSet(); synchronized(clientpool) { Set svrThreads = clientpool.getContents(); svrThreadArray = svrThreads.toArray(); if(trace) { if(svrThreadArray != null) { log.trace("Idle timer task fired. Number of ServerThreads = " + svrThreadArray.length); } } // iterate through pooled server threads and evict idle ones if(svrThreadArray != null) { long currentTime = System.currentTimeMillis(); for(int x = 0; x < svrThreadArray.length; x++) { ServerThread svrThread = (ServerThread)svrThreadArray[x]; // check the idle time and evict long idleTime = currentTime - svrThread.getLastRequestTimestamp(); if(trace) { log.trace("Idle time for ServerThread (" + svrThread + ") is " + idleTime); } long idleTimeout = getIdleTimeout() * 1000; if(idleTime > idleTimeout) { if(trace) { log.trace("Idle timeout reached for ServerThread (" + svrThread + ") and will be evicted."); } clientpool.remove(svrThread); threadsToShutdown.add(svrThread); // svrThread.shutdown(); // svrThread.unblock(); } } } // now check idle server threads in the thread pool svrThreadArray = null; if(threadpool.size() > 0) { // now need to check the tread pool to remove threads svrThreadArray = threadpool.toArray(); } if(trace) { if(svrThreadArray != null) { log.trace("Number of ServerThread in thead pool = " + svrThreadArray.length); } } if(svrThreadArray != null) { long currentTime = System.currentTimeMillis(); for(int x = 0; x < svrThreadArray.length; x++) { ServerThread svrThread = (ServerThread)svrThreadArray[x]; long idleTime = currentTime - svrThread.getLastRequestTimestamp(); if(trace) { log.trace("Idle time for ServerThread (" + svrThread + ") is " + idleTime); } long idleTimeout = getIdleTimeout() * 1000; if(idleTime > idleTimeout) { if(trace) { log.trace("Idle timeout reached for ServerThread (" + svrThread + ") and will be removed from thread pool."); } threadpool.remove(svrThread); threadsToShutdown.add(svrThread); // svrThread.shutdown(); } } } } Iterator it = threadsToShutdown.iterator(); while (it.hasNext()) { ServerThread svrThread = (ServerThread) it.next(); svrThread.shutdown(); // svrThread.unblock(); } } } public class AcceptThread extends Thread { ServerSocket serverSocket; ServerSocketRefresh refreshThread; public AcceptThread(ServerSocket serverSocket, ServerSocketRefresh refreshThread) { this.serverSocket = serverSocket; this.refreshThread = refreshThread; setName("AcceptorThread[" + serverSocket + "]"); if(trace) log.trace(SocketServerInvoker.this + " created " + this); } public void run() { if(trace) { log.trace(this + " started execution of method run()"); } while(running) { try { refreshThread.release(); //goes on if serversocket refresh is completed if(trace) { log.trace(this + " is going to wait on serverSocket.accept()"); } Socket socket = accept(serverSocket); if(trace) { log.trace(this + " accepted " + socket); } // the acceptor thread should spend as little time as possbile doing any kind of // operation, and under no circumstances should perform IO on the new socket, which // can potentially block and lock up the server. For this reason, the acceptor thread // should grab a worker thread and delegate all subsequent work to it. This is what // processInvocation() does. configureSocket(socket); processInvocation(socket); } catch (SSLException e) { log.error("SSLServerSocket error", e); return; } catch (InvalidStateException e) { log.error("Cannot proceed without functioning server socket. Shutting down", e); return; } catch(Throwable ex) { if(running) { log.error(this + " failed to handle socket", ex); } else { log.trace(this + " caught exception in run()", ex); } } } } public void shutdown() { try { serverSocket.close(); } catch (IOException e) { log.debug(this + " error closing " + serverSocket, e); } } public ServerSocket getServerSocket() { return serverSocket; } public void setServerSocket(ServerSocket serverSocket) { this.serverSocket = serverSocket; } } static private void mapJavaBeanProperties(final Object o, final Properties props, final boolean isStrict) throws IntrospectionException { if (SecurityUtility.skipAccessControl()) { PropertyEditors.mapJavaBeanProperties(o, props, isStrict); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IntrospectionException { PropertyEditors.mapJavaBeanProperties(o, props, isStrict); return null; } }); } catch (PrivilegedActionException e) { throw (IntrospectionException) e.getCause(); } } static private Socket accept(final ServerSocket ss) throws IOException { if (SecurityUtility.skipAccessControl()) { return ss.accept(); } try { return (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return ss.accept(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private void bind(final ServerSocket ss, final SocketAddress address, final int backlog) throws IOException { if (SecurityUtility.skipAccessControl()) { ss.bind(address, backlog); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { ss.bind(address, backlog); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/SocketClientInvok0000644000175000017500000002215611337554713033522 0ustar twernertwerner/* * 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.remoting.transport.socket; import org.jboss.logging.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.InvocationFailureException; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.util.SecurityUtility; import javax.net.SocketFactory; import java.io.IOException; import java.lang.reflect.Constructor; import java.net.InetAddress; import java.net.Socket; import java.net.SocketTimeoutException; import java.net.InetSocketAddress; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Map; /** * SocketClientInvoker uses Sockets to remotely connect to the a remote ServerInvoker, which * must be a SocketServerInvoker. * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5739 $ */ public class SocketClientInvoker extends MicroSocketClientInvoker { private static final Logger log = Logger.getLogger(SocketClientInvoker.class); private static final boolean isTraceEnabled = log.isTraceEnabled(); public static final String SO_TIMEOUT_FLAG = "timeout"; /** * Default value for socket timeout is 30 minutes. */ public static final int SO_TIMEOUT_DEFAULT = 1800000; protected int timeout = SO_TIMEOUT_DEFAULT; private Constructor clientSocketConstructor = null; /** * Set number of retries in getSocket method */ public SocketClientInvoker(InvokerLocator locator) { this(locator, null); } public SocketClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); configureParameters(); } protected ServerAddress createServerAddress(InetAddress addr, int port) { return new ServerAddress(addr.getHostAddress(), port, enableTcpNoDelay, timeout, maxPoolSize); } protected void configureParameters() { super.configureParameters(); // For JBREM-1188 timeout = SO_TIMEOUT_DEFAULT; Map params = configuration; if (params != null) { // look for socketTimeout param Object val = params.get(SO_TIMEOUT_FLAG); if (val != null) { try { timeout = Integer.valueOf((String) val).intValue();; log.debug(this + " setting timeout to " + timeout); } catch (Exception e) { log.warn(this + " could not convert " + SO_TIMEOUT_FLAG + " value of " + val + " to a int value."); } } } } protected Object handleException(Exception ex, SocketWrapper socketWrapper) throws ClassNotFoundException, InvocationFailureException, CannotConnectException { if (ex instanceof ClassNotFoundException) { //TODO: -TME Add better exception handling for class not found exception log.debug("Error loading classes from remote call result.", ex); throw (ClassNotFoundException) ex; } if (ex instanceof CannotConnectException) { log.debug(this, ex); throw (CannotConnectException) ex; } if (ex instanceof SocketTimeoutException) { log.debug("Got SocketTimeoutException, exiting", ex); String message = "Socket timed out. Waited " + socketWrapper.getTimeout() + " milliseconds for response while calling on " + getLocator(); throw new InvocationFailureException(message, ex); } if (ex instanceof InterruptedException) { log.debug(this, ex); throw new RuntimeException(ex); } throw new InvocationFailureException("Unable to perform invocation", ex); } /** * used for debugging (tracing) connections leaks */ protected SocketWrapper createClientSocket(Socket socket, int timeout, Map metadata) throws Exception { if (clientSocketConstructor == null) { if(clientSocketClass == null) { clientSocketClass = ClassLoaderUtility.loadClass(getClass(), clientSocketClassName); } try { clientSocketConstructor = clientSocketClass.getConstructor(new Class[]{Socket.class, Map.class, Integer.class}); } catch (NoSuchMethodException e) { clientSocketConstructor = clientSocketClass.getConstructor(new Class[]{Socket.class}); } } SocketWrapper clientSocketWrapper = null; if (clientSocketConstructor.getParameterTypes().length == 3) { clientSocketWrapper = (SocketWrapper) clientSocketConstructor.newInstance(new Object[]{socket, metadata, new Integer(timeout)}); } else { clientSocketWrapper = (SocketWrapper) clientSocketConstructor.newInstance(new Object[]{socket}); clientSocketWrapper.setTimeout(timeout); } return clientSocketWrapper; } protected Socket createSocket(String address, int port, int timeout) throws IOException { Socket s = null; SocketFactory socketFactory = getSocketFactory(); if (socketFactory != null) { s = socketFactory.createSocket(); } else { s = new Socket(); } configureSocket(s); InetSocketAddress inetAddr = new InetSocketAddress(address, port); if (timeout < 0) { timeout = getTimeout(); if (timeout < 0) timeout = 0; } connect(s, inetAddr, timeout); return s; } protected SocketWrapper getPooledConnection() { SocketWrapper socketWrapper = null; while (pool.size() > 0) { socketWrapper = (SocketWrapper) pool.removeFirst(); try { if (socketWrapper != null) { if (socketWrapper instanceof OpenConnectionChecker) { ((OpenConnectionChecker) socketWrapper).checkOpenConnection(); } if (shouldCheckConnection) { socketWrapper.checkConnection(); return socketWrapper; } else { if (socketWrapper.getSocket().isConnected()) { return socketWrapper; } else { try { socketWrapper.close(); } catch (IOException e) { } return null; } } } } catch (Exception ex) { if (isTraceEnabled) { log.trace("Couldn't reuse connection from pool", ex); } try { socketWrapper.close(); } catch (Exception ignored) { } } } return null; } /** * Getter for property timeout * * @return Value of property timeout */ public int getTimeout() { return timeout; } public String toString() { return "SocketClientInvoker[" + Integer.toHexString(System.identityHashCode(this)) + ", " + locator.getProtocol() + "://" + locator.getHost() + ":" + locator.getPort() + "]"; } static private void connect(final Socket socket, final InetSocketAddress address, final int timeout) throws IOException { if (SecurityUtility.skipAccessControl()) { socket.connect(address, timeout); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { socket.connect(address, timeout); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/TransportServerFa0000644000175000017500000000104310455077561033547 0ustar twernertwernerpackage org.jboss.remoting.transport.socket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new SocketServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/ServerSocketWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/ServerSocketWrapp0000644000175000017500000000652111160603172033537 0ustar twernertwerner/* * 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.remoting.transport.socket; import java.io.EOFException; import java.io.IOException; import java.io.OutputStream; import java.net.Socket; import java.util.Map; import org.jboss.logging.Logger; /** * @author Tom Elrod */ public class ServerSocketWrapper extends ClientSocketWrapper { final static private Logger log = Logger.getLogger(ServerSocketWrapper.class); public ServerSocketWrapper(Socket socket) throws Exception { super(socket); } public ServerSocketWrapper(Socket socket, Map metadata, Integer timeout) throws Exception { super(socket, metadata, timeout); } public synchronized void close() throws IOException { if(socket != null) { try { getOutputStream().write(CLOSING); getOutputStream().write(CLOSING); getOutputStream().flush(); log.trace(this + " wrote CLOSING"); } catch (IOException e) { log.trace(this + " unable to writing CLOSING byte", e); } super.close(); socket = null; } } public void checkConnection() throws IOException { // Perform acknowledgement to convince client // that the socket is still active int ACK = 0; //long startWait = System.currentTimeMillis(); try { // ACK = ((ObjectInputStream) getInputStream()).readByte(); ACK = getInputStream().read(); } catch(EOFException eof) { log.trace("EOFException waiting on ACK in read()."); throw eof; } catch(IOException e) { log.debug("IOException when reading in ACK: " + e.getMessage()); log.trace("IOException when reading in ACK", e); throw e; } if(log.isTraceEnabled()) { log.trace("acknowledge read byte: " + ACK + ": " + Thread.currentThread()); } // ObjectOutputStream out = (ObjectOutputStream) getOutputStream(); OutputStream out = getOutputStream(); // out.writeByte(ACK); // out.flush(); // out.reset(); out.write(ACK); out.flush(); } public String toString() { Socket socket = getSocket(); return "ServerSocketWrapper[" + socket + "." + Integer.toHexString(System.identityHashCode(socket)) + "]"; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/SocketServerInvokerMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/SocketServerInvok0000644000175000017500000000436010404171322033530 0ustar twernertwerner/* * 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.remoting.transport.socket; import org.jboss.remoting.ServerInvokerMBean; /** * MBean interface. */ public interface SocketServerInvokerMBean extends ServerInvokerMBean { /** * Starts the invoker. */ void start() throws java.io.IOException; /** * Stops the invoker. */ void stop(); int getCurrentThreadPoolSize(); int getCurrentClientPoolSize(); /** * Getter for property numAcceptThreads * * @return The number of threads that exist for accepting client connections */ int getNumAcceptThreads(); /** * Setter for property numAcceptThreads * * @param size The number of threads that exist for accepting client connections */ void setNumAcceptThreads(int size); /** * Setter for max pool size. The number of server threads for processing client. The default is 300. * * @return */ int getMaxPoolSize(); /** * The number of server threads for processing client. The default is 300. * * @param maxPoolSize */ void setMaxPoolSize(int maxPoolSize); /** * Getter for property serverBindPort. * * @return Value of property serverBindPort. */ int getServerBindPort(); int getBacklog(); void setBacklog(int backlog); } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/OpenConnectionChecker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/OpenConnectionChe0000644000175000017500000000242410560766661033465 0ustar twernertwerner/* * 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.remoting.transport.socket; import java.io.IOException; /** * * @author Ron Sigal * @version $Revision: 2039 $ *

          * Copyright Feb 1, 2007 *

          */ public interface OpenConnectionChecker { void checkOpenConnection() throws IOException; } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/ServerAddress.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/socket/ServerAddress.jav0000644000175000017500000001042610732420245033442 0ustar twernertwerner/* * 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.remoting.transport.socket; import java.io.IOException; import java.io.Serializable; /** * This class encapsulates all the required information for a client to * establish a connection with the server. *

          * It also attempts to provide a fast hash() function since this object * is used as a key in a hashmap mainted by the ConnectionManager. * * @author Hiram Chirino * @version $Revision: 3186 $ */ public class ServerAddress implements Serializable { /** * The serialVersionUID @since 1.1.4.1 */ private static final long serialVersionUID = -7206359745950445445L; /** * Address of host ot connect to */ public String address; /** * Port the service is listening on */ public int port; /** * If the TcpNoDelay option should be used on the socket. */ public boolean enableTcpNoDelay = false; /** * Timeout of setSoTimeout */ public int timeout = 60000; /** * Maximum size of connection pool */ public int maxPoolSize; /** * This object is used as a key in a hashmap, * so we precompute the hascode for faster lookups. */ private transient int hashCode; public ServerAddress(String address, int port, boolean enableTcpNoDelay, int timeout, int maxPoolSize) { this.address = address; this.port = port; this.enableTcpNoDelay = enableTcpNoDelay; this.hashCode = address.hashCode() + port; if (enableTcpNoDelay) { this.hashCode ++; } if(timeout >= 0) { this.timeout = timeout; } this.hashCode = 7 * this.hashCode + timeout; this.maxPoolSize = maxPoolSize; this.hashCode = 11 * this.hashCode + maxPoolSize; } public String toString() { return "ServerAddress[" + address + ":" + port + (enableTcpNoDelay ? ", enableTcpNoDelay" : ", NO enableTcpNoDelay") + " timeout " + timeout + " ms" + ", maxPoolSize=" + maxPoolSize + "]"; } public boolean equals(Object obj) { try { // Compare this to obj ServerAddress o = (ServerAddress)obj; if (port != o.port) { return false; } if (!address.equals(o.address)) { return false; } if (enableTcpNoDelay != o.enableTcpNoDelay) { return false; } if (timeout != o.timeout) { return false; } if (maxPoolSize != o.maxPoolSize) { return false; } return true; } catch (Throwable e) { return false; } } public int hashCode() { return hashCode; } /** * Create the transient hashCode * * @param in * @throws IOException * @throws ClassNotFoundException */ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { // Trigger default serialization in.defaultReadObject(); // Build the hashCode this.hashCode = address.hashCode() + port; if (enableTcpNoDelay) { this.hashCode ++; } this.hashCode = 7 * this.hashCode + timeout; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/ServerFactory.java0000644000175000017500000000257610455077561032357 0ustar twernertwerner/* * 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.remoting.transport; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public interface ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException; public boolean supportsSSL(); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/ConnectorMBean.java0000644000175000017500000001366410365202142032377 0ustar twernertwerner/* * 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.remoting.transport; import org.jboss.remoting.ConnectionListener; /** * MBean interface. */ public interface ConnectorMBean { /** * Starts the connector. */ void start() throws java.lang.Exception; /** * Starts the connector. * * @param runAsNewThread indicates if should be started on new thread or the current one * @throws java.lang.Exception */ void start(boolean runAsNewThread) throws java.lang.Exception; /** * Stops the connector. */ void stop(); /** * Creates the connector. */ void create() throws java.lang.Exception; /** * Destroys the connector. */ void destroy(); /** * Returns the locator to the connector. Locator is the actual InvokerLocator object used to identify and get the ServerInvoker we are wrapping. */ org.jboss.remoting.InvokerLocator getLocator(); /** * Sets the invoker locator. InvokerLocator is the string URI representation of the InvokerLocator used to get and identify the ServerInvoker we are wrapping. */ void setInvokerLocator(java.lang.String locator) throws java.lang.Exception; /** * Returns the invoker locator. InvokerLocator is the string URI representation of the InvokerLocator used to get and identify the ServerInvoker we are wrapping. */ java.lang.String getInvokerLocator() throws java.lang.Exception; /** * Configuration is an xml element indicating subsystems to be registered with the ServerInvoker we wrap. Using mbean subsystems that call registerSubsystem is more flexible. */ void setConfiguration(org.w3c.dom.Element xml) throws java.lang.Exception; /** * Configuration is an xml element indicating subsystems to be registered with the ServerInvoker we wrap. Using mbean subsystems that call registerSubsystem is more flexible. */ org.w3c.dom.Element getConfiguration(); /** * Adds a handler to the connector via OjbectName. This will create a mbean proxy of type of ServerInvocationHandler for the MBean specified by object name passed (so has to implement ServerInvocationHandler interface). * * @param subsystem * @param handlerObjectName * @return The previous ServerInvocationHandler with the same subsystem value (case insensitive), if one existed. Otherwise will return null. * @throws Exception */ org.jboss.remoting.ServerInvocationHandler addInvocationHandler(java.lang.String subsystem, javax.management.ObjectName handlerObjectName) throws java.lang.Exception; /** * Adds an invocation handler for the named subsystem to the invoker we manage, and sets the mbean server on the invocation handler. * Will return previous ServerInvocationHandler with same subsystem value (case insensitive), if one existed. Otherwise will return null. */ org.jboss.remoting.ServerInvocationHandler addInvocationHandler(java.lang.String subsystem, org.jboss.remoting.ServerInvocationHandler handler) throws java.lang.Exception; /** * Removes an invocation handler for the supplied subsystem from the invoker we manage, and unsets the MBeanServer on the handler. */ void removeInvocationHandler(java.lang.String subsystem) throws java.lang.Exception; /** * Adds a connection listener to receive notification when a client connection * is lost or disconnected. Will only be triggered for notifications when * leasing is turned on (via the lease period attribute being set to > 0). * @param listener * * @jmx.managed-operation description = "Add a connection listener to call when detect that a client has * failed or disconnected." * impact = "ACTION" * @jmx.managed-parameter name = "listener" * type = "org.jboss.remoting.ConnectionListener" * description = "The connection listener to register" */ void addConnectionListener(ConnectionListener listener); /** * Removes connection listener from receiving client connection lost/disconnected * notifications. * @param listener * * @jmx.managed-operation description = "Remove a client connection listener." * impact = "ACTION" * @jmx.managed-parameter name = "listener" * type = "org.jboss.remoting.ConnectionListener" * description = "The client connection listener to remove." */ void removeConnectionListener(ConnectionListener listener); /** * Sets the lease period for client connections. * Value is in milliseconds. * @param leasePeriodValue * * @jmx.managed-attribute description = "The number of milliseconds that should be used * when establishing the client lease period (meaning client will need to update its lease * within this amount of time or will be considered dead)." * access = "read-write" */ void setLeasePeriod(long leasePeriodValue); /** * Gets the lease period for client connections. * Value in milliseconds. * @return * * @jmx.managed-attribute */ long getLeasePeriod(); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/BidirectionalClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/BidirectionalClientInvok0000644000175000017500000000334310434337013033534 0ustar twernertwerner/* * 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.remoting.transport; import org.jboss.remoting.InvokerLocator; import java.util.Map; /** * This interface is used to indicate that a client invoker represents * as transport that is bidirectional, which means that calls from the * server to the client can be made without having to open a new physical connection * from the server back to the client/ * * @author Tom Elrod */ public interface BidirectionalClientInvoker extends ClientInvoker { /** * Gets the locator to be used for callbacks when want do not want * to establish a new physical connectiong from the server to the client. * @param metadata * @return */ public InvokerLocator getCallbackLocator(Map metadata); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/Connector.java0000644000175000017500000015103411422065010031462 0ustar twernertwerner/* * 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.remoting.transport; import org.jboss.logging.Logger; import org.jboss.remoting.ConnectionListener; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerConfiguration; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.ServerInvocationHandlerWrapper; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.MarshallLoaderFactory; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.util.SecurityUtility; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import javax.management.MBeanRegistration; import javax.management.MBeanServer; import javax.management.MBeanServerInvocationHandler; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; /** * Connector is an implementation of the ConnectorMBean interface. *

          * The Connector is root component for the remoting server. It binds the server transport, marshaller, * and handler together to form the remoting server instance. *

          * A transport connector is configured via *-service.xml such as: * * * * * * * *

          * *

          * * * * * * * * * * 1 * 303 * 304 * 60000 * ${jboss.bind.address} * 6666 * * * false * 200 * * * org.jboss.remoting.transport.mock.MockServerInvocationHandler * * * * *

          * * * * 2410 * *

          * * * * @author Jeff Haynie * @author Adrian Brock * @author David Jencks * @author Juha Lindfors * @author Tom Elrod * @version $Revision: 5925 $ * @jmx.mbean description = "An MBean wrapper around a ServerInvoker." * @jboss.xmbean */ public class Connector implements MBeanRegistration, ConnectorMBean { protected ServerInvoker invoker; private String locatorURI; private Element xml; private ServerConfiguration serverConfiguration; private Map configuration = new HashMap(); private MBeanServer server; private ServerSocketFactory svrSocketFactory; private SocketFactory socketFactory; private Connector marshallerLoaderConnector = null; private boolean isMarshallerLoader = false; private List remoteClassLoaders; private boolean isStarted = false; private boolean isCreated = false; protected static final Logger log = Logger.getLogger(Connector.class); private static final InetAddress LOCAL_HOST; static { try { LOCAL_HOST = (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } }); } catch (PrivilegedActionException e) { log.debug(Connector.class.getName() + " unable to get local host address", e.getCause()); throw new ExceptionInInitializerError(e.getCause()); } catch (SecurityException e) { log.debug(Connector.class.getName() + " unable to get local host address", e); throw e; } } /** * Empty constructor. */ public Connector() { } /** * Creates Connector with specified locator. * * @param locatorURI */ public Connector(String locatorURI) { this.locatorURI = locatorURI; } /** * Creates Connector with specified locator. * * @param locator */ public Connector(InvokerLocator locator) { if (locator != null) { this.locatorURI = locator.getLocatorURI(); } } /** * Constructs connector and populates configuration information. * * @param configuration */ public Connector(Map configuration) { this.configuration.putAll(configuration); } /** * Constructs connector for given locator and configuration. * * @param locatorURI * @param configuration */ public Connector(String locatorURI, Map configuration) { this.locatorURI = locatorURI; this.configuration.putAll(configuration); } /** * Constructs connector for given locator and configuration. * * @param locator * @param configuration */ public Connector(InvokerLocator locator, Map configuration) { if (locator != null) { this.locatorURI = locator.getLocatorURI(); } if (configuration != null) { this.configuration.putAll(configuration); } } protected Connector(boolean isMarshallerConnector) { this(); this.isMarshallerLoader = isMarshallerConnector; } /** * Indicates if the connector has been started yet. * * @return */ public boolean isStarted() { return isStarted; } /** * This method is called by the MBeanServer before registration takes * place. The MBean is passed a reference of the MBeanServer it is * about to be registered with. The MBean must return the ObjectName it * will be registered with. The MBeanServer can pass a suggested object * depending upon how the MBean is registered.

          *

          * The MBean can stop the registration by throwing an exception.The * exception is forwarded to the invoker wrapped in an * MBeanRegistrationException. * * @param server the MBeanServer the MBean is about to be * registered with. * @param name the suggested ObjectName supplied by the * MBeanServer. * @return the actual ObjectName to register this MBean with. * @throws Exception for any error, the MBean is not registered. */ public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { this.server = server; return name; } /** * This method is called by the MBeanServer after registration takes * place or when registration fails. * * @param registrationDone the MBeanServer passes true when the * MBean was registered, false otherwise. */ public void postRegister(Boolean registrationDone) { } /** * This method is called by the MBeanServer before deregistration takes * place.

          *

          * The MBean can throw an exception, this will stop the deregistration. * The exception is forwarded to the invoker wrapped in * an MBeanRegistrationException. */ public void preDeregister() throws Exception { } /** * This method is called by the MBeanServer after deregistration takes * place. */ public void postDeregister() { } /** * Starts the connector. This is when configuration will be applied and server invoker created. * * @jmx.managed-operation description = "Start sets up the ServerInvoker we are wrapping." * impact = "ACTION" */ public void start() throws Exception { if (!isStarted) { // doing this for those who use remoting outside of jboss container // so don't have to call create() and then start() if (!isCreated) { create(); } // want to have handlers registered before starting, so if someone makes invocation, // there is something to handle it. if (serverConfiguration != null) { configureHandlersFromServerConfiguration(); } else if (xml != null) { configureHandlersFromXML(); } // if marshaller loader not started, start it if (!isMarshallerLoader) { if (marshallerLoaderConnector != null && !marshallerLoaderConnector.isStarted()) { marshallerLoaderConnector.start(); } } // if invoker not started, start it if (invoker.isStarted() == false) { try { invoker.start(); } catch (Exception e) { if (marshallerLoaderConnector != null) { marshallerLoaderConnector.stop(); } log.debug("Error starting connector.", e); throw e; } } isStarted = true; log.debug(this + " started"); } } /** * Starts the connector. * * @param runAsNewThread indicates if should be started on new thread or the current one. If * runAsNewThread is true, new thread will not be daemon thread. * @throws Exception */ public void start(boolean runAsNewThread) throws Exception { Runnable r = new Runnable() { public void run() { try { start(); } catch (Exception e) { log.error("Error starting Connector.", e); } } }; Thread t = new Thread(r); t.setDaemon(false); t.start(); } private void init() throws Exception { Map invokerConfig = new HashMap(); if (locatorURI == null) { // InvokerLocator attribute not set; check to see if serverConfiguration is set. if (serverConfiguration != null) { getInvokerConfigFromServerConfiguration(invokerConfig); } // Check to see if Configuration attribute is set. else if (xml != null) { getInvokerConfigFromXML(invokerConfig); } configuration.putAll(invokerConfig); } if (locatorURI == null) { throw new IllegalStateException("Connector not configured with LocatorURI."); } final InvokerLocator locator = new InvokerLocator(locatorURI); if (invoker == null) { // create the server invoker try { invoker = (ServerInvoker) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return InvokerRegistry.createServerInvoker(locator, configuration); } }); } catch (PrivilegedActionException pae) { throw pae.getException(); } invoker.setMBeanServer(server); // set the server socket factory if has been already set on the connector invoker.setServerSocketFactory(svrSocketFactory); // seting to null as don't want to keep reference in connector, but the server invoker // see JBREM-367 this.svrSocketFactory = null; // set the socket factory if has been already set on the connector invoker.setSocketFactory(socketFactory); this.socketFactory = null; invoker.create(); // this will set the mbean server on the invoker and register it with mbean server if (server != null) { try { final ObjectName objName = new ObjectName(invoker.getMBeanObjectName()); try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { if (!server.isRegistered(objName)) { server.registerMBean(invoker, objName); } else { log.warn(objName + " is already registered with MBeanServer"); } return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } catch (Throwable e) { log.warn("Error registering invoker " + invoker + " with MBeanServer.", e); } } } // if using a generic locator (such as socket://localhost:0), the locator may change so // keep the local cache in synch locatorURI = invoker.getLocator().getLocatorURI(); if (remoteClassLoaders == null) { Object o = configuration.get(Remoting.REMOTE_CLASS_LOADERS); if (o instanceof List) { setRemoteClassLoaders((List) o); } else if (o != null) { log.warn("value of " + Remoting.REMOTE_CLASS_LOADERS + " must be a List"); } } if (!isMarshallerLoader) { // need to check if should create a marshaller loader on the server side if (marshallerLoaderConnector == null) { marshallerLoaderConnector = createMarshallerLoader(invoker.getLocator()); } } } private Connector createMarshallerLoader(InvokerLocator locator) { /** * This is a bit of a hack, but have to bootstrap the marshaller/unmarshaller here because * need them loaded and added to the MarshalFactory now, because is possible the first client * to make a call on this connector may not have the marshaller/unmarshaller. Therefore, when * the MarshallerLoaderHandler goes to load them for the client (MarshallerLoaderClient), they * have to be there. Otherwise, would not be loaded until first client actually reaches the * target server invoker, where they would otherwise be loaded. */ ClassLoader classLoader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Connector.class.getClassLoader(); } }); MarshalFactory.getMarshaller(locator, classLoader, configuration); Connector marshallerLoader = null; InvokerLocator loaderLocator = MarshallLoaderFactory.convertLocator(locator); // if loaderLocator is null, then probably not defined to have loader service (i.e. no loader port specified) if (loaderLocator != null) { marshallerLoader = MarshallLoaderFactory.createMarshallLoader(loaderLocator, remoteClassLoaders, server); } return marshallerLoader; } private void getInvokerConfigFromXML(Map invokerConfig) { try { NodeList invokerNodes = xml.getElementsByTagName("invoker"); if (invokerNodes != null && invokerNodes.getLength() >= 1) { // only accept on invoker per connector at present Node invokerNode = invokerNodes.item(0); NamedNodeMap attributes = invokerNode.getAttributes(); Node transportNode = attributes.getNamedItem("transport"); if (transportNode != null) { String transport = transportNode.getNodeValue(); // need to log warning if there are more than one invoker elements if (invokerNodes.getLength() > 1) { log.warn("Found more than one invokers defined in configuration. " + "Will only be using the first one - " + transport); } // now create a map for all the sub attributes Map paramConfig = new HashMap(); // In case of a multihome configuration. List homes = new ArrayList(); List connectHomes = new ArrayList(); NodeList invokerAttributes = invokerNode.getChildNodes(); int len = invokerAttributes.getLength(); for (int x = 0; x < len; x++) { Node attr = invokerAttributes.item(x); if ("attribute".equals(attr.getNodeName())) { String name = attr.getAttributes().getNamedItem("name").getNodeValue(); String value = attr.getFirstChild().getNodeValue(); if ("homes".equals(name)) { processHomes(attr, "home", homes); } else if ("connecthomes".equals(name)) { processHomes(attr, "connecthome", connectHomes); } else { invokerConfig.put(name, value); } Node isParamAttribute = attr.getAttributes().getNamedItem("isParam"); if (isParamAttribute != null && Boolean.valueOf(isParamAttribute.getNodeValue()).booleanValue()) { paramConfig.put(name, value); } } } if (homes.isEmpty() && !connectHomes.isEmpty()) { throw new Exception("Configuration has a " + InvokerLocator.CONNECT_HOMES_KEY + " without a " + InvokerLocator.HOMES_KEY); } // should now have my map with all my attributes, now need to look for // specific attributes that will impact the locator uri. String clientConnectAddress = (String) invokerConfig.get("clientConnectAddress"); String clientConnectPort = (String) invokerConfig.get("clientConnectPort"); String serverBindAddress = (String) invokerConfig.get("serverBindAddress"); String serverBindPort = (String) invokerConfig.get("serverBindPort"); String localHostAddress = getLocalHost().getHostAddress(); String tempURI = null; String path = (String) invokerConfig.get("path"); PortUtil.updateRange(invokerConfig); if (homes.isEmpty() && connectHomes.isEmpty()) { int port = clientConnectPort != null ? Integer.parseInt(clientConnectPort) : serverBindPort != null ? Integer.parseInt(serverBindPort) : PortUtil.findFreePort(serverBindAddress != null ? serverBindAddress : localHostAddress); String host = clientConnectAddress != null ? clientConnectAddress : serverBindAddress != null ? serverBindAddress : localHostAddress; // finally, let's build the invoker uri tempURI = transport + "://" + fixHostnameForURL(host) + ":" + port; if (path != null) { tempURI += "/" + path; } } else { String port = clientConnectPort != null ? ":" + clientConnectPort : serverBindPort != null ? ":" + serverBindPort : ""; tempURI = transport + "://multihome" + port; if (path != null) { tempURI += "/" + path; } tempURI += "/?"; Iterator it = homes.iterator(); tempURI += "homes=" + it.next(); while (it.hasNext()) { tempURI += "!" + it.next(); } if (!connectHomes.isEmpty()) { tempURI += "&connecthomes="; it = connectHomes.iterator(); tempURI += it.next(); while (it.hasNext()) { tempURI += "!" + it.next(); } } } // any params to add to the uri? if (paramConfig.size() > 0) { if (tempURI.indexOf("/?") < 0) tempURI += "/?"; else tempURI += "&"; Iterator keyItr = paramConfig.keySet().iterator(); if (keyItr.hasNext()) { Object name = keyItr.next(); Object value = paramConfig.get(name); tempURI += name + "=" + value; } while (keyItr.hasNext()) { tempURI += "&"; Object name = keyItr.next(); Object value = paramConfig.get(name); tempURI += name + "=" + value; } } locatorURI = tempURI; } else { log.error("Invoker element within Configuration attribute does not contain a transport attribute."); } } } catch (Exception e) { log.error("Error configuring invoker for connector: " + e.getMessage()); log.debug("Error configuring invoker for connector.", e); throw new IllegalStateException("Error configuring invoker for connector. Can not continue without invoker."); } } private void processHomes(Node node, String homeType, List homes) { NodeList nodes = node.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node child = nodes.item(i); if (Node.ELEMENT_NODE == child.getNodeType()) { if (homeType.equals(child.getNodeName())) { NodeList children = child.getChildNodes(); for (int k = 0; k < children.getLength(); k++) { Node grandchild = children.item(k); if (Node.TEXT_NODE == grandchild.getNodeType()) { homes.add(grandchild.getNodeValue()); } } } } } } private void getInvokerConfigFromServerConfiguration(Map invokerConfig) throws Exception { try { String transport = serverConfiguration.getTransport(); if (transport == null) { log.error("ServerConfiguration must contain a non-null transport attribute."); return; } Map locatorParameters = serverConfiguration.getInvokerLocatorParameters(); Map serverParameters = serverConfiguration.getServerParameters(); // Remove single home elements meant to be ignored. String temp = (String) serverParameters.remove("clientConnectAddress"); if (temp != null) log.warn("clientConnectAddress in server parameters will be ignored"); temp = (String) serverParameters.remove("clientConnectPort"); if (temp != null) log.warn("clientConnectPort in server parameters will be ignored"); temp = (String) serverParameters.get("serverBindAddress"); if (temp != null) { locatorParameters.remove("serverBindAddress"); log.warn("serverBindAddress in locator parameters will be ignored"); } temp = (String) serverParameters.get("serverBindPort"); if (temp != null) { locatorParameters.remove("serverBindPort"); log.warn("serverBindPort in locator parameters will be ignored"); } // Adjust multihome elements. temp = (String) serverParameters.remove(InvokerLocator.CONNECT_HOMES_KEY); if (temp != null) log.warn(InvokerLocator.CONNECT_HOMES_KEY + " in server parameters will be ignored"); temp = (String) serverParameters.remove(InvokerLocator.HOMES_KEY); if (temp != null) { if (locatorParameters.get(InvokerLocator.HOMES_KEY) == null) locatorParameters.put(InvokerLocator.HOMES_KEY, temp); else log.warn(InvokerLocator.HOMES_KEY + " in server parameters will be ignored"); } // If there is a connect homes value, then there must be a homes value. if (locatorParameters.get(InvokerLocator.CONNECT_HOMES_KEY) != null && locatorParameters.get(InvokerLocator.HOMES_KEY) == null) { throw new Exception("Configuration has a " + InvokerLocator.CONNECT_HOMES_KEY + " without a " + InvokerLocator.HOMES_KEY); } // Get multihome parameters. String connectHomes = (String) locatorParameters.remove(InvokerLocator.CONNECT_HOMES_KEY); String homes = (String) serverParameters.remove(InvokerLocator.HOMES_KEY); temp = (String) locatorParameters.remove(InvokerLocator.HOMES_KEY); if (homes == null) homes = temp; locatorParameters = new HashMap(serverConfiguration.getInvokerLocatorParameters()); serverParameters = new HashMap(serverConfiguration.getServerParameters()); // Get single home parameters. String clientConnectAddress = (String) locatorParameters.remove("clientConnectAddress"); String clientConnectPort = (String) locatorParameters.remove("clientConnectPort"); String serverBindAddress = (String) serverParameters.get("serverBindAddress"); String defaultPortString = (String) serverParameters.get("serverBindPort"); temp = (String) locatorParameters.remove("serverBindAddress"); if (serverBindAddress == null) serverBindAddress = temp; temp = (String) locatorParameters.remove("serverBindPort"); if (defaultPortString == null) defaultPortString = temp; String path = (String) locatorParameters.remove("path"); PortUtil.updateRange(invokerConfig); String tempURI = null; boolean parametersStarted = false; if (connectHomes == null && homes == null) { String localHostAddress = getLocalHost().getHostAddress(); // A single home configuration. String host = clientConnectAddress != null ? clientConnectAddress : serverBindAddress != null ? serverBindAddress : localHostAddress; int port = clientConnectPort != null ? Integer.parseInt(clientConnectPort) : defaultPortString != null ? Integer.parseInt(defaultPortString) : PortUtil.findFreePort(serverBindAddress != null ? serverBindAddress : localHostAddress); tempURI = transport + "://" + fixHostnameForURL(host) + ":" + port + ((path != null) ? ("/" + path) : ""); } else { // A multihome configuration. tempURI = transport + "://multihome" + ((path != null) ? ("/" + path) : ""); parametersStarted = true; tempURI += "/?"; if (connectHomes != null) { tempURI += InvokerLocator.CONNECT_HOMES_KEY + "=" + connectHomes; if (homes != null) tempURI += "&" + InvokerLocator.HOMES_KEY + "=" + homes; } else if (homes != null) tempURI += InvokerLocator.HOMES_KEY + "=" + homes; } // any params to add to the uri? if (locatorParameters.size() > 0) { if (!parametersStarted) tempURI += "/?"; else tempURI += "&"; Iterator keyItr = locatorParameters.keySet().iterator(); if (keyItr.hasNext()) { Object name = keyItr.next(); Object value = locatorParameters.get(name); tempURI += name + "=" + value; } while (keyItr.hasNext()) { tempURI += "&"; Object name = keyItr.next(); Object value = locatorParameters.get(name); tempURI += name + "=" + value; } } locatorURI = tempURI; invokerConfig.putAll(serverConfiguration.getServerParameters()); invokerConfig.putAll((serverConfiguration.getInvokerLocatorParameters())); } catch (Exception e) { log.error("Error configuring invoker for connector: " + e.getMessage()); log.debug("Error configuring invoker for connector.", e); throw new IllegalStateException("Error configuring invoker from configuration POJO. Can not continue without invoker."); } } // adds enclosing brackets if an IPv6 literal address private String fixHostnameForURL(String address) { if (address == null) return address ; if (address.indexOf(':') != -1 && address.indexOf("[") == -1) return "[" + address + "]" ; else return address ; } private void configureHandlersFromServerConfiguration() throws Exception { Map handlerMap = serverConfiguration.getInvocationHandlers(); if (handlerMap.size() == 0 && (getInvocationHandlers() == null || getInvocationHandlers().length == 0)) { throw new IllegalArgumentException("invocationHandlers list empty and are no registered handlers found."); } Iterator it = handlerMap.keySet().iterator(); while (it.hasNext()) { String subsystems = (String) it.next(); Object value = handlerMap.get(subsystems); ServerInvocationHandler handler = null; if (value instanceof ServerInvocationHandler) { handler = (ServerInvocationHandler) value; } else if (value instanceof String) { //first check to see if this is an ObjectName String valueString = (String) value; boolean isObjName = false; try { ObjectName objName = new ObjectName(valueString); handler = createHandlerProxy(objName); isObjName = true; } catch (MalformedObjectNameException e) { log.debug("Handler supplied is not an object name."); } if (!isObjName) { Class serverInvocationHandlerClass = ClassLoaderUtility.loadClass(valueString, Connector.class); handler = (ServerInvocationHandler) serverInvocationHandlerClass.newInstance(); } } else { throw new IllegalArgumentException("handler has invalid type: " + value); } StringTokenizer tok = new StringTokenizer(subsystems, ","); while (tok.hasMoreTokens()) { String subsystem = tok.nextToken(); addInvocationHandler(subsystem, handler); } } } private void configureHandlersFromXML() throws Exception { NodeList handlersNodes = xml.getElementsByTagName("handler"); if ((handlersNodes == null || handlersNodes.getLength() <= 0) && (getInvocationHandlers() == null || getInvocationHandlers().length == 0)) { throw new IllegalArgumentException("required 'handler' element not found and are no registered handlers found."); } int len = handlersNodes.getLength(); for (int c = 0; c < len; c++) { Node node = handlersNodes.item(c); Node subNode = node.getAttributes().getNamedItem("subsystem"); if (subNode == null) { throw new IllegalArgumentException("Required 'subsystem' attribute on 'handler' element"); } String handlerClass = node.getFirstChild().getNodeValue(); boolean isObjName = false; ServerInvocationHandler handler = null; //first check to see if this is an ObjectName try { ObjectName objName = new ObjectName(handlerClass); handler = createHandlerProxy(objName); isObjName = true; } catch (MalformedObjectNameException e) { log.debug("Handler supplied is not an object name."); } if (!isObjName) { Class serverInvocationHandlerClass = ClassLoaderUtility.loadClass(handlerClass, Connector.class); handler = (ServerInvocationHandler) serverInvocationHandlerClass.newInstance(); // handler = (ServerInvocationHandler) cl.loadClass(handlerClass).newInstance(); } StringTokenizer tok = new StringTokenizer(subNode.getNodeValue(), ","); while (tok.hasMoreTokens()) { String subsystem = tok.nextToken(); addInvocationHandler(subsystem, handler); } } } private ServerInvocationHandler createHandlerProxy(ObjectName objName) { ServerInvocationHandler handler; if (server != null) { handler = (ServerInvocationHandler) MBeanServerInvocationHandler.newProxyInstance(server, objName, ServerInvocationHandler.class, false); handler = new ServerInvocationHandlerWrapper(handler); } else { throw new RuntimeException("Can not register MBean invocation handler as the Connector has not been registered with a MBeanServer."); } return handler; } /** * Adds a connection listener to receive notification when a client connection * is lost or disconnected. Will only be triggered for notifications when * leasing is turned on (via the lease period attribute being set to > 0). * * @param listener * @jmx.managed-operation description = "Add a connection listener to call when detect that a client has * failed or disconnected." * impact = "ACTION" * @jmx.managed-parameter name = "listener" * type = "org.jboss.remoting.ConnectionListener" * description = "The connection listener to register" */ public void addConnectionListener(ConnectionListener listener) { if (invoker != null) { invoker.addConnectionListener(listener); } } /** * Removes connection listener from receiving client connection lost/disconnected * notifications. * * @param listener * @jmx.managed-operation description = "Remove a client connection listener." * impact = "ACTION" * @jmx.managed-parameter name = "listener" * type = "org.jboss.remoting.ConnectionListener" * description = "The client connection listener to remove." */ public void removeConnectionListener(ConnectionListener listener) { if (invoker != null) { invoker.removeConnectionListener(listener); } } /** * Sets the lease period for client connections. * Value is in milliseconds. * * @param leasePeriodValue * @jmx.managed-attribute description = "The number of milliseconds that should be used * when establishing the client lease period (meaning client will need to update its lease * within this amount of time or will be considered dead)." * access = "read-write" */ public void setLeasePeriod(long leasePeriodValue) { if (invoker != null) { invoker.setLeasePeriod(leasePeriodValue); } } /** * Gets the lease period for client connections. * Value in milliseconds. * * @return * @jmx.managed-attribute */ public long getLeasePeriod() { if (invoker != null) { return invoker.getLeasePeriod(); } else { return -1; } } /** * Stops the connector. Will also stop and destroy server invoker (transport) * * @jmx.managed-operation description = "Stop tears down the ServerInvoker we are wrapping." * impact = "ACTION" */ public void stop() { if (isStarted) { if (invoker != null) { if (server != null) { try { ObjectName objName = new ObjectName(invoker.getMBeanObjectName()); unregisterMBean(server, objName); } catch (Exception e) { log.error("invalid Object Name", e); } } log.trace(this + " shutting down server invoker"); invoker.stop(); invoker.destroy(); AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.destroyServerInvoker(invoker); return null; } }); invoker = null; } if (marshallerLoaderConnector != null && marshallerLoaderConnector.isStarted) { marshallerLoaderConnector.stop(); marshallerLoaderConnector = null; } isStarted = false; } log.trace(this + " is stopped"); } /** * Creates the connector. * * @jmx.managed-operation */ public void create() throws Exception { if (!isCreated) { try { init(); isCreated = true; } catch (Exception e) { // unwind create process if (invoker != null) { invoker.stop(); invoker.destroy(); AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.destroyServerInvoker(invoker); return null; } }); invoker = null; } isCreated = false; throw e; } } } /** * Destroys the connector. * * @jmx.managed-operation */ public void destroy() { if (isStarted) { stop(); } if (invoker != null) { invoker.stop(); invoker.destroy(); AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.destroyServerInvoker(invoker); return null; } }); invoker = null; } isCreated = false; } public ServerInvoker getServerInvoker() { return invoker; } /** * Will get array of all the handlers registered with the connector's server invoker. * * @return */ public ServerInvocationHandler[] getInvocationHandlers() { ServerInvocationHandler[] handlers = null; if (invoker != null) { handlers = invoker.getInvocationHandlers(); } return handlers; } /** * Returns the locator to the connector. Locator is the actual InvokerLocator * object used to identify and get the ServerInvoker we are wrapping. * * @jmx.managed-attribute description = "Locator is the actual InvokerLocator object used to * identify and get the ServerInvoker we are wrapping." * access = "read-only" */ public InvokerLocator getLocator() { return invoker.getLocator(); } /** * Sets the invoker locator. InvokerLocator is the string URI representation * of the InvokerLocator used to get and identify the ServerInvoker * we are wrapping. * * @jmx.managed-attribute description = "InvokerLocator is the string URI representation of the * InvokerLocator used to get and identify the ServerInvoker * we are wrapping." * access = "read-write" */ public void setInvokerLocator(String locator) throws Exception { if (!isCreated) { locatorURI = locator; } else { throw new RuntimeException("Can not set the invoker locator on this Connector " + "as has already been created with a different locator."); } } /** * Returns the invoker locator. InvokerLocator is the string URI representation * of the InvokerLocator used to get and identify the ServerInvoker * we are wrapping. * * @jmx.managed-attribute */ public String getInvokerLocator() throws Exception { return locatorURI; } /** * Configuration is an xml element indicating subsystems to be registered * with the ServerInvoker we wrap. Using mbean subsystems that call * registerSubsystem is more flexible. * * @jmx.managed-attribute description = "Configuration is an xml element indicating subsystems * to be registered with the ServerInvoker we wrap. Using * mbean subsystems that call registerSubsystem is more * flexible." * access = "read-write" */ public void setConfiguration(Element xml) throws Exception { this.xml = xml; } /** * Configuration is an xml element indicating subsystems to be registered * with the ServerInvoker we wrap. Using mbean subsystems that call * registerSubsystem is more flexible. * * @jmx.managed-attribute */ public Element getConfiguration() { return xml; } /** * Adds a handler to the connector via OjbectName. This will create a mbean proxy of * type of ServerInvocationHandler for the MBean specified by object name passed (so has * to implement ServerInvocationHandler interface). * * @param subsystem * @param handlerObjectName * @return Previous ServerInvocatioHandler with the same subsystem value (case insensitive) or null if one did not previously exist. * @throws Exception * @jmx.managed-operation description = "Add a subsystem invocation handler to the ServerInvoker * we wrap, identified by the subsystem parameter." * impact = "ACTION" * @jmx.managed-parameter name = "subsystem" * type = "java.lang.String" * description = "The subsystem this handler is for." * @jmx.managed-parameter name = "handlerObjectName" * type = "javax.management.ObjectName" * description = "The ServerInvocationHandler MBean we are registering * for the subsystem" */ public ServerInvocationHandler addInvocationHandler(String subsystem, ObjectName handlerObjectName) throws Exception { ServerInvocationHandler invocationHandler = createHandlerProxy(handlerObjectName); return addInvocationHandler(subsystem, invocationHandler); } /** * Adds an invocation handler for the named subsystem to the invoker we * manage, and sets the mbean server on the invocation handler. * * @return Previous ServerInvocatioHandler with the same subsystem value (case insensitive) or null if one did not previously exist. * @jmx.managed-operation description = "Add a subsystem invocation handler to the ServerInvoker * we wrap, identified by the subsystem parameter." * impact = "ACTION" * @jmx.managed-parameter name = "subsystem" * type = "java.lang.String" * description = "The subsystem this handler is for." * @jmx.managed-parameter name = "handler" * type = "org.jboss.remoting.ServerInvocationHandler" * description = "The ServerInvocationHandler we are registering * for the subsystem" */ public ServerInvocationHandler addInvocationHandler(String subsystem, final ServerInvocationHandler handler) throws Exception { if (invoker == null) { throw new IllegalStateException("You may only add handlers once the Connector is created (via create() method)."); } // In case handler is an MBean. AccessController.doPrivileged( new PrivilegedAction() { public Object run() { handler.setMBeanServer(server); return null; } }); return invoker.addInvocationHandler(subsystem, handler); } /** * Removes an invocation handler for the supplied subsystem from the invoker * we manage, and unsets the MBeanServer on the handler. * * @jmx.managed-operation description = "Remove a subsystem invocation handler to the * ServerInvoker we wrap, identified by the subsystem * parameter." * impact = "ACTION" * @jmx.managed-parameter name = "subsystem" * type = "java.lang.String" * description = "The subsystem this handler is for." */ public void removeInvocationHandler(String subsystem) throws Exception { ServerInvocationHandler handler = invoker.removeInvocationHandler(subsystem); if (handler != null) { handler.setMBeanServer(null); } } /** * The server socket factory can only be set on the Connector before the create() method * has been called. Otherwise, a runtime exception will be thrown. * @param serverSocketFactory */ public void setServerSocketFactory(ServerSocketFactory serverSocketFactory) { if(isCreated) { throw new RuntimeException("Can not set server socket factory on Connector after the create() method has been called."); } if (invoker != null) { invoker.setServerSocketFactory(serverSocketFactory); } else { this.svrSocketFactory = serverSocketFactory; } } public ServerSocketFactory getServerSocketFactory() { if (invoker != null) { return invoker.getServerSocketFactory(); } else { return svrSocketFactory; } } /** * The socket factory (for callbacks) can only be set on the Connector before the * create() method has been called. Otherwise, a runtime exception will be thrown. * @param socketFactory */ public void setSocketFactory(SocketFactory socketFactory) { if(isCreated) { throw new RuntimeException("Can not set socket factory on Connector after the create() method has been called."); } if (invoker != null) { invoker.setSocketFactory(socketFactory); } else { this.socketFactory = socketFactory; } } public SocketFactory getSocketFactory() { if (invoker != null) { return invoker.getSocketFactory(); } else { return socketFactory; } } public ServerConfiguration getServerConfiguration() { return serverConfiguration; } public void setServerConfiguration(ServerConfiguration serverConfig) { this.serverConfiguration = serverConfig; } public void setRemoteClassLoaders(List classLoaders) { if (classLoaders == null) return; SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("setContextClassLoader")); } this.remoteClassLoaders = classLoaders; } static private void unregisterMBean(final MBeanServer server, final ObjectName name) throws Exception { if (SecurityUtility.skipAccessControl()) { server.unregisterMBean(name); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { server.unregisterMBean(name); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } } static private InetAddress getLocalHost() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return doGetLocalHost(); } try { return (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { return doGetLocalHost(); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } static private InetAddress doGetLocalHost() throws UnknownHostException { if (LOCAL_HOST != null) { return LOCAL_HOST; } try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/PortUtil.java0000644000175000017500000001752211241424707031330 0ustar twernertwerner/* * 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.remoting.transport; import java.net.ServerSocket; import java.net.InetAddress; import java.net.UnknownHostException; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Map; import java.util.Random; import org.jboss.logging.Logger; /** * PortUtil is a set of utilities for dealing with TCP/IP ports * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5342 $ */ public class PortUtil { public static final String MIN_PORT = "minPort"; public static final String MAX_PORT = "maxPort"; private static final Logger log = Logger.getLogger(PortUtil.class); private static final int MIN_UNPRIVILEGED_PORT = 1024; private static final int MAX_LEGAL_PORT = 65535; private static int portCounter = 0; private static int retryMax = 50; private static int minPort = MIN_UNPRIVILEGED_PORT; private static int maxPort = MAX_LEGAL_PORT; static { portCounter = getRandomStartingPort(); } /** * Checks to see if the specified port is free. * * @param p * @return true if available, false if already in use */ public static boolean checkPort(final int p, final String host) { boolean available = true; ServerSocket socket = null; try { try { socket = (ServerSocket) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { InetAddress inetAddress = InetAddress.getByName(host); return new ServerSocket(p, 0, inetAddress); } }); } catch (PrivilegedActionException e) { available = false; throw (IOException) e.getCause(); } } catch (UnknownHostException e) { log.warn("unknown host: " + host); } catch (IOException e) { if ("Protocol family unavailable".equalsIgnoreCase(e.getMessage()) || "Protocol family not supported".equalsIgnoreCase(e.getMessage())) { log.debug("perhaps IPv6 is not available: " + e.getMessage()); } else { log.debug("port " + p + " already in use. Will try another.", e.getCause()); } } finally { if(socket != null) { try { socket.close(); } catch(IOException e) { } } } return available; } /** * Will try to find a port that is not in use up to 50 tries, at which point, * will throw an exception. * @return */ public static int findFreePort(String host) throws IOException { Integer port = null; int tryCount = 0; while(port == null && tryCount < retryMax) { port = getFreePort(host); if(port != null) { // validate port again, just in case two instances start on the port at same time. if(!checkPort(port.intValue(), host)) { port = null; } } tryCount++; } if(tryCount >= retryMax) { throw new IOException("Can not find a free port for use."); } return port.intValue(); } private static Integer getFreePort(String host) { int p = getNextPort(); if(checkPort(p, host)) { return new Integer(p); } else { return null; } } private static synchronized int getNextPort() { if (portCounter < maxPort) return portCounter++; portCounter = minPort; return maxPort; } public static int getRandomStartingPort() { int range = maxPort - minPort + 1; int port = new Random(System.currentTimeMillis()).nextInt(range) + minPort; return port; } public static synchronized int getMinPort() { return minPort; } public static synchronized void setMinPort(int minPort) throws IllegalStateException { if (minPort > PortUtil.maxPort) { String msg = "trying to set minPort to value greater than maxPort: " + minPort + " > " + PortUtil.maxPort; log.debug(msg); throw new IllegalStateException(msg); } if (minPort < PortUtil.minPort) { log.debug("will not set minPort to " + minPort + ": minPort is already " + PortUtil.minPort); return; } log.debug("setting minPort to " + minPort); PortUtil.minPort = minPort; } public static synchronized int getMaxPort() { return maxPort; } public static synchronized void setMaxPort(int maxPort) { if (maxPort < PortUtil.minPort) { String msg = "trying to set maxPort to value less than minPort: " + maxPort + " < " + PortUtil.minPort; log.debug(msg); throw new IllegalStateException(msg); } if (maxPort > PortUtil.maxPort) { log.debug("will not set maxPort to " + maxPort + ": maxPort is already " + PortUtil.maxPort); return; } log.debug("setting maxPort to " + maxPort); PortUtil.maxPort = maxPort; } public static synchronized void updateRange(Map config) { if (config != null) { int savedMinPort = getMinPort(); Object o = config.get(MIN_PORT); if (o instanceof String) { try { setMinPort(Integer.parseInt((String) o)); } catch (NumberFormatException e) { log.error("minPort parameter has invalid format: " + o); } } else if (o != null) { log.error("minPort parameter must be a string in integer format: " + o); } int savedMaxPort = getMaxPort(); o = config.get(MAX_PORT); if (o instanceof String) { try { setMaxPort(Integer.parseInt((String) o)); } catch (NumberFormatException e) { log.error("maxPort parameter has invalid format: " + o); } } else if (o != null) { log.error("maxPort parameter must be a string in integer format: " + o); } if (savedMinPort != getMinPort() || savedMaxPort != getMaxPort()) { portCounter = getRandomStartingPort(); } } } public static void main(String args[]) { try { System.out.println("port - " + findFreePort("localhost")); } catch(Exception ex) { ex.printStackTrace(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/ClientFactory.java0000644000175000017500000000252510455077561032321 0ustar twernertwerner/* * 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.remoting.transport; import org.jboss.remoting.InvokerLocator; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public interface ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException; public boolean supportsSSL(); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/0000755000175000017500000000000011632407051030202 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/SSLRMIServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/SSLRMIServerInvok0000644000175000017500000001052210767632543033352 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.remoting.transport.sslrmi; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.rmi.RMIServerInvoker; import org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import java.io.IOException; import java.util.HashMap; import java.util.Map; /** * * @author Ron Sigal * @version $Revision: 3661 $ *

          * Copyright (c) Jun 9, 2006 *

          */ public class SSLRMIServerInvoker extends RMIServerInvoker { public SSLRMIServerInvoker(InvokerLocator locator) { super(locator); } public SSLRMIServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } protected RemotingRMIClientSocketFactory getRMIClientSocketFactory(String ignored) { // Remove from config map any properties relating to keystore and truststore. HashMap remoteConfig = new HashMap(configuration); remoteConfig.remove(SSLSocketBuilder.REMOTING_KEY_ALIAS); remoteConfig.remove(SSLSocketBuilder.REMOTING_KEY_PASSWORD); remoteConfig.remove(SSLSocketBuilder.REMOTING_KEY_STORE_ALGORITHM); remoteConfig.remove(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH); remoteConfig.remove(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD); remoteConfig.remove(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE); remoteConfig.remove(SSLSocketBuilder.REMOTING_TRUST_STORE_ALGORITHM); remoteConfig.remove(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH); remoteConfig.remove(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD); remoteConfig.remove(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE); // Remove ServerSocketFactory. remoteConfig.remove(Remoting.CUSTOM_SERVER_SOCKET_FACTORY); // Remove server side socket creation listeners. remoteConfig.remove(Remoting.SOCKET_CREATION_CLIENT_LISTENER); remoteConfig.remove(Remoting.SOCKET_CREATION_SERVER_LISTENER); // If server socket should use client mode, then default behavior will be for socket // to not use client mode. String serverSocketUseClientModeString = (String) configuration.get(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE); if (serverSocketUseClientModeString != null) { boolean serverSocketUseClientMode = Boolean.valueOf(serverSocketUseClientModeString).booleanValue(); if (serverSocketUseClientMode) { String socketUseClientModeString = (String) configuration.get(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE); if (socketUseClientModeString == null) { remoteConfig.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false"); } } } return new SerializableSSLClientSocketFactory(locator, getTimeout(), remoteConfig); } protected ServerSocketFactory getDefaultServerSocketFactory() throws IOException { SSLSocketBuilder builder = new SSLSocketBuilder(configuration); builder.setUseSSLServerSocketFactory(false); return builder.createSSLServerSocketFactory(); } protected SocketFactory createSocketFactory(Map configuration) { return null; } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/TransportClientFa0000644000175000017500000000307510455077561033547 0ustar twernertwerner/* * 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.remoting.transport.sslrmi; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new SSLRMIClientInvoker(locator, config); } public boolean supportsSSL() { return true; } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/TransportServerFa0000644000175000017500000000104310455077561033570 0ustar twernertwernerpackage org.jboss.remoting.transport.sslrmi; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new SSLRMIServerInvoker(locator, config); } public boolean supportsSSL() { return true; } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/SerializableSSLClientSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/SerializableSSLCl0000644000175000017500000001226610766132264033413 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.remoting.transport.sslrmi; import org.jboss.logging.Logger; import org.jboss.remoting.AbstractInvoker; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory; import org.jboss.remoting.util.socket.HandshakeRepeater; import javax.net.SocketFactory; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLSocket; import java.io.IOException; import java.net.Socket; import java.util.HashMap; import java.util.Map; /** * * @author Ron Sigal * @version $Revision: 3626 $ *

          * Copyright (c) Jun 9, 2006 *

          */ public class SerializableSSLClientSocketFactory extends RemotingRMIClientSocketFactory { private static final long serialVersionUID = 3242156275483606618L; private static Logger log = Logger.getLogger(SerializableSSLClientSocketFactory.class); public SerializableSSLClientSocketFactory(InvokerLocator invokerLocator, int timeout, Map configuration) { super(invokerLocator, invokerLocator.getHost(), timeout, configuration); this.invokerLocator = invokerLocator; this.configuration = new HashMap(configuration); } public Socket createSocket(String host, int port) throws IOException { Socket s = super.createSocket(host, port); // need to check for handshake listener and add them if there is one Object obj = configuration.get(Client.HANDSHAKE_COMPLETED_LISTENER); if (obj != null && obj instanceof HandshakeCompletedListener) { SSLSocket sslSocket = (SSLSocket) s; HandshakeCompletedListener listener = (HandshakeCompletedListener) obj; establishHandshake(sslSocket, listener); } return s; } public SocketFactory retrieveSocketFactory(ComparableHolder holder) throws IOException { SocketFactory sf = (SocketFactory) socketFactories.get(this); if (sf == null) { try { // We want to keep the local configuration map, which might contain a // SocketFactory, separate from the configuration map, which is meant // to contain only serializable objects. Map tempConfig = new HashMap(configuration); Map localConfig = (Map) configMaps.get(holder); if (localConfig != null) tempConfig.putAll(localConfig); if (tempConfig.containsKey(Remoting.CUSTOM_SOCKET_FACTORY)) { sf = (SocketFactory) tempConfig.get(Remoting.CUSTOM_SOCKET_FACTORY); } else { SSLSocketBuilder socketBuilder = new SSLSocketBuilder(tempConfig); socketBuilder.setUseSSLSocketFactory( false ); sf = socketBuilder.createSSLSocketFactory(); sf = AbstractInvoker.wrapSocketFactory(sf, tempConfig); } socketFactories.put(this, sf); // Get handshake listener from local configuration map and store in // configuration map brought over from server. We don't have to worry // about the handshake listener being serializable because if we // find an entry in configMaps, we are running on the client. if (localConfig != null) { Object obj = localConfig.get(Client.HANDSHAKE_COMPLETED_LISTENER); if (obj != null) configuration.put(Client.HANDSHAKE_COMPLETED_LISTENER, obj); } } catch (IOException e) { log.debug(e); throw new RuntimeException("Unable to create customized SSL socket factory", e); } } return sf; } private void establishHandshake(SSLSocket sslSocket, HandshakeCompletedListener listener) throws IOException { HandshakeRepeater repeater = new HandshakeRepeater(listener); sslSocket.addHandshakeCompletedListener(repeater); sslSocket.getSession(); repeater.waitForHandshake(); } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/SSLRMIClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslrmi/SSLRMIClientInvok0000644000175000017500000000310510553067147033314 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.remoting.transport.sslrmi; import java.util.Map; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.rmi.RMIClientInvoker; /** * * @author Ron Sigal * @version $Revision: 1833 $ *

          * Copyright (c) Jun 11, 2006 *

          */ public class SSLRMIClientInvoker extends RMIClientInvoker { public SSLRMIClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public SSLRMIClientInvoker(InvokerLocator locator) { super(locator); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/0000755000175000017500000000000011632407050030172 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.jav0000644000175000017500000011413011311232363033471 0ustar twernertwerner/* * Copyright 1999-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.remoting.transport.coyote; import org.apache.coyote.ActionCode; import org.apache.coyote.Adapter; import org.apache.coyote.ProtocolHandler; import org.apache.coyote.Request; import org.apache.coyote.Response; import org.apache.tomcat.util.buf.B2CConverter; import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.buf.CharChunk; import org.apache.tomcat.util.buf.MessageBytes; import org.apache.tomcat.util.http.MimeHeaders; import org.apache.tomcat.util.net.SocketStatus; import org.jboss.remoting.Home; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvocationResponse; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.Version; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.transport.coyote.ssl.RemotingSSLImplementation; import org.jboss.remoting.transport.coyote.ssl.RemotingServerSocketFactory; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.remoting.transport.web.WebServerInvoker; import org.jboss.remoting.transport.web.WebUtil; import org.jboss.remoting.util.SecurityUtility; import org.jboss.logging.Logger; import javax.net.ServerSocketFactory; import java.io.IOException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** * This is the stand alone http server invoker which acts basically as a web server. * Server invoker implementation based on http protocol. Is basically a stand alone http server whose request are * forwared to the invocation handler and responses from invocation handler are sent back to caller as http response. * * @author Tom Elrod * @author Craig R. McClanahan * @author Remy Maucherat */ /** * Some of the code in this class was pulled from org.apache.coyote.tomcat4.CoyoteAdapter * and hence will maintain the Apache License (and author credit from original source). */ public class CoyoteInvoker extends WebServerInvoker implements Adapter { private static final Logger log = Logger.getLogger(CoyoteInvoker.class); /** Indicates if input was raw or an InvocationRequest */ protected static ThreadLocal receivedInvocationRequest = new ThreadLocal(); protected static final Boolean FALSE = new Boolean(false); protected static final Boolean TRUE = new Boolean(true); private boolean running = false; // protected ProtocolHandler protocolHandler = null; protected List protocolHandlers = new ArrayList(); protected String URIEncoding = null; protected String useRemotingContentType = "false"; public CoyoteInvoker(InvokerLocator locator) { super(locator); } public CoyoteInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } protected void setup() throws Exception { super.setup(); Map config = getConfiguration(); // Test APR support boolean apr = false; try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { String methodName = "initialize"; Class paramTypes[] = new Class[1]; paramTypes[0] = String.class; Object paramValues[] = new Object[1]; paramValues[0] = null; String className = "org.apache.tomcat.jni.Library"; Method method = Class.forName(className).getMethod(methodName, paramTypes); method.invoke(null, paramValues); return null; } }); apr = true; } catch (PrivilegedActionException e) { // Ignore. log.trace("", e.getCause()); } // Instantiate the associated HTTP protocol handler String protocolHandlerClassName = null; Object value = config.get("protocolHandlerClassName"); if(value != null) { protocolHandlerClassName = String.valueOf(value); } else { if(apr) { protocolHandlerClassName = "org.apache.coyote.http11.Http11AprProtocol"; } else { protocolHandlerClassName = "org.apache.coyote.http11.Http11Protocol"; } } log.info("Using " + protocolHandlerClassName + " for http (coyote) invoker protocol handler."); Class clazz = null; try { clazz = (Class) forName(protocolHandlerClassName); } catch (ClassNotFoundException e) { log.error("Protocol handler class instatiation failed: protocolHandlerClassName", e); return; } ProtocolHandler protocolHandler = null; for (int i = 0; i < connectHomes.size(); i++) { try { protocolHandler = (ProtocolHandler) clazz.newInstance(); } catch(Exception e) { log.error("Protocol handler instantiation failed", e); return; } protocolHandler.setAdapter(this); // Pass all attributes to the protocol handler Iterator keys = config.keySet().iterator(); while(keys.hasNext()) { String key = (String) keys.next(); Object obj = config.get(key); if (obj instanceof String) { String val = (String) obj; setProperty(protocolHandler, key, val); } } // need to convert standard remoting timeout config to tomcat timeout String timeoutValue = (String)config.get(TIMEOUT); if(timeoutValue != null) { setProperty(protocolHandler, "connectionTimeout", timeoutValue); } // Configuration of URI encoding value = config.get("URIEncoding"); if(value != null) { URIEncoding = String.valueOf(value); } protocolHandlers.add(protocolHandler); value = config.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE); if (value instanceof String) { useRemotingContentType = (String) value; } else if (value != null) { log.warn(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE + " value should be a String: " + value); } log.debug(this + " useRemotingContentType: " + useRemotingContentType); } } protected ServerSocketFactory getDefaultServerSocketFactory() throws IOException { /** * Returning a null here as if has not already been set previously * via config in ServerInvoker, then want to return null so that * will use the default within tomcat (and not override with own default). */ if ("https".equals(locator.getProtocol())) { SSLSocketBuilder builder = new SSLSocketBuilder(configuration); builder.setUseSSLServerSocketFactory(false); try { return builder.createSSLServerSocketFactory(); } catch (IOException e) { log.debug("unable to create server socket factory", e); throw e; } } else return null; } public void start() throws IOException { if(!running) { for (int i = 0; i < protocolHandlers.size(); i++) { try { final ProtocolHandler protocolHandler = (ProtocolHandler) protocolHandlers.get(i); Home home = (Home) getHomes().get(i); setProperty(protocolHandler, "address", home.host); setProperty(protocolHandler, "port", "" + home.port); //TODO: -TME - Should not have to hard set this every time. Should // be a way to figure out if this is needed or not. // Need to set the MBeanServer to use since there is no direct way to do it. setProperty(protocolHandler, "locator", getLocator().getLocatorURI()); RemotingSSLImplementation.setMBeanServer(getLocator().getLocatorURI(), getMBeanServer()); ServerSocketFactory svrSocketFactory = getServerSocketFactory(); if(svrSocketFactory != null) { RemotingServerSocketFactory.setServerSocketFactory(getLocator().getLocatorURI(), svrSocketFactory); setProperty(protocolHandler, "SocketFactory", RemotingServerSocketFactory.class.getName()); } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { protocolHandler.init(); protocolHandler.start(); return null; } }); } catch (PrivilegedActionException e) { throw (Exception) e.getCause(); } running = true; } catch(Exception e) { log.debug("Error starting protocol handler. Bind port: " + getServerBindPort() + ", bind address: " + getServerBindAddress(), e); throw new IOException("" + e.getMessage()); } } } super.start(); } /** * Service method. */ public void service(org.apache.coyote.Request req, org.apache.coyote.Response res) throws Exception { RequestMap request = (RequestMap) req.getNote(1); ResponseMap response = (ResponseMap) res.getNote(1); if(request == null) { // Create objects request = new RequestMap(); request.setCoyoteRequest(req); response = new ResponseMap(); response.setCoyoteResponse(res); // Set as notes req.setNote(1, request); res.setNote(1, response); // Set query string encoding // FIMXE?: req.getParameters().setQueryStringEncoding(protocolHandler.getAttribute("URIEncoding")); } else { response.clear(); request.clear(); } try { if(postParseRequest(req, request, res, response)) { populateRequestMetadata(request, req); Object responseObject = null; boolean isError = false; int version = getVersion(request); // Check if client is HTTPClientInvoker boolean isRemotingUserAgent = false; Object userAgentObj = request.get(HTTPMetadataConstants.REMOTING_USER_AGENT); if (userAgentObj != null) { String userAgent = (String) userAgentObj; isRemotingUserAgent = userAgent.startsWith("JBossRemoting"); } InvocationRequest invocationRequest = versionedRead(req, request, response, version); if (invocationRequest.getRequestPayload() == null) invocationRequest.setRequestPayload(new HashMap()); MessageBytes remoteAddressMB = req.remoteAddr(); if (remoteAddressMB != null) { String remoteAddressString = remoteAddressMB.toString(); InetAddress remoteAddress = getAddressByName(remoteAddressString); invocationRequest.getRequestPayload().put(Remoting.CLIENT_ADDRESS, remoteAddress); } else { log.debug("unable to retrieve client address from coyote transport layer"); } // FIXME: OPTIONS method handling ? try { // call transport on the subclass, get the result to handback responseObject = invoke(invocationRequest); } catch(Throwable ex) { log.debug("Error thrown calling invoke on server invoker.", ex); responseObject = ex; isError = true; } //Start with response code of 204 (no content), then if is a return from handler, change to 200 (ok) int status; String message = ""; if(responseObject != null) { if(isError) { status = 500; message = "JBoss Remoting: Error occurred within target application."; } else { status = 200; message = "OK"; } } else { if (isRemotingUserAgent && !req.method().equals("HEAD")) { status = 200; message = "OK"; } else { status = 204; message = "No Content"; } } // extract response code/message if exists Map responseMap = invocationRequest.getReturnPayload(); if(responseMap != null) { Integer handlerStatus = (Integer) responseMap.get(HTTPMetadataConstants.RESPONSE_CODE); if(handlerStatus != null) { status = handlerStatus.intValue(); } String handlerMessage = (String) responseMap.get(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE); if(handlerMessage != null) { message = handlerMessage; } } res.setStatus(status); res.setMessage(message); if (isRemotingUserAgent && ((Boolean)receivedInvocationRequest.get()).booleanValue()) { responseMap = ((ResponseMap) responseMap).getMap(); responseObject = new InvocationResponse(invocationRequest.getSessionId(), responseObject, isError, responseMap); } if(responseObject != null) { versionedWrite(version, responseObject, req, res, response); } } response.outputBuffer.close(); req.action(ActionCode.ACTION_POST_REQUEST, null); } catch (ClientAbortException e) { log.debug("Client didn't wait", e); } catch(IOException e) { log.error("Error processing request", e); } catch(Throwable t) { log.error("Service error", t); } finally { // Recycle the wrapper request and response request.recycle(); response.recycle(); } } private void addLeaseInfo(ResponseMap response) { boolean leaseManagement = isLeaseActivated(); response.put("LEASING_ENABLED", new Boolean(leaseManagement)); if(leaseManagement) { long leasePeriod = getLeasePeriod(); response.put("LEASE_PERIOD", new Long(leasePeriod)); } } private void versionedWrite(int version, Object responseObject, Request req, org.apache.coyote.Response res, ResponseMap response) throws IOException { switch (version) { case Version.VERSION_1: case Version.VERSION_2: case Version.VERSION_2_2: { String responseContentType = (String) response.get("Content-Type"); if (responseContentType != null) { if (isInvalidContentType(responseContentType)) { log.warn("Ignoring invalid content-type from ServerInvocationHandler: " + responseContentType); if (responseObject == null) { responseContentType = req.getContentType(); if (isInvalidContentType(responseContentType)) { log.warn("Ignoring invalid content-type from request: " + responseContentType); responseContentType = WebUtil.getContentType(responseObject); } } else { responseContentType = WebUtil.getContentType(responseObject); } } } else { if (responseObject == null) { responseContentType = req.getContentType(); if (isInvalidContentType(responseContentType)) { log.warn("Ignoring invalid content-type from request: " + responseContentType); responseContentType = WebUtil.getContentType(responseObject); } } else { responseContentType = WebUtil.getContentType(responseObject); } } res.setContentType(responseContentType); if (responseObject instanceof String) { res.addHeader(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING); } else { res.addHeader(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING); } Marshaller marshaller = getMarshaller(); if (marshaller instanceof VersionedMarshaller) ((VersionedMarshaller) marshaller).write(responseObject, response.getOutputStream(), version); else marshaller.write(responseObject, response.getOutputStream()); return; } default: { throw new IOException("Can not send response due to version (" + version + ") not being supported. Supported versions: " + Version.VERSION_1 + ", " + Version.VERSION_2 + ", " + Version.VERSION_2_2); } } } private InvocationRequest versionedRead(Request req, RequestMap request, ResponseMap response, int version) throws IOException, ClassNotFoundException { switch (version) { case Version.VERSION_1: case Version.VERSION_2: case Version.VERSION_2_2: { // UnMarshaller may not be an HTTPUnMarshaller, in which case it // can ignore this parameter. Object o = configuration.get(HTTPUnMarshaller.PRESERVE_LINES); if (o != null) { request.put(HTTPUnMarshaller.PRESERVE_LINES, o); } receivedInvocationRequest.set(FALSE); InvocationRequest invocationRequest = null; MessageBytes method = req.method(); if (method.equals("GET") || method.equals("HEAD") || (method.equals("OPTIONS") && req.getContentLength() <= 0)) { invocationRequest = createNewInvocationRequest(request, response, null); } else { // must be POST or PUT UnMarshaller unmarshaller = getUnMarshaller(); request.put(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE, useRemotingContentType); Object obj = null; if (unmarshaller instanceof VersionedUnMarshaller) obj = ((VersionedUnMarshaller)unmarshaller).read(request.getInputStream(), request, version); else obj = unmarshaller.read(request.getInputStream(), request); if (obj instanceof InvocationRequest) { receivedInvocationRequest.set(TRUE); invocationRequest = (InvocationRequest) obj; if (invocationRequest.getReturnPayload() == null) { // need to create a return payload map, so can be populated with metadata invocationRequest.setReturnPayload(response); } Map requestPayloadMap = invocationRequest.getRequestPayload(); if (requestPayloadMap != null) { request.putAll(requestPayloadMap); } invocationRequest.setRequestPayload(request); } else { invocationRequest = createNewInvocationRequest(request, response, obj); } } return invocationRequest; } default: { throw new IOException("Can not processes request due to incorrect version (" + version + "). Can only process versions: " + Version.VERSION_1 + ", " + Version.VERSION_2 + ", " + Version.VERSION_2_2); } } } private int getVersion(RequestMap request) { int version = Version.VERSION_1; // going to default to old version Object versionObj = request.get(HTTPMetadataConstants.REMOTING_VERSION_HEADER); if (versionObj != null) { String versionString = (String) versionObj; try { version = Integer.parseInt(versionString); } catch (NumberFormatException e) { log.error("Can not processes remoting version of " + versionString + " as is not a number."); } } return version; } private void populateRequestMetadata(RequestMap metadata, Request req) { final MimeHeaders headers = req.getMimeHeaders(); Enumeration nameEnum = null; if (SecurityUtility.skipAccessControl()) { nameEnum = headers.names(); } else { nameEnum = (Enumeration)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return headers.names(); }} ); } while (nameEnum.hasMoreElements()) { Object nameObj = nameEnum.nextElement(); if (nameObj instanceof String) { Object valueObj = headers.getHeader((String) nameObj); metadata.put(nameObj, valueObj); } } metadata.put(HTTPMetadataConstants.METHODTYPE, req.method().getString()); metadata.put(HTTPMetadataConstants.PATH, req.requestURI().getString()); metadata.put(HTTPMetadataConstants.QUERY, req.query().toString()); metadata.put(HTTPMetadataConstants.HTTPVERSION, req.protocol().getString()); } protected InvocationRequest createNewInvocationRequest(RequestMap requestMap, ResponseMap responseMap, Object payload) { // will try to use the same session id if possible to track String sessionId = getSessionId(requestMap); String subSystem = (String) requestMap.get(HEADER_SUBSYSTEM); InvocationRequest request = null; boolean isLeaseQueury = checkForLeaseQuery(requestMap); if(isLeaseQueury) { addLeaseInfo(responseMap); request = new InvocationRequest(sessionId, subSystem, "$PING$", null, responseMap, null); } else { request = new InvocationRequest(sessionId, subSystem, payload, requestMap, responseMap, null); } return request; } private boolean checkForLeaseQuery(RequestMap headers) { boolean isLeaseQuery = false; if(headers != null) { Object val = headers.get(HTTPMetadataConstants.REMOTING_LEASE_QUERY); if(val != null && val instanceof String) { isLeaseQuery = Boolean.valueOf((String)val).booleanValue(); } } return isLeaseQuery; } /** * Parse additional request parameters. */ protected boolean postParseRequest(org.apache.coyote.Request req, RequestMap request, org.apache.coyote.Response res, ResponseMap response) throws Exception { // URI decoding MessageBytes decodedURI = req.decodedURI(); decodedURI.duplicate(req.requestURI()); if(decodedURI.getType() == MessageBytes.T_BYTES) { // %xx decoding of the URL try { req.getURLDecoder().convert(decodedURI, false); } catch(IOException ioe) { res.setStatus(400); res.setMessage("Invalid URI"); throw ioe; } // Normalization if(!normalize(req.decodedURI())) { res.setStatus(400); res.setMessage("Invalid URI"); return false; } // Character decoding convertURI(decodedURI, request); } else { // The URL is chars or String, and has been sent using an in-memory // protocol handler, we have to assume the URL has been properly // decoded already decodedURI.toChars(); } return true; } /** * Character conversion of the URI. */ protected void convertURI(MessageBytes uri, RequestMap request) throws Exception { ByteChunk bc = uri.getByteChunk(); CharChunk cc = uri.getCharChunk(); cc.allocate(bc.getLength(), -1); String enc = URIEncoding; if(enc != null) { B2CConverter conv = request.getURIConverter(); try { if(conv == null) { conv = new B2CConverter(enc); request.setURIConverter(conv); } else { conv.recycle(); } } catch(IOException e) { // Ignore log.error("Invalid URI encoding; using HTTP default"); URIEncoding = null; } if(conv != null) { try { conv.convert(bc, cc); uri.setChars(cc.getBuffer(), cc.getStart(), cc.getLength()); return; } catch(IOException e) { log.error("Invalid URI character encoding; trying ascii"); cc.recycle(); } } } // Default encoding: fast conversion byte[] bbuf = bc.getBuffer(); char[] cbuf = cc.getBuffer(); int start = bc.getStart(); for(int i = 0; i < bc.getLength(); i++) { cbuf[i] = (char) (bbuf[i + start] & 0xff); } uri.setChars(cbuf, 0, bc.getLength()); } /** * Character conversion of the a US-ASCII MessageBytes. */ protected void convertMB(MessageBytes mb) { // This is of course only meaningful for bytes if(mb.getType() != MessageBytes.T_BYTES) { return; } ByteChunk bc = mb.getByteChunk(); CharChunk cc = mb.getCharChunk(); cc.allocate(bc.getLength(), -1); // Default encoding: fast conversion byte[] bbuf = bc.getBuffer(); char[] cbuf = cc.getBuffer(); int start = bc.getStart(); for(int i = 0; i < bc.getLength(); i++) { cbuf[i] = (char) (bbuf[i + start] & 0xff); } mb.setChars(cbuf, 0, bc.getLength()); } /** * Normalize URI. *

          * This method normalizes "\", "//", "/./" and "/../". This method will * return false when trying to go above the root, or if the URI contains * a null byte. * * @param uriMB URI to be normalized */ public static boolean normalize(MessageBytes uriMB) { ByteChunk uriBC = uriMB.getByteChunk(); byte[] b = uriBC.getBytes(); int start = uriBC.getStart(); int end = uriBC.getEnd(); // Expect request URI to be at least one character. if (start - end == 0) { return false; } // URL * is acceptable if((end - start == 1) && b[start] == (byte) '*') { return true; } int pos = 0; int index = 0; // Replace '\' with '/' // Check for null byte for(pos = start; pos < end; pos++) { if(b[pos] == (byte) '\\') { b[pos] = (byte) '/'; } if(b[pos] == (byte) 0) { return false; } } // The URL must start with '/' if(b[start] != (byte) '/') { return false; } // Replace "//" with "/" for(pos = start; pos < (end - 1); pos++) { if(b[pos] == (byte) '/') { while((pos + 1 < end) && (b[pos + 1] == (byte) '/')) { copyBytes(b, pos, pos + 1, end - pos - 1); end--; } } } // If the URI ends with "/." or "/..", then we append an extra "/" // Note: It is possible to extend the URI by 1 without any side effect // as the next character is a non-significant WS. if(((end - start) >= 2) && (b[end - 1] == (byte) '.')) { if((b[end - 2] == (byte) '/') || ((b[end - 2] == (byte) '.') && (b[end - 3] == (byte) '/'))) { b[end] = (byte) '/'; end++; } } uriBC.setEnd(end); index = 0; // Resolve occurrences of "/./" in the normalized path while(true) { index = uriBC.indexOf("/./", 0, 3, index); if(index < 0) { break; } copyBytes(b, start + index, start + index + 2, end - start - index - 2); end = end - 2; uriBC.setEnd(end); } index = 0; // Resolve occurrences of "/../" in the normalized path while(true) { index = uriBC.indexOf("/../", 0, 4, index); if(index < 0) { break; } // Prevent from going outside our context if(index == 0) { return false; } int index2 = -1; for(pos = start + index - 1; (pos >= 0) && (index2 < 0); pos --) { if(b[pos] == (byte) '/') { index2 = pos; } } copyBytes(b, start + index2, start + index + 3, end - start - index - 3); end = end + index2 - index - 3; uriBC.setEnd(end); index = index2; } uriBC.setBytes(b, start, end); return true; } /** * Copy an array of bytes to a different position. Used during * normalization. */ protected static void copyBytes(byte[] b, int dest, int src, int len) { for(int pos = 0; pos < len; pos++) { b[pos + dest] = b[pos + src]; } } public void stop() { if(running) { running = false; if (protocolHandlers != null) { Iterator it = protocolHandlers.iterator(); while (it.hasNext()) { try { ProtocolHandler protocolHandler = (ProtocolHandler) it.next(); protocolHandler.destroy(); } catch(Exception e) { log.error("Stop error", e); } } } } super.stop(); log.debug("CoyoteInvoker stopped."); } /** * Find a method with the right name If found, call the method ( if param is * int or boolean we'll convert value to the right type before) - that means * you can have setDebug(1). */ public static boolean setProperty(final Object o, String name, final String value) { String setter = "set" + capitalize(name); try { Method[] methods = null; if (SecurityUtility.skipAccessControl()) { methods = o.getClass().getMethods(); } else { methods = (Method[]) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return o.getClass().getMethods(); } }); } Method setPropertyMethod = null; // First, the ideal case - a setFoo( String ) method for(int i = 0; i < methods.length; i++) { Class paramT[] = methods[i].getParameterTypes(); if(setter.equals(methods[i].getName()) && paramT.length == 1 && "java.lang.String".equals(paramT[0].getName())) { methods[i].invoke(o, new Object[]{value}); return true; } } // Try a setFoo ( int ) or ( boolean ) for(int i = 0; i < methods.length; i++) { boolean ok = true; if(setter.equals(methods[i].getName()) && methods[i].getParameterTypes().length == 1) { // match - find the type and invoke it Class paramType = methods[i].getParameterTypes()[0]; Object params[] = new Object[1]; // Try a setFoo ( int ) if("java.lang.Integer".equals(paramType.getName()) || "int".equals(paramType.getName())) { try { params[0] = new Integer(value); } catch(NumberFormatException ex) { ok = false; } // Try a setFoo ( long ) } else if("java.lang.Long".equals(paramType.getName()) || "long".equals(paramType.getName())) { try { params[0] = new Long(value); } catch(NumberFormatException ex) { ok = false; } // Try a setFoo ( boolean ) } else if("java.lang.Boolean".equals(paramType.getName()) || "boolean".equals(paramType.getName())) { params[0] = new Boolean(value); // Try a setFoo ( InetAddress ) } else if("java.net.InetAddress".equals(paramType.getName())) { try { params[0] = getAddressByName(value); } catch(UnknownHostException exc) { ok = false; } // Unknown type } if(ok) { methods[i].invoke(o, params); return true; } } // save "setProperty" for later if("setProperty".equals(methods[i].getName())) { setPropertyMethod = methods[i]; } } // Ok, no setXXX found, try a setProperty("name", "value") if(setPropertyMethod != null) { Object params[] = new Object[2]; params[0] = name; params[1] = value; setPropertyMethod.invoke(o, params); return true; } } catch(Exception e) { return false; } return false; } /** * Reverse of Introspector.decapitalize */ public static String capitalize(String name) { if(name == null || name.length() == 0) { return name; } char chars[] = name.toCharArray(); chars[0] = Character.toUpperCase(chars[0]); return new String(chars); } /** * Necessary for implementation of org.apache.coyote.Adapter interface. * Body is vacuous because event() is only used in comet mode. */ public boolean event(Request arg0, Response arg1, SocketStatus arg2) throws Exception { return true; } static private boolean isInvalidContentType(String contentType) { return contentType.indexOf('\n') + contentType.indexOf('\r') > -2; } static private Object forName(final String className) throws ClassNotFoundException { if (SecurityUtility.skipAccessControl()) { return Class.forName(className); } try { return AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return Class.forName(className); } }); } catch (PrivilegedActionException e) { throw (ClassNotFoundException) e.getCause(); } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/CoyoteInputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/CoyoteInputStream0000644000175000017500000000436610373016624033570 0ustar twernertwerner/* * Copyright 1999,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.remoting.transport.coyote; import java.io.IOException; import java.io.InputStream; /** * This class handles reading bytes. * * @author Remy Maucherat * @author Jean-Francois Arcand */ public class CoyoteInputStream extends InputStream { // ----------------------------------------------------- Instance Variables protected InputBuffer ib; // ----------------------------------------------------------- Constructors protected CoyoteInputStream(InputBuffer ib) { this.ib = ib; } // -------------------------------------------------------- Package Methods /** * Clear facade. */ void clear() { ib = null; } // --------------------------------------------------------- Public Methods /** * Prevent cloning the facade. */ protected Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); } // --------------------------------------------- ServletInputStream Methods public int read() throws IOException { return ib.readByte(); } public int available() throws IOException { return ib.available(); } public int read(final byte[] b) throws IOException { return ib.read(b, 0, b.length); } public int read(final byte[] b, final int off, final int len) throws IOException { return ib.read(b, off, len); } /** * Close the stream * Since we re-cycle, we can't allow the call to super.close() * which would permantely disable us. */ public void close() throws IOException { ib.close(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ResponseMap.java0000644000175000017500000000640510504436536033306 0ustar twernertwerner/* * 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.remoting.transport.coyote; import java.io.OutputStream; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; public class ResponseMap implements Map { Map internalMap = new HashMap(); /** * The associated output buffer. */ protected OutputBuffer outputBuffer = new OutputBuffer(); /** * ServletOutputStream. */ protected CoyoteOutputStream outputStream = new CoyoteOutputStream(outputBuffer); /** * Coyote response. */ protected org.apache.coyote.Response coyoteResponse; /** * Set the Coyote response. * * @param coyoteResponse The Coyote response */ public void setCoyoteResponse(org.apache.coyote.Response coyoteResponse) { this.coyoteResponse = coyoteResponse; outputBuffer.setResponse(coyoteResponse); } /** * Get the Coyote response. */ public org.apache.coyote.Response getCoyoteResponse() { return (this.coyoteResponse); } /** * Get the output stream. */ public OutputStream getOutputStream() { return (this.outputStream); } public void recycle() { outputBuffer.recycle(); } public int size() { return internalMap.size(); } public boolean isEmpty() { return internalMap.isEmpty(); } public boolean containsKey(Object key) { return internalMap.containsKey(key); } public boolean containsValue(Object value) { return internalMap.containsValue(value); } public Object get(Object key) { return internalMap.get(key); } public Object put(Object arg0, Object arg1) { Object obj = internalMap.put(arg0, arg1); coyoteResponse.setHeader(String.valueOf(arg0), String.valueOf(arg1)); return obj; } public Object remove(Object key) { return internalMap.remove(key); } public void putAll(Map arg0) { internalMap.putAll(arg0); } public void clear() { internalMap.clear(); } public Set keySet() { return internalMap.keySet(); } public Collection values() { return internalMap.values(); } public Set entrySet() { return internalMap.entrySet(); } public Map getMap() { return internalMap; } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/OutputBuffer.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/OutputBuffer.java0000644000175000017500000003405311060654745033506 0ustar twernertwerner/* * Copyright 1999,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.remoting.transport.coyote; import java.io.IOException; import java.io.Writer; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import org.apache.coyote.ActionCode; import org.apache.coyote.Response; import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.buf.C2BConverter; import org.apache.tomcat.util.buf.CharChunk; import org.jboss.remoting.util.SecurityUtility; /** * The buffer used by Tomcat response. This is a derivative of the Tomcat 3.3 * OutputBuffer, with the removal of some of the state handling (which in * Coyote is mostly the Processor's responsability). * * @author Costin Manolache * @author Remy Maucherat */ public class OutputBuffer extends Writer implements ByteChunk.ByteOutputChannel, CharChunk.CharOutputChannel { // -------------------------------------------------------------- Constants public static final String DEFAULT_ENCODING = org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING; public static final int DEFAULT_BUFFER_SIZE = 8 * 1024; // The buffer can be used for byte[] and char[] writing // ( this is needed to support ServletOutputStream and for // efficient implementations of templating systems ) public final int INITIAL_STATE = 0; public final int CHAR_STATE = 1; public final int BYTE_STATE = 2; // ----------------------------------------------------- Instance Variables /** * The byte buffer. */ private ByteChunk bb; /** * The chunk buffer. */ private CharChunk cb; /** * State of the output buffer. */ private int state = 0; /** * Number of bytes written. */ private int bytesWritten = 0; /** * Number of chars written. */ private int charsWritten = 0; /** * Flag which indicates if the output buffer is closed. */ private boolean closed = false; /** * Do a flush on the next operation. */ private boolean doFlush = false; /** * Byte chunk used to output bytes. */ private ByteChunk outputChunk = new ByteChunk(); /** * Encoding to use. */ private String enc; /** * Encoder is set. */ private boolean gotEnc = false; /** * List of encoders. */ protected HashMap encoders = new HashMap(); /** * Current char to byte converter. */ protected C2BConverter conv; /** * Associated Coyote response. */ private Response coyoteResponse; /** * Suspended flag. All output bytes will be swallowed if this is true. */ private boolean suspended = false; // ----------------------------------------------------------- Constructors /** * Default constructor. Allocate the buffer with the default buffer size. */ public OutputBuffer() { this(DEFAULT_BUFFER_SIZE); } /** * Alternate constructor which allows specifying the initial buffer size. * * @param size Buffer size to use */ public OutputBuffer(int size) { bb = new ByteChunk(size); // Allow buffer to grow, to avoid using chunking // FIXME: Allowing chunking could be a better idea bb.setLimit(-1); bb.setByteOutputChannel(this); cb = new CharChunk(size); cb.setCharOutputChannel(this); cb.setLimit(size); } // ------------------------------------------------------------- Properties /** * Associated Coyote response. * * @param coyoteResponse Associated Coyote response */ public void setResponse(Response coyoteResponse) { this.coyoteResponse = coyoteResponse; } /** * Get associated Coyote response. * * @return the associated Coyote response */ public Response getResponse() { return this.coyoteResponse; } /** * Is the response output suspended ? * * @return suspended flag value */ public boolean isSuspended() { return this.suspended; } /** * Set the suspended flag. * * @param suspended New suspended flag value */ public void setSuspended(boolean suspended) { this.suspended = suspended; } // --------------------------------------------------------- Public Methods /** * Recycle the output buffer. */ public void recycle() { state = INITIAL_STATE; bytesWritten = 0; charsWritten = 0; cb.recycle(); bb.recycle(); closed = false; suspended = false; if(conv != null) { conv.recycle(); } gotEnc = false; enc = null; } /** * Close the output buffer. This tries to calculate the response size if * the response has not been committed yet. * * @throws IOException An underlying IOException occurred */ public void close() throws IOException { if(closed) { return; } if(suspended) { return; } if((!coyoteResponse.isCommitted()) && (coyoteResponse.getContentLengthLong() == -1)) { // Flushing the char buffer if(state == CHAR_STATE) { cb.flushBuffer(); state = BYTE_STATE; } // If this didn't cause a commit of the response, the final content // length can be calculated if(!coyoteResponse.isCommitted()) { coyoteResponse.setContentLength(bb.getLength()); } } doFlush(false); closed = true; coyoteResponse.finish(); } /** * Flush bytes or chars contained in the buffer. * * @throws IOException An underlying IOException occurred */ public void flush() throws IOException { doFlush(true); } /** * Flush bytes or chars contained in the buffer. * * @throws IOException An underlying IOException occurred */ protected void doFlush(boolean realFlush) throws IOException { if(suspended) { return; } doFlush = true; if(state == CHAR_STATE) { cb.flushBuffer(); bb.flushBuffer(); state = BYTE_STATE; } else if(state == BYTE_STATE) { bb.flushBuffer(); } else if(state == INITIAL_STATE) { // If the buffers are empty, commit the response header coyoteResponse.sendHeaders(); } doFlush = false; if(realFlush) { coyoteResponse.action(ActionCode.ACTION_CLIENT_FLUSH, coyoteResponse); // If some exception occurred earlier, or if some IOE occurred // here, notify the servlet with an IOE if(coyoteResponse.isExceptionPresent()) { throw new ClientAbortException (coyoteResponse.getErrorException()); } } } // ------------------------------------------------- Bytes Handling Methods /** * Sends the buffer data to the client output, checking the * state of Response and calling the right interceptors. * * @param buf Byte buffer to be written to the response * @param off Offset * @param cnt Length * @throws IOException An underlying IOException occurred */ public void realWriteBytes(byte buf[], int off, int cnt) throws IOException { if(closed) { return; } if(coyoteResponse == null) { return; } // If we really have something to write if(cnt > 0) { // real write to the adapter outputChunk.setBytes(buf, off, cnt); try { coyoteResponse.doWrite(outputChunk); } catch(IOException e) { // An IOException on a write is almost always due to // the remote client aborting the request. Wrap this // so that it can be handled better by the error dispatcher. throw new ClientAbortException(e); } } } public void write(byte b[], int off, int len) throws IOException { if(suspended) { return; } if(state == CHAR_STATE) { cb.flushBuffer(); } state = BYTE_STATE; writeBytes(b, off, len); } private void writeBytes(byte b[], int off, int len) throws IOException { if(closed) { return; } bb.append(b, off, len); bytesWritten += len; // if called from within flush(), then immediately flush // remaining bytes if(doFlush) { bb.flushBuffer(); } } public void writeByte(int b) throws IOException { if(suspended) { return; } if(state == CHAR_STATE) { cb.flushBuffer(); } state = BYTE_STATE; bb.append((byte) b); bytesWritten++; } // ------------------------------------------------- Chars Handling Methods public void write(int c) throws IOException { if(suspended) { return; } state = CHAR_STATE; cb.append((char) c); charsWritten++; } public void write(char c[]) throws IOException { if(suspended) { return; } write(c, 0, c.length); } public void write(char c[], int off, int len) throws IOException { if(suspended) { return; } state = CHAR_STATE; cb.append(c, off, len); charsWritten += len; } public void write(StringBuffer sb) throws IOException { if(suspended) { return; } state = CHAR_STATE; int len = sb.length(); charsWritten += len; cb.append(sb); } /** * Append a string to the buffer */ public void write(String s, int off, int len) throws IOException { if(suspended) { return; } state = CHAR_STATE; charsWritten += len; if(s == null) { s = "null"; } cb.append(s, off, len); } public void write(String s) throws IOException { if(suspended) { return; } state = CHAR_STATE; if(s == null) { s = "null"; } write(s, 0, s.length()); } public void flushChars() throws IOException { cb.flushBuffer(); state = BYTE_STATE; } public boolean flushCharsNeeded() { return state == CHAR_STATE; } public void setEncoding(String s) { enc = s; } public void realWriteChars(char c[], int off, int len) throws IOException { if(!gotEnc) { setConverter(); } // The following has been updated to conform to jbossweb 2.1. cb.setChars(c, off, len); while (cb.getLength() > 0) { conv.convert(cb, bb); if (cb.getLength() > 0) { bb.flushBuffer(); } } } public void checkConverter() throws IOException { if(!gotEnc) { setConverter(); } } protected void setConverter() throws IOException { if(coyoteResponse != null) { enc = coyoteResponse.getCharacterEncoding(); } gotEnc = true; if(enc == null) { enc = DEFAULT_ENCODING; } conv = (C2BConverter) encoders.get(enc); // The following has been updated to conform to jbossweb 2.1. if(conv == null) { if(!SecurityUtility.skipAccessControl()) { try { conv = (C2BConverter) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return new C2BConverter(enc); } } ); } catch(PrivilegedActionException ex) { Exception e = ex.getException(); if(e instanceof IOException) { throw (IOException) e; } } } else { conv = new C2BConverter(enc); } encoders.put(enc, conv); } } // -------------------- BufferedOutputStream compatibility /** * Real write - this buffer will be sent to the client */ public void flushBytes() throws IOException { bb.flushBuffer(); } public int getBytesWritten() { return bytesWritten; } public int getCharsWritten() { return charsWritten; } public int getContentWritten() { return bytesWritten + charsWritten; } /** * True if this buffer hasn't been used ( since recycle() ) - * i.e. no chars or bytes have been added to the buffer. */ public boolean isNew() { return (bytesWritten == 0) && (charsWritten == 0); } public void setBufferSize(int size) { if(size > bb.getLimit()) {// ?????? bb.setLimit(size); } } public void reset() { //count=0; bb.recycle(); bytesWritten = 0; cb.recycle(); charsWritten = 0; gotEnc = false; enc = null; state = INITIAL_STATE; } public int getBufferSize() { return bb.getLimit(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ssl/0000755000175000017500000000000011632407050030773 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingSSLSupport.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingSSLSu0000644000175000017500000001442310707513070033402 0ustar twernertwerner/** * This class uses code taken directly from the org.apache.tomcat.util.net.SSLSupport class of the * Apache tomcat-connectors project. Please refer to the NOTICE file included in this distribution for * more details. The following is the copyright, patent, trademark, and attribution notices from the * SSLSupport source, which this class also maintains: * * Copyright 1999-2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @author EKR * @author Craig R. McClanahan * Parts cribbed from JSSECertCompat * Parts cribbed from CertificatesValve * * (the full source of the org.apache.tomcat.util.net.SSLSupport can be found at * http://svn.apache.org/repos/asf/tomcat/connectors/trunk/util/java/org/apache/tomcat/util/net/jsse/JSSESupport.java). */ package org.jboss.remoting.transport.coyote.ssl; import java.io.ByteArrayInputStream; import java.io.IOException; import java.security.cert.CertificateFactory; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import javax.security.cert.X509Certificate; import org.apache.tomcat.util.net.SSLSupport; /** * @author Tom Elrod */ public class RemotingSSLSupport implements SSLSupport { private SSLSocket sslSocket; private SSLSession session; public RemotingSSLSupport(SSLSocket socket) { this.sslSocket = socket; this.session = socket.getSession(); } public RemotingSSLSupport(SSLSession session) { this.session = session; } /** * The cipher suite being used on this connection. */ public String getCipherSuite() throws IOException { if(session == null) { return null; } return session.getCipherSuite(); } /** * The client certificate chain (if any). */ public Object[] getPeerCertificateChain() throws IOException { return getPeerCertificateChain(false); } public Object[] getPeerCertificateChain(boolean force) throws IOException { if(session == null) { return null; } // Convert JSSE's certificate format to the ones we need X509Certificate [] jsseCerts = null; try { jsseCerts = session.getPeerCertificateChain(); } catch(Exception bex) { // ignore. } if(jsseCerts == null) { jsseCerts = new X509Certificate[0]; } if(jsseCerts.length <= 0 && force) { session.invalidate(); handShake(); session = sslSocket.getSession(); } return getX509Certificates(session); } protected void handShake() throws IOException { if (sslSocket != null) { sslSocket.setNeedClientAuth(true); sslSocket.startHandshake(); } } protected java.security.cert.X509Certificate[] getX509Certificates(SSLSession session) throws IOException { X509Certificate jsseCerts[] = null; try { jsseCerts = session.getPeerCertificateChain(); } catch(Throwable ex) { // Get rid of the warning in the logs when no Client-Cert is // available } if(jsseCerts == null) { jsseCerts = new X509Certificate[0]; } java.security.cert.X509Certificate [] x509Certs = new java.security.cert.X509Certificate[jsseCerts.length]; for(int i = 0; i < x509Certs.length; i++) { try { byte buffer[] = jsseCerts[i].getEncoded(); CertificateFactory cf = CertificateFactory.getInstance("X.509"); ByteArrayInputStream stream = new ByteArrayInputStream(buffer); x509Certs[i] = (java.security.cert.X509Certificate) cf.generateCertificate(stream); } catch(Exception ex) { return null; } } if(x509Certs.length < 1) { return null; } return x509Certs; } /** * Get the keysize. *

          * What we're supposed to put here is ill-defined by the * Servlet spec (S 4.7 again). There are at least 4 potential * values that might go here: *

          * (a) The size of the encryption key * (b) The size of the MAC key * (c) The size of the key-exchange key * (d) The size of the signature key used by the server *

          * Unfortunately, all of these values are nonsensical. */ public Integer getKeySize() throws IOException { SSLSupport.CipherData c_aux[] = ciphers; if(session == null) { return null; } Integer keySize = (Integer) session.getValue(KEY_SIZE_KEY); if(keySize == null) { int size = 0; String cipherSuite = session.getCipherSuite(); for(int i = 0; i < c_aux.length; i++) { if(cipherSuite.indexOf(c_aux[i].phrase) >= 0) { size = c_aux[i].keySize; break; } } keySize = new Integer(size); session.putValue(KEY_SIZE_KEY, keySize); } return keySize; } /** * The current session Id. */ public String getSessionId() throws IOException { if(session == null) { return null; } // Expose ssl_session (getId) byte [] ssl_session = session.getId(); if(ssl_session == null) { return null; } StringBuffer buf = new StringBuffer(""); for(int x = 0; x < ssl_session.length; x++) { String digit = Integer.toHexString((int) ssl_session[x]); if(digit.length() < 2) { buf.append('0'); } if(digit.length() > 2) { digit = digit.substring(digit.length() - 2); } buf.append(digit); } return buf.toString(); } }././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingServerSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingServe0000644000175000017500000001767211171061542033524 0ustar twernertwerner/* * 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.remoting.transport.coyote.ssl; import org.apache.tomcat.util.net.ServerSocketFactory; import org.jboss.logging.Logger; import org.jboss.remoting.security.ServerSocketFactoryMBean; import org.jboss.remoting.security.ServerSocketFactoryWrapper; import org.jboss.remoting.util.SecurityUtility; import javax.management.MBeanServer; import javax.management.MBeanServerInvocationHandler; import javax.management.ObjectName; import javax.net.ssl.SSLSocket; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; /** * @author Tom Elrod */ public class RemotingServerSocketFactory extends ServerSocketFactory { private Map mbeanServerMap = null; private javax.net.ServerSocketFactory serverSocketFactory = null; private static Map serverSocketFactories = new HashMap(); protected final Logger log = Logger.getLogger(getClass()); private boolean performHandshake = false; public RemotingServerSocketFactory() { } public RemotingServerSocketFactory(Map mbeanServerMap) { //TODO: -TME - THIS IS A TOTAL HACK!!! // Am having to do this because need to get reference to // MBeanServer from original CoyoteInvoker so can lookup // the real ServerSocketFactory to use (which will be registered // within the mbean server). this.mbeanServerMap = mbeanServerMap; } private void init() throws InstantiationException { //TODO: -TME - check for nulls and fallback defaults (or throw exception) String locator = (String) attributes.get("locator"); // first look to see if there is socket factory to use already set serverSocketFactory = (javax.net.ServerSocketFactory)serverSocketFactories.get(locator); if(serverSocketFactory == null) { MBeanServer mbeanserver = (MBeanServer) mbeanServerMap.get(locator); String serverSocketObjName = (String) attributes.get("serverSocketFactory"); if(locator == null || mbeanserver == null || serverSocketObjName == null) { throw new InstantiationException("Can not create ServerSocketFactory with SSL support due " + "to one of the following being null." + "\nlocator = " + locator + "\nmbeanserver = " + mbeanserver + "\nserverSocketObjName = " + serverSocketObjName); } try { ServerSocketFactoryMBean serverSocketFactoryMBean = (ServerSocketFactoryMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanserver, new ObjectName(serverSocketObjName), ServerSocketFactoryMBean.class, false); serverSocketFactory = new ServerSocketFactoryWrapper(serverSocketFactoryMBean); performHandshake = true; } catch(Exception e) { InstantiationException iex = new InstantiationException("Error creating ServerSocketFactory proxy via MBeanServer"); iex.setStackTrace(e.getStackTrace()); throw iex; } } } /** * Returns a server socket which uses all network interfaces on * the host, and is bound to a the specified port. The socket is * configured with the socket options (such as accept timeout) * given to this factory. * * @param port the port to listen to * @throws java.io.IOException for networking errors * @throws InstantiationException for construction errors */ public ServerSocket createSocket(int port) throws IOException, InstantiationException { if(serverSocketFactory == null) { init(); } return serverSocketFactory.createServerSocket(port); } /** * Returns a server socket which uses all network interfaces on * the host, is bound to a the specified port, and uses the * specified connection backlog. The socket is configured with * the socket options (such as accept timeout) given to this factory. * * @param port the port to listen to * @param backlog how many connections are queued * @throws java.io.IOException for networking errors * @throws InstantiationException for construction errors */ public ServerSocket createSocket(int port, int backlog) throws IOException, InstantiationException { if(serverSocketFactory == null) { init(); } return serverSocketFactory.createServerSocket(port, backlog); } /** * Returns a server socket which uses only the specified network * interface on the local host, is bound to a the specified port, * and uses the specified connection backlog. The socket is configured * with the socket options (such as accept timeout) given to this factory. * * @param port the port to listen to * @param backlog how many connections are queued * @param ifAddress the network interface address to use * @throws java.io.IOException for networking errors * @throws InstantiationException for construction errors */ public ServerSocket createSocket(int port, int backlog, InetAddress ifAddress) throws IOException, InstantiationException { if(serverSocketFactory == null) { init(); } ServerSocket svrSocket = serverSocketFactory.createServerSocket(port, backlog, ifAddress); return svrSocket; } /** * Wrapper function for accept(). This allows us to trap and * translate exceptions if necessary * * @throws java.io.IOException; */ public Socket acceptSocket(ServerSocket serverSocket) throws IOException { return accept(serverSocket); } /** * Extra function to initiate the handshake. Sometimes necessary * for SSL * * @throws java.io.IOException; */ public void handshake(Socket sock) throws IOException { if(performHandshake) { ((SSLSocket) sock).startHandshake(); } } public static void setServerSocketFactory(String locatorURI, javax.net.ServerSocketFactory svrSocketFactory) { serverSocketFactories.put(locatorURI, svrSocketFactory); } static private Socket accept(final ServerSocket ss) throws IOException { if (SecurityUtility.skipAccessControl()) { return ss.accept(); } try { return (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return ss.accept(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } }././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingSSLImplementation.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ssl/RemotingSSLIm0000644000175000017500000000430110707512673033362 0ustar twernertwerner/* * 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.remoting.transport.coyote.ssl; import java.net.Socket; import java.util.HashMap; import java.util.Map; import javax.management.MBeanServer; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; import org.apache.tomcat.util.net.SSLImplementation; import org.apache.tomcat.util.net.SSLSupport; import org.apache.tomcat.util.net.ServerSocketFactory; /** * @author Tom Elrod */ public class RemotingSSLImplementation extends SSLImplementation { private static Map mbeanServerMap = new HashMap(); public RemotingSSLImplementation() { super(); } public String getImplementationName() { return "JBoss Remoting SSL"; } public ServerSocketFactory getServerSocketFactory() { return new RemotingServerSocketFactory(mbeanServerMap); } public SSLSupport getSSLSupport(Socket sock) { SSLSupport ssls = new RemotingSSLSupport((SSLSocket) sock); return ssls; } public SSLSupport getSSLSupport(SSLSession session) { return new RemotingSSLSupport(session); } public static void setMBeanServer(String locator, MBeanServer mBeanServer) { mbeanServerMap.put(locator, mBeanServer); } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ClientAbortException.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/ClientAbortExcept0000644000175000017500000000636610452770174033520 0ustar twernertwerner/* * Copyright 1999,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.remoting.transport.coyote; import java.io.IOException; /** * Wrap an IOException identifying it as being caused by an abort * of a request by a remote client. * * @author Glenn L. Nielsen * @version $Revision: 1216 $ $Date: 2006-07-05 19:01:48 +0200 (Mi, 05. Jul 2006) $ */ public final class ClientAbortException extends IOException { private static final long serialVersionUID = -8324466966188969115L; //------------------------------------------------------------ Constructors /** * Construct a new ClientAbortException with no other information. */ public ClientAbortException() { this(null, null); } /** * Construct a new ClientAbortException for the specified message. * * @param message Message describing this exception */ public ClientAbortException(String message) { this(message, null); } /** * Construct a new ClientAbortException for the specified throwable. * * @param throwable Throwable that caused this exception */ public ClientAbortException(Throwable throwable) { this(null, throwable); } /** * Construct a new ClientAbortException for the specified message * and throwable. * * @param message Message describing this exception * @param throwable Throwable that caused this exception */ public ClientAbortException(String message, Throwable throwable) { super(); this.message = message; this.throwable = throwable; } //------------------------------------------------------ Instance Variables /** * The error message passed to our constructor (if any) */ protected String message = null; /** * The underlying exception or error passed to our constructor (if any) */ protected Throwable throwable = null; //---------------------------------------------------------- Public Methods /** * Returns the message associated with this exception, if any. */ public String getMessage() { return (message); } /** * Returns the cause that caused this exception, if any. */ public Throwable getCause() { return (throwable); } /** * Return a formatted string that describes this exception. */ public String toString() { StringBuffer sb = new StringBuffer("ClientAbortException: "); if(message != null) { sb.append(message); if(throwable != null) { sb.append(": "); } } if(throwable != null) { sb.append(throwable.toString()); } return (sb.toString()); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/InputBuffer.java0000644000175000017500000002405310373016624033276 0ustar twernertwerner/* * Copyright 1999,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.remoting.transport.coyote; import java.io.IOException; import java.io.Reader; import java.util.HashMap; import org.apache.coyote.Request; import org.apache.tomcat.util.buf.B2CConverter; import org.apache.tomcat.util.buf.ByteChunk; import org.apache.tomcat.util.buf.CharChunk; /** * The buffer used by Tomcat request. This is a derivative of the Tomcat 3.3 * OutputBuffer, adapted to handle input instead of output. This allows * complete recycling of the facade objects (the ServletInputStream and the * BufferedReader). * * @author Remy Maucherat */ public class InputBuffer extends Reader implements ByteChunk.ByteInputChannel, CharChunk.CharInputChannel, CharChunk.CharOutputChannel { // -------------------------------------------------------------- Constants public static final String DEFAULT_ENCODING = org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING; public static final int DEFAULT_BUFFER_SIZE = 8 * 1024; // The buffer can be used for byte[] and char[] reading // ( this is needed to support ServletInputStream and BufferedReader ) public final int INITIAL_STATE = 0; public final int CHAR_STATE = 1; public final int BYTE_STATE = 2; // ----------------------------------------------------- Instance Variables /** * The byte buffer. */ private ByteChunk bb; /** * The chunk buffer. */ private CharChunk cb; /** * State of the output buffer. */ private int state = 0; /** * Number of bytes read. */ private int bytesRead = 0; /** * Number of chars read. */ private int charsRead = 0; /** * Flag which indicates if the input buffer is closed. */ private boolean closed = false; /** * Byte chunk used to input bytes. */ private ByteChunk inputChunk = new ByteChunk(); /** * Encoding to use. */ private String enc; /** * Encoder is set. */ private boolean gotEnc = false; /** * List of encoders. */ protected HashMap encoders = new HashMap(); /** * Current byte to char converter. */ protected B2CConverter conv; /** * Associated Coyote request. */ private Request coyoteRequest; /** * Buffer position. */ private int markPos = -1; /** * Buffer size. */ private int size = -1; // ----------------------------------------------------------- Constructors /** * Default constructor. Allocate the buffer with the default buffer size. */ public InputBuffer() { this(DEFAULT_BUFFER_SIZE); } /** * Alternate constructor which allows specifying the initial buffer size. * * @param size Buffer size to use */ public InputBuffer(int size) { this.size = size; bb = new ByteChunk(size); bb.setLimit(size); bb.setByteInputChannel(this); cb = new CharChunk(size); cb.setLimit(size); cb.setOptimizedWrite(false); cb.setCharInputChannel(this); cb.setCharOutputChannel(this); } // ------------------------------------------------------------- Properties /** * Associated Coyote request. * * @param coyoteRequest Associated Coyote request */ public void setRequest(Request coyoteRequest) { this.coyoteRequest = coyoteRequest; } /** * Get associated Coyote request. * * @return the associated Coyote request */ public Request getRequest() { return this.coyoteRequest; } // --------------------------------------------------------- Public Methods /** * Recycle the output buffer. */ public void recycle() { state = INITIAL_STATE; bytesRead = 0; charsRead = 0; // If usage of mark made the buffer too big, reallocate it if(cb.getChars().length > size) { cb = new CharChunk(size); cb.setLimit(size); cb.setCharInputChannel(this); cb.setCharOutputChannel(this); } else { cb.recycle(); } markPos = -1; bb.recycle(); closed = false; if(conv != null) { conv.recycle(); } gotEnc = false; enc = null; } /** * Close the input buffer. * * @throws IOException An underlying IOException occurred */ public void close() throws IOException { closed = true; } public int available() throws IOException { if(state == BYTE_STATE) { return bb.getLength(); } else if(state == CHAR_STATE) { return cb.getLength(); } else { return 0; } } // ------------------------------------------------- Bytes Handling Methods /** * Reads new bytes in the byte chunk. * * @param cbuf Byte buffer to be written to the response * @param off Offset * @param len Length * @throws IOException An underlying IOException occurred */ public int realReadBytes(byte cbuf[], int off, int len) throws IOException { if(closed) { return -1; } if(coyoteRequest == null) { return -1; } state = BYTE_STATE; int result = coyoteRequest.doRead(bb); return result; } public int readByte() throws IOException { return bb.substract(); } public int read(byte[] b, int off, int len) throws IOException { return bb.substract(b, off, len); } // ------------------------------------------------- Chars Handling Methods /** * Since the converter will use append, it is possible to get chars to * be removed from the buffer for "writing". Since the chars have already * been read before, they are ignored. If a mark was set, then the * mark is lost. */ public void realWriteChars(char c[], int off, int len) throws IOException { markPos = -1; } public void setEncoding(String s) { enc = s; } public int realReadChars(char cbuf[], int off, int len) throws IOException { if(!gotEnc) { setConverter(); } if(bb.getLength() <= 0) { int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length); if(nRead < 0) { return -1; } } if(markPos == -1) { cb.setOffset(0); cb.setEnd(0); } conv.convert(bb, cb); bb.setOffset(bb.getEnd()); state = CHAR_STATE; return cb.getLength(); } public int read() throws IOException { return cb.substract(); } public int read(char[] cbuf) throws IOException { return read(cbuf, 0, cbuf.length); } public int read(char[] cbuf, int off, int len) throws IOException { return cb.substract(cbuf, off, len); } public long skip(long n) throws IOException { if(n < 0) { throw new IllegalArgumentException(); } long nRead = 0; while(nRead < n) { if(cb.getLength() >= n) { cb.setOffset(cb.getStart() + (int) n); nRead = n; } else { nRead += cb.getLength(); cb.setOffset(cb.getEnd()); int toRead = 0; if(cb.getChars().length < (n - nRead)) { toRead = cb.getChars().length; } else { toRead = (int) (n - nRead); } int nb = realReadChars(cb.getChars(), 0, toRead); if(nb < 0) { break; } } } return nRead; } public boolean ready() throws IOException { return (cb.getLength() > 0); } public boolean markSupported() { return true; } public void mark(int readAheadLimit) throws IOException { if(cb.getLength() <= 0) { cb.setOffset(0); cb.setEnd(0); } else { if((cb.getBuffer().length > (2 * size)) && (cb.getLength()) < (cb.getStart())) { System.arraycopy(cb.getBuffer(), cb.getStart(), cb.getBuffer(), 0, cb.getLength()); cb.setEnd(cb.getLength()); cb.setOffset(0); } } int offset = readAheadLimit; if(offset < size) { offset = size; } cb.setLimit(cb.getStart() + offset); markPos = cb.getStart(); } public void reset() throws IOException { if(state == CHAR_STATE) { if(markPos < 0) { cb.recycle(); markPos = -1; throw new IOException(); } else { cb.setOffset(markPos); } } else { bb.recycle(); } } public void checkConverter() throws IOException { if(!gotEnc) { setConverter(); } } protected void setConverter() throws IOException { if(coyoteRequest != null) { enc = coyoteRequest.getCharacterEncoding(); } gotEnc = true; if(enc == null) { enc = DEFAULT_ENCODING; } conv = (B2CConverter) encoders.get(enc); if(conv == null) { conv = new B2CConverter(enc); encoders.put(enc, conv); } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/CoyoteOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/CoyoteOutputStrea0000644000175000017500000000451410373016624033607 0ustar twernertwerner/* * Copyright 1999,2004 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.remoting.transport.coyote; import java.io.IOException; import java.io.OutputStream; /** * Coyote implementation of the servlet output stream. * * @author Costin Manolache * @author Remy Maucherat */ public class CoyoteOutputStream extends OutputStream { // ----------------------------------------------------- Instance Variables protected OutputBuffer ob; // ----------------------------------------------------------- Constructors protected CoyoteOutputStream(OutputBuffer ob) { this.ob = ob; } // --------------------------------------------------------- Public Methods /** * Prevent cloning the facade. */ protected Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); } // -------------------------------------------------------- Package Methods /** * Clear facade. */ void clear() { ob = null; } // --------------------------------------------------- OutputStream Methods public void write(int i) throws IOException { ob.writeByte(i); } public void write(byte[] b) throws IOException { write(b, 0, b.length); } public void write(byte[] b, int off, int len) throws IOException { ob.write(b, off, len); } /** * Will send the buffer to the client. */ public void flush() throws IOException { // Disabled } public void close() throws IOException { ob.close(); } // -------------------------------------------- ServletOutputStream Methods public void print(String s) throws IOException { ob.write(s); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/coyote/RequestMap.java0000644000175000017500000001011010355142433033116 0ustar twernertwerner/* * 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.remoting.transport.coyote; import java.io.InputStream; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.apache.tomcat.util.buf.B2CConverter; public class RequestMap implements Map { Map internalMap = new HashMap(); /** * The associated input buffer. */ protected InputBuffer inputBuffer = new InputBuffer(); /** * ServletInputStream. */ protected CoyoteInputStream inputStream = new CoyoteInputStream(inputBuffer); /** * Coyote request. */ protected org.apache.coyote.Request coyoteRequest; /** * Set the Coyote request. * * @param coyoteRequest The Coyote request */ public void setCoyoteRequest(org.apache.coyote.Request coyoteRequest) { this.coyoteRequest = coyoteRequest; inputBuffer.setRequest(coyoteRequest); } /** * Get the Coyote request. */ public org.apache.coyote.Request getCoyoteRequest() { return (this.coyoteRequest); } /** * Get the input stream. */ public InputStream getInputStream() { return (this.inputStream); } /** * URI byte to char converter (not recycled). */ protected B2CConverter URIConverter = null; /** * Return the URI converter. */ protected B2CConverter getURIConverter() { return URIConverter; } /** * Set the URI converter. * * @param URIConverter the new URI connverter */ protected void setURIConverter(B2CConverter URIConverter) { this.URIConverter = URIConverter; } public void recycle() { inputBuffer.recycle(); } public int size() { return internalMap.size(); } public boolean isEmpty() { return internalMap.isEmpty(); } public boolean containsKey(Object key) { return internalMap.containsKey(key); } public boolean containsValue(Object value) { return internalMap.containsValue(value); } public Object get(Object key) { if("MethodType".equals(key)) { return coyoteRequest.method().toString(); } else if("Path".equals(key)) { return coyoteRequest.decodedURI().toString(); } else if("HttpVersion".equals(key)) { return coyoteRequest.protocol().toString(); } else { Object value = internalMap.get(key); if(value != null) { return value; } else { return coyoteRequest.getHeader(String.valueOf(key)); } } } public Object put(Object arg0, Object arg1) { return internalMap.put(arg0, arg1); } public Object remove(Object key) { return internalMap.remove(key); } public void putAll(Map arg0) { internalMap.putAll(arg0); } public void clear() { internalMap.clear(); } public Set keySet() { return internalMap.keySet(); } public Collection values() { return internalMap.values(); } public Set entrySet() { return internalMap.entrySet(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/0000755000175000017500000000000011632407045027653 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/WebServerError.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/WebServerError.java0000644000175000017500000000272510456620557033452 0ustar twernertwerner/* * 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.remoting.transport.http; import java.io.IOException; /** * Exception to be thrown by http client invoker in the case * an error is received from web server is calling upon. * The message within this exception will be the data from the error * stream of the web server (error html in most cases). * @author Tom Elrod */ public class WebServerError extends IOException { public WebServerError(String s) { super(s); } }././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.j0000644000175000017500000012647411245307561033322 0ustar twernertwerner/* * 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.remoting.transport.http; import org.jboss.logging.Logger; import org.jboss.remoting.CannotConnectException; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.Home; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvocationResponse; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.RemoteClientInvoker; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.Version; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.marshal.compress.CompressingUnMarshaller; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.transport.web.WebUtil; import org.jboss.remoting.util.SecurityUtility; import org.jboss.util.Base64; import org.jboss.util.threadpool.BasicThreadPool; import org.jboss.util.threadpool.BlockingMode; import org.jboss.util.threadpool.RunnableTaskWrapper; import org.jboss.util.threadpool.Task; import org.jboss.util.threadpool.ThreadPool; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.net.SocketTimeoutException; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; /** * HTTP client invoker. Used for making http requests on http/servlet invoker. * * @author Tom Elrod */ public class HTTPClientInvoker extends RemoteClientInvoker { /** * Key for the configuration map that determines the threadpool size for * simulated timeouts when using jdk 1.4. */ public static final String MAX_NUM_TIMEOUT_THREADS = "maxNumTimeoutThreads"; /** * Key for the configuration map that determines the queue size for simulated * timeout threadpool when using jdk 1.4. */ public static final String MAX_TIMEOUT_QUEUE_SIZE = "maxTimeoutQueueSize"; /** * Specifies the default number of work threads in the thread pool for * simulating timeouts when using jdk 1.4. */ public static final int MAX_NUM_TIMEOUT_THREADS_DEFAULT = 10; /** * Specifies the number of attempts to get a functioning connection * to the http server. Defaults to 1. */ public static final String NUMBER_OF_CALL_ATTEMPTS = "numberOfCallAttempts"; /* * Specifies whether useHttpURLConnection(), upon receiving a null InputStream or ErrorStream, * should call the UnMarshaller. */ public static final String UNMARSHAL_NULL_STREAM = "unmarshalNullStream"; protected static final Logger log = Logger.getLogger(HTTPClientInvoker.class); protected boolean noThrowOnError; protected int numberOfCallAttempts = 1; protected boolean unmarshalNullStream = true; protected boolean useRemotingContentType = false; private Object timeoutThreadPoolLock = new Object(); private ThreadPool timeoutThreadPool; public HTTPClientInvoker(InvokerLocator locator) { super(locator); configureParameters(); } public HTTPClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); configureParameters(); } /** * @param sessionId * @param invocation * @param marshaller * @return * @throws java.io.IOException * @throws org.jboss.remoting.ConnectionFailedException * */ protected Object transport(String sessionId, final Object invocation, Map metadata, final Marshaller marshaller, final UnMarshaller unmarshaller) throws IOException, ConnectionFailedException { // need to check the url and make sure it compatible protocol final String validatedUrl = validateURL(getLocator().getLocatorURI()); if (metadata == null) { metadata = new HashMap(); } final HttpURLConnection conn = createURLConnection(validatedUrl, metadata); int simulatedTimeout = getSimulatedTimeout(configuration, metadata, conn); if (simulatedTimeout <= 0) { return makeInvocation(conn, validatedUrl, invocation, metadata, marshaller, unmarshaller, true); } else { if (log.isTraceEnabled()) log.trace("using simulated timeout: " + simulatedTimeout); class Holder {public Object value;} final Holder resultHolder = new Holder(); final Map finalMetadata = metadata; Runnable r = new Runnable() { public void run() { try { resultHolder.value = useHttpURLConnection(conn, invocation, finalMetadata, marshaller, unmarshaller); if (log.isTraceEnabled()) log.trace("result: " + resultHolder.value); } catch (Exception e) { resultHolder.value = e; if (log.isTraceEnabled()) log.trace("exception: " + e); } } }; // BasicThreadPool timeout mechanism depends on the interrupted status of // the running thread. Thread.interrupted(); ThreadPool pool = getTimeoutThreadPool(); WaitingTaskWrapper wrapper = new WaitingTaskWrapper(r, simulatedTimeout); if (log.isTraceEnabled()) log.trace("starting task in thread pool"); pool.runTaskWrapper(wrapper); if (log.isTraceEnabled()) log.trace("task finished in thread pool"); Object result = resultHolder.value; if (result == null) { if (log.isDebugEnabled()) log.debug("invocation timed out"); Exception cause = new SocketTimeoutException("timed out"); throw new CannotConnectException("Can not connect http client invoker.", cause); } else if (result instanceof IOException) { throw (IOException) result; } else if (result instanceof RuntimeException) { throw (RuntimeException) result; } else { if (log.isTraceEnabled()) log.trace("returning result: " + result); return result; } } } protected Object makeInvocation(HttpURLConnection conn, String url, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller, boolean setTimeout) throws IOException { Throwable savedException = null; for (int i = 0; i < numberOfCallAttempts; i++) { try { Object o = useHttpURLConnection(conn, invocation, metadata, marshaller, unmarshaller); if (log.isTraceEnabled()) log.trace("result: " + o); return o; } catch (CannotConnectException e) { savedException = e.getCause(); String suffix = (i < (numberOfCallAttempts - 1) ? ": will retry" : ""); log.debug("Cannot connect on attempt " + (i + 1) + suffix); conn = createURLConnection(url, metadata); if (setTimeout) { getSimulatedTimeout(configuration, metadata, conn); } } } String msg = "Can not connect http client invoker after " + numberOfCallAttempts + " attempt(s)"; throw new CannotConnectException(msg, savedException); } private Object useHttpURLConnection(HttpURLConnection conn, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller) throws WebServerError { Object result = null; int responseCode = -1; try { setChunked(configuration, conn); // check to see if basic auth required String basicAuth = getBasicAuth(metadata); if (basicAuth != null) { conn.setRequestProperty("Authorization", basicAuth); } // check for ping request and process it now and return result = checkForLeasePing(conn, invocation, metadata); if(result != null) { return result; } // Get the request method type boolean sendingData = true; String type = "POST"; if (metadata != null) { type = (String) metadata.get("TYPE"); if (type != null) { if ((!type.equals("POST") && !type.equals("PUT"))) { sendingData = false; } } else { type = "POST"; } } else // need to check for content type and set metadata { metadata = new HashMap(); Map header = new HashMap(); header.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.getContentType(invocation)); metadata.put("HEADER", header); } // Set request headers Map header = (Map) metadata.get("HEADER"); if (header != null) { Set keys = header.keySet(); Iterator itr = keys.iterator(); while (itr.hasNext()) { String key = (String) itr.next(); String value = (String) header.get(key); log.debug("Setting request header with " + key + " : " + value); conn.setRequestProperty(key, value); } } else { conn.setRequestProperty(HTTPMetadataConstants.CONTENTTYPE, WebUtil.getContentType(invocation)); } metadata.put(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE, Boolean.toString(useRemotingContentType)); // set the remoting version conn.setRequestProperty(HTTPMetadataConstants.REMOTING_VERSION_HEADER, new Integer(getVersion()).toString()); // set the user agent conn.setRequestProperty(HTTPMetadataConstants.REMOTING_USER_AGENT, "JBossRemoting - " + Version.VERSION); if (sendingData) { //POST or PUT conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestMethod(type); if (invocation instanceof String) { conn.setRequestProperty(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING); } else { conn.setRequestProperty(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING); } OutputStream stream = getOutputStream(conn); if (marshaller instanceof VersionedMarshaller) ((VersionedMarshaller) marshaller).write(invocation, stream, getVersion()); else marshaller.write(invocation, stream); responseCode = getResponseCode(conn); Map headers = conn.getHeaderFields(); if (metadata == null) { metadata = new HashMap(); } // sometimes I get headers with "null" keys (I don't know who's fault is it), so I need // to clean the header map, unless I want to get an NPE thrown by metadata.putAll() if (headers != null) { for(Iterator i = headers.entrySet().iterator(); i.hasNext(); ) { Map.Entry e = (Map.Entry)i.next(); if (e.getKey() != null) { metadata.put(e.getKey(), e.getValue()); } } } String responseMessage = getResponseMessage(conn); metadata.put(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE, responseMessage); metadata.put(HTTPMetadataConstants.RESPONSE_CODE, new Integer(responseCode)); metadata.put(HTTPMetadataConstants.RESPONSE_HEADERS, headers); InputStream is = (responseCode < 400) ? conn.getInputStream() : conn.getErrorStream(); if (is != null || unmarshalNullStream) { result = readResponse(metadata, headers, unmarshaller, is); } } else { conn.setDoOutput(false); conn.setDoInput(true); conn.setRequestMethod(type); connect(conn); InputStream is = (getResponseCode(conn) < 400) ? conn.getInputStream() : conn.getErrorStream(); Map headers = conn.getHeaderFields(); if (is != null || unmarshalNullStream) { result = readResponse(null, headers, unmarshaller, is); } if (metadata == null) { metadata = new HashMap(); } metadata.putAll(headers); String responseMessage = getResponseMessage(conn); metadata.put(HTTPMetadataConstants.RESPONSE_CODE_MESSAGE, responseMessage); responseCode = getResponseCode(conn); metadata.put(HTTPMetadataConstants.RESPONSE_CODE, new Integer(responseCode)); metadata.put(HTTPMetadataConstants.RESPONSE_HEADERS, conn.getHeaderFields()); } } catch (Exception e) { String message = "Can not connect http client invoker."; if (e.getMessage() != null) message += " " + e.getMessage() + "."; try { String responseMessage = getResponseMessage(conn); int code = getResponseCode(conn); message += " Response: " + responseMessage + "/" + code + "."; } catch (IOException e1) { log.debug("Unable to retrieve response message", e1); } throw new CannotConnectException(message, e); } // now check for error response and throw exception unless configured to not do so if(responseCode >= 400) { boolean doNotThrow = noThrowOnError; if(metadata != null) { Object configObj = metadata.get(HTTPMetadataConstants.NO_THROW_ON_ERROR); if(configObj != null && configObj instanceof String) { doNotThrow = Boolean.valueOf((String)configObj).booleanValue(); } } if(doNotThrow) { if(result instanceof String) { // this is a html error page displayed by web server, need to conver to exception WebServerError ex = new WebServerError((String)result); return ex; } else if (result instanceof InvocationResponse) { return ((InvocationResponse) result).getResult(); } else { return result; } } // if got here, wasn't configured to not throw exception, so will throw it. // In this case, MicroRemoteClientInvoker will throw the exception carried by // the InvocationResponse. if (result instanceof InvocationResponse) return result; // Otherwise, create a new WebServerError. if(result instanceof String) { WebServerError ex = new WebServerError((String)result); throw ex; } else { WebServerError ex = new WebServerError("Error received when calling on web server. Error returned was " + responseCode); throw ex; } } return result; } private Object checkForLeasePing(HttpURLConnection conn, Object invocation, Map metadata) throws IOException { InvocationResponse response = null; boolean shouldLease = false; long leasePeriod = -1; if(invocation != null && invocation instanceof InvocationRequest) { InvocationRequest request = (InvocationRequest)invocation; Object payload = request.getParameter(); // although a bit of a hack, this will determin if first time ping called by client. if(payload != null && payload instanceof String && "$PING$".equalsIgnoreCase((String)payload) && request.getReturnPayload() != null) { try { // now know is a ping request, so convert to be a HEAD method call conn.setDoOutput(false); conn.setDoInput(true); conn.setRequestMethod("HEAD"); // set the remoting version conn.setRequestProperty(HTTPMetadataConstants.REMOTING_VERSION_HEADER, new Integer(getVersion()).toString()); // set the user agent conn.setRequestProperty(HTTPMetadataConstants.REMOTING_USER_AGENT, "JBossRemoting - " + Version.VERSION); conn.setRequestProperty(HTTPMetadataConstants.REMOTING_LEASE_QUERY, "true"); conn.setRequestProperty("sessionId", request.getSessionId()); connect(conn); //InputStream is = (conn.getResponseCode() < 400) ? conn.getInputStream() : conn.getErrorStream(); Map headers = conn.getHeaderFields(); if(headers != null) { Object leasingEnabled = headers.get("LEASING_ENABLED"); if(leasingEnabled != null && leasingEnabled instanceof List) { shouldLease = new Boolean((String)((List)leasingEnabled).get(0)).booleanValue(); } Object leasingPeriod = headers.get("LEASE_PERIOD"); if(leasingPeriod != null && leasingPeriod instanceof List) { leasePeriod = new Long((String)((List)leasingPeriod).get(0)).longValue(); } } } catch (IOException e) { log.error("Error checking server for lease information.", e); } Map p = new HashMap(); p.put("clientLeasePeriod", new Long(leasePeriod)); InvocationResponse innterResponse = new InvocationResponse(null, new Boolean(shouldLease), false, p); response = new InvocationResponse(null, innterResponse, false, null); } } return response; } private Object readResponse(Map metadata, Map headers, UnMarshaller unmarshaller, InputStream is) throws ClassNotFoundException, IOException { Object result = null; String encoding = null; Object ceObj = headers.get("Content-Encoding"); if (ceObj != null) { if (ceObj instanceof List) { encoding = (String) ((List) ceObj).get(0); } } if (encoding != null && encoding.indexOf("gzip") >= 0) { unmarshaller = new CompressingUnMarshaller(MarshalFactory.getUnMarshaller(SerializableUnMarshaller.DATATYPE)); } Map map = metadata == null ? new HashMap(headers) : metadata; // UnMarshaller may not be an HTTPUnMarshaller, in which case it // can ignore this parameter. if (map.get(HTTPUnMarshaller.PRESERVE_LINES) == null) { Object o = configuration.get(HTTPUnMarshaller.PRESERVE_LINES); if (o != null) map.put(HTTPUnMarshaller.PRESERVE_LINES, o); } map.put(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE, Boolean.toString(useRemotingContentType)); try { if (unmarshaller instanceof VersionedUnMarshaller) result = ((VersionedUnMarshaller)unmarshaller).read(is, map, getVersion()); else result = unmarshaller.read(is, map); } catch (ClassNotFoundException e) { throw e; } catch (IOException e) { log.trace(this + " unable to read response", e); if (-1 == is.read()) { throw new EOFException(); } throw e; } return result; } private void setChunked(Map metadata, final HttpURLConnection conn) { String chunkedValue = (String) metadata.get("chunkedLength"); if (chunkedValue != null && chunkedValue.length() > 0) { try { int chunkedLength = Integer.parseInt(chunkedValue); /** * Since HTTPURLConnection in jdk 1.4 does NOT have a setChunkedStreamingMode() method and * the one in jdk 1.5 does, will have to use reflection to see if it exists before trying to set it. */ try { Class cl = conn.getClass(); Class[] paramTypes = new Class[] {int.class}; Method setChunkedLengthMethod = getMethod(cl, "setChunkedStreamingMode", paramTypes); setChunkedLengthMethod.invoke(conn, new Object[]{new Integer(chunkedLength)}); } catch (NoSuchMethodException e) { log.warn("Could not set chunked length (" + chunkedLength + ") on http client transport as method not available with JDK 1.4 (only JDK 1.5 or higher)"); } catch (IllegalAccessException e) { log.error("Error setting http client connection chunked length."); log.debug(e); } catch (InvocationTargetException e) { log.error("Error setting http client connection chunked length."); log.debug(e); } catch (Exception e) { // Unexpected. log.error("Unexpected error setting http client connection chunked length."); log.debug(e); } } catch (NumberFormatException e) { log.error("Could not set chunked length for http client connection because value (" + chunkedValue + ") is not a number."); } } } private int getSimulatedTimeout(Map configuration, Map metadata, final HttpURLConnection conn) { int timeout = -1; String connectionTimeout = (String) configuration.get("timeout"); String invocationTimeout = (String) metadata.get("timeout"); if (invocationTimeout != null && invocationTimeout.length() > 0) { try { timeout = Integer.parseInt(invocationTimeout); } catch (NumberFormatException e) { log.error("Could not set timeout for current invocation because value (" + invocationTimeout + ") is not a number."); } } if (timeout < 0 && connectionTimeout != null && connectionTimeout.length() > 0) { try { timeout = Integer.parseInt(connectionTimeout); } catch (NumberFormatException e) { log.error("Could not set timeout for http client connection because value (" + connectionTimeout + ") is not a number."); } } if (timeout < 0) timeout = 0; /** * Since URLConnection in jdk 1.4 does NOT have a setConnectTimeout() method and * the one in jdk 1.5 does, will have to use reflection to see if it exists before * trying to set it. */ try { Class cl = conn.getClass(); Class[] paramTypes = new Class[] {int.class}; Method setTimeoutMethod = getMethod(cl, "setConnectTimeout", paramTypes); setTimeoutMethod.invoke(conn, new Object[]{new Integer(timeout)}); setTimeoutMethod = getMethod(cl, "setReadTimeout", paramTypes); setTimeoutMethod.invoke(conn, new Object[]{new Integer(timeout)}); return -1; } catch (NoSuchMethodException e) { log.debug("Using older JDK (prior to 1.5): will simulate timeout"); } catch (IllegalAccessException e) { log.error("Error setting http client connection timeout."); log.debug(e); } catch (InvocationTargetException e) { log.error("Error setting http client connection timeout."); log.debug(e); } catch (Exception e) { // Unexpected. log.error("Unexpected error setting http client connection timeout."); log.debug(e); } return timeout; } protected String validateURL(String url) { String validatedUrl = url; if (validatedUrl.startsWith("servlet")) { // servlet:// is a valid protocol, but only in the remoting world, so need to convert to http validatedUrl = "http" + validatedUrl.substring("servlet".length()); } return validatedUrl; } protected Home getUsableAddress() { InvokerLocator savedLocator = locator; String protocol = savedLocator.getProtocol(); String path = savedLocator.getPath(); Map params = savedLocator.getParameters(); List homes = getConnectHomes(); Iterator it = homes.iterator(); while (it.hasNext()) { Home home = null; try { home = (Home) it.next(); locator = new InvokerLocator(protocol, home.host, home.port, path, params); invoke(new InvocationRequest(null, null, ServerInvoker.ECHO, null, null, null)); if (log.isTraceEnabled()) log.trace(this + " able to contact server at: " + home); return home; } catch (Throwable e) { log.debug(this + " unable to contact server at: " + home); } finally { locator = savedLocator; } } return null; } protected HttpURLConnection createURLConnection(String url, Map metadata) throws IOException { URL externalURL = null; HttpURLConnection httpURLConn = null; // need to find out if need to use a proxy or not String proxyHost = null; String proxyportString = null; int proxyPort = 80; if (metadata != null) { // first check the metadata as will have precedence proxyHost = (String) metadata.get("http.proxyHost"); proxyportString = (String) metadata.get("http.proxyPort"); if (proxyportString != null && proxyportString.length() > 0) { try { proxyPort = Integer.parseInt(proxyportString); } catch (NumberFormatException e) { log.warn("Error converting proxy port specified (" + proxyportString + ") to a number."); } } } // now determin if going to use proxy or not if (proxyHost != null) { externalURL = new URL(url); /** * Since URL in jdk 1.4 does NOT have a openConnection(Proxy) method and * the one in jdk 1.5 does, will have to use reflection to see if it exists before trying to set it. */ try { final Class proxyClass = ClassLoaderUtility.loadClass("java.net.Proxy", HTTPClientInvoker.class); InetSocketAddress proxyAddress = new InetSocketAddress(proxyHost, proxyPort); Class[] decalredClasses = proxyClass.getDeclaredClasses(); Class proxyTypeClass = null; for(int x = 0; x < decalredClasses.length; x++) { Class declaredClass = decalredClasses[x]; String className = declaredClass.getName(); if(className.endsWith("Type")) { proxyTypeClass = declaredClass; break; } } Object proxyType = null; Field[] fields = proxyTypeClass.getDeclaredFields(); for(int i = 0; i < fields.length; i++) { Field field = fields[i]; String fieldName = field.getName(); if(fieldName.endsWith("HTTP")) { proxyType = field.get(proxyTypeClass); break; } } Constructor proxyConstructor = proxyClass.getConstructor(new Class[] {proxyTypeClass, SocketAddress.class}); Object proxy = proxyConstructor.newInstance(new Object[] {proxyType, proxyAddress}); Method openConnection = getMethod(URL.class, "openConnection", new Class[] {proxyClass}); httpURLConn = (HttpURLConnection)openConnection.invoke(externalURL, new Object[] {proxy}); } catch (Exception e) { log.error("Can not set proxy for http invocation (proxy host: " + proxyHost + ", proxy port: " + proxyPort + ") " + "as this configuration requires JDK 1.5 or later. If running JDK 1.4, can use proxy by setting system properties."); log.debug(e); } // since know it is a proxy being used, see if have proxy auth String proxyAuth = getProxyAuth(metadata); if (proxyAuth != null) { httpURLConn.setRequestProperty("Proxy-Authorization", proxyAuth); } } else { externalURL = new URL(url); httpURLConn = (HttpURLConnection) externalURL.openConnection(); // Check if proxy is being configured by system properties. if (getSystemProperty("http.proxyHost") != null) { String proxyAuth = getProxyAuth(metadata); if (proxyAuth != null) { httpURLConn.setRequestProperty("Proxy-Authorization", proxyAuth); } } } return httpURLConn; } private String getProxyAuth(Map metadata) { String authString = null; String username = null; String password = null; if (metadata != null) { username = (String) metadata.get("http.proxy.username"); } if (username == null || username.length() == 0) { username = getSystemProperty("http.proxy.username"); } if (metadata != null) { password = (String) metadata.get("http.proxy.password"); } if (password == null) { password = getSystemProperty("http.proxy.password"); } if (username != null && password != null) { StringBuffer buffer = new StringBuffer(); buffer.append(username); buffer.append(":"); buffer.append(password); String encoded = Base64.encodeBytes(buffer.toString().getBytes()); authString = "Basic " + encoded; } return authString; } private String getBasicAuth(Map metadata) { String authString = null; String username = null; String password = null; if (metadata != null) { username = (String) metadata.get("http.basic.username"); } if (username == null || username.length() == 0) { username = getSystemProperty("http.basic.username"); } if (metadata != null) { password = (String) metadata.get("http.basic.password"); } if (password == null) { password = getSystemProperty("http.basic.password"); } if (username != null && password != null) { StringBuffer buffer = new StringBuffer(); buffer.append(username); buffer.append(":"); buffer.append(password); String encoded = Base64.encodeBytes(buffer.toString().getBytes(), Base64.DONT_BREAK_LINES); authString = "Basic " + encoded; } return authString; } /** * subclasses must implement this method to provide a hook to connect to the remote server, if this applies * to the specific transport. However, in some transport implementations, this may not make must difference since * the connection is not persistent among invocations, such as SOAP. In these cases, the method should * silently return without any processing. * * @throws org.jboss.remoting.ConnectionFailedException * */ protected void handleConnect() throws ConnectionFailedException { if (InvokerLocator.MULTIHOME.equals(locator.getHost())) { Home home = getUsableAddress(); if (home == null) { throw new ConnectionFailedException(this + " unable to find a usable address for: " + home); } String protocol = locator.getProtocol(); String path = locator.getPath(); Map params = locator.getParameters(); locator = new InvokerLocator(protocol, home.host, home.port, path, params); if (log.isDebugEnabled()) log.debug(this + " will use InvokerLocator " + locator); } } /** * subclasses must implement this method to provide a hook to disconnect from the remote server, if this applies * to the specific transport. However, in some transport implementations, this may not make must difference since * the connection is not persistent among invocations, such as SOAP. In these cases, the method should * silently return without any processing. */ protected void handleDisconnect() { // NO OP as not statefull connection } /** * Each implementation of the remote client invoker should have * a default data type that is uses in the case it is not specified * in the invoker locator uri. * * @return */ protected String getDefaultDataType() { return HTTPMarshaller.DATATYPE; } /** * Sets the thread pool to be used for simulating timeouts with jdk 1.4. */ public void setTimeoutThreadPool(ThreadPool pool) { this.timeoutThreadPool = pool; } protected void configureParameters() { Object val = configuration.get(HTTPMetadataConstants.NO_THROW_ON_ERROR); if (val != null) { try { noThrowOnError = Boolean.valueOf((String)val).booleanValue(); log.debug(this + " setting noThrowOnError to " + noThrowOnError); } catch (Exception e) { log.warn(this + " could not convert " + HTTPMetadataConstants.NO_THROW_ON_ERROR + " value of " + val + " to a boolean value."); } } val = configuration.get(NUMBER_OF_CALL_ATTEMPTS); if (val != null) { try { numberOfCallAttempts = Integer.valueOf((String)val).intValue(); log.debug(this + " setting numberOfCallRetries to " + numberOfCallAttempts); } catch (Exception e) { log.warn(this + " could not convert " + NUMBER_OF_CALL_ATTEMPTS + " value of " + val + " to an int value."); } } val = configuration.get(UNMARSHAL_NULL_STREAM); if (val != null) { try { unmarshalNullStream = Boolean.valueOf((String)val).booleanValue(); log.debug(this + " setting unmarshalNullStream to " + unmarshalNullStream); } catch (Exception e) { log.warn(this + " could not convert " + UNMARSHAL_NULL_STREAM + " value of " + val + " to a boolean value."); } } val = configuration.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE); if (val != null) { try { useRemotingContentType = Boolean.valueOf((String)val).booleanValue(); log.debug(this + " setting useRemotingContent to " + useRemotingContentType); } catch (Exception e) { log.warn(this + " could not convert " + HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE + " value of " + val + " to a boolean value."); } } } /** * Gets the thread pool being used for simulating timeouts with jdk 1.4. If one has * not be specifically set via configuration or call to set it, will always return * instance of org.jboss.util.threadpool.BasicThreadPool. */ public ThreadPool getTimeoutThreadPool() { synchronized (timeoutThreadPoolLock) { if (timeoutThreadPool == null) { int maxNumberThreads = MAX_NUM_TIMEOUT_THREADS_DEFAULT; int maxTimeoutQueueSize = -1; BasicThreadPool pool = new BasicThreadPool("HTTP timeout"); log.debug("created new thread pool: " + pool); Object param = configuration.get(MAX_NUM_TIMEOUT_THREADS); if (param instanceof String) { try { maxNumberThreads = Integer.parseInt((String) param); } catch (NumberFormatException e) { log.error("maxNumberThreads parameter has invalid format: " + param); } } else if (param != null) { log.error("maxNumberThreads parameter must be a string in integer format: " + param); } param = configuration.get(MAX_TIMEOUT_QUEUE_SIZE); if (param instanceof String) { try { maxTimeoutQueueSize = Integer.parseInt((String) param); } catch (NumberFormatException e) { log.error("maxTimeoutQueueSize parameter has invalid format: " + param); } } else if (param != null) { log.error("maxTimeoutQueueSize parameter must be a string in integer format: " + param); } pool.setMaximumPoolSize(maxNumberThreads); if (maxTimeoutQueueSize > 0) { pool.setMaximumQueueSize(maxTimeoutQueueSize); } pool.setBlockingMode(BlockingMode.RUN); timeoutThreadPool = pool; } } return timeoutThreadPool; } /** * When a WaitingTaskWrapper is run in a BasicThreadPool, the calling thread * will block for the designated timeout period. */ static class WaitingTaskWrapper extends RunnableTaskWrapper { long completeTimeout; public WaitingTaskWrapper(Runnable runnable, long completeTimeout) { super(runnable, 0, completeTimeout); this.completeTimeout = completeTimeout; } public int getTaskWaitType() { return Task.WAIT_FOR_COMPLETE; } public String toString() { return "WaitingTaskWrapper[" + completeTimeout + "]"; } } static private String getSystemProperty(final String name) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private Method getMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { return c.getMethod(name, parameterTypes); } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { return c.getMethod(name, parameterTypes); } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } static private void connect(final HttpURLConnection conn) throws IOException { if (SecurityUtility.skipAccessControl()) { conn.connect(); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { conn.connect(); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private OutputStream getOutputStream(final HttpURLConnection conn) throws IOException { if (SecurityUtility.skipAccessControl()) { return conn.getOutputStream(); } try { return (OutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return conn.getOutputStream(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private int getResponseCode(final HttpURLConnection conn) throws IOException { if (SecurityUtility.skipAccessControl()) { return conn.getResponseCode(); } try { return ((Integer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return new Integer(conn.getResponseCode()); } })).intValue(); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private String getResponseMessage(final HttpURLConnection conn) throws IOException { if (SecurityUtility.skipAccessControl()) { return conn.getResponseMessage(); } try { return (String) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return conn.getResponseMessage(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/TransportClientFact0000644000175000017500000000307210455077561033541 0ustar twernertwerner/* * 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.remoting.transport.http; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new HTTPClientInvoker(locator, config); } public boolean supportsSSL() { return false; } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/TransportServerFact0000644000175000017500000000112510455077561033566 0ustar twernertwernerpackage org.jboss.remoting.transport.http; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.coyote.CoyoteInvoker; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new CoyoteInvoker(locator, config); } public boolean supportsSSL() { return false; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/ssl/0000755000175000017500000000000011632407045030454 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/ssl/HTTPSClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/ssl/HTTPSClientInvo0000644000175000017500000002065611011161647033301 0ustar twernertwerner/* * 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.remoting.transport.http.ssl; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.remoting.security.CustomSSLSocketFactory; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.SSLSocketBuilderMBean; import org.jboss.remoting.socketfactory.SocketFactoryWrapper; import org.jboss.remoting.transport.http.HTTPClientInvoker; import javax.net.SocketFactory; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocketFactory; import java.io.IOException; import java.lang.reflect.Constructor; import java.net.HttpURLConnection; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Map; /** * @author Tom Elrod */ public class HTTPSClientInvoker extends HTTPClientInvoker { /** * A property to override the default https url host verification */ public static final String IGNORE_HTTPS_HOST = "org.jboss.security.ignoreHttpsHost"; public static final String HOSTNAME_VERIFIER = "hostnameVerifier"; public HTTPSClientInvoker(InvokerLocator locator) { super(locator); } public HTTPSClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } protected String validateURL(String url) { String validatedUrl = url; if (validatedUrl.startsWith("servlet")) { // servlet:// is a valid protocol, but only in the remoting world, so need to convert to http validatedUrl = "http" + validatedUrl.substring("servlet".length()); } else if(validatedUrl.startsWith("sslservlet")) { // sslservlet:// is a valid protocol, but only in the remoting world, so need to convert to https validatedUrl = "https" + validatedUrl.substring("sslservlet".length()); } return validatedUrl; } /** * Checks to see if org.jboss.security.ignoreHttpHost property is set to true, and if it * is, will ste the host name verifier so that will accept any host. * * @return * @throws IOException */ protected HttpURLConnection createURLConnection(String url, Map metadata) throws IOException { HttpURLConnection conn = super.createURLConnection(url, metadata); if (conn instanceof HttpsURLConnection) { HttpsURLConnection sconn = (HttpsURLConnection) conn; SocketFactory socketFactory = getSocketFactory(); if (socketFactory != null && socketFactory instanceof SSLSocketFactory) { SSLSocketFactory sslSocketFactory = getHandshakeCompatibleFactory((SSLSocketFactory) socketFactory, metadata); sconn.setSSLSocketFactory(sslSocketFactory); } setHostnameVerifier(sconn, metadata); } return conn; } private SSLSocketFactory getHandshakeCompatibleFactory(SSLSocketFactory socketFactory, Map metadata) { SSLSocketFactory sslSocketFactory = socketFactory; // need to check for handshake listener and add them if there is one Object obj = configuration.get(Client.HANDSHAKE_COMPLETED_LISTENER); if (obj != null && obj instanceof HandshakeCompletedListener) { HandshakeCompletedListener listener = (HandshakeCompletedListener) obj; sslSocketFactory = new HTTPSSocketFactory(socketFactory, listener); } return sslSocketFactory; } protected SocketFactory createSocketFactory(Map configuration) { SocketFactory sf = super.createSocketFactory(configuration); if (isCompleteSocketFactory(sf)) return sf; SocketFactory wrapper = sf; try { SSLSocketBuilder server = new SSLSocketBuilder(configuration); server.setUseSSLSocketFactory(false); sf = server.createSSLSocketFactory(); } catch (Exception e) { log.error("Error creating SSL Socket Factory for client invoker: " + e.getMessage()); log.debug("Error creating SSL Socket Factory for client invoker.", e); } if (wrapper != null) { ((SocketFactoryWrapper) wrapper).setSocketFactory(sf); return wrapper; } return sf; } protected void setHostnameVerifier(HttpsURLConnection conn, Map metadata) { HostnameVerifier hostnameVerifier = null; // First look for specific HostnameVerifier classname. String hostnameVerifierString = (String)metadata.get(HOSTNAME_VERIFIER); if (hostnameVerifierString == null || hostnameVerifierString.length() == 0) hostnameVerifierString = (String)configuration.get(HOSTNAME_VERIFIER); if(hostnameVerifierString != null && hostnameVerifierString.length() > 0) { try { Class cl = ClassLoaderUtility.loadClass(hostnameVerifierString, getClass()); Constructor constructor = cl.getConstructor(new Class[]{}); hostnameVerifier = (HostnameVerifier) constructor.newInstance(new Object[] {}); log.trace("HostnameVerifier (" + hostnameVerifierString + ") loaded"); } catch(Exception e) { log.debug("Could not create server socket factory by classname (" + hostnameVerifierString + "). Error message: " + e.getMessage()); } } // If we still don't have a HostnameVerifier, look for directive to ignore host name. if (hostnameVerifier == null) { Boolean b = (Boolean) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(Boolean.getBoolean(IGNORE_HTTPS_HOST)); } }); boolean ignoreHTTPSHost = b.booleanValue(); String ignoreHost = (String) metadata.get(IGNORE_HTTPS_HOST); if (ignoreHost != null && ignoreHost.length() > 0) { ignoreHTTPSHost = Boolean.valueOf(ignoreHost).booleanValue(); } else { ignoreHost = (String) configuration.get(IGNORE_HTTPS_HOST); if (ignoreHost != null && ignoreHost.length() > 0) { ignoreHTTPSHost = Boolean.valueOf(ignoreHost).booleanValue(); } } if (ignoreHTTPSHost) { hostnameVerifier = new AnyhostVerifier(); } } // If we still don't have a HostnameVerifier, see if the SocketFactory is an instance of // org.jboss.remoting.security.CustomSSLSocketFactory, and, if so, if it has turned off // authentication. if (hostnameVerifier == null) { if (getSocketFactory() instanceof CustomSSLSocketFactory) { CustomSSLSocketFactory sf = (CustomSSLSocketFactory) getSocketFactory(); SSLSocketBuilderMBean builder = sf.getSSLSocketBuilder(); if (( builder.isSocketUseClientMode() && !builder.isServerAuthMode()) || (!builder.isSocketUseClientMode() && builder.isClientAuthModeNone())) hostnameVerifier = new AnyhostVerifier(); } } if (hostnameVerifier != null) conn.setHostnameVerifier(hostnameVerifier); } protected class AnyhostVerifier implements HostnameVerifier { public boolean verify(String s, SSLSession sslSession) { return true; } } }././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/ssl/HTTPSSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/ssl/HTTPSSocketFact0000644000175000017500000001103110426161234033241 0ustar twernertwerner/* * 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.remoting.transport.http.ssl; import org.jboss.remoting.util.socket.HandshakeRepeater; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; /** * This is a wrapper for the real SSLSocketFactory passed to it so can have it create * the real SSLSocket and then add HandshakeCompletedListener to it. This is needed * because no direct API to the HttpsURLConnection class to do this, so am having to * do it this way. * * @author Tom Elrod */ public class HTTPSSocketFactory extends SSLSocketFactory { private SSLSocketFactory targetFactory = null; private HandshakeCompletedListener targetListener = null; public HTTPSSocketFactory(SSLSocketFactory socketFactory, HandshakeCompletedListener listener) { this.targetFactory = socketFactory; this.targetListener = listener; if (targetFactory == null) { throw new RuntimeException("Can not create HTTPSSocketFactory with target SSLSocketFactory being null."); } if (targetListener == null) { throw new RuntimeException("Can not create HTTPSSocketFactory with target HandshakeCompletedListener being null."); } } public String[] getDefaultCipherSuites() { return targetFactory.getDefaultCipherSuites(); } public String[] getSupportedCipherSuites() { return targetFactory.getSupportedCipherSuites(); } public Socket createSocket(Socket socket, String string, int i, boolean b) throws IOException { Socket retSocket = targetFactory.createSocket(socket, string, i, b); if (retSocket instanceof SSLSocket) { establishHandshake((SSLSocket) retSocket, targetListener); } return retSocket; } public Socket createSocket(String string, int i) throws IOException, UnknownHostException { Socket retSocket = targetFactory.createSocket(string, i); if (retSocket instanceof SSLSocket) { establishHandshake((SSLSocket) retSocket, targetListener); } return retSocket; } public Socket createSocket(InetAddress inetAddress, int i) throws IOException { Socket retSocket = targetFactory.createSocket(inetAddress, i); if (retSocket instanceof SSLSocket) { establishHandshake((SSLSocket) retSocket, targetListener); } return retSocket; } public Socket createSocket(String string, int i, InetAddress inetAddress, int i1) throws IOException, UnknownHostException { Socket retSocket = targetFactory.createSocket(string, i, inetAddress, i1); if (retSocket instanceof SSLSocket) { establishHandshake((SSLSocket) retSocket, targetListener); } return retSocket; } public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress1, int i1) throws IOException { Socket retSocket = targetFactory.createSocket(inetAddress, i, inetAddress1, i1); if (retSocket instanceof SSLSocket) { establishHandshake((SSLSocket) retSocket, targetListener); } return retSocket; } private void establishHandshake(SSLSocket sslSocket, HandshakeCompletedListener listener) throws IOException { HandshakeRepeater repeater = new HandshakeRepeater(listener); sslSocket.addHandshakeCompletedListener(repeater); sslSocket.getSession(); repeater.waitForHandshake(); } }././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/HTTPMetadataConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/http/HTTPMetadataConstan0000644000175000017500000000653011245307607033353 0ustar twernertwerner/* * 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.remoting.transport.http; /** * There is some metadata that can be expected to be found in the * metadata passed to the server invoker handlers for http transports. * This class contains the constants for the keys to these values. * * @author Tom Elrod */ public class HTTPMetadataConstants { public static final String METHODTYPE = "MethodType"; public static final String PATH = "Path"; public static final String QUERY = "Query"; public static final String HTTPVERSION = "HttpVersion"; public static final String RESPONSE_CODE = "ResponseCode"; public static final String CONTENTTYPE = "Content-Type"; public static final String RESPONSE_CODE_MESSAGE = "ResponseCodeMessage"; public static final String REMOTING_VERSION_HEADER = "JBoss-Remoting-Version"; public static final String REMOTING_USER_AGENT = "User-Agent"; public static final String REMOTING_LEASE_QUERY = "JBoss-Remoting-Lease-Query"; // for some reason, if using servlet invoker, the header name is all lower case (at least w/ JBoss/Tomcat) public static final String REMOTING_LEASE_QUERY_LOWER_CASE = "jboss-remoting-lease-query"; /** * Key used for returning the value of java.net.URLConnection.getHeaderFields() * in the metadata map passed to org.jboss.remoting.Client.invoke(). */ public static final String RESPONSE_HEADERS = "ResponseHeaders"; /** * Configuration key for indicating if http client invoker should * throw exception on error from server or just return the error * as the response. */ public static final String NO_THROW_ON_ERROR = "NoThrowOnError"; /** * Configuration key for indicating that servlet invoker should return actual exception * thrown by invocation handler. */ public static final String DONT_RETURN_EXCEPTION = "dont-return-exception"; /** Used to distinguish special case of payload of type String. */ public static final String REMOTING_CONTENT_TYPE = "remotingContentType"; public static final String REMOTING_CONTENT_TYPE_LC = "remotingcontenttype"; public static final String REMOTING_CONTENT_TYPE_STRING = "remotingContentTypeString"; public static final String REMOTING_CONTENT_TYPE_NON_STRING = "remotingContentTypeNonString"; public static final String USE_REMOTING_CONTENT_TYPE = "useRemotingContentType"; }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/0000755000175000017500000000000011632407050027762 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/LocalClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/LocalClientInvoker0000644000175000017500000002126211000007412033422 0ustar twernertwerner/* * 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.remoting.transport.local; import org.jboss.remoting.AbstractInvoker; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.transport.BidirectionalClientInvoker; import org.jboss.remoting.util.SecurityUtility; import org.jboss.logging.Logger; import java.io.IOException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Map; /** * LocalClientInvoker does not use any transport protocol for invoking * the ServerInvoker, instead will make call directly on it locally. * This increases performance since no serialization required as well * as needed for push callbacks where InvokerCallbackHandler is in * same JVM as the callback server. * * @author Tom Elrod * @version $Revision: 3956 $ */ public class LocalClientInvoker extends AbstractInvoker implements BidirectionalClientInvoker { private static final Logger log = Logger.getLogger(LocalClientInvoker.class); private ServerInvoker serverInvoker; private boolean isConnected = false; private boolean byValue = false; public LocalClientInvoker(InvokerLocator locator) { super(locator); } public LocalClientInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public LocalClientInvoker(InvokerLocator locator, Map configuration, boolean byValue) { super(locator, configuration); this.byValue = byValue; } /** * transport a request against a remote ServerInvoker * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { if(log.isTraceEnabled()) { log.trace("Using local client invoker for invocation."); } InvocationRequest localInvocation = invocation; if(byValue) { localInvocation = marshallInvocation(localInvocation); } Object ret = null; if(serverInvoker != null) { try { ret = serverInvoker.invoke(localInvocation); } catch (ServerInvoker.InvalidStateException invalidStateEx) { if(log.isTraceEnabled()) { log.trace("Error calling on " + serverInvoker + " because is in invalid state. Will retry with new server invoker."); } ServerInvoker newServerInvoker = null; // try to get new server invoker if one exists ServerInvoker[] invokers = InvokerRegistry.getServerInvokers(); if(invokers != null) { for(int x = 0; x < invokers.length; x++) { ServerInvoker svrinvoker = invokers[x]; InvokerLocator svrlocator = svrinvoker.getLocator(); if(getLocator().equals(svrlocator)) { newServerInvoker = svrinvoker; break; } } } // if new server invoker found, try invocation call again if(newServerInvoker != null) { serverInvoker = newServerInvoker; ret = serverInvoker.invoke(localInvocation); } else { throw invalidStateEx; } } } else { throw new ConnectionFailedException("Error invoking on server because " + "no local server to call upon."); } return ret; } protected InvocationRequest marshallInvocation(InvocationRequest localInvocation) throws IOException, ClassNotFoundException { final Object param = localInvocation.getParameter(); Object newParam = null; String serializationType = getSerializationType(); final SerializationManager manager = SerializationStreamFactory.getManagerInstance(serializationType); if (serializationType.indexOf("jboss") < 0 || SecurityUtility.skipAccessControl()) { newParam = manager.createMarshalledValueForClone(param).get(); } else { try { newParam = AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return manager.createMarshalledValueForClone(param).get(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } localInvocation.setParameter(newParam); return localInvocation; } /** * subclasses must provide this method to return true if their remote connection is connected and * false if disconnected. in some transports, such as SOAP, this method may always return true, since the * remote connectivity is done on demand and not kept persistent like other transports (such as socket-based * transport). * * @return boolean true if connected, false if not */ public boolean isConnected() { return isConnected; } /** * connect to the remote invoker * * @throws ConnectionFailedException */ public void connect() throws ConnectionFailedException { isConnected = true; } /** * disconnect from the remote invoker. Once disconnect called * will not be able to re-connect by calling connect since will * loose reference to server invoker. */ public void disconnect() { isConnected = false; } public void setMarshaller(Marshaller marshaller) { // No op since is local, do not need marshaller } public Marshaller getMarshaller() { return null; } public void setUnMarshaller(UnMarshaller unmarshaller) { // No op since is local, do not need unmarshaller } public UnMarshaller getUnMarshaller() { return null; } public void establishLease(String sessionID, Map configuration, long leasePeriod) throws Throwable { // noop since is local } public void terminateLease(String sessionId, int disconnectTimeout) { // noop since is local } public long getLeasePeriod(String sessionID) { return -1; // no lease, since is local } /** * This will set the local reference to the server invoker. * This is needed to so can make calls directly against server. * * @param svrInvoker */ public void setServerInvoker(ServerInvoker svrInvoker) { this.serverInvoker = svrInvoker; } public InvokerLocator getCallbackLocator(Map metadata) { String transport = (String) metadata.get(Client.CALLBACK_SERVER_PROTOCOL); String host = (String) metadata.get(Client.CALLBACK_SERVER_HOST); String sPort = (String) metadata.get(Client.CALLBACK_SERVER_PORT); int port = -1; if (sPort != null) { try { port = Integer.parseInt(sPort); } catch (NumberFormatException e) { throw new RuntimeException("Can not set internal callback server port as configuration value (" + sPort + " is not a number."); } } return new InvokerLocator(transport, host, port, "callback", metadata); } } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/LocalServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/LocalServerInvoker0000644000175000017500000000337310547473106033503 0ustar twernertwerner/* * 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.remoting.transport.local; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import java.util.Map; import java.io.IOException; /** * @author Tom Elrod */ public class LocalServerInvoker extends ServerInvoker { public LocalServerInvoker(InvokerLocator locator, Map config) { super(locator, config); } protected String getDefaultDataType() { return SerializableMarshaller.DATATYPE; } public boolean isTransportBiDirectional() { return false; } protected int assignPort() throws IOException { // no port needed, so can just return any hard-code value return 5; } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/TransportClientFac0000644000175000017500000000310010547473106033455 0ustar twernertwerner/* * 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.remoting.transport.local; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new LocalClientInvoker(locator, config); } public boolean supportsSSL() { return false; } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/local/TransportServerFac0000644000175000017500000000277710547473106033530 0ustar twernertwerner/* * 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.remoting.transport.local; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new LocalServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/0000755000175000017500000000000011632407051030474 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/Bisocket.java0000644000175000017500000000620010742614000033073 0ustar twernertwerner/* * 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.remoting.transport.bisocket; /** * @author Ron Sigal * @version $Revision: 3259 $ *

          * Copyright Nov 22, 2006 *

          */ public class Bisocket { public static final String GET_SECONDARY_INVOKER_LOCATOR = "getSecondaryInvokerLocator"; public static final String IS_CALLBACK_SERVER = "isCallbackServer"; public static final byte PING = 1; public static final byte CREATE_CONTROL_SOCKET = 2; public static final byte RECREATE_CONTROL_SOCKET = 3; public static final byte CREATE_ORDINARY_SOCKET = 4; /** * Configuration key and default value for frequency with which pings are sent * on a control connection. */ public static final String PING_FREQUENCY = "pingFrequency"; public static final int PING_FREQUENCY_DEFAULT = 5000; /** * Configuration key and default value for window within which a ping on a * control connection must be receeived for the connection to be considered * alive. */ public static final String PING_WINDOW_FACTOR = "pingWindowFactor"; public static final int PING_WINDOW_FACTOR_DEFAULT = 2; /** * Configuration key and default value for number of retries * BisocketServerInvoker.ControlConnectionThread and * BisocketServerInvoker.createControlConnection should attempt while creating * sockets. */ public static final String MAX_RETRIES = "maxRetries"; public static final int MAX_RETRIES_DEFAULT = 10; /** * Configuration key and default value for number of times a control connection * will be restarted. */ public static final String MAX_CONTROL_CONNECTION_RESTARTS = "maxControlConnectionRestarts"; public static final int MAX_CONTROL_CONNECTION_RESTARTS_DEFAULT = 10; /** * Configuration keys for secondary ServerSocket. */ public static final String SECONDARY_BIND_PORT = "secondaryBindPort"; public static final String SECONDARY_CONNECT_PORT = "secondaryConnectPort"; public static final String SECONDARY_BIND_PORTS = "secondaryBindPorts"; public static final String SECONDARY_CONNECT_PORTS = "secondaryConnectPorts"; } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/BisocketClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/BisocketClientI0000644000175000017500000005744611241350273033451 0ustar twernertwerner/* * 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.remoting.transport.bisocket; import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Method; import java.net.Socket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Collections; 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 java.util.Timer; import java.util.TimerTask; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.invocation.InternalInvocation; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.transport.BidirectionalClientInvoker; import org.jboss.remoting.transport.socket.SocketClientInvoker; import org.jboss.remoting.transport.socket.SocketWrapper; import org.jboss.remoting.util.SecurityUtility; import EDU.oswego.cs.dl.util.concurrent.Semaphore; /** * The bisocket transport, an extension of the socket transport, is designed to allow * a callback server to function behind a firewall. All connections are created by * a Socket constructor or factory on the client side connecting to a ServerSocket on * the server side. When a callback client invoker on the server side needs to * open a connection to the callback server, it requests a connection by sending a * request message over a control connection to the client side. * * Because all connections are created in one direction, the bisocket transport is * asymmetric, in the sense that client invokers and server invokers behave differently * on the client side and on the server side. * * * * @author Ron Sigal */ public class BisocketClientInvoker extends SocketClientInvoker implements BidirectionalClientInvoker { private static final Logger log = Logger.getLogger(BisocketClientInvoker.class); private static Map listenerIdToClientInvokerMap = Collections.synchronizedMap(new HashMap()); private static Map listenerIdToCallbackClientInvokerMap = Collections.synchronizedMap(new HashMap()); private static Map listenerIdToSocketsMap = new HashMap(); private static Map listenerIdToControlSocketsMap = new HashMap(); private static Timer timer; private static Object timerLock = new Object(); protected String listenerId; private int pingFrequency = Bisocket.PING_FREQUENCY_DEFAULT; private int pingWindowFactor = Bisocket.PING_WINDOW_FACTOR_DEFAULT; private int pingWindow = pingWindowFactor * pingFrequency; private int maxRetries = Bisocket.MAX_RETRIES_DEFAULT; private Socket controlSocket; private OutputStream controlOutputStream; private Object controlLock = new Object(); private PingTimerTask pingTimerTask; protected boolean isCallbackInvoker; protected BooleanHolder pingFailed = new BooleanHolder(false); /** * @param listenerId * @return */ static BisocketClientInvoker getBisocketClientInvoker(String listenerId) { return (BisocketClientInvoker) listenerIdToClientInvokerMap.get(listenerId); } static BisocketClientInvoker getBisocketCallbackClientInvoker(String listenerId) { return (BisocketClientInvoker) listenerIdToCallbackClientInvokerMap.get(listenerId); } static void removeBisocketClientInvoker(String listenerId) { listenerIdToClientInvokerMap.remove(listenerId); } static void transferSocket(String listenerId, Socket socket, boolean isControlSocket) { Set sockets = null; if (isControlSocket) { synchronized (listenerIdToControlSocketsMap) { sockets = (Set) listenerIdToControlSocketsMap.get(listenerId); if (sockets == null) { sockets = new HashSet(); listenerIdToControlSocketsMap.put(listenerId, sockets); } } } else { synchronized (listenerIdToSocketsMap) { sockets = (Set) listenerIdToSocketsMap.get(listenerId); if (sockets == null) { sockets = new HashSet(); listenerIdToSocketsMap.put(listenerId, sockets); } } } synchronized (sockets) { sockets.add(socket); sockets.notify(); } } public BisocketClientInvoker(InvokerLocator locator) throws IOException { this(locator, null); } public BisocketClientInvoker(InvokerLocator locator, Map config) throws IOException { super(locator, config); if (configuration != null) { listenerId = (String) configuration.get(Client.LISTENER_ID_KEY); if (listenerId != null) { isCallbackInvoker = true; listenerIdToCallbackClientInvokerMap.put(listenerId, this); log.debug(this + " :registered " + listenerId + " -> " + this); } // look for pingFrequency param Object val = configuration.get(Bisocket.PING_FREQUENCY); if (val != null) { try { int nVal = Integer.valueOf((String) val).intValue(); pingFrequency = nVal; log.debug("Setting ping frequency to: " + pingFrequency); } catch (Exception e) { log.warn("Could not convert " + Bisocket.PING_FREQUENCY + " value of " + val + " to an int value."); } } val = configuration.get(Bisocket.PING_WINDOW_FACTOR); if (val != null && val instanceof String && ((String) val).length() > 0) { try { pingWindowFactor = Integer.valueOf(((String) val)).intValue(); log.debug(this + " setting pingWindowFactor to " + pingWindowFactor); } catch (NumberFormatException e) { log.warn("Invalid format for " + "\"" + Bisocket.PING_WINDOW_FACTOR + "\": " + val); } } else if (val != null) { log.warn("\"" + Bisocket.PING_WINDOW_FACTOR + "\" must be specified as a String"); } pingWindow = pingWindowFactor * pingFrequency; val = configuration.get(Bisocket.MAX_RETRIES); if (val != null) { try { int nVal = Integer.valueOf((String) val).intValue(); maxRetries = nVal; log.debug("Setting retry limit: " + maxRetries); } catch (Exception e) { log.warn("Could not convert " + Bisocket.MAX_RETRIES + " value of " + val + " to an int value."); } } } } public int getMaxRetries() { return maxRetries; } public void setMaxRetries(int maxRetries) { this.maxRetries = maxRetries; } public int getPingFrequency() { return pingFrequency; } public void setPingFrequency(int pingFrequency) { this.pingFrequency = pingFrequency; } public int getPingWindowFactor() { return pingWindowFactor; } public void setPingWindowFactor(int pingWindowFactor) { this.pingWindowFactor = pingWindowFactor; pingWindow = pingWindowFactor * pingFrequency; } protected void handleConnect() throws ConnectionFailedException { // Callback client on server side. if (isCallbackInvoker) { Set sockets = null; synchronized (listenerIdToControlSocketsMap) { sockets = (Set) listenerIdToControlSocketsMap.get(listenerId); if (sockets == null) { sockets = new HashSet(); listenerIdToControlSocketsMap.put(listenerId, sockets); } } synchronized (sockets) { if (sockets.isEmpty()) { long wait = timeout; long start = System.currentTimeMillis(); while (timeout == 0 || wait > 0) { try { sockets.wait(wait); break; } catch (InterruptedException e) { log.debug("unexpected interrupt"); if (timeout > 0) wait = timeout - (System.currentTimeMillis() - start); } } } if (sockets.isEmpty()) throw new ConnectionFailedException("Timed out trying to create control socket"); Iterator it = sockets.iterator(); controlSocket = (Socket) it.next(); it.remove(); try { controlOutputStream = controlSocket.getOutputStream(); } catch (IOException e1) { throw new ConnectionFailedException("Unable to get control socket output stream"); } log.debug("got control socket( " + listenerId + "): " + controlSocket); if (pingFrequency > 0) { pingTimerTask = new PingTimerTask(this); synchronized (timerLock) { if (timer == null) { timer = new Timer(true); } try { timer.schedule(pingTimerTask, pingFrequency, pingFrequency); } catch (IllegalStateException e) { log.debug("Unable to schedule TimerTask on existing Timer", e); timer = new Timer(true); timer.schedule(pingTimerTask, pingFrequency, pingFrequency); } } } } // Bisocket callback client invoker doesn't share socket pools because of the danger // that two distinct callback servers could have the same "artifical" port. pool = new LinkedList(); log.debug("Creating semaphore with size " + maxPoolSize); semaphore = new Semaphore(maxPoolSize); return; } // Client on client side. super.handleConnect(); } protected void handleDisconnect() { if (listenerId != null) { if (isCallbackInvoker) { if (controlSocket != null) { try { controlSocket.close(); } catch (IOException e) { log.debug("unable to close control socket: " + controlSocket); } } listenerIdToCallbackClientInvokerMap.remove(listenerId); for (Iterator it = pool.iterator(); it.hasNext();) { SocketWrapper socketWrapper = (SocketWrapper) it.next(); try { socketWrapper.close(); } catch (Exception ignored) { } } } else { listenerIdToClientInvokerMap.remove(listenerId); super.handleDisconnect(); } synchronized (listenerIdToControlSocketsMap) { listenerIdToControlSocketsMap.remove(listenerId); } Set sockets = null; synchronized (listenerIdToSocketsMap) { sockets = (Set) listenerIdToSocketsMap.remove(listenerId); } // Wake up any threads blocked in createSocket(). if (sockets != null) { synchronized (sockets) { sockets.notifyAll(); } } if (pingTimerTask != null) pingTimerTask.shutDown(); } else { super.handleDisconnect(); } } protected Object transport(String sessionId, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller) throws IOException, ConnectionFailedException, ClassNotFoundException { String listenerId = null; if (invocation instanceof InvocationRequest) { InvocationRequest ir = (InvocationRequest) invocation; Object o = ir.getParameter(); if (o instanceof InternalInvocation) { InternalInvocation ii = (InternalInvocation) o; if (InternalInvocation.ADDLISTENER.equals(ii.getMethodName()) && ir.getLocator() != null) // getLocator() == null for pull callbacks { Map requestPayload = ir.getRequestPayload(); listenerId = (String) requestPayload.get(Client.LISTENER_ID_KEY); listenerIdToClientInvokerMap.put(listenerId, this); BisocketServerInvoker callbackServerInvoker; callbackServerInvoker = BisocketServerInvoker.getBisocketServerInvoker(listenerId); callbackServerInvoker.createControlConnection(listenerId, true); } // Rather than handle the REMOVELISTENER case symmetrically, it is // handled when a REMOVECLIENTLISTENER message is received by // BisocketServerInvoker.handleInternalInvocation(). The reason is that // if the Client executes removeListener() with disconnectTimeout == 0, // no REMOVELISTENER message will be sent. } } return super.transport(sessionId, invocation, metadata, marshaller, unmarshaller); } protected Socket createSocket(String address, int port, int timeout) throws IOException { if (!isCallbackInvoker) return super.createSocket(address, port, timeout); if (timeout < 0) { timeout = getTimeout(); if (timeout < 0) timeout = 0; } Set sockets = null; synchronized (listenerIdToSocketsMap) { sockets = (Set) listenerIdToSocketsMap.get(listenerId); if (sockets == null) { sockets = new HashSet(); listenerIdToSocketsMap.put(listenerId, sockets); } } synchronized (controlLock) { if (log.isTraceEnabled()) log.trace(this + " writing Bisocket.CREATE_ORDINARY_SOCKET on " + controlOutputStream); try { controlOutputStream.write(Bisocket.CREATE_ORDINARY_SOCKET); if (log.isTraceEnabled()) log.trace(this + " wrote Bisocket.CREATE_ORDINARY_SOCKET"); synchronized (sockets) { if (!sockets.isEmpty()) { Iterator it = sockets.iterator(); Socket socket = (Socket) it.next(); it.remove(); log.debug(this + " found socket (" + listenerId + "): " + socket); return socket; } } } catch (IOException e) { log.debug(this + " unable to write Bisocket.CREATE_ORDINARY_SOCKET", e); } } long timeRemaining = timeout; long pingFailedWindow = 2 * pingWindow; long pingFailedTimeRemaining = pingFailedWindow; long start = System.currentTimeMillis(); OutputStream savedControlOutputStream = controlOutputStream; while (isConnected() && (!pingFailed.flag || pingFailedTimeRemaining > 0) && (timeout == 0 || timeRemaining > 0)) { synchronized (sockets) { try { sockets.wait(1000); } catch (InterruptedException e) { log.debug(this + " unexpected interrupt"); } if (!sockets.isEmpty()) { Iterator it = sockets.iterator(); Socket socket = (Socket) it.next(); it.remove(); log.debug(this + " found socket (" + listenerId + "): " + socket); return socket; } } if (savedControlOutputStream != controlOutputStream) { savedControlOutputStream = controlOutputStream; log.debug(this + " rewriting Bisocket.CREATE_ORDINARY_SOCKET on " + controlOutputStream); try { controlOutputStream.write(Bisocket.CREATE_ORDINARY_SOCKET); log.debug(this + " rewrote Bisocket.CREATE_ORDINARY_SOCKET"); } catch (IOException e) { log.debug(this + " unable to rewrite Bisocket.CREATE_ORDINARY_SOCKET" + e.getMessage()); } } long elapsed = System.currentTimeMillis() - start; if (timeout > 0) timeRemaining = timeout - elapsed; pingFailedTimeRemaining = pingFailedWindow - elapsed; } if (!isConnected()) { throw new IOException("Connection is closed"); } if (pingFailed.flag) { throw new IOException("Unable to create socket"); } throw new IOException("Timed out trying to create socket"); } void replaceControlSocket(Socket socket) throws IOException { synchronized (controlLock) { if (controlSocket != null) { controlSocket.close(); } log.debug(this + " replacing control socket: " + controlSocket); controlSocket = socket; log.debug(this + " control socket replaced by: " + socket); controlOutputStream = controlSocket.getOutputStream(); log.debug("controlOutputStream replaced by: " + controlOutputStream); } if (pingTimerTask != null) pingTimerTask.cancel(); if (pingFrequency > 0) { pingTimerTask = new PingTimerTask(this); synchronized (timerLock) { if (timer == null) { timer = new Timer(true); } try { timer.schedule(pingTimerTask, pingFrequency, pingFrequency); } catch (IllegalStateException e) { log.debug("Unable to schedule TimerTask on existing Timer", e); timer = new Timer(true); timer.schedule(pingTimerTask, pingFrequency, pingFrequency); } } } } InvokerLocator getSecondaryLocator() throws Throwable { InternalInvocation ii = new InternalInvocation(Bisocket.GET_SECONDARY_INVOKER_LOCATOR, null); InvocationRequest r = new InvocationRequest(null, null, ii, null, null, null); log.debug("getting secondary locator"); Exception savedException = null; for (int i = 0; i < maxRetries; i++) { try { Object o = invoke(r); log.debug("secondary locator: " + o); return (InvokerLocator) o; } catch (Exception e) { savedException = e; log.debug("unable to get secondary locator: trying again"); } } throw savedException; } public InvokerLocator getCallbackLocator(Map metadata) { String transport = (String) metadata.get(Client.CALLBACK_SERVER_PROTOCOL); String host = (String) metadata.get(Client.CALLBACK_SERVER_HOST); String sPort = (String) metadata.get(Client.CALLBACK_SERVER_PORT); int port = -1; if (sPort != null) { try { port = Integer.parseInt(sPort); } catch (NumberFormatException e) { throw new RuntimeException("Can not set internal callback server port as configuration value (" + sPort + " is not a number."); } } return new InvokerLocator(transport, host, port, "callback", metadata); } static class PingTimerTask extends TimerTask { private Object controlLock; private OutputStream controlOutputStream; private int maxRetries; private Exception savedException; private boolean running = true; private boolean pingSent; private BooleanHolder pingFailed; PingTimerTask(BisocketClientInvoker invoker) { controlLock = invoker.controlLock; controlOutputStream = invoker.controlOutputStream; maxRetries = invoker.getMaxRetries(); pingFailed = invoker.pingFailed; pingFailed.flag = false; } public void shutDown() { synchronized (controlLock) { controlOutputStream = null; } cancel(); try { Method purge = getDeclaredMethod(Timer.class, "purge", new Class[]{}); purge.invoke(timer, new Object[]{}); } catch (Exception e) { log.debug("running with jdk 1.4: unable to purge Timer"); } } public void run() { pingSent = false; for (int i = 0; i < maxRetries; i++) { try { synchronized (controlLock) { if (!running) return; controlOutputStream.write(Bisocket.PING); } pingSent = true; break; } catch (Exception e) { savedException = e; log.debug("Unable to send ping: trying again"); } } if (!running) return; if (!pingSent) { log.warn("Unable to send ping: shutting down PingTimerTask", savedException); pingFailed.flag = true; shutDown(); } } } static class BooleanHolder { public boolean flag; public BooleanHolder(boolean flag) { this.flag = flag; } } static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/TransportClient0000644000175000017500000000321710540121373033552 0ustar twernertwerner/* * 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.remoting.transport.bisocket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * * @author Ron Sigal * @version $Revision: 1681 $ *

          * Copyright Nov 25, 2006 *

          */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new BisocketClientInvoker(locator, config); } public boolean supportsSSL() { return false; } }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/TransportServer0000644000175000017500000000115410540121373033600 0ustar twernertwernerpackage org.jboss.remoting.transport.bisocket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.util.Map; /** * * @author Ron Sigal * @version $Revision: 1681 $ *

          * Copyright Nov 25, 2006 *

          */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new BisocketServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/bisocket/BisocketServerI0000644000175000017500000012475211311045105033465 0ustar twernertwerner/* * 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.remoting.transport.bisocket; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.Method; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import java.util.Timer; import java.util.TimerTask; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.Home; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.ServerInvocationHandler; import org.jboss.remoting.invocation.InternalInvocation; import org.jboss.remoting.socketfactory.CreationListenerServerSocket; import org.jboss.remoting.socketfactory.CreationListenerSocketFactory; import org.jboss.remoting.socketfactory.SocketCreationListener; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.socket.LRUPool; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.util.SecurityUtility; /** * * @author Ron Sigal * @version $Revision: 5605 $ *

          * Copyright Nov 23, 2006 *

          */ public class BisocketServerInvoker extends SocketServerInvoker { private static final Logger log = Logger.getLogger(BisocketServerInvoker.class); private static Map listenerIdToServerInvokerMap = Collections.synchronizedMap(new HashMap()); private static Timer timer; private static Object timerLock = new Object(); private Map listenerIdToInvokerLocatorMap = Collections.synchronizedMap(new HashMap()); private Set secondaryServerSockets = new HashSet(); private InvokerLocator secondaryLocator; private Set secondaryServerSocketThreads = new HashSet(); private Map controlConnectionThreadMap = new HashMap(); private Map controlConnectionRestartsMap = Collections.synchronizedMap(new HashMap()); private int pingFrequency = Bisocket.PING_FREQUENCY_DEFAULT; private int pingWindowFactor = Bisocket.PING_WINDOW_FACTOR_DEFAULT; private int pingWindow = pingWindowFactor * pingFrequency; private int socketCreationRetries = Bisocket.MAX_RETRIES_DEFAULT; private int controlConnectionRestarts = Bisocket.MAX_CONTROL_CONNECTION_RESTARTS_DEFAULT; private ControlMonitorTimerTask controlMonitorTimerTask; protected boolean isCallbackServer = false; protected List secondaryBindPorts = new ArrayList(); protected List secondaryConnectPorts = new ArrayList(); public static BisocketServerInvoker getBisocketServerInvoker(String listenerId) { return (BisocketServerInvoker) listenerIdToServerInvokerMap.get(listenerId); } public BisocketServerInvoker(InvokerLocator locator) { super(locator); } public BisocketServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public void start() throws IOException { if (isCallbackServer) { Object val = configuration.get(Bisocket.MAX_RETRIES); if (val != null) { try { int nVal = Integer.valueOf((String) val).intValue(); socketCreationRetries = nVal; log.debug("Setting socket creation retry limit: " + socketCreationRetries); } catch (Exception e) { log.warn("Could not convert " + Bisocket.MAX_RETRIES + " value of " + val + " to an int value."); } } val = configuration.get(Bisocket.MAX_CONTROL_CONNECTION_RESTARTS); if (val != null) { try { int nVal = Integer.valueOf((String) val).intValue(); controlConnectionRestarts = nVal; log.debug("Setting control connection restart limit: " + controlConnectionRestarts); } catch (Exception e) { log.warn("Could not convert " + Bisocket.MAX_CONTROL_CONNECTION_RESTARTS + " value of " + val + " to an int value."); } } if(maxPoolSize <= 0) { maxPoolSize = MAX_POOL_SIZE_DEFAULT; } clientpool = new LRUPool(2, maxPoolSize); clientpool.create(); threadpool = new LinkedList(); checkSocketFactoryWrapper(); if (pingFrequency > 0) { controlMonitorTimerTask = new ControlMonitorTimerTask(this); synchronized (timerLock) { if (timer == null) { timer = new Timer(true); } try { timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency); } catch (IllegalStateException e) { log.debug("Unable to schedule TimerTask on existing Timer", e); timer = new Timer(true); timer.schedule(controlMonitorTimerTask, pingFrequency, pingFrequency); } } } running = true; started = true; } else { super.start(); if (serverSockets.size() < secondaryBindPorts.size()) log.warn(this + " extra secondary bind ports will be ignored"); else if (serverSockets.size() > secondaryBindPorts.size()) log.warn(this + " not enough secondary bind ports: will use anonymous ports as necessary"); if (secondaryConnectPorts.size() == 0) { secondaryConnectPorts = secondaryBindPorts; } else if(secondaryConnectPorts.size() != secondaryBindPorts.size()) { log.warn(this + " number of secondary connect ports != number of secondary bind ports"); log.warn(this + " will ignore secondary connect ports"); secondaryConnectPorts = secondaryBindPorts; } int i = 0; Iterator it = serverSockets.iterator(); while (it.hasNext()) { ServerSocket ss = (ServerSocket) it.next(); final InetAddress host = ss.getInetAddress(); int secondaryBindPort = -1; if (secondaryBindPorts.size() > i) { secondaryBindPort = ((Integer) secondaryBindPorts.get(i)).intValue(); } else { secondaryBindPorts.add(new Integer(-1)); } if (secondaryBindPort < 0) { secondaryBindPort = PortUtil.findFreePort(host.getHostAddress()); secondaryBindPorts.set(i, new Integer(secondaryBindPort)); } ServerSocket secondaryServerSocket = null; final int finalBindPort = secondaryBindPort; try { secondaryServerSocket = (ServerSocket) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { ServerSocket ss = null; if (serverSocketFactory != null) { ss = serverSocketFactory.createServerSocket(finalBindPort, 0, host); } else { ss = new ServerSocket(finalBindPort, 0, host); } return ss; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } ss = checkSecondaryServerSocketWrapper(secondaryServerSocket); secondaryServerSockets.add(ss); log.debug(this + " created secondary " + ss); i++; } i = 0; it = secondaryServerSockets.iterator(); while (it.hasNext()) { ServerSocket secondaryServerSocket = (ServerSocket) it.next(); Thread t = new SecondaryServerSocketThread(secondaryServerSocket); t.setName("secondaryServerSocketThread[" + i++ + "]"); t.setDaemon(true); t.start(); secondaryServerSocketThreads.add(t); log.debug(this + " created " + t); } if (getLocator().isMultihome()) { int j = 0; String host = ((Home) connectHomes.get(j)).host; int port = ((Integer) secondaryConnectPorts.get(j)).intValue(); if (port < 0) port = ((Integer) secondaryBindPorts.get(j)).intValue(); StringBuffer sb = new StringBuffer(host).append(':').append(port); for (j = 1; j < connectHomes.size(); j++) { host = ((Home) connectHomes.get(j)).host; port = ((Integer) secondaryConnectPorts.get(j)).intValue(); if (port < 0) port = ((Integer) secondaryBindPorts.get(j)).intValue(); sb.append('!').append(host).append(':').append(port); } Map params = new HashMap(); params.put(InvokerLocator.HOMES_KEY, sb.toString()); secondaryLocator = new InvokerLocator(null, InvokerLocator.MULTIHOME, -1, null, params); } else { String connectAddress = getLocator().getHost(); int connectPort = ((Integer) secondaryConnectPorts.get(0)).intValue(); if (connectPort < 0) connectPort = ((Integer) secondaryBindPorts.get(0)).intValue(); secondaryLocator = new InvokerLocator(null, connectAddress, connectPort, null, null); } log.debug(this + " created secondary InvokerLocator: " + secondaryLocator); } } public boolean isTransportBiDirectional() { return true; } public void createControlConnection(String listenerId, boolean firstConnection) throws IOException { BisocketClientInvoker clientInvoker = BisocketClientInvoker.getBisocketClientInvoker(listenerId); if (clientInvoker == null) { log.debug("Unable to retrieve client invoker: must have disconnected"); throw new ClientUnavailableException(); } InvokerLocator oldLocator = (InvokerLocator) listenerIdToInvokerLocatorMap.get(listenerId); InvokerLocator newLocator = null; try { newLocator = clientInvoker.getSecondaryLocator(); } catch (Throwable t) { log.debug("unable to get secondary locator", t); throw new IOException("unable to get secondary locator: " + t.getMessage()); } // If a server restarts, it is likely that it creates a new secondary server socket on // a different port. It will possible to recreate the control connection, but if // there is no PingTimerTask running in the new server to keep it alive, it will just // die again. Once a new secondary server socket address is detected, a count is kept // of the number of times the control connection is restarted, and when it hits a // configured maximum, it is allowed to die. See JBREM-731. boolean locatorChanged = !newLocator.equals(oldLocator); listenerIdToInvokerLocatorMap.put(listenerId, newLocator); String host = newLocator.getHost(); int port = newLocator.getPort(); if (newLocator.isMultihome()) { host = clientInvoker.getHomeInUse().host; port = -1; Iterator it = null; if (newLocator.getConnectHomeList().isEmpty()) it = newLocator.getHomeList().iterator(); else it = newLocator.getConnectHomeList().iterator(); while (it.hasNext()) { Home h = (Home) it.next(); if (host.equals(h.host)) { port = h.port; newLocator.setHomeInUse(h); break; } } } if (port == -1) { throw new IOException("Cannot find matching home for control connection"); } log.debug("creating control connection: " + newLocator); Socket socket = null; IOException savedException = null; final String finalHost = host; final int finalPort = port; for (int i = 0; i < socketCreationRetries; i++) { try { socket = (Socket) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { Socket s = null; if (socketFactory != null) s = socketFactory.createSocket(finalHost, finalPort); else s = new Socket(finalHost, finalPort); return s; } }); } catch (PrivilegedActionException e) { IOException ioe = (IOException) e.getCause(); log.debug("Error creating a control socket", ioe); savedException = ioe; } if (socket != null) break; try { Thread.sleep(1000); } catch (InterruptedException e) { log.debug("received interrupt"); } } if (socket == null) { log.debug("unable to create control connection after " + socketCreationRetries + " retries", savedException); throw savedException; } DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); if (firstConnection) { dos.write(Bisocket.CREATE_CONTROL_SOCKET); } else { dos.write(Bisocket.RECREATE_CONTROL_SOCKET); } dos.writeUTF(listenerId); Thread thread = new ControlConnectionThread(socket, listenerId); thread.setName("control: " + socket.toString()); thread.setDaemon(true); synchronized (controlConnectionThreadMap) { controlConnectionThreadMap.put(listenerId, thread); } Object o = controlConnectionRestartsMap.get(listenerId); if (o != null) { int restarts = ((Integer) o).intValue(); if (locatorChanged || restarts > 0) controlConnectionRestartsMap.put(listenerId, new Integer(++restarts)); } else { controlConnectionRestartsMap.put(listenerId, new Integer(0)); } thread.start(); log.debug(this + " created control connection (" + listenerId + "): " + socket.toString()); } public void destroyControlConnection(String listenerId) { Thread t = null; synchronized (controlConnectionThreadMap) { t = (Thread) controlConnectionThreadMap.remove(listenerId); } if (t != null) { ((ControlConnectionThread)t).shutdown(); log.debug(this + " shutting down control connection: " + listenerId); } else { log.debug("unrecognized listener ID: " + listenerId); } listenerIdToInvokerLocatorMap.remove(listenerId); controlConnectionRestartsMap.remove(listenerId); } public int getControlConnectionRestarts() { return controlConnectionRestarts; } public void setControlConnectionRestarts(int controlConnectionRestarts) { this.controlConnectionRestarts = controlConnectionRestarts; } public int getPingFrequency() { return pingFrequency; } public void setPingFrequency(int pingFrequency) { this.pingFrequency = pingFrequency; pingWindow = pingWindowFactor * pingFrequency; } public int getPingWindowFactor() { return pingWindowFactor; } public void setPingWindowFactor(int pingWindowFactor) { this.pingWindowFactor = pingWindowFactor; pingWindow = pingWindowFactor * pingFrequency; } public int getSecondaryBindPort() { if (secondaryBindPorts.size() == 0 || secondaryBindPorts.size() > 1) return -1; return ((Integer) secondaryBindPorts.get(0)).intValue(); } public void setSecondaryBindPort(int secondaryPort) { secondaryBindPorts.clear(); secondaryBindPorts.add(new Integer(secondaryPort)); } public List getSecondaryBindPorts() { return new ArrayList(secondaryBindPorts); } public void setSecondaryBindPorts(List secondaryBindPorts) { this.secondaryBindPorts = secondaryBindPorts; } public void setSecondaryBindPorts(String secondaryBindPortString) { StringTokenizer tok = new StringTokenizer(secondaryBindPortString, "!"); String token = null; while (tok.hasMoreTokens()) { try { token = tok.nextToken(); secondaryBindPorts.add(Integer.valueOf(token)); } catch (NumberFormatException e) { log.warn("Invalid format for " + "\"" + Bisocket.SECONDARY_BIND_PORT + "\": " + token); secondaryBindPorts.add(new Integer(-1)); } } } public int getSecondaryConnectPort() { if (secondaryConnectPorts.size() == 0 || secondaryConnectPorts.size() > 1) return -1; return ((Integer) secondaryConnectPorts.get(0)).intValue(); } public void setSecondaryConnectPort(int secondaryConnectPort) { secondaryConnectPorts.clear(); secondaryConnectPorts.add(new Integer(secondaryConnectPort)); } public List getSecondaryConnectPorts() { return new ArrayList(secondaryConnectPorts); } public void setSecondaryConnectPorts(List secondaryConnectPorts) { this.secondaryConnectPorts = secondaryConnectPorts; } public void setSecondaryConnectPorts(String secondaryConnectPortString) { StringTokenizer tok = new StringTokenizer(secondaryConnectPortString, "!"); String token = null; while (tok.hasMoreTokens()) { try { token = tok.nextToken(); secondaryConnectPorts.add(Integer.valueOf(token)); } catch (NumberFormatException e) { log.warn("Invalid format for " + "\"" + Bisocket.SECONDARY_CONNECT_PORT + "\": " + token); secondaryConnectPorts.add(new Integer(-1)); } } } public int getSocketCreationRetries() { return socketCreationRetries; } public void setSocketCreationRetries(int socketCreationRetries) { this.socketCreationRetries = socketCreationRetries; } protected void setup() throws Exception { Object o = configuration.get(Bisocket.IS_CALLBACK_SERVER); if (o != null) { if (o instanceof String) isCallbackServer = Boolean.valueOf((String) o).booleanValue(); else if (o instanceof Boolean) isCallbackServer = ((Boolean) o).booleanValue(); else log.error("unrecognized value for configuration key \"" + Bisocket.IS_CALLBACK_SERVER + "\": " + o); } super.setup(); o = configuration.get(Bisocket.PING_FREQUENCY); if (o instanceof String && ((String) o).length() > 0) { try { pingFrequency = Integer.valueOf(((String) o)).intValue(); log.debug(this + " setting pingFrequency to " + pingFrequency); } catch (NumberFormatException e) { log.warn("Invalid format for " + "\"" + Bisocket.PING_FREQUENCY + "\": " + o); } } else if (o != null) { log.warn("\"" + Bisocket.PING_FREQUENCY + "\" must be specified as a String"); } o = configuration.get(Bisocket.PING_WINDOW_FACTOR); if (o instanceof String && ((String) o).length() > 0) { try { pingWindowFactor = Integer.valueOf(((String) o)).intValue(); log.debug(this + " setting pingWindowFactor to " + pingWindowFactor); } catch (NumberFormatException e) { log.warn("Invalid format for " + "\"" + Bisocket.PING_WINDOW_FACTOR + "\": " + o); } } else if (o != null) { log.warn("\"" + Bisocket.PING_WINDOW_FACTOR + "\" must be specified as a String"); } pingWindow = pingWindowFactor * pingFrequency; o = configuration.get(Bisocket.SECONDARY_BIND_PORTS); if (o instanceof String && ((String) o).length() > 0) { setSecondaryBindPorts((String) o); } else if (o instanceof List) { setSecondaryBindPorts((List) o); } else if (o != null) { log.warn("\"" + Bisocket.SECONDARY_BIND_PORTS + "\" must be specified as a String or a List"); } o = configuration.get(Bisocket.SECONDARY_CONNECT_PORTS); if (o instanceof String && ((String) o).length() > 0) { setSecondaryConnectPorts((String) o); } else if (o instanceof List) { setSecondaryConnectPorts((List) o); } else if (o != null) { log.warn("\"" + Bisocket.SECONDARY_CONNECT_PORTS + "\" must be specified as a String or a List"); } if (secondaryBindPorts.isEmpty()) { for (int i = 0; i < homes.size(); i++) secondaryBindPorts.add(new Integer(-1)); } if (secondaryConnectPorts.isEmpty()) { secondaryConnectPorts = new ArrayList(secondaryBindPorts); } if (isCallbackServer) { socketFactory = createSocketFactory(configuration); } } protected void cleanup() { synchronized (controlConnectionThreadMap) { Iterator it = controlConnectionThreadMap.values().iterator(); while (it.hasNext()) { ControlConnectionThread t = (ControlConnectionThread) it.next(); it.remove(); t.shutdown(); } } super.cleanup(); if (controlMonitorTimerTask != null) controlMonitorTimerTask.shutdown(); Iterator it = secondaryServerSocketThreads.iterator(); while (it.hasNext()) { SecondaryServerSocketThread t = (SecondaryServerSocketThread) it.next(); t.shutdown(); } it = secondaryServerSockets.iterator(); while (it.hasNext()) { try { ServerSocket ss = (ServerSocket) it.next(); ss.close(); } catch (IOException e) { log.info("Error closing secondary server socket: " + e.getMessage()); } } secondaryBindPorts.clear(); secondaryConnectPorts.clear(); } protected InvokerLocator getSecondaryLocator() { return secondaryLocator; } protected void checkSocketFactoryWrapper() throws IOException { Object o = configuration.get(Remoting.SOCKET_CREATION_SERVER_LISTENER); if (o != null) { if (o instanceof SocketCreationListener) { SocketCreationListener listener = (SocketCreationListener) o; if (socketFactory instanceof CreationListenerSocketFactory) { CreationListenerSocketFactory clsf = (CreationListenerSocketFactory) socketFactory; clsf.setListener(listener); } else { socketFactory = new CreationListenerSocketFactory(socketFactory, listener); } } else { log.error("socket creation listener of invalid type: " + o); } } else { if (socketFactory instanceof CreationListenerSocketFactory) { CreationListenerSocketFactory clsf = (CreationListenerSocketFactory) socketFactory; socketFactory = clsf.getFactory(); } } } protected ServerSocket checkSecondaryServerSocketWrapper(ServerSocket secondaryServerSocket) throws IOException { Object o = configuration.get(Remoting.SOCKET_CREATION_CLIENT_LISTENER); if (o != null) { if (o instanceof SocketCreationListener) { SocketCreationListener listener = (SocketCreationListener) o; if (secondaryServerSocket instanceof CreationListenerServerSocket) { CreationListenerServerSocket clss = (CreationListenerServerSocket) secondaryServerSocket; clss.setListener(listener); } else { secondaryServerSocket = new CreationListenerServerSocket(secondaryServerSocket, listener); } } else { log.error("socket creation listener of invalid type: " + o); } } else { if (secondaryServerSocket instanceof CreationListenerServerSocket) { CreationListenerServerSocket clss = (CreationListenerServerSocket) secondaryServerSocket; secondaryServerSocket = clss.getServerSocket(); } } return secondaryServerSocket; } protected Object handleInternalInvocation(InternalInvocation ii, InvocationRequest ir, ServerInvocationHandler handler) throws Throwable { if(Bisocket.GET_SECONDARY_INVOKER_LOCATOR.equals(ii.getMethodName())) { return secondaryLocator; } Object response = super.handleInternalInvocation(ii, ir, handler); if(InternalInvocation.ADDCLIENTLISTENER.equals(ii.getMethodName())) { Map metadata = ir.getRequestPayload(); if(metadata != null) { String listenerId = (String) metadata.get(Client.LISTENER_ID_KEY); if (listenerId != null) { listenerIdToServerInvokerMap.put(listenerId, this); } } } else if(InternalInvocation.REMOVECLIENTLISTENER.equals(ii.getMethodName())) { Map metadata = ir.getRequestPayload(); if(metadata != null) { String listenerId = (String) metadata.get(Client.LISTENER_ID_KEY); if (listenerId != null) { listenerIdToServerInvokerMap.remove(listenerId); BisocketClientInvoker.removeBisocketClientInvoker(listenerId); destroyControlConnection(listenerId); } } } return response; } class ControlConnectionThread extends Thread { private static final int MAX_INITIAL_ATTEMPTS = 5; private Socket controlSocket; private String listenerId; private DataInputStream dis; private boolean running; private int errorCount; private long lastPing = -1; private int initialAttempts; ControlConnectionThread(Socket socket, String listenerId) throws IOException { controlSocket = socket; this.listenerId = listenerId; dis = new DataInputStream(socket.getInputStream()); } void shutdown() { running = false; try { controlSocket.close(); } catch (IOException e) { log.warn("unable to close controlSocket"); } interrupt(); } boolean checkConnection() { if (lastPing < 0 && initialAttempts++ < MAX_INITIAL_ATTEMPTS) { return true; } else if (lastPing < 0) { return false; } long currentTime = System.currentTimeMillis(); if (log.isTraceEnabled()) { log.trace("elapsed: " + (currentTime - lastPing)); } return (currentTime - lastPing <= pingWindow); } String getListenerId() { return listenerId; } public void run() { running = true; while (running) { Socket socket = null; try { int action = dis.read(); lastPing = System.currentTimeMillis(); switch (action) { case Bisocket.CREATE_ORDINARY_SOCKET: InvokerLocator locator = (InvokerLocator) listenerIdToInvokerLocatorMap.get(listenerId); IOException savedException = null; final String finalHost = locator.getHost(); final int finalPort = locator.getPort(); for (int i = 0; i < socketCreationRetries; i++) { try { socket = (Socket) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { Socket s = null; if (socketFactory != null) s = socketFactory.createSocket(finalHost, finalPort); else s = new Socket(finalHost, finalPort); return s; } }); } catch (PrivilegedActionException e) { IOException ioe = (IOException) e.getCause(); log.debug("Error creating a socket", ioe); savedException = ioe; } if (socket != null) break; try { Thread.sleep(1000); } catch (InterruptedException e) { if (running) { log.debug("received unexpected interrupt"); continue; } else { return; } } } if (socket == null) { log.error("Unable to create socket after " + socketCreationRetries + " retries", savedException); continue; } DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); dos.write(Bisocket.CREATE_ORDINARY_SOCKET); dos.writeUTF(listenerId); break; case Bisocket.PING: continue; case -1: shutdown(); return; default: log.error("unrecognized action on ControlConnectionThread (" + listenerId + "): " + action); continue; } } catch (IOException e) { if (running) { if ("Socket closed".equalsIgnoreCase(e.getMessage()) || "Socket is closed".equalsIgnoreCase(e.getMessage()) || "Connection reset".equalsIgnoreCase(e.getMessage())) { shutdown(); return; } log.error("Unable to process control connection: " + e.getMessage(), e); if (++errorCount > 5) { shutdown(); return; } continue; } return; } if (!running) { return; } try { processInvocation(socket); } catch (Exception e) { log.error("Unable to create new ServerThread: " + e.getMessage(), e); } } } } class SecondaryServerSocketThread extends Thread { private ServerSocket secondaryServerSocket; boolean running = true; SecondaryServerSocketThread(ServerSocket secondaryServerSocket) throws IOException { this.secondaryServerSocket = secondaryServerSocket; } void shutdown() { running = false; interrupt(); } public void run() { while (running) { try { Socket socket = null; try { socket = (Socket)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return secondaryServerSocket.accept(); } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } if (log.isTraceEnabled()) log.trace("accepted: " + socket); DataInputStream dis = new DataInputStream(socket.getInputStream()); int action = dis.read(); String listenerId = dis.readUTF(); switch (action) { case Bisocket.CREATE_CONTROL_SOCKET: BisocketClientInvoker.transferSocket(listenerId, socket, true); if (log.isTraceEnabled()) log.trace("SecondaryServerSocketThread: created control socket: (" + socket + ")"+ listenerId); break; case Bisocket.RECREATE_CONTROL_SOCKET: BisocketClientInvoker invoker = BisocketClientInvoker.getBisocketCallbackClientInvoker(listenerId); if (invoker == null) { log.debug("received new control socket for unrecognized listenerId: " + listenerId); } else { invoker.replaceControlSocket(socket); if (log.isTraceEnabled()) log.trace("SecondaryServerSocketThread: recreated control socket: " + listenerId); } break; case Bisocket.CREATE_ORDINARY_SOCKET: BisocketClientInvoker.transferSocket(listenerId, socket, false); if (log.isTraceEnabled()) log.trace("SecondaryServerSocketThread: transferred socket: " + listenerId); break; default: log.error("unrecognized action on SecondaryServerSocketThread: " + action); } } catch (IOException e) { if (running) log.error("Failed to accept socket connection", e); else return; } } } ServerSocket getServerSocket() { return secondaryServerSocket; } } static class ControlMonitorTimerTask extends TimerTask { private boolean running = true; private BisocketServerInvoker invoker; private Map listenerIdToInvokerLocatorMap; private Map controlConnectionThreadMap; private Map controlConnectionRestartsMap; private int controlConnectionRestarts; ControlMonitorTimerTask(BisocketServerInvoker invoker) { this.invoker = invoker; listenerIdToInvokerLocatorMap = invoker.listenerIdToInvokerLocatorMap; controlConnectionThreadMap = invoker.controlConnectionThreadMap; controlConnectionRestartsMap = invoker.controlConnectionRestartsMap; controlConnectionRestarts = invoker.controlConnectionRestarts; } synchronized void shutdown() { // Note that there is a race between shutdown() and run(). But if run() // were synchronized, then shutdown() could be held up waiting on network // i/o, including invocations on a server that no longer is accessible. // So only minimal synchronization is imposed on run(), enough to avoid // NullPointerExceptions. running = false; invoker = null; listenerIdToInvokerLocatorMap = null; controlConnectionThreadMap = null; cancel(); try { Method purge = getDeclaredMethod(Timer.class, "purge", new Class[]{}); purge.invoke(timer, new Object[]{}); } catch (Exception e) { log.debug("running with jdk 1.4: unable to purge Timer"); } } public void run() { if (!running) return; if (log.isTraceEnabled()) log.trace("checking connections"); Collection controlConnectionThreads = null; synchronized (this) { if (!running) return; controlConnectionThreads = new HashSet(controlConnectionThreadMap.values()); } Iterator it = controlConnectionThreads.iterator(); while (it.hasNext()) { final ControlConnectionThread t = (ControlConnectionThread) it.next(); final String listenerId = t.getListenerId(); final Object locator; synchronized (this) { if (!running) return; locator = listenerIdToInvokerLocatorMap.get(listenerId); } if (!t.checkConnection()) { t.shutdown(); synchronized (this) { if (!running) return; controlConnectionThreadMap.remove(listenerId); Object o = controlConnectionRestartsMap.get(listenerId); int restarts = ((Integer)o).intValue(); if (restarts + 1 > controlConnectionRestarts) { log.warn(this + ": detected failure on control connection " + t); log.warn("Control connection " + listenerId + " has been recreated " + restarts + " times."); log.warn("Assuming it is a connection to an old server, and will not restart"); controlConnectionRestartsMap.remove(listenerId); continue; } log.warn(this + ": detected failure on control connection " + t + " (" + listenerId + ": requesting new control connection"); } Thread t2 = new Thread() { public void run() { if (!running) return; try { invoker.createControlConnection(listenerId, false); } catch (ClientUnavailableException e) { log.debug("Unable to recreate control connection: " + locator, e); } catch (IOException e) { if (running) log.error("Unable to recreate control connection: " + locator, e); else log.debug("Unable to recreate control connection: " + locator, e); } } }; t2.setName("controlConnectionRecreate:" + t.getName()); t2.start(); } } } } static class ClientUnavailableException extends IOException { private static final long serialVersionUID = 2846502029152028732L; } static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/AddressUtil.java0000644000175000017500000001070011413660476031766 0ustar twernertwerner /* * 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.remoting.transport; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.jboss.logging.Logger; import org.jboss.remoting.util.SecurityUtility; /** * Checks if an IP interface address is usable. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Jan 30, 2008 *

          */ public class AddressUtil { private static Logger log = Logger.getLogger(AddressUtil.class); public static boolean checkAddress(String host) throws Exception { return checkAddress(host, 5000); } public static boolean checkAddress(final String host, int timeout) throws Exception { try { log.trace("checking host: " + host); int port = PortUtil.findFreePort(host); InetAddress addr = getAddressByName(host); ServerTestThread t1 = new ServerTestThread(addr, port); t1.setDaemon(true); t1.start(); ClientTestThread t2 = new ClientTestThread(addr, port); t2.setDaemon(true); t2.start(); t2.join(timeout); return t2.ok; } catch (Exception e) { return false; } } static class ServerTestThread extends Thread { InetAddress addr; int port; ServerTestThread(InetAddress addr, int port) { this.addr = addr; this.port = port; } public void run() { try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { ServerSocket ss = new ServerSocket(port, 0, addr); Socket s = ss.accept(); s.close(); ss.close(); log.trace("ServerTestThread ok: " + addr + ":" + port); return null; } }); } catch (PrivilegedActionException e) { log.trace("error in ServerTestThread", e); } } } static class ClientTestThread extends Thread { public boolean ok; InetAddress addr; int port; ClientTestThread(InetAddress addr, int port) { this.addr = addr; this.port = port; } public void run() { try { Socket s = new Socket(addr, port); s.close(); ok = true; log.trace("ClientTestThread ok: " + addr + ":" + port); } catch (Exception e) { log.trace("error in ClientTestThread", e); } } } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/0000755000175000017500000000000011632407051030703 5ustar twernertwerner././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketServerInvokerMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketServe0000644000175000017500000000311010455077561033453 0ustar twernertwerner/* * 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.remoting.transport.sslsocket; import org.jboss.remoting.transport.socket.SocketServerInvokerMBean; import javax.net.ServerSocketFactory; /** * @author Tom Elrod */ public interface SSLSocketServerInvokerMBean extends SocketServerInvokerMBean { /** * Sets the server socket factory for the SocketServerInvoker to use. * Can produce normal server socket or ssl server socket, depending * on implementation passed. * * @param serverSocketFactory */ void setServerSocketFactory(ServerSocketFactory serverSocketFactory); }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClien0000644000175000017500000001717711171062165033431 0ustar twernertwerner/* * 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.remoting.transport.sslsocket; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.socketfactory.SocketFactoryWrapper; import org.jboss.remoting.transport.socket.SocketClientInvoker; import org.jboss.remoting.util.SecurityUtility; import org.jboss.remoting.util.socket.HandshakeRepeater; import javax.net.SocketFactory; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLSocket; import java.io.IOException; import java.net.Socket; import java.net.InetSocketAddress; import java.net.SocketException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Map; /** * @author Tom Elrod */ public class SSLSocketClientInvoker extends SocketClientInvoker { private static final Logger log = Logger.getLogger(SSLSocketClientInvoker.class); private static final boolean isTraceEnabled = log.isTraceEnabled(); protected String[] enabledCipherSuites; protected String[] enabledProtocols; protected boolean enableSessionCreation = true; public SSLSocketClientInvoker(InvokerLocator locator) throws IOException { super(locator); try { setup(); } catch (Exception ex) { log.debug("Error setting up ssl socket client invoker.", ex); throw new RuntimeException(ex.getMessage()); } } public SSLSocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); try { setup(); } catch (Exception ex) { log.debug("Error setting up ssl socket client invoker.", ex); throw new RuntimeException(ex.getMessage()); } } public void setOOBInline(boolean inline) { log.warn("Ignored: sending urgent data is not supported by SSLSockets"); } public String[] getEnabledCipherSuites() { return enabledCipherSuites; } public void setEnabledCipherSuites(String[] enabledCipherSuites) { this.enabledCipherSuites = enabledCipherSuites; } public String[] getEnabledProtocols() { return enabledProtocols; } public void setEnabledProtocols(String[] enabledProtocols) { this.enabledProtocols = enabledProtocols; } public boolean isEnableSessionCreation() { return enableSessionCreation; } public void setEnableSessionCreation(boolean enableSessionCreation) { this.enableSessionCreation = enableSessionCreation; } protected void setup() throws Exception { super.setup(); Object o = configuration.get("enabledCipherSuites"); if (o instanceof String[]) setEnabledCipherSuites((String[]) o); o = configuration.get("enabledProtocols"); if (o instanceof String[]) setEnabledProtocols((String[]) o); } protected SocketFactory createSocketFactory(Map configuration) { SocketFactory sf = super.createSocketFactory(configuration); if (isCompleteSocketFactory(sf)) { return sf; } SocketFactory wrapper = sf; try { SSLSocketBuilder server = new SSLSocketBuilder(configuration); sf = server.createSSLSocketFactory(); } catch (Exception e) { log.error("Error creating SSL Socket Factory for client invoker: " + e.getMessage()); log.debug("Error creating SSL Socket Factory for client invoker.", e); } if (wrapper != null) { ((SocketFactoryWrapper) wrapper).setSocketFactory(sf); socketFactory = wrapper; return wrapper; } return sf; } protected Socket createSocket(String address, int port, int timeout) throws IOException { SocketFactory sf = getSocketFactory(); if (sf == null) sf = createSocketFactory(configuration); Socket s = sf.createSocket(); configureSocket(s); InetSocketAddress inetAddr = new InetSocketAddress(address, port); if (timeout < 0) { timeout = getTimeout(); if (timeout < 0) timeout = 0; } connect(s, inetAddr, timeout); if (s instanceof SSLSocket) { // need to check for handshake listener and add them if there is one Object obj = configuration.get(Client.HANDSHAKE_COMPLETED_LISTENER); if (obj != null && obj instanceof HandshakeCompletedListener) { SSLSocket sslSocket = (SSLSocket) s; HandshakeCompletedListener listener = (HandshakeCompletedListener) obj; establishHandshake(sslSocket, listener); } } return s; } protected void configureSocket(Socket s) throws SocketException { s.setReuseAddress(getReuseAddress()); if (keepAliveSet) s.setKeepAlive(keepAlive); if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize); if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize); if (soLingerSet && soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration); if (trafficClass > -1) s.setTrafficClass(trafficClass); if (s instanceof SSLSocket) { SSLSocket ss = (SSLSocket) s; if (enabledCipherSuites != null) { ss.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { ss.setEnabledProtocols(enabledProtocols); } ss.setEnableSessionCreation(enableSessionCreation); } } private void establishHandshake(SSLSocket sslSocket, HandshakeCompletedListener listener) throws IOException { HandshakeRepeater repeater = new HandshakeRepeater(listener); sslSocket.addHandshakeCompletedListener(repeater); sslSocket.getSession(); repeater.waitForHandshake(); } static private void connect(final Socket socket, final InetSocketAddress address, final int timeout) throws IOException { if (SecurityUtility.skipAccessControl()) { socket.connect(address, timeout); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { socket.connect(address, timeout); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/TransportClien0000644000175000017500000000310210455077561033604 0ustar twernertwerner/* * 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.remoting.transport.sslsocket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new SSLSocketClientInvoker(locator, config); } public boolean supportsSSL() { return true; } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketServe0000644000175000017500000000736710761740575033477 0ustar twernertwerner/* * 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.remoting.transport.sslsocket; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.socket.SocketServerInvoker; import javax.net.ServerSocketFactory; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import java.net.ServerSocket; import java.net.SocketException; import java.util.Map; /** * @author Tom Elrod */ public class SSLSocketServerInvoker extends SocketServerInvoker implements SSLSocketServerInvokerMBean { private static final Logger log = Logger.getLogger(SSLSocketServerInvoker.class); protected String[] enabledCipherSuites; protected String[] enabledProtocols; protected boolean enableSessionCreation = true; public SSLSocketServerInvoker(InvokerLocator locator) { super(locator); } public SSLSocketServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } public void setOOBInline(boolean inline) { log.warn("Ignored: sending urgent data is not supported by SSLSockets"); } public String[] getEnabledCipherSuites() { return enabledCipherSuites; } public void setEnabledCipherSuites(String[] enabledCipherSuites) { this.enabledCipherSuites = enabledCipherSuites; } public String[] getEnabledProtocols() { return enabledProtocols; } public void setEnabledProtocols(String[] enabledProtocols) { this.enabledProtocols = enabledProtocols; } public boolean isEnableSessionCreation() { return enableSessionCreation; } public void setEnableSessionCreation(boolean enableSessionCreation) { this.enableSessionCreation = enableSessionCreation; } protected void setup() throws Exception { super.setup(); Object o = configuration.get("enabledCipherSuites"); if (o instanceof String[]) setEnabledCipherSuites((String[]) o); o = configuration.get("enabledProtocols"); if (o instanceof String[]) setEnabledProtocols((String[]) o); } protected ServerSocketFactory getDefaultServerSocketFactory() { return SSLServerSocketFactory.getDefault(); } protected void configureServerSocket(ServerSocket ss) throws SocketException { super.configureServerSocket(ss); if (ss instanceof SSLServerSocket) { SSLServerSocket sss = (SSLServerSocket) ss; if (enabledCipherSuites != null) { sss.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sss.setEnabledProtocols(enabledProtocols); } sss.setEnableSessionCreation(enableSessionCreation); } } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslsocket/TransportServe0000644000175000017500000000105010455077561033636 0ustar twernertwernerpackage org.jboss.remoting.transport.sslsocket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new SSLSocketServerInvoker(locator, config); } public boolean supportsSSL() { return true; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/0000755000175000017500000000000011632407051031436 5ustar twernertwerner././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/SSLMultiplexClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/SSLMultiple0000644000175000017500000000721510567021037033545 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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. */ /* * Created on Mar 24, 2006 */ package org.jboss.remoting.transport.sslmultiplex; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.socketfactory.SocketFactoryWrapper; import org.jboss.remoting.transport.multiplex.Multiplex; import org.jboss.remoting.transport.multiplex.MultiplexClientInvoker; import org.jboss.remoting.transport.multiplex.VirtualSocket; import javax.net.SocketFactory; import java.io.IOException; import java.net.Socket; import java.util.Map; /** * SSLMultiplexClientInvoker is the client side of the sslmultiplex transport. * For more information, see Remoting documentation on labs.jboss.org. * * @author Ron Sigal * @version $Revision: 2188 $ *

          * Copyright (c) 2006 *

          */ public class SSLMultiplexClientInvoker extends MultiplexClientInvoker { private static final Logger log = Logger.getLogger(SSLMultiplexClientInvoker.class); private static final boolean isTraceEnabled = log.isTraceEnabled(); public SSLMultiplexClientInvoker(InvokerLocator locator) throws IOException { super(locator); } /** * @param locator * @param configuration * @throws IOException */ public SSLMultiplexClientInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); } /** * */ protected SocketFactory createSocketFactory(Map configuration) { SocketFactory sf = super.createSocketFactory(configuration); if (isCompleteSocketFactory(sf)) { socketFactory = sf; return sf; } SocketFactory wrapper = sf; try { SSLSocketBuilder server = new SSLSocketBuilder(configuration); server.setUseSSLSocketFactory(false); sf = server.createSSLSocketFactory(); this.configuration.put(Multiplex.SOCKET_FACTORY, sf); } catch(Exception e) { log.error("Error creating SSL Socket Factory for client invoker.", e); } if (wrapper != null) { ((SocketFactoryWrapper) wrapper).setSocketFactory(sf); socketFactory = wrapper; return wrapper; } socketFactory = sf; return sf; } protected Socket createSocket(String address, int port, int timeout) throws IOException { SocketFactory sf = getSocketFactory(); if (sf == null) createSocketFactory(configuration); VirtualSocket socket = new VirtualSocket(configuration); socket.connect(getConnectSocketAddress(), getBindSocketAddress(), this.timeout); return socket; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/TransportCl0000644000175000017500000000311110455077561033643 0ustar twernertwerner/* * 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.remoting.transport.sslmultiplex; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new SSLMultiplexClientInvoker(locator, config); } public boolean supportsSSL() { return true; } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/TransportSe0000644000175000017500000000113610455077561033661 0ustar twernertwernerpackage org.jboss.remoting.transport.sslmultiplex; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException { return new SSLMultiplexServerInvoker(locator, config); } public boolean supportsSSL() { return true; } } ././@LongLink0000000000000000000000000000017000000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/SSLMultiplexServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslmultiplex/SSLMultiple0000644000175000017500000000724510457537345033564 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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. */ /* * Created on Mar 24, 2006 */ package org.jboss.remoting.transport.sslmultiplex; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.CustomSSLServerSocketFactory; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.security.SSLSocketBuilderMBean; import org.jboss.remoting.transport.multiplex.MultiplexServerInvoker; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.SSLServerSocketFactory; import java.io.IOException; import java.util.Map; /** * SSLMultiplexServerInvoker is the server side of the sslmultiplex transport. * For more information, see Remoting documentation on labs.jboss.org. * * @author Ron Sigal * @version $Revision: 1248 $ *

          * Copyright (c) Mar 24, 2006 *

          */ public class SSLMultiplexServerInvoker extends MultiplexServerInvoker { /** * @param locator */ public SSLMultiplexServerInvoker(InvokerLocator locator) { super(locator); } /** * @param locator * @param configuration */ public SSLMultiplexServerInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); } /** * @param configuration * @return */ protected SocketFactory createSocketFactory(Map configuration) { SocketFactory socketFactory = null; if ((socketFactory = super.createSocketFactory(configuration)) != null) return socketFactory; ServerSocketFactory serverSocketFactory = getServerSocketFactory(); try { if (serverSocketFactory instanceof CustomSSLServerSocketFactory) { CustomSSLServerSocketFactory customServerSocketFactory = (CustomSSLServerSocketFactory) serverSocketFactory; SSLSocketBuilderMBean builder = customServerSocketFactory.getSSLSocketBuilder(); boolean shouldUseDefault = builder.getUseSSLServerSocketFactory(); builder.setUseSSLSocketFactory(shouldUseDefault); boolean useClientMode = builder.isServerSocketUseClientMode(); builder.setSocketUseClientMode(useClientMode); return builder.createSSLSocketFactory(); } SSLSocketBuilder builder = new SSLSocketBuilder(configuration); return builder.createSSLSocketFactory(); } catch(Exception e) { log.error("Error creating SSL Socket Factory for server invoker.", e); // throw new IOException("Error creating SSL Socket Factory. Root cause: " + e.getMessage()); return null; } } protected ServerSocketFactory getDefaultServerSocketFactory() { return SSLServerSocketFactory.getDefault(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/https/0000755000175000017500000000000011632407050030032 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/https/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/https/TransportClientFac0000644000175000017500000000317410455077561033543 0ustar twernertwerner/* * 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.remoting.transport.https; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new HTTPSClientInvoker(locator, config); } public boolean supportsSSL() { return true; } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/https/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/https/TransportServerFac0000644000175000017500000000112610455077561033566 0ustar twernertwernerpackage org.jboss.remoting.transport.https; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.coyote.CoyoteInvoker; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new CoyoteInvoker(locator, config); } public boolean supportsSSL() { return true; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/0000755000175000017500000000000011632407050031215 5ustar twernertwerner././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketS0000644000175000017500000001202111173761062033412 0ustar twernertwerner/* * 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.remoting.transport.sslbisocket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.socketfactory.SocketFactoryWrapper; import org.jboss.remoting.transport.bisocket.BisocketServerInvoker; import org.jboss.remoting.transport.sslsocket.SSLSocketServerInvokerMBean; import org.jboss.logging.Logger; import javax.net.ServerSocketFactory; import javax.net.SocketFactory; import javax.net.ssl.SSLServerSocket; import javax.net.ssl.SSLServerSocketFactory; import java.io.IOException; import java.net.ServerSocket; import java.net.SocketException; import java.util.Map; /** * @author Tom Elrod * @author Ron Sigal */ public class SSLBisocketServerInvoker extends BisocketServerInvoker implements SSLSocketServerInvokerMBean { private static final Logger log = Logger.getLogger(SSLBisocketServerInvoker.class); protected String[] enabledCipherSuites; protected String[] enabledProtocols; protected boolean enableSessionCreation = true; public SSLBisocketServerInvoker(InvokerLocator locator) { super(locator); } public SSLBisocketServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } protected ServerSocketFactory getDefaultServerSocketFactory() { return SSLServerSocketFactory.getDefault(); } public void setOOBInline(boolean inline) { log.warn("Ignored: sending urgent data is not supported by SSLSockets"); } public String[] getEnabledCipherSuites() { return enabledCipherSuites; } public void setEnabledCipherSuites(String[] enabledCipherSuites) { this.enabledCipherSuites = enabledCipherSuites; } public String[] getEnabledProtocols() { return enabledProtocols; } public void setEnabledProtocols(String[] enabledProtocols) { this.enabledProtocols = enabledProtocols; } public boolean isEnableSessionCreation() { return enableSessionCreation; } public void setEnableSessionCreation(boolean enableSessionCreation) { this.enableSessionCreation = enableSessionCreation; } protected ServerSocketFactory createServerSocketFactory() throws IOException { if (isCallbackServer) return null; return super.createServerSocketFactory(); } protected void setup() throws Exception { super.setup(); Object o = configuration.get("enabledCipherSuites"); if (o instanceof String[]) setEnabledCipherSuites((String[]) o); o = configuration.get("enabledProtocols"); if (o instanceof String[]) setEnabledProtocols((String[]) o); } protected SocketFactory createSocketFactory(Map configuration) { SocketFactory sf = super.createSocketFactory(configuration); if (isCompleteSocketFactory(sf)) return sf; SocketFactory wrapper = sf; try { SSLSocketBuilder server = new SSLSocketBuilder(configuration); sf = server.createSSLSocketFactory(); } catch (Exception e) { log.error("Error creating SSL Socket Factory for client invoker: " + e.getMessage()); log.debug("Error creating SSL Socket Factory for client invoker.", e); } if (wrapper != null) { ((SocketFactoryWrapper) wrapper).setSocketFactory(sf); return wrapper; } return sf; } protected void configureServerSocket(ServerSocket ss) throws SocketException { super.configureServerSocket(ss); if (ss instanceof SSLServerSocket) { SSLServerSocket sss = (SSLServerSocket) ss; if (enabledCipherSuites != null) { sss.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { sss.setEnabledProtocols(enabledProtocols); } sss.setEnableSessionCreation(enableSessionCreation); } } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/TransportCli0000644000175000017500000000320410541701071033561 0ustar twernertwerner/* * 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.remoting.transport.sslbisocket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod * @author Ron Sigal */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new SSLBisocketClientInvoker(locator, config); } public boolean supportsSSL() { return true; } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/TransportSer0000644000175000017500000000115210541701071033603 0ustar twernertwernerpackage org.jboss.remoting.transport.sslbisocket; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.util.Map; /** * @author Tom Elrod * @author Ron Sigal */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new SSLBisocketServerInvoker(locator, config); } public boolean supportsSSL() { return true; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketC0000644000175000017500000001732511171062137033401 0ustar twernertwerner/* * 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.remoting.transport.sslbisocket; import java.io.IOException; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Map; import javax.net.SocketFactory; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLSocket; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.security.SSLSocketBuilder; import org.jboss.remoting.socketfactory.SocketFactoryWrapper; import org.jboss.remoting.transport.bisocket.BisocketClientInvoker; import org.jboss.remoting.util.SecurityUtility; import org.jboss.remoting.util.socket.HandshakeRepeater; /** * @author Tom Elrod * * @author Ron Sigal */ public class SSLBisocketClientInvoker extends BisocketClientInvoker { private static final Logger log = Logger.getLogger(SSLBisocketClientInvoker.class); protected String[] enabledCipherSuites; protected String[] enabledProtocols; protected boolean enableSessionCreation = true; public SSLBisocketClientInvoker(InvokerLocator locator) throws IOException { super(locator); try { setup(); } catch (Exception ex) { log.debug("Error setting up ssl bisocket client invoker.", ex); throw new RuntimeException(ex.getMessage()); } } public SSLBisocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); try { setup(); } catch (Exception ex) { log.debug("Error setting up ssl bisocket client invoker.", ex); throw new RuntimeException(ex.getMessage()); } } public void setOOBInline(boolean inline) { log.warn("Ignored: sending urgent data is not supported by SSLSockets"); } public String[] getEnabledCipherSuites() { return enabledCipherSuites; } public void setEnabledCipherSuites(String[] enabledCipherSuites) { this.enabledCipherSuites = enabledCipherSuites; } public String[] getEnabledProtocols() { return enabledProtocols; } public void setEnabledProtocols(String[] enabledProtocols) { this.enabledProtocols = enabledProtocols; } public boolean isEnableSessionCreation() { return enableSessionCreation; } public void setEnableSessionCreation(boolean enableSessionCreation) { this.enableSessionCreation = enableSessionCreation; } protected void setup() throws Exception { super.setup(); Object o = configuration.get("enabledCipherSuites"); if (o instanceof String[]) setEnabledCipherSuites((String[]) o); o = configuration.get("enabledProtocols"); if (o instanceof String[]) setEnabledProtocols((String[]) o); } protected SocketFactory createSocketFactory(Map configuration) { SocketFactory sf = super.createSocketFactory(configuration); if (isCompleteSocketFactory(sf)) return sf; SocketFactory wrapper = sf; try { SSLSocketBuilder server = new SSLSocketBuilder(configuration); sf = server.createSSLSocketFactory(); } catch (Exception e) { log.error("Error creating SSL Socket Factory for client invoker: " + e.getMessage()); log.debug("Error creating SSL Socket Factory for client invoker.", e); } if (wrapper != null) { ((SocketFactoryWrapper) wrapper).setSocketFactory(sf); return wrapper; } return sf; } protected Socket createSocket(String address, int port, int timeout) throws IOException { if (isCallbackInvoker) return super.createSocket(address, port, timeout); SocketFactory sf = getSocketFactory(); if (sf == null) sf = createSocketFactory(configuration); Socket s = sf.createSocket(); configureSocket(s); InetSocketAddress inetAddr = new InetSocketAddress(address, port); if (timeout < 0) { timeout = getTimeout(); if (timeout < 0) timeout = 0; } connect(s, inetAddr, timeout); if (s instanceof SSLSocket) { // need to check for handshake listener and add them if there is one Object obj = configuration.get(Client.HANDSHAKE_COMPLETED_LISTENER); if (obj != null && obj instanceof HandshakeCompletedListener) { SSLSocket sslSocket = (SSLSocket) s; HandshakeCompletedListener listener = (HandshakeCompletedListener) obj; establishHandshake(sslSocket, listener); } } return s; } protected void configureSocket(Socket s) throws SocketException { s.setReuseAddress(getReuseAddress()); if (keepAliveSet) s.setKeepAlive(keepAlive); if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize); if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize); if (soLingerSet && soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration); if (trafficClass > -1) s.setTrafficClass(trafficClass); if (s instanceof SSLSocket) { SSLSocket ss = (SSLSocket) s; if (enabledCipherSuites != null) { ss.setEnabledCipherSuites(enabledCipherSuites); } if (enabledProtocols != null) { ss.setEnabledProtocols(enabledProtocols); } ss.setEnableSessionCreation(enableSessionCreation); } } private void establishHandshake(SSLSocket sslSocket, HandshakeCompletedListener listener) throws IOException { HandshakeRepeater repeater = new HandshakeRepeater(listener); sslSocket.addHandshakeCompletedListener(repeater); sslSocket.getSession(); repeater.waitForHandshake(); } static private void connect(final Socket socket, final InetSocketAddress address, final int timeout) throws IOException { if (SecurityUtility.skipAccessControl()) { socket.connect(address, timeout); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { socket.connect(address, timeout); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/web/0000755000175000017500000000000011632407051027446 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/web/WebUtil.java0000644000175000017500000000335210355142433031670 0ustar twernertwerner/* * 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.remoting.transport.web; /** * @author Tom Elrod */ public class WebUtil { // list of content types public static String HTML = "text/html"; public static String PLAIN = "text/plain"; public static String SOAP = "application/soap+xml"; public static String BINARY = "application/octet-stream"; public static boolean isBinary(String requestContentType) { if(BINARY.equalsIgnoreCase(requestContentType)) { return true; } else { return false; } } public static String getContentType(Object param) { if(param instanceof String) { return HTML; } else { return BINARY; } } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/web/WebServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/web/WebServerInvoker.jav0000644000175000017500000002006111203656307033415 0ustar twernertwerner/* * 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.remoting.transport.web; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.remoting.util.SecurityUtility; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.http.HTTPMarshaller; /** * @author Tom Elrod */ public abstract class WebServerInvoker extends ServerInvoker { // header constants public static String HEADER_SESSION_ID = "sessionId"; public static String HEADER_SUBSYSTEM = "subsystem"; public WebServerInvoker(InvokerLocator locator) { super(locator); } public WebServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); } /** * returns true if the transport is bi-directional in nature, for example, HTTP in unidirectional and SOCKETs are * bi-directional (unless behind a firewall for example). * * @return false (HTTP is unidirrectional) */ public boolean isTransportBiDirectional() { return false; } protected String getDefaultDataType() { return HTTPMarshaller.DATATYPE; } protected InvocationRequest getInvocationRequest(Map metadata, Object obj) { InvocationRequest request = null; if(obj instanceof InvocationRequest) { request = (InvocationRequest) obj; if(request.getRequestPayload() == null) { request.setRequestPayload(metadata); } else { request.getRequestPayload().putAll(metadata); } } else { request = createNewInvocationRequest(metadata, obj); } return request; } public UnMarshaller getUnMarshaller() { ClassLoader classLoader = getClassLoader(WebServerInvoker.class); Map map = passConfigMapToMarshalFactory ? configuration : null; UnMarshaller unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), classLoader, map); if(unmarshaller == null) { unmarshaller = MarshalFactory.getUnMarshaller(getDataType(), getSerializationType()); } return unmarshaller; } public Marshaller getMarshaller() { ClassLoader classLoader = getClassLoader(WebServerInvoker.class); Map map = passConfigMapToMarshalFactory ? configuration : null; Marshaller marshaller = MarshalFactory.getMarshaller(getLocator(), classLoader, map); if(marshaller == null) { marshaller = MarshalFactory.getMarshaller(getDataType(), getSerializationType()); } return marshaller; } protected InvocationRequest createNewInvocationRequest(Map metadata, Object payload) { // will try to use the same session id if possible to track String sessionId = getSessionId(metadata); String subSystem = (String) metadata.get(HEADER_SUBSYSTEM); InvocationRequest request = null; Map responseMap = new HashMap(); boolean isLeasQuery = checkForLeaseQuery(metadata); if(isLeasQuery) { addLeaseInfo(responseMap); request = new CreatedInvocationRequest(sessionId, subSystem, "$PING$", null, responseMap, null); } else { request = new CreatedInvocationRequest(sessionId, subSystem, payload, metadata, null, null); } request.setReturnPayload(responseMap); return request; } private boolean checkForLeaseQuery(Map headers) { boolean isLeaseQuery = false; if(headers != null) { Object val = headers.get(HTTPMetadataConstants.REMOTING_LEASE_QUERY); if(val != null && val instanceof String) { isLeaseQuery = Boolean.valueOf((String)val).booleanValue(); } else { val = headers.get(HTTPMetadataConstants.REMOTING_LEASE_QUERY_LOWER_CASE); if(val != null && val instanceof String) { isLeaseQuery = Boolean.valueOf((String)val).booleanValue(); } } } return isLeaseQuery; } private void addLeaseInfo(Map response) { boolean leaseManagement = isLeaseActivated(); response.put("LEASING_ENABLED", new Boolean(leaseManagement)); if(leaseManagement) { long leasePeriod = getLeasePeriod(); response.put("LEASE_PERIOD", new Long(leasePeriod)); } } protected String getSessionId(Map metadata) { String sessionId = (String) metadata.get(HEADER_SESSION_ID); if(sessionId == null || sessionId.length() == 0) { String userAgent = (String) metadata.get("User-Agent"); String host = (String) metadata.get("Host"); String idSeed = userAgent + ":" + host; sessionId = Integer.toString(idSeed.hashCode()); } return sessionId; } /** * Will write out the object to byte array and check size of byte array. This is VERY expensive, but need for the * content length. * * @param response * @return */ protected int getContentLength(Object response) throws IOException { if(response != null) { /** * Am checking to see if type String because: * 1. faster to just get the length compared to doing serialization * 2. doing serialization adds extra bytes, so the value calculated is larger * than the actual number of characters (and causes the client to wait for the * extra characters that it will never get). */ if(response instanceof String) { return ((String) response).length(); } else { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(response); oos.flush(); bos.flush(); byte buffer[] = bos.toByteArray(); return buffer.length; } } else { return 0; } } static protected class CreatedInvocationRequest extends InvocationRequest { public CreatedInvocationRequest(String sessionId, String subsystem, Object arg, Map requestPayload, Map returnPayload, InvokerLocator locator) { super(sessionId, subsystem, arg, requestPayload, returnPayload, locator); } } static private ClassLoader getClassLoader(final Class c) { if (SecurityUtility.skipAccessControl()) { return c.getClassLoader(); } return (ClassLoader)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return c.getClassLoader(); } }); } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/0000755000175000017500000000000011632407050030354 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/ServletServerInv0000644000175000017500000004671611247340104033603 0ustar twernertwerner/* * 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.remoting.transport.servlet; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.InvocationResponse; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.Remoting; import org.jboss.remoting.marshal.MarshalFactory; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.remoting.transport.web.WebServerInvoker; import org.jboss.remoting.transport.web.WebUtil; import org.jboss.remoting.util.SecurityUtility; import org.jboss.logging.Logger; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Iterator; /** * The servlet based server invoker that receives the original http request * from the ServerInvokerServlet. * * @author Tom Elrod */ public class ServletServerInvoker extends WebServerInvoker implements ServletServerInvokerMBean { public static final String UNWRAP_SINGLETON_ARRAYS = "unwrapSingletonArrays"; private static final Logger log = Logger.getLogger(ServletServerInvoker.class); private boolean unwrapSingletonArrays; private boolean useRemotingContentType; public ServletServerInvoker(InvokerLocator locator) { super(locator); init(); } public ServletServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); init(); } protected String getDefaultDataType() { return HTTPMarshaller.DATATYPE; } protected void init() { Object val = configuration.get(UNWRAP_SINGLETON_ARRAYS); if (val != null) { try { unwrapSingletonArrays = Boolean.valueOf((String)val).booleanValue(); log.debug(this + " setting unwrapSingletonArrays to " + unwrapSingletonArrays); } catch (Exception e) { log.warn(this + " could not convert " + UNWRAP_SINGLETON_ARRAYS + " value of " + val + " to a boolean value."); } } val = configuration.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE); if (val instanceof String) { useRemotingContentType = Boolean.valueOf((String) val).booleanValue(); } else if (val != null) { log.warn(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE + " value should be a String: " + val); } log.debug(this + " useRemotingContentType: " + useRemotingContentType); } public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Map metadata = new HashMap(); Enumeration enumer = request.getHeaderNames(); while(enumer.hasMoreElements()) { Object obj = enumer.nextElement(); String headerKey = (String) obj; String headerValue = request.getHeader(headerKey); metadata.put(headerKey, headerValue); } Map urlParams = request.getParameterMap(); if (unwrapSingletonArrays) { Iterator it = urlParams.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); Object value = urlParams.get(key); String[] valueArray = (String[]) value; if (valueArray.length == 1) { value = valueArray[0]; } metadata.put(key, value); } } else { metadata.putAll(urlParams); } if(log.isTraceEnabled()) { log.trace("metadata:"); Iterator it = metadata.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); log.trace(" " + key + ": " + metadata.get(key)); } } // UnMarshaller may not be an HTTPUnMarshaller, in which case it // can ignore this parameter. Object o = configuration.get(HTTPUnMarshaller.PRESERVE_LINES); if (o != null) { if (o instanceof String[]) { metadata.put(HTTPUnMarshaller.PRESERVE_LINES, ((String[]) o)[0]); } else { metadata.put(HTTPUnMarshaller.PRESERVE_LINES, o); } } String requestContentType = request.getContentType(); try { Object invocationResponse = null; ServletInputStream inputStream = request.getInputStream(); UnMarshaller unmarshaller = MarshalFactory.getUnMarshaller(HTTPUnMarshaller.DATATYPE, getSerializationType()); Object obj = null; if (unmarshaller instanceof VersionedUnMarshaller) obj = ((VersionedUnMarshaller)unmarshaller).read(inputStream, metadata, getVersion()); else obj = unmarshaller.read(inputStream, metadata); inputStream.close(); InvocationRequest invocationRequest = null; if(obj instanceof InvocationRequest) { invocationRequest = (InvocationRequest) obj; } else { if(WebUtil.isBinary(requestContentType)) { invocationRequest = getInvocationRequest(metadata, obj); } else { invocationRequest = createNewInvocationRequest(metadata, obj); } } String remoteAddressString = request.getRemoteAddr(); InetAddress remoteAddress = getAddressByName(remoteAddressString); Map requestPayload = invocationRequest.getRequestPayload(); if (requestPayload == null) { requestPayload = new HashMap(); invocationRequest.setRequestPayload(requestPayload); } requestPayload.put(Remoting.CLIENT_ADDRESS, remoteAddress); try { // call transport on the subclass, get the result to handback invocationResponse = invoke(invocationRequest); } catch(Throwable ex) { log.debug("Error thrown calling invoke on server invoker.", ex); invocationResponse = null; response.sendError(500, "Error processing invocation request. " + ex.getMessage()); } if(invocationResponse != null) { if (isInvalidContentType(requestContentType)) { log.warn("Ignoring invalid content-type from client: " + requestContentType); } else { response.setContentType(requestContentType); } int iContentLength = getContentLength(invocationResponse); response.setContentLength(iContentLength); ServletOutputStream outputStream = response.getOutputStream(); Marshaller marshaller = MarshalFactory.getMarshaller(HTTPMarshaller.DATATYPE, getSerializationType()); if (marshaller instanceof VersionedMarshaller) ((VersionedMarshaller) marshaller).write(invocationResponse, outputStream, getVersion()); else marshaller.write(invocationResponse, outputStream); outputStream.close(); } } catch(ClassNotFoundException e) { log.error("Error processing invocation request due to class not being found.", e); response.sendError(500, "Error processing invocation request due to class not being found. " + e.getMessage()); } } public byte[] processRequest(HttpServletRequest request, byte[] requestByte, HttpServletResponse response) throws ServletException, IOException { byte[] retval = new byte[0]; // Check if client is HTTPClientInvoker boolean isRemotingUserAgent = false; String userAgent = request.getHeader(HTTPMetadataConstants.REMOTING_USER_AGENT); if (userAgent != null) { isRemotingUserAgent = userAgent.startsWith("JBossRemoting"); } Map metadata = new HashMap(); Enumeration enumer = request.getHeaderNames(); while(enumer.hasMoreElements()) { Object obj = enumer.nextElement(); String headerKey = (String) obj; String headerValue = request.getHeader(headerKey); metadata.put(headerKey, headerValue); } Map urlParams = request.getParameterMap(); if (unwrapSingletonArrays) { Iterator it = urlParams.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); Object value = urlParams.get(key); String[] valueArray = (String[]) value; if (valueArray.length == 1) { value = valueArray[0]; } metadata.put(key, value); } } else { metadata.putAll(urlParams); } metadata.put(HTTPMetadataConstants.METHODTYPE, request.getMethod()); // UnMarshaller may not be an HTTPUnMarshaller, in which case it // can ignore this parameter. Object o = configuration.get(HTTPUnMarshaller.PRESERVE_LINES); if (o != null) { if (o instanceof String[]) { metadata.put(HTTPUnMarshaller.PRESERVE_LINES, ((String[]) o)[0]); } else { metadata.put(HTTPUnMarshaller.PRESERVE_LINES, o); } } String path = request.getPathTranslated(); if (path != null) metadata.put(HTTPMetadataConstants.PATH, path); metadata.put(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE, Boolean.toString(useRemotingContentType)); String remotingContentType = (String) metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE); if (remotingContentType == null) { remotingContentType = (String) metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_LC); } String requestContentType = request.getContentType(); try { InvocationRequest invocationRequest = null; Object responseObject = null; boolean isError = false; String method = request.getMethod(); if (method.equals("GET") || method.equals("HEAD") || (method.equals("OPTIONS") && request.getContentLength() <= 0)) { invocationRequest = createNewInvocationRequest(metadata, null); } else { ServletInputStream inputStream = request.getInputStream(); UnMarshaller unmarshaller = getUnMarshaller(); Object obj = null; if (unmarshaller instanceof VersionedUnMarshaller) obj = ((VersionedUnMarshaller)unmarshaller).read(new ByteArrayInputStream(requestByte), metadata, getVersion()); else obj = unmarshaller.read(new ByteArrayInputStream(requestByte), metadata); inputStream.close(); if(obj instanceof InvocationRequest) { invocationRequest = (InvocationRequest) obj; Map requestMap = invocationRequest.getRequestPayload(); if (requestMap == null) { invocationRequest.setRequestPayload(metadata); } else { requestMap.putAll(metadata); } } else { if((useRemotingContentType && HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING.equalsIgnoreCase(remotingContentType)) || (!useRemotingContentType && WebUtil.isBinary(requestContentType))) { invocationRequest = getInvocationRequest(metadata, obj); } else { invocationRequest = createNewInvocationRequest(metadata, obj); } } } String remoteAddressString = request.getRemoteAddr(); InetAddress remoteAddress = getAddressByName(remoteAddressString); Map requestPayload = invocationRequest.getRequestPayload(); if (requestPayload == null) { requestPayload = new HashMap(); invocationRequest.setRequestPayload(requestPayload); } requestPayload.put(Remoting.CLIENT_ADDRESS, remoteAddress); try { // call transport on the subclass, get the result to handback responseObject = invoke(invocationRequest); } catch(Throwable ex) { log.debug("Error thrown calling invoke on server invoker.", ex); if (checkForNoExceptionReturn(metadata)) { log.trace("Returning error message instead of Exception"); response.addHeader(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING); response.sendError(500, "Error occurred processing invocation request. "); return retval; } else { responseObject = ex; isError = true; } } int status = 200; if(responseObject != null) { if(isError) { status = 500; } } else { if (!isRemotingUserAgent || "HEAD".equals(request.getMethod())) { status = 204; } } // extract response code/message if exists Map responseMap = invocationRequest.getReturnPayload(); if(responseMap != null) { Integer handlerStatus = (Integer) responseMap.remove(HTTPMetadataConstants.RESPONSE_CODE); if(handlerStatus != null) { status = handlerStatus.intValue(); } // add any response map headers Set entries = responseMap.entrySet(); Iterator itr = entries.iterator(); while(itr.hasNext()) { Map.Entry entry = (Map.Entry)itr.next(); response.addHeader(entry.getKey().toString(), entry.getValue().toString()); } } // can't set message anymore as is deprecated response.setStatus(status); if (isRemotingUserAgent && !(invocationRequest instanceof CreatedInvocationRequest)) { responseObject = new InvocationResponse(invocationRequest.getSessionId(), responseObject, isError, responseMap); } if(responseObject != null) { String responseContentType = null; if (responseMap != null) { responseContentType = (String) responseMap.get("Content-Type"); } if (responseContentType != null) { if (isInvalidContentType(responseContentType)) { log.warn("Ignoring invalid content-type from ServerInvocationHandler: " + responseContentType); responseContentType = WebUtil.getContentType(responseObject); } } else { responseContentType = WebUtil.getContentType(responseObject); } response.setContentType(responseContentType); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); Marshaller marshaller = getMarshaller(); if (marshaller instanceof VersionedMarshaller) ((VersionedMarshaller) marshaller).write(responseObject, outputStream, getVersion()); else marshaller.write(responseObject, outputStream); retval = outputStream.toByteArray(); response.setContentLength(retval.length); } if (responseObject instanceof String) { response.addHeader(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING); } else { response.addHeader(HTTPMetadataConstants.REMOTING_CONTENT_TYPE, HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING); } } catch(ClassNotFoundException e) { log.error("Error processing invocation request due to class not being found.", e); response.sendError(500, "Error processing invocation request due to class not being found. " + e.getMessage()); } return retval; } static private boolean isInvalidContentType(String contentType) { return contentType.indexOf('\n') + contentType.indexOf('\r') > -2; } private boolean checkForNoExceptionReturn(Map headers) { boolean flag = false; if(headers != null) { Object val = headers.get(HTTPMetadataConstants.DONT_RETURN_EXCEPTION); if (val != null) { if (val instanceof String) { flag = Boolean.valueOf((String) val).booleanValue(); } else if (val instanceof String[]) { String param = ((String[]) val)[0]; flag = Boolean.valueOf(param).booleanValue(); } } } return flag; } static private InetAddress getAddressByName(final String host) throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return InetAddress.getByName(host); } try { return (InetAddress)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { return InetAddress.getByName(host); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/web/0000755000175000017500000000000011632407050031131 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/web/ServerInvokerServlet.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/web/ServerInvoke0000644000175000017500000003371311171062013033477 0ustar twernertwerner/* * 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.remoting.transport.servlet.web; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.InvokerRegistry; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.servlet.ServletServerInvokerMBean; import org.jboss.remoting.util.SecurityUtility; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.MBeanServerInvocationHandler; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Iterator; /** * The servlet that receives the inital http request for the ServletServerInvoker. * * @author Tom Elrod */ public class ServerInvokerServlet extends HttpServlet { private static Logger log = Logger.getLogger(ServerInvokerServlet.class); private ServletServerInvokerMBean servletInvoker; private static final long serialVersionUID = 8796224225710165263L; /** * Initializes the servlet. */ public void init(ServletConfig config) throws ServletException { super.init(config); // first see if the invoker is specified by its URL; if not, then see if the invoker was specified by name servletInvoker = getInvokerFromInvokerUrl(config); if (servletInvoker == null) { servletInvoker = getInvokerFromInvokerName(config); if (servletInvoker == null) { throw new ServletException("Could not find init parameter for 'locatorUrl' or 'locatorName' - one of which must be supplied for ServerInvokerServlet to function."); } else { log.debug("Got ServletServerInvoker from InvokerName: " + config.getInitParameter("invokerName")); } } else { log.debug("Got ServletServerInvoker from InvokerLocator: " + config.getInitParameter("locatorUrl")); } } /** * Destroys the servlet. */ public void destroy() { } /** * Read a MarshalledInvocation and dispatch it to the target JMX object * invoke(Invocation) object. * * @param request servlet request * @param response servlet response */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { boolean trace = log.isTraceEnabled(); if (trace) { log.trace("processRequest, ContentLength: " + request.getContentLength()); log.trace("processRequest, ContentType: " + request.getContentType()); } int bufferSize = 1024; byte[] byteBuffer = new byte[bufferSize]; ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); int pointer = 0; int contentLength = request.getContentLength(); ServletInputStream inputStream = request.getInputStream(); int amtRead = inputStream.read(byteBuffer); while (amtRead > 0) { byteOutputStream.write(byteBuffer, pointer, amtRead); //pointer+=amtRead; if (amtRead < bufferSize && byteOutputStream.size() >= contentLength) { //done reading, so process break; } amtRead = inputStream.read(byteBuffer); } byteOutputStream.flush(); byte[] totalByteArray = byteOutputStream.toByteArray(); byte[] out = processRequest(servletInvoker, request, totalByteArray, response); ServletOutputStream outStream = response.getOutputStream(); outStream.write(out); outStream.flush(); outStream.close(); //response.setContentLength(out.length); } /** * Handles the HTTP GET method. * * @param request servlet request * @param response servlet response */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP POST method. * * @param request servlet request * @param response servlet response */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. */ public String getServletInfo() { return "Servlet front to JBossRemoting servlet server invoker."; } /** * Returns the servlet server invoker but only if it was specified via the * "invokerUrl" init parameter. * * @param config the servlet configuration * @return the servlet server invoker as specified by the "invokerUrl", or * null if "invokerUrl" init parameter was not specified * @throws ServletException */ protected ServletServerInvokerMBean getInvokerFromInvokerUrl(ServletConfig config) throws ServletException { String locatorUrl = config.getInitParameter("locatorUrl"); if (locatorUrl == null) { return null; } try { InvokerLocator validatedLocator = new InvokerLocator(locatorUrl); locatorUrl = InvokerLocator.validateLocator(validatedLocator).getLocatorURI(); } catch (MalformedURLException e) { log.warn("malformed URL: " + locatorUrl); return null; } ServerInvoker[] serverInvokers = InvokerRegistry.getServerInvokers(); if (serverInvokers != null && serverInvokers.length > 0) { for (int x = 0; x < serverInvokers.length; x++) { ServerInvoker svrInvoker = serverInvokers[x]; InvokerLocator locator = svrInvoker.getLocator(); if (locatorUrl.equalsIgnoreCase(locator.getLocatorURI())) { return (ServletServerInvokerMBean) svrInvoker; } } throw new ServletException("Can not find servlet server invoker with same locator as specified (" + locatorUrl + ")"); } throw new ServletException("Can not find any server invokers registered. " + "Could be that servlet server invoker not registered or " + "has been created using different classloader."); } /** * Returns the servlet server invoker but only if it was specified via the * "invokerName" init parameter. * * @param config the servlet configuration * @return the servlet server invoker as specified by the "invokerName", or * null if "invokerName" init parameter was not specified * @throws ServletException */ protected ServletServerInvokerMBean getInvokerFromInvokerName(ServletConfig config) throws ServletException { ObjectName localInvokerName = null; String name = config.getInitParameter("invokerName"); if (name == null) { return null; } try { localInvokerName = new ObjectName(name); log.debug("localInvokerName=" + localInvokerName); } catch (MalformedObjectNameException e) { throw new ServletException("Failed to build invokerName", e); } // Lookup the MBeanServer String mbeanServerId = config.getInitParameter("mbeanServer"); MBeanServer mbeanServer = getMBeanServer(mbeanServerId); if (mbeanServer == null) { throw new ServletException("Failed to locate the MBeanServer"); } return (ServletServerInvokerMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanServer, localInvokerName, ServletServerInvokerMBean.class, false); } /** * Returns the MBeanServer where the server invoker should be found. This should only be * used if the "invokerName" init parameter is specified (where that invoker name is the * object name registered in the returned MBeanServer). * * @param mbeanServerId indicates which MBeanServer to use * * @return MBeanServer where the invoker is supposed to be registered */ protected MBeanServer getMBeanServer(String mbeanServerId) { if (mbeanServerId == null) { mbeanServerId = "jboss"; } if (mbeanServerId.equals("*platform*")) { try { MBeanServer s = getPlatformMBeanServer(); log.debug("Using platform MBeanServer"); return s; } catch (Exception e) { mbeanServerId = "jboss"; } } Iterator i = findMBeanServer(null).iterator(); while(i.hasNext()) { MBeanServer server = (MBeanServer) i.next(); if (server.getDefaultDomain() == null) { continue; } if (server.getDefaultDomain().equals(mbeanServerId)) { log.debug("Using MBeanServer with defaultDomain: " + mbeanServerId); return server; } } return null; } static private ArrayList findMBeanServer(final String agentId) { if (SecurityUtility.skipAccessControl()) { return MBeanServerFactory.findMBeanServer(agentId); } return (ArrayList)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return MBeanServerFactory.findMBeanServer(agentId); } }); } static private MBeanServer getPlatformMBeanServer() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (SecurityUtility.skipAccessControl()) { Class c = null; try { c = Class.forName("java.lang.management.ManagementFactory"); } catch (Exception e) { System.out.println("Unable to access java.lang.management.ManagementFactory: must be using jdk 1.4"); return null; } Method m = c.getMethod("getPlatformMBeanServer", new Class[] {}); MBeanServer s = (MBeanServer) m.invoke(null, new Object[] {}); return s; } try { return (MBeanServer) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Class c = null; try { c = Class.forName("java.lang.management.ManagementFactory"); } catch (Exception e) { System.out.println("Unable to access java.lang.management.ManagementFactory: must be using jdk 1.4"); return null; } Method m = c.getMethod("getPlatformMBeanServer", new Class[] {}); MBeanServer s = (MBeanServer) m.invoke(null, new Object[] {}); return s; } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof NoSuchMethodException) throw (NoSuchMethodException) cause; else if (cause instanceof IllegalAccessException) throw (IllegalAccessException) cause; else throw (InvocationTargetException) cause; } } static private byte[] processRequest(final ServletServerInvokerMBean invoker, final HttpServletRequest request, final byte[] byteArray, final HttpServletResponse response) throws ServletException, IOException { if (SecurityUtility.skipAccessControl()) { return invoker.processRequest(request, byteArray, response); } try { return (byte[]) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws ServletException, IOException { return invoker.processRequest(request, byteArray, response); } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof ServletException) throw (ServletException) cause; else throw (IOException) e.getCause(); } } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/TransportClientF0000644000175000017500000000317010456070655033553 0ustar twernertwerner/* * 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.remoting.transport.servlet; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.http.HTTPClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new HTTPClientInvoker(locator, config); } public boolean supportsSSL() { return false; } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/TransportServerF0000644000175000017500000000104510455077561033604 0ustar twernertwernerpackage org.jboss.remoting.transport.servlet; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new ServletServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/ServletServerInvokerMBean.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/servlet/ServletServerInv0000644000175000017500000000360510357543115033601 0ustar twernertwerner/* * 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.remoting.transport.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * The MBean interface for the ServletServerInvoker. * * @author Tom Elrod */ public interface ServletServerInvokerMBean { /** * Method to be called by the servlet to handle the incoming request. * * @param request * @param response * @throws ServletException * @throws IOException */ void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException; public byte[] processRequest(HttpServletRequest request, byte[] requestByte, HttpServletResponse response) throws ServletException, IOException; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/0000755000175000017500000000000011632407047030721 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexingManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexingMa0000644000175000017500000025633710753261335033624 0ustar twernertwerner/* * 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.remoting.transport.multiplex; import org.jboss.logging.Logger; import org.jboss.remoting.transport.multiplex.InputMultiplexor.MultiGroupInputThread; import org.jboss.remoting.transport.multiplex.utility.GrowablePipedOutputStream; import org.jboss.remoting.transport.multiplex.utility.StoppableThread; import org.jboss.remoting.transport.multiplex.utility.VirtualSelector; import javax.net.SocketFactory; import javax.net.ssl.HandshakeCompletedEvent; import javax.net.ssl.HandshakeCompletedListener; import javax.net.ssl.SSLSocket; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketTimeoutException; import java.nio.channels.Channels; import java.nio.channels.SocketChannel; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Date; 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 java.util.Timer; import java.util.TimerTask; /** * MultiplexingManager is the heart of the Multiplex system. It is the implementation * of the virtual socket group concept. See the Multiplex documentation on the * labs.jboss.org website for more information about virtual socket groups. *

          * MultiplexingManager wraps a single real java.net.Socket. * It creates the socket when it is running on the client side, and it is passed a * socket by MasterServerSocket when it is running on the server side. *

          * MultiplexingManager creates the infrastructure * which supports multiplexing, including an OutputMultiplexor output thread and one * or more InputMultiplexor input threads. When the last member leaves the socket * group, a MultiplexingManager is responsible for negotiating with its remote peer * for permission to shut down, and for tearing down the multiplexing infrastructure when * the negotiations succeed. *

          * MultiplexingManager also provides the mechanism by which a virtual socket joins * a virtual socket group, identifying the new socket to the InputMultiplexor input * thread. * *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class MultiplexingManager implements OutputMultiplexor.OutputMultiplexorClient, HandshakeCompletedListener { private static final Logger log = Logger.getLogger(MultiplexingManager.class); /** Determines how often to check that no MultiplexingManagers have been running, * in which case the static threads can be shut down. */ private static int staticThreadsMonitorPeriod; /** True if and only if the MultiplexingManager static threads are running */ private static boolean staticThreadsRunning; /** This object is used to synchronized operations on the managersByRemoteAddress map. */ private static Object shareableMapLock = new Object(); /** A HashMap> of sets of MultiplexingManager's * indexed by remote address. Holds all MultiplexingManagers whose peer has an attached * VirtualServerSocket. */ private static Map shareableManagers = new HashMap(); /** This object is used to synchronize operations on the managersByLocalAddress map. */ private static Object localAddressMapLock = new Object(); /** A HashMap> of sets of MultiplexingManager's * indexed by local address */ private static Map managersByLocalAddress = new HashMap(); /** This object is used to synchronized operations on the managersByRemoteAddress map. */ private static Object remoteAddressMapLock = new Object(); /** A HashMap> of sets of MultiplexingManager's * indexed by remote address */ // private static Map managersByRemoteAddress = Collections.synchronizedMap(new HashMap()); private static Map managersByRemoteAddress = new HashMap(); /** Set of all MultiplexingManagers */ private static Set allManagers = Collections.synchronizedSet(new HashSet()); /** InputMultiplexor in this JVM */ private static InputMultiplexor inputMultiplexor; /** OutputMultiplexor in this JVM */ private static OutputMultiplexor outputMultiplexor; /** Thread for writing to socket's OutputStream */ private static OutputMultiplexor.OutputThread outputThread; /** MultiGroupInputThread reading from socket's InputStream and distributing to virtual sockets * Processes all NIO sockets */ private static MultiGroupInputThread multiGroupInputThread; /** MultiplexingInputStreams register with virtualSelector when they have bytes to read */ private static VirtualSelector virtualSelector; /** Thread for getting asynchronous messages from remote Protocol */ private static Protocol.BackChannelThread backChannelThread; /** Holds PendingActions waiting to be performed */ private static List pendingActions = new ArrayList(); /** Removes virtual sockets from closingSockets and closes them. */ private static PendingActionThread pendingActionThread; /** Thread for stashing potentially long activities, as well as periodic activities */ private static Timer timer; /** Used to determine when to shut down static threads */ private static boolean hasBeenIdle; /** Used to distinguish the static threads in this jvm */ private final static short time = (short) System.currentTimeMillis(); /** If shutdown request is not answered within this time period, assume a problem * snd shut down. */ private int shutdownRequestTimeout; /** Determines how often ShutdownMonitorTimerTask should check for response * to ShutdownRequestThread. */ private int shutdownMonitorPeriod; /** If the peer MultiplexingManager has refused to shutdown this many times, * shut down anyway. */ private int shutdownRefusalsMaximum; /** Holds configuration parameters */ private static Map configuration = new HashMap(); /** A HashMap of VirtualSocket's indexed by local SocketId */ private Map socketMap = Collections.synchronizedMap(new HashMap()); /** A HashSet of SocketId's registered on this MultiplexingManager */ private Set registeredSockets = Collections.synchronizedSet(new HashSet()); /** A HashMap of piped OutputStreams associated with InputStreams */ private Map outputStreamMap = Collections.synchronizedMap(new HashMap()); /** A HashMap of InputStreams associated with virtual sockets */ private Map inputStreamMap = Collections.synchronizedMap(new HashMap()); /** Holds OutputStreams associated with virtual sockets */ private Set outputStreamSet = Collections.synchronizedSet(new HashSet()); /** Protocol back channel OutputStream */ private OutputStream backchannelOutputStream; /** Threads waiting to be notified of registration of remote server socket */ private Set threadsWaitingForRemoteServerSocket = new HashSet(); /** Protocol object for handling connection/disconnection communications */ private Protocol protocol; /** Actual local socket upon which this family of virtual sockets is based */ private Socket socket; /** Returned by toString() and used in log messages */ String description; /** bound state of actual local socket */ private boolean bound = false; /** connected state of actual local socket */ private boolean connected = false; /** SocketAddress of remote actual socket to which this Manager's socket is connected */ private InetSocketAddress remoteSocketAddress; /** SocketAddress to which this manager's actual socket is bound */ private InetSocketAddress localSocketAddress; /** Represents local port on which this manager's actual socket is bound, with any local address */ private InetSocketAddress localWildCardAddress; /** InputStream of real socket */ private InputStream inputStream; /** OutputStream of real socket */ private OutputStream outputStream; /** Currently registered server socket */ private ServerSocket serverSocket; /** Indicates if remote server socket has been registered */ private boolean remoteServerSocketRegistered = false; /** True if and only if this MultiplexingManager was originally created by a * call to MasterServerSocket.acceptServerSocketConnection(). */ private boolean createdForRemoteServerSocket; /** SingleGroupInputThread reading from socket's InputStream and distributing to virtual sockets */ private InputMultiplexor.SingleGroupInputThread inputThread; /** OutputStream for unknown virtual sockets */ private OutputStream deadLetterOutputStream = new ByteArrayOutputStream(); /** Manages the shutdown handshaking protocol between peer MultiplexingManagers */ private ShutdownManager shutdownManager = new ShutdownManager(); /** Thread that carries out shut down process */ private ShutdownThread shutdownThread; /** true if and only MultiplexingManager is completely shut down */ private boolean shutdown = false; /** Indicates if log trace level is enabled */ private boolean trace; /** Indicates if log debug level is enabled */ private boolean debug; /** Indicates if log info level is enabled */ private boolean info; private long id; /** SocketFactory to use for creating sockets */ private SocketFactory socketFactory; /** Saves HandshakeCompletedEvent for SSLSocket */ private HandshakeCompletedEvent handshakeCompletedEvent; /** Holds IOException thrown by real InputStream */ private IOException readException; /** Holds IOException thrown by real OutputStream */ private IOException writeException; protected synchronized static void init(Map configuration) throws IOException { try { if (staticThreadsRunning) return; log.debug("starting static threads"); // Start output thread. outputMultiplexor = new OutputMultiplexor(configuration); outputThread = outputMultiplexor.getAnOutputThread(); outputThread.setName("output:" + time); outputThread.setDaemon(true); outputThread.start(); log.debug("started output thread"); // Start input thread. inputMultiplexor = new InputMultiplexor(configuration); multiGroupInputThread = inputMultiplexor.getaMultiGroupInputThread(); multiGroupInputThread.setName("input:" + time); multiGroupInputThread.setDaemon(true); multiGroupInputThread.start(); log.debug("started input thread"); // Start back channel thread. virtualSelector = new VirtualSelector(); backChannelThread = Protocol.getBackChannelThread(virtualSelector); backChannelThread.setName("backchannel:" + time); backChannelThread.setDaemon(true); backChannelThread.start(); log.debug("started backchannel thread"); // Start timer. timer = new Timer(true); TimerTask shutdownMonitorTask = new TimerTask() { public void run() { log.trace("allManagers.isEmpty(): " + allManagers.isEmpty()); log.trace("hasBeenIdle: " + hasBeenIdle); if (allManagers.isEmpty()) { if (hasBeenIdle) { MultiplexingManager.shutdownThreads(); this.cancel(); } else hasBeenIdle = true; } else { hasBeenIdle = false; } } }; timer.scheduleAtFixedRate(shutdownMonitorTask, staticThreadsMonitorPeriod, staticThreadsMonitorPeriod); // Start pending actions thread. pendingActionThread = new PendingActionThread(); pendingActionThread.setName("pending actions:" + time); pendingActionThread.setDaemon(true); pendingActionThread.start(); log.debug("started pendingAction thread"); staticThreadsRunning = true; } catch (IOException e) { log.error(e); throw e; } } protected MultiplexingManager(Map configuration) throws IOException { if (configuration != null) MultiplexingManager.configuration.putAll(configuration); socketFactory = (SocketFactory) configuration.get(Multiplex.SOCKET_FACTORY); id = new Date().getTime(); socket = createSocket(); allManagers.add(this); if (debug) log.debug("new MultiplexingManager(" + id + "): " + description); } /** * * @param socket * @param configuration * @throws IOException */ protected MultiplexingManager(Socket socket, Map configuration) throws IOException { this.socket = socket; if (configuration != null) MultiplexingManager.configuration.putAll(configuration); id = new Date().getTime(); setup(); allManagers.add(this); if (debug) log.debug("new MultiplexingManager(" + id + "): " + description); } /** * * @param address * @param timeout * @param configuration * @throws IOException */ protected MultiplexingManager(InetSocketAddress address, int timeout, Map configuration) throws IOException { if (configuration != null) MultiplexingManager.configuration.putAll(configuration); socketFactory = (SocketFactory) configuration.get(Multiplex.SOCKET_FACTORY); id = new Date().getTime(); socket = createSocket(address, timeout); setup(); allManagers.add(this); if (debug) log.debug("new MultiplexingManager(" + id + "): " + description); } /** * */ protected synchronized void setup() throws IOException { description = socket.toString(); trace = log.isTraceEnabled(); debug = log.isDebugEnabled(); info = log.isInfoEnabled(); // Initialize MultiplexingManager parameters. initParameters(configuration); // Make sure static threads are running. synchronized (MultiplexingManager.class) { if (!staticThreadsRunning) init(configuration); } // Get InputStream and OutputStream if (socket.getChannel() == null) { // inputStream = new BufferedInputStream(socket.getInputStream()); // outputStream = new BufferedOutputStream(socket.getOutputStream()); inputStream = socket.getInputStream(); outputStream = socket.getOutputStream(); } else { inputStream = Channels.newInputStream(socket.getChannel()); outputStream = Channels.newOutputStream(socket.getChannel()); socket.setTcpNoDelay(false); } // register dead letter output stream (for unrecognized destinations) outputStreamMap.put(SocketId.DEADLETTER_SOCKET_ID, deadLetterOutputStream); // TODO: what was this for??? registeredSockets.add(SocketId.PROTOCOL_SOCKET_ID); registeredSockets.add(SocketId.SERVER_SOCKET_ID); registeredSockets.add(SocketId.SERVER_SOCKET_CONNECT_ID); registeredSockets.add(SocketId.SERVER_SOCKET_VERIFY_ID); registeredSockets.add(SocketId.BACKCHANNEL_SOCKET_ID); // set up standard piped streams getAnInputStream(SocketId.PROTOCOL_SOCKET_ID, null); getAnInputStream(SocketId.SERVER_SOCKET_ID, null); getAnInputStream(SocketId.SERVER_SOCKET_CONNECT_ID, null); getAnInputStream(SocketId.SERVER_SOCKET_VERIFY_ID, null); // Create protocol backchannel streams protocol = new Protocol(this); MultiplexingInputStream bcis = getAnInputStream(SocketId.BACKCHANNEL_SOCKET_ID, null); bcis.register(virtualSelector, this); if (debug) log.debug("registered backchannel input stream"); backchannelOutputStream = new MultiplexingOutputStream(this, SocketId.PROTOCOL_SOCKET_ID); // Register with OutputMultiplexor outputMultiplexor.register(this); // Create or register with input thread if (socket.getChannel() == null) { // start input thread log.debug("creating single group input thread"); if (inputMultiplexor == null) inputMultiplexor = new InputMultiplexor(configuration); inputThread = inputMultiplexor.getaSingleGroupInputThread(this, socket, deadLetterOutputStream); inputThread.setName(inputThread.getName() + ":input(" + description + ")"); inputThread.start(); } else { socket.getChannel().configureBlocking(false); multiGroupInputThread.registerSocketGroup(this); log.debug("registered socket group"); } registerByLocalAddress(new InetSocketAddress(socket.getLocalAddress(), socket.getLocalPort())); registerByRemoteAddress(new InetSocketAddress(socket.getInetAddress(), socket.getPort())); bound = true; connected = true; if (socket instanceof SSLSocket) { // Object o = configuration.get(Multiplex.SSL_HANDSHAKE_LISTENER); // if (o != null) // { // HandshakeCompletedListener hcl = (HandshakeCompletedListener) o; // ((SSLSocket) socket).addHandshakeCompletedListener(hcl); // } ((SSLSocket) socket).addHandshakeCompletedListener(this); } } protected void initParameters(Map configuration) { this.configuration = configuration; staticThreadsMonitorPeriod = Multiplex.getOneParameter(configuration, "staticThreadsMonitorPeriod", Multiplex.STATIC_THREADS_MONITOR_PERIOD, Multiplex.STATIC_THREADS_MONITOR_PERIOD_DEFAULT); shutdownRequestTimeout = Multiplex.getOneParameter(configuration, "shutdownRequestTimeout", Multiplex.SHUTDOWN_REQUEST_TIMEOUT, Multiplex.SHUTDOWN_REQUEST_TIMEOUT_DEFAULT); shutdownRefusalsMaximum = Multiplex.getOneParameter(configuration, "shutdownRefusalsMaximum", Multiplex.SHUTDOWN_REFUSALS_MAXIMUM, Multiplex.SHUTDOWN_REFUSALS_MAXIMUM_DEFAULT); shutdownMonitorPeriod = Multiplex.getOneParameter(configuration, "shutdownMonitorPeriod", Multiplex.SHUTDOWN_MONITOR_PERIOD, Multiplex.SHUTDOWN_MONITOR_PERIOD_DEFAULT); } /** * * @param socket * @param configuration * @return * @throws IOException * * TODO: what if multiplexor already exists? */ public static MultiplexingManager getaManager(Socket socket, Map configuration) throws IOException { log.debug("entering getaManager(Socket socket)"); return new MultiplexingManager(socket, configuration); } /** * @param address * @return * @throws IOException */ public static synchronized MultiplexingManager getaManagerByLocalAddress(InetSocketAddress address) throws IOException { return getaManagerByLocalAddress(address, null); } /** * * @param address * @param conf * @return * @throws IOException */ public static synchronized MultiplexingManager getaManagerByLocalAddress(InetSocketAddress address, Map conf) throws IOException { log.debug("entering getaManagerByLocalAddress(InetSocketAddress address)"); MultiplexingManager m = null; synchronized (localAddressMapLock) { HashSet managers = (HashSet) managersByLocalAddress.get(address); if (managers != null) { Iterator it = managers.iterator(); while (it.hasNext()) { m = (MultiplexingManager) it.next(); try { m.shutdownManager.incrementReferences(); return m; } catch (IOException e) { } } } } log.debug("There is no joinable MultiplexingManager. Creating new one."); m = new MultiplexingManager(conf); m.bind(address); return m; } /** * * @param address * @param timeout * @return * @throws IOException */ public static synchronized MultiplexingManager getaManagerByRemoteAddress(InetSocketAddress address, int timeout) throws IOException { return getaManagerByRemoteAddress(address, timeout, null); } /** * * @param address * @param timeout * @param configuration * @return * @throws IOException */ public static synchronized MultiplexingManager getaManagerByRemoteAddress(InetSocketAddress address, int timeout, Map conf) throws IOException { log.debug("entering getaManagerByRemoteAddress(InetSocketAddress address)"); // if (isOnServer()) // { // Check each of the MultiplexingManagers connected to the target remote address, looking // for one which is not shutting down. synchronized(remoteAddressMapLock) { HashSet managers = (HashSet) managersByRemoteAddress.get(address); if (managers != null && !managers.isEmpty()) { Iterator it = managers.iterator(); while (it.hasNext()) { MultiplexingManager m = (MultiplexingManager) it.next(); try { m.shutdownManager.incrementReferences(); return m; } catch (Exception e) { log.debug("manager shutting down: " + m); } } } } return new MultiplexingManager(address, timeout, conf); } /** * @param remoteAddress * @param localAddress * @param timeout * @return * @throws IOException */ public static synchronized MultiplexingManager getaManagerByAddressPair(InetSocketAddress remoteAddress, InetSocketAddress localAddress, int timeout) throws IOException { return getaManagerByAddressPair(remoteAddress, localAddress, timeout, null); } /** * @param remoteAddress * @param localAddress * @param timeout * @param configuration * @return * @throws IOException */ public static synchronized MultiplexingManager getaManagerByAddressPair(InetSocketAddress remoteAddress, InetSocketAddress localAddress, int timeout, Map conf) throws IOException { log.debug("entering getaManagerByRemoteAddress(InetSocketAddress address)"); MultiplexingManager m; // Check each of the MultiplexingManagers connected to the target remote address, looking // for one which is not shutting down. synchronized(remoteAddressMapLock) { HashSet managers = (HashSet) managersByRemoteAddress.get(remoteAddress); if (managers != null && !managers.isEmpty()) { Iterator it = managers.iterator(); while (it.hasNext()) { m = (MultiplexingManager) it.next(); if (m.getSocket().getLocalAddress().equals(localAddress.getAddress()) && m.getSocket().getLocalPort() == localAddress.getPort()) { try { m.shutdownManager.incrementReferences(); return m; } catch (Exception e) { log.debug("manager shutting down: " + m); } } } } } log.debug("There is no joinable MultiplexingManager. Creating new one."); m = new MultiplexingManager(conf); m.bind(localAddress); return m; } /** * @param address * @param timeout * @return * @throws IOException */ public static synchronized MultiplexingManager getaShareableManager(InetSocketAddress address, int timeout) throws IOException { return getaShareableManager(address, timeout, null); } /** * @param address * @param timeout * @param conf * @return * @throws IOException */ public static synchronized MultiplexingManager getaShareableManager(InetSocketAddress address, int timeout, Map conf) throws IOException { log.debug("entering getaShareableManager(InetSocketAddress address)"); // Check each of the shareable MultiplexingManagers connected to the target remote address, looking // for one which is not shutting down. synchronized(shareableMapLock) { HashSet managers = (HashSet) shareableManagers.get(address); if (managers != null && !managers.isEmpty()) { Iterator it = managers.iterator(); while (it.hasNext()) { MultiplexingManager m = (MultiplexingManager) it.next(); try { m.shutdownManager.incrementReferences(); return m; } catch (Exception e) { log.debug("manager shutting down: " + m); } } } } return new MultiplexingManager(address, timeout, conf); } /** * @param address * @param timeout * @param conf * @return * @throws IOException */ public static MultiplexingManager getAnExistingShareableManager(InetSocketAddress address, Map conf) throws IOException { log.debug("entering getAnExistingShareableManager()"); // Check each of the shareable MultiplexingManagers connected to the target remote address, looking // for one which is not shutting down. synchronized(shareableMapLock) { HashSet managers = (HashSet) shareableManagers.get(address); if (managers != null && !managers.isEmpty()) { Iterator it = managers.iterator(); while (it.hasNext()) { MultiplexingManager m = (MultiplexingManager) it.next(); try { m.shutdownManager.incrementReferences(); return m; } catch (Exception e) { log.debug("manager shutting down: " + m); } } } } return null; } /** * @param remoteAddress * @param localAddress * @param timeout * @return * @throws IOException */ public static synchronized MultiplexingManager getaShareableManagerByAddressPair(InetSocketAddress remoteAddress, InetSocketAddress localAddress, int timeout) throws IOException { return getaShareableManagerByAddressPair(remoteAddress, localAddress, timeout, null); } /** * @param remoteAddress * @param localAddress * @param timeout * @param conf * @return * @throws IOException */ public static synchronized MultiplexingManager getaShareableManagerByAddressPair(InetSocketAddress remoteAddress, InetSocketAddress localAddress, int timeout, Map conf) throws IOException { MultiplexingManager m; // Check each of the shareable MultiplexingManagers connected to the target remote address, looking // for one which is not shutting down. synchronized(shareableMapLock) { HashSet managers = (HashSet) shareableManagers.get(remoteAddress); if (managers != null && !managers.isEmpty()) { Iterator it = managers.iterator(); while (it.hasNext()) { m = (MultiplexingManager) it.next(); if (m.getSocket().getLocalAddress().equals(localAddress.getAddress()) && m.getSocket().getLocalPort() == localAddress.getPort()) { try { m.shutdownManager.incrementReferences(); return m; } catch (Exception e) { log.debug("manager shutting down: " + m); } } } } } log.debug("There is no joinable MultiplexingManager. Creating new one."); m = new MultiplexingManager(conf); m.bind(localAddress); return m; } /** * @param remoteAddress * @param localAddress * @param conf * @return * @throws IOException */ public static MultiplexingManager getAnExistingShareableManagerByAddressPair(InetSocketAddress remoteAddress, InetSocketAddress localAddress, Map conf) throws IOException { log.debug("entering getaShareableManager(InetSocketAddress address)"); MultiplexingManager m; // Check each of the shareable MultiplexingManagers connected to the target remote address, looking // for one which is not shutting down. synchronized(shareableMapLock) { HashSet managers = (HashSet) shareableManagers.get(remoteAddress); if (managers != null && !managers.isEmpty()) { Iterator it = managers.iterator(); while (it.hasNext()) { m = (MultiplexingManager) it.next(); if (m.getSocket().getLocalAddress().equals(localAddress.getAddress()) && m.getSocket().getLocalPort() == localAddress.getPort()) { try { m.shutdownManager.incrementReferences(); return m; } catch (Exception e) { log.debug("manager shutting down: " + m); } } } } } return null; } /** * @param address * @return * @throws IOException */ public static boolean checkForShareableManager(InetSocketAddress address) throws IOException { log.debug("entering checkForShareableManager(InetSocketAddress address)"); // Check each if there is at least one shareable MultiplexingManagers connected to the target remote address. synchronized (shareableMapLock) { HashSet managers = (HashSet) shareableManagers.get(address); if (managers != null && !managers.isEmpty()) return true; return false; } } /** * @param localAddress * @param remoteAddress * @return */ public static boolean checkForManagerByAddressPair(InetSocketAddress localAddress, InetSocketAddress remoteAddress) { log.debug("entering checkForManagerByAddressPair()"); // Check each of the MultiplexingManagers connected to the target remote address, looking // for one bound to the local address. synchronized(remoteAddressMapLock) { HashSet managers = (HashSet) managersByRemoteAddress.get(remoteAddress); if (managers != null && !managers.isEmpty()) { Iterator it = managers.iterator(); while (it.hasNext()) { MultiplexingManager m = (MultiplexingManager) it.next(); if (m.localSocketAddress.equals(localAddress)) return true; } } } return false; } /** * @param localAddress * @param remoteAddress * @return */ public static boolean checkForShareableManagerByAddressPair(InetSocketAddress localAddress, InetSocketAddress remoteAddress) { log.debug("entering checkForShareableManagerByAddressPair()"); // Check each of the shareable MultiplexingManagers connected to the target remote address, looking // for one bound to the local address. synchronized (shareableMapLock) { HashSet managers = (HashSet) shareableManagers.get(remoteAddress); if (managers != null && !managers.isEmpty()) { Iterator it = managers.iterator(); while (it.hasNext()) { MultiplexingManager m = (MultiplexingManager) it.next(); if (m.localSocketAddress.equals(localAddress)) return true; } } } return false; } /** * @return */ public static int getStaticThreadMonitorPeriod() { return staticThreadsMonitorPeriod; } /** * @param period */ public static void setStaticThreadsMonitorPeriod(int period) { staticThreadsMonitorPeriod = period; } /** * */ protected synchronized static void shutdownThreads() { log.debug("entering shutdownThreads"); if (outputThread != null) outputThread.shutdown(); if (multiGroupInputThread != null) multiGroupInputThread.shutdown(); if (backChannelThread != null) backChannelThread.shutdown(); if (pendingActionThread != null) pendingActionThread.shutdown(); log.debug("cancelling timer"); if (timer != null) timer.cancel(); while (true) { try { if (outputThread != null) outputThread.join(); if (multiGroupInputThread != null) multiGroupInputThread.join(); if (backChannelThread != null) backChannelThread.join(); if (pendingActionThread != null) pendingActionThread.join(); break; } catch (InterruptedException ignored) {} } staticThreadsRunning = false; log.debug("static threads shut down"); } /** * Adds a PendingAction to the list of actions waiting to be executed. * @param pendingAction */ protected static void addToPendingActions(PendingAction pendingAction) { synchronized (pendingActions) { pendingActions.add(pendingAction); pendingActions.notifyAll(); } } /** * Binds the wrapped socket. * @param address * @throws IOException */ public synchronized void bind(InetSocketAddress address) throws IOException { if (bound) throw new IOException("socket is already bound"); if (socket == null) socket = createSocket(); if (socket == null) localSocketAddress = address; else socket.bind(address); bound = true; } /** * Connects the wrapped socket. * @param address * @param timeout * @throws IOException */ public synchronized void connect(InetSocketAddress address, int timeout) throws IOException { if (connected) { if (socket.getRemoteSocketAddress().equals(address)) return; else throw new IOException("socket is already connected"); } if (debug) log.debug("connecting to: " + address); if (socket == null) socket = createSocket(address, timeout); else socket.connect(address, timeout); connected = true; setup(); } /** * Identifies a VirtualServerSocket as the one associated with this virtual socket group. * @return a MultiplexingInputStream for use by serverSocket. */ public synchronized MultiplexingInputStream registerServerSocket(ServerSocket serverSocket) throws IOException { if (this.serverSocket != null && this.serverSocket != serverSocket) { log.error("[" + id + "]: " + "attempt to register a second server socket"); log.error("current server socket: " + this.serverSocket.toString()); log.error("new server socket: " + serverSocket.toString()); throw new IOException("attempt to register a second server socket"); } if (debug) log.debug(serverSocket.toString()); this.serverSocket = serverSocket; return getAnInputStream(SocketId.SERVER_SOCKET_ID, null); } /** * Indicates a VirtualServerSocket is leaving this virtual socket group. * @param serverSocket * @throws IOException */ public synchronized void unRegisterServerSocket(ServerSocket serverSocket) throws IOException { if (this.serverSocket != serverSocket) { log.error("server socket attempting unregister but is not registered"); throw new IOException("server socket is not registered"); } log.debug("server socket unregistering"); removeAnInputStream(SocketId.SERVER_SOCKET_ID); this.serverSocket = null; shutdownManager.decrementReferences(); } /** * Adds a VirtualSocket to this virtual socket group. * @param socket * @return a MultiplexingInputStream for use by socket * @throws IOException */ public synchronized MultiplexingInputStream registerSocket(VirtualSocket socket) throws IOException { SocketId localSocketId = socket.getLocalSocketId(); VirtualSocket currentSocket = (VirtualSocket) socketMap.put(localSocketId, socket); if (currentSocket != null) { String errorMessage = "attempting to register socket on currently used port:" + currentSocket.getLocalVirtualPort(); log.error(errorMessage); throw new IOException(errorMessage); } if (debug) log.debug("registering virtual socket on port: " + localSocketId.getPort()); registeredSockets.add(socket.getLocalSocketId()); return getAnInputStream(localSocketId, socket); } /** * Indicates that a VirtualSocket is leaving a virtual socket group. * @param socket * @throws IOException */ public synchronized void unRegisterSocket(VirtualSocket socket) throws IOException { try { if (debug) log.debug(this + ": entering unRegisterSocket()"); shutdownManager.decrementReferences(); SocketId localSocketId = socket.getLocalSocketId(); if (localSocketId == null) return; VirtualSocket currentSocket = (VirtualSocket) socketMap.remove(localSocketId); if (currentSocket == null) { String errorMessage = "attempting to unregister unrecognized socket: " + socket.getLocalSocketId().getPort(); log.error(errorMessage); throw new IOException(errorMessage); } if (debug) log.debug("unregistering virtual socket on port: " + localSocketId.getPort()); registeredSockets.remove(localSocketId); removeAnInputStream(localSocketId); if (debug) log.debug(this + ": leaving unRegisterSocket()"); } finally { socket.close(); } } /** * Indicates that a VirtualServerSocket belongs the virtual socket group at the * remote end of the connection. This virtual socket groupD becomes "joinable", in the * sense that a new VirtualSocket v can join this virtual group because there is a * VirtualServerSocket at the other end of the connection to create a remote peer for * v. */ public synchronized void registerRemoteServerSocket() throws IOException { log.debug("registerRemoteServerSocket()"); if (remoteServerSocketRegistered) { log.error("duplicate remote server socket registration"); throw new IOException("duplicate remote server socket registration"); } else { remoteServerSocketRegistered = true; // Now that remote MultiplexingManager has a VirtualServerSocket, we // add it to set of managers eligible to accept new clients. registerShareable(remoteSocketAddress); synchronized (threadsWaitingForRemoteServerSocket) { threadsWaitingForRemoteServerSocket.notifyAll(); } if (!createdForRemoteServerSocket) incrementReferences(); } } /** * Indicates there will no longer be a VirtualServeSocket at the remote end of * this connection. This virtual socket group will no longer be "joinable". * (See registerRemoteServerSocket().) */ public synchronized void unRegisterRemoteServerSocket() { if (!remoteServerSocketRegistered) log.error("no remote server socket is registered"); else { if (debug) log.debug(this + ": remote VSS unregistering"); remoteServerSocketRegistered = false; unregisterShareable(); MultiplexingManager.addToPendingActions ( new PendingAction() { void doAction() { try { decrementReferences(); } catch (IOException e) { log.error(e); } } } ); } } public void setCreatedForRemoteServerSocket() { createdForRemoteServerSocket = true; } public synchronized boolean isRemoteServerSocketRegistered() { return remoteServerSocketRegistered; } public boolean waitForRemoteServerSocketRegistered() { if (remoteServerSocketRegistered) return true; synchronized (threadsWaitingForRemoteServerSocket) { threadsWaitingForRemoteServerSocket.add(Thread.currentThread()); while (!remoteServerSocketRegistered) { try { threadsWaitingForRemoteServerSocket.wait(); } catch (InterruptedException e) { log.info("interrupted waiting for registration of remote server socket"); if (shutdown) { threadsWaitingForRemoteServerSocket.remove(Thread.currentThread()); return false; } } } } threadsWaitingForRemoteServerSocket.remove(Thread.currentThread()); return true; } /** * Increment reference counter for this MultiplexingManager. * @throws IOException */ public void incrementReferences() throws IOException { shutdownManager.incrementReferences(); } /** * Decrement reference counter for this MultiplexingManager. * @throws IOException */ public void decrementReferences() throws IOException { shutdownManager.decrementReferences(); } /** * * @return */ public Collection getAllOutputStreams() { return outputStreamMap.values(); } /** * Returns OutputStream to use when corrupted InputStream gives no known "mailbox" * @return OutputStream to use when corrupted InputStream gives no known "mailbox" */ public OutputStream getDeadLetterOutputStream() { return deadLetterOutputStream; } /** * Returns InputStream of real socket * @return InputStream of real socket */ public InputStream getInputStream() { return inputStream; } /** * Returns OutputStream of real socket * @return OutputStream of real socket */ public OutputStream getOutputStream() { return outputStream; } /** * Get an InputStream for a VirtualSocket. * @param socketId * @param socket * @return * @throws IOException */ public MultiplexingInputStream getAnInputStream(SocketId socketId, VirtualSocket socket) throws IOException { if (debug) log.debug("getAnInputStream(): " + socketId.getPort()); MultiplexingInputStream mis = (MultiplexingInputStream) inputStreamMap.get(socketId); if (mis != null) { if (mis.getSocket() == null) mis.setSocket(socket); return mis; } GrowablePipedOutputStream pos = (GrowablePipedOutputStream) outputStreamMap.get(socketId); if (pos == null) { pos = new GrowablePipedOutputStream(); outputStreamMap.put(socketId, pos); } mis = new MultiplexingInputStream(pos, this, socket); inputStreamMap.put(socketId, mis); if (readException != null) mis.setReadException(readException); return mis; } /** * Get an OutputStrem for a VirtualSocket. * @param socketId * @return */ public GrowablePipedOutputStream getAnOutputStream(SocketId socketId) { if (debug) log.debug("getAnOutputStream(): " + socketId.getPort()); GrowablePipedOutputStream pos = (GrowablePipedOutputStream) outputStreamMap.get(socketId); if (pos == null) { pos = new GrowablePipedOutputStream(); outputStreamMap.put(socketId, pos); } return pos; } /** * @param socketId * @return */ public MultiplexingOutputStream getAnOutputStream(VirtualSocket socket, SocketId socketId) { MultiplexingOutputStream mos = new MultiplexingOutputStream(this, socket, socketId); outputStreamSet.add(mos); if (writeException != null) mos.setWriteException(writeException); return mos; } /** * Returns a GrowablePipedOutputStream that is connected to a * MultiplexingInputStream. * It will create the MultiplexingInputStream if necessary. This method exists to * allow InputMultiplexor to get a place to put bytes directed to an unrecognized * SocketId, which might be necessary if the remote socket starts writing before this * end of the connection is ready. Originally, we had a three step handshake, in which * (1) the client socket sent a "connect" message, (2) the server socket sent a "connected" * message, and (3) the client socket sent a "connect verify" message. In the interests * of performance we eliminated the final step. * * @param socketId * @return * @throws IOException */ public GrowablePipedOutputStream getConnectedOutputStream(SocketId socketId) throws IOException { if (debug) log.debug("getConnectedOutputStream(): " + socketId.getPort()); MultiplexingInputStream mis = (MultiplexingInputStream) inputStreamMap.get(socketId); if (mis != null) { GrowablePipedOutputStream pos = (GrowablePipedOutputStream) outputStreamMap.get(socketId); if (pos == null) { StringBuffer message = new StringBuffer(); message.append("MultiplexingInputStream exists ") .append("without matching GrowablePipedOutputStream: ") .append("socketId = ").append(socketId); throw new IOException(message.toString()); } return pos; } GrowablePipedOutputStream pos = (GrowablePipedOutputStream) outputStreamMap.get(socketId); if (pos == null) { pos = new GrowablePipedOutputStream(); outputStreamMap.put(socketId, pos); } mis = new MultiplexingInputStream(pos, this); inputStreamMap.put(socketId, mis); return pos; } /** * @return */ public OutputStream getBackchannelOutputStream() { return backchannelOutputStream; } /** * @return handshakeCompletedEvent */ public HandshakeCompletedEvent getHandshakeCompletedEvent() { return handshakeCompletedEvent; } /** * * @return */ public OutputMultiplexor getOutputMultiplexor() { return outputMultiplexor; } /** * * @param socketId * @return */ public OutputStream getOutputStreamByLocalSocket(SocketId socketId) { return (OutputStream) outputStreamMap.get(socketId); } /** * * @return */ public Protocol getProtocol() { return protocol; } /** * @return */ public synchronized ServerSocket getServerSocket() { return serverSocket; } /** * * @return */ public Socket getSocket() { return socket; } /** * * @param socketId * @return */ public VirtualSocket getSocketByLocalPort(SocketId socketId) { return (VirtualSocket) socketMap.get(socketId); } /** * @return */ public SocketFactory getSocketFactory() { return socketFactory; } /** * To implement HandshakeCompletedListener interface. */ public void handshakeCompleted(HandshakeCompletedEvent event) { description = socket.toString(); handshakeCompletedEvent = event; Object obj = configuration.get(Multiplex.SSL_HANDSHAKE_LISTENER); if (obj != null) { HandshakeCompletedListener listener = (HandshakeCompletedListener) obj; listener.handshakeCompleted(event); } } /** * @return */ public boolean isBound() { return bound; } /** * @return */ public boolean isConnected() { return connected; } /** * @return */ public synchronized boolean isServerSocketRegistered() { return serverSocket != null; } /** * */ public boolean isShutdown() { return shutdown; } /** * * @param socketId * @return * TODO: isn't used */ public synchronized boolean isSocketRegistered(SocketId socketId) { return registeredSockets.contains(socketId); } /** * @return */ public boolean respondToShutdownRequest() { return shutdownManager.respondToShutdownRequest(); } /** * @param socketFactory */ public void setSocketFactory(SocketFactory socketFactory) { this.socketFactory = socketFactory; } /** * @return */ public int getShutdownMonitorPeriod() { return shutdownMonitorPeriod; } /** * @return */ public int getShutdownRefusalsMaximum() { return shutdownRefusalsMaximum; } /** * @return */ public int getShutdownRequestTimeout() { return shutdownRequestTimeout; } /** * @param timeout */ public void setShutdownRequestTimeout(int timeout) { shutdownRequestTimeout = timeout; } /** * @param maximum */ public void setShutdownRefusalsMaximum(int maximum) { shutdownRefusalsMaximum = maximum; } /** * @param period */ public void setShutdownMonitorPeriod(int period) { shutdownMonitorPeriod = period; } /** * Needed to implement OutputMultiplexor.OutputMultiplexorClient */ public synchronized void outputFlushed() { if (shutdownThread != null) shutdownThread.setSafeToShutdown(true); notifyAll(); } public String toString() { if (description != null) return description; return super.toString(); } /******************************************************************************************** * protected methods and classes ********************************************************************************************/ protected Socket createSocket(InetSocketAddress endpoint, int timeout) throws IOException { Socket socket = null; if (localSocketAddress == null) { if (socketFactory != null) socket = socketFactory.createSocket(endpoint.getAddress(), endpoint.getPort()); else socket = SocketChannel.open(endpoint).socket(); } else { // It's possible that bind() was called, but a socket hasn't been created yet, since // SSLSocketFactory will not create an unconnected socket. In that case, bind() just // saved localSocketAddress for later use. if (socketFactory != null) socket = socketFactory.createSocket(endpoint.getAddress(), endpoint.getPort(), localSocketAddress.getAddress(), localSocketAddress.getPort()); else { socket = SocketChannel.open().socket(); socket.bind(localSocketAddress); socket.connect(endpoint); } } if (socket instanceof SSLSocket) { // Object o = configuration.get(Multiplex.SSL_HANDSHAKE_LISTENER); // if (o != null) // { // HandshakeCompletedListener hcl = (HandshakeCompletedListener) o; // ((SSLSocket) socket).addHandshakeCompletedListener(hcl); // } ((SSLSocket) socket).addHandshakeCompletedListener(this); } socket.setSoTimeout(timeout); return socket; } protected Socket createSocket() throws IOException { Socket socket = null; try { if (socketFactory != null) socket = socketFactory.createSocket(); else socket = SocketChannel.open().socket(); if (socket instanceof SSLSocket) { // Object o = configuration.get(Multiplex.SSL_HANDSHAKE_LISTENER); // if (o != null) // { // HandshakeCompletedListener hcl = (HandshakeCompletedListener) o; // ((SSLSocket) socket).addHandshakeCompletedListener(hcl); // } ((SSLSocket) socket).addHandshakeCompletedListener(this); } } catch (IOException e) { if ("Unconnected sockets not implemented".equals(e.getMessage())) return null; throw e; } return socket; } /** * @param address */ protected void registerByLocalAddress(InetSocketAddress address) { synchronized (localAddressMapLock) { localSocketAddress = address; HashSet managers = (HashSet) managersByLocalAddress.get(address); if (managers == null) { managers = new HashSet(); managersByLocalAddress.put(address, managers); } managers.add(this); // allow searching on any local address localWildCardAddress = new InetSocketAddress(address.getPort()); managers = (HashSet) managersByLocalAddress.get(localWildCardAddress); if (managers == null) { managers = new HashSet(); managersByLocalAddress.put(localWildCardAddress, managers); } managers.add(this); } } /** * */ protected void unregisterByLocalAddress() { synchronized (localAddressMapLock) { HashSet managers = null; if (localSocketAddress != null) { managers = (HashSet) managersByLocalAddress.get(localSocketAddress); if (managers != null) { managers.remove(this); if (managers.isEmpty()) managersByLocalAddress.remove(localSocketAddress); } } if (localWildCardAddress != null) { managers = (HashSet) managersByLocalAddress.get(localWildCardAddress); if (managers != null) { managers.remove(this); if (managers.isEmpty()) managersByLocalAddress.remove(localWildCardAddress); } } } } /** * * @param address */ protected void registerByRemoteAddress(InetSocketAddress address) { remoteSocketAddress = address; synchronized (remoteAddressMapLock) { HashSet managers = (HashSet) managersByRemoteAddress.get(address); if (managers == null) { managers = new HashSet(); managers.add(this); managersByRemoteAddress.put(address, managers); } else managers.add(this); } } /** * */ protected void unregisterByRemoteAddress() { if (remoteSocketAddress != null) { synchronized (remoteAddressMapLock) { HashSet managers = (HashSet) managersByRemoteAddress.get(remoteSocketAddress); if (managers != null) { managers.remove(this); if (managers.isEmpty()) managersByRemoteAddress.remove(remoteSocketAddress); } } } } /** * * @param address */ protected void registerShareable(InetSocketAddress address) { if (debug) log.debug("registering as shareable: " + this + ": " + address.toString()); synchronized (shareableMapLock) { HashSet managers = (HashSet) shareableManagers.get(address); if (managers == null) { managers = new HashSet(); managers.add(this); shareableManagers.put(address, managers); } else managers.add(this); } } /** * */ protected void unregisterShareable() { if (debug) log.debug("unregistering remote: " + this + ": " + description); if (remoteSocketAddress != null) { synchronized (shareableMapLock) { HashSet managers = (HashSet) shareableManagers.get(remoteSocketAddress); if (managers != null) { managers.remove(this); if (managers.isEmpty()) shareableManagers.remove(remoteSocketAddress); } } } } /* * */ protected void unregisterAllMaps() { unregisterByLocalAddress(); unregisterByRemoteAddress(); unregisterShareable(); } /** * @param socketId */ protected void removeAnInputStream(SocketId socketId) { if (debug) log.debug("entering removeAnInputStream(): " + socketId.getPort()); InputStream is = (InputStream) inputStreamMap.remove(socketId); OutputStream os = (OutputStream) outputStreamMap.remove(socketId); if (is != null) { try { is.close(); } catch (Exception ignored) { log.error("error closing PipedInputStream (" + socket.getPort() + ")", ignored); } } if (os != null) { try { os.close(); } catch (Exception ignored) { log.error("error closing PipedOutputStream (" + socket.getPort() + ")", ignored); } } } protected void setReadException(IOException e) { // Note. It looks like there could be a race between setReadException() and // getAnInputStream(). However, suppose getAnInputStream() gets to its test // (readException != null) before readException is set here. Then if it created a // new InputStream "is", setReadException() will see "is" in inputStreamMap and will // set its read exception. Suppose getAnInputStream gets to its test // (readException != null) after setReadException() sets readException. Then // if it created a new InputStream "is", it will set the read exception for "is". // Remove from shareable map (if it's in map). unregisterAllMaps(); notifySocketsOfException(); // Unregister with input thread. if (multiGroupInputThread != null) multiGroupInputThread.unregisterSocketGroup(this); readException = e; HashSet tempSet; synchronized (inputStreamMap) { tempSet = new HashSet(inputStreamMap.values()); } Iterator it = tempSet.iterator(); while (it.hasNext()) { MultiplexingInputStream is = (MultiplexingInputStream) it.next(); is.setReadException(e); } } protected void setWriteException(IOException e) { // Note. See Note in setReadException(). // If this connection is unusable, take out of shareable map (if it's in shareable map). unregisterAllMaps(); notifySocketsOfException(); // Unregister with output thread. outputMultiplexor.unregister(this); writeException = e; HashSet tempSet; synchronized (outputStreamMap) { tempSet = new HashSet(outputStreamSet); } Iterator it = tempSet.iterator(); while (it.hasNext()) { MultiplexingOutputStream os = (MultiplexingOutputStream) it.next(); os.setWriteException(e); } } protected void notifySocketsOfException() { synchronized (socketMap) { Iterator it = socketMap.values().iterator(); while (it.hasNext()) ((VirtualSocket) it.next()).notifyOfException(); } } protected void setEOF() { // Note. See Note in setReadException(). log.debug("setEOF()"); HashSet tempSet; synchronized (inputStreamMap) { tempSet = new HashSet(inputStreamMap.values()); } Iterator it = tempSet.iterator(); while (it.hasNext()) { MultiplexingInputStream is = (MultiplexingInputStream) it.next(); try { is.handleRemoteShutdown(); } catch (IOException e) { log.error(e); } } } /** * */ protected synchronized void shutdown() { if (debug) log.debug(description + ": entering shutdown()"); shutdownThread = new ShutdownThread(); shutdownThread.setName(shutdownThread.getName() + ":shutdown"); shutdownThread.start(); } /** * The motivation behind this class is to prevent the following problem. Suppose MultiplexingManager A * is connected to MultiplexingManager B, and A decides to shut down. Suppose A shuts down before B knows A * is shutting down, and suppose a VirtualSocket C starts up, finds B, and attaches itself to B. Then C * will have "died a-borning," in the words of Tom Paxton. We need a handshake protocol to ensure a * proper shutdown process. In the following, let A be the local MultiplexingManager and let B be its * remote peer. * * There are two forms of synchronization in ShutdownManager. incrementReferences() and decrementReferences() * maintain the reference count to its MultiplexingManager, and of course the changes to variable * referenceCount have to be synchronized. Parallel to incrementReferences() and decrementReferences() are * the pair of methods reseverManager() and unreserveManager(), which are similar but intended for holding a * MultiplexingManger for more temporary applications. See, for example, getaManagerByRemoteAddress(). * * There is also a need for distributed synchronization. When decrementReferences() on A decrements the * referenceCount to 0, it indicates to B the desire of A to shut down. Since all of the virtual sockets * on A are connected to virtual sockets on B, normally the request would be honored. However, if a new virtual * socket attaches itself to B, then it would have > 0 clients, and it would refuse the request to shut down. * In any case, the request is made through Protocol.requestManagerShutdown(), which results in a call to * ShutdownManager.respondToShutdownRequest() on B, which is synchronized since it reads the * readyToShutdown variable, which is modified by decrementReferences(). Here lies the danger of * distributed deadlock. If decrementReferences() on A and B both start executing at about the same time, they * would both be waiting for a response from respondToShutdownRequest(). But each respondToShutdownRequest() * would be locked out because each decrementReferences() is blocked on i/o. * * The solution is to put the i/o operation in a separate thread, ShutdownRequestThread, and have decrementReferences() * enter a wait state, allowing respondToShutdownRequest() to execute. So, on each end respondToShutdownRequest() * will return an answer ("go ahead and shut down", in particular), and each ShutdownRequestThread.run() will wake up * the waiting decrementReferences(), which will then run to completion. * * Note also that while decrementReferences() is waiting, incrementReferences() can run. However, before it waits, * decrementReferences() sets the shutdownRequestInProgress flag, and if incrementReferences() finds the flag set, it * will also enter a wait state and will take no action until the outstanding shutdown request is accepted or * rejected. * * Another issue is what to do if MultiplexingManager B responds negatively to A's request to shut down, not * because it has a new client but simply because some of its virtual sockets just haven't gotten around to * closing yet. When B's referenceCount finally goes to 0, it will send a shutdown request to A, and if A's * referenceCount is still 0, B will shut down. But what about B? If decrementReferences() gets a negative * response, it will start up a ShutdownMonitorThread, which, as long as readyToShutdown remains true, will * periodically check to see if remoteShutdown has been set to true. If it has, ShutdownMonitorThread * initiates the shut down of its enclosing MultiplexingManager. * * reserveManager() interacts with decrementReferences() by preventing decrementReferences() from committing to * shutting down. If reserveManager() runs first, it sets the flag reserved to true, which causes * decrementReferences() to return without checking for referenceCount == 0. If decrementReferences() runs * first and finds referenceCount == 0 and gets a positve response from the remote manager, then reserveManager() * will throw an IOException. But if decrementReferences() gets a negative response, it will start up a * ShutdownMonitorThread, which runs as long as the flag readyToShutdown is true. But reserveManager() will * set readyToShutdown to false, ending the ShutdownMonitorThread. When unreserveManager() eventually runs * and sees referenceCount == 0, it will increment referenceCount and call decrementReferences(), allowing the * shutdown attempt to proceed anew. Note that when incrementReferences() runs successfully, it sets the flag * reserved to false, since incrementing referenceCount will also keep the MultiplexingManager alive. */ protected class ShutdownManager { /** referenceCount keeps track of the number of clients of ShutdownManager's enclosing * MultiplexingManager. */ private int referenceCount = 1; /** reserved is set to true to prevent the manager from shutting down without incrementing * the reference count. */ private boolean reserved = false; /** shutdownRequestInProgress remains true while a remote shutdown request is pending */ private boolean shutdownRequestInProgress = false; /** readyToShutdown is set to true as long as long as referenceCount == 0. It is interpreted * by respondToShutdownRequest() as the local manager's willingness to shut down. */ private boolean readyToShutdown = false; /** shutdownMonitorThread holds a reference to the most recently created ShutdownMonitorThread. */ // ShutdownMonitorThread shutdownMonitorThread; ShutdownMonitorTimerTask shutdownMonitorTimerTask; /** shutdown is set to true when the irrevocable decision has been made to shut down. Once it * is set to true, it is never set to false. */ private boolean shutdown = false; /** remoteShutdown is set to true when the remote manager makes a shutdown request and * respondToShutdownRequest(), its agent for the request, discovers that the local manager * is also willing to shut down. It represents the fact that the remote manager will respond * by deciding to shut down. */ private boolean remoteShutdown = false; /** shutdownHandled is set to true when ShutdownMonitorTimerTask begins the * shut down process */ private boolean shutdownHandled; /** requestShutdownFailed is true if and only if ShutdownRequestThread's attempt * to get a response to a shut down request failed */ private boolean requestShutdownFailed; private class ShutdownRequestThread extends Thread { public ShutdownRequestThread() { shutdownRequestInProgress = true; } public void run() { try { // Note. The timeout for Protocol's input stream should be longer than the // time spent in decrementReferences() or by ShutdownMonitorTimerTask waiting // for a response. shutdown = protocol.requestManagerShutdown(shutdownRequestTimeout * 2); if (debug) log.debug("shutdown: " + shutdown); } catch (SocketTimeoutException e) { requestShutdownFailed = true; log.debug("socket timeout exception in manager shutdown request"); } catch (Exception e) { requestShutdownFailed = true; log.debug("i/o exception in manager shutdown request", e); } if (debug) log.debug("ShutdownRequestThread.run() done: " + shutdown); shutdownRequestInProgress = false; synchronized(ShutdownManager.this) { ShutdownManager.this.notifyAll(); } } } /** * It is possible,due to a race condition, for there to be multiple ShutdownMonitorThreads running. * In particular, suppose *

          *

            *
          1. decrementReferences() starts a ShutdownMonitorThread T1, *
          2. reserverManager() runs and calls T1.terminate(), *
          3. unreserveManager() runs, sees referenceCount == 0, and calls decrementReferences(), *
          4. decrementReferences() creates a new ShutdownMonitorThread T2, *
          5. T1 leaves sleep(1000) finds remoteShutdown == true and calls shutdown(), and *
          6. T2 finds remoteShutdown == true. *
          *

          * For this reason, we turn on shutdown before calling shutdown() in T1, so that T2 will * not call shutdown(). * */ // private class ShutdownMonitorThread extends Thread // { // boolean running = true; // // public void terminate() // { // running = false; // } // // public void run() // { // log.debug(socket.toString() + ": entering ShutdownMonitorThread"); // // while (running) // { // try // { // sleep(1000); // } // catch (InterruptedException ignored) {} // // synchronized (ShutdownManager.this) // { // if (readyToShutdown && remoteShutdown && !shutdown) // { // log.debug("ShutdownMonitorThread: found remoteShutdown == true"); // shutdown = true; // shutdown(); // ShutdownManager.this.notifyAll(); // return; // } // } // } // } // } private class ShutdownMonitorTimerTask extends TimerTask { int count; boolean cancelled; public boolean cancel() { log.debug("cancelling ShutdownMonitorTimerTask"); cancelled = true; return super.cancel(); } public void run() { if (debug) log.debug(description + ": entering ShutdownMonitorTimerTask"); count++; synchronized (ShutdownManager.this) { // Another ShutdownMonitorTimerTask got here first. if (shutdownHandled) { if (debug) log.debug(description + ": shutdownHandled == true"); cancel(); } // ShutdownRequestThread got a positive response. else if (shutdown) { if (debug) log.debug(description + ": shutdown is true"); shutdownHandled = true; shutdown(); cancel(); } // Peer MultiplexingManager requested shutdown consent. else if (readyToShutdown && remoteShutdown) { if (debug) log.debug(description + ": ShutdownMonitorTimerTask: found remoteShutdown == true"); shutdown = true; shutdownHandled = true; shutdown(); ShutdownManager.this.notifyAll(); cancel(); } // Timeout (or other error) in ShutdownRequestThread else if (requestShutdownFailed) { if (debug) log.debug(description + ": ShutdownMonitorTimerTask: found requestShutdownFailed == true"); shutdown = true; shutdownHandled = true; shutdown(); ShutdownManager.this.notifyAll(); cancel(); } // Count of peer MultiplexingManager refusals has reached maximum. // Assume peer is hung up somehow and shut down. else if (count > shutdownRefusalsMaximum) { if (debug) log.debug(description + ": ShutdownMonitorTimerTask: " + "shutdown refusal count exceeded maximut: " + shutdownRefusalsMaximum); shutdown = true; shutdownHandled = true; shutdown(); ShutdownManager.this.notifyAll(); cancel(); } // ShutdownRequestThread is still running. else if (shutdownRequestInProgress) { if (debug) log.debug(description + ": shutdownRequestInProgress == true"); return; } // ShutdownRequestThread got a negative response. If we haven't been cancelled // yet, we still are trying to shut down. Ask again. else { // Note. The timeout for Protocol's input stream should be longer than the // time spent waiting for a response. ShutdownRequestThread shutdownRequestThread = new ShutdownRequestThread(); shutdownRequestThread.setName(shutdownRequestThread.getName() + ":shutdownRequest:" + time); shutdownRequestThread.setDaemon(true); if (debug) log.debug(description + ": starting ShutdownRequestThread: " + shutdownRequestThread.toString()); shutdownRequestThread.start(); } } } public String toString() { return "shutdownRequest:" + time; } } /** * * @throws IOException */ public synchronized void reserveManager() throws IOException { if (debug) log.debug(description + referenceCount); // If decrementReferences() grabbed the lock first, set referenceCount to 0, and initiated a // remote shutdown request, wait until the answer comes back. while (shutdownRequestInProgress) { try { wait(); } catch (InterruptedException e) { // shouldn't happen log.error("interruption in ShutdownRequestThread"); } } // 1. shutdown is true if and only if (a) ShutdownRequestThread returned an indication that the // remote manager is shutting down, or (b) the wait() in decrementReferences() for the return // of ShutdownRequestThread timed out and decrementReferences() set shutdown to true; // 2. remoteShutdown is true if and only if the remote manager initiated a shutdown request // which found that the local manager was ready to shut down. In this case, the remote // manager would go ahead and shut down, and the local manager will inevitably shutdown as well. if (shutdown || remoteShutdown) throw new IOException("manager shutting down"); readyToShutdown = false; reserved = true; // if (shutdownMonitorThread != null) // shutdownMonitorThread.terminate(); if (shutdownMonitorTimerTask != null) shutdownMonitorTimerTask.cancel(); // wake up decrementReferences() if it is waiting notifyAll(); } /** * */ public synchronized void unreserveManager() { if (debug) log.debug(description + referenceCount); if (!reserved) { log.error("attempting to unreserve a MultiplexingManager that was not reserved: " + description); return; } reserved = false; // If referenceCount == 0, it is because it was decremented by decrementReferences(). But if // reserveManager() was able to run, it was because decrementReferences() did not succeed in // negotiating a shutdown. Either it found reserved == true and gave up, or it received a // negative reply from the remote manager and started up a ShutdownMonitorThread, which would // have terminated when reserveManager() set readyToShutdown to false. It is therefore // appropriate to give decrementReferences() another opportunity to shut down. if (referenceCount == 0) { referenceCount++; decrementReferences(); } } /** * */ public synchronized void incrementReferences() throws IOException { if (debug) log.debug(description + referenceCount); // If decrementReferences() grabbed the lock first, set referenceCount to 0, and initiated a // remote shutdown request, wait until the answer comes back. while (shutdownRequestInProgress) { try { wait(); } catch (InterruptedException e) { // shouldn't happen log.error("interruption in ShutdownRequestThread"); } } // 1. shutdown is true if and only if (a) ShutdownRequestThread returned an indication that the // remote manager is shutting down, or (b) the wait() in decrementReferences() for the return // of ShutdownRequestThread timed out and decrementReferences() set shutdown to true; // 2. remoteShutdown is true if and only if the remote manager initiated a shutdown request // which found that the local manager was ready to shut down. In this case, the remote // manager would go ahead and shut down, and the local manager will inevitably shutdown as well. if (shutdown || remoteShutdown) throw new IOException("not accepting new clients"); readyToShutdown = false; reserved = false; referenceCount++; if (debug) log.debug(description + referenceCount); // if (shutdownMonitorThread != null) // shutdownMonitorThread.terminate(); if (shutdownMonitorTimerTask != null) shutdownMonitorTimerTask.cancel(); // wake up decrementReferences() if it is waiting notifyAll(); } /** * */ public synchronized void decrementReferences() { referenceCount--; if (debug) log.debug(description + referenceCount); if (reserved) { if (debug) log.debug(description + ": reserved == true"); return; } if (referenceCount == 0) { readyToShutdown = true; if (isConnected()) { ShutdownRequestThread shutdownRequestThread = new ShutdownRequestThread(); shutdownRequestThread.setName(shutdownRequestThread.getName() + ":shutdownRequest:" + time); shutdownRequestThread.setDaemon(true); if (debug) log.debug(description + "starting ShutdownRequestThread: " + shutdownRequestThread.toString()); shutdownRequestThread.start(); try { // Note. The timeout for Protocol's input stream should be longer than the // time spent waiting for a response. wait(shutdownRequestTimeout); } catch (InterruptedException e) { // shouldn't happen log.error("interrupt in ShutdownRequestThread"); } if (log.isDebugEnabled()) { log.debug(description + shutdown); log.debug(description + shutdownRequestThread.isAlive()); } // If shutdownRequestInProgress is still true, we assume that the peer MultiplexingManager // has shut down or is inaccessible, and we shut down. if (shutdownRequestInProgress) { shutdown = true; // turn off shutdownRequestInProgress in case incrementReferences() or reserveManager() // are waiting shutdownRequestInProgress = false; } } else // !isConnected() shutdown = true; if (shutdown) { shutdown(); // wake up incrementReferences() if it is waiting notifyAll(); } else { // shutdownMonitorThread = new ShutdownMonitorThread(); // shutdownMonitorThread.setName(shutdownMonitorThread.getName() + ":shutdownMonitor"); // shutdownMonitorThread.start(); shutdownMonitorTimerTask = new ShutdownMonitorTimerTask(); if (debug) log.debug(description + ": scheduling ShutdownMonitorTask: " + shutdownMonitorTimerTask); timer.schedule(shutdownMonitorTimerTask, shutdownMonitorPeriod, shutdownMonitorPeriod); } } } /** * @return */ protected synchronized boolean respondToShutdownRequest() { if (debug) { log.debug(description + readyToShutdown); log.debug(description + shutdown); } if (readyToShutdown) { remoteShutdown = true; if (debug) log.debug(description + ": respondToShutdownRequest(): set remoteShutdown to true"); } return readyToShutdown; } /** * @return */ protected boolean isShutdown() { return shutdown; } } /** * */ protected class ShutdownThread extends Thread { private boolean safeToShutDown; public void run() { String message = null; if (debug) log.debug(description + ": manager shutting down"); // Unregister this MultiplexingManager by local address(es) unregisterByLocalAddress(); // Unregister this MultiplexingManager by remote address unregisterByRemoteAddress(); // Remove this MultiplexingManager from Map of shareable managers unregisterShareable(); if (socket != null) { try { if (outputMultiplexor != null) { outputMultiplexor.unregister(MultiplexingManager.this); // Don't close socket until all output has been written. synchronized (MultiplexingManager.this) { while (!safeToShutDown) { if (debug) log.debug("waiting for safe to shut down"); try { MultiplexingManager.this.wait(); } catch (InterruptedException ignored) { } } } } if (socket.getChannel() == null) socket.close(); else { // socket.getChannel().close(); message = description; if (multiGroupInputThread != null) multiGroupInputThread.unregisterSocketGroup(MultiplexingManager.this); socket.close(); if (debug) log.debug("closed socket: " + description); // multiGroupInputThread.unregisterSocketGroup(MultiplexingManager.this); // socket.close(); } log.debug("manager: closed socket"); } catch (Exception e) { log.error("manager: unable to close socket", e); } } if (inputThread != null) { inputThread.shutdown(); try { inputThread.join(); log.debug("manager: joined input thread"); } catch (InterruptedException ignored) { log.debug("manager: interrupted exception waiting for read thread"); } } removeAnInputStream(SocketId.PROTOCOL_SOCKET_ID); removeAnInputStream(SocketId.SERVER_SOCKET_ID); removeAnInputStream(SocketId.SERVER_SOCKET_CONNECT_ID); removeAnInputStream(SocketId.SERVER_SOCKET_VERIFY_ID); removeAnInputStream(SocketId.BACKCHANNEL_SOCKET_ID); shutdown = true; // Remove this MultiplexManager from set of all managers if (debug) log.debug("removing from allManagers: " + description + "(" + id + ")"); allManagers.remove(MultiplexingManager.this); if (debug) log.debug("manager shut down (: " + id + "): " + message); if (debug) log.debug("managers left: " + allManagers.size()); } public void setSafeToShutdown(boolean safe) { if (debug) log.debug("output flushed"); safeToShutDown = safe; } } protected static class PendingActionThread extends StoppableThread { private List pendingActionsTemp = new ArrayList(); protected void doInit() { log.debug("PendingActionThread starting"); } protected void doRun() { synchronized (pendingActions) { while (pendingActions.isEmpty()) { try { pendingActions.wait(); } catch (InterruptedException ignored) { if (!isRunning()) return; } } pendingActionsTemp.addAll(pendingActions); pendingActions.clear(); } Iterator it = pendingActionsTemp.iterator(); while (it.hasNext()) { Object o = it.next(); if (o instanceof PendingAction) ((PendingAction) o).doAction(); else log.error("object in closePendingSockets has invalid type: " + o.getClass()); } pendingActionsTemp.clear(); } public void shutdown() { log.debug("pending action thread beginning shut down"); super.shutdown(); interrupt(); } protected void doShutDown() { log.debug("PendingActionThread shutting down"); } } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexingInputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexingIn0000644000175000017500000003772010753261335033626 0ustar twernertwerner/* * 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.remoting.transport.multiplex; import java.io.EOFException; import java.io.IOException; import java.net.SocketException; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.jboss.logging.Logger; import org.jboss.remoting.transport.multiplex.utility.GrowablePipedInputStream; import org.jboss.remoting.transport.multiplex.utility.GrowablePipedOutputStream; import org.jboss.remoting.transport.multiplex.utility.VirtualSelector; /** * MultiplexingInputStream is the class returned by * VirtualSocket.getInputStream(). * It supports the methods and behavior implemented by the InputStream returned by * java.net.Socket.getInputStream(). For more information about the behavior * of the methods, see the javadoc for java.io.InputStream. *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class MultiplexingInputStream extends GrowablePipedInputStream { protected static final Logger log = Logger.getLogger(MultiplexingInputStream.class); private VirtualSocket socket; private boolean eof = false; private boolean closed = false; private boolean remoteShutDownPending = false; private Set readingThreads = new HashSet(); private IOException readException; private long skipCount = 0; private boolean tracing; /** * @param sourceStream * @param manager */ public MultiplexingInputStream(GrowablePipedOutputStream sourceStream, MultiplexingManager manager) throws IOException { this(sourceStream, manager, null, null); } /** * @param sourceStream * @param manager * @param socket * */ public MultiplexingInputStream(GrowablePipedOutputStream sourceStream, MultiplexingManager manager, VirtualSocket socket) throws IOException { this(sourceStream, manager, socket, null); } /** * @param sourceStream * @param manager * @param socket * @param virtualSelector * */ public MultiplexingInputStream(GrowablePipedOutputStream sourceStream, MultiplexingManager manager, VirtualSocket socket, VirtualSelector virtualSelector) throws IOException { super(sourceStream, virtualSelector); this.socket = socket; tracing = log.isTraceEnabled(); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are required of all InputStreams '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /************************************************************************************************* ok: public int read() throws IOException; ok: public int read(byte b[]) throws IOException; ok: public int read(byte b[], int off, int len) throws IOException; ok: public long skip(long n) throws IOException; ok: public int available() throws IOException; ok: public void close() throws IOException; ok: public void mark(int readlimit); ok: public void reset() throws IOException; ok: public boolean markSupported(); *************************************************************************************************/ /** * See superclass javadoc. */ public void close() throws IOException { if (closed) return; log.debug("MultiplexingInputStream closing"); closed = true; super.close(); if (socket != null) socket.close(); // If a thread is currently in read(), interrupt it. interruptReadingThreads(); } /** * See superclass javadoc. */ public synchronized int read() throws IOException { if (eof) return -1; if (closed) throw new SocketException("Socket closed"); if (readException != null) throw readException; if (skipCount > 0) skip(skipCount); try { // We leave a reference to the current thread so that close() and handleRemoteShutdown() // can interrupt it if necessary. readingThreads.add(Thread.currentThread()); int b = super.read(); readingThreads.remove(Thread.currentThread()); if (tracing) log.trace("read(): super.read() returned: " + b); if (remoteShutDownPending && available() == 0) setEOF(); return b & 0xff; } catch (IOException e) { readingThreads.remove(Thread.currentThread()); if (closed) throw new SocketException("Socket closed"); if (eof) return -1; if (readException != null) throw readException; throw e; } } /** * See superclass javadoc. */ public int read(byte[] bytes) throws IOException { return read(bytes, 0, bytes.length); } /** * See superclass javadoc. */ public synchronized int read(byte[] bytes, int off, int len) throws IOException { log.trace("entering read()"); if (eof) return -1; if (closed) throw new SocketException("Socket closed"); if (readException != null) throw readException; if (skipCount > 0) skip(skipCount); try { // We leave a reference to the current thread so that handleRemoteShutdown() can // interrupt it if necessary. readingThreads.add(Thread.currentThread()); int n = super.read(bytes, off, len); readingThreads.remove(Thread.currentThread()); if (tracing) log.trace("super.read() returned " + n + " bytes: " + "[" + (0xff & bytes[off]) + ".." + (0xff & bytes[off+n-1]) + "]"); if (remoteShutDownPending && available() == 0) setEOF(); return n; } catch (IOException e) { readingThreads.remove(Thread.currentThread()); if (eof) return -1; if (closed) throw new SocketException("Socket closed"); throw e; } } /** * See superclass javadoc. */ public synchronized long skip(long n) throws IOException { if (eof) return 0; if (closed) throw new SocketException("Socket closed"); if (readException != null) throw readException; if (n <= 0) return 0; int skipped = 0; try { readingThreads.add(Thread.currentThread()); while (skipped < n && (skipped == 0 || available() > 0)) { if (read() == -1) break; skipped++; } readingThreads.remove(Thread.currentThread()); if (remoteShutDownPending && available() == 0) setEOF(); return skipped; } catch (IOException e) { readingThreads.remove(Thread.currentThread()); if (eof) return -1; if (closed) throw new SocketException("Socket closed"); throw e; } } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are specific to MultiplexingInputStream '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ protected VirtualSocket getSocket() { return socket; } /** * handleRemoteShutdown() is responsible for informing the MultiplexingInputStream * that no more bytes will be coming from the remote MultiplexingOutputStream to which * it is connected, because shutdownOutput() or close() has been called on the * remote VirtualSocket. The result is that once all bytes sent by the remote socket have * been consumed, all subsequent calls to read() will return -1 and all subsequent calls to skip() will * return 0, indicating end of file has been reached. */ protected synchronized void handleRemoteShutdown() throws IOException { /* * handleRemoteShutdown() needs to handle two cases correctly: * * Case 1. all bytes transmitted by the remote MultiplexingOutputStream have been consumed by the time * handleRemoteShutdown() executes, and * * Case 2. not all bytes transmitted by the remote MultiplexingOutputStream have been consumed * by the time handleRemoteShutdown() executes.. * * Correctness argument: * * Case 1. * * The bracketing facility implemented by OutputMultiplexor guarantees that all bytes * transmitted by the remote MultiplexingOutputStream will arrive and be stored in this * MultiplexingInputStream before the protocol message arrives that leads to * handleRemoteShutdown() being called. Therefore, if available() == 0 is true upon entering * handleRemoteShutdown(), all transmitted bytes have been consumed and it is correct to indicate * that this MultiplexingInputStream is at end of file. * * Case 1a. No threads are currently in read() or skip(): * * Calling setEOF() will guarantee that all subsequent calls to read() will return -1 and all * subsequent calls to skip() will return 0. * * Case 1b. One or more threads are currently in read() or skip(): * * Since all read() methods, skip(), and handleRemoteShutdown() are synchronized, the only way * handleRemoteShutdown() can be executing is if all of the threads in read() and skip() are * blocked on the wait() call in super.read(). Then all of the blocked threads are referenced in * the Set readingThreads, and calling interruptReadingThreads will guarantee that they are * interrupted, which will lead to their throwing an InterruptedIOException. Moreover, calling * setEOF() will guarantee that all such threads will see eof == true in the exception and * will return -1. If any of the threads made the call to read() by way of skip(), then the * condition (skipped == 0 || available() > 0) was true when read() was called, and since we * are assumeing available() == 0, then skipped == 0 must have been true. Therefore, when * it gets -1 from the call to read(), skip() will return 0. Finally, calling setEOF() in * handleRemoteShutdown() will guarantee that all subsequent calls to read() will return -1 * and all subsequent calls to skip() will return 0. * * Case 2. * * Suppose, on the other hand, that available() == 0 is false. Then the only action taken by * handleRemoteShutdown() is to set remoteShutdownPending to true, and as long as bytes are * available, there is no obstacle to their being read or skipped. * * Fact. The last transmitted byte has been consumed if and only if available() == 0. * * (If): * The fact that handleRemoteShutdown() has been called implies that all bytes transmitted from the remote * socket have already arrived and been stored in this MultiplexingInputStream, so the value returned * by available() will decrease monotonically, and once available() == 0, the last transmitted byte has * been consumed. * * (Only if): * This direction is obvious. * * Now, if no thread ever requests the last available byte to be read or skipped, then all calls to read() * or skip() following the call to handleRemoteShutdown() will execute with available() > 0, and there * will be no impediment to their successful completion. * * Suppose, then, that some thread T makes a call to read() that retrieves the last available byte. * Upon returning from super.read(), T will find (remoteShutdownPending && available() == 0) is true, * and it will call setEOF(), which, by the Fact argued above, is a correct action. Since available() * was > 0 when the T entered read(), T will never call wait() in super.read(), so no other thread will * enter read() or skip() until T leaves read(). At that point any threads entering read() will find * eof == true and will return -1, and any threads entering skip() will find eof == true and return 0. * * Finally, suppose that some thread T makes a call to skip() to skip the last available byte. * T will eventually leave the while loop in skip() with available() == 0, and when it reaches * the test for (remoteShutDownPending && available() == 0), it will call setEOF(). * Since available() was > 0 when the T entered skip(), T will never call wait() in super.read(), * so no other thread will enter read() or skip() until T leaves skip(). At that point any threads * entering read() will find eof == true and will return -1, and any threads entering skip() will * find eof == true and return 0. */ log.debug("entering handleRemoteShutdown()"); if (eof) return; remoteShutDownPending = true; if (available() == 0) { setEOF(); interruptReadingThreads(); } log.debug("leaving handleRemoteShutdown()"); } /** * */ protected synchronized void interruptReadingThreads() { // If we obtained the lock, then either there are no threads in read() or skip(), // or any such threads are blocked in super.read(), having executed wait(). Iterator it = readingThreads.iterator(); while (it.hasNext()) { Thread t = (Thread) it.next(); it.remove(); t.interrupt(); } } /** * readInt() is borrowed from DataInputStream. It saves the extra expense of * creating a DataInputStream */ public final int readInt() throws IOException { int b1 = read(); int b2 = read(); int b3 = read(); int b4 = read(); if ((b1 | b2 | b3 | b4) < 0) throw new EOFException(); return ((b1 << 24) + (b2 << 16) + (b3 << 8) + (b4 << 0)); } /** */ protected void setEOF() { eof = true; } protected void setReadException(IOException e) { readException = e; interruptReadingThreads(); } /** * @param n */ protected synchronized void setSkip(long n) { skipCount += n; } /** * A MultiplexingInputStream may be created without reference to a VirtualSocket. * (See MultiplexingManager.getAnOutputStream().) setSocket() allows the socket to * be set afterwards. * * @param socket */ protected void setSocket(VirtualSocket socket) { this.socket = socket; } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/Multiplex.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/Multiplex.java0000644000175000017500000001726310753261335033561 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.remoting.transport.multiplex; import java.util.Map; import org.jboss.logging.Logger; /** * Multiplex is the repository for the names and default values for all of the * configurable parameters in the Multiplex system. The names are meant to * be used as keys in a configuration Map. * The Multiplex class also contains * some keys used internally by the Multiplex classes. *

          * For a discussion of the meaning of these parameters, please see the Multiplex * documentation on the labs.jboss.org web site. *

          * @author Ron Sigal * @version $Revision$ *

          * Copyright (c) May 19, 2006 *

          * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class Multiplex { private static Logger log = Logger.getLogger(Multiplex.class); private Multiplex() {} ///////////////////////////////////////////////////////////////////////////////////// //////////////// invoker parameters ///////////////// ///////////////////////////////////////////////////////////////////////////////////// // configuration map keys: public static final String SERVER_MULTIPLEX_ID = "serverMultiplexId"; public static final String CLIENT_MULTIPLEX_ID = "clientMultiplexId"; public static final String MULTIPLEX_CONNECT_PORT = "multiplexConnectPort"; public static final String MULTIPLEX_CONNECT_HOST = "multiplexConnectHost"; public static final String MULTIPLEX_BIND_HOST = "multiplexBindHost"; public static final String MULTIPLEX_BIND_PORT = "multiplexBindPort"; public static final String MAX_ACCEPT_ERRORS = "multiplex.maxAcceptErrors"; // defaults: public static final int MAX_ACCEPT_ERRORS_DEFAULT = 10; ///////////////////////////////////////////////////////////////////////////////////// //////////////// MultiplexingManager parameters ///////////////// ///////////////////////////////////////////////////////////////////////////////////// // configuration map keys: public static final String STATIC_THREADS_MONITOR_PERIOD = "multiplex.staticThreadsMonitorPeriod"; public static final String SHUTDOWN_REQUEST_TIMEOUT = "multiplex.shutdownRequestTimeout"; public static final String SHUTDOWN_REFUSALS_MAXIMUM = "multiplex.shutdownRefusalsMaximum"; public static final String SHUTDOWN_MONITOR_PERIOD = "multiplex.shutdownMonitorPeriod"; // defaults: public static final int STATIC_THREADS_MONITOR_PERIOD_DEFAULT = 5000; public static final int SHUTDOWN_REQUEST_TIMEOUT_DEFAULT = 5000; public static final int SHUTDOWN_REFUSALS_MAXIMUM_DEFAULT = 5; public static final int SHUTDOWN_MONITOR_PERIOD_DEFAULT = 1000; ///////////////////////////////////////////////////////////////////////////////////// //////////////// InputMultiplexor parameters ///////////////// ///////////////////////////////////////////////////////////////////////////////////// // configuration map keys: public static final String INPUT_BUFFER_SIZE = "multiplex.inputBufferSize"; public static final String INPUT_MAX_ERRORS = "multiplex.inputMaxErrors"; // defaults: public static final int INPUT_BUFFER_SIZE_DEFAULT = 4096; public static final int INPUT_MAX_ERRORS_DEFAULT = 3; ///////////////////////////////////////////////////////////////////////////////////// //////////////// OutputMultiplexor parameters ///////////////// ///////////////////////////////////////////////////////////////////////////////////// // configuration map keys: public static final String OUTPUT_MESSAGE_POOL_SIZE = "multiplex.outputMessagePoolSize"; public static final String OUTPUT_MESSAGE_SIZE = "multiplex.outputMessageSize"; public static final String OUTPUT_MAX_CHUNK_SIZE = "multiplex.outputMaxChunkSize"; public static final String OUTPUT_MAX_TIME_SLICE = "multiplex.outputMaxTimeSlice"; public static final String OUTPUT_MAX_DATA_SLICE = "multiplex.outputMaxDataSlice"; public static final String OUTPUT_MAX_ERRORS = "multiplex.outputMaxErrors"; // defaults: public static final int OUTPUT_MESSAGE_POOL_SIZE_DEFAULT = 1024; public static final int OUTPUT_MESSAGE_SIZE_DEFAULT = 256; public static final int OUTPUT_MAX_CHUNK_SIZE_DEFAULT = 2048; public static final int OUTPUT_MAX_TIME_SLICE_DEFAULT = 500; public static final int OUTPUT_MAX_DATA_SLICE_DEFAULT = OUTPUT_MAX_CHUNK_SIZE_DEFAULT * 8; public static final int OUTPUT_MAX_ERRORS_DEFAULT = 3; ///////////////////////////////////////////////////////////////////////////////////// //////////////// Internal parameters ///////////////// ///////////////////////////////////////////////////////////////////////////////////// public final static String SOCKET_FACTORY = "multiplex.SocketFactory"; public final static String SERVER_SOCKET_FACTORY = "multiplex.ServerSocketFactory"; public final static String SSL_HANDSHAKE_LISTENER = "multiplex.SSLHandshakeListener"; ///////////////////////////////////////////////////////////////////////////////////// //////////////// Utility methods ///////////////// ///////////////////////////////////////////////////////////////////////////////////// /** * Extracts a parameter value from a configuration Map. * @param configuration configuration Map * @param name display form of parameter name * @param key key in configuration Map * @param defaultValue value to use of key is not among configuration keys * @return value in configuration association with key, or defautValue if key is not among * configuration keys */ public static int getOneParameter(Map configuration, String name, String key, int defaultValue) { if (configuration.containsKey(key)) { Object obj = configuration.get(key); if (obj instanceof Integer) { return ((Integer) obj).intValue(); } else if (obj instanceof String) { try { return Integer.parseInt((String) obj); } catch (NumberFormatException e) { log.error("invalid value for " + name + ": using default: " + defaultValue); return defaultValue; } } else { log.error("invalid value for " + name + ": using default: " + defaultValue); return defaultValue; } } else return defaultValue; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexClientInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexClien0000644000175000017500000005223510753261335033612 0ustar twernertwerner/* * 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.remoting.transport.multiplex; import org.jboss.logging.Logger; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.transport.BidirectionalClientInvoker; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.SocketGroupInfo; import org.jboss.remoting.transport.multiplex.utility.AddressPair; import org.jboss.remoting.transport.socket.ClientSocketWrapper; import org.jboss.remoting.transport.socket.SocketClientInvoker; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.util.Map; /** * MultiplexClientInvoker is the client side of the Multiplex transport. * For more information, see Remoting documentation on labs.jboss.org. * * @author Tom Elrod * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class MultiplexClientInvoker extends SocketClientInvoker implements BidirectionalClientInvoker { private static final Logger log = Logger.getLogger(MultiplexClientInvoker.class); private static final boolean isTraceEnabled = log.isTraceEnabled(); private InetAddress connectAddress; private String connectHost; private int connectPort; private InetSocketAddress connectSocketAddress; private InetSocketAddress bindSocketAddress; private String socketGroupId; private MultiplexServerInvoker.SocketGroupInfo socketGroupInfo; private AddressPair addressPair; private boolean readyToRun; protected String clientSocketClassName = ClientSocketWrapper.class.getName(); /** * Create a new MultiplexClientInvoker. * * @param locator */ public MultiplexClientInvoker(InvokerLocator locator) throws IOException { super(locator); } /** * Create a new MultiplexClientInvoker. * * @param locator */ public MultiplexClientInvoker(InvokerLocator locator, Map configuration) throws IOException { super(locator, configuration); } protected void handleConnect() throws ConnectionFailedException { try { log.debug("configuring MultiplexClientInvoker for: " + locator); super.handleConnect(); this.connectAddress = InetAddress.getByName(locator.getHost()); this.connectHost = connectAddress.getHostName(); this.connectPort = locator.getPort(); this.connectSocketAddress = new InetSocketAddress(connectAddress, connectPort); if (getSocketFactory() != null) configuration.put(Multiplex.SOCKET_FACTORY, getSocketFactory()); Map parameters = configuration; if (parameters != null) { configureSocketGroupParameters(parameters); } } catch (Exception e) { throw new ConnectionFailedException(e.getMessage()); } } /** * Finishes the start up process, once adequate bind and connect information is * made available. For more information, see the Multiplex subsystem documentation * at labs.jboss.org. */ public void finishStart() throws IOException { if (socketGroupInfo != null && socketGroupInfo.getBindAddress() != null && bindSocketAddress == null) { InetAddress bindAddress = socketGroupInfo.getBindAddress(); int bindPort = socketGroupInfo.getBindPort(); bindSocketAddress = new InetSocketAddress(bindAddress, bindPort); } if (socketGroupInfo != null && socketGroupInfo.getBindAddress() != null && addressPair == null) { String bindHost = socketGroupInfo.getBindAddress().getHostName(); int bindPort = socketGroupInfo.getBindPort(); addressPair = new AddressPair(connectHost, connectPort, bindHost, bindPort); } readyToRun = true; } public InvokerLocator getCallbackLocator(Map metadata) { Socket socket = socketGroupInfo.getPrimingSocket(); metadata.put(Multiplex.MULTIPLEX_CONNECT_HOST, socket.getInetAddress().getHostAddress()); metadata.put(Multiplex.MULTIPLEX_CONNECT_PORT, Integer.toString(socket.getPort())); metadata.put(Multiplex.MULTIPLEX_BIND_HOST, socket.getInetAddress().getHostAddress()); metadata.put(Multiplex.MULTIPLEX_BIND_PORT, Integer.toString(socket.getPort())); InvokerLocator locator = new InvokerLocator("multiplex", socket.getLocalAddress().getHostAddress(), socket.getLocalPort(), null, metadata); return locator; } /** * @param parameters * @throws IOException */ protected void configureSocketGroupParameters(Map parameters) throws IOException { String bindHost; String bindPortString; int bindPort = -1; InetAddress bindAddress = null; socketGroupId = (String) parameters.get(Multiplex.CLIENT_MULTIPLEX_ID); log.debug("socketGroupId: " + socketGroupId); synchronized (MultiplexServerInvoker.SocketGroupInfo.class) { if (socketGroupId != null) socketGroupInfo = (SocketGroupInfo) MultiplexServerInvoker.getSocketGroupMap().get(socketGroupId); if (socketGroupInfo != null && socketGroupInfo.getServerInvoker() != null) { log.debug("client rule 1"); // If we get here, it's because a MultiplexServerInvoker created a SocketGroupInfo with matching // group id. We want to make sure that it didn't get a connect address or connect port different // than the ones passed in through the parameters map. InetAddress socketGroupConnectAddress = socketGroupInfo.getConnectAddress(); int socketGroupConnectPort = socketGroupInfo.getConnectPort(); if (socketGroupConnectAddress != null && !socketGroupConnectAddress.equals(connectAddress)) { String message = "socket group connect address (" + socketGroupConnectAddress + ") does not match connect address (" + connectAddress + ")"; log.error(message); throw new IOException(message); } if (socketGroupConnectPort > 0 && socketGroupConnectPort != connectPort) { String message = "socket group connect port (" + socketGroupConnectPort + ") does not match connect port (" + connectPort + ")"; log.error(message); throw new IOException(message); } bindAddress = socketGroupInfo.getBindAddress(); bindPort = socketGroupInfo.getBindPort(); bindSocketAddress = new InetSocketAddress(bindAddress, bindPort); if (socketGroupInfo.getPrimingSocket() == null) { String connectHost = connectAddress.getHostName(); MultiplexServerInvoker.createPrimingSocket(socketGroupInfo, connectHost, connectPort, bindAddress, bindPort, configuration, timeout); } socketGroupInfo.setConnectAddress(connectAddress); socketGroupInfo.setConnectPort(connectPort); socketGroupInfo.addClientInvoker(this); // We got socketGroupInfo by socketGroupId. Make sure it is also stored by AddressPair. bindHost = bindAddress.getHostName(); addressPair = new AddressPair(connectHost, connectPort, bindHost, bindPort); MultiplexServerInvoker.getAddressPairMap().put(addressPair, socketGroupInfo); MultiplexServerInvoker serverInvoker = socketGroupInfo.getServerInvoker(); if (serverInvoker != null) serverInvoker.finishStart(); finishStart(); return; } bindHost = (String) parameters.get(Multiplex.MULTIPLEX_BIND_HOST); bindPortString = (String) parameters.get(Multiplex.MULTIPLEX_BIND_PORT); if (bindHost != null && bindPortString == null) { bindPortString = "0"; } if (bindHost == null && bindPortString != null) { bindHost = "localhost"; } if (bindHost != null) { log.debug("client rule 2"); try { bindPort = Integer.parseInt(bindPortString); } catch (NumberFormatException e) { throw new IOException("number format error for bindPort: " + bindPortString); } if (bindPort != 0) { bindSocketAddress = new InetSocketAddress(bindHost, bindPort); addressPair = new AddressPair(connectHost, connectPort, bindHost, bindPort); socketGroupInfo = (SocketGroupInfo) MultiplexServerInvoker.getAddressPairMap().get(addressPair); } // If socketGroupInfo exists, it's because it was created, along with a priming socket, by a // MultiplexServerInvoker. Note that we don't look for a match if the bind port was // anonymous. if (socketGroupInfo != null) { socketGroupInfo.setConnectAddress(connectAddress); socketGroupInfo.setConnectPort(connectPort); socketGroupInfo.addClientInvoker(this); // We got socketGroupInfo by AddressPair. Make sure it is stored by socketGroupId, if we have one. if (socketGroupId != null) { String socketGroupSocketGroupId = socketGroupInfo.getSocketGroupId(); if (socketGroupSocketGroupId != null && !socketGroupSocketGroupId.equals(socketGroupId)) { String message = "socket group multiplexId (" + socketGroupSocketGroupId + ") does not match multiplexId (" + socketGroupId + ")"; log.error(message); throw new IOException(message); } if (socketGroupSocketGroupId == null) { socketGroupInfo.setSocketGroupId(socketGroupId); MultiplexServerInvoker.getSocketGroupMap().put(socketGroupId, socketGroupInfo); } } finishStart(); return; } if (bindPort == 0 && socketGroupId == null) { String message = "Can never be found by any MultiplexServerInvoker: " + "bind port == 0 and socketGroupId == null"; log.warn(message); } // Anonymous bind port if (bindPort == 0) bindPort = PortUtil.findFreePort(bindHost); socketGroupInfo = new SocketGroupInfo(); socketGroupInfo.setConnectAddress(connectAddress); socketGroupInfo.setConnectPort(connectPort); socketGroupInfo.addClientInvoker(this); // Set bindAddress and bindPort to be able to test for inconsistencies with bind address // and bind port determined by companion MultiplexServerInvoker. bindAddress = InetAddress.getByName(bindHost); socketGroupInfo.setBindAddress(bindAddress); socketGroupInfo.setBindPort(bindPort); String connectHost = connectAddress.getHostName(); MultiplexServerInvoker.createPrimingSocket(socketGroupInfo, connectHost, connectPort, bindAddress, bindPort, configuration, timeout); MultiplexServerInvoker.getAddressPairMap().put(addressPair, socketGroupInfo); if (socketGroupId != null) { socketGroupInfo.setSocketGroupId(socketGroupId); MultiplexServerInvoker.getSocketGroupMap().put(socketGroupId, socketGroupInfo); } finishStart(); return; } if (socketGroupId != null) { log.debug("client rule 3"); if (socketGroupInfo == null) { socketGroupInfo = new SocketGroupInfo(); socketGroupInfo.setSocketGroupId(socketGroupId); socketGroupInfo.setConnectAddress(connectAddress); socketGroupInfo.setConnectPort(connectPort); MultiplexServerInvoker.getSocketGroupMap().put(socketGroupId, socketGroupInfo); } socketGroupInfo.addClientInvoker(this); return; } log.debug("client rule 4"); String connectHost = connectAddress.getHostName(); socketGroupInfo = new SocketGroupInfo(); MultiplexServerInvoker.createPrimingSocket(socketGroupInfo, connectHost, connectPort, configuration, timeout); finishStart(); } } /** * @param sessionId * @param invocation * @param marshaller * @return * @throws java.io.IOException * @throws org.jboss.remoting.ConnectionFailedException * */ protected Object transport(String sessionId, Object invocation, Map metadata, Marshaller marshaller, UnMarshaller unmarshaller) throws IOException, ConnectionFailedException, ClassNotFoundException { log.debug("entering transport()"); if (!readyToRun) throw new IOException("connection to server has not been made"); return super.transport(sessionId, invocation, metadata, marshaller, unmarshaller); } /** * subclasses must implement this method to provide a hook to disconnect from the remote server, if this applies * to the specific transport. However, in some transport implementations, this may not make must difference since * the connection is not persistent among invocations, such as SOAP. In these cases, the method should * silently return without any processing. */ protected void handleDisconnect() { //TODO: -TME Should this be a no op or need to pool? log.debug("entering handleDisconnect()"); super.handleDisconnect(); synchronized (MultiplexServerInvoker.SocketGroupInfo.class) { if (socketGroupInfo != null) { socketGroupInfo.removeClientInvoker(this); if (socketGroupInfo.getClientInvokers().isEmpty() && socketGroupInfo.getServerInvoker() == null) { log.debug("invoker group shutting down: " + socketGroupInfo.getSocketGroupId()); if (socketGroupInfo.getPrimingSocket() != null) { log.debug("MultiplexClientInvoker: closing bind priming socket"); VirtualSocket ps = socketGroupInfo.getPrimingSocket(); if (ps != null) { try { // When the remote virtual MultiplexServerInvoker learns that the // priming socket has closed, it will close its VirtualServerSocket, // rendering unshareable the MultiplexingManager that underlies this // socket group. We mark it as unshareable immediately so that it will // not be reused by any other socket group. ps.getManager().unregisterShareable(); ps.close(); } catch (IOException e) { log.error("Error closing bind priming socket during cleanup upon stopping", e); } } } socketGroupId = socketGroupInfo.getSocketGroupId(); if (socketGroupId != null) { MultiplexServerInvoker.getSocketGroupMap().remove(socketGroupId); } // addressPair is set in finishStart(). if (addressPair != null) { MultiplexServerInvoker.getAddressPairMap().remove(addressPair); } } socketGroupInfo = null; // Prevent from occurring a second time in Finalizer thread. } } } /** * @return */ protected InetSocketAddress getBindSocketAddress() { return bindSocketAddress; } /** * @return */ protected InetSocketAddress getConnectSocketAddress() { return connectSocketAddress; } /** * Each implementation of the remote client invoker should have * a default data type that is uses in the case it is not specified * in the invoker locator uri. * * @return */ protected String getDefaultDataType() { return SerializableMarshaller.DATATYPE; } protected Socket createSocket(String address, int port, int timeout) throws IOException { log.debug("MultiplexClientInvoker.createSocket()"); if (timeout < 0) { timeout = getTimeout(); if (timeout < 0) timeout = 0; } // If connection has been broken, try to connect to new server. if (socketGroupInfo != null && socketGroupInfo.getPrimingSocket() != null) { VirtualSocket primingSocket = socketGroupInfo.getPrimingSocket(); if (!primingSocket.isFunctional() || primingSocket.hasReceivedDisconnectMessage()) { log.info("Current server is inaccessible. Will try to connect to new server"); primingSocket.close(); // Get new priming socket. if (bindSocketAddress != null) { InetAddress bindAddress = bindSocketAddress.getAddress(); int bindPort = PortUtil.findFreePort(bindSocketAddress.getHostName()); socketGroupInfo.setBindPort(bindPort); bindSocketAddress = new InetSocketAddress(bindAddress, bindPort); MultiplexServerInvoker.createPrimingSocket(socketGroupInfo, connectHost, connectPort, bindAddress, bindPort, configuration, timeout); } else MultiplexServerInvoker.createPrimingSocket(socketGroupInfo, connectHost, connectPort, configuration, port); MultiplexServerInvoker serverInvoker = socketGroupInfo.getServerInvoker(); if (serverInvoker != null) { try { // Restart callback server invoker with new server socket. serverInvoker.stop(); socketGroupInfo.setServerInvoker(null); serverInvoker.resetLocator(bindSocketAddress.getPort()); serverInvoker.refreshServerSocket(); serverInvoker.setup(); serverInvoker.start(); } catch (Exception e) { log.error(e.getMessage(), e); } } VirtualSocket socket = new VirtualSocket(configuration); for (int i = 0; i < 3; i++) { try { socket.connect(connectSocketAddress, bindSocketAddress, timeout); return socket; } catch (Exception e) { try { Thread.sleep(500); } catch (InterruptedException e1) { } } } } } VirtualSocket socket = new VirtualSocket(configuration); socket.connect(connectSocketAddress, bindSocketAddress, timeout); return socket; } }././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/VirtualSocket.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/VirtualSocket.0000644000175000017500000010111510753261335033521 0ustar twernertwerner/* * 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. */ /* * Created on Jul 22, 2005 */ package org.jboss.remoting.transport.multiplex; import org.jboss.logging.Logger; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.Socket; import java.net.SocketAddress; import java.net.SocketException; import java.net.SocketImpl; import java.net.SocketTimeoutException; import java.net.UnknownHostException; import java.nio.channels.SocketChannel; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * VirtualSocket represents an endpoint on a virtual connection created by the * Multiplex system. It extends java.net.Socket and reimplements nearly all of * the methods in java.net.Socket. For information about method behavior, please * see the java.net.Socket javadoc. For more information about the nature of * virtual sockets, please see the Multiplex documentation at the labs.jboss.org * web site. * *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class VirtualSocket extends Socket { protected static final Logger log = Logger.getLogger(VirtualSocket.class); protected static Thread closingThread; private Map configuration = new HashMap(); private MultiplexingManager manager; private Protocol protocol; private Socket actualSocket; private SocketId remoteSocketId; private SocketId localSocketId; private MultiplexingInputStream inputStream; private MultiplexingOutputStream outputStream; private Set disconnectListeners = new HashSet(); private boolean bound = false; private boolean closed = false; private boolean connected = false; private boolean inputShutdown = false; private boolean outputShutdown = false; private boolean receivedDisconnectMessage = false; private int timeout; private Socket dummySocket; private boolean functional = true; private boolean trace; private boolean debug; private boolean info; /** * A class that implements DisconnectListener can register to * be notified if the remote peer of this VirtualSocket has * disconnected. */ public interface DisconnectListener { void notifyDisconnected(VirtualSocket virtualSocket); } public VirtualSocket(MultiplexingManager manager, SocketId remoteSocketId, Map configuration) throws IOException { this.manager = manager; this.actualSocket = manager.getSocket(); this.remoteSocketId = remoteSocketId; this.configuration.putAll(configuration); protocol = manager.getProtocol(); localSocketId = new SocketId(); inputStream = manager.registerSocket(this); // outputStream = new MultiplexingOutputStream(manager, this, remoteSocketId); outputStream = manager.getAnOutputStream(this, remoteSocketId); bound = true; connected = true; trace = log.isTraceEnabled(); debug = log.isDebugEnabled(); info = log.isInfoEnabled(); if (debug) log.debug("created virtual socket on port: " + localSocketId.getPort()); } public VirtualSocket(Map configuration) { this.configuration.putAll(configuration); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following constructors duplicate those of the parent class Socket '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * See superclass javadoc. */ public VirtualSocket() { log.debug("created unbound virtual socket"); } /** * See superclass javadoc. */ public VirtualSocket(String host, int port) throws UnknownHostException, IOException { InetSocketAddress address = null; if (host == null) address = new InetSocketAddress(InetAddress.getByName(null), port); else address = new InetSocketAddress(host, port); connect(address); if (debug) log.debug("created virtual socket on port: " + localSocketId.getPort()); } /** * See superclass javadoc. * @param host * @param port * @param stream * @throws java.io.IOException */ public VirtualSocket(String host, int port, boolean stream) throws IOException { if (!stream) { throw new SocketException("Deprecated: use DataGramSocket instead of stream = false"); } InetSocketAddress address = null; if (host == null) address = new InetSocketAddress(InetAddress.getByName(null), port); else address = new InetSocketAddress(host, port); connect(address); if (debug) log.debug("created virtual socket on port: " + localSocketId.getPort()); } /** * See superclass javadoc. * @param address * @param port * @throws java.io.IOException */ public VirtualSocket(InetAddress address, int port) throws IOException { connect(new InetSocketAddress(address, port)); if (debug) log.debug("created virtual socket on port: " + localSocketId.getPort()); } /** * See superclass javadoc. * @param host * @param port * @param stream * @throws java.io.IOException */ public VirtualSocket(InetAddress host, int port, boolean stream) throws IOException { if (!stream) { throw new SocketException("Deprecated: use DataGramSocket instead of stream = false"); } connect(new InetSocketAddress(host, port)); if (debug) log.debug("created virtual socket on port: " + localSocketId.getPort()); } /** * This constuctor is not implemented. *

          * @param impl * @throws java.net.SocketException in all cases */ public VirtualSocket(SocketImpl impl) throws SocketException { throw new SocketException("VirtualSocket does not use SocketImpl"); } /** * See superclass javadoc. * @param host * @param port * @param localAddr * @param localPort * @throws java.io.IOException */ public VirtualSocket(String host, int port, InetAddress localAddr, int localPort) throws IOException { this(InetAddress.getByName(host), port, localAddr, localPort); } /** * See superclass javadoc. * @param address * @param port * @param localAddr * @param localPort * @throws java.io.IOException */ public VirtualSocket(InetAddress address, int port, InetAddress localAddr, int localPort) throws IOException { this(); connect(new InetSocketAddress(address, port), new InetSocketAddress(localAddr, localPort), 0); if (debug) log.debug("created virtual socket on port: " + localSocketId.getPort()); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are required of all Socket's '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /************************************************************************************************* * public methods in Socket class * ok: public void connect(SocketAddress endpoint) throws IOException; ok: public void connect(SocketAddress endpoint, int timeout) throws IOException; ok: public void bind(SocketAddress bindpoint) throws IOException; ok: public InetAddress getInetAddress(); ok: public InetAddress getLocalAddress(); ok: public int getPort(); ok: public int getLocalPort(); ok: public SocketAddress getRemoteSocketAddress(); ok: public SocketAddress getLocalSocketAddress(); ok: public SocketChannel getChannel(); ok: public InputStream getInputStream() throws IOException; ok: public OutputStream getOutputStream() throws IOException; ok: public void setTcpNoDelay(boolean on) throws SocketException; ok: public boolean getTcpNoDelay() throws SocketException; ok: public void setSoLinger(boolean on, int linger) throws SocketException; ok: public int getSoLinger() throws SocketException; ok: public void sendUrgentData(int data) throws IOException; ok: public void setOOBInline(boolean on) throws SocketException; ok: public boolean getOOBInline() throws SocketException; ok: public void setSoTimeout(int timeout) throws SocketException; ok: public int getSoTimeout() throws SocketException; ok: public void setSendBufferSize(int size) throws SocketException; ok: public int getSendBufferSize() throws SocketException; ok: public void setReceiveBufferSize(int size) throws SocketException; ok: public int getReceiveBufferSize() throws SocketException; ok: public void setKeepAlive(boolean on) throws SocketException; ok: public boolean getKeepAlive() throws SocketException; ok: public void setTrafficClass(int tc) throws SocketException; ok: public int getTrafficClass() throws SocketException; ok: public void setReuseAddress(boolean on) throws SocketException; ok: public boolean getReuseAddress() throws SocketException; ok: public void close() throws IOException; ok: public void shutdownInput() throws IOException; ok: public void shutdownOutput() throws IOException; ok: public String toString(); ok: public boolean isConnected(); ok: public boolean isBound(); ok: public boolean isClosed(); ok: public boolean isInputShutdown(); ok: public boolean isOutputShutdown(); *************************************************************************************************/ /** * See superclass javadoc. */ public void bind(SocketAddress address) throws IOException { if (isClosed()) throw new SocketException("Socket is closed"); if (isBound()) throw new SocketException("Already bound"); if (address != null && (!(address instanceof InetSocketAddress))) throw new IllegalArgumentException("Unsupported address type"); InetSocketAddress inetAddress = (InetSocketAddress) address; if (inetAddress != null && inetAddress.isUnresolved()) throw new SocketException("Unresolved address"); manager = MultiplexingManager.getaManagerByLocalAddress(inetAddress, configuration); actualSocket = manager.getSocket(); localSocketId = new SocketId(); if (debug) log.debug("bound virtual socket to port: " + localSocketId.getPort()); bound = true; } /** * See superclass javadoc. */ public void close() throws IOException { if (closed) return; log.debug("closing: " + localSocketId); closed = true; if (connected && !receivedDisconnectMessage) protocol.disconnect(remoteSocketId); if (inputStream != null) inputStream.close(); if (outputStream != null) { outputStream.flush(); outputStream.close(); } if (localSocketId != null) localSocketId.releasePort(); // This VirtualSocket might have been unregistered when connect() failed. if (manager.isSocketRegistered(this.localSocketId)) { MultiplexingManager.addToPendingActions(new PendingClose(this)); } if (debug) log.debug("virtual socket closed on port: " + localSocketId.getPort()); } /** * See superclass javadoc. */ public void connect(SocketAddress socketAddress) throws IOException { connect(socketAddress, null, timeout); } /** * See superclass javadoc. */ public void connect(SocketAddress socketAddress, int timeout) throws IOException { connect(socketAddress, null, timeout); } /** * See superclass javadoc. */ public SocketChannel getChannel() { return null; } /** * See superclass javadoc. */ public InetAddress getInetAddress() { if (actualSocket == null) return null; return actualSocket.getInetAddress(); } /** * See superclass javadoc. */ public InputStream getInputStream() throws IOException { if (isClosed()) throw new SocketException("Socket is closed"); if (actualSocket == null || !connected) throw new SocketException("Socket is not connected"); if (isInputShutdown()) throw new SocketException("Socket input is shutdown"); return inputStream; } /** * See superclass javadoc. */ public boolean getKeepAlive() throws SocketException { if (actualSocket == null) return false; return actualSocket.getKeepAlive(); } /** * See superclass javadoc. * Note. Socket.getLocalAddress() returns "wildcard" address for an unbound socket. */ public InetAddress getLocalAddress() { if (actualSocket == null) { if (dummySocket == null) dummySocket = new Socket(); return dummySocket.getLocalAddress(); } // The following is a workaround for a problem in NIO sockets, which sometimes // return "0.0.0.0" instead of "127.0.0.1". InetAddress address = actualSocket.getLocalAddress(); try { if ("0.0.0.0".equals(address.getHostAddress())) return InetAddress.getByName("localhost"); } catch (UnknownHostException e) { return address; } return address; } /** * See superclass javadoc. */ public int getLocalPort() { if (actualSocket == null) return -1; return actualSocket.getLocalPort(); } /** * See superclass javadoc. */ public SocketAddress getLocalSocketAddress() { if (actualSocket == null) return null; SocketAddress address = actualSocket.getLocalSocketAddress(); InetSocketAddress socketAddress = null; // The following is a workaround for a problem in NIO sockets, which sometimes // return "0.0.0.0" instead of "127.0.0.1". if (address instanceof InetSocketAddress) { socketAddress = (InetSocketAddress) address; if ("0.0.0.0".equals(socketAddress.getHostName()) || socketAddress.getAddress() == null) return new InetSocketAddress("localhost", socketAddress.getPort()); } return address; } /** * See superclass javadoc. */ public boolean getOOBInline() throws SocketException { return false; } /** * See superclass javadoc. */ public OutputStream getOutputStream() throws IOException { if (isClosed()) throw new SocketException("Socket is closed"); if (actualSocket == null || !connected) throw new SocketException("Socket is not connected"); if (isOutputShutdown()) throw new SocketException("Socket output is shutdown"); // TODO: return distinct output streams? See PlainSocketImpl. //return new SocketOutputStream(this); return outputStream; } /** * See superclass javadoc. */ public int getPort() { if (actualSocket == null) return 0; return actualSocket.getPort(); } /** * See superclass javadoc. */ public int getReceiveBufferSize() throws SocketException { if (actualSocket == null) { if (dummySocket == null) dummySocket = new Socket(); return dummySocket.getReceiveBufferSize(); } return actualSocket.getReceiveBufferSize(); } /** * See superclass javadoc. */ public SocketAddress getRemoteSocketAddress() { if (actualSocket == null) return null; return actualSocket.getRemoteSocketAddress(); } /** * See superclass javadoc. */ public boolean getReuseAddress() throws SocketException { if (actualSocket == null) return false; return actualSocket.getReuseAddress(); } /** * See superclass javadoc. */ public int getSendBufferSize() throws SocketException { if (actualSocket == null) { if (dummySocket == null) dummySocket = new Socket(); return dummySocket.getSendBufferSize(); } return actualSocket.getSendBufferSize(); } /** * See superclass javadoc. */ public int getSoLinger() throws SocketException { if (actualSocket == null) return -1; return actualSocket.getSoLinger(); } /** * See superclass javadoc. */ public int getSoTimeout() throws SocketException { if (isClosed()) throw new SocketException("Socket is closed"); return timeout; } /** * See superclass javadoc. */ public boolean getTcpNoDelay() throws SocketException { if (actualSocket == null) return false; return actualSocket.getTcpNoDelay(); } /** * See superclass javadoc. */ public int getTrafficClass() throws SocketException { if (actualSocket == null) return 0; return actualSocket.getTrafficClass(); } /** * See superclass javadoc. */ public boolean isBound() { return bound; } /** * See superclass javadoc. */ public boolean isClosed() { return closed; } /** * See superclass javadoc. */ public boolean isConnected() { return connected; } /** * See superclass javadoc. */ public boolean isInputShutdown() { return inputShutdown; } /** * See superclass javadoc. */ public boolean isOutputShutdown() { return outputShutdown; } /** * This method is not implemented. *

          * See superclass javadoc. */ public void sendUrgentData(int data) throws IOException { log.warn("sendUrgentData() called: ignored"); if (isClosed()) throw new IOException("Socket Closed"); } /** * See superclass javadoc. */ public void setKeepAlive(boolean on) throws SocketException { if (actualSocket != null) actualSocket.setKeepAlive(on); } /** * */ public void setOOBInline(boolean on) throws SocketException { log.warn("setOOBInLine() called: ignored"); if (isClosed()) throw new SocketException("Socket is closed"); } /** * See superclass javadoc. */ public void setReceiveBufferSize(int size) throws SocketException { if (actualSocket != null) actualSocket.setReceiveBufferSize(size); } /** * See superclass javadoc. */ public void setReuseAddress(boolean on) throws SocketException { if (actualSocket != null) actualSocket.setReuseAddress(on); } /** * See superclass javadoc. */ public void setSendBufferSize(int size) throws SocketException { if (actualSocket != null) actualSocket.setSendBufferSize(size); } /** * See superclass javadoc. */ public void setSoLinger(boolean on, int linger) throws SocketException { if (actualSocket != null) actualSocket.setSoLinger(on, linger); } /** * See superclass javadoc. */ public void setSoTimeout(int timeout) throws SocketException { if (isClosed()) throw new SocketException("Socket is closed"); if (timeout < 0) throw new IllegalArgumentException("timeout can't be negative"); this.timeout = timeout; if (inputStream != null) inputStream.setTimeout(timeout); } /** * See superclass javadoc. */ public void setTcpNoDelay(boolean on) throws SocketException { if (actualSocket != null) actualSocket.setTcpNoDelay(on); } /** * See superclass javadoc. */ public void setTrafficClass(int tc) throws SocketException { if (actualSocket != null) actualSocket.setTrafficClass(tc); } /** * See superclass javadoc. */ public void shutdownInput() throws IOException { if (isClosed()) throw new SocketException("Socket is closed"); if (!isConnected()) throw new SocketException("Socket is not connected"); if (isInputShutdown()) throw new SocketException("Socket input is already shutdown"); inputStream.setEOF(); inputShutdown = true; // protocol.notifyInputShutdown(localSocketId); } /** * See superclass javadoc. */ public void shutdownOutput() throws IOException { if (isClosed()) throw new SocketException("Socket is closed"); if (!isConnected()) throw new SocketException("Socket is not connected"); if (isOutputShutdown()) throw new SocketException("Socket output is already shutdown"); outputStream.shutdown(); outputShutdown = true; protocol.notifyOutputShutdown(remoteSocketId); } /** * See superclass javadoc. */ public String toString() { StringBuffer answer = new StringBuffer().append("VirtualSocket["); if (actualSocket == null) answer.append("unbound"); else answer.append(actualSocket.toString()); return answer.append("]").toString(); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are specific to VirtualSockets /// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ public void addDisconnectListener(DisconnectListener listener) { disconnectListeners.add(listener); } /** * */ public void connect(SocketAddress remoteAddress, SocketAddress localAddress, int timeout) throws IOException { log.debug("entering connect()"); long start = System.currentTimeMillis(); int timeLeft = 0; if (remoteAddress == null) throw new IllegalArgumentException("connect: The address can't be null"); if (timeout < 0) throw new IllegalArgumentException("connect: timeout can't be negative"); if (isClosed()) throw new SocketException("Socket is closed"); if (isConnected()) throw new SocketException("already connected"); if (!(remoteAddress instanceof InetSocketAddress)) throw new IllegalArgumentException("Unsupported address type"); InetSocketAddress remoteInetSocketAddress = (InetSocketAddress) remoteAddress; SecurityManager security = System.getSecurityManager(); if (security != null) { if (remoteInetSocketAddress.isUnresolved()) security.checkConnect(remoteInetSocketAddress.getHostName(), remoteInetSocketAddress.getPort()); else security.checkConnect(remoteInetSocketAddress.getAddress().getHostAddress(), remoteInetSocketAddress.getPort()); } if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); if (manager == null) { if (localAddress == null) manager = MultiplexingManager.getaShareableManager(remoteInetSocketAddress, timeLeft, configuration); else { InetSocketAddress localInetSocketAddress = (InetSocketAddress) localAddress; manager = MultiplexingManager.getaShareableManagerByAddressPair(remoteInetSocketAddress, localInetSocketAddress, timeLeft, configuration); } } try { if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); manager.connect(remoteInetSocketAddress, timeLeft); actualSocket = manager.getSocket(); protocol = manager.getProtocol(); if (!bound) { localSocketId = new SocketId(); bound = true; } inputStream = manager.registerSocket(this); inputStream.setTimeout(timeout); if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); remoteSocketId = protocol.connect(inputStream, localSocketId, timeLeft); outputStream = new MultiplexingOutputStream(manager, this, remoteSocketId); } catch (IOException e) { // Calling unRegisterSocket() will lead to this VirtualSocket being closed. try { manager.unRegisterSocket(this); } catch (IOException ignored) { // May not be registered yet. } if (e instanceof SocketTimeoutException) throw new SocketTimeoutException("connect timed out"); throw e; } finally { if (inputStream != null) inputStream.setTimeout(this.timeout); } connected = true; } public MultiplexingManager getMultiplexingManager() { return manager; } public int getVirtualPort() { return remoteSocketId.getPort(); } public int getLocalVirtualPort() { return localSocketId.getPort(); } /** * * @return */ public SocketId getLocalSocketId() { return localSocketId; } /** * @return */ public Socket getRealSocket() { return actualSocket; } /** * * @return */ public SocketId getRemoteSocketId() { return localSocketId; } /** * Returns true if and only if has not received notification of error state * on actual connection. * * @return true if and only if has not received notification of error state * on actual connection */ public boolean isFunctional() { return functional; } /** * * @param listener */ public void removeDisconnectListener(DisconnectListener listener) { if (!disconnectListeners.remove(listener)) log.error("attempt to remove unregistered DisconnectListener: " + listener); } /** * @param configuration */ public void setConfiguration(Map configuration) { this.configuration.putAll(configuration); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// Protected getters and setters '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * @return Returns the actualSocket. */ protected Socket getActualSocket() { return actualSocket; } /** * @param actualSocket The actualSocket to set. */ protected void setActualSocket(Socket actualSocket) { this.actualSocket = actualSocket; } // in socket API section ///** // * @return Returns the bound. // */ // public boolean isBound() // { // return bound; // } /** * @param bound The bound to set. */ protected void setBound(boolean bound) { this.bound = bound; } /** * @param closed The closed to set. */ protected void setClosed(boolean closed) { this.closed = closed; } /** * @param connected The connected to set. */ protected void setConnected(boolean connected) { this.connected = connected; } /** * @param inputShutdown The inputShutdown to set. */ protected void setInputShutdown(boolean inputShutdown) { this.inputShutdown = inputShutdown; } /** * @param inputStream The inputStream to set. */ protected void setInputStream(MultiplexingInputStream inputStream) { this.inputStream = inputStream; } /** * @param localSocketId The localSocketId to set. */ protected void setLocalSocketId(SocketId localSocketId) { this.localSocketId = localSocketId; } /** * * @return */ protected MultiplexingManager getManager() { return manager; } /** * @param manager The manager to set. */ protected void setManager(MultiplexingManager manager) { this.manager = manager; } /** * @param outputShutdown The outputShutdown to set. */ protected void setOutputShutdown(boolean outputShutdown) { this.outputShutdown = outputShutdown; } /** * @param outputStream The outputStream to set. */ protected void setOutputStream(MultiplexingOutputStream outputStream) { this.outputStream = outputStream; } /** * @return Returns the protocol. */ protected Protocol getProtocol() { return protocol; } /** * @param protocol The protocol to set. */ protected void setProtocol(Protocol protocol) { this.protocol = protocol; } /** * * @return */ protected boolean hasReceivedDisconnectMessage() { return receivedDisconnectMessage; } /** * * @param receivedDisconnectMessage */ protected void setReceivedDisconnectMessage(boolean receivedDisconnectMessage) { this.receivedDisconnectMessage = receivedDisconnectMessage; } /** * @param remoteSocketId The remoteSocketId to set. */ protected void setRemoteSocketId(SocketId remoteSocketId) { this.remoteSocketId = remoteSocketId; } ////////////////////////////////////////////////////////////////////////////////////////////////// /// Other protected methods '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * */ protected void doClose() { if (debug) log.debug("doClose()" + this.localSocketId.getPort()); try { // if (connected && !receivedDisconnectMessage) // protocol.disconnect(remoteSocketId); // This VirtualSocket might have been unregistered when connect() failed. if (manager.isSocketRegistered(getLocalSocketId())) manager.unRegisterSocket(this); if (debug) log.debug("virtual socket closed on port: " + remoteSocketId.getPort()); } catch (Exception e) { log.error("error closing socket: " + this); log.error(e); } } /** * * @throws IOException */ protected void handleRemoteOutputShutDown() throws IOException { // already closed ? try { inputStream.handleRemoteShutdown(); } catch (NullPointerException ignored) { } } /** * * @throws IOException */ protected void handleRemoteDisconnect() throws IOException { if (isClosed()) return; if (debug) log.debug("remote virtual socket disconnecting: local port: " + getLocalVirtualPort()); receivedDisconnectMessage = true; // already closed ? if (inputStream != null) inputStream.handleRemoteShutdown(); // already closed ? if (outputStream != null) { outputStream.flush(); outputStream.handleRemoteDisconnect(); } MultiplexingManager.addToPendingActions(new PendingRemoteDisconnect(this)); log.debug("handleRemoteDisconnect(): done."); // TODO // connected = false; // inputShutdown = true; // outputShutdown = true; } /** * Indicate error condition on actual connection. */ protected void notifyOfException() { functional = false; } protected class PendingRemoteDisconnect extends PendingAction { public PendingRemoteDisconnect(Object o) { super(o); } void doAction() { VirtualSocket vs = (VirtualSocket) o; Set disconnectListeners = vs.disconnectListeners; Iterator it = disconnectListeners.iterator(); while (it.hasNext()) ((DisconnectListener) it.next()).notifyDisconnected(vs); } } protected class PendingClose extends PendingAction { public PendingClose(Object o) { super(o); } public void doAction() { ((VirtualSocket)o).doClose(); } } }././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/VirtualServerSocket.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/VirtualServerS0000644000175000017500000005532710753261335033621 0ustar twernertwerner/* * 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. */ /* * Created on Jul 23, 2005 */ package org.jboss.remoting.transport.multiplex; import org.jboss.logging.Logger; import java.io.IOException; import java.io.InterruptedIOException; import java.io.Serializable; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketAddress; import java.net.SocketException; import java.net.SocketTimeoutException; import java.nio.channels.ServerSocketChannel; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; /** * VirtualServerSocket is one of the two implementations of a server socket in the * Multiplex project. Each VirtualServerSocket belongs to an existing virtual * socket group, and each VirtualScoket it creates is added to that virtual socket * group. For more details, see the Multiplex documentation on * the labs.jboss.org web site. * *

          * Most of the methods in VirtualServerSocket override those in its parent class, * java.net.ServerSocket. For method descriptions, see the ServerSocket * javadoc. * *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class VirtualServerSocket extends ServerSocket implements Serializable { private static final Logger log = Logger.getLogger(VirtualServerSocket.class); private List acceptingThreads = Collections.synchronizedList(new LinkedList()); private Map configuration = new HashMap(); private MultiplexingManager manager; private MultiplexingInputStream is; private MultiplexingInputStream cis; private Protocol protocol; private Socket actualSocket; private int timeout; private boolean bound = false; private boolean connected = false; private boolean closed = false; private Socket dummySocket; private static final long serialVersionUID = -5320724929164012313L; ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following constructors duplicate those of the parent class ServerSocket '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * @throws java.io.IOException */ public VirtualServerSocket() throws IOException { } /** * * See superclass javadoc. * * @param port * @throws IOException */ public VirtualServerSocket(int port) throws IOException { bind(new InetSocketAddress(port)); log.debug("created VirtualServerSocket: " + toString()); } /** * See superclass javadoc. * * @param port * @param backlog * @throws java.io.IOException */ public VirtualServerSocket(int port, int backlog) throws IOException { this(port); log.warn("backlog parameter is ignored"); log.debug("created VirtualServerSocket: " + toString()); } /** * See superclass javadoc. * * @param port * @param backlog * @param bindAddr * @throws java.io.IOException */ public VirtualServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException { bind(new InetSocketAddress(bindAddr, port)); log.warn("backlog parameter is ignored"); log.debug("created VirtualServerSocket: " + toString()); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following constructors are particular to VirtualServerSocket '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * See superclass javadoc. * @param configuration */ public VirtualServerSocket(VirtualSocket socket, Map configuration) throws IOException { this.actualSocket = socket.getActualSocket(); if (configuration != null) this.configuration.putAll(configuration); manager = socket.getManager(); manager.incrementReferences(); bind(new InetSocketAddress(socket.getLocalAddress(), socket.getLocalPort())); log.debug("created VirtualServerSocket: " + toString()); } /** * * See superclass javadoc. * * @param timeout * @param configuration * @param port * @throws IOException */ public VirtualServerSocket(InetSocketAddress remoteAddress, InetSocketAddress localAddress, int timeout, Map configuration) throws IOException { if (configuration != null) this.configuration.putAll(configuration); connect(remoteAddress, localAddress, timeout); log.debug("created VirtualServerSocket: " + toString()); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are required of any ServerSocket '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /* ok: public void bind(SocketAddress endpoint) throws IOException; ok: public void bind(SocketAddress endpoint, int backlog) throws IOException; ok: public InetAddress getInetAddress(); ok: public int getLocalPort(); ok: public SocketAddress getLocalSocketAddress(); ok: public Socket accept() throws IOException; ok: public void close() throws IOException; ok: public ServerSocketChannel getChannel(); ok: public boolean isBound(); ok: public boolean isClosed(); ok: public void setSoTimeout(int timeout) throws SocketException; ok: public int getSoTimeout() throws IOException; ok: public void setReuseAddress(boolean on) throws SocketException; ok: public boolean getReuseAddress() throws SocketException; ok: public String toString(); ok: public void setReceiveBufferSize(int size) throws SocketException; ok: public int getReceiveBufferSize() throws SocketException; */ /** * See superclass javadoc. */ public synchronized Socket accept() throws IOException { log.debug("entering accept()"); long start = System.currentTimeMillis(); int timeout = getSoTimeout(); int timeLeft = 0; if (isClosed()) throw new SocketException("Socket is closed"); if (!isBound()) throw new SocketException("Socket is not bound yet"); SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkAccept(actualSocket.getInetAddress().getHostAddress(), actualSocket.getPort()); } Thread currentThread = Thread.currentThread(); acceptingThreads.add(currentThread); VirtualSocket virtualSocket = null; try { if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) { log.error("timed out"); throw new SocketTimeoutException("Accept timed out"); } log.debug("timeLeft: " + timeLeft); SocketId clientPort = protocol.acceptConnect(is, timeLeft); log.debug("clientPort: " + clientPort.getPort()); virtualSocket = new VirtualSocket(manager, clientPort, configuration); manager.incrementReferences(); int localPort = virtualSocket.getLocalVirtualPort(); protocol.answerConnect((MultiplexingOutputStream) virtualSocket.getOutputStream(), localPort); return virtualSocket; } catch (IOException e) { if (e instanceof InterruptedIOException || "Socket closed".equals(e.getMessage()) || "An existing connection was forcibly closed by the remote host".equals(e.getMessage())) log.debug(e); else log.error(e); if (virtualSocket != null) virtualSocket.close(); if (isClosed()) throw new SocketException("Socket closed"); if (e instanceof SocketTimeoutException) throw new SocketTimeoutException("Accept timed out"); throw e; } finally { acceptingThreads.remove(currentThread); if (isClosed()) { if (virtualSocket != null) virtualSocket.close(); throw new SocketException("Socket closed"); } } } /** * See superclass javadoc. */ public void bind(SocketAddress socketAddress) throws IOException { bind(socketAddress, 1); } /** * See superclass javadoc. */ public void bind(SocketAddress socketAddress, int backlog) throws IOException { if (backlog != 1) { log.warn("backlog != 1: ignored"); } if (isClosed()) throw new SocketException("Socket is closed"); if (isBound()) throw new SocketException("Already bound"); if (socketAddress == null) socketAddress = new InetSocketAddress(0); if (!(socketAddress instanceof InetSocketAddress)) throw new IllegalArgumentException("Unsupported address type"); InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress; if (inetSocketAddress.isUnresolved()) throw new SocketException("Unresolved address"); SecurityManager security = System.getSecurityManager(); if (security != null) security.checkListen(inetSocketAddress.getPort()); if (manager == null) { manager = MultiplexingManager.getaManagerByLocalAddress(inetSocketAddress, configuration); actualSocket = manager.getSocket(); } try { bound = true; is = manager.registerServerSocket(this); cis = manager.getAnInputStream(SocketId.SERVER_SOCKET_CONNECT_ID, null); is.setTimeout(timeout); cis.setTimeout(timeout); if (manager.isConnected()) { protocol = manager.getProtocol(); // remote MultiplexingManager might be shutting down and refuse to register ServerSocket protocol.registerRemoteServerSocket(getSoTimeout()); connected = true; } } catch (IOException e) { bound = false; if (manager.isServerSocketRegistered()) manager.unRegisterServerSocket(this); throw e; } log.debug(toString()); } /** * See superclass javadoc. */ public void close() throws IOException { if (isClosed()) return; closed = true; // Try once to interrupt accepting threads. if (!acceptingThreads.isEmpty()) { // We get a copy of acceptingThreads to avoid a ConcurrentModificationException when a thread // removes itself from acceptingThreads. LinkedList threads = new LinkedList(acceptingThreads); Iterator it = threads.iterator(); while (it.hasNext()) { Thread t = (Thread) it.next(); t.interrupt(); log.debug("interrupting accepting thread: " + t.getName()); } if (!acceptingThreads.isEmpty()) { MultiplexingManager.addToPendingActions(new PendingClose(this)); } } // We want the unregister request to go out to the remote MultiplexingManager first. // This way, if the local unregister request causes the local MultiplexingManager to // shut down, the remote MultiplexingManager will get the unregisterRemoteServerSocket // request before it gets the shutdown manager request. if (protocol != null) protocol.unregisterRemoteServerSocket(); if (manager != null) manager.unRegisterServerSocket(this); } /** * See superclass javadoc. */ public InetAddress getInetAddress() { if (actualSocket == null) return null; return actualSocket.getInetAddress(); } /** * See superclass javadoc. */ public int getLocalPort() { if (actualSocket == null) return -1; return actualSocket.getLocalPort(); } /** * See superclass javadoc. */ public ServerSocketChannel getChannel() { return null; } /** * See superclass javadoc. */ public SocketAddress getLocalSocketAddress() { if (actualSocket == null) return null; return actualSocket.getLocalSocketAddress(); } /** * See superclass javadoc. */ public int getReceiveBufferSize() throws SocketException { if (actualSocket == null) { if (dummySocket == null) dummySocket = new Socket(); return dummySocket.getReceiveBufferSize(); } return actualSocket.getReceiveBufferSize(); } /** * See superclass javadoc. */ public boolean getReuseAddress() throws SocketException { if (actualSocket == null) return true; else return actualSocket.getReuseAddress(); } /** * See superclass javadoc. */ public int getSoTimeout() throws SocketException { if (isClosed()) throw new SocketException("Socket is closed"); return timeout; } /** * See superclass javadoc. */ public boolean isBound() { return bound; } /** * See superclass javadoc. */ public boolean isClosed() { return closed; } /** * See superclass javadoc. */ public void setReceiveBufferSize (int size) throws SocketException { if (actualSocket != null) actualSocket.setReceiveBufferSize(size); } /** * See superclass javadoc. */ public void setReuseAddress(boolean on) throws SocketException { if (actualSocket != null) actualSocket.setReuseAddress(on); } /** * See superclass javadoc. */ public void setSoTimeout(int timeout) throws SocketException { if (isClosed()) throw new SocketException("Socket is closed"); if (timeout < 0) throw new IllegalArgumentException("timeout can't be negative"); this.timeout = timeout; if (is != null) is.setTimeout(timeout); if (cis != null) cis.setTimeout(timeout); } /** * See superclass javadoc. */ public String toString() { StringBuffer answer = new StringBuffer().append("VirtualServerSocket["); if (actualSocket == null) answer.append("unbound"); else answer.append(actualSocket.toString()); return answer.append("]").toString(); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are specific to VirtualServerSocket '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * See superclass javadoc. */ public void connect(SocketAddress remoteAddress) throws IOException { connect(remoteAddress, null, timeout); } /** * Connects this socket to the server. * * See superclass javadoc. */ public void connect(SocketAddress remoteAddress, SocketAddress localAddress) throws IOException { connect(remoteAddress, localAddress, timeout); } /** * See superclass javadoc. */ public void connect(SocketAddress remoteAddress, SocketAddress localAddress, int timeout) throws IOException { long start = System.currentTimeMillis(); int timeLeft = 0; if (remoteAddress == null) throw new IllegalArgumentException("connect: The address can't be null"); if (timeout < 0) throw new IllegalArgumentException("connect: timeout can't be negative"); if (isClosed()) throw new SocketException("Socket is closed"); if (!(remoteAddress instanceof InetSocketAddress)) throw new IllegalArgumentException("Unsupported address type"); InetSocketAddress remoteInetSocketAddress = (InetSocketAddress) remoteAddress; SecurityManager security = System.getSecurityManager(); if (security != null) { if (remoteInetSocketAddress.isUnresolved()) security.checkConnect(remoteInetSocketAddress.getHostName(), remoteInetSocketAddress.getPort()); else security.checkConnect(remoteInetSocketAddress.getAddress().getHostAddress(), remoteInetSocketAddress.getPort()); } // Binding entails getting a MultiplexingManager, which might already be connected, // thereby putting the ServerSocket in a connected state. Therefore, we allow connect() to be // called on a connected ServerSocket, as long as the host to which it is to be connected // is the same as the host to which it is already connected. if (isConnected()) if (getRemoteAddress().equals(remoteInetSocketAddress.getAddress())) return; else throw new SocketException("already connected"); if (manager == null) { if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); if (localAddress == null) manager = MultiplexingManager.getaManagerByRemoteAddress(remoteInetSocketAddress, timeLeft, configuration); else { InetSocketAddress localInetSocketAddress = (InetSocketAddress) localAddress; manager = MultiplexingManager.getaManagerByAddressPair(remoteInetSocketAddress, localInetSocketAddress, timeLeft, configuration); } } actualSocket = manager.getSocket(); try { if (!isBound()) { log.debug("calling registerServerSocket()"); is = manager.registerServerSocket(this); cis = manager.getAnInputStream(SocketId.SERVER_SOCKET_CONNECT_ID, null); is.setTimeout(this.timeout); cis.setTimeout(this.timeout); bound = true; } // If the manager is not connected, we need to connect to the remote MasterServerSocket, which // will create a real socket and a MultiplexingManager to wrap it. if (!manager.isConnected()) { if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); manager.connect(remoteInetSocketAddress, timeLeft); protocol = manager.getProtocol(); if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); cis.setTimeout(timeout); protocol.connect(cis, SocketId.SERVER_SOCKET_ID, timeLeft); // Remote MultiplexingManager might be shutting down and refuse to register ServerSocket. // If so, registerRemoteServerSocket() will throw an IOException if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); } else protocol = manager.getProtocol(); if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); protocol.registerRemoteServerSocket(timeLeft); } catch (IOException e) { log.error("i/o exception in VirtualServerSocket.connect()", e); if (manager.isServerSocketRegistered()) manager.unRegisterServerSocket(this); if (e instanceof SocketTimeoutException) throw new SocketTimeoutException("connect timed out"); throw e; } finally { if (cis != null) cis.setTimeout(this.timeout); } connected = true; log.debug(toString()); } /** * @return */ public MultiplexingManager getMultiplexingManager() { return manager; } /** * See superclass javadoc. */ public boolean isConnected() { return connected; } /** * See superclass javadoc. */ public InetAddress getRemoteAddress() { if (actualSocket == null) return null; return actualSocket.getInetAddress(); } /** * See superclass javadoc. */ public int getRemotePort() { if (actualSocket == null) return 0; return actualSocket.getPort(); } /** * See superclass javadoc. */ public void setConfiguration(Map configuration) { this.configuration.putAll(configuration); } /** * */ protected void doClose() { // We get a copy of acceptingThreads to avoid a ConcurrentModificationException when a thread // removes itself from acceptingThreads. LinkedList threads = new LinkedList(acceptingThreads); Iterator it = threads.iterator(); while (it.hasNext()) { Thread t = (Thread) it.next(); t.interrupt(); log.debug("interrupting accepting thread: " + t.getName()); // Make sure the accepting thread caught the interrupt. while (acceptingThreads.contains(t)) { try { log.debug("waiting for accepting thread to catch interrupt: " + t.getName()); Thread.sleep(500); t.interrupt(); log.debug("interrupting accepting thread: " + t.getName()); } catch (InterruptedException ignored) {} } } } protected class PendingClose extends PendingAction { public PendingClose(Object o) { super(o); } public void doAction() { ((VirtualServerSocket) o).doClose(); } } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexingOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexingOu0000644000175000017500000002305510753261335033637 0ustar twernertwerner/* * 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. */ /* * Created on Jul 22, 2005 */ package org.jboss.remoting.transport.multiplex; import java.io.IOException; import java.io.OutputStream; import java.net.SocketException; import org.jboss.logging.Logger; /** * MultiplexingOutputStream is the class returned by * VirtualSocket.getOutputStream(). * It supports the methods and behavior implemented by the OutputStream returned by * java.net.Socket.getOutputStream(). For more information about the behavior * of the methods, see the javadoc for java.io.OutputStream. *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class MultiplexingOutputStream extends OutputStream { protected static final Logger log = Logger.getLogger(MultiplexingOutputStream.class); private MultiplexingManager manager; private OutputMultiplexor outputMultiplexor; private VirtualSocket virtualSocket; private SocketId socketId; private boolean outputShutdown = false; private boolean closed = false; private IOException writeException; private static final int OPEN = 0; private static final int CONNECTION_RESET = 1; private static final int CLOSED = 2; private int connectionState = OPEN; private byte[] oneByte = new byte[1]; private byte[] fourBytes = new byte[4]; /** * * @param manager * @param socketId */ public MultiplexingOutputStream(MultiplexingManager manager, SocketId socketId) { this(manager, null, socketId); } /** * * @param manager * @param virtualSocket * @param socketId */ public MultiplexingOutputStream(MultiplexingManager manager, VirtualSocket virtualSocket, SocketId socketId) { this.manager = manager; this.virtualSocket = virtualSocket; this.socketId = socketId; this.outputMultiplexor = manager.getOutputMultiplexor(); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are required of all OutputStreams '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /************************************************************************************************* ok: public void write(int b) throws IOException; ok: public void write(byte b[]) throws IOException; ok: public void write(byte b[], int off, int len) throws IOException; public void flush() throws IOException; ok: public void close() throws IOException; *************************************************************************************************/ /** * See superclass javadoc. */ public void close() throws IOException { log.debug("MultiplexingOutputStream.close() entered"); if (closed) return; closed = true; if (virtualSocket != null) virtualSocket.close(); } /** * See superclass javadoc. */ public void flush() throws IOException { // Could use flush() to raise priority of messages waiting in OutputMultiplexor's write queue. } /** * See superclass javadoc. */ public void write(int i) throws IOException { checkStatus(); oneByte[0] = (byte) i; outputMultiplexor.write(manager, socketId, oneByte); } /** * See superclass javadoc. */ public void write(byte[] array) throws IOException, NullPointerException { checkStatus(); outputMultiplexor.write(manager, socketId, array); } /** * See superclass javadoc. */ public void write(byte[] array, int off, int len) throws IOException, NullPointerException, IndexOutOfBoundsException { checkStatus(); if (array == null) throw new NullPointerException(); if (off < 0 || len < 0 || off + len > array.length) throw new IndexOutOfBoundsException(); byte[] subArray = new byte[len]; for (int i = 0; i < len; i++) subArray[i] = array[off + i]; outputMultiplexor.write(manager, socketId, subArray); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are specific to MultiplexingOutputStream '/// ////////////////////////////////////////////////////////////////////////////////////////////////// protected void setWriteException(IOException e) { writeException = e; } /** * writeInt() is borrowed from DataOutputStream. * It saves the extra expense of creating a DataOutputStream. * @param i * @throws IOException */ public void writeInt(int i) throws IOException { fourBytes[0] = (byte) ((i >>> 24) & 0xff); fourBytes[1] = (byte) ((i >>> 16) & 0xff); fourBytes[2] = (byte) ((i >>> 8) & 0xff); fourBytes[3] = (byte) ((i >>> 0) & 0xff); outputMultiplexor.write(manager, socketId, fourBytes); } /** * Determines how to handle a write request depending on what this socket knows about the state * of the peer socket. *

          * Once this socket knows that the peer socket has closed, no more write requests will be honored. * There seem to be two ways for a socket A to learn that its peer socket B has closed. *

          *

            *
          1. If socket A has executed a write, but no subsequent write is performed on B, * then the acknowledgement of the write will carry back the information that B has closed. *
          2. If socket B has no pending acknowledgements to send at the time it closes, and then socket A * does a write after B has closed, the (negative) acknowledgement of the write will carry back * the information that B has closed. *
          *

          * Java seems to respond differently to the two cases. The first write after this socket has learned * of the peer's closing through the first scenario will result in a SocketException("Connection reset"). * In the second scenario, the first write by this socket after the peer has closed * will quietly fail (no exception is thrown). All subsequent writes after either of these two * scenarios will result in a SocketException("Broken pipe"). *

          * Currently, MultiplexingOutputStream implements only a simplified version of this behavior. In * particular, it allows in all cases one write to silently fail, after which all writes result in a * SocketException("Broken pipe"); *

          * Note. This discussion is based on empirical observation on a linux system, not on examination of code. * Your mileage may vary. */ protected void checkStatus() throws IOException { if (closed) throw new SocketException("Socket closed"); if (outputShutdown) throw new SocketException("Broken pipe"); if (writeException != null) throw writeException; switch (connectionState) { case OPEN: return; case CONNECTION_RESET: connectionState = CLOSED; return; case CLOSED: throw new SocketException("Broken pipe"); default: log.error("unrecognized connection state: " + connectionState); } } /** * */ protected void handleRemoteDisconnect() { log.debug("entering handleRemoteDisconnect()"); switch (connectionState) { case OPEN: connectionState = CONNECTION_RESET; return; default: connectionState = CLOSED; log.error("invalid connection state in handleRemoteDisconnect(): " + connectionState); } } /** * */ protected void shutdown() { outputShutdown = true; } /** * @param i * @param brackets * @throws IOException */ protected void write(int i, int brackets) throws IOException { log.debug("brackets: " + brackets); oneByte[0] = (byte) i; outputMultiplexor.write(manager, socketId, oneByte, brackets); } /** * @param i * @param brackets * @throws IOException */ protected void writeInt(int i, int brackets) throws IOException { log.debug("brackets: " + brackets); fourBytes[0] = (byte) ((i >>> 24) & 0xff); fourBytes[1] = (byte) ((i >>> 16) & 0xff); fourBytes[2] = (byte) ((i >>> 8) & 0xff); fourBytes[3] = (byte) ((i >>> 0) & 0xff); outputMultiplexor.write(manager, socketId, fourBytes, brackets); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/VirtualServerSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/VirtualServerS0000644000175000017500000001042110753261335033603 0ustar twernertwerner/* * 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. */ /* * Created on Aug 21, 2005 */ package org.jboss.remoting.transport.multiplex; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import javax.net.ServerSocketFactory; import org.jboss.logging.Logger; /** * VirtualServerSocketFactory extends the * javax.net.ServerSocketFactory class and reimplements * its createServerSocket() methods. By default it creates * MasterServerSockets, but * if the setOnClient() method has been called and the * setOnServer() method has not * been called more recently, VirtualServerSocketFactory creates * VirtualServerSockets. * *

          * @author Ron Sigal * @version $Revision: 3443 $ *

          * Copyright (c) 2005 *

          * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class VirtualServerSocketFactory extends ServerSocketFactory { protected static final Logger log = Logger.getLogger(VirtualServerSocketFactory.class); boolean onClient = false; public static ServerSocketFactory getDefault() { return new VirtualServerSocketFactory(); } protected VirtualServerSocketFactory() { } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are required of all ServerSocketFactory's '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * See superclass javadoc. */ public ServerSocket createServerSocket(int port) throws IOException { if (isOnClient()) return new VirtualServerSocket(port); else return new MasterServerSocket(port); } /** * See superclass javadoc. */ public ServerSocket createServerSocket(int port, int backlog) throws IOException { if (isOnClient()) { log.warn("backlog parameter is ignored"); return new VirtualServerSocket(port, backlog); } else return new MasterServerSocket(port, backlog); } /** * See superclass javadoc. */ public ServerSocket createServerSocket(int port, int backlog, InetAddress address) throws IOException { if (isOnClient()) { log.warn("backlog parameter is ignored"); return new VirtualServerSocket(port, backlog, address); } else return new MasterServerSocket(port, backlog, address); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are specific to VirtualServerSocketFactory '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * @return */ public boolean isOnClient() { return onClient; } /** * @return */ public boolean isOnServer() { return !onClient; } /** * @return */ public boolean setOnClient() { boolean temp = onClient; onClient = true; return temp; } /** * @return */ public boolean setOnServer() { boolean temp = onClient; onClient = false; return !temp; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/SocketId.java0000644000175000017500000001614010753261335033274 0ustar twernertwerner/* * 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. */ /* * Created on Jul 22, 2005 */ package org.jboss.remoting.transport.multiplex; import org.apache.log4j.Logger; import java.io.IOException; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.util.HashSet; /** * A SocketId wraps an integer that identifies an endpoint of a * virtual connection. Each virtual * socket group is created with a standard set of system endpoints used * for protocol messages. These have standard negative integer values * that are reused in each virtual socket group. Virtual sockets are * created with a SocketId whose value is unique in its JVM. *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * TODO: verify bytes has no 0's * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class SocketId implements Serializable { protected static final Logger log = Logger.getLogger(SocketId.class); private static final String ISO_8859_1 = "ISO-8859-1"; public static final int PROTOCOL_PORT = -1; public static final int SERVER_SOCKET_PORT = -2; public static final int SERVER_SOCKET_CONNECT_PORT = -3; public static final int SERVER_SOCKET_VERIFY_PORT = -4; public static final int BACKCHANNEL_PORT = -5; public static final int DEADLETTER_PORT = -6; public static final int INITIAL_OUTPUT_PORT = -7; private static final int MIN_PORT = INITIAL_OUTPUT_PORT; private static int maxPort = Integer.MAX_VALUE - 1; public static final SocketId PROTOCOL_SOCKET_ID = new SocketId((short) PROTOCOL_PORT); public static final SocketId SERVER_SOCKET_ID = new SocketId((short) SERVER_SOCKET_PORT); public static final SocketId SERVER_SOCKET_CONNECT_ID = new SocketId((short) SERVER_SOCKET_CONNECT_PORT); public static final SocketId SERVER_SOCKET_VERIFY_ID = new SocketId((short) SERVER_SOCKET_VERIFY_PORT); public static final SocketId BACKCHANNEL_SOCKET_ID = new SocketId((short) BACKCHANNEL_PORT); public static final SocketId DEADLETTER_SOCKET_ID = new SocketId((short) DEADLETTER_PORT); public static final SocketId INITIAL_OUTPUT_SOCKET_ID = new SocketId((short) INITIAL_OUTPUT_PORT); private static HashSet portsInUse = new HashSet(); private static int nextNewPort = 1; private static boolean hasWrapped = false; private int port; byte[] bytes; private static final long serialVersionUID = 1126328489938867931L; /** * */ public SocketId() { port = getFreePort(); setBytes(port); } /** * * @param port */ public SocketId(int port) throws IOException { checkPortValue(port); this.port = port; setBytes(port); } /** * * @param id */ public SocketId(byte[] bytes) throws IOException { this.bytes = bytes; setPort(bytes); checkPortValue(port); } /** * * @param port */ protected SocketId(short port) { this.port = port; setBytes(port); } public byte[] toByteArray() { return bytes; } public int getPort() { return port; } public void releasePort() { freePort(port); } public static void setMaxPort(int max) { maxPort = max; } public boolean equals(Object o) { if (! (o instanceof SocketId)) return false; if (this.port == ((SocketId) o).port) return true; else return false; } public int hashCode() { return port; } public String toString() { return Integer.toString(port); } protected void checkPortValue(int port) throws IOException { if (port < MIN_PORT) { log.error("attempt to create port with illegal value: " + port); throw new IOException("attempt to create port with illegal value: " + port); } } protected void setPort(byte[] bytes) { try { port = Integer.parseInt(new String(bytes, ISO_8859_1)); } catch (UnsupportedEncodingException e) { // ISO-8859-1 should be standard in all Java implementations log.fatal("org.jboss.remoting.transport.multiplex.OutputMultiplexor(): charset ISO-8859-1 not found", e); throw new RuntimeException("org.jboss.remoting.transport.multiplex.OutputMultiplexor(): charset ISO-8859-1 not found", e); } catch (RuntimeException r) { log.error("problem with port: "); for (int i = 0; i < bytes.length; i++) log.error("" + bytes[i]); throw r; } } protected void setBytes(int port) { try { bytes = Integer.toString(port).getBytes(ISO_8859_1); } catch (UnsupportedEncodingException e) { // ISO-8859-1 should be standard in all Java implementations log.fatal("org.jboss.remoting.transport.multiplex.OutputMultiplexor(): charset ISO-8859-1 not found", e); throw new RuntimeException("org.jboss.remoting.transport.multiplex.OutputMultiplexor(): charset ISO-8859-1 not found", e); } } protected static synchronized void freePort(int port) { portsInUse.remove(new Integer(port)); SocketId.class.notifyAll(); } protected static synchronized int getFreePort() { // If we've used all ints and wrapped around, start over at 1. if (nextNewPort > maxPort) { nextNewPort = 1; hasWrapped = true; } if (hasWrapped) { if (portsInUse.size() >= maxPort) try { SocketId.class.wait(); } catch (InterruptedException ignored) { } while (true) { int port = nextNewPort > maxPort ? 1 : nextNewPort++; Integer portInteger = new Integer(port); if (!portsInUse.contains(portInteger)) { portsInUse.add(portInteger); return port; } } } else { int port = nextNewPort++; Integer portInteger = new Integer(port); portsInUse.add(portInteger); return port; } } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexServerInvoker.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexServe0000644000175000017500000014747211413670544033654 0ustar twernertwerner/* * 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.remoting.transport.multiplex; import java.io.EOFException; import java.io.IOException; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; import java.net.SocketTimeoutException; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; 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.net.ServerSocketFactory; import javax.net.ssl.HandshakeCompletedEvent; import javax.net.ssl.HandshakeCompletedListener; import org.jboss.logging.Logger; import org.jboss.remoting.Client; 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.ServerInvokerCallbackHandler; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.transport.PortUtil; import org.jboss.remoting.transport.multiplex.utility.AddressPair; import org.jboss.remoting.transport.socket.SocketServerInvoker; import org.jboss.remoting.util.socket.HandshakeRepeater; /** * MultiplexServerInvoker is the server side of the Multiplex transport. * For more information, see Remoting documentation on labs.jboss.org. * * @author Tom Elrod * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class MultiplexServerInvoker extends SocketServerInvoker implements Runnable, VirtualSocket.DisconnectListener { protected static final Logger log = Logger.getLogger(MultiplexServerInvoker.class); private static boolean trace = log.isTraceEnabled(); private static Map socketGroupMap = new HashMap(); private static Map addressPairMap = new HashMap(); private static HandshakeCompletedEvent handshakeCompletedEvent; private boolean isVirtual = false; private Map virtualServerInvokers; private Socket connectPrimingSocket; private SocketGroupInfo socketGroupInfo; private AddressPair addressPair; private String bindHost; private int bindPort; private int originalBindPort; private InetAddress bindAddress; private InetSocketAddress connectSocketAddress; private boolean readyToStart = true; private boolean needsSocketGroupConfiguration = true; private boolean cleanedUp; private boolean hasMaster; private int errorCount; private ServerSocket serverSocket; ///////////////////////////////////////////////////////////////////////////////////// // configurable Multiplex parameters // ///////////////////////////////////////////////////////////////////////////////////// /* * The following parameters may be set in any of four ways: * * 1. They may be appended to an InvokerLocator passed to a * Connector constructor. * 2. They may be included in a configuration Map passed to a * Connector constructor. * 3. They may be described in a XML element passed to * Connector.setConfiguration(). * 4. In some cases, a MultiplexServerInvoker setter methods may be invoked. * * Of those of the following parameters destined for MultiplexServerInvoker, * there are two categories. * * 1. serverMultiplexId, multiplexConnectHost, and * multiplexConnectPort are used to * match up MultiplexClientInvokers and virtual * MultiplexServerInvokers so that * they share an underlying socket connection. Depending on the way in which * the information is provided (see Remoting documentation), the connection may * be created any time during or after the call to Connector.create(). Note, * however, that if a callback MultiplexServerInvoker is created with just a * serverMultiplexId parameter (server rule 3 in the Remoting documentation), * then calling setMultiplexConnectHost() and * setMultiplexConnectPort() will * not trigger the creation of a connection. Moreover, when a Client comes * along, the connect information supplied by the Client will be used, so there * is no point to having setter methods for these parameters. * * 2. maxAcceptErrors is used in the * MultiplexServerInvoker accept() loop, and it * may be changed at any time by calling setMaxAcceptErrors(). * * Those of the following parameters which are destined for the MultiplexingManager, * InputMultiplexor, and OutputMultiplexor classes are * passed to them by way of a configuration Map passed to * VirtualSocket and VirtualServerSocket constructors. * * A VirtualServerSocket is created when a server side master * MultiplexServerInvoker * accepts a connection request generated by the creation of a priming socket on a client. * Since this can happen any time after Connector.start() is created, the values of * these parameters can be changed by calling their respective setter methods any * time before Connector.start() is called. * * A VirtualSocket is created when a client side * MultiplexClientInvoker or callback * MultiplexServerInvoker opens a priming socket, and this happens when * Connector.create() is called. Therefore, the values of these parameters can be * changed by calling their respective setter methods any time before * Connector.create() is called. */ // MultiplexingManager: private int staticThreadsMonitorPeriod; private int shutdownRequestTimeout; private int shutdownRefusalsMaximum; private int shutdownMonitorPeriod; // InputMultiplexor: private int inputBufferSize; private int inputMaxErrors; // OutputMultiplexor: private int outputMessagePoolSize; private int outputMessageSize; private int outputMaxChunkSize; private int outputMaxTimeSlice; private int outputMaxDataSlice; // MultiplexServerInvoker private int maxAcceptErrors; private String serverMultiplexId; private String multiplexConnectHost; private int multiplexConnectPort; private boolean multiplexConnectPortIsSet; // to check for missing configuration information public static Map getAddressPairMap() { return addressPairMap; } public static Map getSocketGroupMap() { return socketGroupMap; } /** * * Create a new MultiplexServerInvoker. * * @param locator */ public MultiplexServerInvoker(InvokerLocator locator) { super(locator); // virtualServerInvokers = Collections.synchronizedMap(new HashMap()); virtualServerInvokers = new HashMap(); } /** * Create a new MultiplexServerInvoker. */ public MultiplexServerInvoker(InvokerLocator locator, Map configuration) { super(locator, configuration); // virtualServerInvokers = Collections.synchronizedMap(new HashMap()); virtualServerInvokers = new HashMap(); } /** * Create a new MultiplexServerInvoker. */ protected MultiplexServerInvoker(InvokerLocator locator, Map configuration, List serverSockets, Socket socket, Map virtualServerInvokers) { super(locator, configuration); this.serverSockets = serverSockets; serverSocket = (ServerSocket) serverSockets.get(0); connectPrimingSocket = socket; this.virtualServerInvokers = virtualServerInvokers; isVirtual = true; needsSocketGroupConfiguration = false; ((VirtualSocket) connectPrimingSocket).addDisconnectListener(this); try { getParameters(); } catch (Exception e) { log.error(e); } } /** * Each implementation of the remote client invoker should have * a default data type that is uses in the case it is not specified * in the invoker locator uri. */ protected String getDefaultDataType() { return SerializableMarshaller.DATATYPE; } //TODO: -TME Need to check on synchronization after initial hook up public void start() throws IOException { if (readyToStart) finishStart(); } public void run() { if(trace) { log.trace("Started execution of method run"); } ServerSocketRefresh thread=new ServerSocketRefresh(); thread.setDaemon(true); thread.start(); try { while(running) { try { if(trace) { log.trace("Socket is going to be accepted"); } thread.release(); //goes on if serversocket refresh is completed Socket socket = serverSocket.accept(); if(trace) { log.trace("Accepted: " + socket); } processInvocation(socket); } catch (SocketException e) { if ("Socket is closed".equals(e.getMessage()) || "Socket closed".equals(e.getMessage())) { log.info("socket is closed: stopping thread"); // If this invoker was started by a Connector, let the Connector stop it. if (hasMaster) stop(); return; } else if (++errorCount > maxAcceptErrors) { log.error("maximum accept errors exceeded: stopping thread"); // If this invoker was started by a Connector, let the Connector stop it. if (hasMaster) stop(); return; } else { log.info(e); } } catch (SocketTimeoutException e) { if(running) { // If remote MultiplexClientInvoker and optional callback MultiplexServerInvoker // have shutdown, it's safe to stop. if (connectPrimingSocket != null && ((VirtualSocket)connectPrimingSocket).hasReceivedDisconnectMessage()) { log.info("Client has closed: stopping thread"); // If this invoker was started by a Connector, let the Connector stop it. if (hasMaster) stop(); return; } } } catch (javax.net.ssl.SSLHandshakeException e) { log.info("SSLHandshakeException", e); } catch(Throwable ex) { if(running) { log.error("Failed to accept socket connection", ex); if (++errorCount > maxAcceptErrors) { log.error("maximum accept errors exceeded: stopping"); // If this invoker was started by a Connector, let the Connector stop it. if (hasMaster) stop(); return; } } else { log.info(ex); } } } } finally { thread.interrupt(); } } public boolean isSafeToShutdown() { return (connectPrimingSocket == null || ((VirtualSocket) connectPrimingSocket).hasReceivedDisconnectMessage()); } public void notifyDisconnected(VirtualSocket virtualSocket) { if (virtualSocket != connectPrimingSocket) { log.error("notified about disconnection of unrecognized virtual socket"); return; } log.debug("remote peer socket has closed: stopping"); stop(); } public void stop() { // If running == false, super.stop() will not call cleanup(). // However, MultiplexServerInvoker could have stuff to clean up // (socket group information) even if it didn't start. if (!running) cleanup(); super.stop(); } public String toString() { if (isVirtual) { VirtualServerSocket vss = (VirtualServerSocket) serverSocket; if (vss != null) return "MultiplexServerInvoker[virtual:" + vss.getInetAddress() + ":" + vss.getLocalPort() + "->" + vss.getRemoteAddress() + ":" + vss.getRemotePort() + "]"; else return "MultiplexServerInvoker[virtual]"; } else if (serverSocket != null) return "MultiplexServerInvoker[master:" + serverSocket.getInetAddress() + ":" + serverSocket.getLocalPort() + "]"; else return "MultiplexServerInvoker[master]"; } protected void setup() throws Exception { originalBindPort = this.getLocator().getPort(); super.setup(); getParameters(); setBindingInfo(); // socketFactory = createSocketFactory(configuration); // if (socketFactory != null) // configuration.put(Multiplex.SOCKET_FACTORY, socketFactory); if (!configuration.isEmpty()) { if (needsSocketGroupConfiguration) { try { configureSocketGroupParameters(configuration); } catch (IOException e) { log.error("error configuring socket group parameters", e); cleanup(); throw e; } } } } /** * Finishes start up process when suitable bind and connect information is available. * For more information, see the Multiplex subsystem documentation at labs.jboss.org. */ protected void finishStart() throws IOException { log.debug("entering finishStart()"); if (isStarted()) return; if (socketGroupInfo != null && connectSocketAddress == null) { InetAddress connectAddress = socketGroupInfo.getConnectAddress(); int connectPort = socketGroupInfo.getConnectPort(); connectSocketAddress = new InetSocketAddress(connectAddress, connectPort); } if (socketGroupInfo != null && addressPair == null) { String connectHost = socketGroupInfo.getConnectAddress().getHostName(); int connectPort = socketGroupInfo.getConnectPort(); addressPair = new AddressPair(connectHost, connectPort, bindHost, bindPort); } try { super.start(); } catch(IOException e) { log.error("Error starting MultiplexServerInvoker.", e); cleanup(); } if (running) log.debug("MultiplexServerInvoker started."); } /** * Called by MultiplexClientInvoker.createSocket() when it finds connection is * broken and binds virtual socket group to new bind port. *

          * @param bindPort */ protected void resetLocator(int bindPort) { this.bindPort = bindPort; final InvokerLocator newLocator = new InvokerLocator(locator.getProtocol(), locator.getHost(), bindPort, locator.getPath(), locator.getParameters()); AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.updateServerInvokerLocator(locator, newLocator); return null; } }); locator = newLocator; } protected void configureSocketGroupParameters(Map parameters) throws IOException { log.debug("entering configureSocketGroupParameters()"); log.debug(locator); synchronized (SocketGroupInfo.class) { if (serverMultiplexId != null) { socketGroupInfo = (SocketGroupInfo) getSocketGroupMap().get(serverMultiplexId); if (socketGroupInfo != null) { rule1(); return; } } if (multiplexConnectHost != null && !this.multiplexConnectPortIsSet) throw new IOException("multiplexConnectHost != null and multiplexConnectPort is not set"); if (multiplexConnectHost == null && this.multiplexConnectPortIsSet) throw new IOException("multiplexConnectHost == null and multiplexConnectPort is set"); // server rule 2. if (multiplexConnectHost != null) { rule2(multiplexConnectHost, multiplexConnectPort); return; } // server rule 3. if (serverMultiplexId != null) { rule3(); return; } // server rule 4. rule4(); } } protected static void createPrimingSocket(SocketGroupInfo socketGroupInfo, String connectHost, int connectPort, Map configuration, int timeout) throws IOException { createPrimingSocket(socketGroupInfo, connectHost, connectPort, null, -1, configuration, timeout); } protected static void createPrimingSocket(SocketGroupInfo socketGroupInfo, String connectHost, int connectPort, InetAddress bindAddress, int bindPort, Map configuration, int timeout) throws IOException { log.debug("entering createPrimingSocket()"); boolean needed = true; InetSocketAddress csa = new InetSocketAddress(connectHost, connectPort); InetSocketAddress bsa = null; if (bindAddress != null) { bsa = new InetSocketAddress(bindAddress, bindPort); needed = !MultiplexingManager.checkForShareableManagerByAddressPair(bsa, csa); } else { needed = !MultiplexingManager.checkForShareableManager(csa); } if (socketGroupInfo != null) socketGroupInfo.setPrimingSocketNeeded(needed); if (!needed) { log.debug("priming socket is not necessary"); return; } // If the configuration Map has an SSL HandshakeCompletedListener, we register to // receive the HandshakeCompletedEvent with a HandshakeRepeater and, if the event // arrives within 60 seconds, we pass it on to the configured listener. Otherwise, // HandshakeRepeater.waitForHandshake() will throw an SSLException. Object obj = configuration.get(Client.HANDSHAKE_COMPLETED_LISTENER); HandshakeCompletedListener externalListener = null; HandshakeRepeater internalListener = null; if (obj != null && obj instanceof HandshakeCompletedListener) { externalListener = (HandshakeCompletedListener) obj; internalListener = new HandshakeRepeater(new InternalHandshakeListener()); configuration.put(Multiplex.SSL_HANDSHAKE_LISTENER, internalListener); } VirtualSocket socket = new VirtualSocket(configuration); if (bindAddress != null) socket.connect(csa, bsa, timeout); else socket.connect(csa, timeout); MultiplexingManager manager = socket.getManager(); if (externalListener != null) { if (manager.getHandshakeCompletedEvent() != null) { externalListener.handshakeCompleted(manager.getHandshakeCompletedEvent()); } else { internalListener.waitForHandshake(); externalListener.handshakeCompleted(handshakeCompletedEvent); } } if (!manager.waitForRemoteServerSocketRegistered()) throw new IOException("error waiting for remote server socket to be registered"); if (socketGroupInfo != null) socketGroupInfo.setPrimingSocket(socket); log.debug("created priming socket: " + socket.getLocalSocketId()); } protected String getThreadName(int i) { String virtualTag = isVirtual ? "v" : "m"; return "MultiplexServerInvoker#" + i + virtualTag + "-" + serverSocket.toString(); } protected void processInvocation(Socket socket) throws Exception { if (isVirtual) super.processInvocation(socket); else { log.debug("creating VSS"); ServerSocket ss = new VirtualServerSocket((VirtualSocket) socket, configuration); ss.setSoTimeout(getTimeout()); List serverSockets = new ArrayList(); serverSockets.add(ss); MultiplexServerInvoker si = new MultiplexServerInvoker(locator, configuration, serverSockets, socket, virtualServerInvokers); si.hasMaster = true; si.clientCallbackListener = clientCallbackListener; si.handlers = handlers; si.setMBeanServer(this.getMBeanServer()); si.setServerSocketFactory(this.getServerSocketFactory()); si.setSocketFactory(this.socketFactory); synchronized (virtualServerInvokers) { virtualServerInvokers.put(socket.getRemoteSocketAddress(), si); } si.connectionNotifier = connectionNotifier; si.create(); si.start(); log.debug("created virtual MultiplexServerInvoker: " + si); } } protected void cleanup() { // If running == false, SocketServerInvoker doesn't want to call cleanup(). if (running) { super.cleanup(); } // If the Finalizer thread gets here after clean up has occurred, return. if (cleanedUp) return; cleanedUp = true; if (isVirtual) { if (connectPrimingSocket != null) { log.debug("connect priming != null"); // If !virtualServerInvokers.containsKey(connectPrimingSocket.getRemoteSocketAddress()), // the master MultiplexServerInvoker might be iterating through virtualServerInvokers // and shutting them down. This test avoids a NullPointerException. Object key = connectPrimingSocket.getRemoteSocketAddress(); synchronized (virtualServerInvokers) { if (virtualServerInvokers.containsKey(key)) virtualServerInvokers.remove(key); } try { log.debug("MultiplexServerInvoker: closing connect priming socket"); connectPrimingSocket.close(); } catch (IOException e) { log.error("Error closing connect priming socket during cleanup upon stopping", e); } } else { log.debug("connect priming socket == null"); } // Remove all callback handlers (if any ServerInvocationHandlers are registered). Iterator it = handlers.values().iterator(); if (it.hasNext()) { log.debug("removing callback handlers"); ServerInvocationHandler defaultHandler = (ServerInvocationHandler) it.next(); ServerInvocationHandler handler = null; ServerInvokerCallbackHandler callbackHandler = null; it = callbackHandlers.values().iterator(); while (it.hasNext()) { callbackHandler = (ServerInvokerCallbackHandler) it.next(); String subsystem = callbackHandler.getSubsystem(); if (subsystem == null) handler = defaultHandler; else handler = (ServerInvocationHandler) handlers.get(subsystem.toUpperCase()); handler.removeListener(callbackHandler); } } } else { // Iterator it = virtualServerInvokers.values().iterator(); Iterator it = null; synchronized (virtualServerInvokers) { it = new HashMap(virtualServerInvokers).values().iterator(); } while (it.hasNext()) { ServerInvoker serverInvoker = ((ServerInvoker) it.next()); it.remove(); serverInvoker.stop(); } } if (socketGroupInfo != null) { synchronized (MultiplexServerInvoker.SocketGroupInfo.class) { socketGroupInfo.removeServerInvoker(this); VirtualSocket ps = null; if (socketGroupInfo.getClientInvokers().isEmpty()) { log.debug("invoker group shutting down: " + socketGroupInfo.getSocketGroupId()); if ((ps = socketGroupInfo.getPrimingSocket()) != null) { // When the remote virtual MultiplexServerInvoker learns that the // priming socket has closed, it will close its VirtualServerSocket, // rendering unshareable the MultiplexingManager that underlies this // socket group. We mark it as unshareable immediately so that it will // not be reused by any other socket group. ps.getManager().unregisterShareable(); log.debug("MultiplexServerInvoker: closing bind priming socket"); try { ps.close(); } catch (IOException e) { log.error("Error closing bind priming socket during cleanup upon stopping", e); } } serverMultiplexId = socketGroupInfo.getSocketGroupId(); log.debug("serverMultiplexId: " + serverMultiplexId); if (serverMultiplexId != null) { getSocketGroupMap().remove(serverMultiplexId); log.debug("removed serverMultiplexId: " + serverMultiplexId); log.debug("socketGroupInfo: " + getSocketGroupMap().get(serverMultiplexId)); } // addressPair is set in finishStart(). if (addressPair != null) { getAddressPairMap().remove(addressPair); } } } } } /** * In creating the server socket, createServerSocket() determines whether multiplexing * will be supported by this ServerInvoker. The determination is made according to the * presence or absence of certain parameters in the ServerInvoker's locator. In particular, * a VirtualServerSocket, which supports multiplexing, needs to connect to a * remote MasterServerSocket before it can begin to accept connection requests. * In order to know which MasterServerSocket to connect to, * it looks for parameters "connectHost" and "connectPort" in the locator. The presence of these parameters * indicates that a VirtualServerSocket should be created, and their absence indicates that a * MasterServerSocket, which does not support multiplexing, should be created. * * @param bindPort * @param backlog * @param bindAddress * @return * @throws IOException */ protected ServerSocket createServerSocket(int bindPort, int backlog, InetAddress bindAddress) throws IOException // private ServerSocket createServerSocket() throws IOException { // The following commented code represents an attempt to make an automatic determination as to whether // a VirtualServerSocket should be created. The idea is to see if a ClientInvoker already // exists on the local port to which the new server socket wants to bind. The existence of such a // ClientInvoker would indicate that multiplexing is desired. However, it appears that a ClientInvoker // has no control over which local port(s) it uses. // if (InvokerRegistry.isClientInvokerRegistered(getLocator())) // { // try // { // Invoker clientInvoker = InvokerRegistry.createClientInvoker(getLocator()); // InvokerLocator connectLocator = clientInvoker.getLocator(); // InetSocketAddress connectSocketAddress = new InetSocketAddress(connectLocator.getHost(), connectLocator.getPort()); // InetSocketAddress bindSocketAddress = new InetSocketAddress(bindAddress, serverBindPort); // svrSocket = new VirtualServerSocket(connectSocketAddress, bindSocketAddress); // } // catch (Exception e) // { // throw new IOException(e.getMessage()); // } // } // If this is a virtual MultiplexServerInvoker created by a master MultiplexServerInvoker, // then the server socket has already been created. if (serverSocket != null) return serverSocket; ServerSocket svrSocket = null; if (isVirtual) { InetSocketAddress bindSocketAddress = new InetSocketAddress(bindAddress, this.bindPort); svrSocket = new VirtualServerSocket(connectSocketAddress, bindSocketAddress, getTimeout(), configuration); svrSocket.setSoTimeout(getTimeout()); if (socketGroupInfo != null) socketGroupInfo.setPrimingSocketNeeded(false); } else { // svrSocket = new MasterServerSocket(getServerSocketFactory(), bindPort, backlog, bindAddress); ServerSocketFactory ssf = getServerSocketFactory(); if (ssf != null && !ssf.getClass().equals(ServerSocketFactory.getDefault().getClass())) { configuration.put(Multiplex.SERVER_SOCKET_FACTORY, ssf); } svrSocket = new MasterServerSocket(bindPort, backlog, bindAddress, configuration); svrSocket.setSoTimeout(getTimeout()); } log.debug("Created " + svrSocket.getClass() + ": " + svrSocket); return svrSocket; } protected void rule1() throws IOException { log.debug("server rule 1"); // If we get here, it's because a MultiplexClientInvoker created a SocketGroupInfo with matching // group id. We want to make sure that it didn't get a bind address or bind port different // than the ones passed in through the parameters map. InetAddress socketGroupBindAddress = socketGroupInfo.getBindAddress(); int socketGroupBindPort = socketGroupInfo.getBindPort(); if (socketGroupBindAddress != null && !socketGroupBindAddress.equals(bindAddress)) { String message = "socket group bind address (" + socketGroupBindAddress + ") does not match bind address (" + bindAddress + ")"; log.error(message); socketGroupInfo = null; // We don't belong to this group. throw new IOException(message); } if (socketGroupBindPort > 0 && originalBindPort > 0 && socketGroupBindPort != bindPort) { String message = "socket group bind port (" + socketGroupBindPort + ") does not match bind port (" + bindPort + ")"; log.error(message); socketGroupInfo = null; // We don't belong to this group. throw new IOException(message); } if (originalBindPort <= 0) { if (socketGroupBindPort > 0) bindPort = socketGroupBindPort; else { bindPort = PortUtil.findFreePort(bindHost); socketGroupBindPort = bindPort; } // re-write locator since the port is different final InvokerLocator newLocator = new InvokerLocator(locator.getProtocol(), locator.getHost(), bindPort, locator.getPath(), locator.getParameters()); // need to update the locator key used in the invoker registry AccessController.doPrivileged( new PrivilegedAction() { public Object run() { InvokerRegistry.updateServerInvokerLocator(locator, newLocator); return null; } }); this.locator = newLocator; } isVirtual = true; InetAddress connectAddress = socketGroupInfo.getConnectAddress(); int connectPort = socketGroupInfo.getConnectPort(); connectSocketAddress = new InetSocketAddress(connectAddress, connectPort); socketGroupInfo.setBindAddress(bindAddress); socketGroupInfo.setBindPort(bindPort); socketGroupInfo.setServerInvoker(this); Iterator it = socketGroupInfo.getClientInvokers().iterator(); while (it.hasNext()) { ((MultiplexClientInvoker) it.next()).finishStart(); } readyToStart = true; if (socketGroupInfo.getPrimingSocket() == null) { socketFactory = createSocketFactory(configuration); if (socketFactory != null) configuration.put(Multiplex.SOCKET_FACTORY, socketFactory); createPrimingSocket(socketGroupInfo, connectAddress.getHostName(), connectPort, bindAddress, bindPort, configuration, getTimeout()); } // We got socketGroupInfo by socketGroupId. Make sure it is also stored by AddressPair. String connectHost = connectAddress.getHostName(); addressPair = new AddressPair(connectHost, connectPort, bindHost, bindPort); addressPairMap.put(addressPair, socketGroupInfo); } protected void rule2(String connectHost, int connectPort) throws IOException { log.debug("server rule 2"); isVirtual = true; connectSocketAddress = new InetSocketAddress(connectHost, connectPort); addressPair = new AddressPair(connectHost, connectPort, bindHost, bindPort); socketGroupInfo = (SocketGroupInfo) addressPairMap.get(addressPair); // If socketGroupInfo exists, it's because it was created, along with a priming socket (if necessary), // by a MultiplexClientInvoker. if (socketGroupInfo != null) { // We got socketGroupInfo by AddressPair. Make sure it is stored by socketGroupId, if we have one. if (serverMultiplexId != null) { String socketGroupSocketGroupId = socketGroupInfo.getSocketGroupId(); if (socketGroupSocketGroupId != null && socketGroupSocketGroupId != serverMultiplexId) { String message = "socket group multiplexId (" + socketGroupSocketGroupId + ") does not match multiplexId (" + serverMultiplexId + ")"; log.error(message); socketGroupInfo = null; // Assume we weren't meant to join this group. throw new IOException(message); } if (socketGroupSocketGroupId == null) { socketGroupInfo.setSocketGroupId(serverMultiplexId); getSocketGroupMap().put(serverMultiplexId, socketGroupInfo); } } socketGroupInfo.setBindAddress(bindAddress); socketGroupInfo.setBindPort(bindPort); socketGroupInfo.setServerInvoker(this); readyToStart = true; return; } socketGroupInfo = new SocketGroupInfo(); socketGroupInfo.setBindAddress(bindAddress); socketGroupInfo.setBindPort(bindPort); socketGroupInfo.setServerInvoker(this); // Set connectAddress and connectPort to be able to test for inconsistencies with connect address // and connect port determined by companion MultiplexClientInvoker. InetAddress connectAddress = InetAddress.getByName(connectHost); socketGroupInfo.setConnectAddress(connectAddress); socketGroupInfo.setConnectPort(connectPort); socketFactory = createSocketFactory(configuration); if (socketFactory != null) configuration.put(Multiplex.SOCKET_FACTORY, socketFactory); createPrimingSocket(socketGroupInfo, connectHost, connectPort, bindAddress, bindPort, configuration, getTimeout()); addressPairMap.put(addressPair, socketGroupInfo); if (serverMultiplexId != null) { socketGroupInfo.setSocketGroupId(serverMultiplexId); socketGroupMap.put(serverMultiplexId, socketGroupInfo); } readyToStart = true; } protected void rule3() throws IOException { log.debug("server rule 3"); socketGroupInfo = new SocketGroupInfo(); socketGroupInfo.setSocketGroupId(serverMultiplexId); socketGroupInfo.setServerInvoker(this); socketGroupInfo.setBindAddress(bindAddress); socketGroupInfo.setBindPort(bindPort); socketGroupMap.put(serverMultiplexId, socketGroupInfo); isVirtual = true; readyToStart = false; } protected void rule4() { log.debug("server rule 4"); isVirtual = false; readyToStart = true; } protected void refreshServerSocket() throws IOException { super.refreshServerSocket(); } /** * Returns ServerSocket used to accept invocation requests. * It is added to facilitate unit tests. * * @return ServerSocket used to accept invocation requests. */ public ServerSocket getServerSocket() { return serverSocket; } /** * Provides access to a virtual MultiplexServerInvoker in a master * MultiplexServerInvoker's invoker farm. */ public MultiplexServerInvoker getServerInvoker(InetSocketAddress address) { synchronized (virtualServerInvokers) { return (MultiplexServerInvoker) virtualServerInvokers.get(address); } } /** * Provides access to all virtual MultiplexServerInvokers in a master * MultiplexServerInvoker's invoker farm. */ public Collection getServerInvokers() { synchronized (virtualServerInvokers) { return virtualServerInvokers.values(); } } protected void setBindingInfo() throws IOException { String originalUri = getLocator().getOriginalURI(); String pastProtocol = originalUri.substring(originalUri.indexOf("://") + 3); int colon = pastProtocol.indexOf(":"); int slash = pastProtocol.indexOf("/"); String originalHost = null; int originalPort = 0; if(colon != -1) { originalHost = pastProtocol.substring(0, colon).trim(); if(slash > -1) { originalPort = Integer.parseInt(pastProtocol.substring(colon + 1, slash)); } else { originalPort = Integer.parseInt(pastProtocol.substring(colon + 1)); } } else { if(slash > -1) { originalHost = pastProtocol.substring(0, slash).trim(); } else { originalHost = pastProtocol.substring(0).trim(); } } bindHost = getServerBindAddress(); bindPort = getServerBindPort(); bindAddress = InetAddress.getByName(bindHost); } protected void getParameters() throws Exception { if (configuration != null) maxAcceptErrors = Multiplex.getOneParameter(configuration, "maxAcceptErrors", Multiplex.MAX_ACCEPT_ERRORS, Multiplex.MAX_ACCEPT_ERRORS_DEFAULT); if (configuration != null) serverMultiplexId = (String) configuration.get(Multiplex.SERVER_MULTIPLEX_ID); if (configuration != null) multiplexConnectHost = (String) configuration.get(Multiplex.MULTIPLEX_CONNECT_HOST); Object value = configuration.get(Multiplex.MULTIPLEX_CONNECT_PORT); if (value != null) { if (value instanceof String) { try { multiplexConnectPort = Integer.parseInt((String) value); multiplexConnectPortIsSet = true; } catch (NumberFormatException e) { String errorMessage = "number format error for multiplexConnectPort: " + (String) value; log.error(errorMessage); throw new IOException(errorMessage); } } else if (value instanceof Integer) { multiplexConnectPort = ((Integer) configuration.get(Multiplex.MULTIPLEX_CONNECT_PORT)).intValue(); multiplexConnectPortIsSet = true; } else { String errorMessage = "invalid object passed for multiplexConnectPort: " + value; log.error(errorMessage); throw new IOException(errorMessage); } } } ///////////////////////////////////////////////////////////////////////////////////// // accessors for configurable Multiplex parameters // ///////////////////////////////////////////////////////////////////////////////////// public int getInputBufferSize() { return inputBufferSize; } public void setInputBufferSize(int inputBufferSize) { this.inputBufferSize = inputBufferSize; if (configuration != null) configuration.put(Multiplex.INPUT_BUFFER_SIZE, new Integer(inputBufferSize)); } public int getInputMaxErrors() { return inputMaxErrors; } public void setInputMaxErrors(int inputMaxErrors) { this.inputMaxErrors = inputMaxErrors; if (configuration != null) configuration.put(Multiplex.INPUT_MAX_ERRORS, new Integer(inputMaxErrors)); } public int getMaxAcceptErrors() { return maxAcceptErrors; } public void setMaxAcceptErrors(int maxAcceptErrors) { this.maxAcceptErrors = maxAcceptErrors; if (configuration != null) configuration.put(Multiplex.MAX_ACCEPT_ERRORS, new Integer(maxAcceptErrors)); } public String getMultiplexConnectHost() { return multiplexConnectHost; } // This method is useless. See notes about paramters, above. // public void setMultiplexConnectHost(String multiplexConnectHost) // { // this.multiplexConnectHost = multiplexConnectHost; // if (configuration != null) // configuration.put(Multiplex.MULTIPLEX_CONNECT_HOST, multiplexConnectHost); // } public int getMultiplexConnectPort() { return multiplexConnectPort; } // This method is useless. See notes about paramters, above. // public void setMultiplexConnectPort(int multiplexConnectPort) // { // this.multiplexConnectPort = multiplexConnectPort; // if (configuration != null) // configuration.put(Multiplex.MULTIPLEX_CONNECT_PORT, new Integer(multiplexConnectPort)); // } public int getOutputMaxChunkSize() { return outputMaxChunkSize; } public void setOutputMaxChunkSize(int outputMaxChunkSize) { this.outputMaxChunkSize = outputMaxChunkSize; if (configuration != null) configuration.put(Multiplex.OUTPUT_MAX_CHUNK_SIZE, new Integer(outputMaxChunkSize)); } public int getOutputMaxDataSlice() { return outputMaxDataSlice; } public void setOutputMaxDataSlice(int outputMaxDataSlice) { this.outputMaxDataSlice = outputMaxDataSlice; if (configuration != null) configuration.put(Multiplex.OUTPUT_MAX_DATA_SLICE, new Integer(outputMaxDataSlice)); } public int getOutputMaxTimeSlice() { return outputMaxTimeSlice; } public void setOutputMaxTimeSlice(int outputMaxTimeSlice) { this.outputMaxTimeSlice = outputMaxTimeSlice; if (configuration != null) configuration.put(Multiplex.OUTPUT_MAX_TIME_SLICE, new Integer(outputMaxTimeSlice)); } public int getOutputMessagePoolSize() { return outputMessagePoolSize; } public void setOutputMessagePoolSize(int outputMessagePoolSize) { this.outputMessagePoolSize = outputMessagePoolSize; if (configuration != null) configuration.put(Multiplex.OUTPUT_MESSAGE_POOL_SIZE, new Integer(outputMessagePoolSize)); } public int getOutputMessageSize() { return outputMessageSize; } public void setOutputMessageSize(int outputMessageSize) { this.outputMessageSize = outputMessageSize; if (configuration != null) configuration.put(Multiplex.OUTPUT_MESSAGE_SIZE, new Integer(outputMessageSize)); } public String getServerMultiplexId() { return serverMultiplexId; } // This method is useless. See notes about paramters, above. // public void setServerMultiplexId(String serverMultiplexId) // { // this.serverMultiplexId = serverMultiplexId; // if (configuration != null) // configuration.put(Multiplex.SERVER_MULTIPLEX_ID, serverMultiplexId); // } public int getShutdownMonitorPeriod() { return shutdownMonitorPeriod; } public void setShutdownMonitorPeriod(int shutdownMonitorPeriod) { this.shutdownMonitorPeriod = shutdownMonitorPeriod; if (configuration != null) configuration.put(Multiplex.SHUTDOWN_MONITOR_PERIOD, new Integer(shutdownMonitorPeriod)); } public int getShutdownRefusalsMaximum() { return shutdownRefusalsMaximum; } public void setShutdownRefusalsMaximum(int shutdownRefusalsMaximum) { this.shutdownRefusalsMaximum = shutdownRefusalsMaximum; if (configuration != null) configuration.put(Multiplex.SHUTDOWN_REFUSALS_MAXIMUM, new Integer(shutdownRefusalsMaximum)); } public int getShutdownRequestTimeout() { return shutdownRequestTimeout; } public void setShutdownRequestTimeout(int shutdownRequestTimeout) { this.shutdownRequestTimeout = shutdownRequestTimeout; if (configuration != null) configuration.put(Multiplex.SHUTDOWN_REQUEST_TIMEOUT, new Integer(shutdownRequestTimeout)); } public int getStaticThreadsMonitorPeriod() { return staticThreadsMonitorPeriod; } public void setStaticThreadsMonitorPeriod(int staticThreadsMonitorPeriod) { this.staticThreadsMonitorPeriod = staticThreadsMonitorPeriod; if (configuration != null) configuration.put(Multiplex.STATIC_THREADS_MONITOR_PERIOD, new Integer(staticThreadsMonitorPeriod)); } /** * SocketGroupInfo holds all of the information for a single virtual socket group. */ public static class SocketGroupInfo { private String socketGroupId; private Set clientInvokers = new HashSet(); private MultiplexServerInvoker serverInvoker; private boolean primingSocketNeeded; private VirtualSocket primingSocket; private InetAddress connectAddress; private int connectPort; private InetAddress bindAddress; private int bindPort; public InetAddress getBindAddress() { return bindAddress; } public void setBindAddress(InetAddress bindAddress) { this.bindAddress = bindAddress; } public int getBindPort() { return bindPort; } public void setBindPort(int bindPort) { this.bindPort = bindPort; } public Set getClientInvokers() { return clientInvokers; } public void addClientInvoker(MultiplexClientInvoker clientInvoker) { clientInvokers.add(clientInvoker); } public void removeClientInvoker(MultiplexClientInvoker clientInvoker) { clientInvokers.remove(clientInvoker); } public InetAddress getConnectAddress() { return connectAddress; } public void setConnectAddress(InetAddress connectAddress) { this.connectAddress = connectAddress; } public int getConnectPort() { return connectPort; } public void setConnectPort(int connectPort) { this.connectPort = connectPort; } public boolean getPrimingSocketNeeded() { return primingSocketNeeded; } public void setPrimingSocketNeeded(boolean primingSocketNeeded) { this.primingSocketNeeded = primingSocketNeeded; } public VirtualSocket getPrimingSocket() { return primingSocket; } public void setPrimingSocket(VirtualSocket primingSocket) { this.primingSocket = primingSocket; } public String getSocketGroupId() { return socketGroupId; } public void setSocketGroupId(String socketGroupId) { this.socketGroupId = socketGroupId; } public MultiplexServerInvoker getServerInvoker() { return serverInvoker; } public void removeServerInvoker(MultiplexServerInvoker serverInvoker) { if (this.serverInvoker != serverInvoker) { String message = "Attempt to remove unknown MultiplexServerInvoker: " + "(" + bindAddress + "," + bindPort + ")->(" + connectAddress + "," + connectPort + ")"; log.error(message); } this.serverInvoker = null; } public void setServerInvoker(MultiplexServerInvoker serverInvoker) throws IOException { if (this.serverInvoker != null && serverInvoker != null) { String message = "Second MultiplexServerInvoker attempting to join invoker group: " + "(" + bindAddress + "," + bindPort + ")->(" + connectAddress + "," + connectPort + ")"; log.error(message); throw new IOException(message); } this.serverInvoker = serverInvoker; } } protected static class InternalHandshakeListener implements HandshakeCompletedListener { public void handshakeCompleted(HandshakeCompletedEvent event) { handshakeCompletedEvent = event; } } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/VirtualSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/VirtualSocketF0000644000175000017500000000577210753261335033565 0ustar twernertwerner/* * 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. */ /* * Created on Jul 24, 2005 */ package org.jboss.remoting.transport.multiplex; import javax.net.SocketFactory; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; /** * VirtualSocketFactory extends the * javax.net.SocketFactory class and reimplements * its createSocket() methods, returning VirtualSockets. * *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class VirtualSocketFactory extends SocketFactory implements Serializable { private static final long serialVersionUID = 3422810508320563967L; /** * See superclass javadoc. */ public static SocketFactory getDefault() { return new VirtualSocketFactory(); } /** * See superclass javadoc. */ protected VirtualSocketFactory() { } /** * See superclass javadoc. */ public Socket createSocket() { return new VirtualSocket(); } /** * See superclass javadoc. */ public Socket createSocket(String host, int port) throws IOException, UnknownHostException { return new VirtualSocket(host, port); } /** * See superclass javadoc. */ public Socket createSocket(String host, int port, InetAddress localAddress, int localPort) throws IOException, UnknownHostException { return new VirtualSocket(host, port, localAddress, localPort); } /** * See superclass javadoc. */ public Socket createSocket(InetAddress address, int port) throws IOException { return new VirtualSocket(address, port); } /** * See superclass javadoc. */ public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException, UnknownHostException { return new VirtualSocket(address, port, localAddress, localPort); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/PendingAction.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/PendingAction.0000644000175000017500000000346310753261335033453 0ustar twernertwerner/* * 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. */ /* * Created on Oct 22, 2005 */ package org.jboss.remoting.transport.multiplex; /** * Each PendingAction holds information about an action that will be performed * on the MultiplexingManager.PendingActionThread. These are time consuming * activities that should not be executed on the "main" thread. * For more information, see MultiplexingManager. *

          * @author Ron Sigal * @version $Revision: 3443 $ *

          * Copyright (c) 2005 *

          * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public abstract class PendingAction { protected Object o; public PendingAction() { } public PendingAction(Object o) { this.o = o; } abstract void doAction(); } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/InputMultiplexor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/InputMultiplex0000644000175000017500000005044610753261335033661 0ustar twernertwerner/* * 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.remoting.transport.multiplex; import org.jboss.logging.Logger; import org.jboss.remoting.transport.multiplex.utility.StoppableThread; import java.io.BufferedInputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; import java.nio.ByteBuffer; import java.nio.channels.ClosedSelectorException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.SocketChannel; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.net.ssl.SSLException; /** * InputMultiplexor is one of the key Multiplex classes, responsible for * demultiplexing multiple byte streams sharing a single TCP connection. It has two * inner classes which can perform this function. MultiGroupInputThread can perform * demultiplexing for any number of NIO sockets, taking advantage of the Selector * facility. For non-NIO sockets, notably SSL sockets, SingleGroupInputThread * handles demultiplexing for a single socket. *

          * The data stream, created at the other end of the TCP connection by the * OutputMultiplexor class, consists of a sequence of packets, each consisting of * a header, giving version, destination virtual socket, and number of bytes. followed * by the specified number of data bytes. (See OutputMultiplexor for the * header format. * Each of the demultiplexing thread classes reads a header and transfers the * following bytes to the input stream of the target virtual socket. * *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class InputMultiplexor { protected static final Logger log = Logger.getLogger(InputMultiplexor.class); private static final int HEADER_LENGTH = 7; private int bufferSize; private int maxErrors; public InputMultiplexor(Map configuration) { bufferSize = Multiplex.getOneParameter(configuration, "bufferSize", Multiplex.INPUT_BUFFER_SIZE, Multiplex.INPUT_BUFFER_SIZE_DEFAULT); maxErrors = Multiplex.getOneParameter(configuration, "maxErrors", Multiplex.INPUT_MAX_ERRORS, Multiplex.INPUT_MAX_ERRORS_DEFAULT); } /** * Returns a MultiGroupInputThread designed to handle multiple virtual socket groups. * @param configuration * @return a MultiGroupInputThread designed to handle multiple virtual socket groups */ public MultiGroupInputThread getaMultiGroupInputThread() throws IOException { return new MultiGroupInputThread(); } /** * Returns a SingleGroupInputThread designed to handle a single virtual socket group. * @return a SingleGroupInputThread designed to handle a single virtual socket group */ public SingleGroupInputThread getaSingleGroupInputThread(MultiplexingManager manager, Socket socket, OutputStream os) throws IOException { return new SingleGroupInputThread(manager, socket, os); } public class MultiGroupInputThread extends StoppableThread { private static final String errMsg1 = "An existing connection was forcibly closed by the remote host"; private static final String errMsg2 = "An established connection was aborted by the software in your host machine"; private Map managerProcessorMap; private Set socketGroupsToBeRegistered = new HashSet(); private Set tempSocketGroupSet = new HashSet(); private boolean socketGroupsAreWaiting; private Selector selector; private ByteBuffer buffer; private byte[] data; private boolean trace; private boolean debug; private boolean info; public MultiGroupInputThread() throws IOException { managerProcessorMap = Collections.synchronizedMap(new HashMap()); selector = Selector.open(); buffer = ByteBuffer.allocate(bufferSize); data = new byte[bufferSize]; trace = log.isTraceEnabled(); debug = log.isDebugEnabled(); info = log.isInfoEnabled(); } /** * Registers manager and socket with NIO Selector * @param manager MultiplexingManager * @return * @throws IOException */ public void registerSocketGroup(MultiplexingManager manager) throws IOException { if (debug) log.debug(" accepting socket group for registration: " + manager); synchronized (socketGroupsToBeRegistered) { socketGroupsToBeRegistered.add(manager); socketGroupsAreWaiting = true; } } protected void doRegistration() { tempSocketGroupSet.clear(); synchronized(socketGroupsToBeRegistered) { tempSocketGroupSet.addAll(socketGroupsToBeRegistered); socketGroupsToBeRegistered.clear(); socketGroupsAreWaiting = false; } Iterator it = tempSocketGroupSet.iterator(); while (it.hasNext()) { MultiplexingManager manager = (MultiplexingManager) it.next(); GroupProcessor groupProcessor = new GroupProcessor(manager); SelectableChannel channel = manager.getSocket().getChannel(); try { SelectionKey key = channel.register(selector, SelectionKey.OP_READ, groupProcessor); groupProcessor.setKey(key); managerProcessorMap.put(manager, groupProcessor); } catch (IOException e) { // channel might be closed. log.warn(e); } } } /** * Removes references to virtual socket group. * @param manager */ public void unregisterSocketGroup(MultiplexingManager manager) { // Leave GroupProcessor in Map until SelectionKey is cancelled. GroupProcessor groupProcessor = (GroupProcessor) managerProcessorMap.get(manager); if(groupProcessor == null) { log.debug("attempting to unregister unknown MultiplexingManager: " + manager); return; } SelectionKey key = groupProcessor.getKey(); key.cancel(); managerProcessorMap.remove(manager); if (debug) log.debug("unregistered socket group:" + manager); } public void shutdown() { // in case thread is still reading super.shutdown(); try { selector.close(); } catch (IOException e) { log.error("unable to close selector", e); } interrupt(); } protected void doInit() { log.debug("MultiGroupInputThread thread starting"); } protected void doRun() { log.debug("entering doRun()"); Set keys = null; try { while (true) { if (!running) return; if (socketGroupsAreWaiting) doRegistration(); selector.select(200); keys = selector.selectedKeys(); if (!keys.isEmpty()) break; } } catch (IOException e) { log.info(e); } catch (ClosedSelectorException e) { log.info("Selector is closed: shutting down input thread"); super.shutdown(); return; } if (trace) { log.trace("keys: " + selector.keys().size()); log.trace("selected keys: " + keys.size()); } Iterator it = keys.iterator(); while (it.hasNext()) { SelectionKey key = (SelectionKey) it.next(); it.remove(); GroupProcessor groupProcessor = (GroupProcessor) key.attachment(); if (groupProcessor == null) { if (key.isValid()) log.error("valid SelectionKey has no attachment: " + key); continue; } groupProcessor.processChannel(key); } } protected void doShutDown() { log.debug("MultiGroupInputThread shutting down"); } class GroupProcessor { // Message header private byte[] b = new byte[HEADER_LENGTH]; private int headerCount; private byte version; private int destination; private short size; private MultiplexingManager manager; private OutputStream outputStream; private SelectionKey key; private int errorCount; public GroupProcessor(MultiplexingManager manager) { this.manager = manager; } public void processChannel(SelectionKey key) { log.debug("processChannel()"); SocketChannel channel = (SocketChannel) key.channel(); buffer.clear(); try { if (channel.read(buffer) < 0) throw new EOFException(); buffer.flip(); if (debug) log.debug("read: " + buffer.remaining()); while (buffer.hasRemaining()) { if (headerCount < HEADER_LENGTH || size == 0) { // then prepare to process next virtual stream. completeHeader(buffer); if (headerCount < HEADER_LENGTH) return; SocketId socketId = new SocketId(destination); outputStream = manager.getOutputStreamByLocalSocket(socketId); if (outputStream == null) { // We'll get an OutputStream to stash these bytes, just in case they // are coming from a valid source and the local VirtualSocket is still // getting set up. log.info("unknown socket id: " + destination); outputStream = manager.getConnectedOutputStream(socketId); } if (!buffer.hasRemaining()) return; } int n = Math.min(size, buffer.remaining()); buffer.get(data, 0, n); outputStream.write(data, 0, n); if (trace) { log.trace("received " + n + " bytes for socket: " + destination); for (int i = 0; i < n; i++) log.trace("" + (0xff & data[i])); } size -= n; if (size == 0) headerCount = 0; } } catch (IOException e) { handleChannelException(e, key, channel); } catch (Throwable t) { log.error("doRun()"); log.error(t); } } public SelectionKey getKey() { return key; } public void setKey(SelectionKey key) { this.key = key; } private void completeHeader(ByteBuffer bb) throws IOException { int n = Math.min(bb.remaining(), HEADER_LENGTH - headerCount); bb.get(b, headerCount, n); headerCount += n; if (headerCount == HEADER_LENGTH) { version = b[0]; destination = (b[1] << 24) | (0x00ff0000 & (b[2] << 16)) | (0x0000ff00 & (b[3] << 8)) | (0x000000ff & b[4]); size = (short) ((0x0000ff00 & (b[5] << 8)) | (0x000000ff & b[6])); if (size < 0 || bufferSize < size) throw new CorruptedStreamException("invalid chunk size read on: " + manager + ": "+ size); if (version != 0) throw new CorruptedStreamException("invalid version read on: " + manager + ": " + version); } } private void handleChannelException(IOException e, SelectionKey key, SocketChannel channel) { try { if (!channel.isOpen()) { key.cancel(); return; } if (e instanceof EOFException) { key.cancel(); manager.setEOF(); log.debug(e); return; } if (e instanceof SSLException) { key.cancel(); log.error(e); return; } if (++errorCount > maxErrors) { manager.setReadException(e); channel.close(); key.cancel(); log.error(e); log.error("error count exceeds max errors: " + errorCount); return; } Socket socket = channel.socket(); String message = e.getMessage(); if (socket.isClosed() || socket.isInputShutdown() || errMsg1.equals(message) || errMsg2.equals(message) || e instanceof CorruptedStreamException) { manager.setReadException(e); channel.close(); key.cancel(); log.info(e); return; } // Haven't reached maxErrors yet log.warn(e); } catch (IOException e2) { log.error("problem closing channel: " + manager, e2); } } public int getDestination() {return destination;} public short getSize() {return size;} public byte getVersion() {return version;} public OutputStream getOutputStream() {return outputStream;} } } class SingleGroupInputThread extends StoppableThread { private InputStream is; private OutputStream currentOutputStream; private byte[] dataBytes = new byte[bufferSize]; private MultiplexingManager manager; private int dataInCount = 0; private int errorCount; private boolean eof; // Message header private byte[] headerBytes = new byte[HEADER_LENGTH]; private int headerCount; private byte version; private int destination; private short size; private boolean trace; private boolean debug; private boolean info; public SingleGroupInputThread(MultiplexingManager manager, Socket socket, OutputStream os) throws IOException { this.is = new BufferedInputStream(socket.getInputStream()); this.manager = manager; currentOutputStream = os; trace = log.isTraceEnabled(); debug = log.isDebugEnabled(); info = log.isInfoEnabled(); } public void shutdown() { // in case thread is still reading super.shutdown(); log.info("interrupting input thread"); interrupt(); } /** * */ protected void doInit() { log.debug("SingleGroupInputThread thread starting"); } /** * */ protected void doRun() { try { // end of file if (!completeHeader()) { eof = true; return; } SocketId socketId = new SocketId(destination); currentOutputStream = manager.getOutputStreamByLocalSocket(socketId); if (currentOutputStream == null) { // We'll get an OutputStream to stash these bytes, just in case they // are coming from a valid source and the local VirtualSocket is still // getting set up. log.info("unknown socket id: " + destination); currentOutputStream = manager.getConnectedOutputStream(socketId); } int bytesRead = 0; while (bytesRead < size) { int n = is.read(dataBytes, 0, size - bytesRead); if (n < 0) { eof = true; return; } currentOutputStream.write(dataBytes, 0, n); bytesRead += n; if (trace) { for (int i = 0; i < n; i++) log.trace("" + dataBytes[i]); } } } catch (SSLException e) { log.debug(e.getMessage()); } catch (EOFException e) { eof = true; log.info("end of file"); } catch (IOException e) { if (++errorCount > maxErrors) { manager.setReadException(e); super.shutdown(); log.error(e); } else log.warn(e); } finally { if (eof) { super.shutdown(); manager.setEOF(); } } } private boolean completeHeader() throws IOException { while (headerCount < HEADER_LENGTH) { int n = is.read(headerBytes, headerCount, HEADER_LENGTH - headerCount); // end of file if (n < 0) return false; headerCount += n; } // Reset for next header. headerCount = 0; version = headerBytes[0]; destination = (headerBytes[1] << 24) | (0x00ff0000 & (headerBytes[2] << 16)) | (0x0000ff00 & (headerBytes[3] << 8)) | (0x000000ff & headerBytes[4]); size = (short) ((0x0000ff00 & (headerBytes[5] << 8)) | (0x000000ff & headerBytes[6])); if (trace) { log.trace("version: " + version); log.trace("destination: " + destination); log.trace("size: " + size); } if (size < 0 || bufferSize < size) throw new CorruptedStreamException("invalid chunk size read on: " + manager + ": "+ size); if (version != 0) throw new CorruptedStreamException("invalid version read on: " + manager + ": " + version); return true; } protected void doShutDown() { log.debug("input thread: data bytes read: " + dataInCount); log.debug("input thread shutting down"); } } private static class CorruptedStreamException extends IOException { CorruptedStreamException(String message) {super(message);} } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/TransportClien0000644000175000017500000000325110753261335033615 0ustar twernertwerner/* * 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.remoting.transport.multiplex; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new MultiplexClientInvoker(locator, config); } public boolean supportsSSL() { return false; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/0000755000175000017500000000000011632407047032424 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/GrowablePipedInputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/Growab0000644000175000017500000001773710753261335033610 0ustar twernertwerner/* * 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. */ /* * Created on Dec 15, 2005 */ package org.jboss.remoting.transport.multiplex.utility; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.net.SocketTimeoutException; import org.jboss.logging.Logger; /** * GrowablePipedInputStream is the parent of the * MultiplexingInputStream returned by * VirtualSocket.getInputStream(). GrowablePipedInputStream and * GrowablePipedOutputStream work together like java.io.PipedInputStream * and java.io.PipedOutputStream, so that * calling GrowablePipedOutputStream.write() causes bytes to be deposited with the * matching GrowablePipedInputStream. However, unlike PipedInputStream, * GrowablePipedInputStream stores bytes in a * ShrinkableByteArrayOutputStream, which * can grow and contract dynamically in response to the number of bytes it contains. * *

          * For more information about method behavior, see the java.io.InputStream javadoc. *

          * @author Ron Sigal * @version $Revision: 3443 $ *

          * Copyright (c) 2005 *

          * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class GrowablePipedInputStream extends InputStream { protected static final Logger log = Logger.getLogger(GrowablePipedInputStream.class); private GrowablePipedOutputStream source; private ShrinkableByteArrayOutputStream baos = new ShrinkableByteArrayOutputStream(); private VirtualSelector virtualSelector; private boolean connected; private int timeout; /** * Create a new GrowablePipedInputStream. */ public GrowablePipedInputStream() { } /** * Create a new GrowablePipedInputStream. * @param virtualSelector */ public GrowablePipedInputStream(VirtualSelector virtualSelector) { this.virtualSelector = virtualSelector; } /** * Create a new GrowablePipedInputStream. * @param src * * @throws java.io.IOException */ public GrowablePipedInputStream(GrowablePipedOutputStream source) throws IOException { this.source = source; source.connect(this); connected = true; } /** * Create a new GrowablePipedInputStream. * @param virtualSelector * @param src * * @throws java.io.IOException */ public GrowablePipedInputStream(GrowablePipedOutputStream source, VirtualSelector virtualSelector) throws IOException { this.source = source; this.virtualSelector = virtualSelector; source.connect(this); connected = true; } public synchronized int available() { return baos.available(); } public void close() throws IOException { super.close(); if (virtualSelector != null) virtualSelector.unregister(this); } public int getTimeout() { return timeout; } public synchronized int read() throws IOException { if (!connected) throw new IOException("Pipe not connected"); if (baos.available() == 0) { long start = System.currentTimeMillis(); while (true) { try { log.trace(this + ": entering wait()"); wait(timeout); log.trace("leaving wait()"); if (baos.available() > 0) break; if (0 < timeout && timeout <= System.currentTimeMillis() - start) throw new SocketTimeoutException("Read timed out"); } catch (InterruptedException ignored) { log.debug("interrupted"); throw new InterruptedIOException(); } } } byte[] bytes = baos.toByteArray(1); int answer = 0xff & bytes[baos.start()]; if (baos.available() > 0) notify(); return answer; } public synchronized int read(byte[] bytes) throws IOException { return read(bytes, 0, bytes.length); } public synchronized int read(byte[] bytes, int offset, int length) throws IOException { if (!connected) throw new IOException("Pipe not connected"); if (baos.available() == 0) { long start = System.currentTimeMillis(); while (true) { try { log.trace(this + ": entering wait()"); wait(timeout); log.trace("leaving wait()"); if (baos.available() > 0) break; if (0 < timeout && timeout <= System.currentTimeMillis() - start) throw new SocketTimeoutException("Read timed out"); } catch (InterruptedException ignored) { log.debug("interrupted"); throw new InterruptedIOException(); } } } byte[] localBytes = baos.toByteArray(length); int from = baos.start(); int n = baos.bytesReturned(); System.arraycopy(localBytes, from, bytes, offset, n); if (baos.available() > 0) notify(); return n; } public void register(VirtualSelector virtualSelector, Object attachment) { this.virtualSelector = virtualSelector; virtualSelector.register(this, attachment); } public void setTimeout(int timeout) { this.timeout = timeout; } protected void connect(GrowablePipedOutputStream source) throws IOException { if (source == null) throw new NullPointerException(); if (source.isConnected()) throw new IOException("Already connected"); this.source = source; connected = true; } protected boolean isConnected() { return connected; } protected void receive(int i) throws IOException { log.trace("entering receive()"); synchronized (this) { baos.write(i); notify(); } if (virtualSelector != null) virtualSelector.addToReadyInputStreams(this); } protected void receive(byte[] bytes) throws IOException { log.trace("entering receive()"); synchronized (this) { baos.write(bytes); notify(); } if (virtualSelector != null) virtualSelector.addToReadyInputStreams(this); } protected void receive(byte[] bytes, int offset, int length) throws IOException { log.trace(this + ": entering receive()"); synchronized (this) { baos.write(bytes, offset, length); log.trace(this + ": notifying"); notify(); } if (virtualSelector != null) virtualSelector.addToReadyInputStreams(this); } }././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/SinkOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/SinkOu0000644000175000017500000000341010753261335033556 0ustar twernertwerner/* * 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. */ /* * Created on Jul 31, 2005 */ package org.jboss.remoting.transport.multiplex.utility; import java.io.IOException; import java.io.OutputStream; /** * *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class SinkOutputStream extends OutputStream { private static SinkOutputStream sinkOutputStream; private SinkOutputStream() { } public static SinkOutputStream getSinkOutputStream() { if (sinkOutputStream == null) sinkOutputStream = new SinkOutputStream(); return sinkOutputStream; } public void write(int b) throws IOException { } public void close() { } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/AddressPair.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/Addres0000644000175000017500000000652610753261335033563 0ustar twernertwerner/* * 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. */ /* * Created on Oct 28, 2005 */ package org.jboss.remoting.transport.multiplex.utility; import java.io.IOException; import java.net.InetAddress; /** * AddressPair is a utility class that represents a pair of socket addresses, * each with a host and port. * * @author Ron Sigal * @version $Revision: 3443 $ *

          * Copyright (c) 2005 *

          * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class AddressPair { private InetAddress localHost; private int localPort; private InetAddress remoteHost; private int remotePort; private boolean hashCodeSet = false; private int hashCode; /** * * Create a new AddressPair. * @param remoteHost * @param remotePort * @param localHost * @param localPort */ public AddressPair(String remoteHost, int remotePort, String localHost, int localPort) throws IOException { this.localHost = InetAddress.getByName(localHost); this.localPort = localPort; this.remoteHost = InetAddress.getByName(remoteHost); this.remotePort = remotePort; } /** * */ public boolean equals(Object o) { if (o == null) return false; if (!(o instanceof AddressPair)) return false; AddressPair ap = (AddressPair) o; return (localHost.equals(ap.localHost) && localPort == ap.localPort && remoteHost.equals(ap.remoteHost) && remotePort == ap.remotePort); } /** * */ public int hashCode() { if (!hashCodeSet) { hashCode = localHost.hashCode() * localPort + remoteHost.hashCode() * remotePort; hashCodeSet = true; } return hashCode; } /** * Get the localHost. * * @return the localHost. */ public String getLocalHost() { return localHost.getHostName(); } /** * Get the localPort. * * @return the localPort. */ public int getLocalPort() { return localPort; } /** * Get the remoteHost. * * @return the remoteHost. */ public String getRemoteHost() { return remoteHost.getHostName(); } /** * Get the remotePort. * * @return the remotePort. */ public int getRemotePort() { return remotePort; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/StoppableThread.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/Stoppa0000644000175000017500000000445210753261335033623 0ustar twernertwerner/* * 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. */ /* * Created on Jul 23, 2005 */ package org.jboss.remoting.transport.multiplex.utility; /** * StoppableThread is the abstract parent of several threads used in the Multiplex system. * It is distinguished by a shutdown() method that facilitates termination. *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public abstract class StoppableThread extends Thread { protected boolean running = false; protected boolean stopped = true; protected boolean terminatedOnError = false; /** * */ public void run() { running = true; stopped = false; doInit(); while (running) doRun(); doShutDown(); stopped = true; } /** * */ protected abstract void doInit(); /** * */ protected abstract void doRun(); /** * */ protected abstract void doShutDown(); /** * * @return */ public synchronized boolean isRunning() { return running; } /** * * @return */ public synchronized boolean isStopped() { return stopped; } /** * */ public synchronized void shutdown() { running = false; } } ././@LongLink0000000000000000000000000000020300000000000011560 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/ShrinkableByteArrayOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/Shrink0000644000175000017500000001332210753261335033607 0ustar twernertwerner/* * 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. */ /* * Created on Oct 15, 2005 */ package org.jboss.remoting.transport.multiplex.utility; import java.io.ByteArrayOutputStream; /** * ShrinkableByteArrayOutputStream extends java.io.ByteArrayOutputStream and adds * the following features: *

          *

            *
          1. Rather than creating a new byte array with each call to toByteArray(), * it returns a reference to its internal byte array. start() * returns the position of the next available byte and available() * returns the number of bytes of content, starting at start(), are available. *
          2. It reuses its capacity, treating its byte array as a circular queue. When * write() is called, if there is too little space at the end of the buffer, * and less than half of the capacity is currently in use, it will shift the current * contents of its buffer to position 0. *
          3. When toByteArray() is called, if less than a quarter of the * current capacity is in use and the current capacity is greater than MIN_LENGTH * (currently defined as 1024), it will copy the current contents to a byte array * one half the size of the current byte array. *
          * *

          * @author Ron Sigal * @version $Revision: 3443 $ *

          * Copyright (c) 2005 *

          * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class ShrinkableByteArrayOutputStream extends ByteArrayOutputStream { static private int MIN_LENGTH = 1024; private int used = 0; private int nextUsed = 0; private int bytesReturned = 0; /** * Create a new ShrinkableByteArrayOutputStream. */ public ShrinkableByteArrayOutputStream() { super(MIN_LENGTH); } /** * Create a new ShrinkableByteArrayOutputStream. */ public ShrinkableByteArrayOutputStream(int size) { super(size); } /** * Returns number of bytes of content which can be retrieved. * @return number of bytes of content which can be retrieved */ public int available() { return count - nextUsed; } /** * Returns number of bytes of content returned by last call to toByteArray(). * @return number of bytes of content returned by last call to toByteArray() */ public int bytesReturned() { return bytesReturned; } /** * Returns position of next available byte of content in byte array returned * by toByteArray(). * @return position of next available byte of content in byte array returned * by toByteArray() */ public int start() { return used; } /** * Returns reference to internal byte array. * @param length number of bytes desired * @return reference to internal byte array */ public byte[] toByteArray(int length) { used = nextUsed; int currentLength = buf.length; int quarterLength = currentLength >> 2; if (currentLength > MIN_LENGTH && currentLength - used <= quarterLength) { byte newbuf[] = new byte[currentLength >> 1]; System.arraycopy(buf, used, newbuf, 0, available()); buf = newbuf; count -= used; used = 0; } bytesReturned = Math.min(count - used, length); nextUsed = used + bytesReturned; return buf; } /** * Writes the specified byte to this byte array output stream. * * @param b the byte to be written. */ public void write(int b) { if (count == buf.length && used > buf.length >> 1) { System.arraycopy(buf, used, buf, 0, count - used); nextUsed -= used; count -= used; used = 0; } super.write(b); } /** * Writes len bytes from the specified byte array * starting at offset off to this byte array output stream. * * @param b the data. * @param off the start offset in the data. * @param len the number of bytes to write. */ public void write(byte b[], int off, int len) { if (count + len > buf.length && used > buf.length >> 1) { System.arraycopy(buf, used, buf, 0, count - used); nextUsed -= used; count -= used; used = 0; } super.write(b, off, len); } protected int getCount() { return super.size(); } protected int getLength() { return buf.length; } protected int getNextUsed() { return nextUsed; } protected int getUsed() { return used; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/VirtualSelector.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/Virtua0000644000175000017500000001462410753261335033631 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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.remoting.transport.multiplex.utility; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Set; import org.jboss.logging.Logger; /** * @author Ron Sigal * @version $$Revision$$ *

          * Copyright (c) April 8, 2006 *

          */ /** * VirtualSelector is a simple version of * java.nio.channels.Selector. It allows a thread to * register for InputStreams to notify it that they have bytes ready to read. * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class VirtualSelector { protected static final Logger log = Logger.getLogger(VirtualSelector.class); private Map attachmentMap = new HashMap(); private Map readyMap = new HashMap(); private Map readyMapCopy = new HashMap(); private Set removableStreams = new HashSet(); private boolean open = true; private boolean closed; private boolean inUse; /** * Allows an InputStream to register itself and an attachment. * @param inputStream * @param attachment */ public synchronized void register(GrowablePipedInputStream inputStream, Object attachment) { attachmentMap.put(inputStream, attachment); } /** * Allows an InputStream to unregister itself. * @param inputStream */ public synchronized void unregister(InputStream inputStream) { attachmentMap.remove(inputStream); readyMap.remove(inputStream); removableStreams.add(inputStream); } /** * Allows a Thread to wait to be informed of InputStreams that have bytes ready to read. * @return a Map from a set of InputStreams with ready bytes to their attachments. * If close() is called while a Thread is waiting in * select(), and if there are * no ready InputStreams, select() will return null. */ public synchronized Map select() { if (closed) return null; // Remove any InputStreams declared to be removable. Iterator it = removableStreams.iterator(); while (it.hasNext()) { readyMapCopy.remove(it.next()); } removableStreams.clear(); // Add any newly ready InputStreams. readyMapCopy.putAll(readyMap); readyMap.clear(); // If there are any ready InputStreams, we're done. if (!readyMapCopy.isEmpty()) return readyMapCopy; // Otherwise, wait for some InputStream to become ready. while (readyMap.isEmpty() && open) { try { inUse = true; wait(); } catch (InterruptedException ignored) {} finally { inUse = false; } } // If readyMap is empty, then we're here because someone called close(). if (readyMap.isEmpty()) { log.debug("returning null"); finishClose(); return null; } // Transfer all ready InputStreams to readyMapCopy. readyMapCopy.putAll(readyMap); readyMap.clear(); return readyMapCopy; } /** * Returns true if and only if this VirtualSelector is open. * @return true if and only if this VirtualSelector is open */ public boolean isOpen() { return open; } /** * Marks this VirtualSelector as preparing to close. * If any Thread is blocked in select(), select() returns null. */ public synchronized void close() { open = false; if (inUse) notifyAll(); else finishClose(); } /** * Allows an InputStream to inform a listening Thread * that it has bytes ready to read. * @param inputStream */ public synchronized void addToReadyInputStreams(InputStream inputStream) throws IOException { if (!open) throw new IOException("This VirtualSelector is closed."); readyMap.put(inputStream, attachmentMap.get(inputStream)); notifyAll(); } /** * Indicates that an InputStream has been processed. * If InputStream has no available bytes, it * will be removed from the Set of InputStreams * that will be returned by the next call to * select(). If InputStream has available bytes, * its status will not be changed. * * @param inputStream * @throws IOException */ public synchronized void remove(InputStream inputStream) throws IOException { removableStreams.add(inputStream); } public synchronized void waitUntilEmpty() { while (!readyMap.isEmpty()) { try { log.debug("waiting until empty"); wait(); } catch (InterruptedException ignored) {} } log.debug("empty"); } /** * Finishes the process of closing this VirtualSelector, releasing all resources. */ protected void finishClose() { attachmentMap.clear(); readyMap.clear(); readyMapCopy.clear(); removableStreams.clear(); closed = true; } }././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/GrowablePipedOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/utility/Growab0000644000175000017500000001010410753261335033565 0ustar twernertwerner/* * 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. */ /* * Created on Dec 15, 2005 */ package org.jboss.remoting.transport.multiplex.utility; import java.io.IOException; import java.io.OutputStream; /** * GrowablePipedOutputStream works together with * GrowablePipedInputStream like java.io.PipedInputStream * and java.io.PipedOutputStream work together, so that * calling GrowablePipedOutputStream.write() causes bytes to be deposited with the * matching GrowablePipedInputStream. However, unlike * PipedInputStream, GrowablePipedInputStream stores * bytes in a ShrinkableByteArrayOutputStream, which * can grow and contract dynamically in response to the number of bytes it contains. * *

          * For more information about method behavior, see the java.io.OutputStream javadoc. * @author Ron Sigal * @version $Revision: 3443 $ *

          * Copyright (c) 2005 *

          * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class GrowablePipedOutputStream extends OutputStream { private GrowablePipedInputStream sink; private boolean connected; /** * Create a new GrowablePipedOutputStream. * * */ public GrowablePipedOutputStream() { } /** * Create a new GrowablePipedOutputStream. * * @param snk * @throws java.io.IOException */ public GrowablePipedOutputStream(GrowablePipedInputStream sink) throws IOException { this.sink = sink; sink.connect(this); connected = true; } public void write(int b) throws IOException { if (sink == null) throw new IOException("Pipe not connected"); sink.receive(b); } public void write(byte[] bytes) throws IOException { if (sink == null) throw new IOException("Pipe not connected"); if (bytes == null) throw new NullPointerException(); sink.receive(bytes); } public void write(byte[] bytes, int offset, int length) throws IOException { if (sink == null) throw new IOException("Pipe not connected"); if (bytes == null) throw new NullPointerException(); if ((offset < 0) || (offset > bytes.length) || (length < 0) || ((offset + length) > bytes.length) || ((offset + length) < 0)) throw new IndexOutOfBoundsException("offset = " + offset + ", length = " + length + ", file buffer size: " + bytes.length); if (length == 0) return; sink.receive(bytes, offset, length); } protected void connect(GrowablePipedInputStream sink) throws IOException { if (sink == null) throw new NullPointerException(); if (sink.isConnected()) throw new IOException("Already connected"); this.sink = sink; connected = true; } protected boolean isConnected() { return connected; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/OutputMultiplexor.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/OutputMultiple0000644000175000017500000006144410753261335033672 0ustar twernertwerner/* * 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. */ /* * Created on Jul 22, 2005 */ package org.jboss.remoting.transport.multiplex; import org.jboss.logging.Logger; import org.jboss.remoting.transport.multiplex.utility.StoppableThread; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.SocketException; import java.nio.ByteBuffer; import java.nio.channels.ClosedChannelException; import java.nio.channels.SocketChannel; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.Set; import javax.net.ssl.SSLException; /** * OutputMultiplexor is one of the key Multiplex classes, responsible for * multiplexing multiple byte streams that share a single TCP connection. It has an * inner class that performs this function. *

          * The data stream created here consists of a sequence of packets, each consisting of * a header, with the format: *

          * * * * * * * *
          byte: version (current version is 0) *
          int: destination virtual socket id *
          short: number of data bytes to follow *
          *

          * followed by the number of data bytes specified in the header. *

          * OutputMultiplexor has two fairness constraints that prevent one virtual stream from * starving the others. *

          *

            *
          1. maxTimeSlice determines the maximum time devoted to writing bytes for a * given virtual connection before going on to process another virtual connection, and *
          2. maxDataSlice determines the maximum number of bytes written for a given * virtual connection before going on to process another virtual connection. *
          * *

          * For additional information about configuring OutputMultiplexor, please see the * documentation at labs.jbos.org. *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class OutputMultiplexor { protected static final Logger log = Logger.getLogger(OutputMultiplexor.class); protected static final int BRACKETS_ALL = -1; protected static final int BRACKETS_NONE = -2; protected static final int HEADER_SIZE = 7; private int messagePoolSize; private int messageSize; private int maxChunkSize; private int maxTimeSlice; private int maxDataSlice; private int maxErrors; private Map configuration = new HashMap(); private Map writeQueues = Collections.synchronizedMap(new HashMap()); private Map readyQueues = Collections.synchronizedMap(new HashMap()); private Map previousDestinationIds = Collections.synchronizedMap(new HashMap()); private Set unregisteredClients = Collections.synchronizedSet(new HashSet()); private List messagePool; private ByteBuffer buffer; private byte[] header = new byte[HEADER_SIZE]; private int errorCount; private boolean trace; private boolean debug; private boolean info; /** * @param configuration * @throws IOException */ protected OutputMultiplexor(Map configuration) throws IOException { this.configuration.putAll(configuration); messagePoolSize = Multiplex.getOneParameter(configuration, "messagePoolSize", Multiplex.OUTPUT_MESSAGE_POOL_SIZE, Multiplex.OUTPUT_MESSAGE_POOL_SIZE_DEFAULT); messageSize = Multiplex.getOneParameter(configuration, "messageSize", Multiplex.OUTPUT_MESSAGE_SIZE, Multiplex.OUTPUT_MESSAGE_SIZE_DEFAULT); maxChunkSize = Multiplex.getOneParameter(configuration, "maxChunkSize", Multiplex.OUTPUT_MAX_CHUNK_SIZE, Multiplex.OUTPUT_MAX_CHUNK_SIZE_DEFAULT); maxTimeSlice = Multiplex.getOneParameter(configuration, "maxTimeSlice", Multiplex.OUTPUT_MAX_TIME_SLICE, Multiplex.OUTPUT_MAX_TIME_SLICE_DEFAULT); maxDataSlice = Multiplex.getOneParameter(configuration, "maxDataSlice", Multiplex.OUTPUT_MAX_DATA_SLICE, Multiplex.OUTPUT_MAX_DATA_SLICE_DEFAULT); maxErrors = Multiplex.getOneParameter(configuration, "maxErrors", Multiplex.OUTPUT_MAX_ERRORS, Multiplex.OUTPUT_MAX_ERRORS_DEFAULT); log.debug("messagePoolSize: " + messagePoolSize); log.debug("messageSize: " + messageSize); log.debug("maxChunkSize: " + maxChunkSize); log.debug("maxTimeSlice: " + maxTimeSlice); log.debug("maxDataSlice: " + maxDataSlice); log.debug("maxErrors: " + maxErrors); messagePool = Collections.synchronizedList(new ArrayList(messagePoolSize)); for (int i = 0; i < messagePoolSize; i++) messagePool.add(new Message(messageSize)); buffer = ByteBuffer.allocate(maxChunkSize + HEADER_SIZE); trace = log.isTraceEnabled(); debug = log.isDebugEnabled(); info = log.isInfoEnabled(); } /** * A class implementing this interface can register to be notified when all of its * bytes have been processed. */ public interface OutputMultiplexorClient { void outputFlushed(); } /** * @return */ public OutputThread getAnOutputThread() { return new OutputThread(); } /** * @param manager * @param socketId * @param content * @throws IOException */ public void write(MultiplexingManager manager, SocketId socketId, byte[] content) throws IOException { write(manager, socketId, content, BRACKETS_NONE); } /** * * @param manager * @param socketId * @param content * @throws InterruptedException */ public void write(MultiplexingManager manager, SocketId socketId, byte[] content, int brackets) throws IOException { log.debug("entering write()"); if (trace) { String messageEnd = ""; if (content.length > 0) messageEnd = ": [" + (0xff & content[0]) + "]"; log.trace("OutputMultiplexor.write(): queueing " + content.length + " bytes for \n manager: " + manager + "\n socket: " + socketId.getPort() + messageEnd); } if (content.length == 0) return; synchronized (readyQueues) { List writeQueue = (List) writeQueues.get(manager); if (writeQueue == null) { log.error("unregistered client: " + manager); return; } synchronized (writeQueue) { if (!writeQueue.isEmpty()) { Message message = (Message) writeQueue.get(writeQueue.size() - 1); if (message.getDestination().equals(socketId) && message.hasCompatibleBrackets(brackets)) { message.addContent(content); } else writeQueue.add(getaMessage(socketId, content, brackets)); } else writeQueue.add(getaMessage(socketId, content, brackets)); } readyQueues.put(manager, writeQueue); readyQueues.notifyAll(); } } /** * Allows a OutputMultiplexorClient to register to be notified when all * of its bytes have been processed. * * @param client */ public void register(OutputMultiplexorClient client) { if (debug) log.debug("registering: " + client); synchronized (writeQueues) { List writeQueue = Collections.synchronizedList(new LinkedList()); writeQueues.put(client, writeQueue); } } /** * Unregisters an OutputMultiplexorClient. * * @param client */ public void unregister(OutputMultiplexorClient client) { if (debug) log.debug("unregistering: " + client); synchronized (writeQueues) { List writeQueue = (List) writeQueues.get(client); if (writeQueue == null) { log.debug("attempt to unregister unknown Listener: " + client); client.outputFlushed(); return; } if (writeQueue.isEmpty()) { writeQueues.remove(client); previousDestinationIds.remove(client); client.outputFlushed(); } else { unregisteredClients.add(client); } } } protected Message getaMessage(SocketId socketId, byte[] content, int brackets) throws IOException { Message m = null; if (messagePool.isEmpty()) m = new Message(messageSize); else m = (Message) messagePool.remove(0); m.set(socketId, content, brackets); return m; } protected void releaseMessage(Message m) { if (messagePool.size() < messagePoolSize) { messagePool.add(m); } } /** * */ class OutputThread extends StoppableThread { private final Logger log = Logger.getLogger(OutputMultiplexor.OutputThread.class); private boolean socketIsOpen = true; private Map localWriteQueues = new HashMap(); private Message pendingMessage; public OutputThread() { } /** * */ public void shutdown() { super.shutdown(); interrupt(); } protected void doInit() { log.debug("output thread starting"); } protected void doRun() { while (isRunning()) { log.debug("STARTING new output round"); localWriteQueues.clear(); // Wait until there is a pending message in some socket group, then get a // local copy of the writeQueue Map. synchronized (readyQueues) { while (readyQueues.isEmpty()) { try { log.debug("waiting"); readyQueues.wait(); } catch (InterruptedException e) { if (!isRunning()) return; } } localWriteQueues.putAll(readyQueues); readyQueues.clear(); } // Process each socket group that has a pending message. Iterator it = localWriteQueues.keySet().iterator(); while (it.hasNext()) { try { MultiplexingManager manager = (MultiplexingManager) it.next(); List writeQueue = (List) localWriteQueues.get(manager); OutputStream os = manager.getOutputStream(); SocketId destination = null; int dataOutCount = 0; long startTime = System.currentTimeMillis(); // Process pending messages in one socket group. while (!writeQueue. isEmpty()) { long timeSpent = System.currentTimeMillis() - startTime; if (timeSpent > maxTimeSlice || dataOutCount > maxDataSlice) { if (debug) { log.debug("returning queue: data out: " + dataOutCount + ", time spent: " + timeSpent); } synchronized (readyQueues) { readyQueues.put(manager, writeQueue); } break; } pendingMessage = (Message) writeQueue.remove(0); destination = pendingMessage.getDestination(); // The following code, which combines contiguous messages to the same // destination, slightly degraded performance in tests. // while (!writeQueue.isEmpty()) // { // if (!destination.equals(((Message) writeQueue.get(0)).getDestination())) // break; // // Message nextMessage = (Message) writeQueue.remove(0); // int start = nextMessage.getStart(); // int length = nextMessage.getLength(); // pendingMessage.addContent(nextMessage.getContent(), start, length); // } int start = pendingMessage.getStart(); int length = Math.min(pendingMessage.getLength(), maxChunkSize); try { encode(destination, pendingMessage.getContent(), start, length, os, manager.getSocket().getChannel()); } catch (ClosedChannelException e) { log.info(e); writeQueue.clear(); manager.setWriteException(e); break; } catch (IOException e) { String message = e.getMessage(); if ("An existing connection was forcibly closed by the remote host".equals(message) || "An established connection was aborted by the software in your host machine".equals(message) || "Broken pipe".equals(message) || "Connection reset".equals(message) || "Connection closed by remote host".equals(message) || "Socket is closed".equals(message) ) { log.debug(e); writeQueue.clear(); manager.setWriteException(e); break; } else if (++errorCount > maxErrors) { log.error(e); manager.setWriteException(e); throw e; } else { // Haven't reached maxErrors yet throw e; } } // If it's a long message with bytes left over, return to message queue. if (length < pendingMessage.getLength()) returnLongMessageToQueue(writeQueue, pendingMessage); else releaseMessage(pendingMessage); dataOutCount += length; pendingMessage = null; if (trace) log.trace("output thread wrote: " + length + " bytes to socket " + destination.getPort()); } if (writeQueue.isEmpty() && unregisteredClients.contains(manager)) { writeQueues.remove(writeQueue); previousDestinationIds.remove(manager); unregisteredClients.remove(manager); manager.outputFlushed(); continue; } previousDestinationIds.put(manager, destination); if (interrupted()) // outside of writeQueue.take() throw new InterruptedException(); } catch (InterruptedException e) { handleError("output thread: interrupted", e); } catch (SocketException e) { handleError("output thread: socket exception", e); } catch (IOException e) { handleError("output thread: i/o error", e); } finally { // Indicate that messages for this socket group have been written. it.remove(); } } } log.debug("output thread: socketIsConnected: " + socketIsOpen); log.debug("output thread: running: " + running); log.debug("output thread: pendingMessage == " + pendingMessage); } /** * */ protected void doShutDown() { log.debug("output thread shutting down"); } /** * * @param bytes * @param start * @param length * @param os * @param channel * @throws IOException */ protected void encode(SocketId destination, byte[] bytes, int start, int length, OutputStream os, SocketChannel channel) throws IOException { // Create header. int port = destination.getPort(); // Set version. header[0] = (byte) 0; // Set destination. header[1] = (byte) ((port >>> 24) & 0xff); header[2] = (byte) ((port >>> 16) & 0xff); header[3] = (byte) ((port >>> 8) & 0xff); header[4] = (byte) ( port & 0xff); // Set size. header[5] = (byte) ((length >> 8) & 0xff); header[6] = (byte) ( length & 0xff); if (channel == null) { os.write(header); os.write(bytes, start, length); os.flush(); } else { buffer.clear(); buffer.put(header); buffer.put(bytes, start, length); buffer.flip(); while (buffer.hasRemaining()) channel.write(buffer); } if (trace) { log.trace("encode(): wrote " + length + " bytes to: " + destination); log.trace("header: " + header[0] + " " + header[1] + " " + header[2] + " " + header[3] + " " + header[4] + " " + header[5] + " " + header[6]); for (int i = 0; i < length; i++) log.trace("" + (0xff & bytes[i])); } } protected void returnLongMessageToQueue(List writeQueue, Message pendingMessage) { SocketId destination = pendingMessage.getDestination(); pendingMessage.markUsed(maxChunkSize); synchronized (writeQueue) { if (!writeQueue.isEmpty()) { ListIterator lit = writeQueue.listIterator(); boolean processed = false; int remotePort = destination.getPort(); int brackets = pendingMessage.getBrackets(); while (lit.hasNext()) { Message message = (Message) lit.next(); if (message.brackets(remotePort)) { lit.previous(); lit.add(pendingMessage); processed = true; break; } if (message.getDestination().equals(destination) && (BRACKETS_NONE == message.getBrackets() || brackets == message.getBrackets())) { pendingMessage.addContent(message.getContent(), message.getStart(), message.getLength()); lit.set(pendingMessage); processed = true; break; } } if (!processed) { writeQueue.add(pendingMessage); } } else { writeQueue.add(pendingMessage); } } } /** * * @param message * @param e */ protected void handleError(String message, Throwable e) { if (log != null) { if (e instanceof InterruptedException) { if (trace) log.trace(message, e); } else log.error(message, e); } } } /** * A Message holds the destination and content of a byte array destined for * the endpoint of a virtual connection. *

          * It also has a variable brackets which can be used to indicate that this * Message should be sent after other Messages to a given * destination. There are three cases: *

          * * * * * * * * *
          valuemeaning
          BRACKETS_ALL * all other Messages should preceed this one *
          BRACKETS_NONE * there are no constraints on this Message *
          any other integer x * all other Messages to destination x should * preceed this Message *
          */ private static class Message { private SocketId socketId; private ByteArrayOutputStream baos; private int start; private int length; private int brackets; public Message(int size) { baos = new ByteArrayOutputStream(size); } public void set(SocketId socketId, byte[] content, int brackets) throws IOException { this.socketId = socketId; baos.reset(); baos.write(content); start = 0; length = content.length; this.brackets = brackets; } public SocketId getDestination() { return socketId; } public byte[] getContent() { return baos.toByteArray(); } public void addContent(byte[] bytes) throws IOException { baos.write(bytes); length += bytes.length; } public void addContent(byte[] bytes, int start, int length) { baos.write(bytes, start, length); this.length += length; } public int getStart() { return start; } public int getLength() { return length; } public int getBrackets() { return brackets; } public void markUsed(int used) { length -= used; if (length <= 0) { start = 0; length = 0; baos.reset(); } else { start += used; } } public boolean brackets(int b) { if (brackets == BRACKETS_ALL) return true; if (brackets == BRACKETS_NONE) return false; return (brackets == b); } public boolean hasCompatibleBrackets(int b) { if (brackets == BRACKETS_ALL || b == BRACKETS_NONE) return true; return (brackets == b); } } public int getMaxChunkSize() { return maxChunkSize; } public void setMaxChunkSize(int maxChunkSize) { this.maxChunkSize = maxChunkSize; } public int getMessagePoolSize() { return messagePoolSize; } public void setMessagePoolSize(int messagePoolSize) { this.messagePoolSize = messagePoolSize; } public int getMessageSize() { return messageSize; } public void setMessageSize(int messageSize) { this.messageSize = messageSize; } }././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MasterServerSocket.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MasterServerSo0000644000175000017500000004327210753261335033601 0ustar twernertwerner/* * 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. */ /* * Created on Jul 24, 2005 */ package org.jboss.remoting.transport.multiplex; import org.jboss.logging.Logger; import javax.net.ServerSocketFactory; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketAddress; import java.net.SocketException; import java.net.SocketTimeoutException; import java.nio.channels.ServerSocketChannel; import java.util.HashMap; import java.util.Map; /** * MasterServerSocket is one of the two implementations of a server socket in the * Multiplex project. For each socket created in the accept() method, it builds * a virtual socket group. For more details, see the Multiplex documentation on * the labs.jboss.org web site. * *

          * Most of the methods in MasterServerSocket override those in its parent class, * java.net.ServerSocket. For method descriptions, see the ServerSocket javadoc. * *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class MasterServerSocket extends ServerSocket implements Serializable { private static final Logger log = Logger.getLogger(MasterServerSocket.class); private Map configuration = new HashMap(); private ServerSocket ss; private ServerSocketChannel ssc; private static final long serialVersionUID = 402293949935889044L; /** * @throws java.io.IOException */ public MasterServerSocket() throws IOException { this(true); } /** * @param port * @throws java.io.IOException */ public MasterServerSocket(int port) throws IOException { this(true, port); } /** * @param port * @param backlog * @throws java.io.IOException */ public MasterServerSocket(int port, int backlog) throws IOException { this(true, port, backlog); } /** * @param port * @param backlog * @param bindAddr * @throws java.io.IOException */ public MasterServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException { this(true, port, backlog, bindAddr); } /** * @throws java.io.IOException */ public MasterServerSocket(boolean nio) throws IOException { if (nio) { ssc = ServerSocketChannel.open(); ss = ssc.socket(); } else { ss = new ServerSocket(); } } /** * @param port * @throws java.io.IOException */ public MasterServerSocket(boolean nio, int port) throws IOException { if (nio) { ssc = ServerSocketChannel.open(); ss = ssc.socket(); ss.bind(new InetSocketAddress(port)); } else { ss = new ServerSocket(port); } } /** * @param port * @param backlog * @throws java.io.IOException */ public MasterServerSocket(boolean nio, int port, int backlog) throws IOException { if (nio) { ssc = ServerSocketChannel.open(); ss = ssc.socket(); ss.bind(new InetSocketAddress(port), backlog); } else { ss = new ServerSocket(port, backlog); } } /** * @param port * @param backlog * @param bindAddr * @throws java.io.IOException */ public MasterServerSocket(boolean nio, int port, int backlog, InetAddress bindAddr) throws IOException { if (nio) { ssc = ServerSocketChannel.open(); ss = ssc.socket(); ss.bind(new InetSocketAddress(bindAddr, port), backlog); } else { ss = new ServerSocket(port, backlog, bindAddr); } } /** * * Create a new MasterServerSocket. * If Map conf contains key Multiplex.SERVER_SOCKET_FACTORY, will use it. * Otherwise, will create an NIO ServerSocket. * * @param port * @param backlog * @param bindAddr * @param conf * @throws IOException */ public MasterServerSocket(int port, int backlog, InetAddress bindAddr, Map conf) throws IOException { if (conf != null) configuration.putAll((conf)); if (conf == null || conf.get(Multiplex.SERVER_SOCKET_FACTORY) == null) { ssc = ServerSocketChannel.open(); ss = ssc.socket(); ss.bind(new InetSocketAddress(bindAddr, port), backlog); } else { Object obj = conf.get(Multiplex.SERVER_SOCKET_FACTORY); if (!(obj instanceof ServerSocketFactory)) { String msg = "configuration map contains invalid entry for Multiplex.SERVER_SOCKET_FACTORY: " + obj; log.error(msg); throw new IOException(msg); } ServerSocketFactory ssf = (ServerSocketFactory) obj; ss = ssf.createServerSocket(port, backlog, bindAddr); } } /** * @param ssf * @throws IOException */ public MasterServerSocket(ServerSocketFactory ssf) throws IOException { ss = ssf.createServerSocket(); } /** * @param ssf * @param port * @throws IOException */ public MasterServerSocket(ServerSocketFactory ssf, int port) throws IOException { ss = ssf.createServerSocket(port); } /** * @param ssf * @param port * @param backlog * @throws IOException */ public MasterServerSocket(ServerSocketFactory ssf, int port, int backlog) throws IOException { ss = ssf.createServerSocket(port, backlog); } /** * @param ssf * @param port * @param backlog * @param bindAddr * @throws IOException */ public MasterServerSocket(ServerSocketFactory ssf, int port, int backlog, InetAddress bindAddr) throws IOException { ss = ssf.createServerSocket(port, backlog, bindAddr); } ////////////////////////////////////////////////////////////////////////////////////////////////// /// The following methods are required of any ServerSocket '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /* ok: public Socket accept() throws IOException; ok: public void bind(SocketAddress endpoint) throws IOException; ok: public void bind(SocketAddress endpoint, int backlog) throws IOException; ok: public void close() throws IOException; ok: public ServerSocketChannel getChannel(); ok: public InetAddress getInetAddress(); ok: public int getLocalPort(); ok: public SocketAddress getLocalSocketAddress(); ok: public int getReceiveBufferSize() throws SocketException; ok: public boolean getReuseAddress() throws SocketException; ok: public int getSoTimeout() throws IOException; ok: public boolean isBound(); ok: public boolean isClosed(); ok: public void setReceiveBufferSize(int size) throws SocketException; ok: public void setReuseAddress(boolean on) throws SocketException; ok: public void setSoTimeout(int timeout) throws SocketException; ok: public String toString(); */ /** * See java.net.ServerSocket javadoc. */ public Socket accept() throws IOException { long start = System.currentTimeMillis(); int timeout = getSoTimeout(); int savedTimeout = timeout; int timeLeft = 0; Socket socket = null; SocketTimeoutException savedException = null; while (true) { if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("Accept timed out"); setSoTimeout(timeLeft); try { socket = ss.accept(); } catch (SocketTimeoutException e) { // NIO ServerSocket doesn't set message. savedException = new SocketTimeoutException("Accept timed out"); throw savedException; } finally { try { setSoTimeout(savedTimeout); } catch (Exception e) {} if (savedException != null) throw savedException; } MultiplexingManager manager = MultiplexingManager.getaManager(socket, configuration); MultiplexingInputStream is = null; Protocol protocol = null; SocketId clientPort = null; try { is = manager.getAnInputStream(SocketId.SERVER_SOCKET_ID, null); protocol = manager.getProtocol(); if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("Accept timed out"); clientPort = protocol.acceptConnect(is, timeLeft); } catch (SocketTimeoutException e) { log.debug("i/o exception in MasterServerSocket.accept()"); manager.decrementReferences(); throw e; } catch (IOException e) { log.error("i/o exception in MasterServerSocket.accept()", e); manager.decrementReferences(); throw e; } if (log.isDebugEnabled()) log.debug("accept(): clientPort: " + clientPort.getPort()); // connection from independent VirtualServerSocket if (clientPort.getPort() < 0) { MultiplexingOutputStream os = new MultiplexingOutputStream(manager, SocketId.SERVER_SOCKET_CONNECT_ID); try { protocol.answerConnect(os, SocketId.SERVER_SOCKET_CONNECT_PORT); } catch (IOException e) { // If this connect timed out at the other end, there may not be an OutputStream to write to. log.error("unable to respond to connect request"); manager.decrementReferences(); if (e instanceof SocketTimeoutException) throw new SocketTimeoutException("Accept timed out"); throw e; } // Keept trying to accept a request for a VirtualSocket connection. continue; } VirtualSocket virtualSocket = null; try { virtualSocket = new VirtualSocket(manager, clientPort, configuration); } catch (IOException e) { manager.decrementReferences(); throw e; } int localPort = virtualSocket.getLocalVirtualPort(); try { protocol.answerConnect((MultiplexingOutputStream)virtualSocket.getOutputStream(), localPort); } catch (IOException e) { // If this connect timed out at the other end, there may not be an OutputStream to write to. log.error("unable to respond to connect request"); virtualSocket.close(); throw e; } return virtualSocket; } } /** * See java.net.ServerSocket javadoc. */ public void bind(SocketAddress endpoint) throws IOException { ss.bind(endpoint); } /** * See java.net.ServerSocket javadoc. */ public void bind(SocketAddress endpoint, int backlog) throws IOException { ss.bind(endpoint, backlog); } /** * See java.net.ServerSocket javadoc. */ public void close() throws IOException { log.debug("MasterServerSocket: closing"); ss.close(); } /** * See java.net.ServerSocket javadoc. */ public ServerSocketChannel getChannel() { return ss.getChannel(); } /** * See java.net.ServerSocket javadoc. */ public InetAddress getInetAddress() { return ss.getInetAddress(); } /** * See java.net.ServerSocket javadoc. */ public int getLocalPort() { return ss.getLocalPort(); } /** * See java.net.ServerSocket javadoc. */ public SocketAddress getLocalSocketAddress() { return ss.getLocalSocketAddress(); } /** * See java.net.ServerSocket javadoc. */ public int getReceiveBufferSize() throws SocketException { return ss.getReceiveBufferSize(); } /** * See java.net.ServerSocket javadoc. */ public boolean getReuseAddress() throws SocketException { return ss.getReuseAddress(); } /** * See java.net.ServerSocket javadoc. */ public int getSoTimeout() throws IOException { return ss.getSoTimeout(); } /** * See java.net.ServerSocket javadoc. */ public boolean isBound() { return ss.isBound(); } /** * See java.net.ServerSocket javadoc. */ public boolean isClosed() { return ss.isClosed(); } /** * See java.net.ServerSocket javadoc. */ public void setReceiveBufferSize(int size) throws SocketException { ss.setReceiveBufferSize(size); } /** * See java.net.ServerSocket javadoc. */ public void setReuseAddress(boolean on) throws SocketException { ss.setReuseAddress(on); } /** * See java.net.ServerSocket javadoc. */ public void setSoTimeout(int timeout) throws SocketException { ss.setSoTimeout(timeout); } /** * See java.net.ServerSocket javadoc. */ public String toString() { if (!isBound()) return "MasterServerSocket[unbound]"; return "MasterServerSocket[" + ss.toString() + "]"; } ////////////////////////////////////////////////////////////////////////////////////////////////// // / The following methods are specific to MasterServerSocket '/// ////////////////////////////////////////////////////////////////////////////////////////////////// /** * Accepts a connection from a remote VirtualServerSocket. */ public int acceptServerSocketConnection() throws IOException { long start = System.currentTimeMillis(); int timeout = getSoTimeout(); int savedTimeout = timeout; int timeLeft = 0; // Socket socket = ss.accept(); Socket socket = null; if (ssc == null) socket = ss.accept(); else socket = ssc.accept().socket(); MultiplexingManager manager = MultiplexingManager.getaManager(socket, configuration); manager.setCreatedForRemoteServerSocket(); MultiplexingInputStream is = null; Protocol protocol = null; SocketId clientPort = null; try { is = manager.getAnInputStream(SocketId.SERVER_SOCKET_ID, null); protocol = manager.getProtocol(); if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("Accept timed out"); clientPort = protocol.acceptConnect(is, timeLeft); } catch (IOException e) { log.error("i/o exception in MasterServerSocket.acceptServerSocketConnection()", e); manager.decrementReferences(); if (e instanceof SocketTimeoutException) throw new SocketTimeoutException("Accept timed out"); throw e; } if (clientPort.getPort() != SocketId.SERVER_SOCKET_PORT) { manager.decrementReferences(); String message = "received connect request not from a VirtualServerSocket"; log.error(message); throw new IOException(message); } MultiplexingOutputStream os = new MultiplexingOutputStream(manager, SocketId.SERVER_SOCKET_CONNECT_ID); try { protocol.answerConnect(os, SocketId.SERVER_SOCKET_CONNECT_PORT); } catch (IOException e) { // If this connect timed out at the other end, there may not be an OutputStream to write to. log.error("unable to respond to connect request"); manager.decrementReferences(); throw e; } return manager.getSocket().getLocalPort(); } public void setConfiguration(Map configuration) { this.configuration.putAll(configuration); } }././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/TransportServe0000644000175000017500000000130610753261335033646 0ustar twernertwernerpackage org.jboss.remoting.transport.multiplex; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException { return new MultiplexServerInvoker(locator, config); } public boolean supportsSSL() { return false; } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexInvokerConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/MultiplexInvok0000644000175000017500000000357610457537345033662 0ustar twernertwerner/* * 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. */ /* * Created on Jan 23, 2006 */ package org.jboss.remoting.transport.multiplex; /** * Holds some constants for Multiplex system. Now superceded by the Multiplex * class and deprecated. Will be eliminated in future. * * @author Ron Sigal * @version $Revision: 1248 $ *

          * Copyright (c) 2005 *

          * @deprecated */ public interface MultiplexInvokerConstants { public static final String SERVER_MULTIPLEX_ID_KEY = "serverMultiplexId"; public static final String MULTIPLEX_CONNECT_PORT_KEY = "multiplexConnectPort"; public static final String CLIENT_MULTIPLEX_ID_KEY = "clientMultiplexId"; public static final String MULTIPLEX_BIND_HOST_KEY = "multiplexBindHost"; public static final String MULTIPLEX_BIND_PORT_KEY = "multiplexBindPort"; public static final String MULTIPLEX_CONNECT_HOST_KEY = "multiplexConnectHost"; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/Protocol.java0000644000175000017500000004212710753261335033374 0ustar twernertwerner/* * 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. */ /* * Created on Jul 23, 2005 */ package org.jboss.remoting.transport.multiplex; import org.jboss.logging.Logger; import org.jboss.remoting.transport.multiplex.utility.StoppableThread; import org.jboss.remoting.transport.multiplex.utility.VirtualSelector; import java.io.EOFException; import java.io.IOException; import java.io.InterruptedIOException; import java.io.OutputStream; import java.net.SocketTimeoutException; import java.util.Iterator; import java.util.Map; /** * Protocol is responsible for handling internal Multiplex messages. * Some of these, for example, the messages involved in creating a * new connection (acceptConnect(), connect(), * answerConnect()) are synchronous. * Others, such as a request to shut down, are received asynchronously by * Protocol.BackChannelThread. *

          * Copyright (c) 2005 *

          * @author Ron Sigal * * @deprecated As of release 2.4.0 the multiplex transport will no longer be actively supported. */ public class Protocol { protected static final Logger log = Logger.getLogger(Protocol.class); // message types public static final int MP_CONNECT = 0; public static final int MP_CONNECTED = 1; public static final int MP_VERIFY_CONNECTION = 2; // public static final int MP_INPUT_SHUTDOWN = 3; public static final int MP_OUTPUT_SHUTDOWN = 4; public static final int MP_DISCONNECT = 5; public static final int MP_REGISTER_REMOTE_SERVER = 6; public static final int MP_UNREGISTER_REMOTE_SERVER = 7; public static final int MP_REQUEST_MANAGER_SHUTDOWN = 8; public static final int MP_ERROR = 9; public static final int MP_TRUE = 10; public static final int MP_FALSE = 11; /** InputStream used to receive synchronous messages */ private MultiplexingInputStream protocolInputStream; /** OutputStream used by connect() to communicate with a ServerSocket */ private MultiplexingOutputStream serverSocketOutputStream; /** OutputStream for sending messages to remote backChannelInputStream */ private MultiplexingOutputStream protocolOutputStream; private boolean trace; private boolean debug; private boolean info; /** * @param virtualSelector * @return */ public static BackChannelThread getBackChannelThread(VirtualSelector virtualSelector) { return new BackChannelThread(virtualSelector); } /** * * @param manager * @throws IOException */ public Protocol(MultiplexingManager manager) throws IOException { protocolInputStream = manager.getAnInputStream(SocketId.PROTOCOL_SOCKET_ID, null); protocolOutputStream = new MultiplexingOutputStream(manager, SocketId.BACKCHANNEL_SOCKET_ID); serverSocketOutputStream = new MultiplexingOutputStream(manager, SocketId.SERVER_SOCKET_ID); trace = log.isTraceEnabled(); debug = log.isDebugEnabled(); info = log.isInfoEnabled(); } /** * @param is * @param socketId * @return * @throws IOException */ public SocketId connect(MultiplexingInputStream is, SocketId socketId) throws IOException { return connect(is, socketId, 0); } /** * @param is * @param socketId * * @return * @throws IOException */ public SocketId connect(MultiplexingInputStream is, SocketId socketId, int timeout) throws IOException { log.debug("entering Protocol.connect()"); long start = System.currentTimeMillis(); int timeLeft = 0; int savedTimeout = is.getTimeout(); synchronized (serverSocketOutputStream) { serverSocketOutputStream.write(MP_CONNECT); if (debug) log.debug("Protocol.connect(): wrote: CONNECT (" + MP_CONNECT + ")"); serverSocketOutputStream.writeInt(socketId.getPort()); if (debug) log.debug("Protocol.connect(): wrote port: " + socketId.getPort()); } try { if (timeout > 0) if ((timeLeft = timeout - (int)(System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException(); is.setTimeout(timeLeft); int messageType = is.read(); if (debug) log.debug("Protocol.connect(): read message type: " + messageType); switch (messageType) { case MP_CONNECTED: if (timeout > 0) if ((timeLeft = timeout - (int) (System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException("connect timed out"); is.setTimeout(timeLeft); int remotePort = is.readInt(); if (debug) log.debug("Protocol.connect(): read port: " + remotePort); return new SocketId(remotePort); default: log.error("Protocol.connect(): expecting a CONNECTED message: received: " + messageType); throw new IOException("Protocol.connect(): expecting a CONNECTED message: received: " + messageType); } } catch (SocketTimeoutException e) { log.info("timeout in Protocol.connect()"); throw e; } catch (Exception e) { log.error(e); StackTraceElement[] stes = e.getStackTrace(); for (int i = 0; i < stes.length; i++) log.error(stes[i].toString()); throw new IOException(e.getMessage()); } finally { is.setTimeout(savedTimeout); } } /** * @param is * @param timeout * * @return * @throws IOException */ public SocketId acceptConnect(MultiplexingInputStream is, int timeout) throws IOException { log.debug("entered acceptConnect()"); long start = System.currentTimeMillis(); int timeLeft = timeout; int savedTimeout = is.getTimeout(); try { is.setTimeout(timeLeft); int messageType = is.read(); if (debug) log.debug("Protocol.acceptConnect(): read message type: " + messageType); switch (messageType) { case MP_CONNECT: if (timeout > 0) if ((timeLeft = timeout - (int)(System.currentTimeMillis() - start)) <= 0) throw new SocketTimeoutException(); is.setTimeout(timeLeft); int remotePort = is.readInt(); if (debug) log.debug("Protocol.acceptConnect(): read port: " + remotePort); return new SocketId(remotePort); case -1: log.info("Protocol.acceptConnect(): end of file"); throw new EOFException(); default: log.error("Protocol.acceptConnect: expecting a CONNECT message: received: " + messageType); throw new IOException("Protocol.acceptConnect: expecting a CONNECT message: received: " + messageType); } } catch (SocketTimeoutException e) { log.info("timeout in Protocol.acceptConnect()");; throw e; } finally { is.setTimeout(savedTimeout); } } /** * @param os * @param port * * @throws IOException */ public void answerConnect(MultiplexingOutputStream os, int port) throws IOException { os.write(MP_CONNECTED); if (debug) log.debug("Protocol.answerConnect(): wrote: CONNECTED (" + MP_CONNECTED + ")"); os.writeInt(port); if (debug) log.debug("Protocol.answerConnect(): wrote port: " + port); } /** * * @param socketId */ public void notifyOutputShutdown(SocketId socketId) { int port = socketId.getPort(); try { synchronized (protocolOutputStream) { protocolOutputStream.write(MP_OUTPUT_SHUTDOWN, port); protocolOutputStream.writeInt(port, port); } if (debug) log.debug("Protocol.notifyOutputShutdown(): wrote: OUTPUT_SHUTDOWN (" + MP_OUTPUT_SHUTDOWN + ") for port: " + port); } catch (IOException ignored) { log.error("Protocol.notifyOutputShutdown(): unable to send MP_OUTPUT_SHUTDOWN message to port: " + port); } } /** * * @param socketId */ public void disconnect(SocketId socketId) { int port = socketId.getPort(); try { synchronized (protocolOutputStream) { protocolOutputStream.write(MP_DISCONNECT, port); protocolOutputStream.writeInt(port, port); } if (debug) log.debug("Protocol.disconnect(): wrote: DISCONNECT (" + MP_CONNECTED + ") for port: " + port); } catch (IOException ignored) { log.error("Protocol.disconnect(): unable to send DISCONNECT message to port: " + port); } } /** * @param timeout */ public void registerRemoteServerSocket(int timeout) throws IOException { int answer = MP_FALSE; synchronized (protocolInputStream) { synchronized (protocolOutputStream) { protocolOutputStream.write(MP_REGISTER_REMOTE_SERVER); } if (debug) log.debug("Protocol.registerRemoteServerSocket(): wrote: REGISTER_REMOTE_SERVER (" + MP_REGISTER_REMOTE_SERVER + ")"); protocolInputStream.setTimeout(timeout); answer = protocolInputStream.read(); } if (debug) log.debug("Protocol.registerRemoteServerSocket(): read: " + (answer == MP_TRUE ? "true" : "false")); if (answer == MP_FALSE) throw new IOException("unable to register remote socket"); } /** * */ public void unregisterRemoteServerSocket() { log.debug("unregisterRemoteServerSocket()"); try { synchronized (protocolOutputStream) { protocolOutputStream.write(MP_UNREGISTER_REMOTE_SERVER); } if (debug) log.debug("Protocol.disconnect(): wrote: UNREGISTER_REMOTE_SERVER (" + MP_UNREGISTER_REMOTE_SERVER + ")"); } catch (IOException ignored) { log.error("Protocol.unregisterRemoteServerSocket(): unable to send UNREGISTER_REMOTE_SERVER"); } } public boolean requestManagerShutdown(int timeout) throws IOException { int b; synchronized (protocolInputStream) { synchronized (protocolOutputStream) { protocolOutputStream.write(MP_REQUEST_MANAGER_SHUTDOWN, OutputMultiplexor.BRACKETS_ALL); } if (debug) log.debug("Protocol.requestManagerShutdown(): wrote: REQUEST_MANAGER_SHUTDOWN (" + MP_REQUEST_MANAGER_SHUTDOWN + ")"); protocolInputStream.setTimeout(timeout); b = protocolInputStream.read(); } boolean answer = (b == MP_TRUE) ? true : false; if (debug) log.debug("Protocol.requestManagerShutdown(): read: " + answer); return answer; } /** * */ static class BackChannelThread extends StoppableThread { VirtualSelector virtualSelector; VirtualSocket socket; public BackChannelThread(VirtualSelector virtualSelector) { this.virtualSelector = virtualSelector; } /** * */ public void shutdown() { log.debug("back channel thread: beginning shut down"); super.shutdown(); virtualSelector.close(); interrupt(); } /** * */ protected void doInit() { log.debug("back channel thread starting"); } /** * */ protected void doRun() { MultiplexingManager manager = null; Map streamMap; int messageType; int port; int answer; // while (null == (streamMap = virtualSelector.select()) && running) // log.debug("select() loop"); // // if (!running) // return; streamMap = virtualSelector.select(); if (streamMap == null) return; Iterator it = streamMap.keySet().iterator(); while (it.hasNext()) { try { MultiplexingInputStream is = (MultiplexingInputStream) it.next(); if (is.available() == 0) { log.debug("available == 0"); virtualSelector.remove(is); continue; } manager = (MultiplexingManager) streamMap.get(is); if (manager == null) continue; OutputStream os = manager.getBackchannelOutputStream(); messageType = is.read(); log.debug("back channel thread: read message type: " + messageType); switch (messageType) { case MP_OUTPUT_SHUTDOWN: port = is.readInt(); if (log.isDebugEnabled()) log.debug("back channel thread: read OUTPUT_SHUTDOWN for port: " + port); socket = manager.getSocketByLocalPort(new SocketId(port)); if (socket == null) { log.info("back channel thread (OUTPUT_SHUTDOWN): unable to retrieve socket at port: " + port); } else { socket.handleRemoteOutputShutDown(); } break; case MP_DISCONNECT: port = is.readInt(); log.debug("back channel thread: read DISCONNECT for port: " + port); socket = manager.getSocketByLocalPort(new SocketId(port)); if (socket == null) { log.info("back channel thread (DISCONNECT): unable to retrieve socket at port: " + port); } else { socket.handleRemoteDisconnect(); } break; case MP_REGISTER_REMOTE_SERVER: // remote VirtualServerSocket is starting up log.debug("back channel thread: read REGISTER_REMOTE_SERVER"); answer = MP_TRUE; try { manager.registerRemoteServerSocket(); } catch (Exception e) { answer = MP_FALSE; log.info("back channel thread: unable to register remote server", e); } os.write(answer); break; case MP_UNREGISTER_REMOTE_SERVER: // remote VirtualServerSocket is shutting down log.debug("back channel thread: read UNREGISTER_REMOTE_SERVER"); manager.unRegisterRemoteServerSocket(); break; case MP_REQUEST_MANAGER_SHUTDOWN: // remote MultiplexingManager is shutting down log.debug("back channel thread: read REQUEST_MANAGER_SHUTDOWN"); answer = manager.respondToShutdownRequest() ? MP_TRUE : MP_FALSE; if (log.isDebugEnabled()) log.debug("back channel thread: writing " + answer); os.write(answer); break; default: log.error("unexpected message type in back channel thread: " + messageType); } } catch (InterruptedIOException e) { if (isRunning()) log.error("back channel thread: i/o interruption", e); else log.error("back channel thread: i/o interruption"); } catch (IOException e) { if (isRunning()) { log.error("back channel thread: i/o error: " + manager.getSocket().toString(), e); } else log.error("back channel thread: i/o error"); } } } /** * */ protected void doShutDown() { log.debug("back channel thread shutting down"); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/multiplex/.cvsignore0000644000175000017500000000016010430564100032703 0ustar twernertwernerlog4j.client_properties log4j.properties log4j.server_properties experimental log4j_client.xml log4j_server.xml libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/ClientInvoker.java0000644000175000017500000001044410567022732032320 0ustar twernertwerner/* * 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.remoting.transport; import org.jboss.remoting.ConnectionFailedException; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.Invoker; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.UnMarshaller; import javax.net.SocketFactory; import java.util.Map; import java.util.List; /** * Interface to be used for calling on all the different invoker types (LocalClientInvoker * and RemoteClientInvoker). * * @author Tom Elrod * @author Ovidiu Feodorov */ public interface ClientInvoker extends Invoker { /** * This should be set when want to override the default behavior of automatically getting a * suitable locator. This should be used want want to control what type of callbacks to receive * (pull or push). Set to null to poll for callback messages. This can also be used to receive * callbacks using another transport and subsystem, if desired. * * @return id for callback handler and locator combination. */ String addClientLocator(String sessionId, InvokerCallbackHandler callbackhandler, InvokerLocator locator); /** * Gets the client locator. This locator will be used by the server side * to make callbacks to the handler for this locator. */ InvokerLocator getClientLocator(String listenerId); /** * Gets list of AbstractInvoker.CallbackLocatorHolder containing listener id and locator */ List getClientLocators(String sessionId, InvokerCallbackHandler handler); /** * Gets SocketFactory used to connect to ServerInvoker. */ SocketFactory getSocketFactory(); /** * Sets the SocketFactory that will be used to connect to ServerInvoker. * * @param socketFactory */ void setSocketFactory(SocketFactory socketFactory); /** * Transport a request against a remote ServerInvoker. */ Object invoke(InvocationRequest in) throws Throwable; /** * Subclasses must provide this method to return true if their remote connection is connected and * false if disconnected. In some transports, such as SOAP, this method may always return true, * since the remote connectivity is done on demand and not kept persistent like other transports * (such as socket-based transport). * * @return boolean true if connected, false if not. */ boolean isConnected(); /** * Connect to the remote invoker. */ void connect() throws ConnectionFailedException; /** * Disconnect from the remote invokere. */ void disconnect(); void setMarshaller(Marshaller marshaller); Marshaller getMarshaller(); void setUnMarshaller(UnMarshaller unmarshaller); UnMarshaller getUnMarshaller(); void establishLease(String sessionID, Map configuration, long leasePeriod) throws Throwable; /** * Must behave as a noop if there's no active lease. */ void terminateLease(String sessionID, int disconnectTimeout); /** * @return the lease period (in ms) if the client has an active leasing mechanism with the server * or -1 otherwise. */ long getLeasePeriod(String sessionID); }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslservlet/0000755000175000017500000000000011632407051031077 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslservlet/TransportClientFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslservlet/TransportClie0000644000175000017500000000320010456070655033617 0ustar twernertwerner/* * 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.remoting.transport.sslservlet; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.ClientFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker; import java.io.IOException; import java.util.Map; /** * @author Tom Elrod */ public class TransportClientFactory implements ClientFactory { public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException { return new HTTPSClientInvoker(locator, config); } public boolean supportsSSL() { return true; } }././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslservlet/TransportServerFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/transport/sslservlet/TransportServ0000644000175000017500000000311210456070655033664 0ustar twernertwerner/* * 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.remoting.transport.sslservlet; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.ServerInvoker; import org.jboss.remoting.transport.ServerFactory; import org.jboss.remoting.transport.servlet.ServletServerInvoker; import java.util.Map; /** * @author Tom Elrod */ public class TransportServerFactory implements ServerFactory { public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) { return new ServletServerInvoker(locator, config); } public boolean supportsSSL() { return true; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/Lease.java0000644000175000017500000003327411247620321026541 0ustar twernertwerner/* * 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.remoting; import org.jboss.logging.Logger; import org.jboss.remoting.util.TimerUtil; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.TimerTask; /** * This class is used on the remoting server to maintain lease information * for remoting clients. Will generate callback to ConnectionListener interface * if determined that client no longer available. * * @author Tom Elrod */ public class Lease { private ConnectionNotifier notifier = null; private String clientSessionId = null; private long leasePeriod = -1; private String locatorURL = null; private Map requestPayload = null; private LeaseTimerTask leaseTimerTask = null; private long leaseWindow = -1; private long pingStart = -1; private Map clientLeases = null; private Object lock = new Object(); private String leasePingerId; private boolean stopped; private boolean leaseUpdated = false; private long lastUpdate; private boolean useClientConnectionIdentity; private static final Logger log = Logger.getLogger(Lease.class); private static final boolean isTraceEnabled = log.isTraceEnabled(); public Lease(String clientSessionId, long leasePeriod, String locatorurl, Map requestPayload, ConnectionNotifier notifier, Map clientLeases) { this.clientSessionId = clientSessionId; this.leasePeriod = leasePeriod; this.notifier = notifier; this.locatorURL = locatorurl; if(requestPayload != null) { this.requestPayload = (Map)requestPayload.get(ClientHolder.CLIENT_HOLDER_KEY); this.leasePingerId = (String) requestPayload.get(LeasePinger.LEASE_PINGER_ID); String s = (String) requestPayload.get(LeasePinger.TIME_STAMP); if (s != null) { this.lastUpdate = Long.valueOf(s).longValue(); this.useClientConnectionIdentity = true; if (isTraceEnabled) log.trace(this + " initialized with lastUpdate: " + lastUpdate); } if (isTraceEnabled) log.trace(this + " initialized with requestPayload: " + this.requestPayload); if (isTraceEnabled) log.trace("leasePingerId: " + leasePingerId); } this.leaseWindow = leasePeriod * 2; this.clientLeases = clientLeases; } public void startLease() { if(isTraceEnabled) { log.trace("Starting lease for client invoker (session id = " + clientSessionId + ") with lease window time of " + leaseWindow); } leaseTimerTask = new LeaseTimerTask(); TimerUtil.schedule(leaseTimerTask, leaseWindow); } public void updateLease(long leasePeriod, Map requestMap) { if(requestMap != null) { synchronized (lock) { if (useClientConnectionIdentity) { if (isTraceEnabled) log.trace(this + " requestMap: " + requestMap); long time = 0; String timeString = (String) requestMap.get(LeasePinger.TIME_STAMP); time = Long.valueOf(timeString).longValue(); if (isTraceEnabled) log.trace(this + " last update: " + lastUpdate + ", this update: " + time); if (time >= lastUpdate) { lastUpdate = time; doUpdate(requestMap); } else { if (isTraceEnabled) log.trace(this + " updating lease but not client list"); leaseUpdated = true; } } else { doUpdate(requestMap); } } } else { if (isTraceEnabled) log.trace(this + " requestPayload == null"); } } public void updateLease(long leasePeriod) { leaseUpdated = true; if (leasePeriod != this.leasePeriod) { this.leasePeriod = leasePeriod; this.leaseWindow = leasePeriod * 2; stopLease(); startLease(); if(isTraceEnabled) { log.trace("Lease for client invoker (session id = " + clientSessionId + ") updated with new lease window of " + leaseWindow + ". Resetting timer."); } } else { if (pingStart != -1) { long pingDuration = System.currentTimeMillis() - pingStart; if (pingDuration > 0.75 * leaseWindow) { leaseWindow = pingDuration * 2; stopLease(); leaseTimerTask = new LeaseTimerTask(); TimerUtil.schedule(leaseTimerTask, leaseWindow); } } } pingStart = System.currentTimeMillis(); } public void terminateLease(String sessionId) { // is this terminate for all clients if (clientSessionId.equals(sessionId)) { if(isTraceEnabled) { log.trace(this + " Terminating lease group for session id " + sessionId); } stopLease(); // should be ok to call this will null as all the client should have // already been disconnected and there been a notification for each // of these client disconnections (which would remove the client from // the lease, thus leaving the collection empty notifyClientTermination(null); } else { if(isTraceEnabled) { log.trace(this + " Terminating individual lease for session id " + sessionId); } notifyClientTermination(sessionId); } } public void terminateLeaseUponFailure(String sessionId) { // is this terminate for all clients if (clientSessionId.equals(sessionId)) { if(isTraceEnabled) { log.trace(this + " Terminating lease group for session id " + sessionId); } stopLease(); // should be ok to call this will null as all the client should have // already been disconnected and there been a notification for each // of these client disconnections (which would remove the client from // the lease, thus leaving the collection empty notifyClientLost(); } else { if(true) { log.warn(this + " Expected invoker session id: " + sessionId); } notifyClientLost(); } } public String toString() { String hash = Integer.toHexString(System.identityHashCode(this)); return "Lease[" + hash + ":" + clientSessionId + ":" + leasePingerId + "]"; } private void notifyClientTermination(String sessionId) { Map localRequestPayload = null; synchronized (lock) { if (requestPayload != null) { localRequestPayload = new HashMap(requestPayload); if (sessionId != null) { requestPayload.remove(sessionId); } } } if (localRequestPayload != null) { // should notify for one client or all? if (sessionId != null) { synchronized (lock) { if (stopped) { if (isTraceEnabled) log.trace(this + " already stopped"); return; } } Object clientHolderObj = localRequestPayload.get(sessionId); if (clientHolderObj != null && clientHolderObj instanceof ClientHolder) { ClientHolder clientHolder = (ClientHolder) clientHolderObj; notifier.connectionTerminated(locatorURL, clientHolder.getSessionId(), clientHolder.getConfig()); if(isTraceEnabled) { log.trace(this + " Notified connection listener of lease termination due to disconnect from client (client session id = " + clientHolder.getSessionId()); } } } else { synchronized (lock) { if (stopped) { if (isTraceEnabled) log.trace(this + " already stopped"); return; } stopped = true; } // loop through and notify for all clients Collection clientHoldersCol = localRequestPayload.values(); if (clientHoldersCol != null && clientHoldersCol.size() > 0) { Iterator itr = clientHoldersCol.iterator(); while (itr.hasNext()) { Object val = itr.next(); if (val != null && val instanceof ClientHolder) { ClientHolder clientHolder = (ClientHolder) val; notifier.connectionTerminated(locatorURL, clientHolder.getSessionId(), clientHolder.getConfig()); if(isTraceEnabled) { log.trace(this + " Notified connection lif (isTraceEnabled) log.tracef lease termination due to disconnect from client (client session id = " + clientHolder.getSessionId()); } } } } } } else { log.warn(this + " Tried to terminate lease for session id " + sessionId + ", but no collection of clients have been set."); } } private void notifyClientLost() { Map localRequestPayload = null; synchronized (lock) { if (stopped) { if (isTraceEnabled) log.trace(this + " already stopped"); return; } stopped = true; if (requestPayload != null) { localRequestPayload = new HashMap(requestPayload); } } if (localRequestPayload != null) { // loop through and notify for all clients Collection clientHoldersCol = localRequestPayload.values(); if (isTraceEnabled) log.trace(this + " notifying listeners about " + clientHoldersCol.size() + " expired client(s)"); if (clientHoldersCol != null && clientHoldersCol.size() > 0) { Iterator itr = clientHoldersCol.iterator(); while (itr.hasNext()) { Object val = itr.next(); if (val != null && val instanceof ClientHolder) { ClientHolder clientHolder = (ClientHolder) val; notifier.connectionLost(locatorURL, clientHolder.getSessionId(), clientHolder.getConfig()); if(isTraceEnabled) { log.trace(this + " Notified connection listener of lease expired due to lost connection from client (client session id = " + clientHolder.getSessionId()); } } } } } else { if (isTraceEnabled) log.trace(this + " requestPayload == null, calling ConnectionNotifier.connectionLost()"); notifier.connectionLost(locatorURL, clientSessionId, null); } } protected String getLeasePingerId() { return leasePingerId; } private void stopLease() { leaseTimerTask.cancel(); } private void doUpdate(Map requestMap) { this.requestPayload = (Map)requestMap.get(ClientHolder.CLIENT_HOLDER_KEY); if (isTraceEnabled) { log.trace(this + " updating: new Client list:"); Collection clientHoldersCol = requestPayload.values(); Iterator itr = clientHoldersCol.iterator(); while (itr.hasNext()) { Object val = itr.next(); if (val != null && val instanceof ClientHolder) { ClientHolder clientHolder = (ClientHolder) val; log.trace(leasePingerId + ": " + clientHolder.getSessionId()); } } } updateLease(leasePeriod); } private class LeaseTimerTask extends TimerTask { /** * The action to be performed by this timer task. */ public void run() { if (leaseUpdated) { leaseUpdated = false; } else { try { if (isTraceEnabled) log.trace(Lease.this + " did not receive ping: " + clientSessionId); stopLease(); notifyClientLost(); if (clientLeases != null) { clientLeases.remove(clientSessionId); } if (isTraceEnabled) log.trace(Lease.this + " removed lease:" + clientSessionId); } catch (Throwable thr) { log.error("Error terminating client lease and sending notification of lost client.", thr); } } } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ConnectionFailedException.java0000644000175000017500000000313710355142433032570 0ustar twernertwerner/* * 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.remoting; /** * ConnectionFailedException is a RuntimeException that is raised when a remote connection * fails. * * @author Jeff Haynie * @version $Revision: 566 $ */ public class ConnectionFailedException extends RuntimeException { /** * @since 4.0.1 */ static final long serialVersionUID = 1353105726630086615L; public ConnectionFailedException() { super(); } public ConnectionFailedException(String msg) { super(msg); } public ConnectionFailedException(String msg, Exception ex) { super(msg, ex); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ConnectionNotifier.java0000644000175000017500000000567311203143765031315 0ustar twernertwernerpackage org.jboss.remoting; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.ArrayList; import java.util.Map; import org.jboss.logging.Logger; /** * This class is used on the server side to notify any connection listeners when a client connection * has been terminated (either by loss of lease or by normal disconnect). * * @author Tom Elrod */ public class ConnectionNotifier { private List listeners = Collections.synchronizedList(new ArrayList()); private static final Logger log = Logger.getLogger(ConnectionNotifier.class); public void addListener(ConnectionListener listener) { listeners.add(listener); } public void addListenerFirst(ConnectionListener listener) { listeners.add(0, listener); } public void removeListener(ConnectionListener listener) { listeners.remove(listener); } public int size() { return listeners.size(); } public void connectionLost(String locatorurl, String clientSessionId, Map requestPayload) { try { log.debug(this + " Server connection lost to client (session id = " + clientSessionId); Client client = new Client(new InvokerLocator(locatorurl), requestPayload); client.setSessionId(clientSessionId); ArrayList localListeners = null; synchronized (listeners) { localListeners = new ArrayList(listeners); } Iterator it = localListeners.iterator(); while (it.hasNext()) { ConnectionListener listener = (ConnectionListener) it.next(); listener.handleConnectionException(null, client); log.debug(this + " notified " + listener + " of connection lost to: " + clientSessionId); } } catch(Exception e) { log.error("Error notifying connection listeners of lost client connection.", e); } } public void connectionTerminated(String locatorURL, String clientSessionId, Map requestPayload) { try { if(log.isTraceEnabled()) { log.trace(this + " Client disconnected (session id = " + clientSessionId); } Client client = new Client(new InvokerLocator(locatorURL), requestPayload); client.setSessionId(clientSessionId); ClientDisconnectedException ex = new ClientDisconnectedException(); ArrayList localListeners = null; synchronized (listeners) { localListeners = new ArrayList(listeners); } Iterator it = localListeners.iterator(); while (it.hasNext()) { ((ConnectionListener) it.next()).handleConnectionException(ex, client); } } catch(Exception e) { log.error("Error notifying connection listeners of disconnected client connection.", e); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/stream/0000755000175000017500000000000011632407044026132 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/stream/StreamServer.java0000644000175000017500000003204711422064756031433 0ustar twernertwerner/* * 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.remoting.stream; import org.jboss.logging.Logger; 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.util.SecurityUtility; import javax.management.MBeanServer; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; /** * This is a helper class that runs internal to remoting on the * client side. It contains a reference to a local input stream * and creates a remoting server to receive calls from a target * remoting server (via calls from a StreamHandler initiated by a * server invoker handler). *

          * NOTE: That once this class receives the close() method called * from the server, it will also stop and destroy the internal * remoting server, since is assumed there will be no more callbacks * (since the stream itself is closed). * * @author Tom Elrod */ public class StreamServer { private InputStream streamSource = null; private String transport = "socket"; private String host = "localhost"; private int port = 5405; private Connector connector = null; private boolean internalConnector = true; private static final Logger log = Logger.getLogger(StreamServer.class); public static final String STREAM_TRANSPORT_KEY = "remoting.stream.transport"; public static final String STREAM_HOST_KEY = "remoting.stream.host"; public static final String STREAM_PORT_KEY = "remoting.stream.port"; private static final InetAddress LOCAL_HOST; static { try { LOCAL_HOST = (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } }); } catch (PrivilegedActionException e) { log.debug(StreamServer.class.getName() + " unable to get local host address", e.getCause()); throw new ExceptionInInitializerError(e.getCause()); } catch (SecurityException e) { log.debug(StreamServer.class.getName() + " unable to get local host address", e); throw e; } } /** * Creates the server wrapped around the specified input stream. * This will create the remoting server as well. * * @param stream * @throws Exception */ public StreamServer(InputStream stream) throws Exception { this.streamSource = stream; String locatorURI = getLocatorURI(); setupServer(locatorURI); } public StreamServer(InputStream stream, InvokerLocator locator) throws Exception { this.streamSource = stream; setupServer(locator.getLocatorURI()); } public StreamServer(InputStream stream, Connector connector) throws Exception { this.streamSource = stream; this.connector = connector; if(connector != null) { if(!connector.isStarted()) { throw new IllegalStateException("Connector (" + connector + ") passed to act as stream server has not been started."); } ServerInvocationHandler invocationHandler = new Handler(connector); connector.addInvocationHandler("stream", invocationHandler); internalConnector = false; } else { throw new NullPointerException("Connector passed to act as stream server can not be null."); } } private String getLocatorURI() throws IOException { // check for system properties for locator values transport = getSystemProperty(STREAM_TRANSPORT_KEY, transport); try { host = getLocalHostName(); } catch(UnknownHostException e) { try { InetAddress localAddress = getLocalHost(); host = localAddress.getHostAddress(); } catch(UnknownHostException e1) { log.error("Stream server could not determine local host or address."); } } host = getSystemProperty(STREAM_HOST_KEY, host); String defaultPort = "" + PortUtil.findFreePort(host); String sPort = getSystemProperty(STREAM_PORT_KEY, defaultPort); try { port = Integer.parseInt(sPort); } catch(NumberFormatException e) { log.error("Stream server could not convert specified port " + sPort + " to a number."); } return transport + "://" + host + ":" + port; } /** * Gets the locator to call back on this server to get the inputstream data. * * @return * @throws Exception */ public String getInvokerLocator() throws Exception { String locator = null; if(connector != null) { locator = connector.getInvokerLocator(); } return locator; } public void setupServer(String locatorURI) throws Exception { InvokerLocator locator = new InvokerLocator(locatorURI); connector = new Connector(); connector.setInvokerLocator(locator.getLocatorURI()); connector.create(); ServerInvocationHandler invocationHandler = new Handler(connector); connector.addInvocationHandler("stream", invocationHandler); connector.start(); } /** * Handler for accepting method calls on the input stream and perform the coresponding * method call on the original input stream and returning the data. */ public class Handler implements ServerInvocationHandler { private Connector connector = null; public Handler(Connector connector) { this.connector = connector; } public Object invoke(InvocationRequest invocation) throws Throwable { Object obj = invocation.getParameter(); // will expect the parameter to ALWAYS be of type StreamCallPaylod if(obj instanceof StreamCallPayload) { StreamCallPayload payload = (StreamCallPayload) obj; String method = payload.getMethod(); if(StreamHandler.READ.equals(method)) { int i = streamSource.read(); return new Integer(i); } else if(StreamHandler.AVAILABLE.equals(method)) { int i = streamSource.available(); return new Integer(i); } else if(StreamHandler.CLOSE.equals(method)) { streamSource.close(); if(connector != null && internalConnector) { connector.stop(); connector.destroy(); } } else if(StreamHandler.RESET.equals(method)) { streamSource.reset(); } else if(StreamHandler.MARKSUPPORTED.equals(method)) { boolean b = streamSource.markSupported(); return new Boolean(b); } else if(StreamHandler.MARKREADLIMIT.equals(method)) { Object[] param = payload.getParams(); Integer intr = (Integer) param[0]; int readLimit = intr.intValue(); streamSource.mark(readLimit); } else if(StreamHandler.SKIP.equals(method)) { Object[] param = payload.getParams(); Long lg = (Long) param[0]; long n = lg.longValue(); long ret = streamSource.skip(n); return new Long(ret); } else if(StreamHandler.READBYTEARRAY.equals(method)) { Object[] param = payload.getParams(); byte[] byteParam = (byte[]) param[0]; int i = streamSource.read(byteParam); StreamCallPayload ret = new StreamCallPayload(StreamHandler.READBYTEARRAY); ret.setParams(new Object[]{byteParam, new Integer(i)}); return ret; } else { throw new Exception("Unsupported method call - " + method); } } else { log.error("Can not process invocation request because is not of type StreamCallPayload."); throw new Exception("Invalid payload type. Must be of type StreamCallPayload."); } return null; } /** * 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 } } static private String getSystemProperty(final String name, final String defaultValue) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name, defaultValue); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name, defaultValue); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private InetAddress getLocalHost() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return doGetLocalHost(); } try { return (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { return doGetLocalHost(); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } static private InetAddress doGetLocalHost() throws UnknownHostException { if (LOCAL_HOST != null) { return LOCAL_HOST; } try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } static private String getLocalHostName() throws UnknownHostException { if (SecurityUtility.skipAccessControl()) { return doGetLocalHost().getHostName(); } try { return (String) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { return doGetLocalHost().getHostName(); } }); } catch (PrivilegedActionException e) { throw (UnknownHostException) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/stream/StreamHandler.java0000644000175000017500000005106210766132065031537 0ustar twernertwerner/* * 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.remoting.stream; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import java.io.IOException; import java.io.InputStream; /** * This is the server side proxy back to the orginal stream * on the client side. It implements InputStream, so can be * passed and acted on by the server handler as a regular InputStream * type. For all the InputStream methods, it should behave EXACTLY * like a local InputStream with the one exception being that it * will sometimes throw IOExceptions based on network exceptions * or in the case when the method does not throw an IOException, throwing * a RuntimeException if network problem (however none of the method * signatures are changed). *

          * Internally, it will use remoting to callback to the client. * * @author Tom Elrod */ public class StreamHandler extends InputStream //implements InvocationHandler { private InvokerLocator streamServerLocator = null; private Client streamClient = null; private static final Logger log = Logger.getLogger(StreamHandler.class); // The remoting invocation methods the match the InputStream metnhods. public static final String READ = "read()"; public static final String AVAILABLE = "available()"; public static final String CLOSE = "close()"; public static final String RESET = "reset()"; public static final String MARKSUPPORTED = "markSupported()"; public static final String MARKREADLIMIT = "mark(int readlimit)"; public static final String SKIP = "skip(long n)"; public static final String READBYTEARRAY = "read(byte b[])"; public static final String READOFFSET = "read(byte b[], int off, int len)"; /** * Constructor requiring the locator url back to the client's * StreamServer connector (actually the connector's server invoker). * * @param locatorURL * @throws Exception */ //private StreamHandler(String locatorURL) throws Exception public StreamHandler(String locatorURL) throws Exception { streamServerLocator = new InvokerLocator(locatorURL); streamClient = new Client(streamServerLocator); streamClient.connect(); } /** * Returns the number of bytes that can be read (or skipped over) from * this input stream without blocking by the next caller of a method for * this input stream. The next caller might be the same thread or or * another thread. *

          *

          The available method for class InputStream * always returns 0. *

          *

          This method should be overridden by subclasses. * * @return the number of bytes that can be read from this input stream * without blocking. * @throws java.io.IOException if an I/O error occurs. */ public int available() throws IOException { int readInt = 0; try { Integer retInt = (Integer) streamClient.invoke(new StreamCallPayload(AVAILABLE)); if(retInt != null) { readInt = retInt.intValue(); } } catch(Throwable throwable) { log.debug("Error getting available from client stream.", throwable); throw new IOException(throwable.getMessage()); } return readInt; } /** * Closes this input stream and releases any system resources associated * with the stream. *

          *

          The close method of InputStream does * nothing. * * @throws java.io.IOException if an I/O error occurs. */ public void close() throws IOException { try { streamClient.invoke(new StreamCallPayload(CLOSE)); } catch(Throwable throwable) { log.debug("Error closing client stream.", throwable); throw new IOException(throwable.getMessage()); } } /** * Repositions this stream to the position at the time the * mark method was last called on this input stream. *

          *

          The general contract of reset is: *

          *

            *

            *

          • If the method markSupported returns * true, then: *

            *

            • If the method mark has not been called since * the stream was created, or the number of bytes read from the stream * since mark was last called is larger than the argument * to mark at that last call, then an * IOException might be thrown. *

              *

            • If such an IOException is not thrown, then the * stream is reset to a state such that all the bytes read since the * most recent call to mark (or since the start of the * file, if mark has not been called) will be resupplied * to subsequent callers of the read method, followed by * any bytes that otherwise would have been the next input data as of * the time of the call to reset.
            *

            *

          • If the method markSupported returns * false, then: *

            *

            • The call to reset may throw an * IOException. *

              *

            • If an IOException is not thrown, then the stream * is reset to a fixed state that depends on the particular type of the * input stream and how it was created. The bytes that will be supplied * to subsequent callers of the read method depend on the * particular type of the input stream.
          *

          *

          The method reset for class InputStream * does nothing and always throws an IOException. * * @throws java.io.IOException if this stream has not been marked or if the * mark has been invalidated. * @see java.io.InputStream#mark(int) * @see java.io.IOException */ public synchronized void reset() throws IOException { try { streamClient.invoke(new StreamCallPayload(RESET)); } catch(Throwable throwable) { log.debug("Error reseting client stream.", throwable); throw new IOException(throwable.getMessage()); } } /** * Tests if this input stream supports the mark and * reset methods. Whether or not mark and * reset are supported is an invariant property of a * particular input stream instance. The markSupported method * of InputStream returns false. * * @return true if this stream instance supports the mark * and reset methods; false otherwise. * @see java.io.InputStream#mark(int) * @see java.io.InputStream#reset() */ public boolean markSupported() { boolean supported = false; try { Boolean bSupported = (Boolean) streamClient.invoke(new StreamCallPayload(MARKSUPPORTED)); if(bSupported != null) { supported = bSupported.booleanValue(); } } catch(Throwable throwable) { log.debug("Error getting markSupported from client stream.", throwable); throw new RuntimeException(throwable.getMessage(), throwable); } return supported; } /** * Marks the current position in this input stream. A subsequent call to * the reset method repositions this stream at the last marked * position so that subsequent reads re-read the same bytes. *

          *

          The readlimit arguments tells this input stream to * allow that many bytes to be read before the mark position gets * invalidated. *

          *

          The general contract of mark is that, if the method * markSupported returns true, the stream somehow * remembers all the bytes read after the call to mark and * stands ready to supply those same bytes again if and whenever the method * reset is called. However, the stream is not required to * remember any data at all if more than readlimit bytes are * read from the stream before reset is called. *

          *

          The mark method of InputStream does * nothing. * * @param readlimit the maximum limit of bytes that can be read before * the mark position becomes invalid. * @see java.io.InputStream#reset() */ public synchronized void mark(int readlimit) { try { StreamCallPayload payload = new StreamCallPayload(MARKREADLIMIT); payload.setParams(new Object[]{new Integer(readlimit)}); streamClient.invoke(payload); } catch(Throwable throwable) { log.debug("Error marking with read limit on client stream.", throwable); throw new RuntimeException(throwable.getMessage(), throwable); } } /** * Skips over and discards n bytes of data from this input * stream. The skip method may, for a variety of reasons, end * up skipping over some smaller number of bytes, possibly 0. * This may result from any of a number of conditions; reaching end of file * before n bytes have been skipped is only one possibility. * The actual number of bytes skipped is returned. If n is * negative, no bytes are skipped. *

          *

          The skip method of InputStream creates a * byte array and then repeatedly reads into it until n bytes * have been read or the end of the stream has been reached. Subclasses are * encouraged to provide a more efficient implementation of this method. * * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. * @throws java.io.IOException if an I/O error occurs. */ public long skip(long n) throws IOException { long numSkipped = -1; try { StreamCallPayload payload = new StreamCallPayload(SKIP); payload.setParams(new Object[]{new Long(n)}); Long ret = (Long) streamClient.invoke(payload); if(ret != null) { numSkipped = ret.longValue(); } } catch(Throwable throwable) { log.debug("Error skipping on client stream.", throwable); throw new IOException(throwable.getMessage()); } return numSkipped; } /** * Reads some number of bytes from the input stream and stores them into * the buffer array b. The number of bytes actually read is * returned as an integer. This method blocks until input data is * available, end of file is detected, or an exception is thrown. *

          *

          If b is null, a * NullPointerException is thrown. If the length of * b is zero, then no bytes are read and 0 is * returned; otherwise, there is an attempt to read at least one byte. If * no byte is available because the stream is at end of file, the value * -1 is returned; otherwise, at least one byte is read and * stored into b. *

          *

          The first byte read is stored into element b[0], the * next one into b[1], and so on. The number of bytes read is, * at most, equal to the length of b. Let k be the * number of bytes actually read; these bytes will be stored in elements * b[0] through b[k-1], * leaving elements b[k] through * b[b.length-1] unaffected. *

          *

          If the first byte cannot be read for any reason other than end of * file, then an IOException is thrown. In particular, an * IOException is thrown if the input stream has been closed. *

          *

          The read(b) method for class InputStream * has the same effect as:

           read(b, 0, b.length) 
          * * @param b the buffer into which the data is read. * @return the total number of bytes read into the buffer, or * -1 is there is no more data because the end of * the stream has been reached. * @throws java.io.IOException if an I/O error occurs. * @throws NullPointerException if b is null. * @see java.io.InputStream#read(byte[], int, int) */ public int read(byte b[]) throws IOException { if(b == null) { throw new NullPointerException("can not read for a null byte array."); } else { if(b.length == 0) { return 0; } } int retByte = -1; try { StreamCallPayload payload = new StreamCallPayload(READBYTEARRAY); payload.setParams(new Object[]{b}); StreamCallPayload ret = (StreamCallPayload) streamClient.invoke(payload); if(ret != null) { Object[] retVals = ret.getParams(); byte[] retBytes = (byte[]) retVals[0]; Integer retInt = (Integer) retVals[1]; retByte = retInt.intValue(); if(retByte != -1) { System.arraycopy(retBytes, 0, b, 0, retByte); } } } catch(Throwable throwable) { log.debug("Error reading from client stream.", throwable); throw new IOException(throwable.getMessage()); } return retByte; } /** * Reads up to len bytes of data from the input stream into * an array of bytes. An attempt is made to read as many as * len bytes, but a smaller number may be read, possibly * zero. The number of bytes actually read is returned as an integer. *

          *

          This method blocks until input data is available, end of file is * detected, or an exception is thrown. *

          *

          If b is null, a * NullPointerException is thrown. *

          *

          If off is negative, or len is negative, or * off+len is greater than the length of the array * b, then an IndexOutOfBoundsException is * thrown. *

          *

          If len is zero, then no bytes are read and * 0 is returned; otherwise, there is an attempt to read at * least one byte. If no byte is available because the stream is at end of * file, the value -1 is returned; otherwise, at least one * byte is read and stored into b. *

          *

          The first byte read is stored into element b[off], the * next one into b[off+1], and so on. The number of bytes read * is, at most, equal to len. Let k be the number of * bytes actually read; these bytes will be stored in elements * b[off] through b[off+k-1], * leaving elements b[off+k] through * b[off+len-1] unaffected. *

          *

          In every case, elements b[0] through * b[off] and elements b[off+len] through * b[b.length-1] are unaffected. *

          *

          If the first byte cannot be read for any reason other than end of * file, then an IOException is thrown. In particular, an * IOException is thrown if the input stream has been closed. *

          *

          The read(b, off, len) method * for class InputStream simply calls the method * read() repeatedly. If the first such call results in an * IOException, that exception is returned from the call to * the read(b, off, len) method. If * any subsequent call to read() results in a * IOException, the exception is caught and treated as if it * were end of file; the bytes read up to that point are stored into * b and the number of bytes read before the exception * occurred is returned. Subclasses are encouraged to provide a more * efficient implementation of this method. * * @param b the buffer into which the data is read. * @param off the start offset in array b * at which the data is written. * @param len the maximum number of bytes to read. * @return the total number of bytes read into the buffer, or * -1 if there is no more data because the end of * the stream has been reached. * @throws java.io.IOException if an I/O error occurs. * @throws NullPointerException if b is null. * @see java.io.InputStream#read() */ public int read(byte b[], int off, int len) throws IOException { if(b == null) { throw new NullPointerException("can not read for a null byte array."); } else { if(b.length == 0) { return 0; } else { if(off < 0 || len < 0 || off + len > b.length) { throw new IndexOutOfBoundsException("Either off or len is negative or off+len is greater than length of b."); } if(len == 0) { return 0; } } } int retByte = -1; try { byte[] payloadArray = new byte[len]; StreamCallPayload payload = new StreamCallPayload(READBYTEARRAY); payload.setParams(new Object[]{payloadArray}); StreamCallPayload ret = (StreamCallPayload) streamClient.invoke(payload); if(ret != null) { Object[] retVals = ret.getParams(); byte[] retBytes = (byte[]) retVals[0]; Integer retInt = (Integer) retVals[1]; retByte = retInt.intValue(); if(retByte != -1) { System.arraycopy(retBytes, 0, b, off, retByte); } } } catch(Throwable throwable) { log.debug("Error reading with offset from client stream.", throwable); throw new IOException(throwable.getMessage()); } return retByte; } /** * Reads the next byte of data from the input stream. The value byte is * returned as an int in the range 0 to * 255. If no byte is available because the end of the stream * has been reached, the value -1 is returned. This method * blocks until input data is available, the end of the stream is detected, * or an exception is thrown. *

          *

          A subclass must provide an implementation of this method. * * @return the next byte of data, or -1 if the end of the * stream is reached. * @throws java.io.IOException if an I/O error occurs. */ public int read() throws IOException { int readInt = -1; try { Integer retInt = (Integer) streamClient.invoke(new StreamCallPayload(READ)); if(retInt != null) { readInt = retInt.intValue(); } } catch(Throwable throwable) { log.debug("Error reading from client stream.", throwable); throw new IOException(throwable.getMessage()); } return readInt; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/stream/StreamCallPayload.java0000644000175000017500000000456310355142433032345 0ustar twernertwerner/* * 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.remoting.stream; import java.io.Serializable; /** * The StreamCallPayload is used when making calls from the server * to the client to read from the original input stream. * It will contain the method name being called from the server side (i.e. available(), read(), etc.) * along with any parameters for the respective method. * * @author Tom Elrod */ public class StreamCallPayload implements Serializable { static final long serialVersionUID = 3243358524048714566L; private String method = null; private Object[] paramArray = null; /** * Constructor which requires the name of the method to call on the * the original stream. * * @param methodCallName */ public StreamCallPayload(String methodCallName) { this.method = methodCallName; } /** * Gets the method to call on the original stream. * * @return */ public String getMethod() { return method; } /** * Sets the params for the method to call on the * stream. For example, the Integer for markSupported(int supported). * * @param params */ public void setParams(Object[] params) { this.paramArray = params; } /** * Gets the params for the method to call on the stream. * * @return */ public Object[] getParams() { return this.paramArray; } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/stream/StreamInvocationHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/stream/StreamInvocationHandler.jav0000644000175000017500000000366710426271750033436 0ustar twernertwerner/* * 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.remoting.stream; import org.jboss.remoting.InvocationRequest; import org.jboss.remoting.ServerInvocationHandler; import java.io.InputStream; /** * This interface is intended for those handlers that expect to * receive calls from clients where a InputStream will be passed. * * @author Tom Elrod */ public interface StreamInvocationHandler extends ServerInvocationHandler { /** * Will receive an input stream, which is actually a proxy back * to the original stream on the client's vm. This stream can * be acted upon as though it was a local input stream. * When finished reading from the stream, it MUST be closed, or * will remain open on the client side. * * @param stream stream proxy to client's original stream * @param param the payload associated with the invocation */ public Object handleStream(InputStream stream, InvocationRequest param) throws Throwable; }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ServerConfiguration.java0000644000175000017500000000674411171274424031515 0ustar twernertwerner/* * 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.remoting; import java.util.HashMap; import java.util.Map; /** * ServerConfiguration can hold all parameters used to configure an * org.jboss.remoting.transport.Connector. * * Though it can be used programmatically, it is primarily meant to be used * as a replacement for the xml element currently used for external * configuration of a Connector. In particular, it is meant to be constructed * by the microcontainer from a jboss-beans.xml file and injected into the * Connector. * * For an example of the use of ServerConfiguration with the microcontainer, * see the configuration file remoting-jboss-beans.xml in the server/default/deploy * directory of the JBoss Application Server 5.0.0. * * @author Ron Sigal * @version $Revision: 5046 $ *

          * Copyright Oct 13, 2007 *

          */ public class ServerConfiguration { /** * transport to be used by server. */ private String transport; /** * Parameters that will go into InvokerLocator. *

          * Values MUST be of String type. */ private Map invokerLocatorParameters = new HashMap(); /** * Parameters that will be used locally by the server and will not go * into InvokerLocator. *

          * Values may be of any type. */ private Map serverParameters = new HashMap(); /** * ServerInvocationHandlers. The key is used as the subsystem name. * It may also be a comma separated list of subsystem names. */ private Map invocationHandlers = new HashMap(); public ServerConfiguration(String transport) { this.transport = transport; } public ServerConfiguration() { } public Map getInvocationHandlers() { return invocationHandlers; } public void setInvocationHandlers(Map invocationHandlers) { this.invocationHandlers = invocationHandlers; } public Map getInvokerLocatorParameters() { return invokerLocatorParameters; } public void setInvokerLocatorParameters(Map invokerLocatorParameters) { this.invokerLocatorParameters.putAll(invokerLocatorParameters); } public Map getServerParameters() { return serverParameters; } public void setServerParameters(Map serverParameters) { this.serverParameters.putAll(serverParameters); } public String getTransport() { return transport; } public void setTransport(String transport) { this.transport = transport; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/0000755000175000017500000000000011632407045027520 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/SocketCreationListener.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/SocketCreationListen0000644000175000017500000000313510553256471033547 0ustar twernertwerner/* * 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.remoting.socketfactory; import java.io.IOException; import java.net.Socket; /** * Interface for a listener that is called when a socket is created. * * @author Ron Sigal * @version $Revision: 1866 $ *

          * Copyright Jan 10, 2007 *

          */ public interface SocketCreationListener { /** * Called when a socket has been created. * * @param socket socket that has been created * @param source SocketFactory or ServerSocket that created the socket * @throws IOException */ void socketCreated(Socket socket, Object source) throws IOException; } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/SocketFactoryWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/SocketFactoryWrapper0000644000175000017500000000247110553064070033566 0ustar twernertwerner/* * 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.remoting.socketfactory; import javax.net.SocketFactory; /** * @author Ron Sigal * @version $Revision: 1827 $ *

          * Copyright Jan 13, 2007 *

          */ public interface SocketFactoryWrapper { SocketFactory getSocketFactory(); void setSocketFactory(SocketFactory factory); } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/ServerSocketFactoryWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/ServerSocketFactoryW0000644000175000017500000000253510553064070033544 0ustar twernertwerner/* * 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.remoting.socketfactory; import javax.net.ServerSocketFactory; /** * @author Ron Sigal * @version $Revision: 1827 $ *

          * Copyright Jan 13, 2007 *

          */ public interface ServerSocketFactoryWrapper { ServerSocketFactory getServerSocketFactory(); void setServerSocketFactory(ServerSocketFactory factory); } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/CreationListenerSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/CreationListenerSock0000644000175000017500000001151410553256471033545 0ustar twernertwerner/* * 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.remoting.socketfactory; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException; import javax.net.SocketFactory; import javax.net.ssl.SSLSocketFactory; /** * A CreationListenerSocketFactory wraps a SocketFactory and notifies a listener * of the creation of a Socket before returning the socket. * * @author Ron Sigal * @version $Revision: 1866 $ *

          * Copyright Jan 10, 2007 *

          */ public class CreationListenerSocketFactory extends SSLSocketFactory implements SocketFactoryWrapper, Serializable { private static final long serialVersionUID = 1210774093889434553L; private SocketFactory factory; private SocketCreationListener listener; public CreationListenerSocketFactory(SocketCreationListener listener) { this(SocketFactory.getDefault(), listener); } public CreationListenerSocketFactory(SocketFactory factory, SocketCreationListener listener) { this.factory = factory; this.listener = listener; } public SocketFactory getFactory() { return factory; } public SocketCreationListener getListener() { return listener; } public void setFactory(SocketFactory factory) { this.factory = factory; } public void setListener(SocketCreationListener listener) { this.listener = listener; } public Socket createSocket() throws IOException { checkFactory(); Socket socket = factory.createSocket(); listener.socketCreated(socket, factory); return socket; } public Socket createSocket(String host, int port) throws IOException, UnknownHostException { checkFactory(); Socket socket = factory.createSocket(host, port); listener.socketCreated(socket, factory); return socket; } public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort) throws IOException, UnknownHostException { checkFactory(); Socket socket = factory.createSocket(host, port, clientHost, clientPort); listener.socketCreated(socket, factory); return socket; } public Socket createSocket(InetAddress host, int port) throws IOException { checkFactory(); Socket socket = factory.createSocket(host, port); listener.socketCreated(socket, factory); return socket; } public Socket createSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort) throws IOException { checkFactory(); Socket socket = factory.createSocket(address, port, clientAddress, clientPort); listener.socketCreated(socket, factory); return socket; } public String[] getDefaultCipherSuites() { if (factory instanceof SSLSocketFactory) return ((SSLSocketFactory) factory).getDefaultCipherSuites(); else return null; } public String[] getSupportedCipherSuites() { if (factory instanceof SSLSocketFactory) return ((SSLSocketFactory) factory).getSupportedCipherSuites(); else return null; } public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException { if (factory instanceof SSLSocketFactory) { Socket socket = ((SSLSocketFactory) factory).createSocket(s, host, port, autoClose); listener.socketCreated(socket, factory); return socket; } else return null; } public SocketFactory getSocketFactory() { return factory; } public void setSocketFactory(SocketFactory factory) { this.factory = factory; } protected void checkFactory() { if (factory == null) factory = SocketFactory.getDefault(); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/CreationListenerServerSocketFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/CreationListenerServ0000644000175000017500000000704510553256471033571 0ustar twernertwerner/* * 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.remoting.socketfactory; import java.io.IOException; import java.io.Serializable; import java.net.InetAddress; import java.net.ServerSocket; import javax.net.ServerSocketFactory; /** * A CreationListenerServerSocketFactory wraps a ServerSocketFactory, and whenever * the ServerSocketFactory creates a ServerSocket, the ServerSocket is wrapped in a * CreationListenerServerSocket. * * @author Ron Sigal * @version $Revision: 1866 $ *

          * Copyright Jan 10, 2007 *

          */ public class CreationListenerServerSocketFactory extends ServerSocketFactory implements ServerSocketFactoryWrapper, Serializable { private static final long serialVersionUID = -7939318527267014514L; private ServerSocketFactory factory; private SocketCreationListener listener; public CreationListenerServerSocketFactory(ServerSocketFactory factory, SocketCreationListener listener) { this.factory = factory; this.listener = listener; } public ServerSocketFactory getFactory() { return factory; } public SocketCreationListener getListener() { return listener; } public void setFactory(ServerSocketFactory factory) { this.factory = factory; } public void setListener(SocketCreationListener listener) { this.listener = listener; } public ServerSocket createServerSocket() throws IOException { ServerSocket serverSocket = factory.createServerSocket(); return new CreationListenerServerSocket(serverSocket, listener); } public ServerSocket createServerSocket(int port) throws IOException { ServerSocket serverSocket = factory.createServerSocket(port); return new CreationListenerServerSocket(serverSocket, listener); } public ServerSocket createServerSocket(int port, int backlog) throws IOException { ServerSocket serverSocket = factory.createServerSocket(port, backlog); return new CreationListenerServerSocket(serverSocket, listener); } public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException { ServerSocket serverSocket = factory.createServerSocket(port, backlog, ifAddress); return new CreationListenerServerSocket(serverSocket, listener); } public ServerSocketFactory getServerSocketFactory() { return factory; } public void setServerSocketFactory(ServerSocketFactory factory) { this.factory = factory; } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/CreationListenerServerSocket.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/socketfactory/CreationListenerServ0000644000175000017500000001442211171061347033557 0ustar twernertwerner/* * 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.remoting.socketfactory; import java.io.IOException; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketAddress; import java.net.SocketException; import java.nio.channels.ServerSocketChannel; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import org.jboss.remoting.util.SecurityUtility; /** * A CreationListenerServerSocket wraps a ServerSocket to which it delegates * calls to accept(), and when the wrapped ServerSocket creates a Socket in * accept(), a SocketCreationListener is notified before the Socket is returned. * * @author Ron Sigal * @version $Revision: 5010 $ *

          * Copyright Jan 10, 2007 *

          */ public class CreationListenerServerSocket extends ServerSocket { private ServerSocket serverSocket; private SocketCreationListener listener; private PrivilegedExceptionAction action; public CreationListenerServerSocket(ServerSocket serverSocket, SocketCreationListener listener) throws IOException { this.serverSocket = serverSocket; this.listener = listener; action = new PrivilegedExceptionAction() { public Object run() throws Exception { return CreationListenerServerSocket.this.serverSocket.accept(); } }; } public SocketCreationListener getListener() { return listener; } public ServerSocket getServerSocket() { return serverSocket; } public void setListener(SocketCreationListener listener) { this.listener = listener; } public void setServerSocket(ServerSocket serverSocket) { this.serverSocket = serverSocket; } public void bind(SocketAddress endpoint) throws IOException { bind(serverSocket, endpoint); } public void bind(SocketAddress endpoint, int backlog) throws IOException { bind(serverSocket, endpoint, backlog); } public Socket accept() throws IOException { Socket socket = null; if (SecurityUtility.skipAccessControl()) { socket = serverSocket.accept(); } else { try { socket = (Socket)AccessController.doPrivileged(action); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } listener.socketCreated(socket, serverSocket); return socket; } public void close() throws IOException { serverSocket.close(); } public boolean equals(Object obj) { return serverSocket.equals(obj); } public ServerSocketChannel getChannel() { return serverSocket.getChannel(); } public InetAddress getInetAddress() { return serverSocket.getInetAddress(); } public int getLocalPort() { return serverSocket.getLocalPort(); } public SocketAddress getLocalSocketAddress() { return serverSocket.getLocalSocketAddress(); } public int getReceiveBufferSize() throws SocketException { return serverSocket.getReceiveBufferSize(); } public boolean getReuseAddress() throws SocketException { return serverSocket.getReuseAddress(); } public int getSoTimeout() throws IOException { return serverSocket.getSoTimeout(); } public int hashCode() { return serverSocket.hashCode(); } public boolean isBound() { return serverSocket.isBound(); } public boolean isClosed() { return serverSocket.isClosed(); } public void setReceiveBufferSize(int size) throws SocketException { serverSocket.setReceiveBufferSize(size); } public void setReuseAddress(boolean on) throws SocketException { serverSocket.setReuseAddress(on); } public void setSoTimeout(int timeout) throws SocketException { serverSocket.setSoTimeout(timeout); } public String toString() { return serverSocket.toString(); } static private void bind(final ServerSocket ss, final SocketAddress address) throws IOException { if (SecurityUtility.skipAccessControl()) { ss.bind(address); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { ss.bind(address); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private void bind(final ServerSocket ss, final SocketAddress address, final int backlog) throws IOException { if (SecurityUtility.skipAccessControl()) { ss.bind(address, backlog); return; } try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { ss.bind(address, backlog); return null; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/LeasePinger.java0000644000175000017500000003410211252745724027710 0ustar twernertwernerpackage org.jboss.remoting; import org.jboss.logging.Logger; import org.jboss.remoting.transport.ClientInvoker; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Timer; import java.util.TimerTask; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; /** * Internal agent class to ping the remote server to keep lease alive. * * @author Tom Elrod * @author Ovidiu Feodorov */ public class LeasePinger { // Constants ------------------------------------------------------------------------------------ private static final Logger log = Logger.getLogger(LeasePinger.class); public static final long DEFAULT_LEASE_PERIOD = 5000; public static final int DEFAULT_DISCONNECT_TIMEOUT = -1; public static final String LEASE_PINGER_TIMEOUT = "leasePingerTimeout"; static final String LEASE_PINGER_ID = "leasePingerId"; static final String TIME_STAMP = "timeStamp"; // Static --------------------------------------------------------------------------------------- private static boolean trace = log.isTraceEnabled(); private static Timer timer = new Timer(true); // Attributes ----------------------------------------------------------------------------------- private long defaultPingPeriod = -1; private ClientInvoker invoker = null; private String invokerSessionID = null; private Map clientSessionIds = new ConcurrentHashMap(); private Map clients = new ConcurrentHashMap(); private TimerTask timerTask = null; private long pingPeriod = -1; private int disconnectTimeout = DEFAULT_DISCONNECT_TIMEOUT; private int leasePingerTimeout = -1; // The following variables exist for testing purposes. private boolean pingInvoked; private boolean pingSucceeded; private String leasePingerId; private boolean useClientConnectionIdentity; // Constructors --------------------------------------------------------------------------------- public LeasePinger(ClientInvoker invoker, String invokerSessionID, long defaultLeasePeriod) { this(invoker, invokerSessionID, defaultLeasePeriod, null); } public LeasePinger(ClientInvoker invoker, String invokerSessionID, long defaultLeasePeriod, Map config) { this.invoker = invoker; this.invokerSessionID = invokerSessionID; this.pingPeriod = defaultLeasePeriod; this.defaultPingPeriod = defaultLeasePeriod; if (config != null) { Object o = config.get(LEASE_PINGER_TIMEOUT); if (o != null) { if (o instanceof String) { try { leasePingerTimeout = Integer.valueOf((String) o).intValue(); } catch (NumberFormatException e) { log.warn("leasePingerTimeout parameter must represent an int: " + o); } } else { log.warn("leasePingerTimeout parameter must be a String representing an int"); } } } } // Public --------------------------------------------------------------------------------------- public void startPing() { if(trace) { log.trace(this + " starting lease timer with ping period of " + pingPeriod); } timerTask = new LeaseTimerTask(this); try { timer.schedule(timerTask, pingPeriod, pingPeriod); } catch (IllegalStateException e) { log.debug("Unable to schedule TimerTask on existing Timer", e); timer = new Timer(true); timer.schedule(timerTask, pingPeriod, pingPeriod); } } public void stopPing() { if(trace) { log.trace(this + " stopping lease timer"); } if (timerTask != null) { timerTask.cancel(); timerTask = null; if (useClientConnectionIdentity) { Iterator it = clients.values().iterator(); while (it.hasNext()) { Client client = (Client) it.next(); if (trace) log.trace(this + " calling " + client + ".notifyAndDisconnect()"); client.notifyListeners(); it.remove(); } } try { // sending request map with no ClientHolders will indicate to server // that is full disconnect (for client invoker) HashMap metadata = null; // If disconnectTimeout == 0, skip network i/o. if (trace) log.trace(this + ": disconnectTimeout: " + disconnectTimeout); if (disconnectTimeout != 0) { if (disconnectTimeout > 0) { metadata = new HashMap(1); metadata.put(ServerInvoker.TIMEOUT, Integer.toString(disconnectTimeout)); } InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$DISCONNECT$", metadata, null, null); invoker.invoke(ir); } } catch (Throwable throwable) { RuntimeException e = new RuntimeException("Error tearing down lease with server."); e.initCause(throwable); throw e; } if (trace) { log.trace(this + " shut down"); if (!clientSessionIds.isEmpty()) { log.trace(this + " " + clientSessionIds.size() + " remaining clients:"); Iterator it = clientSessionIds.keySet().iterator(); while (it.hasNext()) { log.trace(this + ": " + it.next()); } clientSessionIds.clear(); } else { log.trace(this + " No remaining clients"); } } } } public void addClient(String sessionID, Map configuration, long leasePeriod) { if (leasePeriod <= 0) { leasePeriod = defaultPingPeriod; } if(trace) { log.trace(this + " adding new client with session ID " + sessionID + " and lease period " + leasePeriod); } if (useClientConnectionIdentity) { Client client = (Client) configuration.remove(Client.CLIENT); if (client != null) { clients.put(sessionID, client); } } ClientHolder newClient = new ClientHolder(sessionID, configuration, leasePeriod); clientSessionIds.put(sessionID, newClient); try { sendClientPing(); } catch (Throwable t) { log.debug(this + " failed to ping to server", t); log.warn(this + " failed to ping to server: " + t.getMessage()); throw new RuntimeException(t); } // if new client lease period is less than the current ping period, need to refresh to new one if (leasePeriod < pingPeriod) { pingPeriod = leasePeriod; // don't want to call stopPing() as that will send disconnect for client invoker if (timerTask != null) { timerTask.cancel(); timerTask = null; startPing(); } } } public boolean removeClient(String sessionID) { boolean isLastClientLease = false; if(trace) { log.trace(this + " removing client with session ID " + sessionID); } // Don't remove holder until after client has been removed from server side Lease, to // avoid a race with LeaseTimerTask sending a PING without the Client being removed. ClientHolder holder = (ClientHolder)clientSessionIds.get(sessionID); if (holder != null) { // send disconnect for this client try { Map clientMap = new HashMap(); clientMap.put(ClientHolder.CLIENT_HOLDER_KEY, holder); // If disconnectTimeout == 0, skip network i/o. if (disconnectTimeout != 0) { if (disconnectTimeout > 0) clientMap.put(ServerInvoker.TIMEOUT, Integer.toString(disconnectTimeout)); InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$DISCONNECT$", clientMap, null, null); invoker.invoke(ir); if(trace) { log.trace(this + " sent out disconnect message to server for lease tied to client with session ID " + sessionID); } } } catch (Throwable throwable) { log.debug(this + " failed sending disconnect for client lease for " + "client with session ID " + sessionID); } clientSessionIds.remove(sessionID); if (useClientConnectionIdentity) { clients.remove(sessionID); } } else { log.debug(this + " tried to remove lease for client with session ID " + sessionID + ", but no such lease was found: probably it was registered with an older LeasePinger"); } if (clientSessionIds.isEmpty()) { isLastClientLease = true; if(trace) { log.trace(this + " has no more client leases"); } } else { // now need to see if any of the other client holders have a lower lease period than // default long tempPingPeriod = defaultPingPeriod; for (Iterator i = clientSessionIds.values().iterator(); i.hasNext(); ) { ClientHolder clientHolder = (ClientHolder)i.next(); long clientHolderLeasePeriod = clientHolder.getLeasePeriod(); if (clientHolderLeasePeriod > 0 && clientHolderLeasePeriod < tempPingPeriod) { tempPingPeriod = clientHolderLeasePeriod; } } // was there a change in lease period? if (tempPingPeriod != pingPeriod) { // need to update to new ping period and reset timer pingPeriod = tempPingPeriod; if (timerTask != null) { timerTask.cancel(); timerTask = null; } startPing(); } } return isLastClientLease; } public long getLeasePeriod(String sessionID) { if (timerTask == null) { return -1; } // look to see if the client is still amont those serviced by this lease pinger if (clientSessionIds.containsKey(sessionID)) { return pingPeriod; } else { return -1; } } public String toString() { return "LeasePinger[" + leasePingerId + ":" + invoker + "(" + invokerSessionID + ")]"; } // Package protected ---------------------------------------------------------------------------- // Protected ------------------------------------------------------------------------------------ protected int getDisconnectTimeout() { return disconnectTimeout; } protected void setDisconnectTimeout(int disconnectTimeout) { this.disconnectTimeout = disconnectTimeout; if (trace) log.trace(this + " setting disconnect timeout to: " + disconnectTimeout); } protected String getLeasePingerId() { return leasePingerId; } protected void setLeasePingerId(String leasePingerId) { this.leasePingerId = leasePingerId; } boolean isUseClientConnectionIdentity() { return useClientConnectionIdentity; } void setUseClientConnectionIdentity(boolean useClientConnectionIdentity) { this.useClientConnectionIdentity = useClientConnectionIdentity; } // Private -------------------------------------------------------------------------------------- private void sendClientPing() throws Throwable { if(trace) { StringBuffer sb = new StringBuffer(); if(clientSessionIds != null) { for(Iterator i = clientSessionIds.values().iterator(); i.hasNext(); ) { ClientHolder h = (ClientHolder)i.next(); sb.append(" ").append(h.getSessionId()).append('\n'); } } log.trace(this + " sending ping to server. Currently managing lease " + "for following clients:\n" + sb.toString()); } Map clientsClone = new ConcurrentHashMap(clientSessionIds); Map requestClients = new ConcurrentHashMap(); requestClients.put(ClientHolder.CLIENT_HOLDER_KEY, clientsClone); requestClients.put(LeasePinger.LEASE_PINGER_ID, leasePingerId); requestClients.put(TIME_STAMP, Long.toString(System.currentTimeMillis())); if (leasePingerTimeout >= 0) { requestClients.put(ServerInvoker.TIMEOUT, Integer.toString(leasePingerTimeout)); } InvocationRequest ir = new InvocationRequest(invokerSessionID, null, "$PING$", requestClients, null, null); pingSucceeded = false; pingInvoked = true; invoker.invoke(ir); pingSucceeded = true; pingInvoked = false; if(trace) { log.trace(this + " successfully pinged the server"); } } // Inner classes -------------------------------------------------------------------------------- static private class LeaseTimerTask extends TimerTask { private LeasePinger pinger; LeaseTimerTask(final LeasePinger pinger) { this.pinger = pinger; } public void run() { final LeasePinger currentPinger; synchronized(this) { currentPinger = pinger; } if (currentPinger != null) { try { currentPinger.sendClientPing(); } catch (Throwable t) { log.debug(this + " failed to ping to server", t); log.warn(this + " failed to ping to server: " + t.getMessage()); } } } public boolean cancel() { synchronized(this) { pinger = null; } return super.cancel(); } } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ServerInvocationHandlerWrapper.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/ServerInvocationHandlerWrapper.jav0000644000175000017500000001040411413660476033506 0ustar twernertwerner /* * 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.remoting; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import javax.management.MBeanServer; import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.util.SecurityUtility; /** * A ServerInvocationHandlerWrapper is used to wrap an MBean proxy that implements * org.jboss.remoting.ServerInvocationHandler. If necessary, each call will go * through an AccessController.doPrivileged() call. * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright May 4, 2008 *

          */ public class ServerInvocationHandlerWrapper implements ServerInvocationHandler { private ServerInvocationHandler proxy; public ServerInvocationHandlerWrapper(ServerInvocationHandler proxy) { this.proxy = proxy; } public void addListener(final InvokerCallbackHandler callbackHandler) { if (SecurityUtility.skipAccessControl()) { proxy.addListener(callbackHandler); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.addListener(callbackHandler); return null; } }); } public Object invoke(final InvocationRequest invocation) throws Throwable { if (SecurityUtility.skipAccessControl()) { return proxy.invoke(invocation); } try { return AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { try { return proxy.invoke(invocation); } catch (Throwable t) { throw new Exception(t); } } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause.getCause() == null) throw cause; else throw cause.getCause(); } } public void removeListener(final InvokerCallbackHandler callbackHandler) { if (SecurityUtility.skipAccessControl()) { proxy.removeListener(callbackHandler); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.removeListener(callbackHandler); return null; } }); } public void setInvoker(final ServerInvoker invoker) { if (SecurityUtility.skipAccessControl()) { proxy.setInvoker(invoker); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.setInvoker(invoker); return null; } }); } public void setMBeanServer(final MBeanServer server) { if (SecurityUtility.skipAccessControl()) { proxy.setMBeanServer(server); return; } AccessController.doPrivileged( new PrivilegedAction() { public Object run() { proxy.setMBeanServer(server); return null; } }); } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/InvocationRequest.java0000644000175000017500000000647310555353667031214 0ustar twernertwerner/* * 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.remoting; import java.io.Serializable; import java.util.Map; /** * InvocationRequest is passed to ServerInvocationHandler which encapsulates the unmarshalled method * invocation parameters from the ServerInvoker. * * @author Jeff Haynie * @version $Revision: 1972 $ */ //TODO: Need to remove Serializable if not going to pass InvocationRequest as the callback object -TME public class InvocationRequest implements Serializable { static final long serialVersionUID = -6719842238864057289L; private String sessionId; private String subsystem; private Object arg; private Map requestPayload; private Map returnPayload; private InvokerLocator locator; public InvocationRequest(String sessionId, String subsystem, Object arg, Map requestPayload, Map returnPayload, InvokerLocator locator) { this.sessionId = sessionId; this.subsystem = subsystem; this.arg = arg; this.requestPayload = requestPayload; this.returnPayload = returnPayload; this.locator = locator; } protected InvocationRequest(Object arg) { this.arg = arg; } public InvokerLocator getLocator() { return locator; } public void setLocator(InvokerLocator locator) { this.locator = locator; } public String getSubsystem() { return subsystem; } public void setSubsystem(String subsystem) { this.subsystem = subsystem; } public String getSessionId() { return sessionId; } public void setSessionId(String sessionId) { this.sessionId = sessionId; } public Object getParameter() { return arg; } public void setParameter(Object arg) { this.arg = arg; } public Map getRequestPayload() { return requestPayload; } public void setRequestPayload(Map requestPayload) { this.requestPayload = requestPayload; } public Map getReturnPayload() { return returnPayload; } public void setReturnPayload(Map returnPayload) { this.returnPayload = returnPayload; } public String toString() { return "InvocationRequest[" + Integer.toHexString(hashCode()) + (subsystem != null ? ", " + subsystem : "") + (arg != null ? ", " + arg : ", EMPTY") + "]"; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/0000755000175000017500000000000011632407044026266 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/rmi/0000755000175000017500000000000011632407044027055 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/rmi/RMIMarshaller.java0000644000175000017500000000374510355142433032372 0ustar twernertwerner/* * 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.remoting.marshal.rmi; import java.io.IOException; import java.io.OutputStream; import org.jboss.remoting.marshal.Marshaller; /** * This marshaller does nothing as will not be used by default RMI invoker * since marshalling is done by RMI itself. * * @author Tom Elrod */ public class RMIMarshaller implements Marshaller { static final long serialVersionUID = -5659717749693258742L; public final static String DATATYPE = "rmi"; /** * Marshaller will need to take the dataObject and convert * into primitive java data types and write to the * given output. * * @param dataObject Object to be writen to output * @param output The data output to write the object * data to. */ public void write(Object dataObject, OutputStream output) throws IOException { //NO OP } public Marshaller cloneMarshaller() throws CloneNotSupportedException { return new RMIMarshaller(); } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/rmi/RMIUnMarshaller.java0000644000175000017500000000534210355142433032670 0ustar twernertwerner/* * 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.remoting.marshal.rmi; import java.io.IOException; import java.io.InputStream; import java.util.Map; import org.jboss.remoting.marshal.UnMarshaller; /** * This basically does nothing since RMI will handle marshalling by * default. Is only here as a place holder. * * @author Tom Elrod */ public class RMIUnMarshaller implements UnMarshaller { static final long serialVersionUID = -6342200977048213419L; public final static String DATATYPE = "rmi"; /** * Will read from the inputstream and converty contents to java Object. * * @param inputStream stream to read data from to do conversion * @param metadata can be any transport specific metadata (such as headers from http transport). * This can be null, depending on if transport supports metadata. * @return * @throws java.io.IOException all specific i/o exceptions need to be thrown as this. * @throws ClassNotFoundException will be thrown if during the unmarshalling process can not find a specific class * within classloader. */ public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException { return null; //NO OP } /** * Set the class loader to use for unmarhsalling. This may * be needed when need to have access to class definitions that * are not part of this unmarshaller's parent classloader (especially * when doing remote classloading). * * @param classloader */ public void setClassLoader(ClassLoader classloader) { //NO OP } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { return new RMIUnMarshaller(); } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/Marshaller.java0000644000175000017500000000423110355142433031222 0ustar twernertwerner/* * 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.remoting.marshal; import java.io.IOException; import java.io.OutputStream; import java.io.Serializable; /** * Interface that all data marshallers must implements. * Requires them to take Java data objects and convert * primitive java data types (i.e. byte[]) and write * to output provided. *

          * Since the Marshaller is only responsible for doing * the conversion to primitive type, does not make sense * that would be supplied any type of object output to * write to, as this implies that the object that it * writes would be converted to bytes at some other * point external to the marshaller. * * @author Tom Elrod */ public interface Marshaller extends Serializable { /** * Marshaller will need to take the dataObject and convert * into primitive java data types and write to the * given output. * * @param dataObject Object to be writen to output * @param output The data output to write the object * data to. */ public void write(Object dataObject, OutputStream output) throws IOException; public Marshaller cloneMarshaller() throws CloneNotSupportedException; }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/UnMarshallerDecorator.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/UnMarshallerDecorator.java0000644000175000017500000000342310355142433033372 0ustar twernertwerner/* * 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.remoting.marshal; import java.io.IOException; /** * On RMI invocations we can't use customer Marshallers, but we need to decorate Invocations (or any other objects) * with some data before sending the object. *

          * We could use a ByteArrayOutputStream and ByteArrayInputStream but that would be an expensive operation, * so we decided to keep the needed decoration on an interface. Marshaller implementations could refactor their logic to * the methods defined on this interface so we can have a cheaper marshalling with RMI. * $Id: UnMarshallerDecorator.java 566 2005-12-30 05:26:51Z telrod $ * * @author Clebert Suconic */ public interface UnMarshallerDecorator { public Object removeDecoration(Object obj) throws IOException; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/http/0000755000175000017500000000000011632407044027245 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/http/HTTPMarshaller.java0000644000175000017500000000537710623457627032731 0ustar twernertwerner/* * 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.remoting.marshal.http; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.serialization.SerializationStreamFactory; /** * @author Tom Elrod */ public class HTTPMarshaller extends SerializableMarshaller { static final long serialVersionUID = -51801299849879386L; public final static String DATATYPE = "http"; /** * Take the data object and write to the output. * If the data object is of type String, will just * write the bytes of the String, otherwise will * use the SerializableMarshaller implementation. * * @param dataObject Object to be writen to output * @param output The data output to write the object * data to. * @param version Wire format version. */ public void write(Object dataObject, OutputStream output, int version) throws IOException { if(dataObject instanceof String) { output.write(((String) dataObject).getBytes()); output.flush(); } else { // ObjectOutputStream oos = null; // if(output instanceof ObjectOutputStream) // { // oos = (ObjectOutputStream) output; // } // else // { // oos = SerializationStreamFactory.getManagerInstance(getSerializationType()).createOutput(output); // } // oos.writeObject(dataObject); // // oos.flush(); super.write(dataObject, output, version); } } public Marshaller cloneMarshaller() throws CloneNotSupportedException { return new HTTPMarshaller(); } }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java0000644000175000017500000002321611245307406033212 0ustar twernertwerner/* * 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.remoting.marshal.http; import org.jboss.logging.Logger; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import org.jboss.remoting.transport.http.HTTPMetadataConstants; import org.jboss.remoting.transport.web.WebUtil; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.util.Map; /** * @author Tom Elrod */ public class HTTPUnMarshaller extends SerializableUnMarshaller { static final long serialVersionUID = 1085086661310576768L; public final static String DATATYPE = "http"; public final static String PRESERVE_LINES = "preserveLines"; protected final static Logger log = Logger.getLogger(HTTPUnMarshaller.class); /** * Will try to unmarshall data from inputstream. Will try to convert to either an object * or a string. If there is no data to read, will return null. * * @param inputStream * @param metadata * @param version * @return * @throws IOException * @throws ClassNotFoundException */ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { if (isBinaryData(metadata)) { try { return super.read(inputStream, metadata, version); } catch (EOFException e) { return null; } } int contentLength = -1; Object ret = null; int bufferSize = 1024; byte[] byteBuffer = new byte[bufferSize]; ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); boolean preserveLines = false; boolean isChunked = false; // check the metadat to see if is entry for content length if(metadata != null) { Object value = metadata.get("Content-Length"); if(value == null) { value = metadata.get("content-length"); } if(value != null) { if(value instanceof List) { List valueList = (List) value; if(valueList != null && valueList.size() > 0) { value = valueList.get(0); } } if(value instanceof String) { try { contentLength = Integer.parseInt((String) value); } catch(NumberFormatException e) { log.warn("Error converting Content-Length value (" + value + ") from metadata into int value."); } } else { log.warn("Can not get Content-Length from header for http unmarshalling."); } } value = metadata.get(PRESERVE_LINES); if (value != null) { if (value instanceof String) { preserveLines = Boolean.valueOf((String) value).booleanValue(); } } value = metadata.get("transfer-encoding"); if (value instanceof String && "chunked".equalsIgnoreCase((String)value)) { isChunked = true; } } int pointer = 0; int amtRead = inputStream.read(byteBuffer); while(amtRead > 0) { byteOutputStream.write(byteBuffer, pointer, amtRead); if(!isChunked && (amtRead < bufferSize && byteOutputStream.size() >= contentLength)) { //done reading, so process break; } amtRead = inputStream.read(byteBuffer); } byteOutputStream.flush(); byte[] totalByteArray = byteOutputStream.toByteArray(); if(totalByteArray.length == 0) { //nothing to read, so is null return null; } //boolean isError = isErrorReturn(metadata); //if(isBinary || isError) try { BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(totalByteArray))); StringBuffer buffer = new StringBuffer(); if (preserveLines) { if (log.isTraceEnabled()) log.trace("preserving cr/lf"); int len = 0; char[] chars = new char[bufferSize]; while ((len = reader.read(chars)) > -1) { buffer.append(chars, 0, len); } } else { if (log.isTraceEnabled()) log.trace("deleting cr/lf"); String str = null; while((str = reader.readLine()) != null) { buffer.append(str); } } reader.close(); ret = buffer.toString(); } catch(Exception e) { log.debug("Can not unmarshall inputstream. Tried to unmarshall as both an object and string type.", e); throw new IOException("Can not unmarshall inputstream."); } return ret; } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { HTTPUnMarshaller unmarshaller = new HTTPUnMarshaller(); unmarshaller.setClassLoader(getClassLoader()); return unmarshaller; } private boolean isErrorReturn(Map metadata) { boolean isError = false; if(metadata != null) { // key of null will be the response (http type, response code, and response message) Object value = metadata.get(HTTPMetadataConstants.RESPONSE_CODE); if(value != null && value instanceof Integer) { int responseCode = ((Integer) value).intValue(); if(responseCode > 400) { isError = true; } } } return isError; } private boolean isBinaryData(Map metadata) throws IOException { String useRemotingContentType = (String) metadata.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE); if (Boolean.valueOf(useRemotingContentType).booleanValue()) { return isBinaryDataNew(metadata); } else { return isBinaryDataOld(metadata); } } private boolean isBinaryDataOld(Map metadata) throws IOException { if (log.isTraceEnabled()) log.trace(this + " using isBinaryDataOld()"); boolean isBinary = false; if(metadata != null) { // need to get the content type Object value = metadata.get("Content-Type"); if(value == null) { value = metadata.get("content-type"); } if(value != null) { if(value instanceof List) { List valueList = (List) value; if(valueList != null && valueList.size() > 0) { value = valueList.get(0); } } isBinary = WebUtil.isBinary((String) value); } } if (log.isTraceEnabled()) log.trace(this + " isBinary: " + isBinary); return isBinary; } private boolean isBinaryDataNew(Map metadata) throws IOException { if (log.isTraceEnabled()) log.trace(this + " using isBinaryDataNew()"); boolean isBinary = true; if(metadata != null) { // need to get the content type String remotingContentType = null; Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE); if (o instanceof List) { remotingContentType = (String) ((List) o).get(0); } else if (o instanceof String) { remotingContentType = (String) o; } else { o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_LC); if (o instanceof List) { remotingContentType = (String) ((List) o).get(0); } else if (o instanceof String) { remotingContentType = (String) o; } else if (o != null) { log.debug(this + " unrecognized remotingContentType: " + o); } } if (log.isTraceEnabled()) log.trace(this + " remotingContentType: " + remotingContentType); if (remotingContentType != null) { isBinary = HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING.equals(remotingContentType); } } if (log.isTraceEnabled()) log.trace(this + " isBinary: " + isBinary); return isBinary; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/serializable/0000755000175000017500000000000011632407044030734 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/serializable/SerializableMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/serializable/SerializableM0000644000175000017500000001036410623457627033421 0ustar twernertwerner/* * 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.remoting.marshal.serializable; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.Map; import org.jboss.remoting.Version; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.PreferredStreamMarshaller; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; /** * Simple marshaller that simply serializes java objects * using standard output stream. * * @author Tom Elrod */ public class SerializableMarshaller implements PreferredStreamMarshaller, VersionedMarshaller { static final long serialVersionUID = -5553685435323600244L; public final static String DATATYPE = "serializable"; String serializationType; public void setSerializationType(String serializationType) { this.serializationType = serializationType; } public String getSerializationType() { if(serializationType == null) { return "java"; } else { return serializationType; } } public OutputStream getMarshallingStream(OutputStream outputStream) throws IOException { return getMarshallingStream(outputStream, null); } /** * SerializableMarshaller prefers to write to an ObjectOutputStream wrapped around a * BufferedOutputStream. */ public OutputStream getMarshallingStream(OutputStream outputStream, Map config) throws IOException { if(outputStream instanceof ObjectOutputStream) { return outputStream; } else { BufferedOutputStream bos = new BufferedOutputStream(outputStream); SerializationManager manager = SerializationStreamFactory.getManagerInstance(getSerializationType()); ObjectOutputStream oos = manager.createOutput(bos); oos.flush(); return oos; } } /** * Take the data object and write to the output. Has ben customized * for working with ObjectOutputStreams since requires extra messaging. * * @param dataObject Object to be writen to output * @param output The data output to write the object * data to. */ public void write(Object dataObject, OutputStream output) throws IOException { int version = Version.getDefaultVersion(); write(dataObject, output, version); } /** * Take the data object and write to the output. Has ben customized * for working with ObjectOutputStreams since requires extra messaging. * * @param dataObject Object to be writen to output * @param output The data output to write the object data to. * @param version Wire format version */ public void write(Object dataObject, OutputStream output, int version) throws IOException { ObjectOutputStream oos = (ObjectOutputStream) getMarshallingStream(output, null); SerializationStreamFactory.getManagerInstance(getSerializationType()).sendObject(oos, dataObject, version); } public Marshaller cloneMarshaller() throws CloneNotSupportedException { return new SerializableMarshaller(); } }././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/serializable/SerializableUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/serializable/SerializableU0000644000175000017500000001414510757514345033431 0ustar twernertwerner/* * 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.remoting.marshal.serializable; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.lang.ref.WeakReference; import java.util.Map; import org.jboss.remoting.Version; import org.jboss.remoting.marshal.PreferredStreamUnMarshaller; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.UpdateableClassloaderUnMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; /** * Will perform the deserialization of objects off the wire. * * @author Tom Elrod */ public class SerializableUnMarshaller implements PreferredStreamUnMarshaller, VersionedUnMarshaller, UpdateableClassloaderUnMarshaller { static final long serialVersionUID = -1554017376768780738L; public final static String DATATYPE = "serializable"; protected ClassLoader customClassLoader; protected String serializationType; public InputStream getMarshallingStream(InputStream inputStream) throws IOException { return getMarshallingStream(inputStream, null); } /** * SerializableUnMarshaller prefers to read from an ObjectOutputStream wrapped around a * BufferedInputStream */ public InputStream getMarshallingStream(InputStream inputStream, Map config) throws IOException { if (inputStream instanceof ObjectInputStream) { return inputStream; } else { BufferedInputStream bis = new BufferedInputStream(inputStream); SerializationManager manager = SerializationStreamFactory.getManagerInstance(getSerializationType()); return manager.createInput(bis, getClassLoader()); } } /** * Reads the data from the input stream and converts to an Object. *

          * If the inputStream passed is an ObjectInputStream (which would prefer it not be), it will just * use it as given. If the input stream is not an instance of ObjectInputStream, will wrap it with a * custom ObjectInputStream (ObjectInputStreamWithClassLoader) and use it. The ObjectInputStreamWithClassLoader * will use the custom class loader set in order to ensure that any classes not found within the local classloader * can be loaded from the server and used within the client VM. If the inpustream is of type ObjectInputStreamWithClassLoader, * then will just set the classloader to the custom classloader and proceed.

          * * @param inputStream * @param metadata * @return * @throws IOException * @throws ClassNotFoundException */ public Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException { int version = Version.getDefaultVersion(); return read(inputStream, metadata, version); } /** * Reads the data from the input stream and converts to an Object. *

          * If the inputStream passed is an ObjectInputStream (which would prefer it not be), it will just * use it as given. If the input stream is not an instance of ObjectInputStream, will wrap it with a * custom ObjectInputStream (ObjectInputStreamWithClassLoader) and use it. The ObjectInputStreamWithClassLoader * will use the custom class loader set in order to ensure that any classes not found within the local classloader * can be loaded from the server and used within the client VM. If the inpustream is of type ObjectInputStreamWithClassLoader, * then will just set the classloader to the custom classloader and proceed.

          * * @param inputStream * @param metadata * @param version * @return * @throws IOException * @throws ClassNotFoundException */ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { ObjectInputStream ois = (ObjectInputStream) getMarshallingStream(inputStream, null); return SerializationStreamFactory.getManagerInstance(getSerializationType()).receiveObject(ois, getClassLoader(), version); } /** * Sets the classloader to be used when deserializing objects off the wire. This will ONLY be used in the * when the input stream passed to the read() method is NOT an instance of ObjectInputStream.

          * * @param classloader */ public void setClassLoader(ClassLoader classloader) { this.customClassLoader = classloader; } public ClassLoader getClassLoader() { return customClassLoader; } public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { SerializableUnMarshaller unmarshaller = new SerializableUnMarshaller(); unmarshaller.setClassLoader(getClassLoader()); return unmarshaller; } public void setSerializationType(String serializationType) { this.serializationType = serializationType; } public String getSerializationType() { if(serializationType == null) { return "java"; } else { return serializationType; } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/SerialMarshaller.java0000644000175000017500000000234110355142433032362 0ustar twernertwerner/* * 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.remoting.marshal; /** * @author Tom Elrod */ public interface SerialMarshaller extends Marshaller { void setSerializationType(String serializationType); String getSerializationType(); }././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/UpdateableClassloaderUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/UpdateableClassloaderUnMar0000644000175000017500000000243511413660476033412 0ustar twernertwerner/* * 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.remoting.marshal; /** * Adds ClassLoader getter(). * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 21, 2008 *

          */ public interface UpdateableClassloaderUnMarshaller extends UnMarshaller { ClassLoader getClassLoader(); } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshalFactory.java0000644000175000017500000005151211162325526032056 0ustar twernertwerner/* * 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.remoting.marshal; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.http.HTTPMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.marshal.rmi.RMIMarshaller; import org.jboss.remoting.marshal.rmi.RMIUnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * This class will provide marshallers and unmarshallers for data based on * the data type want to marshal to. The most common will be just to serialize * the data. However, may have jaxrpc, IIOP, serializers. Can also have marshallers * and unmarshallers based on class type. For example, might be marshaller/unmarshaller * for the Transaction class. * * @author Tom Elrod */ public class MarshalFactory { private static Map marshallers = Collections.synchronizedMap(new HashMap()); private static Map unmarshallers = Collections.synchronizedMap(new HashMap()); private static Map classMarshallers = Collections.synchronizedMap(new HashMap()); private static Map classUnmarshallers = Collections.synchronizedMap(new HashMap()); protected final static Logger log = Logger.getLogger(MarshalFactory.class); private final static boolean isTrace = log.isTraceEnabled(); private final static boolean isDebug = log.isDebugEnabled(); // statically load core marshallers/unmarshallers static { try { marshallers.put(SerializableMarshaller.DATATYPE, new SerializableMarshaller()); unmarshallers.put(SerializableUnMarshaller.DATATYPE, new SerializableUnMarshaller()); marshallers.put(HTTPMarshaller.DATATYPE, new HTTPMarshaller()); unmarshallers.put(HTTPUnMarshaller.DATATYPE, new HTTPUnMarshaller()); marshallers.put(RMIMarshaller.DATATYPE, new RMIMarshaller()); unmarshallers.put(RMIUnMarshaller.DATATYPE, new RMIUnMarshaller()); } catch(Exception e) { log.error("Could not statically load default marshallers.", e); } } /** * Will add the marshaller and unmarshaller based on class type. Each can then be retrieved using the * class type as key. * * @param classType * @param marshaller * @param unMarshaller */ public static void addMarshaller(Class classType, Marshaller marshaller, UnMarshaller unMarshaller) { classMarshallers.put(classType, marshaller); classUnmarshallers.put(classType, unMarshaller); } /** * Adds the marshaller and unmarshaller based on data type. Each can then be retrieved using the data type * as the key. * * @param dataType * @param marshaller * @param unMarshaller */ public static void addMarshaller(String dataType, Marshaller marshaller, UnMarshaller unMarshaller) { marshallers.put(dataType, marshaller); unmarshallers.put(dataType, unMarshaller); } /** * Looks up marshaller by class type. Will return null if not found. * * @param classType * @return */ public static Marshaller getMarshaller(Class classType) { Marshaller marshaller = null; Object obj = classMarshallers.get(classType); if(obj != null && obj instanceof Marshaller) { marshaller = (Marshaller) obj; try { marshaller = marshaller.cloneMarshaller(); } catch(CloneNotSupportedException e) { log.warn("Could not clone " + marshaller); } } else { if(isTrace) { log.trace("Could not find marshaller for class type '" + classType + "'. Object in collection is " + obj); } } return marshaller; } /** * Looks up marshaller by class type. Will return null if not found. * * @param classType * @return */ public static Marshaller getMarshaller(Class classType, String serializationType) { Marshaller marshaller = getMarshaller(classType); if(marshaller instanceof SerialMarshaller) { ((SerialMarshaller) marshaller).setSerializationType(serializationType); } return marshaller; } /** * Returns unmarshaller by class type. Will return null if not found. * * @param classType * @return */ public static UnMarshaller getUnMarshaller(Class classType) { UnMarshaller unmarshaller = null; Object obj = classUnmarshallers.get(classType); if(obj != null && obj instanceof UnMarshaller) { unmarshaller = (UnMarshaller) obj; try { unmarshaller = unmarshaller.cloneUnMarshaller(); } catch(CloneNotSupportedException e) { log.warn("Could not clone " + unmarshaller); } } else { if(isTrace) { log.trace("Could not find unmarshaller for class type '" + classType + "'. Object in collection is " + obj); } } return unmarshaller; } public static UnMarshaller getUnMarshaller(Class classType, String serializationType) { UnMarshaller unmarshaller = getUnMarshaller(classType); if(unmarshaller instanceof SerializableUnMarshaller) { ((SerializableUnMarshaller) unmarshaller).setSerializationType(serializationType); } return unmarshaller; } /** * Gets marshaller based on data type (i.e. serializable) and based on the marshallers registered with the factory. * * @param dataType * @return The marshaller or null if none for for the specified type */ public static Marshaller getMarshaller(String dataType) { Marshaller marshaller = null; Object obj = marshallers.get(dataType); if(obj != null && obj instanceof Marshaller) { marshaller = (Marshaller) obj; try { marshaller = marshaller.cloneMarshaller(); } catch(CloneNotSupportedException e) { log.warn("Could not clone " + marshaller); } } else { if(isTrace) { log.trace("Could not find marshaller for data type '" + dataType + "'. Object in collection is " + obj); } } return marshaller; } public static Marshaller getMarshaller(String dataType, String serializationType) { Marshaller marshaller = getMarshaller(dataType); if(marshaller instanceof SerializableMarshaller) { ((SerializableMarshaller) marshaller).setSerializationType(serializationType); } return marshaller; } public static UnMarshaller getUnMarshaller(String dataType, String serializationType) { UnMarshaller unmarshaller = getUnMarshaller(dataType); if(unmarshaller instanceof SerializableUnMarshaller) { ((SerializableUnMarshaller) unmarshaller).setSerializationType(serializationType); } return unmarshaller; } /** * Gets the marshaller based on data type (i.e. serialziable) and based on the unmarshallers registered with the factory. * * @param dataType * @return The unmarshaller or null if none for the specified type */ public static UnMarshaller getUnMarshaller(String dataType) { UnMarshaller unmarshaller = null; Object obj = unmarshallers.get(dataType); if(obj != null && obj instanceof UnMarshaller) { unmarshaller = (UnMarshaller) obj; try { unmarshaller = unmarshaller.cloneUnMarshaller(); } catch(CloneNotSupportedException e) { log.warn("Could not clone " + unmarshaller); } } else { if(isTrace) { log.trace("Could not find unmarshaller for data type '" + dataType + "'. Object in collection is " + obj); } } return unmarshaller; } /** * Will try to look up marshaller by first looking for data type parameter within locator and then using that * to look up marhsaller locally. If can not find it, will then look to see if can find the 'marshaller' parameter * within the locator parameters. If found, will try to load the marshaller by the class name specified as the parameter * value. If still can not find the class within the local VM, will look to see if there is a parameter for * the server's marshaller loader port. If this exists, will then try calling on the remote server to load the * marshaller (and its related classes) within the local VM. If still can not be found, will return null. * * @param locator * @param classLoader * @return */ public static Marshaller getMarshaller(InvokerLocator locator, ClassLoader classLoader) { return getMarshaller(locator, classLoader, null); } /** * Will try to look up marshaller by first looking for data type parameter within locator and config and then using that * to look up marhsaller locally. If can not find it, will then look to see if can find the 'marshaller' parameter * within the locator parameters or config parameters. If found, will try to load the marshaller by the class name specified * as the parameter value. If still can not find the class within the local VM, will look to see if there is a parameter for * the server's marshaller loader port. If this exists, will then try calling on the remote server to load the * marshaller (and its related classes) within the local VM. If still can not be found, will return null. * * @param locator * @param classLoader * @param config * @return */ public static Marshaller getMarshaller(InvokerLocator locator, ClassLoader classLoader, Map config) { String serializationType = locator.findSerializationType(); Marshaller marshaller = null; if(locator != null || config != null) { Map params = new HashMap(); if (locator.getParameters() != null) { params.putAll(locator.getParameters()); } if (config != null) { params.putAll(config); } if(params != null) { // start with data type as is prefered method of getting marshaller/unmarshaller String dataType = (String) params.get(InvokerLocator.DATATYPE); if(dataType == null) { dataType = (String) params.get(InvokerLocator.DATATYPE_CASED); } if(dataType != null) { marshaller = getMarshaller(dataType); } if(marshaller == null) { if(isTrace) { log.trace("Could not look up marshaller by data type ('" + dataType + "'). Will try to load dynamically."); } // will now look for explicit param for marshaller class String marshallerFQN = (String) params.get(InvokerLocator.MARSHALLER); marshaller = loadMarshaller(marshallerFQN); if(marshaller != null) { if(isTrace) { log.trace("Found marshaller by loading locally."); } // try to load unmarshaller so that can add to list String unmarshallerFQN = (String) params.get(InvokerLocator.UNMARSHALLER); UnMarshaller unmarshaller = loadUnMarshaller(unmarshallerFQN); if(unmarshaller != null) { addMarshaller(dataType, marshaller, unmarshaller); } } } if(marshaller == null && isTrace) { log.trace("Tried to find marshaller from locator by both data type and class name but was unsuccessful. " + "Will try to load it from remote server."); } // if still have not found marshaller, check to see if can load remotely if(marshaller == null && dataType != null) { InvokerLocator loaderLocator = MarshallLoaderFactory.convertLocator(locator); if(loaderLocator != null) { marshaller = MarshallerLoaderClient.getMarshaller(loaderLocator, dataType, classLoader); UnMarshaller unmarshaller = MarshallerLoaderClient.getUnMarshaller(loaderLocator, dataType, classLoader); if(unmarshaller != null) { unmarshaller.setClassLoader(classLoader); } if(isDebug) { log.debug("Remotely loaded marshaller: " + marshaller); log.debug("Remotely loaded unmarshaller: " + unmarshaller); } if(marshaller != null && unmarshaller != null) { addMarshaller(dataType, marshaller, unmarshaller); } } } } } if(marshaller != null) { try { marshaller = marshaller.cloneMarshaller(); } catch(CloneNotSupportedException e) { log.warn("Could not clone " + marshaller); } } if(marshaller instanceof SerialMarshaller) { ((SerialMarshaller) marshaller).setSerializationType(serializationType); } return marshaller; } private static Marshaller loadMarshaller(String marshallerFQN) { Marshaller marshaller = null; if(marshallerFQN != null) { try { Class marshallerClass = Class.forName(marshallerFQN); marshaller = (Marshaller) marshallerClass.newInstance(); } catch(Exception e) { log.warn("Found marshaller fully qualified class name within locator parameters, but was unable " + "to load class: " + marshallerFQN); } } return marshaller; } /** * Will try to look up unmarshaller by first looking for data type parameter within locator and then using that * to look up unmarshaller locally. If can not find it, will then look to see if can find the 'unmarshaller' parameter * within the locator parameters. If found, will try to load the unmarshaller by the class name specified as the parameter * value. If still can not find the class within the local VM, will look to see if there is a parameter for * the server's marshaller loader port. If this exists, will then try calling on the remote server to load the * unmarshaller (and its related classes) within the local VM. If still can not be found, will return null. * * @param locator * @param classLoader * @return */ public static UnMarshaller getUnMarshaller(InvokerLocator locator, ClassLoader classLoader) { return getUnMarshaller(locator, classLoader, null); } /** * Will try to look up unmarshaller by first looking for data type parameter within locator and config map and then using that * to look up unmarshaller locally. If can not find it, will then look to see if can find the 'unmarshaller' parameter * within the locator parameters or config map. If found, will try to load the unmarshaller by the class name specified as the * parameter value. If still can not find the class within the local VM, will look to see if there is a parameter for * the server's marshaller loader port. If this exists, will then try calling on the remote server to load the * unmarshaller (and its related classes) within the local VM. If still can not be found, will return null. * * @param locator * @param classLoader * @param config * @return */ public static UnMarshaller getUnMarshaller(InvokerLocator locator, ClassLoader classLoader, Map config) { String serializationType = locator.findSerializationType(); UnMarshaller unmarshaller = null; if(locator != null || config != null) { Map params = new HashMap(); if (locator.getParameters() != null) { params.putAll(locator.getParameters()); } if (config != null) { params.putAll(config); } if(params != null) { // start with data type as is prefered method of getting marshaller/unmarshaller String dataType = (String) params.get(InvokerLocator.DATATYPE); if(dataType == null) { dataType = (String) params.get(InvokerLocator.DATATYPE_CASED); } if(dataType != null) { unmarshaller = getUnMarshaller(dataType); } if(unmarshaller == null) { if(isTrace) { log.trace("Could not find unmarshaller by data type ('" + dataType + "'). Will try to load dynamically."); } // will now look for explicit param for marshaller class String unmarshallerFQN = (String) params.get(InvokerLocator.UNMARSHALLER); unmarshaller = loadUnMarshaller(unmarshallerFQN); if(unmarshaller != null) { String marshallerFQN = (String) params.get(InvokerLocator.MARSHALLER); Marshaller marshaller = loadMarshaller(marshallerFQN); if(marshaller != null) { addMarshaller(dataType, marshaller, unmarshaller); } } } if(isTrace && unmarshaller == null) { log.trace("Tried to find unmarshaller from locator by both data type and class name but was unsuccessful."); } // if still have not found unmarshaller, check to see if can load remotely if(unmarshaller == null && dataType != null) { InvokerLocator loaderLocator = MarshallLoaderFactory.convertLocator(locator); unmarshaller = MarshallerLoaderClient.getUnMarshaller(loaderLocator, dataType, classLoader); if(unmarshaller != null) { unmarshaller.setClassLoader(classLoader); } Marshaller marshaller = MarshallerLoaderClient.getMarshaller(loaderLocator, dataType, classLoader); if(isTrace) { log.trace("Remotely loaded marshaller: " + marshaller); log.trace("Remotely loaded unmarshaller: " + unmarshaller); } if(marshaller != null && unmarshaller != null) { addMarshaller(dataType, marshaller, unmarshaller); } } } } if(unmarshaller != null) { try { unmarshaller = unmarshaller.cloneUnMarshaller(); } catch(CloneNotSupportedException e) { log.warn("Could not clone " + unmarshaller); } } if(unmarshaller instanceof SerializableUnMarshaller) { ((SerializableUnMarshaller) unmarshaller).setSerializationType(serializationType); } return unmarshaller; } private static UnMarshaller loadUnMarshaller(String unmarshallerFQN) { UnMarshaller unmarshaller = null; if(unmarshallerFQN != null) { try { Class unmarshallerClass = Class.forName(unmarshallerFQN); unmarshaller = (UnMarshaller) unmarshallerClass.newInstance(); } catch(Exception e) { log.error("Found unmarshaller fully qualified class name within locator parameters, but was unable " + "to load class: " + unmarshallerFQN, e); } } return unmarshaller; } }././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallerLoaderClient.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallerLoaderClient.jav0000644000175000017500000001406111047672151033355 0ustar twernertwerner/* * 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.remoting.marshal; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import java.util.HashMap; import java.util.Map; /** * This class is used to load marshaller and unmarshallers from remote server. * * @author Tom Elrod */ public class MarshallerLoaderClient implements MarshallerLoaderConstants { protected final static Logger log = Logger.getLogger(MarshallerLoaderClient.class); /** * Will call on marshall loader server to load marshaller for given data type. * * @param loaderLocator converted locator indicating which marhaller loader to call upon. * @param dataType indicates which marshaller to get. * @param classByteLoader is the class loader that the new marshaller and related classes get loaed into. * @return */ public static Marshaller getMarshaller(InvokerLocator loaderLocator, String dataType, ClassLoader classByteLoader) { Marshaller marshaller = null; try { SerializableMarshaller loaderMarshaller = new SerializableMarshaller(); SerializableUnMarshaller loaderUnMarshaller = new SerializableUnMarshaller(); loaderUnMarshaller.setClassLoader(classByteLoader); String serializationType = "java"; Map parameters = loaderLocator.getParameters(); if (parameters != null) { Object o = parameters.get(InvokerLocator.SERIALIZATIONTYPE); if (o == null) { o = parameters.get(InvokerLocator.SERIALIZATIONTYPE_CASED);; } if (o != null) { serializationType = (String) o; } } loaderMarshaller.setSerializationType(serializationType); loaderUnMarshaller.setSerializationType(serializationType); String marshallerMethodName = GET_MARSHALLER_METHOD; Map metadata = new HashMap(); metadata.put(InvokerLocator.DATATYPE, dataType); Client loaderClient = new Client(loaderLocator); loaderClient.connect(); loaderClient.setMarshaller(loaderMarshaller); loaderClient.setUnMarshaller(loaderUnMarshaller); Object obj = null; obj = loaderClient.invoke(marshallerMethodName, metadata); if(obj != null) { marshaller = (Marshaller) obj; } } catch(Throwable e) { log.error("Error creating remoting client to connect to marhsaller loader.", e); } if(marshaller == null) { log.error("Can not load marshall for loader locator " + loaderLocator + "."); } return marshaller; } /** * Will call on marshall loader server to load unmarshaller for given data type. * * @param loaderLocator converted locator indicating which marhaller loader to call upon. * @param dataType indicates which unmarshaller to get. * @param classByteLoader is the class loader that the new unmarshaller and related classes get loaed into. * @return */ public static UnMarshaller getUnMarshaller(InvokerLocator loaderLocator, String dataType, ClassLoader classByteLoader) { UnMarshaller unmarshaller = null; try { SerializableMarshaller loaderMarshaller = new SerializableMarshaller(); SerializableUnMarshaller loaderUnMarshaller = new SerializableUnMarshaller(); loaderUnMarshaller.setClassLoader(classByteLoader); String serializationType = "java"; Map parameters = loaderLocator.getParameters(); if (parameters != null) { Object o = parameters.get(InvokerLocator.SERIALIZATIONTYPE); if (o == null) { o = parameters.get(InvokerLocator.SERIALIZATIONTYPE_CASED);; } if (o != null) { serializationType = (String) o; } } loaderMarshaller.setSerializationType(serializationType); loaderUnMarshaller.setSerializationType(serializationType); String marshallerMethodName = GET_UNMARSHALLER_METHOD; Map metadata = new HashMap(); metadata.put(InvokerLocator.DATATYPE, dataType); Client loaderClient = new Client(loaderLocator); loaderClient.connect(); loaderClient.setMarshaller(loaderMarshaller); loaderClient.setUnMarshaller(loaderUnMarshaller); Object obj = null; obj = loaderClient.invoke(marshallerMethodName, metadata); if(obj != null) { unmarshaller = (UnMarshaller) obj; } } catch(Throwable e) { log.error("Error creating remoting client to connecto to marhsaller loader.", e); } if(unmarshaller == null) { log.error("Can not load unmarshaller for loader locator " + loaderLocator + "."); } return unmarshaller; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/UnMarshaller.java0000644000175000017500000000453010555353667031546 0ustar twernertwerner/* * 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.remoting.marshal; import java.io.IOException; import java.io.InputStream; import java.io.Serializable; import java.util.Map; /** * Takes a marshalled byte array and converts to a Java data object. * * @author Tom Elrod */ public interface UnMarshaller extends Serializable { /** * Will read from the inputstream and converty contents to java Object. * * @param inputStream stream to read data from to do conversion. * @param metadata can be any transport specific metadata (such as headers from http transport). * This can be null, depending on if transport supports metadata. * * @return * @throws IOException all specific i/o exceptions need to be thrown as this. * @throws ClassNotFoundException will be thrown if during the unmarshalling process can not find * a specific class within classloader. */ Object read(InputStream inputStream, Map metadata) throws IOException, ClassNotFoundException; /** * Set the class loader to use for unmarhsalling. This may be needed when need to have access to * class definitions that are not part of this unmarshaller's parent classloader (especially * when doing remote classloading). */ void setClassLoader(ClassLoader classloader); UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException; }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/VersionedUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/VersionedUnMarshaller.java0000644000175000017500000000401510623457531033412 0ustar twernertwerner/* * 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.remoting.marshal; import java.io.IOException; import java.io.InputStream; import java.util.Map; /** * @author Ron Sigal * @version $Revision: 2410 $ *

          * Copyright May 7, 2007 *

          */ public interface VersionedUnMarshaller extends SerialUnMarshaller { /** * Will read from the inputstream and converty contents to java Object. * * @param inputStream stream to read data from to do conversion. * @param metadata can be any transport specific metadata (such as headers from http transport). * This can be null, depending on if transport supports metadata. * @param version wire format version * * @return * @throws IOException all specific i/o exceptions need to be thrown as this. * @throws ClassNotFoundException will be thrown if during the unmarshalling process can not find * a specific class within classloader. */ Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/0000755000175000017500000000000011632407044030460 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptionManager.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptionManag0000644000175000017500000001616610774601756033527 0ustar twernertwerner/* * 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.remoting.marshal.encryption; import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap; import org.jboss.logging.Logger; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import java.io.InputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.security.AccessController; import java.security.Key; import java.security.PrivilegedAction; import java.util.Map; //$Id: EncryptionManager.java 3836 2008-04-02 03:56:30Z ron.sigal@jboss.com $ /** * Manager that deals with the generation of the Cipher * Mode: * ECB: Electronic Codebook Mode (NIST FIPS PUB 81) * CBC: Cipher Block Chaining Mode(NIST FIPS PUB 81) * PCBC: Plaintext Cipher Block Chaining (Kerberos) * CFB: Cipher Feedback Mode (NIST FIPS PUB 81) * OFB: Output Feedback Mode (NIST FIPS PUB 81) * Padding: * NoPadding: No padding. PKCS5Padding: RSA, "PKCS #5: Password-Based Encryption Standard," version 1.5, Nov 1993. * @author Anil Saldhana * @since Aug 11, 2006 * @version $Revision: 3836 $ */ public class EncryptionManager { private static Logger log = Logger.getLogger(EncryptionManager.class); private static Map keys = new ConcurrentHashMap(); private static byte[] salt8 = { (byte)0x7e, (byte)0xee, (byte)0xc8, (byte)0xc7, (byte)0x99, (byte)0x73, (byte)0x21, (byte)0x8c}; private static byte[] salt16 = { (byte)0x7e, (byte)0xee, (byte)0xc8, (byte)0xc7, (byte)0x99, (byte)0x73, (byte)0x21, (byte)0x8c, (byte)0x7e, (byte)0xee, (byte)0xc8, (byte)0xc7, (byte)0x99, (byte)0x73, (byte)0x21, (byte)0x8c}; private static IvParameterSpec iv8 = new IvParameterSpec(salt8); private static IvParameterSpec iv16 = new IvParameterSpec(salt16); public static final String TRIPLEDES = "DESede"; public static final String DES = "DES"; public static final String AES = "AES"; public static final String BLOWFISH = "Blowfish"; public static final String RC4 = "RC4"; public static final String DEFAULT_CIPHER_ALGORITHM = DES; static { //Generate Keys for the common algorithms try { keys.put("AES", loadKey(AES)); keys.put("DES", loadKey(DES)); keys.put("DESede", loadKey(TRIPLEDES)); keys.put("Blowfish", loadKey(BLOWFISH)); keys.put("RC4", loadKey(RC4)); } catch (Exception e) { if(log.isTraceEnabled()) log.trace("Exception in loading key",e); } } /** * Generate a Cipher * @param mode Cipher.ENCRYPT_MODE or Cipher.DECRYPT_MODE (Wrap/Unwrap not supported) * @param algo Cipher Algorithm * @return cipher */ public static Cipher getCipher(int mode, String algo) { if(algo == null) algo = DEFAULT_CIPHER_ALGORITHM; Cipher cipher = null; boolean correctMode = (mode == Cipher.ENCRYPT_MODE || mode == Cipher.DECRYPT_MODE); if(!correctMode) throw new IllegalArgumentException("Cipher Mode is wrong"); try { cipher = Cipher.getInstance(algo); Key key = (Key)keys.get(canonicalize(algo)); if(key == null) throw new IllegalStateException("Key is null for algo="+algo); initializeCipher(cipher,key,algo,mode); } catch (Throwable e) { log.error("getCipher failed", e); } return cipher; } /** * Obtain an initialized cipher given the Cipher mode, * algorithm and key * @param mode Cipher.ENCRYPT_MODE or Cipher.DECRYPT_MODE * @param algo * @param key * @return initialized cipher */ public static Cipher getCipher(int mode, String algo, Key key) { Cipher cipher = null; boolean correctMode = (mode == Cipher.ENCRYPT_MODE || mode == Cipher.DECRYPT_MODE); if(!correctMode) throw new IllegalArgumentException("Cipher Mode is wrong"); try { cipher = Cipher.getInstance(algo); initializeCipher(cipher,key,algo,mode); } catch (Throwable e) { if(log.isTraceEnabled()) log.trace("getCipher failed:", e); } return cipher; } /** * Load the serialized key * @param algo * @return * @throws Exception */ private static Key loadKey(String algo) throws Exception { ClassLoader tcl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); String file = "org/jboss/remoting/marshall/encryption/"+algo+".key"; InputStream is = tcl.getResourceAsStream(file); if(is == null) throw new IllegalStateException("Key file is not locatable"); ObjectInput out = new ObjectInputStream(is); Key key = (Key)out.readObject(); out.close(); return key; } //Remove padding etc from the key algo private static String canonicalize(String algo) { if(algo == null) throw new IllegalArgumentException("Null algorithm passed"); String result = algo; if(algo.indexOf("/")> 0) { result = algo.substring(0,algo.indexOf("/")); } return result; } /** * Initialize the Cipher * @param cipher Cipher * @param key Key * @param algo Algorithm * @param mode Cipher Mode * @throws Exception */ private static void initializeCipher(Cipher cipher, Key key, String algo, int mode) throws Exception { //No Padding required if(algo.equals("AES") || algo.equals("DES") || algo.equals("DESede") || algo.equals("RC4") || algo.equals("Blowfish")) cipher.init(mode, key); else if(algo.indexOf("AES") == 0 && algo.indexOf("AES/ECB") < 0 ) cipher.init(mode, key,iv16); else if(algo.indexOf("/CBC/") > 0 || algo.indexOf("/OFB/") > 0 || algo.indexOf("/PCBC/") > 0 || algo.indexOf("/CFB/") > 0) cipher.init(mode, key,iv8); else cipher.init(mode, key); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptingMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptingMarsh0000644000175000017500000001340510764146370033532 0ustar twernertwerner/* * 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.remoting.marshal.encryption; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.security.Key; import javax.crypto.Cipher; import javax.crypto.CipherOutputStream; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; /** * EncryptingMarshaller and EncryptingMarshaller are a general * purpose encryption based marshaller / decompressing unmarshaller pair * based on Java's Cipher facilities. *

          * EncryptingMarshaller is subclassed from SerializableMarshaller, * and by default it uses super.write() to marshall an object, which is then * encrypted. Optionally, it can wrap any other marshaller and use that instead of * SerializableMarshaller to marshall an object before it is encrypted. * For example, *

          *

          new EncryptingMarshaller(new HTTPMarshaller())
          *

          * will create a marshaller that encrypts the output of an HTTPMarshaller. * * @author Anil Saldhana */ public class EncryptingMarshaller extends SerializableMarshaller { /** The serialVersionUID */ private static final long serialVersionUID = 1L; public final static String DATATYPE = "encrypt"; private Marshaller wrappedMarshaller; private String cipherAlgorithm = EncryptionManager.DEFAULT_CIPHER_ALGORITHM; private Cipher cipher = EncryptionManager.getCipher(Cipher.ENCRYPT_MODE, cipherAlgorithm); /** * Create a new EncryptingMarshaller. */ public EncryptingMarshaller() { } /** * * Create a new EncryptingMarshaller. * * @param algo Cipher Algorithm * @param key Key * @see #setCipherAlgorithm(String) */ public EncryptingMarshaller(String algo, Key key) { cipher = EncryptionManager.getCipher(Cipher.ENCRYPT_MODE, algo, key); } /** * Create a new EncryptingMarshaller. * * @param marshaller A Marshaller which is used to turn objects into byte streams. */ public EncryptingMarshaller(Marshaller marshaller) { wrappedMarshaller = marshaller; } /** * Set the Cipher Algorithm to use * @param algo * @see EncryptionManager#DEFAULT_CIPHER_ALGORITHM */ public void setCipherAlgorithm(String algo) { this.cipherAlgorithm = algo; cipher = EncryptionManager.getCipher(Cipher.ENCRYPT_MODE, this.cipherAlgorithm); } public OutputStream getMarshallingStream(OutputStream outputStream) throws IOException { return outputStream; } /** * Writes encrypted, marshalled form of dataObject to output. * * @param dataObject arbitrary object to be marshalled * @param output OutputStream to which output is to be marshalled * @param version wire format version */ public void write(Object dataObject, OutputStream output, int version) throws IOException { if(cipher == null) throw new IllegalStateException("Cipher is null for algo="+ this.cipherAlgorithm); output.flush(); //EOS intercepts the close() call and does not close the stream EncryptionOutputStream eos = new EncryptionOutputStream(output); CipherOutputStream cos = new CipherOutputStream(eos, cipher); SerializationManager sm = SerializationStreamFactory.getManagerInstance(getSerializationType()); ObjectOutputStream oos = sm.createOutput(cos); if(wrappedMarshaller != null) { if (wrappedMarshaller instanceof VersionedMarshaller) ((VersionedMarshaller) wrappedMarshaller).write(dataObject, oos, version); else wrappedMarshaller.write(dataObject, oos); } else { super.write(dataObject, oos, version); } oos.flush(); //Vagaries of CipherOutputStream which needs a close() to flush at the end cos.close(); //Tests fail without this statement - oos.close() should do it oos.close(); //There is a need to close cos } /** * Returns a EncryptingMarshaller. * * @return a EncryptingMarshaller. * @throws CloneNotSupportedException In practice no exceptions are thrown */ public Marshaller cloneMarshaller() throws CloneNotSupportedException { EncryptingMarshaller em = new EncryptingMarshaller(wrappedMarshaller); em.setCipherAlgorithm(this.cipherAlgorithm); return em; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptionUtil.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptionUtil.0000644000175000017500000000364210473663357033473 0ustar twernertwerner/* * 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.remoting.marshal.encryption; import java.io.Serializable; import javax.crypto.Cipher; import javax.crypto.SealedObject; //$Id: EncryptionUtil.java 1398 2006-08-25 21:09:03Z asaldhana $ /** * Utility for Encryption Needs * @author Anil Saldhana * @since Aug 25, 2006 * @version $Revision: 1398 $ */ public class EncryptionUtil { private static String algo = EncryptionManager.TRIPLEDES; public static Serializable unsealObject(SealedObject so) throws Exception { Cipher ci = EncryptionManager.getCipher(Cipher.DECRYPT_MODE, algo); Serializable ser = (Serializable)so.getObject(ci); return ser; } public static SealedObject sealObject(Serializable ser) throws Exception { Cipher ci = EncryptionManager.getCipher(Cipher.ENCRYPT_MODE, algo); return new SealedObject(ser,ci); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/KeyGeneratorUtil.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/KeyGeneratorUti0000644000175000017500000000473210471376620033477 0ustar twernertwerner/* * 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.remoting.marshal.encryption; import org.jboss.logging.Logger; import javax.crypto.KeyGenerator; import java.io.FileOutputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.security.Key; //$Id: KeyGeneratorUtil.java 1376 2006-08-18 17:49:04Z telrod $ /** * Generates keys * @author Anil Saldhana * @since Aug 14, 2006 * @version $Revision: 1376 $ */ public class KeyGeneratorUtil { protected final static Logger log = Logger.getLogger(KeyGeneratorUtil.class); public void genKeys() throws Exception { getKey("DES"); getKey("DESede"); getKey("AES"); getKey("RC4"); getKey("Blowfish"); } private Key getKey(String algo) { Key key = null; try { KeyGenerator gen = KeyGenerator.getInstance(algo); key = gen.generateKey(); serializeToFile(key,algo); } catch (Exception e) { log.error(e.getMessage(), e); } return key; } private void serializeToFile(Key key, String algo) throws Exception { ObjectOutput out = new ObjectOutputStream(new FileOutputStream(algo+".key")); out.writeObject(key); out.close(); } public static void main(String[] args) { KeyGeneratorUtil u = new KeyGeneratorUtil(); try { u.genKeys(); } catch (Exception e) { e.printStackTrace(); } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptionOutputStream.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptionOutpu0000644000175000017500000000515510470667606033613 0ustar twernertwerner/* * 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.remoting.marshal.encryption; import java.io.IOException; import java.io.OutputStream; //$Id: EncryptionOutputStream.java 1368 2006-08-16 19:18:30Z asaldhana $ /** * OutputStream that is piped into a CipherOutputStream such that * CipherOutputStream.close will not close the underlying stream * @author Anil Saldhana * @since Aug 16, 2006 * @version $Revision: 1368 $ */ public class EncryptionOutputStream extends OutputStream { private OutputStream delegate; public EncryptionOutputStream(OutputStream os) { this.delegate = os; } /** * @see OutputStream#write(int) */ public void write(int a) throws IOException { delegate.write(a); } /** * @see OutputStream#close() */ public void close() throws IOException { //Flush only. Do not close the stream delegate.flush(); } /** * @see OutputStream#flush() */ public void flush() throws IOException { delegate.flush(); } /** * @see OutputStream#write(byte[], int, int) */ public void write(byte[] b, int off, int len) throws IOException { delegate.write(b, off, len); } /** * @see OutputStream#write(byte[]) */ public void write(byte[] b) throws IOException { delegate.write(b); } /** * @see Object#equals(Object) */ public boolean equals(Object obj) { return delegate.equals(obj); } /** * @see Object#hashCode() */ public int hashCode() { return delegate.hashCode(); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptingUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/encryption/EncryptingUnMar0000644000175000017500000001310310764146370033475 0ustar twernertwerner/* * 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.remoting.marshal.encryption; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.util.Map; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; /** * EncryptingMarshaller and EncryptingUnMarshaller are a general * purpose encrypting marshaller / decompressing unmarshaller pair based on * Java's crypto stream facilities. *

          * EncryptingUnMarshaller is subclassed from SerializableUnMarshaller, * and by default it uses super.read() to deserialize an object, once the object has been * decrypted. Optionally, it can wrap any other unmarshaller and use that instead of * SerializableUnMarshaller to unmarshall an encrypted input stream. For example, *

          *

          new EncryptingUnMarshaller(new HTTPUnMarshaller())
          * will create an umarshaller that * uses an HTTPUnMarshaller to restore an unencrypted input stream. * * @author Anil.Saldhana@jboss.org * @version $Revision: 3584 $ */ public class EncryptingUnMarshaller extends SerializableUnMarshaller { /** The serialVersionUID */ private static final long serialVersionUID = 1L; public final static String DATATYPE = "encrypt"; private UnMarshaller wrappedUnMarshaller; private String cipherAlgorithm = EncryptionManager.DEFAULT_CIPHER_ALGORITHM; private Cipher cipher = EncryptionManager.getCipher(Cipher.DECRYPT_MODE, cipherAlgorithm); /** * Create a new EncryptingUnMarshaller. */ public EncryptingUnMarshaller() { } /** * Create a new EncryptingUnMarshaller. * * @param unMarshaller unmarshaller to be used to restore * unencrypted byte stream to original object */ public EncryptingUnMarshaller(UnMarshaller unMarshaller) { wrappedUnMarshaller = unMarshaller; } /** * Set the Cipher Algorithm to use * @param algo * @see EncryptionManager#DEFAULT_CIPHER_ALGORITHM */ public void setCipherAlgorithm(String algo) { this.cipherAlgorithm = algo; cipher = EncryptionManager.getCipher(Cipher.DECRYPT_MODE, this.cipherAlgorithm); } public InputStream getMarshallingStream(InputStream inputStream) throws IOException { return inputStream; } /** * Restores a encrypted, marshalled form of an object to its original state. * * @param inputStream InputStream from which marshalled form is to be retrieved * @param metadata can be any transport specific metadata (such as headers from http transport). * This can be null, depending on if transport supports metadata. * @param version wire format version * @return restored object * @throws IOException if there is a problem reading from inputStream * @throws ClassNotFoundException if there is a problem finding a class needed for unmarshalling */ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { if(cipher == null) throw new IllegalStateException("Cipher is null for algo="+ this.cipherAlgorithm); CipherInputStream cis = new CipherInputStream(inputStream,cipher); SerializationManager sm = SerializationStreamFactory.getManagerInstance(getSerializationType()); ObjectInputStream ois = sm.createRegularInput(cis); Object obj = null; if(wrappedUnMarshaller != null) { if (wrappedUnMarshaller instanceof VersionedUnMarshaller) return ((VersionedUnMarshaller)wrappedUnMarshaller).read(ois, metadata, version); else obj = wrappedUnMarshaller.read(ois, metadata); } else { obj = super.read(ois, metadata, version); } return obj; } /** * Returns a new EncryptingUnMarshaller * * @return a new EncryptingUnMarshaller * @throws CloneNotSupportedException In practice no exceptions are thrown. */ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { EncryptingUnMarshaller um = new EncryptingUnMarshaller(wrappedUnMarshaller); um.setCipherAlgorithm(this.cipherAlgorithm); return um; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallerDecorator.java0000644000175000017500000000341510355142433033070 0ustar twernertwerner/* * 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.remoting.marshal; import java.io.IOException; /** * On RMI invocations we can't use customer Marshallers, but we need to decorate Invocations (or any other objects) * with some data before sending the object. *

          * We could use a ByteArrayOutputStream and ByteArrayInputStream but that would be an expensive operation, * so we decided to keep the needed decoration on an interface. Marshaller implementations could refactor their logic to * the methods defined on this interface so we can have a cheaper marshalling with RMI. * $Id: MarshallerDecorator.java 566 2005-12-30 05:26:51Z telrod $ * * @author Clebert Suconic */ public interface MarshallerDecorator { public Object addDecoration(Object obj) throws IOException; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/SerialUnMarshaller.java0000644000175000017500000000234510355142433032671 0ustar twernertwerner/* * 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.remoting.marshal; /** * @author Tom Elrod */ public interface SerialUnMarshaller extends UnMarshaller { void setSerializationType(String serializationType); String getSerializationType(); }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallLoaderConnector.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallLoaderConnector.ja0000644000175000017500000000236310355142433033352 0ustar twernertwerner/* * 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.remoting.marshal; import org.jboss.remoting.transport.Connector; /** * @author Tom Elrod */ public class MarshallLoaderConnector extends Connector { public MarshallLoaderConnector() { super(true); } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/compress/0000755000175000017500000000000011632407044030121 5ustar twernertwerner././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/compress/CompressingUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/compress/CompressingUnMars0000644000175000017500000001576511236325116033500 0ustar twernertwerner/* * 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.remoting.marshal.compress; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.util.HashMap; import java.util.Map; import java.util.zip.GZIPInputStream; import java.util.zip.Inflater; import org.jboss.remoting.marshal.UnMarshaller; import org.jboss.remoting.marshal.VersionedUnMarshaller; import org.jboss.remoting.marshal.http.HTTPUnMarshaller; import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller; import org.jboss.remoting.serialization.SerializationManager; import org.jboss.remoting.serialization.SerializationStreamFactory; /** * CompressingMarshaller and CompressingUnMarshaller are a general * purpose compressing marshaller / decompressing unmarshaller pair based on Java's GZIP facilities. *

          * CompressingUnMarshaller is subclassed from SerializableUnMarshaller, * and by default it uses super.read() to deserialize an object, once the object has been * uncompressed. Optionally, it can wrap any other unmarshaller and use that instead of * SerializableUnMarshaller to unmarshall an uncompressed input stream. For example, *

          *

          new CompressingUnMarshaller(new HTTPUnMarshaller())
          * will create an umarshaller that * uses an HTTPUnMarshaller to restore an uncompressed input stream. * * @author Ron Sigal * @version $Revision: 5323 $ *

          * Copyright (c) 2005 *

          */ public class CompressingUnMarshaller extends SerializableUnMarshaller { public final static String DATATYPE = "compressible"; private UnMarshaller wrappedUnMarshaller; private static final long serialVersionUID = 3843451434770746776L; /** * Create a new CompressingUnMarshaller. */ public CompressingUnMarshaller() { } /** * Create a new CompressingUnMarshaller. * * @param unMarshaller unmarshaller to be used to restore uncompressed byte stream to original object */ public CompressingUnMarshaller(UnMarshaller unMarshaller) { wrappedUnMarshaller = unMarshaller; } public InputStream getMarshallingStream(InputStream inputStream) throws IOException { SelfCleaningGZipInputStream gzis = new SelfCleaningGZipInputStream(inputStream); DecomposableBufferedInputStream bis = new DecomposableBufferedInputStream(gzis); return bis; } /** * Restores a compressed, marshalled form of an object to its original state. * * @param inputStream InputStream from which marshalled form is to be retrieved * @param metadata can be any transport specific metadata (such as headers from http transport). * This can be null, depending on if transport supports metadata. * @param version wire format version * @return restored object * @throws IOException if there is a problem reading from inputStream * @throws ClassNotFoundException if there is a problem finding a class needed for unmarshalling */ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException { SelfCleaningGZipInputStream gzis = null; DecomposableBufferedInputStream bis = null; if (inputStream instanceof DecomposableBufferedInputStream) { bis = (DecomposableBufferedInputStream) inputStream; gzis = (SelfCleaningGZipInputStream) bis.getWrappedStream(); } else { gzis = new SelfCleaningGZipInputStream(inputStream); bis = new DecomposableBufferedInputStream(gzis); } SerializationManager manager = SerializationStreamFactory.getManagerInstance(getSerializationType()); ObjectInputStream ois = manager.createInput(bis, getClassLoader()); try { if(wrappedUnMarshaller != null) { // HACK for JBREM-927. if (wrappedUnMarshaller instanceof HTTPUnMarshaller) { Map map = new HashMap(); if (metadata != null) map.putAll(metadata); map.put("Content-Length", Integer.toString(Integer.MAX_VALUE)); metadata = map; } if (wrappedUnMarshaller instanceof VersionedUnMarshaller) return ((VersionedUnMarshaller)wrappedUnMarshaller).read(ois, metadata, version); else return wrappedUnMarshaller.read(ois, metadata); } else { return super.read(ois, metadata, version); } } finally { gzis.end(); } } /** * Returns a new CompressingUnMarshaller * * @return a new CompressingUnMarshaller * @throws CloneNotSupportedException In practice no exceptions are thrown. */ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException { return new CompressingUnMarshaller(wrappedUnMarshaller); } /** * @author Doychin Bondzhev */ static class SelfCleaningGZipInputStream extends GZIPInputStream { SelfCleaningGZipInputStream(InputStream in) throws IOException { super(in); } void refreshInflater() { inf = new Inflater(true); crc.reset(); } void end() throws IOException { while(available() > 0) { // This will force input stream to read gzip trailer from input stream read(); } inf.end(); // TO release resources used by native code } } static class DecomposableBufferedInputStream extends BufferedInputStream { DecomposableBufferedInputStream(InputStream in, int size) { super(in, size); } DecomposableBufferedInputStream(InputStream in) { super(in); } InputStream getWrappedStream() { return in; } } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/compress/CompressingMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/compress/CompressingMarsha0000644000175000017500000001431411236325154033475 0ustar twernertwerner/* * 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.remoting.marshal.compress; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.zip.Deflater; import java.util.zip.GZIPOutputStream; import org.jboss.remoting.marshal.Marshaller; import org.jboss.remoting.marshal.VersionedMarshaller; import org.jboss.remoting.marshal.serializable.SerializableMarshaller; import org.jboss.remoting.serialization.SerializationStreamFactory; /** * CompressingMarshaller and CompressingUnMarshaller are a general * purpose compressing marshaller / decompressing unmarshaller pair based on Java's GZIP facilities. *

          * CompressingMarshaller is subclassed from SerializableMarshaller, and by default * it uses super.write() to marshall an object, which is then * compressed. Optionally, it can wrap any other marshaller and use that instead of * SerializableMarshaller to marshall an object before it is compressed. For example, *

          *

          new CompressingMarshaller(new HTTPMarshaller())
          *

          * will create a marshaller that compresses the output of an HTTPMarshaller. * * @author Ron Sigal * @version $Revision: 5324 $ *

          * Copyright (c) 2005 *

          */ public class CompressingMarshaller extends SerializableMarshaller { public final static String DATATYPE = "compressible"; private Marshaller wrappedMarshaller; private static final long serialVersionUID = 8731343309128430753L; /** * Create a new CompressingMarshaller. */ public CompressingMarshaller() { } /** * Create a new CompressingMarshaller. * * @param marshaller A Marshaller which is used to turn objects into byte streams. */ public CompressingMarshaller(Marshaller marshaller) { wrappedMarshaller = marshaller; } public OutputStream getMarshallingStream(OutputStream outputStream) throws IOException { GZIPOutputStream gzos = new SelfCleaningGZipOutputStream(outputStream); DecomposableBufferedOutputStream bos = new DecomposableBufferedOutputStream(gzos); return bos; } /** * Writes compressed, marshalled form of dataObject to output. * * @param dataObject arbitrary object to be marshalled * @param output OutputStream to which output is to be marshalled * @param version wire format version */ public void write(Object dataObject, OutputStream output, int version) throws IOException { SelfCleaningGZipOutputStream gzos = null; DecomposableBufferedOutputStream bos = null; if (output instanceof DecomposableBufferedOutputStream) { bos = (DecomposableBufferedOutputStream) output; gzos = (SelfCleaningGZipOutputStream) bos.getWrappedStream(); gzos.refreshDeflater(); } else { gzos = new SelfCleaningGZipOutputStream(output); bos = new DecomposableBufferedOutputStream(gzos); } ObjectOutputStream oos = SerializationStreamFactory.getManagerInstance(getSerializationType()).createOutput(bos); if(wrappedMarshaller != null) { if (wrappedMarshaller instanceof VersionedMarshaller) ((VersionedMarshaller) wrappedMarshaller).write(dataObject, oos, version); else wrappedMarshaller.write(dataObject, oos); } else { super.write(dataObject, oos, version); } oos.flush(); bos.flush(); gzos.finish(); gzos.flush(); } /** * Returns a CompressingMarshaller. * * @return a CompressingMarshaller. * @throws CloneNotSupportedException In practice no exceptions are thrown */ public Marshaller cloneMarshaller() throws CloneNotSupportedException { return new CompressingMarshaller(wrappedMarshaller); } /** * @author Doychin Bondzhev */ static class SelfCleaningGZipOutputStream extends GZIPOutputStream { boolean used; public SelfCleaningGZipOutputStream(OutputStream out) throws IOException { super(out); } void refreshDeflater() { if (used) { def = new Deflater(Deflater.DEFAULT_COMPRESSION, true); crc.reset(); } else { used = true; } } /** * Writes remaining compressed data to the output stream and closes the underlying stream. * @exception IOException if an I/O error has occurred */ public void finish() throws IOException { super.finish(); def.end(); // This will release all resources used by zlib native code } } static class DecomposableBufferedOutputStream extends BufferedOutputStream { DecomposableBufferedOutputStream(OutputStream out, int size) { super(out, size); } DecomposableBufferedOutputStream(OutputStream out) { super(out); } OutputStream getWrappedStream() { return out; } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/VersionedMarshaller.java0000644000175000017500000000330210623457531033105 0ustar twernertwerner/* * 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.remoting.marshal; import java.io.IOException; import java.io.OutputStream; /** * @author Ron Sigal * @version $Revision: 2410 $ *

          * Copyright May 7, 2007 *

          */ public interface VersionedMarshaller extends SerialMarshaller { /** * Marshaller will need to take the dataObject and convert * into primitive java data types and write to the * given output. * * @param dataObject Object to be writen to output * @param output The data output to write the object * data to. * @param wire format version */ public void write(Object dataObject, OutputStream output, int version) throws IOException; } ././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/InvalidMarshallingResource.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/InvalidMarshallingResource0000644000175000017500000000253510452770174033504 0ustar twernertwerner/* * 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.remoting.marshal; /** * Exception thrown when a valid data marshaller can not be found. * * @author Tom Elrod */ public class InvalidMarshallingResource extends Exception { private static final long serialVersionUID = -4285227353099943697L; public InvalidMarshallingResource(String s) { super(s); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/PreferredStreamMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/PreferredStreamMarshaller.0000644000175000017500000000277510557300735033413 0ustar twernertwernerpackage org.jboss.remoting.marshal; import java.io.IOException; import java.io.OutputStream; import java.util.Map; /** * A PreferedStreamMarshaller can create from a raw OutputStream the * particular OutputStream it prefers to use. * * @author Ron Sigal * @version $Revision: 2000 $ *

          * Copyright (c) Jan 26, 2007 *

          */ public interface PreferredStreamMarshaller extends SerialMarshaller { /** * An application that calls getMarshallingStream() should provide a * basic OutputStream, e.g., SocketOutputStream, which can be wrapped * to provide the facilities desired by the PreferredStreamMarshaller. * * @param outputStream a raw OutputStream * @return the OutputStream to be used for marshalling * @throws IOException if it unable to create OutputStream */ OutputStream getMarshallingStream(OutputStream outputStream) throws IOException; /** * An application that calls getMarshallingStream() should provide a * basic OutputStream, e.g., SocketOutputStream, which can be wrapped * to provide the facilities desired by the PreferredStreamMarshaller. * * @param outputStream a raw OutputStream * @param config a Map with configuration information (e.g., serialization type) * @return the OutputStream to be used for marshalling * @throws IOException if it unable to create OutputStream */ OutputStream getMarshallingStream(OutputStream outputStream, Map config) throws IOException; }././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/PreferredStreamUnMarshaller.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/PreferredStreamUnMarshalle0000644000175000017500000000476410557300735033456 0ustar twernertwerner/* * JBoss, Home of Professional Open Source * Copyright 2006, 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. */ /* * Created on Jan 26, 2007 */ package org.jboss.remoting.marshal; import java.io.IOException; import java.io.InputStream; import java.util.Map; /** * A PreferedStreamUnMarshaller can create from a raw InputStream the * particular InputStream it prefers to use * @author Ron Sigal * @version $Revision: 2000 $ *

          * Copyright (c) Jan 26, 2007 *

          */ public interface PreferredStreamUnMarshaller extends SerialUnMarshaller { /** * An application that calls getMarshallingStream() should provide a * basic InpputStream, e.g., SocketIntputStream, which can be wrapped * to provide the facilities desired by the PreferredStreamUnMarshaller. * * @param inputStream a raw IntputStream * @return the InputStream to be used for marshalling * @throws IOException if unable to create InputStream */ InputStream getMarshallingStream(InputStream inputStream) throws IOException; /** * An application that calls getMarshallingStream() should provide a * basic InpputStream, e.g., SocketIntputStream, which can be wrapped * to provide the facilities desired by the PreferredStreamUnMarshaller. * * @param inputStream a raw IntputStream * @param config a Map with configuration information (e.g., serialization type) * @return the InputStream to be used for marshalling * @throws IOException if unable to create InputStream */ InputStream getMarshallingStream(InputStream inputStream, Map config) throws IOException; }././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallLoaderFactory.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallLoaderFactory.java0000644000175000017500000001166011047247366033370 0ustar twernertwerner/* * 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.remoting.marshal; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.management.MBeanServer; import org.jboss.logging.Logger; import org.jboss.remoting.InvokerLocator; import org.jboss.remoting.transport.Connector; /** * Creates the marshall loader server to process requests from remoting clients to load marshaller/unmarshallers. * * @author Tom Elrod */ public class MarshallLoaderFactory { protected final static Logger log = Logger.getLogger(MarshallLoaderFactory.class); /** * Create a remoting server connector for a marshaller loader based on the specified locator. * The locator must contain at least the port parameter for which the marshaller loader should * listen on. Will return null if can not create the connector. * * @param locator * @param classLoaders * @param mbeanServer * @return */ public static Connector createMarshallLoader(InvokerLocator locator, List classLoaders, MBeanServer mbeanServer) { Connector marshallerConnector = null; try { marshallerConnector = new MarshallLoaderConnector(); marshallerConnector.setInvokerLocator(locator.getLocatorURI()); marshallerConnector.start(); MarshallerLoaderHandler loader = new MarshallerLoaderHandler(classLoaders); marshallerConnector.addInvocationHandler("loader", loader); // Set after Connector.addInvocationHandler(), which also sets MBeanServer. loader.setMBeanServer(mbeanServer); } catch(Exception e) { log.error("Can not create marshaller loader.", e); if(marshallerConnector != null) { try { marshallerConnector.stop(); marshallerConnector.destroy(); } catch(Exception e1) { log.error("Error cleaning up marshaller loader connector.", e1); } } } return marshallerConnector; } /** * Will take regular invoker locator with extra parameters indicating marshall loader configuration (such as port) * and converts to the marshall loader locator. Note: the transport returned will always be socket, as this is * the only transport protocol supported for dynamic marshall loading. * * @param locator * @return */ public static InvokerLocator convertLocator(InvokerLocator locator) { InvokerLocator loaderLocator = null; if(locator != null) { Map params = locator.getParameters(); if(params != null) { String sPort = (String) params.get(InvokerLocator.LOADER_PORT); if(sPort != null) { try { int port = Integer.parseInt(sPort); // Force to be socket, as is only one supported //String transport = locator.getProtocol(); String transport = "socket"; String host = locator.getHost(); String path = locator.getPath(); Map metadata = new HashMap(); metadata.putAll(locator.getParameters()); // need to remove a few marshall related parameters so will not conflict metadata.remove(InvokerLocator.LOADER_PORT); metadata.remove(InvokerLocator.MARSHALLER); metadata.remove(InvokerLocator.UNMARSHALLER); metadata.remove(InvokerLocator.DATATYPE); metadata.remove(InvokerLocator.DATATYPE_CASED); loaderLocator = new InvokerLocator(transport, host, port, path, metadata); } catch(NumberFormatException e) { log.error("Got loader port (" + sPort + ") from locator uri, but was not an number."); } } } } return loaderLocator; } }././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallerLoaderHandler.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallerLoaderHandler.ja0000644000175000017500000002054611060654212033324 0ustar twernertwerner/* * 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.remoting.marshal; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.management.MBeanServer; import org.jboss.logging.Logger; 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.loading.ClassBytes; import org.jboss.remoting.loading.ClassUtil; /** * The invocation handler that receives requests for getting marshallers/unmarshallers and * loading of these and any related classes to remoting client. * * @author Tom Elrod */ public class MarshallerLoaderHandler implements ServerInvocationHandler, MarshallerLoaderConstants { private ServerInvoker invoker = null; private MBeanServer server = null; private List classLoaders; protected final static Logger log = Logger.getLogger(MarshallerLoaderHandler.class); public MarshallerLoaderHandler(List classLoaders) { this.classLoaders = classLoaders; } /** * set the mbean server that the handler can reference * * @param server */ public void setMBeanServer(MBeanServer server) { this.server = server; } /** * set the invoker that owns this handler * * @param invoker */ public void setInvoker(ServerInvoker invoker) { this.invoker = invoker; } /** * called to handle a specific invocation. Please take care to make sure implementations are thread safe and can, * and often will, receive concurrent calls on this method. * * @param invocation * @return * @throws Throwable */ public Object invoke(InvocationRequest invocation) throws Throwable { Object ret = null; Object param = invocation.getParameter(); Map metadMap = invocation.getRequestPayload(); if(metadMap == null) { throw new RuntimeException("Can not load class as invocation request metadat map is null."); } String dataType = (String) metadMap.get(InvokerLocator.DATATYPE); log.debug("MarshallerLoaderHandler received invocation with param of " + param + " and data type of " + dataType); if(GET_MARSHALLER_METHOD.equals(param)) { ret = MarshalFactory.getMarshaller(dataType, invoker.getSerializationType()); } else if(GET_UNMARSHALLER_METHOD.equals(param)) { ret = MarshalFactory.getUnMarshaller(dataType, invoker.getSerializationType()); } else if(LOAD_CLASS_METHOD.equals(param)) { String className = (String) metadMap.get(CLASSNAME); log.debug("MarshallerLoaderHandler: loading class: " + className); if(className != null) { ret = loadClassBytes(className, invoker.getClassLoader()); log.debug("MarshallerLoaderHandler: returning class: " + className + ": " + ret); } else { log.error("Received invocation " + param + " to load class, but metadata map key " + CLASSNAME + " contains a null value for the class name to load."); } } else if(LOAD_MARSHALLER_METHOD.equals(param)) { // load based on data type Marshaller marshaller = MarshalFactory.getMarshaller(dataType, invoker.getSerializationType()); if(marshaller != null) { String className = marshaller.getClass().getName(); ret = loadClassBytes(className, invoker.getClassLoader()); } else { log.warn("Could not find registered marshaller for data type: " + dataType); } } else if(LOAD_UNMARSHALLER_METHOD.equals(param)) { UnMarshaller unmarshaller = MarshalFactory.getUnMarshaller(dataType, invoker.getSerializationType()); if(unmarshaller != null) { String className = unmarshaller.getClass().getName(); ret = loadClassBytes(className, invoker.getClassLoader()); } else { log.warn("Could not find registered unmarshaller for data type: " + dataType); } } else { log.warn("Received invocation with unknown parameter request: " + param); } return ret; } private Object loadClassBytes(String className, ClassLoader classLoader) { ClassBytes classBytes = null; if(className != null) { byte[] classDefinition = ClassUtil.getClassBytes(className, classLoader); if (classDefinition == null && classLoaders != null) { Iterator it = classLoaders.iterator(); while (it.hasNext()) { ClassLoader cl = (ClassLoader) it.next(); log.debug("trying classLoader " + cl); classDefinition = ClassUtil.getClassBytes(className, cl); if (classDefinition != null) { break; } } } if (classDefinition == null) { log.debug("unable to load class " + className); } classBytes = new ClassBytes(className, classDefinition); } return classBytes; } /** * Adds a callback handler that will listen for callbacks from the server invoker handler. * * @param callbackHandler */ public void addListener(InvokerCallbackHandler callbackHandler) { //NO OP as don't won't allow listeners } /** * Removes the callback handler that was listening for callbacks from the server invoker handler. * * @param callbackHandler */ public void removeListener(InvokerCallbackHandler callbackHandler) { //NO OP as don't won't allow listeners } /** * Adapted from org.jboss.mx.loading.RepositoryClassLoader. * * @param cl * @param classname * @return * @throws ClassNotFoundException * @throws IOException */ protected byte[] loadByteCode(ClassLoader cl, String classname) throws ClassNotFoundException, IOException { byte[] bytecode = null; URL classURL = getClassURL(cl, classname); // Load the class bytecode InputStream is = null; try { is = classURL.openStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] tmp = new byte[1024]; int read = 0; while( (read = is.read(tmp)) > 0 ) { baos.write(tmp, 0, read); } bytecode = baos.toByteArray(); } finally { if( is != null ) is.close(); } return bytecode; } /** * Adapted from org.jboss.mx.loading.RepositoryClassLoader. * * @param cl * @param classname * @return * @throws ClassNotFoundException */ private URL getClassURL(ClassLoader cl, String classname) throws ClassNotFoundException { String classRsrcName = classname.replace('.', '/') + ".class"; URL classURL = cl.getResource(classRsrcName); if( classURL == null ) { String msg = "Failed to find: "+classname+" as resource: "+classRsrcName; throw new ClassNotFoundException(msg); } return classURL; } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallerLoaderConstants.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/marshal/MarshallerLoaderConstants.0000644000175000017500000000276010355142433033411 0ustar twernertwerner/* * 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.remoting.marshal; /** * @author Tom Elrod */ public interface MarshallerLoaderConstants { public final String LOAD_MARSHALLER_METHOD = "load_marshaller"; public final String LOAD_UNMARSHALLER_METHOD = "load_unmarshaller"; public final String GET_MARSHALLER_METHOD = "get_marshaller"; public final String GET_UNMARSHALLER_METHOD = "get_unmarshaller"; public final String LOAD_CLASS_METHOD = "load_class"; public final String CLASSNAME = "classname"; } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/loading/0000755000175000017500000000000011632407052026253 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/loading/RemotingClassLoader.java0000644000175000017500000001075611377763324033045 0ustar twernertwerner/* * 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.remoting.loading; import org.jboss.remoting.serialization.ClassLoaderUtility; import org.jboss.logging.Logger; /** * @author Tom Elrod * @version $Revision: 5868 $ */ public class RemotingClassLoader extends ClassLoader { private ClassLoader userClassLoader = null; private int referenceCounter; private boolean parentFirstDelegation; protected static final Logger log = Logger.getLogger(RemotingClassLoader.class); protected static final boolean isTrace = log.isTraceEnabled(); public RemotingClassLoader(ClassLoader remotingClassLoader, ClassLoader userClassLoader) { this(remotingClassLoader, userClassLoader, true); } public RemotingClassLoader(ClassLoader remotingClassLoader, ClassLoader userClassLoader, boolean parentFirstDelegation) { super(remotingClassLoader); this.userClassLoader = userClassLoader; this.parentFirstDelegation = parentFirstDelegation; referenceCounter = 1; } /* * Note: This method is called only from MicroRemoteClientInvoker.invoke() while a lock * on MicroRemoteClientInvoker.class is held. */ public void setUserClassLoader(ClassLoader userClassLoader) throws Exception { if (this.userClassLoader == null) { this.userClassLoader = userClassLoader; } else if (this.userClassLoader != userClassLoader) { throw new Exception("Attempting to change existing userClassLoader"); } referenceCounter++; } /* * Note: This method is called only from MicroRemoteClientInvoker.invoke() while a lock * on MicroRemoteClientInvoker.class is held. */ public void unsetUserClassLoader() { if (--referenceCounter == 0) userClassLoader = null; } public Class loadClass(String name) throws ClassNotFoundException { Class loadedClass = null; ClassLoader parent = getParent(); if (this.parentFirstDelegation || userClassLoader == null) loadedClass = loadClassDelegate(name, parent, userClassLoader); else loadedClass = loadClassDelegate(name, userClassLoader, parent); if(loadedClass == null) { loadedClass = ClassLoaderUtility.loadClass(name, getClass()); } return loadedClass; } /** * Try to load the named class using the primary and secondary class loaders. * @param name - the class name to load * @param primary - the initial class loader to delegate to * @param secondary - the backup class loader to delegate to * @return the loaded class * @throws ClassNotFoundException */ private Class loadClassDelegate(String name, ClassLoader primary, ClassLoader secondary) throws ClassNotFoundException { Class loadedClass = null; try { loadedClass = Class.forName(name, false, primary); } catch(ClassNotFoundException e) { if(isTrace) { log.trace("Could not load class (" + name + ") using primary class loader (" + primary + ")"); } if(secondary != null) { try { loadedClass = Class.forName(name, false, secondary); } catch (ClassNotFoundException e1) { if(isTrace) { log.trace("Could not load class (" + name + ") using secondary class loader (" + secondary + ")"); } } } } return loadedClass; } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/loading/ClassByteClassLoader.java0000644000175000017500000003557211336277426033153 0ustar twernertwerner/* * 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.remoting.loading; import org.jboss.logging.Logger; import org.jboss.remoting.Client; import org.jboss.remoting.util.SecurityUtility; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Collections; import java.util.HashMap; import java.util.Map; /** * ClassByteClassLoader is a classloader that will allow dynamic adding of classes from a remote machine * to be added and visible locally. * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5683 $ */ public class ClassByteClassLoader extends ClassLoader { private static final Logger log = Logger.getLogger(ClassByteClassLoader.class); private final Map loadedClasses = Collections.synchronizedMap(new java.util.HashMap()); private final Map loadedResources = Collections.synchronizedMap(new java.util.HashMap()); private final ReferenceQueue queue = new ReferenceQueue(); private Client loaderClient = null; public ClassByteClassLoader() { super(); } public ClassByteClassLoader(ClassLoader parent) { super(parent); } public void setClientInvoker(Client loaderClient) { this.loaderClient = loaderClient; } /** * Will disconnect loader client if is present. */ public void destroy() { if(loaderClient != null && loaderClient.isConnected()) { loaderClient.disconnect(); } } /** * inner class will keep an local reference to the key * so we can lookup the resource File that we are using * on deletion to ensure we've cleaned it up */ private final class MyRef extends WeakReference { private final String key; MyRef(String key, Object obj) { super(obj); this.key = key; } } /** * clean an individual reference and delete any remaining * resources that are still being referenced by it */ private void clean(MyRef myref) { loadedClasses.remove(myref.key); File f = (File) loadedResources.remove(myref.key); if(f != null) { f.delete(); } myref.clear(); myref = null; } /** * will walk through all objects (if any) in the ReferenceQueue and * make sure we've cleaned up our released class references */ private void performMaintenance() { int count = 0; Reference ref = null; while((ref = queue.poll()) != null) { count++; MyRef myref = (MyRef) ref; clean(myref); } if(count > 0 && log.isTraceEnabled()) { log.trace("ClassByteClassLoader reclaimed " + count + " objects"); } } public String toString() { return "ClassByteClassLoader [" + loadedClasses + "]"; } protected void finalize() throws Throwable { // make sure we're OK on the reference queue performMaintenance(); java.util.Iterator iter = loadedResources.values().iterator(); while(iter.hasNext()) { ((java.io.File) iter.next()).delete(); } loadedResources.clear(); loadedClasses.clear(); super.finalize(); } public Class loadClass(final String className, ClassBytes bytes[]) throws ClassNotFoundException, java.io.IOException { // make sure we're OK on the reference queue performMaintenance(); if(log.isTraceEnabled()) { log.trace("loadClass: " + className + ", bytes: " + bytes); } if(bytes != null) { for(int c = 0; c < bytes.length; c++) { addClass(bytes[c]); } } Class cl = lookupCachedClass(className); if(cl != null) { return cl; } cl = findLoadedClass(className); if(cl != null) { return cl; } cl = Class.forName(className, false, getSystemClassLoaderPrivate()); if(cl != null) { return cl; } cl = Class.forName(className, false, getParent()); if(cl != null) { return cl; } cl = loadFromNetwork(className); if(cl != null) { return cl; } throw new ClassNotFoundException("Could not load class " + className); } private void addClassResource(String name, byte buf[]) throws IOException { // make sure we're OK on the reference queue performMaintenance(); OutputStream out = null; File file = null; try { file = createTempFile("cbc", ".class", true); if(log.isTraceEnabled()) { log.trace("adding resource at: " + name + " to file: " + file); } out = getFileOutputStream(file); out.write(buf); out.flush(); } catch(java.io.IOException ex) { file = null; throw ex; } finally { if(out != null) { try { out.close(); } catch(Exception ig) { } out = null; } if(file != null) { loadedResources.put(name, file); } } } public java.io.InputStream getResourceAsStream(String name) { // make sure we're OK on the reference queue performMaintenance(); String denormalized = name.replace('/', '.').substring(0, name.length() - 6); java.io.File file = (java.io.File) loadedResources.get(denormalized); if(log.isTraceEnabled()) { log.trace("getResourceAsStream =>" + denormalized + " = " + file); } if(file != null && fileExists(file)) { try { InputStream is = getFileInputStream(file); return new java.io.BufferedInputStream(is); } catch(Exception ex) { log.debug("file doesn't exist", ex); } } return super.getResourceAsStream(name); } public Class addClass(ClassBytes classBytes) throws java.io.IOException { // make sure we're OK on the reference queue performMaintenance(); Class cl = null; String name = classBytes.getClassName(); if(loadedClasses.containsKey(name) == false) { byte buf[] = classBytes.getClassBytes(); boolean array = ClassUtil.isArrayClass(name); String cn = (array) ? ClassUtil.getArrayClassPart(name) : name; if(log.isTraceEnabled()) { log.trace(" add class: " + name + ", array?" + array + ", using as: " + cn); } cl = defineClass(cn, buf, 0, buf.length); resolveClass(cl); addClassResource(cn, buf); loadedClasses.put(cn, new MyRef(cn, cl)); } return cl; } /** * lookup a cached class and return null if not found */ private Class lookupCachedClass(String cn) { Class cl = null; MyRef ref = (MyRef) loadedClasses.get(cn); if(ref != null) { // make sure we've not gotten cleared cl = (Class) ref.get(); if(cl == null) { // oops, we've been cleared clean(ref); } } return cl; } /** * Finds the specified class. This method should be overridden * by class loader implementations that follow the new delegation model * for loading classes, and will be called by the loadClass * method after checking the parent class loader for the requested class. * The default implementation throws ClassNotFoundException. * * @param name the name of the class * @return the resulting Class object * @throws ClassNotFoundException if the class could not be found * @since 1.2 */ protected Class findClass(String name) throws ClassNotFoundException { // make sure we're OK on the reference queue performMaintenance(); boolean array = ClassUtil.isArrayClass(name); String cn = (array) ? ClassUtil.getArrayClassPart(name) : name; if(log.isTraceEnabled()) { log.trace("++ loadClass: " + name + ", array?" + array + ", normalized: [" + cn + "]"); } Class cl = lookupCachedClass(cn); // search the mapped classes first if(cl == null) { // search already loaded classes cl = findLoadedClass(cn); } if(cl != null) { if(array) { // we have to create an instance from the Class Part and return the // class ref from it Object obj = java.lang.reflect.Array.newInstance(cl, 1); return obj.getClass(); } return cl; } cl = loadFromNetwork(cn); if(cl != null) { if(log.isTraceEnabled()) { log.trace("Loaded " + cn + " can class is " + cl); } return cl; } if(log.isTraceEnabled()) { log.trace("++ findClass: " + name + " not found, throwing ClassNotFoundException"); } throw new ClassNotFoundException(name); } private Class loadFromNetwork(String className) { Class loadedClass = null; if(loaderClient != null) { String marshallerMethodName = "load_class"; Map metadata = new HashMap(); metadata.put("classname", className); try { if(!loaderClient.isConnected()) { loaderClient.connect(); } log.debug("attempting to load from network: " + className); Object obj = loaderClient.invoke(marshallerMethodName, metadata); log.debug("loaded from network: " + obj); if(obj != null) { if(obj instanceof ClassBytes) { ClassBytes classBytes = (ClassBytes) obj; if (classBytes.getClassBytes() != null) { loadedClass = addClass(classBytes); } else { log.debug("Can not load remote class bytes: server returned null class"); } } else { log.error("Can not load remote class bytes. Returned object (" + obj + ") is not ClassBytes."); } } else { log.error("Can not load remote class bytes."); } } catch(Throwable throwable) { log.error("Error loading remote class.", throwable); } } else { log.trace("Remoting Client for ClassByteClassLoader is null. Can not load class remotely."); } return loadedClass; } static private File createTempFile(final String prefix, final String suffix, final boolean deleteOnExit) throws IOException { if (SecurityUtility.skipAccessControl()) { File file = File.createTempFile(prefix, suffix); if (deleteOnExit) file.deleteOnExit(); return file; } try { return (File)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws IOException { File file = File.createTempFile(prefix, suffix); if (deleteOnExit) file.deleteOnExit(); return file; } }); } catch (PrivilegedActionException e) { throw (IOException) e.getCause(); } } static private boolean fileExists(final File file) { if (file == null) return false; if (SecurityUtility.skipAccessControl()) { return file.exists(); } return ((Boolean)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(file.exists()); } })).booleanValue(); } static private FileInputStream getFileInputStream(final File file) throws FileNotFoundException { if (SecurityUtility.skipAccessControl()) { return new FileInputStream(file); } try { return (FileInputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileInputStream(file); } }); } catch (PrivilegedActionException e) { throw (FileNotFoundException) e.getCause(); } } static private FileOutputStream getFileOutputStream(final File file) throws FileNotFoundException { if (SecurityUtility.skipAccessControl()) { return new FileOutputStream(file); } try { return (FileOutputStream)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws FileNotFoundException { return new FileOutputStream(file); } }); } catch (PrivilegedActionException e) { throw (FileNotFoundException) e.getCause(); } } static private ClassLoader getSystemClassLoaderPrivate() { if (SecurityUtility.skipAccessControl()) { return ClassLoader.getSystemClassLoader(); } return (ClassLoader)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return ClassLoader.getSystemClassLoader(); } }); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClassLoader.javalibjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/loading/ObjectInputStreamWithClass0000644000175000017500000002366711171061047033436 0ustar twernertwerner/* * 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.remoting.loading; import java.io.IOException; import java.io.ObjectInputStream; import java.io.StreamCorruptedException; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.HashMap; import org.jboss.logging.Logger; import org.jboss.remoting.util.SecurityUtility; /** * ObjectInputStreamWithClassLoader * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5003 $ */ public class ObjectInputStreamWithClassLoader extends ObjectInputStream { protected static Method clearMethod; protected static final Logger log = Logger.getLogger(ObjectInputStreamWithClassLoader.class); static { try { clearMethod = getDeclaredMethod(ObjectInputStream.class, "clear", new Class[]{}); } catch (SecurityException e) { log.error(e.getMessage(), e); } catch (NoSuchMethodException e) { log.error(e.getMessage(), e); } } private ClassLoader cl; // EJBTHREE-440 /** table mapping primitive type names to corresponding class objects */ private static final HashMap primClasses = new HashMap(8, 1.0F); static { primClasses.put("boolean", boolean.class); primClasses.put("byte", byte.class); primClasses.put("char", char.class); primClasses.put("short", short.class); primClasses.put("int", int.class); primClasses.put("long", long.class); primClasses.put("float", float.class); primClasses.put("double", double.class); primClasses.put("void", void.class); } /** * Create an ObjectInputStream that reads from the specified InputStream. * The stream header containing the magic number and version number * are read from the stream and verified. This method will block * until the corresponding ObjectOutputStream has written and flushed the * header. * * @param in the underlying InputStream from which to read * @throws java.io.StreamCorruptedException * The version or magic number are * incorrect. * @throws java.io.IOException An exception occurred in the underlying stream. */ public ObjectInputStreamWithClassLoader(java.io.InputStream in, ClassLoader cl) throws IOException, StreamCorruptedException { super(in); this.cl = cl; } /** * Set the classloader that the stream will used when deserializing class. This will * allow plugging in of classloaders based on invocation context. * * @param cl */ public void setClassLoader(ClassLoader cl) { this.cl = cl; } /** * Gets the pluggable classloader that will be used for classloading when deserializing * objects. * * @return */ public ClassLoader getClassLoader() { return cl; } public void clearCache() { try { clearMethod.invoke(this, new Object[]{}); } catch (Throwable e) { log.error(e.getMessage(), e); } } /** * Load the local class equivalent of the specified stream class description. *

          * Subclasses may implement this method to allow classes to be * fetched from an alternate source. *

          * The corresponding method in ObjectOutputStream is * annotateClass. This method will be invoked only once for each * unique class in the stream. This method can be implemented by * subclasses to use an alternate loading mechanism but must * return a Class object. Once returned, the serialVersionUID of the * class is compared to the serialVersionUID of the serialized class. * If there is a mismatch, the deserialization fails and an exception * is raised.

          *

          * By default the class name is resolved relative to the class * that called readObject.

          *

          * Will use the classloader explicitly set if it exists. If it does not exist, * will used its default classloader (that loader this instance).

          * * @param v an instance of class ObjectStreamClass * @return a Class object corresponding to v * @throws java.io.IOException Any of the usual Input/Output exceptions. * @throws java.lang.ClassNotFoundException * If class of * a serialized object cannot be found. */ protected Class resolveClass(java.io.ObjectStreamClass v) throws java.io.IOException, ClassNotFoundException { if(cl == null) { return super.resolveClass(v); } else { // EJBTHREE-440 & JBREM-508 try { return Class.forName(v.getName(), false, cl); } catch(ClassNotFoundException ex) { Class cl = (Class) primClasses.get(v.getName()); if (cl != null) { return cl; } else { throw ex; } } } } /** * Returns a proxy class that implements the interfaces named in a * proxy class descriptor; subclasses may implement this method to * read custom data from the stream along with the descriptors for * dynamic proxy classes, allowing them to use an alternate loading * mechanism for the interfaces and the proxy class. *

          *

          This method is called exactly once for each unique proxy class * descriptor in the stream. *

          *

          The corresponding method in ObjectOutputStream is * annotateProxyClass. For a given subclass of * ObjectInputStream that overrides this method, the * annotateProxyClass method in the corresponding * subclass of ObjectOutputStream must write any data or * objects read by this method. *

          *

          The default implementation of this method in * ObjectInputStream returns the result of calling * Proxy.getProxyClass with the list of * Class objects for the interfaces that are named in * the interfaces parameter. The Class * object for each interface name i is the value * returned by calling *

              *     Class.forName(i, false, loader)
              * 
          * where loader is that of the first non-null class * loader up the execution stack, or null if no non-null * class loaders are on the stack (the same class loader choice used * by the resolveClass method). This same value of * loader is also the class loader passed to * Proxy.getProxyClass. If Proxy.getProxyClass * throws an IllegalArgumentException, * resolveProxyClass will throw a * ClassNotFoundException containing the * IllegalArgumentException. * * @return a proxy class for the specified interfaces * @param interfaces the list of interface names that were * deserialized in the proxy class descriptor * @throws java.io.IOException any exception thrown by the underlying * InputStream * @throws java.lang.ClassNotFoundException if the proxy class or any of the * named interfaces could not be found * @since 1.3 * @see java.io.ObjectOutputStream#annotateProxyClass(java.lang.Class) */ protected Class resolveProxyClass(String[] interfaces) throws java.io.IOException, ClassNotFoundException { if(cl == null) { return super.resolveProxyClass(interfaces); } else { Class[] classObjs = new Class[interfaces.length]; for(int i = 0; i < interfaces.length; i++) { classObjs[i] = Class.forName(interfaces[i], false, cl); } try { return java.lang.reflect.Proxy.getProxyClass(cl, classObjs); } catch(IllegalArgumentException e) { throw new ClassNotFoundException(null, e); } } } static private Method getDeclaredMethod(final Class c, final String name, final Class[] parameterTypes) throws NoSuchMethodException { if (SecurityUtility.skipAccessControl()) { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } try { return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws NoSuchMethodException { Method m = c.getDeclaredMethod(name, parameterTypes); m.setAccessible(true); return m; } }); } catch (PrivilegedActionException e) { throw (NoSuchMethodException) e.getCause(); } } }libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/loading/ClassUtil.java0000644000175000017500000002032611010540154031013 0ustar twernertwerner/* * 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.remoting.loading; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashSet; import java.util.Set; import org.jboss.logging.Logger; /** * ClassUtil is a set of generic class utlities. * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 4145 $ */ public class ClassUtil { protected final static Logger log = Logger.getLogger(ClassUtil.class); public static Object deserialize(ClassBytes cb, ClassLoader cl) throws IOException, ClassNotFoundException { if(cb.getClassBytes() == null) { return null; } java.io.ByteArrayInputStream bis = new java.io.ByteArrayInputStream(cb.getClassBytes()); java.io.ObjectInputStream ois = new ObjectInputStreamWithClassLoader(bis, cl); Object result = ois.readObject(); bis = null; ois = null; return result; } public static Object deserialize(byte buf[]) throws IOException, ClassNotFoundException { ClassLoader cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { ClassLoader loader = Thread.currentThread().getContextClassLoader(); if (loader == null) loader = ClassUtil.class.getClassLoader(); return loader; } }); return deserialize(buf, cl); } public static Object deserialize(byte buf[], ClassLoader cl) throws IOException, ClassNotFoundException { if(buf == null) { return null; } java.io.ByteArrayInputStream bis = new java.io.ByteArrayInputStream(buf); java.io.ObjectInputStream ois = new ObjectInputStreamWithClassLoader(bis, cl); Object result = ois.readObject(); bis = null; ois = null; return result; } public static byte[] serialize(Object obj) throws java.io.IOException { java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(); java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(bos); oos.writeObject(obj); oos.flush(); bos.flush(); byte buf[] = bos.toByteArray(); bos = null; oos = null; return buf; } public static boolean isArrayClass(String className) { return (className.startsWith("[L") && className.endsWith(";")); } public static String getArrayClassPart(String className) { String cn = className; int i = className.indexOf("[L"); if(i > -1) { cn = className.substring(i + 2, className.length() - 1); } return cn; } public static String getPackageName(Class cl) { String n = cl.getName(); int i = n.lastIndexOf("."); return (i > -1) ? n.substring(0, i) : n; } public static String getShortClassName(Class cl) { String n = cl.getName(); int i = n.lastIndexOf("."); return (i > -1) ? n.substring(i + 1) : n; } /** * given a class, recurse its dependency graph and find all its implemented interfaces * * @param clazz * @return array of interfaces */ public static Class[] getInterfacesFor(Class clazz) { // use a set to eliminate duplicates, since you'll get a // java.lang.ClassFormatError: $Proxy8 (Repetitive interface name)) Set set = new HashSet(); addInterfaces(set, clazz); return (Class[]) set.toArray(new Class[set.size()]); } private static void addInterfaces(Set list, Class clazz) { if(clazz != null && clazz != Object.class) { if(clazz.isInterface() && list.contains(clazz) == false) { list.add(clazz); } Class interfaces[] = clazz.getInterfaces(); if(interfaces != null && interfaces.length > 0) { for(int c = 0; c < interfaces.length; c++) { Class interfaceClass = interfaces[c]; if(list.contains(interfaceClass) == false) { list.add(interfaceClass); } addInterfaces(list, interfaceClass); } } addInterfaces(list, clazz.getSuperclass()); } } /** * method is called to retrieve a byte array of a Class for a given class name * * @param className * @return */ public static byte[] getClassBytes(String className, ClassLoader classbyteloader) { String cn = null; if(isArrayClass(className)) { // if requesting an array, of course, that would be found in our class path, so we // need to strip the class data and just return the class part, the other side // will properly load the class as an array cn = getArrayClassPart(className).replace('.', '/') + ".class"; } else { cn = className.replace('.', '/') + ".class"; } if(log.isTraceEnabled()) { log.trace("trying to load class: " + className + " from path: " + cn); } InputStream in = null; ClassLoader cl = classbyteloader; if(cl == null) { cl = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return ClassLoader.getSystemClassLoader(); } }); } if(cl != null) { try { final ClassLoader fcl = cl; final String fcn = cn; in = (InputStream) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return fcl.getResourceAsStream(fcn); } }); } catch (Exception e) { log.error("error getting resource " + cn, e); } if(in != null) { if(log.isTraceEnabled()) { log.trace("looking for classes at: " + cl); } try { byte data[] = read(in); if(log.isTraceEnabled()) { log.trace("found class at classloader: " + cl); } return data; } catch(IOException io) { } finally { if(in != null) { try { in.close(); } catch(Exception ig) { } in = null; } } } } return null; } /** * simple utility method for reading bytes from an input stream * * @param in * @return * @throws IOException */ protected static byte[] read(InputStream in) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); byte buf[] = new byte[4096]; while(true) { int c = in.read(buf); if(c < 0) { break; } out.write(buf, 0, c); } return out.toByteArray(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/loading/ClassBytes.java0000644000175000017500000000341610355142433031176 0ustar twernertwerner/* * 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.remoting.loading; /** * ClassBytes is a serialized object that represents a class name and the class bytes as a byte array. * * @author Jeff Haynie * @version $Revision: 566 $ */ public class ClassBytes implements java.io.Serializable { static final long serialVersionUID = 9163990179051656161L; protected String className; protected byte classBytes[]; public ClassBytes(String className, byte data[]) { this.className = className; this.classBytes = data; } public String toString() { return "ClassBytes [class=" + className + ",value=" + classBytes + "]"; } public String getClassName() { return className; } public byte[] getClassBytes() { return classBytes; } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/loading/CompressedClassBytes.java0000644000175000017500000001624110774601633033232 0ustar twernertwerner/* * 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.remoting.loading; import java.io.Externalizable; import java.io.StreamCorruptedException; import java.security.AccessController; import java.security.PrivilegedAction; /** * CompressedClassBytes is a ClassBytes subclass that compresses * class data, if possible. * * @author Jeff Haynie * @version $Revision: 3835 $ */ public class CompressedClassBytes extends ClassBytes implements Externalizable { static final long serialVersionUID = 5984363018051268886L; private static final boolean DEBUG = ((Boolean) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return new Boolean(Boolean.getBoolean("jboss.remoting.compression.debug")); } })).booleanValue(); private static final int MIN_COMPRESS = ((Integer)AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return Integer.getInteger("jboss.remoting.compression.min", 1000); } })).intValue(); private int compressionLevel; private int compressedSize; private int originalSize; static final int VERSION_5_0 = 500; static final int CURRENT_VERSION = VERSION_5_0; public CompressedClassBytes() { super(null, null); } public CompressedClassBytes(String className, byte data[], int compressionLevel) { super(className, data); this.compressionLevel = compressionLevel; } public static void main(String args[]) { try { String string = new String("Hello,world - this is a test of compression, not sure what will happen. alskjfdalksjflkajsdfljaslkfjaslkdjflksajflkajsfdlkjsalkfjaslkfdjlksajflkasjfdlkajslkfjsalkfjasldfjlksadjflkasjfdlkajdsf"); byte buf [] = org.jboss.remoting.loading.ClassUtil.serialize(string); CompressedClassBytes cb = new CompressedClassBytes("java.lang.String", buf, 9); byte b1[] = org.jboss.remoting.loading.ClassUtil.serialize(cb); ClassLoader classLoader = (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return ClassLoader.getSystemClassLoader(); } }); Object obj = ClassUtil.deserialize(b1, classLoader); } catch (Throwable ex) { ex.printStackTrace(); } } public void readExternal(java.io.ObjectInput in) throws java.io.IOException, ClassNotFoundException { int version = in.readInt(); switch (version) { case VERSION_5_0: { compressionLevel = in.readInt(); originalSize = in.readInt(); compressedSize = in.readInt(); byte buf[] = new byte[compressedSize]; int count = in.read(buf, 0, compressedSize); if (compressedSize != originalSize) { this.classBytes = uncompress(buf); } else { this.classBytes = buf; } if (DEBUG) { System.err.println("<< reading compressed: " + compressedSize + ", original: " + originalSize + ", compressionLevel:" + compressionLevel); } this.className = (String) in.readObject(); break; } default: throw new StreamCorruptedException("Unknown version seen: " + version); } } public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException { out.writeInt(CURRENT_VERSION); out.writeInt(compressionLevel); out.writeInt(classBytes.length); byte compressed [] = compress(classBytes); out.writeInt(compressed.length); out.write(compressed); out.writeObject(className); out.flush(); } /** * Compresses the input data. * * @return null if compression results in larger output. */ public byte[] compress(byte[] input) { // Too small to spend time compressing if (input.length < MIN_COMPRESS) { return input; } java.util.zip.Deflater deflater = new java.util.zip.Deflater(compressionLevel); deflater.setInput(input, 0, input.length); deflater.finish(); byte[] buff = new byte[input.length + 50]; deflater.deflate(buff); int compressedSize = deflater.getTotalOut(); // Did this data compress well? if (deflater.getTotalIn() != input.length) { if (DEBUG) { System.err.println(">> Attempting compression and the data didn't compress well, returning original"); } return input; } if (compressedSize >= input.length - 4) { if (DEBUG) { System.err.println(">> Compressed size is larger than original .. ?"); } return input; } byte[] output = new byte[compressedSize + 4]; System.arraycopy(buff, 0, output, 4, compressedSize); output[0] = (byte) (input.length >> 24); output[1] = (byte) (input.length >> 16); output[2] = (byte) (input.length >> 8); output[3] = (byte) (input.length); if (DEBUG) { System.err.println(">> writing compressed: " + output.length + ", original: " + classBytes.length + ", compressionLevel:" + compressionLevel); } return output; } /** * Un-compresses the input data. * * @throws java.io.IOException if the input is not valid. */ public byte[] uncompress(byte[] input) throws java.io.IOException { try { int uncompressedSize = (((input[0] & 0xff) << 24) + ((input[1] & 0xff) << 16) + ((input[2] & 0xff) << 8) + ((input[3] & 0xff))); java.util.zip.Inflater inflater = new java.util.zip.Inflater(); inflater.setInput(input, 4, input.length - 4); inflater.finished(); byte[] out = new byte[uncompressedSize]; inflater.inflate(out); inflater.reset(); return out; } catch (java.util.zip.DataFormatException e) { throw new java.io.IOException("Input Stream is corrupt: " + e); } } } libjboss-remoting-java-2.5.3.SP1.orig/src/main/org/jboss/remoting/InvokerLocator.java0000644000175000017500000007624411422064425030457 0ustar twernertwerner/* * 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.remoting; import java.io.Serializable; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; import org.jboss.logging.Logger; import org.jboss.remoting.serialization.SerializationStreamFactory; import org.jboss.remoting.transport.ClientInvoker; import org.jboss.remoting.util.SecurityUtility; /** * InvokerLocator is an object that indentifies a specific Invoker on the network, via a unique * locator URI. The locator URI is in the format:

          *

          * protocol://host[:port][/path[?param=value¶m2=value2]]

          *

          * For example, a http based locator might be:

          *

          * http://192.168.10.1:8081

          *

          * An example Socket based locator might be:

          *

          * socket://192.168.10.1:9999

          *

          * An example RMI based locator might be:

          *

          * rmi://localhost

          *

          * NOTE: If no hostname is given (e.g., "socket://:5555"), then the hostname will * automatically be resolved to the outside IP address of the local machine. * If the given hostname is 0.0.0.0 and the system * property "jboss.bind.address" is set, then the hostname will be replaced by the value * associated with 'jboss.bind.address". * * @author Jeff Haynie * @author Tom Elrod * @version $Revision: 5918 $ */ public class InvokerLocator implements Serializable { static final long serialVersionUID; protected static Logger log = Logger.getLogger(InvokerLocator.class); protected static Boolean legacyParsingFlag; protected String protocol; protected String host; protected ArrayList connectHomes = new ArrayList(); protected ArrayList homes = new ArrayList(); protected int port; protected String path; protected String query; protected Map parameters; private String uri; private String originalURL; private Home homeInUse; static { if(Version.getDefaultVersion() == Version.VERSION_1) { serialVersionUID = -2909329895029296248L; } else { serialVersionUID = -4977622166779282521L; } } public static boolean getUseLegacyParsing() { if (legacyParsingFlag == null) return false; return legacyParsingFlag.booleanValue(); } public static void setUseLegacyParsing(boolean flag) { legacyParsingFlag = new Boolean(flag); } /** * Indicates should address binding to all network interfaces (i.e. 0.0.0.0) */ public static final String ANY = "0.0.0.0"; /** * Constant value for server bind address system property. Value is 'jboss.bind.address'. */ private static final String SERVER_BIND_ADDRESS = "jboss.bind.address"; /** * Public key to use when want to specify that locator look up local address by * IP or host name. */ public static final String BIND_BY_HOST = "remoting.bind_by_host"; /** * Constant to define the param name to be used when defining the data type. */ public static final String DATATYPE = "datatype"; public static final String DATATYPE_CASED = "dataType"; /** * Constant to define the param name to be used when defining the serialization type. */ public static final String SERIALIZATIONTYPE = "serializationtype"; public static final String SERIALIZATIONTYPE_CASED = "serializationType"; /** * Constant to define the param name to be used when defining the marshaller fully qualified classname */ public static final String MARSHALLER = "marshaller"; /** * Constant to define the param name to be used when defining the unmarshaller fully qualified classname */ public static final String UNMARSHALLER = "unmarshaller"; /** * Constant to define what port the marshalling loader port resides on. */ public static final String LOADER_PORT = "loaderport"; /** * Constant to define the param name to be used when defining if marshalling should be by value, * which means will be using local client invoker with cloning of payload value. */ public static final String BYVALUE = "byvalue"; /** * Constant to define the param name to be used when defining if marshalling should use * remote client invoker instead of using local client invoker (even though both client and * server invokers are within same JVM). */ public static final String FORCE_REMOTE = "force_remote"; /** * Constant to define if client should try to automatically establish a * lease with the server. Value for this parameter key should be either 'true' or 'false'. */ public static final String CLIENT_LEASE = "leasing"; /** * Constant to define what the client lease period should be in the case that * server side leasing is turned on. Value for this parameter key should be the number * of milliseconds to wait before each client lease renewal and must be greater than zero * in order to be recognized. */ public static final String CLIENT_LEASE_PERIOD = "lease_period"; /** * Constant to define if InvokerLocator should use the old (ad hoc) parsing * algorithm instead of the new, URI based, parsing algorithm. */ public static final String LEGACY_PARSING = "legacyParsing"; /** * Serves as placeholder in host position when multiple hosts are given in the * query part by way of the parameter "hosts". E.g. *

          * socket://multihome:8888/?hosts=host1.jboss.org:host2.jboss.org */ public static final String MULTIHOME = "multihome"; /** * Parameter key used for specifying multiple homes to connect to. E.g. *

          * socket://multihome/?connecthomes=host1.jboss.org:7777!host2.jboss.org:8888 */ public static final String CONNECT_HOMES_KEY = "connecthomes"; /** * Parameter key used for specifying multiple binding homes. E.g. *

          * socket://multihome/?homes=a.org:66!b.org:77&homes=c.org:88!d.org:99 */ public static final String HOMES_KEY = "homes"; /** * Parameter key used for specifying default connecting port for * multihome InvokerLocator. */ public static final String DEFAULT_CONNECT_PORT = "defaultConnectPort"; /** * Parameter key used for specifying default server bind port for * multihme InvokerLocator. */ public static final String DEFAULT_PORT = "defaultPort"; /** * Constant to determine if warning about null host should be logged. */ public static final String SUPPRESS_HOST_WARNING = "suppressHostWarning"; /** * InvokerLocator leaves address 0.0.0.0 unchanged. Once serverBindAddress has been * extracted from the InvokerLocator, it is necessary to transform 0.0.0.0 into an * address that contacted over the network. See JBREM-687. */ public static InvokerLocator validateLocator(InvokerLocator locator) throws MalformedURLException { InvokerLocator externalLocator = locator; String host = locator.getHost(); String newHost = null; if(host == null || InvokerLocator.ANY.equals(host)) { // now need to get some external bindable address try { newHost = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { String bindByHost = System.getProperty(InvokerLocator.BIND_BY_HOST, "True"); boolean byHost = Boolean.valueOf(bindByHost).booleanValue(); if(byHost) { return getLocalHost().getHostName(); } else { return getLocalHost().getHostAddress(); } } }); } catch (PrivilegedActionException e) { log.debug("Could not get host by name or address.", e.getCause()); } if(newHost == null) { // now what? step through network interfaces? throw new RuntimeException("Can not determine bindable address for locator (" + locator + ")"); } externalLocator = new InvokerLocator(locator.protocol, newHost, locator.port, locator.getPath(), locator.getParameters()); } return externalLocator; } public static void extractHomes(String homeList, List list, int defaultPort) { StringTokenizer tok = new StringTokenizer(homeList, "!"); while(tok.hasMoreTokens()) { String h = null; int p = -1; String token = tok.nextToken(); boolean isIPv6 = token.indexOf('[') >= 0; int boundary; if (isIPv6) { int pos = token.indexOf(']'); if (pos + 1 == token.length()) boundary = -1; else boundary = token.indexOf(']') + 1; } else { boundary = token.lastIndexOf(':'); } if (boundary > -1) { h = token.substring(0, boundary); try { p = Integer.valueOf(token.substring(boundary + 1)).intValue(); } catch (NumberFormatException e) { log.warn("invalid port value: " + token.substring(boundary + 1)); } } else { h = token; } if (p == -1) p = defaultPort; list.add(new Home(h, p)); } } public static String convertHomesListToString(List homes) { if (homes == null || homes.size() == 0) return ""; Iterator it = homes.iterator(); StringBuffer b = new StringBuffer(((Home) it.next()).toString()); while (it.hasNext()) { b.append("!").append(it.next()); } return b.toString(); } private static final InetAddress LOCAL_HOST; static { try { LOCAL_HOST = (InetAddress) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } }); } catch (PrivilegedActionException e) { log.debug(InvokerLocator.class.getName() + " unable to get local host address", e.getCause()); throw new ExceptionInInitializerError(e.getCause()); } catch (SecurityException e) { log.debug(InvokerLocator.class.getName() + " unable to get local host address", e); throw e; } } private static InetAddress getLocalHost() throws UnknownHostException { if (LOCAL_HOST != null) { return LOCAL_HOST; } try { return InetAddress.getLocalHost(); } catch (UnknownHostException e) { return InetAddress.getByName("127.0.0.1"); } } /** * Constructs the object used to identify a remoting server via simple uri format string (e.g. socket://myhost:7000). * Note: the uri passed may not always be the one returned via call to getLocatorURI() as may need to change if * port not specified, host is 0.0.0.0, etc. If need original uri that is passed to this constructor, need to * call getOriginalURI(). * @param uri * @throws MalformedURLException */ public InvokerLocator(String uri) throws MalformedURLException { originalURL = uri; parse(originalURL); } private void parse(String uriString) throws MalformedURLException { boolean doLegacyParsing = false; if (legacyParsingFlag != null) { doLegacyParsing = legacyParsingFlag.booleanValue(); } else { String s = getSystemProperty(LEGACY_PARSING); doLegacyParsing = "true".equalsIgnoreCase(s); } if (doLegacyParsing) { log.warn("using deprecated legacy URL parsing routine"); legacyParse(uriString); } else { URIParse(uriString); } if (query != null) { StringTokenizer tok = new StringTokenizer(query, "&"); parameters = new TreeMap(); while(tok.hasMoreTokens()) { String token = tok.nextToken(); int eq = token.indexOf("="); String name = (eq > -1) ? token.substring(0, eq) : token; String value = (eq > -1) ? token.substring(eq + 1) : ""; parameters.put(name, value); } } if (!MULTIHOME.equals(host) && parameters != null) { // Use "host:port" to connect. String s = (String) parameters.remove(CONNECT_HOMES_KEY); if (s != null) log.warn("host != " + MULTIHOME + ": " + CONNECT_HOMES_KEY + " will be ignored"); } if (parameters != null) { String homesString = (String) parameters.remove(HOMES_KEY); String connectHomesString = (String) parameters.remove(CONNECT_HOMES_KEY); createHomeLists(parameters, homesString, connectHomesString); } // rebuild it, since the host probably got resolved and the port changed rebuildLocatorURI(); if (!MULTIHOME.equals(host)) { homeInUse = new Home(host, port); connectHomes.add(homeInUse); if (homes.isEmpty()) homes.add(homeInUse); } } private void URIParse(String uriString) throws MalformedURLException { try { URI uri = new URI(encodePercent(uriString)); protocol = uri.getScheme(); checkHost(originalURL, uri.getHost()); host = decodePercent(resolveHost(uri.getHost())); port = uri.getPort(); path = uri.getPath(); query = decodePercent(uri.getQuery()); } catch (URISyntaxException e) { throw new MalformedURLException(e.getMessage()); } } private void legacyParse(String uri) throws MalformedURLException { log.warn("Legacy InvokerLocator parsing is deprecated"); int i = uri.indexOf("://"); if(i < 0) { throw new MalformedURLException("Invalid url " + uri); } String tmp = uri.substring(i + 3); this.protocol = uri.substring(0, i); i = tmp.indexOf("/"); int p = tmp.indexOf(":"); if(i != -1) { p = (p < i ? p : -1); } if(p != -1) { host = resolveHost(tmp.substring(0, p).trim()); if(i > -1) { port = Integer.parseInt(tmp.substring(p + 1, i)); } else { port = Integer.parseInt(tmp.substring(p + 1)); } } else { if(i > -1) { host = resolveHost(tmp.substring(0, i).trim()); } else { host = resolveHost(tmp.substring(0).trim()); } port = -1; } // now look for any path p = tmp.indexOf("?"); if(p != -1) { path = tmp.substring(i + 1, p); query = tmp.substring(p + 1); } else { p = tmp.indexOf("/"); if(p != -1) { path = tmp.substring(p + 1); } else { path = ""; } query = null; } } private static void checkHost(String uri, String host) { if (host == null && !getBoolean(SUPPRESS_HOST_WARNING)) { StringBuffer sb = new StringBuffer("Host resolves to null in "); sb.append(uri).append(". Perhaps the host contains an invalid character. "); sb.append("See http://www.ietf.org/rfc/rfc2396.txt."); log.warn(sb.toString()); } } private static final String resolveHost(String host) { if (host == null) { host = fixRemoteAddress(host); } else if(host.indexOf("0.0.0.0") != -1) { String bindAddress = getSystemProperty(SERVER_BIND_ADDRESS, "0.0.0.0"); if(bindAddress.equals("0.0.0.0")) { host = fixRemoteAddress(host); } else { host = host.replaceAll("0\\.0\\.0\\.0", getSystemProperty(SERVER_BIND_ADDRESS)); } } return host; } private static String fixRemoteAddress(String address) { if(address == null) { try { address = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws UnknownHostException { String bindByHost = System.getProperty(BIND_BY_HOST, "True"); boolean byHost = Boolean.valueOf(bindByHost).booleanValue(); if(byHost) { return getLocalHost().getHostName(); } else { return getLocalHost().getHostAddress(); } } }); } catch (PrivilegedActionException e) { log.debug("error", e.getCause()); } } return address; } private void createHomeLists(Map parameters, String homesString, String connectHomesString) { // DEFAULT_PORT value takes precedence, followed by port value. int defaultPort = port; String s = (String) parameters.get(DEFAULT_PORT); if (s != null && s != "") { try { defaultPort = Integer.parseInt(s); } catch (Exception e) { log.warn("invalid value for " + DEFAULT_PORT + ": " + s); } } if (homesString != null) { extractHomes(homesString, homes, defaultPort); } // DEFAULT_CONNECT_PORT value takes precedence, followed by // DEFAULT_PORT value and then port value. s = (String) parameters.get(DEFAULT_CONNECT_PORT); if (s != null && s != "") { try { defaultPort = Integer.parseInt(s); } catch (Exception e) { log.warn("invalid value for " + DEFAULT_CONNECT_PORT + ": " + s); } } if (connectHomesString != null) { extractHomes(connectHomesString, connectHomes, defaultPort); } } /** * Constructs the object used to identify a remoting server. * @param protocol * @param host * @param port * @param path * @param parameters */ public InvokerLocator(String protocol, String host, int port, String path, Map parameters) { this.protocol = protocol; this.host = resolveHost(host); this.port = port; this.path = path == null ? "" : path; this.parameters = parameters == null ? new TreeMap() : new TreeMap(parameters); if (this.parameters != null) { String homesString = (String) this.parameters.remove(HOMES_KEY); String connectHomesString = (String) this.parameters.remove(CONNECT_HOMES_KEY); createHomeLists(this.parameters, homesString, connectHomesString); } // Test for IPv6 host address. if (this.host != null && this.host.indexOf(":") >= 0 && this.host.indexOf("[") == -1) { this.host = "[" + this.host + "]"; } rebuildLocatorURI(); originalURL = uri; if (!MULTIHOME.equals(host)) { homeInUse = new Home(host, port); homes.add(homeInUse); connectHomes.add(homeInUse); if (parameters != null) { // Use "host:port" to connect. String s = (String) parameters.remove(CONNECT_HOMES_KEY); if (s != null) log.warn("host != " + MULTIHOME + ": " + CONNECT_HOMES_KEY + " will be ignored"); } } } public int hashCode() { return uri.hashCode(); } /** * Compares to see if Object passed is of type InvokerLocator and * it's internal locator uri hashcode is same as this one. Note, this * means is testing to see if not only the host, protocol, and port are the * same, but the path and parameters as well. Therefore 'socket://localhost:9000' * and 'socket://localhost:9000/foobar' would NOT be considered equal. * @param obj * @return */ public boolean equals(Object obj) { return obj != null && obj instanceof InvokerLocator && uri.equals(((InvokerLocator)obj).getLocatorURI()); } /** * Compares to see if InvokerLocator passed represents the same physical remoting server * endpoint as this one. Unlike the equals() method, this just tests to see if protocol, host, * and port are the same and ignores the path and parameters. * @param compareMe * @return */ public boolean isSameEndpoint(InvokerLocator compareMe) { return compareMe != null && getProtocol().equalsIgnoreCase(compareMe.getProtocol()) && getHost().equalsIgnoreCase(compareMe.getHost()) && getPort() == compareMe.getPort(); } public boolean isCompatibleWith(InvokerLocator other) { if (other == null) return false; // If this or other comes from pre-2.4.0 Remoting. if (homes == null || other.homes == null) return false; boolean result1 = getProtocol().equalsIgnoreCase(other.getProtocol()) && path.equals(other.getPath()) && parameters.equals(other.getParameters()); ArrayList tempHomes = connectHomes.isEmpty() ? homes : connectHomes; boolean result2 = intersects(tempHomes, other.getConnectHomeList()) || intersects(tempHomes, other.getHomeList()); return result1 && result2; } /** * return the locator URI, in the format:

          *

          * protocol://host[:port][/path[?param=value¶m2=value2]] * Note, this may not be the same as the original uri passed as parameter to the constructor. * @return */ public String getLocatorURI() { return uri; } public String getProtocol() { return protocol; } public String getHost() { if (host.equals(MULTIHOME) && homeInUse != null) return homeInUse.host; return host; } public String getActualHost() { return host; } public boolean isMultihome() { return MULTIHOME.equals(host); } public String getConnectHomes() { return convertHomesListToString(connectHomes); } public List getConnectHomeList() { if (connectHomes == null) { ArrayList list = new ArrayList(); list.add(new Home(host, port)); return list; } return new ArrayList(connectHomes); } public void setConnectHomeList(List connectHomes) { if (connectHomes == null) this.connectHomes = new ArrayList(); else this.connectHomes = new ArrayList(connectHomes); rebuildLocatorURI(); } public Home getHomeInUse() { if (homeInUse != null || isMultihome()) return homeInUse; return new Home(host, port); } public void setHomeInUse(Home homeInUse) { this.homeInUse = homeInUse; } public String getHomes() { return convertHomesListToString(homes); } public List getHomeList() { if (homes == null) { ArrayList list = new ArrayList(); list.add(new Home(host, port)); return new ArrayList(); } return new ArrayList(homes); } public void setHomeList(List homes) { if (homes == null) this.homes = new ArrayList(); else this.homes = new ArrayList(homes); rebuildLocatorURI(); } public int getPort() { if (host.equals(MULTIHOME) && homeInUse != null) return homeInUse.port; return port; } public int getActualPort() { return port; } public String getPath() { return path; } public Map getParameters() { if (parameters == null) { parameters = new TreeMap(); } return parameters; } public String toString() { return "InvokerLocator [" + uri + "]"; } /** * Gets the original uri passed to constructor (if there was one). * @return */ public String getOriginalURI() { return originalURL; } /** * narrow this invoker to a specific RemoteClientInvoker instance * * @return * @throws Exception */ public ClientInvoker narrow() throws Exception { try { return (ClientInvoker) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return InvokerRegistry.createClientInvoker(InvokerLocator.this); } }); } catch (PrivilegedActionException pae) { throw pae.getException(); } } public String findSerializationType() { String serializationTypeLocal = SerializationStreamFactory.JAVA; if(parameters != null) { serializationTypeLocal = (String) parameters.get(SERIALIZATIONTYPE); if(serializationTypeLocal == null) { serializationTypeLocal = (String) parameters.get(InvokerLocator.SERIALIZATIONTYPE_CASED); if(serializationTypeLocal == null) { serializationTypeLocal = SerializationStreamFactory.JAVA; } } } return serializationTypeLocal; } protected boolean intersects(Collection c1, Collection c2) { Iterator it = c1.iterator(); while (it.hasNext()) { if (c2.contains(it.next())) return true; } return false; } protected void rebuildLocatorURI() { String portPart = (port > -1) ? (":" + port) : ""; String divider = path.startsWith("/") ? "" : "/"; String parametersPart = (parameters != null) ? "?" : ""; uri = protocol + "://" + host + portPart + divider + path + parametersPart; if(parameters != null) { if (!homes.isEmpty()) parameters.put(HOMES_KEY, convertHomesListToString(homes)); if (!connectHomes.isEmpty()) parameters.put(CONNECT_HOMES_KEY, convertHomesListToString(connectHomes)); Iterator iter = parameters.keySet().iterator(); while(iter.hasNext()) { String key = (String) iter.next(); String val = (String) parameters.get(key); if ("".equals(val)) { uri += key; } else { uri += key + "=" + val; } if(iter.hasNext()) { uri += "&"; } } parameters.remove(HOMES_KEY); parameters.remove(CONNECT_HOMES_KEY); } } protected static String encodePercent(String s) { if (s == null) return null; StringTokenizer st = new StringTokenizer(s, "%"); StringBuffer sb = new StringBuffer(); int limit = st.countTokens() - 1; for (int i = 0; i < limit; i++) { String token = st.nextToken(); sb.append(token).append("%25"); } sb.append(st.nextToken()); return sb.toString(); } protected static String decodePercent(String s) { if (s == null) return null; StringBuffer sb = new StringBuffer(); int fromIndex = 0; int index = s.indexOf("%25", fromIndex); while (index >= 0) { sb.append(s.substring(fromIndex, index)).append('%'); fromIndex = index + 3; index = s.indexOf("%25", fromIndex); } sb.append(s.substring(fromIndex)); return sb.toString(); } static private String getSystemProperty(final String name, final String defaultValue) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name, defaultValue); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name, defaultValue); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private String getSystemProperty(final String name) { if (SecurityUtility.skipAccessControl()) return System.getProperty(name); String value = null; try { value = (String)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return System.getProperty(name); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value; } static private boolean getBoolean(final String name) { if (SecurityUtility.skipAccessControl()) return Boolean.getBoolean(name); Boolean value = null; try { value = (Boolean)AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return Boolean.valueOf(Boolean.getBoolean(name)); } }); } catch (PrivilegedActionException e) { throw (RuntimeException) e.getCause(); } return value.booleanValue(); } } libjboss-remoting-java-2.5.3.SP1.orig/src/bin/0000755000175000017500000000000011632407052020727 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/bin/runtest0000644000175000017500000000407410556015500022360 0ustar twernertwerner#!/bin/sh # # $Id: runtest 1983 2007-01-25 02:51:44Z ovidiu $ # # Script that runs a single unit test case and allows to easily attach a debugger to it. # # Usage: runtest [-debug|-clientdebug|-serverdebug] # # where: -debug starts this VM in debug mode # -clientdebug starts the JRUnit client VM in debug mode (see ServerLockupTestDriver.java) # -serverddbug starts the JRUnit server VM in debug mode (see ServerLockupTestDriver.java) TARGET_CLASS=org.jboss.test.remoting.callback.exception.CallbackTestCase cygwin=false; case "`uname`" in CYGWIN*) cygwin=true ;; esac if [ $cygwin = true ]; then SEP=";" else SEP=":" fi while [ "$1" != "" ]; do if [ "$1" = "-debug" ]; then if [ $cygwin = false ]; then JAVA_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=12348" else JAVA_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=client" fi elif [ "$1" = "-clientdebug" ]; then JAVA_OPTS="$JAVA_OPTS -Dclientdebug=true" elif [ "$1" = "-serverdebug" ]; then JAVA_OPTS="$JAVA_OPTS -Dserverdebug=true" fi shift done reldir=`dirname $0` java $JAVA_OPTS -cp \ $reldir/../etc${SEP}\ $reldir/../../output/classes${SEP}\ $reldir/../../output/tests/classes${SEP}\ $reldir/../../lib/junit/lib/junit.jar${SEP}\ $reldir/../../lib/jboss/jboss-j2se.jar${SEP}\ $reldir/../../lib/jboss/jboss-common.jar${SEP}\ $reldir/../../lib/jboss/jrunit.jar${SEP}\ $reldir/../../lib/jboss/jboss-jmx.jar${SEP}\ $reldir/../../lib/jboss/jboss-serialization.jar${SEP}\ $reldir/../../lib/apache-log4j/lib/log4j.jar${SEP}\ $reldir/../../lib/sun-servlet/lib/servlet-api.jar${SEP}\ $reldir/../../lib/apache-commons/lib/commons-httpclient.jar${SEP}\ $reldir/../../lib/oswego-concurrent/lib/concurrent.jar${SEP}\ $reldir/../../lib/jgroups/lib/jgroups.jar${SEP}\ $reldir/../../lib/apache-commons/lib/commons-logging-api.jar${SEP}\ $reldir/../../lib/trove/lib/trove.jar${SEP}\ junit.textui.TestRunner $TARGET_CLASS libjboss-remoting-java-2.5.3.SP1.orig/src/etc/0000755000175000017500000000000011632407053020733 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/remoting.security.policy.tests.marshal0000644000175000017500000002261011413660476030445 0ustar twernertwerner// 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. // //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //****************************************************************** //**** Permissions needed by Remoting to run the test suite **** //****************************************************************** //****************************************************************** grant codeBase "file:${build.home}/output/lib/jboss-remoting.jar" { // Permissions to read remotely loaded classes. permission java.io.FilePermission "${build.home}${/}output${/}lib${/}jboss-remoting-loading-tests.jar", "read"; // org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter calls // org.jboss.remoting.util.SystemUtility permission java.util.PropertyPermission "jboss-junit-configuration", "read"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //**************************************************************************** //**** Permissions used by the test suite **** //**** (tests.marshall) **** //**************************************************************************** //**************************************************************************** grant codeBase "file:${build.home}/output/lib/jboss-remoting-tests.jar" { permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}classloader${/}race${/}test.jar", "read"; // Used by the descendents of org.jboss.test.remoting.shutdown.ShutdownTestParent. permission java.io.FilePermission "<>", "execute"; permission java.io.FilePermission "${build.home}${/}output${/}lib${/}jboss-remoting-loading-tests.jar", "read"; permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; permission java.lang.RuntimePermission "enableContextClassLoaderOverride"; permission java.lang.RuntimePermission "createClassLoader"; permission java.lang.RuntimePermission "getClassLoader"; permission java.lang.RuntimePermission "setContextClassLoader"; permission javax.management.MBeanTrustPermission "register"; permission javax.management.MBeanServerPermission "createMBeanServer, findMBeanServer"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.*#-[jboss.remoting:service=invoker,*]", "unregisterMBean, registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[jboss.remoting:type=Connector,*]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf, addNotificationListener"; permission javax.management.MBeanPermission "org.jboss.remoting.network.NetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf, addNotificationListener"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.multicast.MulticastDetector#-[remoting:*]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[jboss:type=serversocketfactory]", "registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent$SelfIdentifyingServerSocketFactory#-[jboss:type=serversocketfactory]", "registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[jboss:type=serversocketfactory2]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[jboss:*]", "invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#-[jboss:type=serversocketfactory2]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.socket.SocketServerInvoker#Configuration[jboss.remoting:service=invoker,*]", "getAttribute"; // This is technically the JNP server, but it seems intentional - note that this might mask other problems though permission java.net.SocketPermission "*:*", "accept, connect, resolve"; // TODO - this stuff ought to be in privileged blocks within the Ant JUnit task permission java.util.PropertyPermission "*", "read, write"; // ugh // Used by org.jboss.test.remoting.marshall.dynamic.remote.http.HTTPMarshallerLoadingTestCase.getExtendedServerClasspath(), // org.jboss.test.remoting.marshall.dynamic.remote.socket.SocketMarshallerLoadingTestCase.getExtendedServerClasspath(). permission java.util.PropertyPermission "loader.path", "read"; // TESTING ONLY - Use with the LoggingSecurityManager to locate needed permissions for the above block // permission java.security.AllPermission; ///////////////////////////////////////////////////////////////////////////////////////////// // TODO - We should use a version of JBoss logging + log4j that does this stuff in privileged blocks permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.properties", "read"; permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.xml", "read"; permission java.io.FilePermission "${build.home}${/}lib${/}apache-log4j${/}lib${/}log4j.jar", "read"; permission java.io.FilePermission "${build.home}${/}output${/}classes${/}-", "read"; permission java.lang.RuntimePermission "accessClassInPackage.*"; permission java.util.PropertyPermission "org.jboss.logging.Logger.pluginClass", "read"; permission java.util.PropertyPermission "log4j.defaultInitOverride", "read"; permission java.util.PropertyPermission "elementAttributeLimit", "read"; permission java.util.PropertyPermission "maxOccurLimit", "read"; permission java.util.PropertyPermission "entityExpansionLimit", "read"; permission java.util.PropertyPermission "javax.xml.parsers.DocumentBuilderFactory", "read"; permission java.util.PropertyPermission "log4j.ignoreTCL", "read"; permission java.util.PropertyPermission "log4j.configuratorClass", "read"; permission java.util.PropertyPermission "log4j.configDebug", "read"; permission java.util.PropertyPermission "log4j.debug", "read"; permission java.util.PropertyPermission "log4j.configuration", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.LogFactory", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.Log", "read"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //****************************************************************** //**** Permissions for third party libraries **** //****************************************************************** //****************************************************************** grant codeBase "file:${build.home}/lib/-" { permission java.security.AllPermission; }; grant codeBase "file:${ant.library.dir}/-" { permission java.security.AllPermission; }; libjboss-remoting-java-2.5.3.SP1.orig/src/etc/example-service.xml0000644000175000017500000005545710415532047024566 0ustar twernertwerner 1 303 304 60000 ${jboss.bind.address} 6666 false 200 30 org.jboss.remoting.callback.CallbackStore callback cst org.jboss.test.remoting.transport.mock.MockServerInvocationHandler jboss.remoting:service=ServerSocketFactory,type=SSL ${jboss.bind.address} 6667 org.jboss.test.remoting.transport.mock.MockServerInvocationHandler jboss.remoting:service=ServerSocketFactory,type=SSL http://${jboss.bind.address}:6668 org.jboss.test.remoting.transport.mock.MockServerInvocationHandler org.jboss.remoting.transport.coyote.ssl.RemotingSSLImplementation jboss.remoting:service=ServerSocketFactory,type=SSL ${jboss.bind.address} 6669 org.jboss.test.remoting.transport.mock.MockServerInvocationHandler jboss.remoting:service=ServerSocketFactory,type=SSL 7000 ${jboss.bind.address} 6670 org.jboss.test.remoting.transport.mock.MockServerInvocationHandler 1 303 304 60000 ${jboss.bind.address} 6666 30 org.jboss.remoting.callback.CallbackStore callback cst org.jboss.test.remoting.transport.mock.MockServerInvocationHandler 224.1.9.2 2411 224.1.9.3 10000 5000 localhost 5555 20 roxanne sparky callback_store cbk false .keystore opensource opensource TLS SunX509 JKS jboss.remoting:service=SocketBuilder,type=SSL libjboss-remoting-java-2.5.3.SP1.orig/src/etc/findbugs.html0000644000175000017500000101250411340253734023426 0ustar twernertwerner FindBugs Report

          FindBugs Report

          Project Information

          Project:

          FindBugs version: 1.3.9

          Code analyzed:

          • C:\cygwin\home\rsigal\workspace.new\JBossRemoting-2.x\output\lib\jboss-remoting.jar



          Metrics

          32630 lines of code analyzed, in 785 classes, in 85 packages.

          Metric Total Density*
          High Priority Warnings 44 1.35
          Medium Priority Warnings 281 8.61
          Total Warnings 325 9.96

          (* Defects per Thousand lines of non-commenting source statements)



          Contents

          Summary

          Warning Type Number
          Bad practice Warnings 36
          Correctness Warnings 30
          Experimental Warnings 2
          Malicious code vulnerability Warnings 69
          Multithreaded correctness Warnings 34
          Performance Warnings 124
          Dodgy Warnings 30
          Total 325

          Warnings

          Click on a warning row to see full context information.

          Bad practice Warnings

          Code Warning
          BC Random object created and used only once in org.jboss.remoting.transport.PortUtil.getRandomStartingPort()
          BC Random object created and used only once in org.jboss.remoting.transporter.DefaultLoadBalancer.selectServer(ArrayList)
          Dm new org.jboss.remoting.samples.chat.client.Chat(String[]) invokes System.exit(...), which shuts down the entire virtual machine
          Dm new org.jboss.remoting.samples.chat.server.ChatManager() invokes System.exit(...), which shuts down the entire virtual machine
          Dm org.jboss.remoting.samples.chat.server.ChatManager.initialize() invokes System.exit(...), which shuts down the entire virtual machine
          Dm org.jboss.remoting.samples.chat.server.ChatManagerLauncher.launchButton_actionPerformed(ActionEvent) invokes System.exit(...), which shuts down the entire virtual machine
          Dm org.jboss.remoting.samples.multiplex.PrimeScenarioExampleClient.runPrimeScenario() invokes System.exit(...), which shuts down the entire virtual machine
          Dm org.jboss.remoting.samples.multiplex.PrimeScenarioExampleClient$AsynchronousThread.run() invokes System.exit(...), which shuts down the entire virtual machine
          Dm org.jboss.remoting.samples.multiplex.PrimeScenarioExampleServer.runPrimeScenario() invokes System.exit(...), which shuts down the entire virtual machine
          Dm org.jboss.remoting.samples.multiplex.PrimeScenarioExampleServer$AsynchronousThread.run() invokes System.exit(...), which shuts down the entire virtual machine
          ES Comparison of String objects using == or != in org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.rule2(String, int)
          HE org.jboss.remoting.InvokerRegistry$ClientInvokerHolder defines equals and uses Object.hashCode()
          HE org.jboss.remoting.samples.http.ComplexObject defines equals and uses Object.hashCode()
          Nm Class org.jboss.remoting.samples.transporter.complex.NoDoctorAvailableException is not derived from an Exception, even though it is named as such
          NP org.jboss.remoting.network.NetworkInstance.equals(Object) does not check for null argument
          NP org.jboss.remoting.transport.socket.ServerAddress.equals(Object) does not check for null argument
          OS org.jboss.remoting.samples.chat.utility.Parameters.getSecondaryParameterSources() may fail to close stream
          RR org.jboss.remoting.transport.multiplex.MultiplexingInputStream.read() ignores result of org.jboss.remoting.transport.multiplex.MultiplexingInputStream.skip(long)
          RR org.jboss.remoting.transport.multiplex.MultiplexingInputStream.read(byte[], int, int) ignores result of org.jboss.remoting.transport.multiplex.MultiplexingInputStream.skip(long)
          RV org.jboss.remoting.loading.ClassByteClassLoader.clean(ClassByteClassLoader$MyRef) ignores exceptional return value of java.io.File.delete()
          RV org.jboss.remoting.loading.ClassByteClassLoader.finalize() ignores exceptional return value of java.io.File.delete()
          RV org.jboss.remoting.samples.stream.StreamingServer$TestStreamInvocationHandler.handleStream(InputStream, InvocationRequest) ignores exceptional return value of java.io.File.createNewFile()
          Se Class org.jboss.remoting.marshal.encryption.EncryptingMarshaller defines non-transient non-serializable instance field cipher
          Se Class org.jboss.remoting.marshal.encryption.EncryptingUnMarshaller defines non-transient non-serializable instance field cipher
          Se Class org.jboss.remoting.marshal.serializable.SerializableUnMarshaller defines non-transient non-serializable instance field customClassLoader
          Se org.jboss.remoting.samples.chat.utility.ReadWriteArrayList$Gate is serializable and an inner class
          Se Class org.jboss.remoting.socketfactory.CreationListenerServerSocketFactory defines non-transient non-serializable instance field listener
          Se Class org.jboss.remoting.socketfactory.CreationListenerSocketFactory defines non-transient non-serializable instance field listener
          Se Class org.jboss.remoting.transport.multiplex.MasterServerSocket defines non-transient non-serializable instance field ss
          Se Class org.jboss.remoting.transport.multiplex.MasterServerSocket defines non-transient non-serializable instance field ssc
          Se Class org.jboss.remoting.transport.multiplex.VirtualServerSocket defines non-transient non-serializable instance field actualSocket
          Se Class org.jboss.remoting.transport.multiplex.VirtualServerSocket defines non-transient non-serializable instance field cis
          Se Class org.jboss.remoting.transport.multiplex.VirtualServerSocket defines non-transient non-serializable instance field dummySocket
          Se Class org.jboss.remoting.transport.multiplex.VirtualServerSocket defines non-transient non-serializable instance field is
          Se Class org.jboss.remoting.transport.multiplex.VirtualServerSocket defines non-transient non-serializable instance field manager
          Se Class org.jboss.remoting.transport.multiplex.VirtualServerSocket defines non-transient non-serializable instance field protocol

          Correctness Warnings

          Code Warning
          MF Field MultiplexClientInvoker.clientSocketClassName masks field in superclass org.jboss.remoting.transport.socket.MicroSocketClientInvoker
          NP callback could be null and is guaranteed to be dereferenced in org.jboss.remoting.callback.ServerInvokerCallbackHandler.handleCallback(Callback, boolean, boolean)
          NP Possible null pointer dereference of Client$ConnectionValidatorKey.metadata in org.jboss.remoting.Client$ConnectionValidatorKey.equals(Object)
          NP Possible null pointer dereference of domainNodes in org.jboss.remoting.detection.AbstractDetector.setConfiguration(Element)
          NP Possible null pointer dereference of Detection.serverInvokers in org.jboss.remoting.detection.Detection.getLocators()
          NP Possible null pointer dereference of ident in org.jboss.remoting.ident.Identity.setDomain(String)
          NP Possible null pointer dereference of customer in org.jboss.remoting.samples.transporter.basic.CustomerProcessorImpl.processCustomer(Customer)
          NP Possible null pointer dereference of customer in org.jboss.remoting.samples.transporter.multiple.CustomerProcessorImpl.processCustomer(Customer)
          NP Possible null pointer dereference of customerProxy in org.jboss.remoting.samples.transporter.proxy.CustomerProcessorImpl.processCustomer(Customer) on exception path
          NP Possible null pointer dereference of handler in org.jboss.remoting.ServerInvoker.removeCallbackListener(String, InvokerCallbackHandler)
          NP Possible null pointer dereference of proxyTypeClass in org.jboss.remoting.transport.http.HTTPClientInvoker.createURLConnection(String, Map)
          NP Possible null pointer dereference of configuration in new org.jboss.remoting.transport.multiplex.MultiplexingManager(InetSocketAddress, int, Map)
          NP Possible null pointer dereference of configuration in new org.jboss.remoting.transport.multiplex.MultiplexingManager(Map)
          NP Possible null pointer dereference of org.jboss.remoting.AbstractInvoker.configuration in org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.getParameters()
          RCN Nullcheck of locator at line 127 of value previously dereferenced in new org.jboss.remoting.AbstractInvoker(InvokerLocator, Map)
          RCN Nullcheck of locator at line 328 of value previously dereferenced in org.jboss.remoting.marshal.MarshalFactory.getMarshaller(InvokerLocator, ClassLoader, Map)
          RCN Nullcheck of locator at line 479 of value previously dereferenced in org.jboss.remoting.marshal.MarshalFactory.getUnMarshaller(InvokerLocator, ClassLoader, Map)
          RCN Nullcheck of configuration at line 471 of value previously dereferenced in org.jboss.remoting.MicroRemoteClientInvoker.establishLease(String, Map, long)
          RCN Nullcheck of Client2Server1.client at line 122 of value previously dereferenced in org.jboss.remoting.samples.multiplex.invoker.Client2Server1.tearDown()
          RCN Nullcheck of Client2Server2.client at line 122 of value previously dereferenced in org.jboss.remoting.samples.multiplex.invoker.Client2Server2.tearDown()
          RCN Nullcheck of Client3Server1.client at line 120 of value previously dereferenced in org.jboss.remoting.samples.multiplex.invoker.Client3Server1.tearDown()
          RCN Nullcheck of Server2Client1.client at line 114 of value previously dereferenced in org.jboss.remoting.samples.multiplex.invoker.Server2Client1.tearDown()
          RCN Nullcheck of Server2Client2.client at line 112 of value previously dereferenced in org.jboss.remoting.samples.multiplex.invoker.Server2Client2.tearDown()
          RCN Nullcheck of Server3Client1.client at line 114 of value previously dereferenced in org.jboss.remoting.samples.multiplex.invoker.Server3Client1.tearDown()
          RCN Nullcheck of MicroSocketClientInvoker.pool at line 435 of value previously dereferenced in org.jboss.remoting.transport.socket.MicroSocketClientInvoker.flushConnectionPool()
          RCN Nullcheck of ServerThread.invoker at line 1020 of value previously dereferenced in org.jboss.remoting.transport.socket.ServerThread.processNewSocket()
          RpC Repeated conditional test in org.jboss.remoting.transport.socket.ServerThread.dorun()
          USELESS_STRING Invocation of toString on bytes in org.jboss.remoting.loading.ClassByteClassLoader.loadClass(String, ClassBytes[])
          USELESS_STRING Invocation of toString on ClassBytes.classBytes in org.jboss.remoting.loading.ClassBytes.toString()
          USELESS_STRING Invocation of toString on params in org.jboss.remoting.ServerInvoker.handleInternalInvocation(InternalInvocation, InvocationRequest, ServerInvocationHandler)

          Experimental Warnings

          Code Warning
          OBL Method org.jboss.remoting.samples.chat.utility.Parameters.getSecondaryParameterSources() may fail to clean up java.io.InputStream
          OBL Method org.jboss.remoting.samples.stream.StreamingServer$TestStreamInvocationHandler.handleStream(InputStream, InvocationRequest) may fail to clean up java.io.OutputStream

          Malicious code vulnerability Warnings

          Code Warning
          EI org.jboss.remoting.detection.Detection.getServerInvokers() may expose internal representation by returning Detection.serverInvokers
          EI org.jboss.remoting.detection.ServerInvokerMetadata.getSubSystems() may expose internal representation by returning ServerInvokerMetadata.subSystems
          EI org.jboss.remoting.invocation.NameBasedInvocation.getSignature() may expose internal representation by returning NameBasedInvocation.sig
          EI org.jboss.remoting.invocation.RemoteInvocation.getParameters() may expose internal representation by returning RemoteInvocation.params
          EI org.jboss.remoting.loading.ClassBytes.getClassBytes() may expose internal representation by returning ClassBytes.classBytes
          EI org.jboss.remoting.network.NetworkInstance.getLocators() may expose internal representation by returning NetworkInstance.locators
          EI org.jboss.remoting.network.NetworkInstance.getServerInvokers() may expose internal representation by returning NetworkInstance.serverInvokers
          EI org.jboss.remoting.network.NetworkNotification.getLocator() may expose internal representation by returning NetworkNotification.locators
          EI org.jboss.remoting.network.NetworkNotification.getServerInvokers() may expose internal representation by returning NetworkNotification.serverInvokers
          EI org.jboss.remoting.samples.chat.client.ChatInfo.get_origin() may expose internal representation by returning ChatInfo.origin
          EI org.jboss.remoting.serialization.impl.java.JavaMarshalledValue.toByteArray() may expose internal representation by returning JavaMarshalledValue.serializedForm
          EI org.jboss.remoting.stream.StreamCallPayload.getParams() may expose internal representation by returning StreamCallPayload.paramArray
          EI org.jboss.remoting.transport.multiplex.SocketId.toByteArray() may expose internal representation by returning SocketId.bytes
          EI org.jboss.remoting.transport.multiplex.utility.ShrinkableByteArrayOutputStream.toByteArray(int) may expose internal representation by returning ShrinkableByteArrayOutputStream.buf
          EI org.jboss.remoting.transport.sslbisocket.SSLBisocketClientInvoker.getEnabledCipherSuites() may expose internal representation by returning SSLBisocketClientInvoker.enabledCipherSuites
          EI org.jboss.remoting.transport.sslbisocket.SSLBisocketClientInvoker.getEnabledProtocols() may expose internal representation by returning SSLBisocketClientInvoker.enabledProtocols
          EI org.jboss.remoting.transport.sslbisocket.SSLBisocketServerInvoker.getEnabledCipherSuites() may expose internal representation by returning SSLBisocketServerInvoker.enabledCipherSuites
          EI org.jboss.remoting.transport.sslbisocket.SSLBisocketServerInvoker.getEnabledProtocols() may expose internal representation by returning SSLBisocketServerInvoker.enabledProtocols
          EI org.jboss.remoting.transport.sslsocket.SSLSocketClientInvoker.getEnabledCipherSuites() may expose internal representation by returning SSLSocketClientInvoker.enabledCipherSuites
          EI org.jboss.remoting.transport.sslsocket.SSLSocketClientInvoker.getEnabledProtocols() may expose internal representation by returning SSLSocketClientInvoker.enabledProtocols
          EI org.jboss.remoting.transport.sslsocket.SSLSocketServerInvoker.getEnabledCipherSuites() may expose internal representation by returning SSLSocketServerInvoker.enabledCipherSuites
          EI org.jboss.remoting.transport.sslsocket.SSLSocketServerInvoker.getEnabledProtocols() may expose internal representation by returning SSLSocketServerInvoker.enabledProtocols
          EI2 new org.jboss.remoting.detection.Detection(Identity, ServerInvokerMetadata[]) may expose internal representation by storing an externally mutable object into Detection.serverInvokers
          EI2 new org.jboss.remoting.detection.ServerInvokerMetadata(InvokerLocator, String[]) may expose internal representation by storing an externally mutable object into ServerInvokerMetadata.subSystems
          EI2 new org.jboss.remoting.invocation.NameBasedInvocation(String, Object[], String[]) may expose internal representation by storing an externally mutable object into NameBasedInvocation.sig
          EI2 new org.jboss.remoting.invocation.RemoteInvocation(String, Object[]) may expose internal representation by storing an externally mutable object into RemoteInvocation.params
          EI2 new org.jboss.remoting.loading.ClassBytes(String, byte[]) may expose internal representation by storing an externally mutable object into ClassBytes.classBytes
          EI2 new org.jboss.remoting.network.NetworkInstance(Identity, InvokerLocator[]) may expose internal representation by storing an externally mutable object into NetworkInstance.locators
          EI2 new org.jboss.remoting.network.NetworkInstance(Identity, ServerInvokerMetadata[]) may expose internal representation by storing an externally mutable object into NetworkInstance.serverInvokers
          EI2 new org.jboss.remoting.network.NetworkNotification(ObjectName, String, Identity, InvokerLocator[]) may expose internal representation by storing an externally mutable object into NetworkNotification.locators
          EI2 new org.jboss.remoting.network.NetworkNotification(ObjectName, String, Identity, ServerInvokerMetadata[]) may expose internal representation by storing an externally mutable object into NetworkNotification.serverInvokers
          EI2 new org.jboss.remoting.samples.chat.client.ChatInfo(String, String, ChatMember, Date, int, int) may expose internal representation by storing an externally mutable object into ChatInfo.origin
          EI2 org.jboss.remoting.samples.chat.client.ChatInfo.set_origin(Date) may expose internal representation by storing an externally mutable object into ChatInfo.origin
          EI2 org.jboss.remoting.samples.http.ComplexObject.setBytes(byte[]) may expose internal representation by storing an externally mutable object into ComplexObject.bytes
          EI2 org.jboss.remoting.stream.StreamCallPayload.setParams(Object[]) may expose internal representation by storing an externally mutable object into StreamCallPayload.paramArray
          EI2 new org.jboss.remoting.transport.multiplex.SocketId(byte[]) may expose internal representation by storing an externally mutable object into SocketId.bytes
          EI2 org.jboss.remoting.transport.sslbisocket.SSLBisocketClientInvoker.setEnabledCipherSuites(String[]) may expose internal representation by storing an externally mutable object into SSLBisocketClientInvoker.enabledCipherSuites
          EI2 org.jboss.remoting.transport.sslbisocket.SSLBisocketClientInvoker.setEnabledProtocols(String[]) may expose internal representation by storing an externally mutable object into SSLBisocketClientInvoker.enabledProtocols
          EI2 org.jboss.remoting.transport.sslbisocket.SSLBisocketServerInvoker.setEnabledCipherSuites(String[]) may expose internal representation by storing an externally mutable object into SSLBisocketServerInvoker.enabledCipherSuites
          EI2 org.jboss.remoting.transport.sslbisocket.SSLBisocketServerInvoker.setEnabledProtocols(String[]) may expose internal representation by storing an externally mutable object into SSLBisocketServerInvoker.enabledProtocols
          EI2 org.jboss.remoting.transport.sslsocket.SSLSocketClientInvoker.setEnabledCipherSuites(String[]) may expose internal representation by storing an externally mutable object into SSLSocketClientInvoker.enabledCipherSuites
          EI2 org.jboss.remoting.transport.sslsocket.SSLSocketClientInvoker.setEnabledProtocols(String[]) may expose internal representation by storing an externally mutable object into SSLSocketClientInvoker.enabledProtocols
          EI2 org.jboss.remoting.transport.sslsocket.SSLSocketServerInvoker.setEnabledCipherSuites(String[]) may expose internal representation by storing an externally mutable object into SSLSocketServerInvoker.enabledCipherSuites
          EI2 org.jboss.remoting.transport.sslsocket.SSLSocketServerInvoker.setEnabledProtocols(String[]) may expose internal representation by storing an externally mutable object into SSLSocketServerInvoker.enabledProtocols
          MS org.jboss.remoting.ident.Identity.DEFAULT_DOMAIN isn't final but should be
          MS org.jboss.remoting.InvokerLocator.legacyParsingFlag should be package protected
          MS org.jboss.remoting.InvokerLocator.log isn't final but should be
          MS org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.clearMethod isn't final but should be
          MS org.jboss.remoting.samples.bisocket.BisocketSampleServer.port isn't final but should be
          MS org.jboss.remoting.samples.config.factories.FactoryConfigSample.log isn't final but should be
          MS org.jboss.remoting.samples.detection.jndi.SimpleDetectorServer.port should be package protected
          MS org.jboss.remoting.samples.detection.jndi.SimpleDetectorServer.transport should be package protected
          MS org.jboss.remoting.samples.detection.jndi.SimpleDetectorServer.host isn't final but should be
          MS org.jboss.remoting.samples.transporter.clustered.server.SocketServer.locatorURI isn't final but should be
          MS org.jboss.remoting.samples.transporter.complex.server.Server.locatorURI isn't final but should be
          MS org.jboss.remoting.samples.transporter.custom.server.SocketServer.locatorURI isn't final but should be
          MS org.jboss.remoting.serialization.impl.java.ClearableObjectOutputStream.PARAMS isn't final but should be
          MS org.jboss.remoting.serialization.impl.java.ClearableObjectOutputStream.clearMethod isn't final but should be
          MS org.jboss.remoting.serialization.impl.java.ClearableObjectOutputStream.log isn't final but should be
          MS org.jboss.remoting.transport.coyote.CoyoteInvoker.receivedInvocationRequest isn't final but should be
          MS org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory.configMaps isn't final but should be
          MS org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory.log isn't final but should be
          MS org.jboss.remoting.transport.rmi.RemotingRMIClientSocketFactory.socketFactories isn't final but should be
          MS org.jboss.remoting.transport.rmi.RMIServerInvoker.RMI_ONEWAY_MARSHALLING isn't final but should be
          MS org.jboss.remoting.transport.socket.SocketServerInvoker.MAX_POOL_SIZE_DEFAULT isn't final but should be
          MS org.jboss.remoting.transport.web.WebServerInvoker.HEADER_SESSION_ID isn't final but should be
          MS org.jboss.remoting.transport.web.WebServerInvoker.HEADER_SUBSYSTEM isn't final but should be
          MS org.jboss.remoting.transport.web.WebUtil.BINARY isn't final but should be
          MS org.jboss.remoting.transport.web.WebUtil.HTML isn't final but should be

          Multithreaded correctness Warnings

          Code Warning
          IS Inconsistent synchronization of org.jboss.remoting.AbstractInvoker.classbyteloader; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.callback.CallbackPoller.reportStatistics; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.callback.DefaultCallbackErrorHandler.callbackHandler; locked 66% of time
          IS Inconsistent synchronization of org.jboss.remoting.callback.DefaultCallbackErrorHandler.handlerSubsystem; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.callback.DefaultCallbackErrorHandler.numOfErrorsAllowed; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.callback.DefaultCallbackErrorHandler.serverInvoker; locked 66% of time
          IS Inconsistent synchronization of org.jboss.remoting.loading.RemotingClassLoader.userClassLoader; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.samples.chat.utility.ShutDownGate.numberOfUsers; locked 87% of time
          IS Inconsistent synchronization of org.jboss.remoting.samples.chat.utility.ShutDownGate.shuttingDown; locked 80% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.bisocket.BisocketServerInvoker$ControlMonitorTimerTask.running; locked 80% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.MultiplexingInputStream.readException; locked 88% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.MultiplexingManager.createdForRemoteServerSocket; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.MultiplexingManager.inputThread; locked 57% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.MultiplexingManager.remoteServerSocketRegistered; locked 71% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.MultiplexingManager.remoteSocketAddress; locked 55% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.MultiplexingManager.socket; locked 81% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.MultiplexingManager$ShutdownManager.shutdown; locked 73% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.MultiplexingManager$ShutdownManager.shutdownRequestInProgress; locked 71% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.multiplex.utility.GrowablePipedInputStream.timeout; locked 75% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.socket.ServerThread.invocationCount; locked 60% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.socket.ServerThread.invoker; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.socket.ServerThread.socket; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.socket.ServerThread.timeout; locked 50% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.socket.SocketServerInvoker.acceptThreads; locked 63% of time
          IS Inconsistent synchronization of org.jboss.remoting.transport.socket.SocketServerInvoker.idleTimerTask; locked 50% of time
          ML org.jboss.remoting.transport.socket.MicroSocketClientInvoker.initPool() synchronizes on updated field MicroSocketClientInvoker.pool
          NN Naked notify in org.jboss.remoting.transport.bisocket.BisocketClientInvoker.handleDisconnect()
          SC new org.jboss.remoting.samples.callback.CallbackServer$SampleInvocationHandler() invokes Thread.start()
          SC new org.jboss.remoting.samples.callback.statistics.CallbackServer$SampleInvocationHandler() invokes Thread.start()
          SC new org.jboss.remoting.samples.multiplex.invoker.MultiplexInvokerServer$SampleInvocationHandler() invokes Thread.start()
          SWL org.jboss.remoting.transport.socket.SocketServerInvoker.refreshServerSocket() calls Thread.sleep() with a lock held
          UW Unconditional wait in org.jboss.remoting.callback.BlockingCallbackStore.add(Serializable)
          Wa Wait not in loop in org.jboss.remoting.callback.BlockingCallbackStore.add(Serializable)
          Wa Wait not in loop in org.jboss.remoting.transport.multiplex.SocketId.getFreePort()

          Performance Warnings

          Code Warning
          Bx Method org.jboss.remoting.callback.CallbackStoreWrapper$9.run() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.callback.statistics.CallbackServer$SampleInvocationHandler.run() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.config.factories.FactoryConfigSample$SampleInvocationHandler.addListener(InvokerCallbackHandler) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.invoker.Client2Server1.makeClientCall() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.invoker.Client2Server2.makeClientCall() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.invoker.Client3Server1.makeClientCall() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.invoker.MultiplexInvokerServer$SampleInvocationHandler.run() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.invoker.Server2Client1.makeClientCall() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.invoker.Server2Client2.makeClientCall() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.invoker.Server3Client1.makeClientCall() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.PrimeScenarioExampleClient.runPrimeScenario() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.multiplex.PrimeScenarioExampleServer$AsynchronousThread.run() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.samples.stream.StreamingServer$TestStreamInvocationHandler.handleStream(InputStream, InvocationRequest) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
          Bx Method org.jboss.remoting.samples.stream.StreamingServer$TestStreamInvocationHandler.invoke(InvocationRequest) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
          Bx Method org.jboss.remoting.ServerInvoker.invoke(InvocationRequest) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
          Bx Method org.jboss.remoting.stream.StreamHandler.mark(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.stream.StreamHandler.skip(long) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
          Bx Method org.jboss.remoting.stream.StreamServer$Handler.invoke(InvocationRequest) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.stream.StreamServer$Handler.invoke(InvocationRequest) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
          Bx Method org.jboss.remoting.transport.bisocket.BisocketServerInvoker.createControlConnection(String, boolean) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.bisocket.BisocketServerInvoker.setSecondaryBindPort(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.bisocket.BisocketServerInvoker.setSecondaryBindPorts(String) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.bisocket.BisocketServerInvoker.setSecondaryConnectPort(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.bisocket.BisocketServerInvoker.setSecondaryConnectPorts(String) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.bisocket.BisocketServerInvoker.setup() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.bisocket.BisocketServerInvoker.start() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.coyote.CoyoteInvoker.addLeaseInfo(ResponseMap) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
          Bx Method org.jboss.remoting.transport.coyote.ssl.RemotingSSLSupport.getKeySize() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.http.HTTPClientInvoker.checkForLeasePing(HttpURLConnection, Object, Map) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.http.HTTPClientInvoker.checkForLeasePing(HttpURLConnection, Object, Map) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
          Bx Method org.jboss.remoting.transport.http.HTTPClientInvoker.getSimulatedTimeout(Map, Map, HttpURLConnection) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.http.HTTPClientInvoker.setChunked(Map, HttpURLConnection) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HttpURLConnection, Object, Map, Marshaller, UnMarshaller) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.http.HTTPClientInvoker$6.run() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setInputBufferSize(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setInputMaxErrors(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setMaxAcceptErrors(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setOutputMaxChunkSize(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setOutputMaxDataSlice(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setOutputMaxTimeSlice(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setOutputMessagePoolSize(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setOutputMessageSize(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setShutdownMonitorPeriod(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setShutdownRefusalsMaximum(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setShutdownRequestTimeout(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setStaticThreadsMonitorPeriod(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.SocketId.freePort(int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.multiplex.SocketId.getFreePort() invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.PortUtil.getFreePort(String) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.socket.MicroSocketClientInvoker.createClientSocket(Socket, int, Map) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.socket.MicroSocketClientInvoker.getConnection(Marshaller, UnMarshaller, boolean, int) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.socket.ServerThread.createServerSocketWrapper(Socket, int, Map) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.socket.SocketClientInvoker.createClientSocket(Socket, int, Map) invokes inefficient new Integer(int) constructor; use Integer.valueOf(int) instead
          Bx Method org.jboss.remoting.transport.web.WebServerInvoker.addLeaseInfo(Map) invokes inefficient new Long(long) constructor; use Long.valueOf(long) instead
          Bx Method org.jboss.remoting.Version.<static initializer>() invokes inefficient new Byte(byte) constructor; use Byte.valueOf(byte) instead
          Dm org.jboss.remoting.callback.CallbackStore$1.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.callback.CallbackStore$2.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.callback.CallbackStore$5.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.callback.CallbackStoreWrapper$5.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.callback.ServerInvokerCallbackHandler$1.run() forces garbage collection; extremely dubious except in benchmarking code
          Dm org.jboss.remoting.callback.ServerInvokerCallbackHandler$2.run() forces garbage collection; extremely dubious except in benchmarking code
          Dm org.jboss.remoting.callback.ServerInvokerCallbackHandler$4.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.ident.Identity$1.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.ident.Identity$2.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.ident.Identity$5.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.ident.Identity$6.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.InvokerLocator.setUseLegacyParsing(boolean) invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.loading.ClassByteClassLoader$2.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.loading.CompressedClassBytes.main(String[]) invokes inefficient new String(String) constructor
          Dm org.jboss.remoting.loading.CompressedClassBytes$1.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.network.NetworkRegistryQuery$1.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.network.NetworkRegistryWrapper$4.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.security.CustomSSLServerSocketFactory$1.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.security.CustomSSLServerSocketFactory$2.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.security.CustomSSLServerSocketFactory$3.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.security.SSLSocketBuilder$2.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.ServerInvoker.invoke(InvocationRequest) invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.stream.StreamServer$Handler.invoke(InvocationRequest) invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.transport.coyote.CoyoteInvoker.<static initializer>() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.transport.coyote.CoyoteInvoker.addLeaseInfo(ResponseMap) invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.transport.coyote.CoyoteInvoker.setProperty(Object, String, String) invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.transport.http.HTTPClientInvoker.checkForLeasePing(HttpURLConnection, Object, Map) invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker$1.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.transport.web.WebServerInvoker.addLeaseInfo(Map) invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          Dm org.jboss.remoting.util.SecurityUtility$1.run() invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead
          SBSC Method org.jboss.remoting.detection.Detection.toString() concatenates strings using + in a loop
          SBSC Method org.jboss.remoting.detection.ServerInvokerMetadata.toString() concatenates strings using + in a loop
          SBSC Method org.jboss.remoting.samples.transporter.complex.Doctor.toString() concatenates strings using + in a loop
          SBSC Method org.jboss.remoting.transport.Connector.getInvokerConfigFromServerConfiguration(Map) concatenates strings using + in a loop
          SBSC Method org.jboss.remoting.transport.Connector.getInvokerConfigFromXML(Map) concatenates strings using + in a loop
          SIC Should org.jboss.remoting.AbstractInvoker$CallbackHandlerHolder be a _static_ inner class?
          SIC Should org.jboss.remoting.AbstractInvoker$CallbackLocatorHolder be a _static_ inner class?
          SIC Should org.jboss.remoting.callback.NullCallbackStore$FailedCallback be a _static_ inner class?
          SIC Should org.jboss.remoting.detection.AbstractDetector$Server be a _static_ inner class?
          SIC Should org.jboss.remoting.loading.ClassByteClassLoader$MyRef be a _static_ inner class?
          SIC Should org.jboss.remoting.samples.callback.CallbackClient$CallbackHandler be a _static_ inner class?
          SIC Should org.jboss.remoting.samples.callback.statistics.CallbackClient$CallbackHandler be a _static_ inner class?
          SIC Should org.jboss.remoting.samples.chat.client.RemoteStrategyRemoting$ChatServerStub be a _static_ inner class?
          SIC Should org.jboss.remoting.samples.multiplex.PrimeScenarioExampleClient$AsynchronousThread be a _static_ inner class?
          SIC Should org.jboss.remoting.samples.multiplex.PrimeScenarioExampleServer$AsynchronousThread be a _static_ inner class?
          SIC Should org.jboss.remoting.security.SSLSocketBuilder$NullStoreURLException be a _static_ inner class?
          SIC Should org.jboss.remoting.ServerInvoker$CallbackContainer be a _static_ inner class?
          SIC Should org.jboss.remoting.transport.bisocket.BisocketServerInvoker$SecondaryServerSocketThread be a _static_ inner class?
          SIC Should org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker$AnyhostVerifier be a _static_ inner class?
          SIC Should org.jboss.remoting.transport.multiplex.VirtualServerSocket$PendingClose be a _static_ inner class?
          SIC Should org.jboss.remoting.transport.multiplex.VirtualSocket$PendingClose be a _static_ inner class?
          SIC Should org.jboss.remoting.transport.multiplex.VirtualSocket$PendingRemoteDisconnect be a _static_ inner class?
          UrF Unread field: org.jboss.remoting.samples.chat.client.LocalStrategy$3.remoteChatServerWrapper
          UrF Unread field: org.jboss.remoting.transport.coyote.InputBuffer.bytesRead
          UrF Unread field: org.jboss.remoting.transport.coyote.InputBuffer.charsRead
          UrF Unread field: org.jboss.remoting.transport.coyote.InputBuffer.inputChunk
          UrF Unread field: org.jboss.remoting.transport.multiplex.InputMultiplexor$MultiGroupInputThread.info
          UrF Unread field: org.jboss.remoting.transport.multiplex.InputMultiplexor$SingleGroupInputThread.debug
          UrF Unread field: org.jboss.remoting.transport.multiplex.InputMultiplexor$SingleGroupInputThread.info
          UrF Unread field: org.jboss.remoting.transport.multiplex.MultiplexingManager$ShutdownManager$ShutdownMonitorTimerTask.cancelled
          WMI Method org.jboss.remoting.ServerInvoker.getMBeanObjectName() makes inefficient use of keySet iterator instead of entrySet iterator
          WMI Method org.jboss.remoting.transport.Connector.configureHandlersFromServerConfiguration() makes inefficient use of keySet iterator instead of entrySet iterator
          WMI Method org.jboss.remoting.transport.Connector.getInvokerConfigFromServerConfiguration(Map) makes inefficient use of keySet iterator instead of entrySet iterator
          WMI Method org.jboss.remoting.transport.Connector.getInvokerConfigFromXML(Map) makes inefficient use of keySet iterator instead of entrySet iterator
          WMI Method org.jboss.remoting.transport.coyote.CoyoteInvoker.setup() makes inefficient use of keySet iterator instead of entrySet iterator
          WMI Method org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HttpURLConnection, Object, Map, Marshaller, UnMarshaller) makes inefficient use of keySet iterator instead of entrySet iterator
          WMI Method org.jboss.remoting.transport.multiplex.Protocol$BackChannelThread.doRun() makes inefficient use of keySet iterator instead of entrySet iterator
          WMI Method org.jboss.remoting.transport.servlet.ServletServerInvoker.processRequest(HttpServletRequest, HttpServletResponse) makes inefficient use of keySet iterator instead of entrySet iterator
          WMI Method org.jboss.remoting.transport.servlet.ServletServerInvoker.processRequest(HttpServletRequest, byte[], HttpServletResponse) makes inefficient use of keySet iterator instead of entrySet iterator

          Dodgy Warnings

          Code Warning
          BC Unchecked/unconfirmed cast from java.net.Socket to javax.net.ssl.SSLSocket in org.jboss.remoting.transport.coyote.ssl.RemotingServerSocketFactory.handshake(Socket)
          BC Unchecked/unconfirmed cast from java.net.Socket to javax.net.ssl.SSLSocket in org.jboss.remoting.transport.coyote.ssl.RemotingSSLImplementation.getSSLSupport(Socket)
          DLS Dead store to obj in org.jboss.remoting.loading.CompressedClassBytes.main(String[])
          DLS Dead store to count in org.jboss.remoting.loading.CompressedClassBytes.readExternal(ObjectInput)
          DLS Dead store to CloseableFrame in org.jboss.remoting.samples.chat.client.CloseableFrame.main(String[])
          DLS Dead store to backChat in org.jboss.remoting.samples.chat.client.TalkFrame.main(String[])
          DLS Dead store to backChat in new org.jboss.remoting.samples.chat.server.CallbackThread(InvokerCallbackHandler, ShutDownGate, ReadWriteArrayList)
          DLS Dead store to chatManagerLauncher in org.jboss.remoting.samples.chat.server.ChatManagerLauncher.main(String[])
          DLS Dead store to locatorURI in org.jboss.remoting.samples.stream.StreamingClient.main(String[])
          DLS Dead store to originalPort in org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setBindingInfo()
          DMI org.jboss.remoting.InvokerLocator.legacyParse(String) invokes substring(0), which returns the original value
          DMI org.jboss.remoting.transport.multiplex.MultiplexServerInvoker.setBindingInfo() invokes substring(0), which returns the original value
          Eq org.jboss.remoting.network.NetworkInstance.equals(Object) is unusual
          IA Ambiguous invocation of either an outer or inherited method java.util.TimerTask.cancel() in org.jboss.remoting.ConnectionValidator$WaitOnConnectionCheckTimerTask.run()
          ICAST integral division result cast to double or float in org.jboss.remoting.callback.ServerInvokerCallbackHandler.isMemLow()
          NP Load of known null value in org.jboss.remoting.Client.addCallbackListener(InvokerCallbackHandler, Map, InvokerLocator, Object)
          NP Possible null pointer dereference in org.jboss.remoting.Client.addConnectionListener(ConnectionListener, Map) due to return value of called method
          NP Load of known null value in org.jboss.remoting.InvokerRegistry.loadClientInvoker(String, InvokerLocator, Map)
          NP Load of known null value in org.jboss.remoting.InvokerRegistry.loadServerInvoker(String, InvokerLocator, Map)
          NP Load of known null value in org.jboss.remoting.transport.http.HTTPClientInvoker.handleConnect()
          REC Exception is caught when Exception is not thrown in org.jboss.remoting.detection.jndi.JNDIDetector.verifyJNDIServer()
          REC Exception is caught when Exception is not thrown in org.jboss.remoting.samples.detection.jndi.SimpleJNDIServer.setupJNDIServer()
          REC Exception is caught when Exception is not thrown in org.jboss.remoting.samples.transporter.custom.server.JNDIServer.main(String[])
          REC Exception is caught when Exception is not thrown in org.jboss.remoting.transport.AddressUtil.checkAddress(String, int)
          REC Exception is caught when Exception is not thrown in org.jboss.remoting.transport.coyote.CoyoteInvoker.setProperty(Object, String, String)
          REC Exception is caught when Exception is not thrown in org.jboss.remoting.transport.coyote.ssl.RemotingSSLSupport.getX509Certificates(SSLSession)
          REC Exception is caught when Exception is not thrown in org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HttpURLConnection, Object, Map, Marshaller, UnMarshaller)
          SA Double assignment of remoteStrategyName in new org.jboss.remoting.samples.chat.client.Chat(String[])
          ST Write to static field org.jboss.remoting.network.NetworkRegistry.singleton from instance method new org.jboss.remoting.network.NetworkRegistry()
          ST Write to static field org.jboss.remoting.transport.multiplex.MultiplexingManager.configuration from instance method org.jboss.remoting.transport.multiplex.MultiplexingManager.initParameters(Map)

          Details

          DMI_RANDOM_USED_ONLY_ONCE: Random object created and used only once

          This code creates a java.util.Random object, uses it to generate one random number, and then discards the Random object. This produces mediocre quality random numbers and is inefficient. If possible, rewrite the code so that the Random object is created once and saved, and each time a new random number is required invoke a method on the existing Random object to obtain it.

          If it is important that the generated Random numbers not be guessable, you must not create a new Random for each random number; the values are too easily guessable. You should strongly consider using a java.security.SecureRandom instead (and avoid allocating a new SecureRandom for each random number needed).

          BC_UNCONFIRMED_CAST: Unchecked/unconfirmed cast

          This cast is unchecked, and not all instances of the type casted from can be cast to the type it is being cast to. Ensure that your program logic ensures that this cast will not fail.

          DM_NUMBER_CTOR: Method invokes inefficient Number constructor; use static valueOf instead

          Using new Integer(int) is guaranteed to always result in a new object whereas Integer.valueOf(int) allows caching of values to be done by the compiler, class library, or JVM. Using of cached values avoids object allocation and the code will be faster.

          Values between -128 and 127 are guaranteed to have corresponding cached instances and using valueOf is approximately 3.5 times faster than using constructor. For values outside the constant range the performance of both styles is the same.

          Unless the class must be compatible with JVMs predating Java 1.5, use either autoboxing or the valueOf() method when creating instances of Long, Integer, Short, Character, and Byte.

          DLS_DEAD_LOCAL_STORE: Dead store to local variable

          This instruction assigns a value to a local variable, but the value is not read or used in any subsequent instruction. Often, this indicates an error, because the value computed is never used.

          Note that Sun's javac compiler often generates dead stores for final local variables. Because FindBugs is a bytecode-based tool, there is no easy way to eliminate these false positives.

          DM_GC: Explicit garbage collection; extremely dubious except in benchmarking code

          Code explicitly invokes garbage collection. Except for specific use in benchmarking, this is very dubious.

          In the past, situations where people have explicitly invoked the garbage collector in routines such as close or finalize methods has led to huge performance black holes. Garbage collection can be expensive. Any situation that forces hundreds or thousands of garbage collections will bring the machine to a crawl.

          DM_BOOLEAN_CTOR: Method invokes inefficient Boolean constructor; use Boolean.valueOf(...) instead

          Creating new instances of java.lang.Boolean wastes memory, since Boolean objects are immutable and there are only two useful values of this type.  Use the Boolean.valueOf() method (or Java 1.5 autoboxing) to create Boolean objects instead.

          DM_STRING_CTOR: Method invokes inefficient new String(String) constructor

          Using the java.lang.String(String) constructor wastes memory because the object so constructed will be functionally indistinguishable from the String passed as a parameter.  Just use the argument String directly.

          DM_EXIT: Method invokes System.exit(...)

          Invoking System.exit shuts down the entire Java virtual machine. This should only been done when it is appropriate. Such calls make it hard or impossible for your code to be invoked by other code. Consider throwing a RuntimeException instead.

          DMI_USELESS_SUBSTRING: Invocation of substring(0), which returns the original value

          This code invokes substring(0) on a String, which returns the original value.

          EI_EXPOSE_REP: May expose internal representation by returning reference to mutable object

          Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Returning a new copy of the object is better approach in many situations.

          EI_EXPOSE_REP2: May expose internal representation by incorporating reference to mutable object

          This code stores a reference to an externally mutable object into the internal representation of the object.  If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Storing a copy of the object is better approach in many situations.

          EQ_UNUSUAL: Unusual equals method

          This class doesn't do any of the patterns we recognize for checking that the type of the argument is compatible with the type of the this object. There might not be anything wrong with this code, but it is worth reviewing.

          ES_COMPARING_STRINGS_WITH_EQ: Comparison of String objects using == or !=

          This code compares java.lang.String objects for reference equality using the == or != operators. Unless both strings are either constants in a source file, or have been interned using the String.intern() method, the same string value may be represented by two different String objects. Consider using the equals(Object) method instead.

          HE_EQUALS_USE_HASHCODE: Class defines equals() and uses Object.hashCode()

          This class overrides equals(Object), but does not override hashCode(), and inherits the implementation of hashCode() from java.lang.Object (which returns the identity hash code, an arbitrary value assigned to the object by the VM).  Therefore, the class is very likely to violate the invariant that equal objects must have equal hashcodes.

          If you don't think instances of this class will ever be inserted into a HashMap/HashTable, the recommended hashCode implementation to use is:

          public int hashCode() {
            assert false : "hashCode not designed";
            return 42; // any arbitrary constant will do 
            }

          IA_AMBIGUOUS_INVOCATION_OF_INHERITED_OR_OUTER_METHOD: Ambiguous invocation of either an inherited or outer method

          An inner class is invoking a method that could be resolved to either a inherited method or a method defined in an outer class. By the Java semantics, it will be resolved to invoke the inherited method, but this may not be want you intend. If you really intend to invoke the inherited method, invoke it by invoking the method on super (e.g., invoke super.foo(17)), and thus it will be clear to other readers of your code and to FindBugs that you want to invoke the inherited method, not the method in the outer class.

          ICAST_IDIV_CAST_TO_DOUBLE: integral division result cast to double or float

          This code casts the result of an integral division (e.g., int or long division) operation to double or float. Doing division on integers truncates the result to the integer value closest to zero. The fact that the result was cast to double suggests that this precision should have been retained. What was probably meant was to cast one or both of the operands to double before performing the division. Here is an example:

          int x = 2;
          int y = 5;
          // Wrong: yields result 0.0
          double value1 =  x / y;
          
          // Right: yields result 0.4
          double value2 =  x / (double) y;
          

          IS2_INCONSISTENT_SYNC: Inconsistent synchronization

          The fields of this class appear to be accessed inconsistently with respect to synchronization.  This bug report indicates that the bug pattern detector judged that

          • The class contains a mix of locked and unlocked accesses,
          • At least one locked access was performed by one of the class's own methods, and
          • The number of unsynchronized field accesses (reads and writes) was no more than one third of all accesses, with writes being weighed twice as high as reads

          A typical bug matching this bug pattern is forgetting to synchronize one of the methods in a class that is intended to be thread-safe.

          You can select the nodes labeled "Unsynchronized access" to show the code locations where the detector believed that a field was accessed without synchronization.

          Note that there are various sources of inaccuracy in this detector; for example, the detector cannot statically detect all situations in which a lock is held.  Also, even when the detector is accurate in distinguishing locked vs. unlocked accesses, the code in question may still be correct.

          MF_CLASS_MASKS_FIELD: Class defines field that masks a superclass field

          This class defines a field with the same name as a visible instance field in a superclass. This is confusing, and may indicate an error if methods update or access one of the fields when they wanted the other.

          ML_SYNC_ON_UPDATED_FIELD: Method synchronizes on an updated field

          This method synchronizes on an object referenced from a mutable field. This is unlikely to have useful semantics, since different threads may be synchronizing on different objects.

          MS_SHOULD_BE_FINAL: Field isn't final but should be

          A mutable static field could be changed by malicious code or by accident from another package. The field could be made final to avoid this vulnerability.

          MS_PKGPROTECT: Field should be package protected

          A mutable static field could be changed by malicious code or by accident. The field could be made package protected to avoid this vulnerability.

          NM_CLASS_NOT_EXCEPTION: Class is not derived from an Exception, even though it is named as such

          This class is not derived from another exception, but ends with 'Exception'. This will be confusing to users of this class.

          NN_NAKED_NOTIFY: Naked notify

          A call to notify() or notifyAll() was made without any (apparent) accompanying modification to mutable object state.  In general, calling a notify method on a monitor is done because some condition another thread is waiting for has become true.  However, for the condition to be meaningful, it must involve a heap object that is visible to both threads.

          This bug does not necessarily indicate an error, since the change to mutable object state may have taken place in a method which then called the method containing the notification.

          NP_EQUALS_SHOULD_HANDLE_NULL_ARGUMENT: equals() method does not check for null argument

          This implementation of equals(Object) violates the contract defined by java.lang.Object.equals() because it does not check for null being passed as the argument. All equals() methods should return false if passed a null value.

          NP_LOAD_OF_KNOWN_NULL_VALUE: Load of known null value

          The variable referenced at this point is known to be null due to an earlier check against null. Although this is valid, it might be a mistake (perhaps you intended to refer to a different variable, or perhaps the earlier check to see if the variable is null should have been a check to see if it was nonnull).

          NP_GUARANTEED_DEREF: Null value is guaranteed to be dereferenced

          There is a statement or branch that if executed guarantees that a value is null at this point, and that value that is guaranteed to be dereferenced (except on forward paths involving runtime exceptions).

          NP_NULL_ON_SOME_PATH: Possible null pointer dereference

          There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception can't ever be executed; deciding that is beyond the ability of FindBugs.

          NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE: Possible null pointer dereference due to return value of called method

          The return value from a method is dereferenced without a null check, and the return value of that method is one that should generally be checked for null. This may lead to a NullPointerException when the code is executed.

          NP_NULL_ON_SOME_PATH_EXCEPTION: Possible null pointer dereference in method on exception path

          A reference value which is null on some exception control path is dereferenced here.  This may lead to a NullPointerException when the code is executed.  Note that because FindBugs currently does not prune infeasible exception paths, this may be a false warning.

          Also note that FindBugs considers the default case of a switch statement to be an exception path, since the default case is often infeasible.

          OBL_UNSATISFIED_OBLIGATION: Method may fail to clean up stream or resource

          This method may fail to clean up (close, dispose of) a stream, database object, or other resource requiring an explicit cleanup operation.

          In general, if a method opens a stream or other resource, the method should use a try/finally block to ensure that the stream or resource is cleaned up before the method returns.

          This bug pattern is essentially the same as the OS_OPEN_STREAM and ODR_OPEN_DATABASE_RESOURCE bug patterns, but is based on a different (and hopefully better) static analysis technique. We are interested is getting feedback about the usefulness of this bug pattern. To send feedback, either:

          In particular, the false-positive suppression heuristics for this bug pattern have not been extensively tuned, so reports about false positives are helpful to us.

          See Weimer and Necula, Finding and Preventing Run-Time Error Handling Mistakes, for a description of the analysis technique.

          OS_OPEN_STREAM: Method may fail to close stream

          The method creates an IO stream object, does not assign it to any fields, pass it to other methods that might close it, or return it, and does not appear to close the stream on all paths out of the method.  This may result in a file descriptor leak.  It is generally a good idea to use a finally block to ensure that streams are closed.

          RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE: Nullcheck of value previously dereferenced

          A value is checked here to see whether it is null, but this value can't be null because it was previously dereferenced and if it were null a null pointer exception would have occurred at the earlier dereference. Essentially, this code and the previous dereference disagree as to whether this value is allowed to be null. Either the check is redundant or the previous dereference is erroneous.

          REC_CATCH_EXCEPTION: Exception is caught when Exception is not thrown

          This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs.

          RpC_REPEATED_CONDITIONAL_TEST: Repeated conditional tests

          The code contains a conditional test is performed twice, one right after the other (e.g., x == 0 || x == 0). Perhaps the second occurrence is intended to be something else (e.g., x == 0 || y == 0).

          SR_NOT_CHECKED: Method ignores results of InputStream.skip()

          This method ignores the return value of java.io.InputStream.skip() which can skip multiple bytes.  If the return value is not checked, the caller will not be able to correctly handle the case where fewer bytes were skipped than the caller requested.  This is a particularly insidious kind of bug, because in many programs, skips from input streams usually do skip the full amount of data requested, causing the program to fail only sporadically. With Buffered streams, however, skip() will only skip data in the buffer, and will routinely fail to skip the requested number of bytes.

          RV_RETURN_VALUE_IGNORED_BAD_PRACTICE: Method ignores exceptional return value

          This method returns a value that is not checked. The return value should be checked since it can indicate an unusual or unexpected function execution. For example, the File.delete() method returns false if the file could not be successfully deleted (rather than throwing an Exception). If you don't check the result, you won't notice if the method invocation signals unexpected behavior by returning an atypical return value.

          SA_LOCAL_DOUBLE_ASSIGNMENT: Double assignment of local variable

          This method contains a double assignment of a local variable; e.g.

            public void foo() {
              int x,y;
              x = x = 17;
            }
          

          Assigning the same value to a variable twice is useless, and may indicate a logic error or typo.

          SBSC_USE_STRINGBUFFER_CONCATENATION: Method concatenates strings using + in a loop

          The method seems to be building a String using concatenation in a loop. In each iteration, the String is converted to a StringBuffer/StringBuilder, appended to, and converted back to a String. This can lead to a cost quadratic in the number of iterations, as the growing string is recopied in each iteration.

          Better performance can be obtained by using a StringBuffer (or StringBuilder in Java 1.5) explicitly.

          For example:

            // This is bad
            String s = "";
            for (int i = 0; i < field.length; ++i) {
              s = s + field[i];
            }
          
            // This is better
            StringBuffer buf = new StringBuffer();
            for (int i = 0; i < field.length; ++i) {
              buf.append(field[i]);
            }
            String s = buf.toString();
          

          SC_START_IN_CTOR: Constructor invokes Thread.start()

          The constructor starts a thread. This is likely to be wrong if the class is ever extended/subclassed, since the thread will be started before the subclass constructor is started.

          SE_BAD_FIELD: Non-transient non-serializable instance field in serializable class

          This Serializable class defines a non-primitive instance field which is neither transient, Serializable, or java.lang.Object, and does not appear to implement the Externalizable interface or the readObject() and writeObject() methods.  Objects of this class will not be deserialized correctly if a non-Serializable object is stored in this field.

          SE_INNER_CLASS: Serializable inner class

          This Serializable class is an inner class. Any attempt to serialize it will also serialize the associated outer instance. The outer instance is serializable, so this won't fail, but it might serialize a lot more data than intended. If possible, making the inner class a static inner class (also known as a nested class) should solve the problem.

          SIC_INNER_SHOULD_BE_STATIC: Should be a static inner class

          This class is an inner class, but does not use its embedded reference to the object which created it.  This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.  If possible, the class should be made static.

          ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD: Write to static field from instance method

          This instance method writes to a static field. This is tricky to get correct if multiple instances are being manipulated, and generally bad practice.

          SWL_SLEEP_WITH_LOCK_HELD: Method calls Thread.sleep() with a lock held

          This method calls Thread.sleep() with a lock held. This may result in very poor performance and scalability, or a deadlock, since other threads may be waiting to acquire the lock. It is a much better idea to call wait() on the lock, which releases the lock and allows other threads to run.

          URF_UNREAD_FIELD: Unread field

          This field is never read.  Consider removing it from the class.

          DMI_INVOKING_TOSTRING_ON_ARRAY: Invocation of toString on an array

          The code invokes toString on an array, which will generate a fairly useless result such as [C@16f0472. Consider using Arrays.toString to convert the array into a readable String that gives the contents of the array. See Programming Puzzlers, chapter 3, puzzle 12.

          UW_UNCOND_WAIT: Unconditional wait

          This method contains a call to java.lang.Object.wait() which is not guarded by conditional control flow.  The code should verify that condition it intends to wait for is not already satisfied before calling wait; any previous notifications will be ignored.

          WA_NOT_IN_LOOP: Wait not in loop

          This method contains a call to java.lang.Object.wait() which is not in a loop.  If the monitor is used for multiple conditions, the condition the caller intended to wait for might not be the one that actually occurred.

          WMI_WRONG_MAP_ITERATOR: Inefficient use of keySet iterator instead of entrySet iterator

          This method accesses the value of a Map entry, using a key that was retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the map, to avoid the Map.get(key) lookup.

          libjboss-remoting-java-2.5.3.SP1.orig/src/etc/remoting.security.policy.tests.minimal0000644000175000017500000002156211413710170030434 0ustar twernertwerner// 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. // //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //****************************************************************** //**** Minimal set of permissions for Remoting classes **** //****************************************************************** //****************************************************************** grant codeBase "file:${remoting.jar.dir}/jboss-remoting.jar" { // Permissions to read test keystores and truststores permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}bisocket${/}ssl${/}.keystore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}bisocket${/}ssl${/}.truststore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}http${/}ssl${/}.keystore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}http${/}ssl${/}.truststore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}rmi${/}ssl${/}.keystore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}rmi${/}ssl${/}.truststore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}socket${/}ssl${/}.keystore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}socket${/}ssl${/}.truststore", "read"; // org.jboss.test.remoting.transport.http.ssl.custom.HTTPSInvokerTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[test:type=serversocketfactory]", "invoke"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //****************************************************************** //**** Minimal set of permissions for tests **** //****************************************************************** //****************************************************************** grant codeBase "file:${build.home}/output/tests/classes/-" { // Permissions to read test keystores and truststores permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}bisocket${/}ssl${/}.keystore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}bisocket${/}ssl${/}.truststore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}rmi${/}ssl${/}.keystore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}rmi${/}ssl${/}.truststore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}socket${/}ssl${/}.keystore", "read"; permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}transport${/}socket${/}ssl${/}.truststore", "read"; permission javax.management.MBeanServerPermission "createMBeanServer"; // org.jboss.test.remoting.transport.http.ssl.custom.HTTPSInvokerTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[test:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=coyote,type=connector]", "registerMBean"; permission java.util.PropertyPermission "org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "read"; permission java.util.PropertyPermission "jrunit.bind_addr", "read"; // org.jboss.test.remoting.transport.InvokerTestDriver permission java.util.PropertyPermission "remoting.metadata", "read"; permission java.util.PropertyPermission "jvm.mx", "read"; // org.jboss.remoting.transport.http.HTTPClientInvoket permission java.util.PropertyPermission "http.proxyHost", "read"; // org.jboss.test.taskdefs.XMLJUnitMultipleResultFormatter permission java.util.PropertyPermission "jboss-junit-configuration", "read"; // org.jboss.test.remoting.transport.InvokerClientTest permission java.util.PropertyPermission "remoting.metadata.callback", "read"; // org.jboss.test.remoting.transport.web.WebInvokerTestClient permission java.util.PropertyPermission "check_content_type", "read"; ///////////////////////////////////////////////////////////////////////////////////////////// // TODO - We should use a version of JBoss logging + log4j that does this stuff in privileged blocks permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.properties", "read"; permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.xml", "read"; permission java.io.FilePermission "${build.home}${/}lib${/}apache-log4j${/}lib${/}log4j.jar", "read"; permission java.io.FilePermission "${build.home}${/}output${/}classes${/}-", "read"; permission java.lang.RuntimePermission "accessClassInPackage.*"; permission java.util.PropertyPermission "org.jboss.logging.Logger.pluginClass", "read"; permission java.util.PropertyPermission "log4j.defaultInitOverride", "read"; permission java.util.PropertyPermission "elementAttributeLimit", "read"; permission java.util.PropertyPermission "maxOccurLimit", "read"; permission java.util.PropertyPermission "entityExpansionLimit", "read"; permission java.util.PropertyPermission "javax.xml.parsers.DocumentBuilderFactory", "read"; permission java.util.PropertyPermission "log4j.ignoreTCL", "read"; permission java.util.PropertyPermission "log4j.configuratorClass", "read"; permission java.util.PropertyPermission "log4j.configDebug", "read"; permission java.util.PropertyPermission "log4j.debug", "read"; permission java.util.PropertyPermission "log4j.configuration", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.LogFactory", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.Log", "read"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //****************************************************************** //**** Permissions for third party libraries **** //****************************************************************** //****************************************************************** grant codeBase "file:${build.home}/lib/-" { permission java.security.AllPermission; }; grant codeBase "file:${ant.library.dir}/-" { permission java.security.AllPermission; };libjboss-remoting-java-2.5.3.SP1.orig/src/etc/remoting.security.policy.core0000644000175000017500000004426511413706155026612 0ustar twernertwerner// 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. // //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //*************************************************** //**** //**** Permissions to run Remoting. This file is a sample security policy file //**** with the permissions necessary to run the code in the org.jboss.remoting.* //**** packages. All security sensitive calls in Remoting are wrapped in a //**** java.security.AccessController.doPrivileged() call, so that Remoting classes //**** can function in the context of a java.lang.SecurityManager, given some //**** variation on the permissions listed below, even if the calling code runs without //**** these restrictions. //**** //**** There are a few ways in which it may be necessary or desirable to modify the //**** the permissions listed below. //**** //**** 1. It may be necessary to change the java.io.FilePermission permissions, according //**** to the configuration of certain files. See the "File permissions" section below, //**** as well as the accompanying remoting.security.policy.tests file, which is used //**** to run the Remoting test suite. //**** //**** 2. If Remoting is configured to operate with one or more MBeans in place of POJOs, //**** it might be necessary to grant additional MBeanPermissions. See the MBean //**** permissions section below, as well as the MBeanPermissions granted to the //**** org.jboss.test.remoting.security.*ProxyTestCase test classes in the accompanying //**** remoting.security.policy.tests file, which is used to run the Remoting test suite //**** //**** 3. Some facilities always use MBeans. The MBean permissions given below may be //**** restricted to particular ObjectNames. //**** //**** 4. Some permission may be eliminated, according to which Remoting facilities are used. //**** //**** Other than changes made according to items 1 and 2, it should not be necessary to grant //**** any additional permissions. //**** //*************************************************** //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** grant codeBase "file:${remoting.jar.dir}/jboss-remoting.jar" { ///////////////////////////////////////////////////////////////////////////////////////////// // File permissions // Used by org.jboss.remotinng.callback.CallbackStore. // This permission might need to be changed, depending on where the CallbackStore // is configured to exist, according to system property "jboss.server.data.dir". // The default location is /data. permission java.io.FilePermission ".${/}data", "read, write, delete"; // Permission for org.jboss.remoting.ident.Identity to create and read "jboss.identity" file. // This permission might need to be changed, depending on the directory in which the // "jboss.identity" file is configured to exist. That directory is configed according to // // 1. the "ServerDataDir" attribute of the "jboss.system:type=ServerConfig" MBean, if that MBean exists, or // 2. the "jboss.identity.dir" system property, if that property exists, or // 3. the current directory. permission java.io.FilePermission ".", "read, write"; permission java.io.FilePermission "*", "read, write"; // Used by org.jboss.remoting.loading.ClassByteClassLoader. permission java.io.FilePermission "${java.io.tmpdir}${/}*", "read, write, delete"; // // Some variation of the following would be needed for SSL transports: // permission java.io.FilePermission "${keystore}", "read"; // permission java.io.FilePermission "${truststore}", "read"; ///////////////////////////////////////////////////////////////////////////////////////////// // MBean permissions // // Some variation of the following might be needed if Remoting gets an MBean in place of an ordinary object. // // See below for examples. // permission javax.management.MBeanPermission "*#*[*:*]", "getAttribute, setAttribute, invoke, registerMBean, unregisterMBean"; permission javax.management.MBeanTrustPermission "register"; // // Some variation of the following is used by org.jboss.remoting.callback.ServerInvokerCallbackHandler // // if it is configured with an MBean which is a ServerSocketFactory. // permission javax.management.MBeanPermission "*#SSLSocketBuilder[*:*]", "getAttribute"; // // Some variation of the following may be used by org.jboss.remoting.callback.ServerInvokerCallbackHandler, // // if it is configured with an MBean which is a ServerSocketFactory. // permission javax.management.MBeanPermission "*#-[*:*]", "isInstanceOf"; // Used by org.jboss.remoting.detection.AbstractDetector permission javax.management.MBeanPermission "*#addServer[*:*]", "invoke"; permission javax.management.MBeanPermission "*#updateServer[*:*]", "invoke"; permission javax.management.MBeanPermission "*#removeServer[*:*]", "invoke"; permission javax.management.MBeanPermission "*#Servers[*:*]", "getAttribute"; // Used by org.jboss.remoting.detection.util.DetectorUtil permission javax.management.MBeanServerPermission "createMBeanServer"; permission javax.management.MBeanPermission "org.jboss.remoting.network.NetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[jboss.remoting:type=Connector,*]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.*#-[remoting:type=Detector,*]", "registerMBean"; // Used by org.jboss.remoting.ident.Identity permission javax.management.MBeanPermission "javax.management.MBeanServerDelegate#MBeanServerId[JMImplementation:type=MBeanServerDelegate]", "getAttribute"; permission javax.management.MBeanPermission "-#ServerDataDir[jboss.system:type=ServerConfig]", "getAttribute"; // Used by org.jboss.remoting.network.NetworkRegistryFinder // (which is used by org.jboss.remoting.detection.AbstractDetector) permission javax.management.MBeanPermission "*#-[*:*]", "queryMBeans"; // Used by org.jboss.remoting.network.NetworkRegistryQuery // (which is used by org.jboss.remoting.network.NetworkRegistryFinder) permission javax.management.MBeanPermission "*#-[*:*]", "isInstanceOf"; // Used by org.jboss.remoting.transport.Connector permission javax.management.MBeanPermission "org.jboss.remoting.transport.*#-[jboss.remoting:service=invoker,*]", "registerMBean, unregisterMBean"; // // Some variation of the following would be necessary for org.jboss.remoting.transport.Connector // // if it is configured to use an MBean as an org.jboss.remoting.ServerInvocationHandler // permission javax.management.MBeanPermission "*#Invoker[*:*]", "setAttribute"; // permission javax.management.MBeanPermission "*#MBeanServer[*:*]", "setAttribute"; // permission javax.management.MBeanPermission "*#*[*:*]", "invoke"; // // Some variation of the following would be necessary for subclasses of org.jboss.remoting.transport.ServerInvoker // // if they are configured with an MBean which is a ServerSocketFactory // permission javax.management.MBeanPermission "*#createServerSocket[*:*]", "invoke"; // Used by org.jboss.remoting.transport.servlet.web.ServerInvokerServlet permission javax.management.MBeanServerPermission "findMBeanServer"; // Used by org.jboss.remoting.transporter.InternalTransporterServices permission javax.management.MBeanPermission "org.jboss.remoting.network.NetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean"; // Used by org.jboss.remoting.transporter.TransporterClient and org.jboss.remoting.transporter.Transporter.Server permission javax.management.MBeanServerPermission "createMBeanServer"; ///////////////////////////////////////////////////////////////////////////////////////////// // Runtime permissions // Used by remote class loading system permission java.lang.RuntimePermission "createClassLoader"; permission java.lang.RuntimePermission "getClassLoader"; permission java.lang.RuntimePermission "setContextClassLoader"; // Used by org.jboss.remoting.detection.jndi.JNDIDetector permission java.lang.RuntimePermission "org.jboss.naming.NamingContext.getLocal"; // Used by: // org.jboss.remoting.security.SSLSocketBuilder // org.jboss.remoting.transport.coyote.CoyoteInvoker // org.jboss.remoting.transport.http.HTTPClientInvoker // org.jboss.remoting.transport.servlet.web.ServerInvokerServlet // org.jboss.remoting.transporter.TransporterHandler // org.jboss.remoting.InvokerRegistry permission java.lang.RuntimePermission "accessClassInPackage.*"; // Used by org.jboss.remoting.transport.coyote.CoyoteInvoker permission java.lang.RuntimePermission "loadLibrary.tcnative-1"; permission java.lang.RuntimePermission "loadLibrary.libtcnative-1"; // Used to guard access to InvokerRegistry state permission java.lang.RuntimePermission "invokerRegistryUpdate"; ///////////////////////////////////////////////////////////////////////////////////////////// // Socket permissions. Can't create sockets without it. permission java.net.SocketPermission "*:*", "accept,connect,listen,resolve"; ///////////////////////////////////////////////////////////////////////////////////////////// // System properties accessed by Remoting // Used by org.jboss.remoting.MicroRemoteClientInvoker permission java.util.PropertyPermission "org.jboss.remoting.classloadingParentFirstDelegation", "read"; // Used by org.jboss.remoting.callback.CallbackStore, // org.jboss.remoting.callback.ServerInvokerCallbackHandler permission java.util.PropertyPermission "file.separator", "read"; permission java.util.PropertyPermission "jboss.server.data.dir", "read"; // Used by org.jboss.remoting.detection.jndi.JNDIDetector permission java.util.PropertyPermission "java.naming.factory.initial", "write"; permission java.util.PropertyPermission "jboss.global.jnp.disableDiscovery", "read"; // Used by org.jboss.remoting.detection.util.DetectorUtil permission java.util.PropertyPermission "jboss.identity", "read, write"; // Used by org.jboss.remoting.ident.Identity permission java.util.PropertyPermission "jboss.identity", "read, write"; permission java.util.PropertyPermission "jboss.identity.dir", "read"; permission java.util.PropertyPermission "jboss.identity.domain", "read"; // Used by org.jboss.remoting.InvokerLocator permission java.util.PropertyPermission "jboss.bind.address", "read"; permission java.util.PropertyPermission "legacyParsing", "read"; permission java.util.PropertyPermission "remoting.bind_by_host", "read"; permission java.util.PropertyPermission "suppressHostWarning", "read"; // Used by org.jboss.remoting.loading.CompressedClassBytes permission java.util.PropertyPermission "jboss.remoting.compression.debug", "read"; permission java.util.PropertyPermission "jboss.remoting.compression.min", "read"; // Used by org.jboss.remoting.network.NetworkRegistry permission java.util.PropertyPermission "jboss.remoting.domain", "write"; permission java.util.PropertyPermission "jboss.remoting.instanceid", "write"; permission java.util.PropertyPermission "jboss.remoting.jmxid", "write"; // Used by org.jboss.remoting.security.SSLSocketBuilder permission java.util.PropertyPermission "javax.net.ssl.keyStore", "read"; permission java.util.PropertyPermission "javax.net.ssl.keyStorePassword", "read"; permission java.util.PropertyPermission "javax.net.ssl.keyStoreType", "read"; permission java.util.PropertyPermission "javax.net.ssl.trustStore", "read"; permission java.util.PropertyPermission "javax.net.ssl.trustStorePassword", "read"; permission java.util.PropertyPermission "javax.net.ssl.trustStoreType", "read"; permission java.util.PropertyPermission "org.jboss.remoting.defaultSocketFactory", "read"; // Used by org.jboss.remoting.serialization.SerializationStreamFactory permission java.util.PropertyPermission "SERIALIZATION", "read"; // Used by org.jboss.remoting.ServerInvoker permission java.util.PropertyPermission "remoting.bind_by_host", "read"; // Used by org.jboss.remoting.stream.StreamServer permission java.util.PropertyPermission "remoting.stream.host", "read"; permission java.util.PropertyPermission "remoting.stream.port", "read"; permission java.util.PropertyPermission "remoting.stream.transport", "read"; // Used by Used by org.jboss.remoting.transport.coyote.CoyoteInvoker permission java.util.PropertyPermission "java.library.path", "read"; permission java.util.PropertyPermission "org.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER", "read"; permission java.util.PropertyPermission "org.apache.tomcat.util.*", "read"; permission java.util.PropertyPermission "tomcat.util.buf.StringCache.*", "read"; // Used by org.jboss.remoting.transport.http.HTTPClientInvoker permission java.util.PropertyPermission "http.basic.username", "read"; permission java.util.PropertyPermission "http.basic.password", "read"; permission java.util.PropertyPermission "http.proxy.username", "read"; permission java.util.PropertyPermission "http.proxy.password", "read"; permission java.util.PropertyPermission "http.proxyHost", "read"; permission java.util.PropertyPermission "http.proxyPort", "read"; // Used by org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker permission java.util.PropertyPermission "org.jboss.security.ignoreHttpsHost" , "read"; // Used by org.jboss.remoting.util.SecurityUtility permission java.util.PropertyPermission "skipAccessControl", "read"; // Used by org.jboss.remoting.Version permission java.util.PropertyPermission "jboss.remoting.pre_2_0_compatible", "read"; permission java.util.PropertyPermission "jboss.remoting.version", "read, write"; ///////////////////////////////////////////////////////////////////////////////////////////// // JBoss permissions // Used by JNDIDetector permission org.jboss.naming.JndiPermission "detection", "createSubcontext"; permission org.jboss.naming.JndiPermission "detection", "listBindings"; permission org.jboss.naming.JndiPermission "detection", "lookup"; permission org.jboss.naming.JndiPermission "detection/*", "rebind"; permission org.jboss.naming.JndiPermission "detection/*", "unbind"; ///////////////////////////////////////////////////////////////////////////////////////////// // Permissions used by JBossSerialization. // [TODO - JBoss Serialization SHOULD be doing these operations in a privileged block - JBSER-105] permission java.lang.RuntimePermission "accessDeclaredMembers"; permission java.lang.RuntimePermission "accessClassInPackage.*"; permission java.lang.RuntimePermission "reflectionFactoryAccess"; permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; permission java.io.SerializablePermission "enableSubclassImplementation"; // Used by org.jboss.remoting.serialization.impl.java.MarshalledValueOutputStream permission java.io.SerializablePermission "enableSubstitution"; ///////////////////////////////////////////////////////////////////////////////////////////// // Permissions used by Logging // [TODO - We should use a version of JBoss logging + log4j that does this stuff in privileged blocks] permission java.io.FilePermission "${remoting.jar.dir}${/}jboss-remoting.jar", "read"; permission java.io.FilePermission "${log4j.jar.dir}${/}log4j.jar", "read"; permission java.io.FilePermission "${log4j.config.dir}${/}log4j.properties", "read"; permission java.io.FilePermission "${log4j.config.dir}${/}log4j.xml", "read"; permission java.util.PropertyPermission "org.jboss.logging.Logger.pluginClass", "read"; permission java.util.PropertyPermission "log4j.defaultInitOverride", "read"; permission java.util.PropertyPermission "elementAttributeLimit", "read"; permission java.util.PropertyPermission "maxOccurLimit", "read"; permission java.util.PropertyPermission "entityExpansionLimit", "read"; permission java.util.PropertyPermission "javax.xml.parsers.DocumentBuilderFactory", "read"; permission java.util.PropertyPermission "log4j.ignoreTCL", "read"; permission java.util.PropertyPermission "log4j.configuratorClass", "read"; permission java.util.PropertyPermission "log4j.configDebug", "read"; permission java.util.PropertyPermission "log4j.debug", "read"; permission java.util.PropertyPermission "log4j.configuration", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.*", "read"; }; libjboss-remoting-java-2.5.3.SP1.orig/src/etc/web/0000755000175000017500000000000011632407053021510 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/web/web.xml0000644000175000017500000000262410456603600023012 0ustar twernertwerner ServerInvokerServlet The ServerInvokerServlet receives requests via HTTP protocol from within a web container and passes it onto the ServletServerInvoker for processing. org.jboss.remoting.transport.servlet.web.ServerInvokerServlet invokerName jboss.remoting:service=invoker,transport=servlet The servlet server invoker 1 ServerInvokerServlet /ServerInvokerServlet/* libjboss-remoting-java-2.5.3.SP1.orig/src/etc/remoting.security.policy.tests0000644000175000017500000005123711413706212027013 0ustar twernertwerner// 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. // //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //****************************************************************** //**** Permissions needed by Remoting to run the test suite **** //****************************************************************** //****************************************************************** grant codeBase "file:${build.home}/output/lib/jboss-remoting.jar" { // Permission to read test keystores permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}-", "read"; // Permission for org.jboss.remoting.callback.CallbackStore permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}-", "read, write, delete"; // Permission for org.jboss.remoting.ConnectionNotifier permission javax.management.MBeanPermission "org.jboss.test.remoting.lease.InjectedConnectionListenerTestCase$TestConnectionListener#handleConnectionException[jboss:type=connectionlistener]", "invoke"; // org.jboss.test.remoting.detection.metadata.MetadataTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "isInstanceOf"; // org.jboss.test.remoting.handler.mbean.ServerTest permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#Invoker[test:type=handler]", "setAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#MBeanServer[test:type=handler]", "setAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#*[test:type=handler]", "invoke"; // org.jboss.test.remoting.security.CallbackErrorHandlerProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackErrorHandler#*[test:type=TestCallbackErrorHandler]", "setAttribute, invoke"; // org.jboss.test.remoting.security.CallbackStoreProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackStore#*[test:type=Callbackstore]", "setAttribute, invoke"; // org.jboss.test.remoting.security.NetworkRegistryProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestNetworkRegistry#addServer[test:type=TestNetworkRegistry]", "invoke"; // org.jboss.test.remoting.security.ServerInvokerHandlerProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerInvocationHandler#*[test:type=TestServerInvocationHandler]", "setAttribute, invoke"; // org.jboss.test.remoting.security.ServerSocketFactoryProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerSocketFactory#createServerSocket[test:type=SSLServerSocketFactoryService]", "invoke"; // org.jboss.test.remoting.transport.bisocket.ssl.builder.SSLBisocketInvokerTestCase // org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestCase // org.jboss.test.remoting.transport.http.ssl.builder.HTTPSInvokerTestCase // org.jboss.test.remoting.transport.http.ssl.custom.HTTPSInvokerTestCase // org.jboss.test.remoting.transport.rmi.ssl.builder.RMIInvokerTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[test:type=serversocketfactory]", "invoke"; // org.jboss.test.remoting.transport.{bisocket,http,socket}.ssl.config.FactoryConfigTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[jboss:type=serversocketfactory]", "invoke"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#SSLSocketBuilder[jboss:type=serversocketfactory]", "getAttribute"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#SSLSocketBuilder[jboss:type=serversocketfactory2]", "getAttribute"; // org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#SSLSocketBuilder[jboss:type=serversocketfactory]", "getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#SSLSocketBuilder[jboss:type=serversocketfactory2]", "getAttribute"; // org.jboss.test.remoting.transport.http.connection.socketfactory.by_mbean.SocketFactoryByMBeanTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.http.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#createServerSocket[jboss:type=serversocketfactory]", "invoke"; // org.jboss.test.remoting.transport.http.ssl.config.FactoryConfigTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[jboss:type=serversocketfactory2]", "invoke"; // org.jboss.test.remoting.transport.rmi.connection.socketfactory.by_mbean.SocketFactoryByMBeanTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#createServerSocket[jboss:type=serversocketfactory]", "invoke"; // org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#createServerSocket[jboss:type=serversocketfactory]", "invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#createServerSocket[jboss:type=serversocketfactory2]", "invoke"; // org.jboss.test.remoting.transport.{bisocket,rmi}.ssl.builder.SSLBisocketInvokerTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#SSLSocketBuilder[test:type=serversocketfactory]", "getAttribute"; // Subclasses of org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent and FactoryConfigTestCaseSSLParent // org.jboss.test.remoting.transport.{http,socket}.connection.socketfactory.by_mbean.SocketFactoryTestServer permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.socket.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#createServerSocket[jboss:type=serversocketfactory]", "invoke"; // org.jboss.test.remoting.transport.http.proxy.ProxyAuthenticationTestCase permission java.util.PropertyPermission "http.proxyHost", "write"; permission java.util.PropertyPermission "http.proxyPort", "write"; permission java.util.PropertyPermission "proxySet", "write"; permission java.util.PropertyPermission "http.proxy.username", "write"; permission java.util.PropertyPermission "http.proxy.password", "write"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //**************************************************************************** //**** Permissions used by the test suite **** //**** (tests.functional.main, tests.functional.main.http, **** //**** tests.functional.main.core, and tests.functional.main.http.core) **** //**************************************************************************** //**************************************************************************** grant codeBase "file:${build.home}/output/tests/classes/-" { permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}classloader${/}race${/}test.jar", "read"; // Used by the descendents of org.jboss.test.remoting.shutdown.ShutdownTestParent. permission java.io.FilePermission "<>", "execute"; permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; permission java.lang.RuntimePermission "enableContextClassLoaderOverride"; permission java.lang.RuntimePermission "createClassLoader"; permission java.lang.RuntimePermission "getClassLoader"; permission java.lang.RuntimePermission "setContextClassLoader"; permission java.lang.RuntimePermission "org.jboss.naming.NamingContext.getLocal"; permission javax.management.MBeanTrustPermission "register"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.jndi.JNDIDetector#-[remoting:type=JNDIDetector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.multicast.MulticastDetector#-[remoting:*]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.multicast.MulticastDetector#*[test:type=MulticastDetector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.network.NetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf, addNotificationListener"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[jboss:type=serversocketfactory2]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[*:type=serversocketfactory]", "registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[jboss:*]", "invoke"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[test:type=serversocketfactory]", "invoke"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.*#-[jboss.remoting:service=invoker,*]", "unregisterMBean, registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[jboss.remoting:type=Connector,*]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[jboss:type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=socket,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=sslsocket,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=coyote,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:type=Connector]","registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.socket.SocketServerInvoker#Configuration[jboss.remoting:service=invoker,*]", "getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.jndi.JNDIDetectorTest1$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.jndi.JNDIDetectorTest2$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf, addNotificationListener"; permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#-[test:type=handler]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.lease.InjectedConnectionListenerTestCase$TestConnectionListener#-[jboss:type=connectionlistener]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.lease.InjectedConnectionListenerTestCase$TestConnectionListener#handleConnectionException[jboss:type=connectionlistener]", "invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackErrorHandler#*[test:type=TestCallbackErrorHandler]", "registerMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackStore#*[test:type=Callbackstore]", "registerMBean, getAttribute, invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestNetworkRegistry#*[test:type=TestNetworkRegistry]", "registerMBean, unregisterMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerInvocationHandler#*[test:type=TestServerInvocationHandler]", "registerMBean, getAttribute, invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerSocketFactory#*[test:type=SSLServerSocketFactoryService]", "registerMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent$SelfIdentifyingServerSocketFactory#-[jboss:type=serversocketfactory]", "registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.http.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#-[jboss:type=serversocketfactory2]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.socket.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanServerPermission "createMBeanServer, findMBeanServer"; // org.jboss.test.remoting.classloader.InvokerTestCase permission java.io.FilePermission "${build.home}${/}lib${/}-", "read"; permission java.io.FilePermission "${build.home}${/}output${/}lib${/}jboss-remoting.jar", "read"; permission java.lang.RuntimePermission "accessDeclaredMembers"; // org.jboss.test.remoting.transport.connector.ObjectNameWithZeroesAddressTestCase permission javax.management.MBeanPermission "*#-[*:*]", "queryMBeans"; // Several test cases. permission java.util.PropertyPermission "jrunit.bind_addr", "read"; // org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter permission java.util.PropertyPermission "jboss-junit-configuration", "read"; // This is technically the JNP server, but it seems intentional - note that this might mask other problems though permission java.net.SocketPermission "*:*", "accept, connect, resolve"; // jndi detection test cases permission java.util.PropertyPermission "java.naming.factory.initial", "write"; permission java.util.PropertyPermission "jboss.global.jnp.disableDiscovery", "read"; permission org.jboss.naming.JndiPermission "detection", "createSubcontext"; permission org.jboss.naming.JndiPermission "detection", "listBindings"; permission org.jboss.naming.JndiPermission "detection", "lookup"; permission org.jboss.naming.JndiPermission "detection/*", "rebind"; permission org.jboss.naming.JndiPermission "detection/*", "unbind"; // MalformedLocatorTestCase, RemoteClassloaderTestCase permission java.lang.RuntimePermission "setIO"; // MalformedLocatorTestCase permission java.util.PropertyPermission "suppressHostWarning", "write"; // org.jboss.test.remoting.security.InvokerRegistryUpdateTestCase permission java.lang.RuntimePermission "invokerRegistryUpdate"; // TODO - this stuff ought to be in privileged blocks within the Ant JUnit task permission java.util.PropertyPermission "*", "read, write"; // ugh // TESTING ONLY - Use with the LoggingSecurityManager to locate needed permissions for the above block // permission java.security.AllPermission; ///////////////////////////////////////////////////////////////////////////////////////////// // TODO - We should use a version of JBoss logging + log4j that does this stuff in privileged blocks permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.properties", "read"; permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.xml", "read"; permission java.io.FilePermission "${build.home}${/}lib${/}apache-log4j${/}lib${/}log4j.jar", "read"; permission java.io.FilePermission "${build.home}${/}output${/}classes${/}-", "read"; permission java.lang.RuntimePermission "accessClassInPackage.*"; permission java.util.PropertyPermission "org.jboss.logging.Logger.pluginClass", "read"; permission java.util.PropertyPermission "log4j.defaultInitOverride", "read"; permission java.util.PropertyPermission "elementAttributeLimit", "read"; permission java.util.PropertyPermission "maxOccurLimit", "read"; permission java.util.PropertyPermission "entityExpansionLimit", "read"; permission java.util.PropertyPermission "javax.xml.parsers.DocumentBuilderFactory", "read"; permission java.util.PropertyPermission "log4j.ignoreTCL", "read"; permission java.util.PropertyPermission "log4j.configuratorClass", "read"; permission java.util.PropertyPermission "log4j.configDebug", "read"; permission java.util.PropertyPermission "log4j.debug", "read"; permission java.util.PropertyPermission "log4j.configuration", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.LogFactory", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.Log", "read"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //****************************************************************** //**** Permissions for third party libraries **** //****************************************************************** //****************************************************************** grant codeBase "file:${build.home}/lib/-" { permission java.security.AllPermission; }; grant codeBase "file:${ant.library.dir}/-" { permission java.security.AllPermission; };libjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/0000755000175000017500000000000011632407053021522 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/0000755000175000017500000000000011632407053022642 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/0000755000175000017500000000000011632407053024466 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/samples/0000755000175000017500000000000011632407053026132 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/samples/chat/0000755000175000017500000000000011632407053027051 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/samples/chat/log4j.server_propertieslibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/samples/chat/log4j.server_propertie0000644000175000017500000000143710400175372033414 0ustar twernertwerner log4j.rootLogger=info, stdout, R #log4j.rootLogger=error, stdout #log4j.rootLogger=error, R log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) <%d{ABSOLUTE}> - %m%n log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=/home/sigal/Eclipse/JBossRemoting/output/logs/samples/chat/server.log log4j.appender.R.MaxFileSize=1000KB # Keep one backup file log4j.appender.R.MaxBackupIndex=1 log4j.appender.R.layout=org.apache.log4j.PatternLayout #log4j.appender.R.layout.ConversionPattern=%p %t %c [%x] - %m%n log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) <%d{ABSOLUTE}> - %m%n ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/samples/chat/log4j.client_propertieslibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/samples/chat/log4j.client_propertie0000644000175000017500000000143210400175372033357 0ustar twernertwerner log4j.rootLogger=info, stdout, R #log4j.rootLogger=error, stdout #log4j.rootLogger=debug, R log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) <%d{ABSOLUTE}> - %m%n log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=/home/sigal/Eclipse/JBossRemoting/output/logs/samples/client.log log4j.appender.R.MaxFileSize=1000KB # Keep one backup file log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout #log4j.appender.R.layout.ConversionPattern=%p %t %c [%x] - %m%n log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) <%d{ABSOLUTE}> - %m%n libjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/samples/chat/chat.conf0000644000175000017500000000024210400175372030633 0ustar twernertwernerdebug=y remoteStrategy=org.jboss.remoting.samples.chat.client.RemoteStrategyRemoting clientUriString=socket://laptop:0 chatManagerUri=socket://localhost:8080 libjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/samples/chat/build.xml0000644000175000017500000000241610401112231030655 0ustar twernertwerner libjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/marshall/0000755000175000017500000000000011632407053026271 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/marshall/encryption/0000755000175000017500000000000011632407053030463 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/marshall/encryption/Blowfish.key0000644000175000017500000000022210473663232032753 0ustar twernertwerner¬ísrjavax.crypto.spec.SecretKeySpec[G fâ0aML algorithmtLjava/lang/String;[keyt[BxptBlowfishur[B¬óøTàxp€äûÌØÁ¼¾]t%ë ?libjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/marshall/encryption/DES.key0000644000175000017500000000013510473663232031614 0ustar twernertwerner¬ísrcom.sun.crypto.provider.DESKeyk4œ5Úh˜[keyt[Bxpur[B¬óøTàxpa‘T¡>øXÁlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/marshall/encryption/RC4.key0000644000175000017500000000022110470667606031573 0ustar twernertwerner¬ísrjavax.crypto.spec.SecretKeySpec[G fâ0aML algorithmtLjava/lang/String;[keyt[BxptARCFOURur[B¬óøTàxpÂq:}jÁ¼Œ\ž}ûlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/marshall/encryption/AES.key0000644000175000017500000000021510473663232031610 0ustar twernertwerner¬ísrjavax.crypto.spec.SecretKeySpec[G fâ0aML algorithmtLjava/lang/String;[keyt[BxptAESur[B¬óøTàxp£RŽ®¹êÖ…Ê$ée‹Plibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/remoting/marshall/encryption/DESede.key0000644000175000017500000000016010473663232032270 0ustar twernertwerner¬ísr!com.sun.crypto.provider.DESedeKey"1ÖºCõÚ[keyt[Bxpur[B¬óøTàxp^y>…‘¶¹¿”Â%¼7€,k«”ýålibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/test/0000755000175000017500000000000011632407053023621 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/test/remoting/0000755000175000017500000000000011632407053025445 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/test/remoting/classloader/0000755000175000017500000000000011632407053027741 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/test/remoting/classloader/race/0000755000175000017500000000000011632407053030653 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootlibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/test/remoting/classloader/race/TestObject.javalibjboss-remoting-java-2.5.3.SP1.orig/src/etc/org/jboss/test/remoting/classloader/race/TestObject.ja0000644000175000017500000000236211413660476033247 0ustar twernertwerner /* * 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.io.Serializable; /** * * @author Ron Sigal * @version $Revision: 1.1 $ *

          * Copyright Feb 19, 2008 *

          */ public class TestObject implements Serializable { } libjboss-remoting-java-2.5.3.SP1.orig/src/etc/log4j.xml0000644000175000017500000000636110524727301022502 0ustar twernertwerner libjboss-remoting-java-2.5.3.SP1.orig/src/etc/remoting.security.policy.tests.invokerregistry0000644000175000017500000010263111413706366032265 0ustar twernertwerner// 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. // //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //*************************************************************************************************** //**** Permissions needed by Remoting to run the test suite **** //**** **** //**** This file is used by org.jboss.test.remoting.security.InvokerRegistrySecurityTestCase. **** //**** It is identical to remoting.security.policy.tests, except that the **** //**** "file:${build.home}/output/tests/classes/-" code base is replaced by the two codebases **** //**** "file:${build.home}/output/lib/jboss-remoting-tests.jar" and **** //**** "file:${build.home}/output/lib/jboss-remoting-invokerregistry-test.jar", which are **** //**** granted the same permissions as "file:${build.home}/output/tests/classes/-" except **** //**** for the lack of permission **** //**** **** //**** permission java.lang.RuntimePermission "invokerRegistryUpdate"; **** //**** **** //**** for "file:${build.home}/output/lib/jboss-remoting-invokerregistry-test.jar". **** //*************************************************************************************************** //*************************************************************************************************** grant codeBase "file:${build.home}/output/lib/jboss-remoting.jar" { // Permission to read test keystores permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}-", "read"; // Permission for org.jboss.remoting.callback.CallbackStore permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}-", "read, write, delete"; // Permission for org.jboss.remoting.ConnectionNotifier permission javax.management.MBeanPermission "org.jboss.test.remoting.lease.InjectedConnectionListenerTestCase$TestConnectionListener#handleConnectionException[jboss:type=connectionlistener]", "invoke"; // org.jboss.test.remoting.detection.metadata.MetadataTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "isInstanceOf"; // org.jboss.test.remoting.handler.mbean.ServerTest permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#Invoker[test:type=handler]", "setAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#MBeanServer[test:type=handler]", "setAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#*[test:type=handler]", "invoke"; // org.jboss.test.remoting.security.CallbackErrorHandlerProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackErrorHandler#*[test:type=TestCallbackErrorHandler]", "setAttribute, invoke"; // org.jboss.test.remoting.security.CallbackStoreProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackStore#*[test:type=Callbackstore]", "setAttribute, invoke"; // org.jboss.test.remoting.security.NetworkRegistryProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestNetworkRegistry#addServer[test:type=TestNetworkRegistry]", "invoke"; // org.jboss.test.remoting.security.ServerInvokerHandlerProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerInvocationHandler#*[test:type=TestServerInvocationHandler]", "setAttribute, invoke"; // org.jboss.test.remoting.security.ServerSocketFactoryProxyTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerSocketFactory#createServerSocket[test:type=SSLServerSocketFactoryService]", "invoke"; // org.jboss.test.remoting.transport.bisocket.ssl.builder.SSLBisocketInvokerTestCase // org.jboss.test.remoting.transport.http.ssl.basic.HTTPSInvokerTestCase // org.jboss.test.remoting.transport.http.ssl.builder.HTTPSInvokerTestCase // org.jboss.test.remoting.transport.http.ssl.custom.HTTPSInvokerTestCase // org.jboss.test.remoting.transport.rmi.ssl.builder.RMIInvokerTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[test:type=serversocketfactory]", "invoke"; // org.jboss.test.remoting.transport.{bisocket,http,socket}.ssl.config.FactoryConfigTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[jboss:type=serversocketfactory]", "invoke"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#SSLSocketBuilder[jboss:type=serversocketfactory]", "getAttribute"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#SSLSocketBuilder[jboss:type=serversocketfactory2]", "getAttribute"; // org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#SSLSocketBuilder[jboss:type=serversocketfactory]", "getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#SSLSocketBuilder[jboss:type=serversocketfactory2]", "getAttribute"; // org.jboss.test.remoting.transport.http.connection.socketfactory.by_mbean.SocketFactoryByMBeanTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.http.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#createServerSocket[jboss:type=serversocketfactory]", "invoke"; // org.jboss.test.remoting.transport.http.ssl.config.FactoryConfigTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[jboss:type=serversocketfactory2]", "invoke"; // org.jboss.test.remoting.transport.rmi.connection.socketfactory.by_mbean.SocketFactoryByMBeanTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#createServerSocket[jboss:type=serversocketfactory]", "invoke"; // org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#createServerSocket[jboss:type=serversocketfactory]", "invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#createServerSocket[jboss:type=serversocketfactory2]", "invoke"; // org.jboss.test.remoting.transport.{bisocket,rmi}.ssl.builder.SSLBisocketInvokerTestCase permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#SSLSocketBuilder[test:type=serversocketfactory]", "getAttribute"; // Subclasses of org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent and FactoryConfigTestCaseSSLParent // org.jboss.test.remoting.transport.{http,socket}.connection.socketfactory.by_mbean.SocketFactoryTestServer permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.socket.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#createServerSocket[jboss:type=serversocketfactory]", "invoke"; // org.jboss.test.remoting.transport.http.proxy.ProxyAuthenticationTestCase permission java.util.PropertyPermission "http.proxyHost", "write"; permission java.util.PropertyPermission "http.proxyPort", "write"; permission java.util.PropertyPermission "proxySet", "write"; permission java.util.PropertyPermission "http.proxy.username", "write"; permission java.util.PropertyPermission "http.proxy.password", "write"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //**************************************************************************** //**** Permissions used by the test suite **** //**** (tests.functional.main, tests.functional.main.http, **** //**** tests.functional.main.core, and tests.functional.main.http.core) **** //**************************************************************************** //**************************************************************************** grant codeBase "file:${build.home}/output/lib/jboss-remoting-tests.jar" { permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}classloader${/}race${/}test.jar", "read"; // Used by the descendents of org.jboss.test.remoting.shutdown.ShutdownTestParent. permission java.io.FilePermission "<>", "execute"; permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; permission java.lang.RuntimePermission "enableContextClassLoaderOverride"; permission java.lang.RuntimePermission "createClassLoader"; permission java.lang.RuntimePermission "getClassLoader"; permission java.lang.RuntimePermission "setContextClassLoader"; permission java.lang.RuntimePermission "org.jboss.naming.NamingContext.getLocal"; permission javax.management.MBeanTrustPermission "register"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.jndi.JNDIDetector#-[remoting:type=JNDIDetector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.multicast.MulticastDetector#-[remoting:*]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.multicast.MulticastDetector#*[test:type=MulticastDetector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.network.NetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf, addNotificationListener"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[jboss:type=serversocketfactory2]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[*:type=serversocketfactory]", "registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[jboss:*]", "invoke"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[test:type=serversocketfactory]", "invoke"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.*#-[jboss.remoting:service=invoker,*]", "unregisterMBean, registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[jboss.remoting:type=Connector,*]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[jboss:type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=socket,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=sslsocket,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=coyote,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:type=Connector]","registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.socket.SocketServerInvoker#Configuration[jboss.remoting:service=invoker,*]", "getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.jndi.JNDIDetectorTest1$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.jndi.JNDIDetectorTest2$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf, addNotificationListener"; permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#-[test:type=handler]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.lease.InjectedConnectionListenerTestCase$TestConnectionListener#-[jboss:type=connectionlistener]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.lease.InjectedConnectionListenerTestCase$TestConnectionListener#handleConnectionException[jboss:type=connectionlistener]", "invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackErrorHandler#*[test:type=TestCallbackErrorHandler]", "registerMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackStore#*[test:type=Callbackstore]", "registerMBean, getAttribute, invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestNetworkRegistry#*[test:type=TestNetworkRegistry]", "registerMBean, unregisterMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerInvocationHandler#*[test:type=TestServerInvocationHandler]", "registerMBean, getAttribute, invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerSocketFactory#*[test:type=SSLServerSocketFactoryService]", "registerMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent$SelfIdentifyingServerSocketFactory#-[jboss:type=serversocketfactory]", "registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.http.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#-[jboss:type=serversocketfactory2]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.socket.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanServerPermission "createMBeanServer, findMBeanServer"; // org.jboss.test.remoting.classloader.InvokerTestCase permission java.io.FilePermission "${build.home}${/}lib${/}-", "read"; permission java.io.FilePermission "${build.home}${/}output${/}lib${/}jboss-remoting.jar", "read"; permission java.lang.RuntimePermission "accessDeclaredMembers"; // org.jboss.test.remoting.transport.connector.ObjectNameWithZeroesAddressTestCase permission javax.management.MBeanPermission "*#-[*:*]", "queryMBeans"; // Several test cases. permission java.util.PropertyPermission "jrunit.bind_addr", "read"; // org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter permission java.util.PropertyPermission "jboss-junit-configuration", "read"; // This is technically the JNP server, but it seems intentional - note that this might mask other problems though permission java.net.SocketPermission "*:*", "accept, connect, resolve"; // jndi detection test cases permission java.util.PropertyPermission "java.naming.factory.initial", "write"; permission java.util.PropertyPermission "jboss.global.jnp.disableDiscovery", "read"; permission org.jboss.naming.JndiPermission "detection", "createSubcontext"; permission org.jboss.naming.JndiPermission "detection", "listBindings"; permission org.jboss.naming.JndiPermission "detection", "lookup"; permission org.jboss.naming.JndiPermission "detection/*", "rebind"; permission org.jboss.naming.JndiPermission "detection/*", "unbind"; // MalformedLocatorTestCase, RemoteClassloaderTestCase permission java.lang.RuntimePermission "setIO"; // MalformedLocatorTestCase permission java.util.PropertyPermission "suppressHostWarning", "write"; // org.jboss.test.remoting.security.InvokerRegistryUpdateTestCase permission java.lang.RuntimePermission "invokerRegistryUpdate"; // TODO - this stuff ought to be in privileged blocks within the Ant JUnit task permission java.util.PropertyPermission "*", "read, write"; // ugh // TESTING ONLY - Use with the LoggingSecurityManager to locate needed permissions for the above block // permission java.security.AllPermission; ///////////////////////////////////////////////////////////////////////////////////////////// // TODO - We should use a version of JBoss logging + log4j that does this stuff in privileged blocks permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.properties", "read"; permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.xml", "read"; permission java.io.FilePermission "${build.home}${/}lib${/}apache-log4j${/}lib${/}log4j.jar", "read"; permission java.io.FilePermission "${build.home}${/}output${/}classes${/}-", "read"; permission java.lang.RuntimePermission "accessClassInPackage.*"; permission java.util.PropertyPermission "org.jboss.logging.Logger.pluginClass", "read"; permission java.util.PropertyPermission "log4j.defaultInitOverride", "read"; permission java.util.PropertyPermission "elementAttributeLimit", "read"; permission java.util.PropertyPermission "maxOccurLimit", "read"; permission java.util.PropertyPermission "entityExpansionLimit", "read"; permission java.util.PropertyPermission "javax.xml.parsers.DocumentBuilderFactory", "read"; permission java.util.PropertyPermission "log4j.ignoreTCL", "read"; permission java.util.PropertyPermission "log4j.configuratorClass", "read"; permission java.util.PropertyPermission "log4j.configDebug", "read"; permission java.util.PropertyPermission "log4j.debug", "read"; permission java.util.PropertyPermission "log4j.configuration", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.LogFactory", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.Log", "read"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //**************************************************************************** //**** Permissions used by the test suite **** //**** (tests.functional.main, tests.functional.main.http, **** //**** tests.functional.main.core, and tests.functional.main.http.core) **** //**************************************************************************** //**************************************************************************** grant codeBase "file:${build.home}/output/lib/jboss-remoting-invokerregistry-test.jar" { permission java.io.FilePermission "${build.home}${/}output${/}tests${/}classes${/}org${/}jboss${/}test${/}remoting${/}classloader${/}race${/}test.jar", "read"; // Used by the descendents of org.jboss.test.remoting.shutdown.ShutdownTestParent. permission java.io.FilePermission "<>", "execute"; permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; permission java.lang.RuntimePermission "enableContextClassLoaderOverride"; permission java.lang.RuntimePermission "createClassLoader"; permission java.lang.RuntimePermission "getClassLoader"; permission java.lang.RuntimePermission "setContextClassLoader"; permission java.lang.RuntimePermission "org.jboss.naming.NamingContext.getLocal"; permission javax.management.MBeanTrustPermission "register"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.jndi.JNDIDetector#-[remoting:type=JNDIDetector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.multicast.MulticastDetector#-[remoting:*]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.detection.multicast.MulticastDetector#*[test:type=MulticastDetector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.network.NetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf, addNotificationListener"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[jboss:type=serversocketfactory2]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#-[*:type=serversocketfactory]", "registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[jboss:*]", "invoke"; permission javax.management.MBeanPermission "org.jboss.remoting.security.SSLServerSocketFactoryService#createServerSocket[test:type=serversocketfactory]", "invoke"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.*#-[jboss.remoting:service=invoker,*]", "unregisterMBean, registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[jboss.remoting:type=Connector,*]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[jboss:type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=socket,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=sslsocket,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:transport=coyote,type=connector]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.Connector#-[test:type=Connector]","registerMBean"; permission javax.management.MBeanPermission "org.jboss.remoting.transport.socket.SocketServerInvoker#Configuration[jboss.remoting:service=invoker,*]", "getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.jndi.JNDIDetectorTest1$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.jndi.JNDIDetectorTest2$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "registerMBean, unregisterMBean, queryMBeans, isInstanceOf, addNotificationListener"; permission javax.management.MBeanPermission "org.jboss.test.remoting.handler.mbean.MBeanHandler#-[test:type=handler]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.lease.InjectedConnectionListenerTestCase$TestConnectionListener#-[jboss:type=connectionlistener]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.lease.InjectedConnectionListenerTestCase$TestConnectionListener#handleConnectionException[jboss:type=connectionlistener]", "invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackErrorHandler#*[test:type=TestCallbackErrorHandler]", "registerMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestCallbackStore#*[test:type=Callbackstore]", "registerMBean, getAttribute, invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestNetworkRegistry#*[test:type=TestNetworkRegistry]", "registerMBean, unregisterMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerInvocationHandler#*[test:type=TestServerInvocationHandler]", "registerMBean, getAttribute, invoke"; permission javax.management.MBeanPermission "org.jboss.test.remoting.security.TestServerSocketFactory#*[test:type=SSLServerSocketFactoryService]", "registerMBean, getAttribute"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.config.FactoryConfigTestCaseParent$SelfIdentifyingServerSocketFactory#-[jboss:type=serversocketfactory]", "registerMBean, queryMBeans, isInstanceOf"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.http.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#-[jboss:type=serversocketfactory2]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.rmi.ssl.config.FactoryConfigTestCase$SerializableServerSocketFactory#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanPermission "org.jboss.test.remoting.transport.socket.connection.socketfactory.by_mbean.SocketFactoryTestServer$ServerSocketFactoryMock#-[jboss:type=serversocketfactory]", "registerMBean"; permission javax.management.MBeanServerPermission "createMBeanServer, findMBeanServer"; // org.jboss.test.remoting.classloader.InvokerTestCase permission java.io.FilePermission "${build.home}${/}lib${/}-", "read"; permission java.io.FilePermission "${build.home}${/}output${/}lib${/}jboss-remoting.jar", "read"; permission java.lang.RuntimePermission "accessDeclaredMembers"; // org.jboss.test.remoting.transport.connector.ObjectNameWithZeroesAddressTestCase permission javax.management.MBeanPermission "*#-[*:*]", "queryMBeans"; // Several test cases. permission java.util.PropertyPermission "jrunit.bind_addr", "read"; // org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter permission java.util.PropertyPermission "jboss-junit-configuration", "read"; // This is technically the JNP server, but it seems intentional - note that this might mask other problems though permission java.net.SocketPermission "*:*", "accept, connect, resolve"; // jndi detection test cases permission java.util.PropertyPermission "java.naming.factory.initial", "write"; permission java.util.PropertyPermission "jboss.global.jnp.disableDiscovery", "read"; permission org.jboss.naming.JndiPermission "detection", "createSubcontext"; permission org.jboss.naming.JndiPermission "detection", "listBindings"; permission org.jboss.naming.JndiPermission "detection", "lookup"; permission org.jboss.naming.JndiPermission "detection/*", "rebind"; permission org.jboss.naming.JndiPermission "detection/*", "unbind"; // MalformedLocatorTestCase, RemoteClassloaderTestCase permission java.lang.RuntimePermission "setIO"; // MalformedLocatorTestCase permission java.util.PropertyPermission "suppressHostWarning", "write"; // TODO - this stuff ought to be in privileged blocks within the Ant JUnit task permission java.util.PropertyPermission "*", "read, write"; // ugh // TESTING ONLY - Use with the LoggingSecurityManager to locate needed permissions for the above block // permission java.security.AllPermission; ///////////////////////////////////////////////////////////////////////////////////////////// // TODO - We should use a version of JBoss logging + log4j that does this stuff in privileged blocks permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.properties", "read"; permission java.io.FilePermission "${build.home}${/}src${/}etc${/}log4j.xml", "read"; permission java.io.FilePermission "${build.home}${/}lib${/}apache-log4j${/}lib${/}log4j.jar", "read"; permission java.io.FilePermission "${build.home}${/}output${/}classes${/}-", "read"; permission java.lang.RuntimePermission "accessClassInPackage.*"; permission java.util.PropertyPermission "org.jboss.logging.Logger.pluginClass", "read"; permission java.util.PropertyPermission "log4j.defaultInitOverride", "read"; permission java.util.PropertyPermission "elementAttributeLimit", "read"; permission java.util.PropertyPermission "maxOccurLimit", "read"; permission java.util.PropertyPermission "entityExpansionLimit", "read"; permission java.util.PropertyPermission "javax.xml.parsers.DocumentBuilderFactory", "read"; permission java.util.PropertyPermission "log4j.ignoreTCL", "read"; permission java.util.PropertyPermission "log4j.configuratorClass", "read"; permission java.util.PropertyPermission "log4j.configDebug", "read"; permission java.util.PropertyPermission "log4j.debug", "read"; permission java.util.PropertyPermission "log4j.configuration", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.LogFactory", "read"; permission java.util.PropertyPermission "org.apache.commons.logging.Log", "read"; }; //**************************************************************************************************************************************************************** //**************************************************************************************************************************************************************** //****************************************************************** //**** Permissions for third party libraries **** //****************************************************************** //****************************************************************** grant codeBase "file:${build.home}/lib/-" { permission java.security.AllPermission; }; grant codeBase "file:${ant.library.dir}/-" { permission java.security.AllPermission; };libjboss-remoting-java-2.5.3.SP1.orig/src/etc/log4j.properties0000644000175000017500000000051010255621770024070 0ustar twernertwerner ## Root logger log4j.rootLogger=info,console ## Appenders log4j.appender.console=org.apache.log4j.ConsoleAppender # log everything #log4j.logger.org.jboss.remoting=DEBUG ## Layouts log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%-7d{HH:mm:ss,SSS} [%p] %c: %m%n libjboss-remoting-java-2.5.3.SP1.orig/src/etc/build.xml0000644000175000017500000004022611017430660022555 0ustar twernertwerner *** This sample can only be run using JDK 1.5 *** libjboss-remoting-java-2.5.3.SP1.orig/local.properties0000644000175000017500000000032511413660476022610 0ustar twernertwernerjboss.home=c://cygwin/home/rsigal/workspace.new/jboss-as-parent-trunk/build/output/jboss-5.0.0.GA as.startup.time=220 as.shutdown.time=10 shell=c:/cygwin/bin/sh.exe findbugs.home=c:/cygwin/opt/local/findbugs-1.3.9libjboss-remoting-java-2.5.3.SP1.orig/component-info.xml0000644000175000017500000000115110241025161023033 0ustar twernertwerner libjboss-remoting-java-2.5.3.SP1.orig/.settings/0000755000175000017500000000000011632407223021306 5ustar twernertwernerlibjboss-remoting-java-2.5.3.SP1.orig/.settings/org.eclipse.jdt.core.prefs0000644000175000017500000005346111413660476026311 0ustar twernertwerner#Thu Nov 13 15:06:08 KST 2008 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.4 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning org.eclipse.jdt.core.compiler.source=1.3 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 org.eclipse.jdt.core.formatter.alignment_for_compact_if=48 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=48 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=64 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=64 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 org.eclipse.jdt.core.formatter.blank_lines_before_field=1 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 org.eclipse.jdt.core.formatter.blank_lines_before_method=1 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=next_line org.eclipse.jdt.core.formatter.brace_position_for_block=next_line org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false org.eclipse.jdt.core.formatter.comment.format_block_comments=false org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false org.eclipse.jdt.core.formatter.comment.format_line_comments=false org.eclipse.jdt.core.formatter.comment.format_source_code=true org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.compact_else_if=true org.eclipse.jdt.core.formatter.continuation_indentation=2 org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_empty_lines=false org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true org.eclipse.jdt.core.formatter.indentation.size=8 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=120 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.size=3 org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true libjboss-remoting-java-2.5.3.SP1.orig/.settings/org.eclipse.jdt.ui.prefs0000644000175000017500000001354411413660476025774 0ustar twernertwerner#Thu Nov 13 15:06:09 KST 2008 eclipse.preferences.version=1 formatter_profile=_JBoss.org formatter_settings_version=11 org.eclipse.jdt.ui.javadoc=false org.eclipse.jdt.ui.text.custom_code_templates=