JBoss Remoting SVN: r6000 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:22:58 -0400 (Wed, 04 Aug 2010)
New Revision: 6000
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory/SocketFactoryClassNameTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory/SocketFactoryClassNameTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory/SocketFactoryClassNameTestCase.java 2010-08-05 01:22:19 UTC (rev 5999)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory/SocketFactoryClassNameTestCase.java 2010-08-05 01:22:58 UTC (rev 6000)
@@ -1,22 +1,22 @@
-package org.jboss.test.remoting.transport.bisocket.socketfactory;
-
-import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot;
-
-
-/**
- *
- * Unit test for JBREM-1014.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Jul 18, 2008
- * </p>
- */
-public class SocketFactoryClassNameTestCase extends SocketFactoryClassNameTestRoot
-{
- protected String getTransport()
- {
- return "bisocket";
- }
+package org.jboss.test.remoting.transport.bisocket.socketfactory;
+
+import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot;
+
+
+/**
+ *
+ * Unit test for JBREM-1014.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jul 18, 2008
+ * </p>
+ */
+public class SocketFactoryClassNameTestCase extends SocketFactoryClassNameTestRoot
+{
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketfactory/SocketFactoryClassNameTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5999 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:22:19 -0400 (Wed, 04 Aug 2010)
New Revision: 5999
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java 2010-08-05 01:21:36 UTC (rev 5998)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java 2010-08-05 01:22:19 UTC (rev 5999)
@@ -1,234 +1,234 @@
-/*
-* 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Rev$
- * <p>
- * Copyright Sep 9, 2009
- * </p>
- */
-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() + "]";
- }
- }
-
+/*
+* 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Sep 9, 2009
+ * </p>
+ */
+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() + "]";
+ }
+ }
+
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketexception/BisocketSocketCreationExceptionTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5998 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/connectionfailure.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:21:36 -0400 (Wed, 04 Aug 2010)
New Revision: 5998
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/connectionfailure/BisocketCallbackConnectionFailureTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/connectionfailure/BisocketCallbackConnectionFailureTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/connectionfailure/BisocketCallbackConnectionFailureTestCase.java 2010-08-05 01:21:05 UTC (rev 5997)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/connectionfailure/BisocketCallbackConnectionFailureTestCase.java 2010-08-05 01:21:36 UTC (rev 5998)
@@ -1,63 +1,63 @@
-
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 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-873.
- *
- * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Dec 10, 2007
- * </p>
- */
-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");
- }
-}
-
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 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-873.
+ *
+ * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Dec 10, 2007
+ * </p>
+ */
+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");
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/connectionfailure/BisocketCallbackConnectionFailureTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5997 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/clientpool.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:21:05 -0400 (Wed, 04 Aug 2010)
New Revision: 5997
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/clientpool/BisocketConnectionPoolSizeTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/clientpool/BisocketConnectionPoolSizeTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/clientpool/BisocketConnectionPoolSizeTestCase.java 2010-08-05 01:20:38 UTC (rev 5996)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/clientpool/BisocketConnectionPoolSizeTestCase.java 2010-08-05 01:21:05 UTC (rev 5997)
@@ -1,43 +1,43 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 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.clientpool;
-
-import org.jboss.test.remoting.transport.socket.connectionpool.ConnectionPoolSizeTestCase;
-
-
-/**
- *
- * Unit test for JBREM-858.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Dec 3, 2007
- * </p>
- */
-public class BisocketConnectionPoolSizeTestCase extends ConnectionPoolSizeTestCase
-{
- protected String getTransport()
- {
- return "bisocket";
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 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.clientpool;
+
+import org.jboss.test.remoting.transport.socket.connectionpool.ConnectionPoolSizeTestCase;
+
+
+/**
+ *
+ * Unit test for JBREM-858.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Dec 3, 2007
+ * </p>
+ */
+public class BisocketConnectionPoolSizeTestCase extends ConnectionPoolSizeTestCase
+{
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/clientpool/BisocketConnectionPoolSizeTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5996 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:20:38 -0400 (Wed, 04 Aug 2010)
New Revision: 5996
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketControlConnectionReplacementTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerClientTest.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerServerTest.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackClientWithZeroTimeoutTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketControlConnectionReplacementTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketControlConnectionReplacementTestCase.java 2010-08-05 01:18:04 UTC (rev 5995)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketControlConnectionReplacementTestCase.java 2010-08-05 01:20:38 UTC (rev 5996)
@@ -1,505 +1,505 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Aug 14, 2009
- * </p>
- */
-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(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);
-
- 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;
- }
- }
- }
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Aug 14, 2009
+ * </p>
+ */
+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(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);
+
+ 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;
+ }
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketControlConnectionReplacementTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerClientTest.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerClientTest.java 2010-08-05 01:18:04 UTC (rev 5995)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerClientTest.java 2010-08-05 01:20:38 UTC (rev 5996)
@@ -1,56 +1,56 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 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 <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
- */
-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();
- }
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 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 <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
+ */
+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();
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerClientTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerServerTest.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerServerTest.java 2010-08-05 01:18:04 UTC (rev 5995)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerServerTest.java 2010-08-05 01:20:38 UTC (rev 5996)
@@ -1,63 +1,63 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 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 <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
- */
-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();
- }
- }
-
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 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 <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
+ */
+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();
+ }
+ }
+
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/BisocketInvokerServerTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackClientWithZeroTimeoutTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackClientWithZeroTimeoutTestCase.java 2010-08-05 01:18:04 UTC (rev 5995)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackClientWithZeroTimeoutTestCase.java 2010-08-05 01:20:38 UTC (rev 5996)
@@ -1,276 +1,276 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Dec 11, 2007
- * </p>
- */
-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("secondaryServerSocketThread");
- field.setAccessible(true);
- Thread secondaryServerSocketThread = (Thread) field.get(connector.getServerInvoker());
- assertNotNull(secondaryServerSocketThread);
- secondaryServerSocketThread.stop();
-
- // 3. Try to do callback.
- client.invokeOneway(CALLBACK);
-
- // 4. Close client side control socket so PING fails.
- controlSocket.close();
-
- // 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";
- 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("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
- {
- 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);
- 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");
- }
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Dec 11, 2007
+ * </p>
+ */
+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("secondaryServerSocketThread");
+ field.setAccessible(true);
+ Thread secondaryServerSocketThread = (Thread) field.get(connector.getServerInvoker());
+ assertNotNull(secondaryServerSocketThread);
+ secondaryServerSocketThread.stop();
+
+ // 3. Try to do callback.
+ client.invokeOneway(CALLBACK);
+
+ // 4. Close client side control socket so PING fails.
+ controlSocket.close();
+
+ // 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";
+ 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("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
+ {
+ 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);
+ 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");
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/CallbackClientWithZeroTimeoutTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5995 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ssl/emptystore.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:18:04 -0400 (Wed, 04 Aug 2010)
New Revision: 5995
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ssl/emptystore/EmptyStoreTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ssl/emptystore/EmptyStoreTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ssl/emptystore/EmptyStoreTestCase.java 2010-08-05 01:17:10 UTC (rev 5994)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ssl/emptystore/EmptyStoreTestCase.java 2010-08-05 01:18:04 UTC (rev 5995)
@@ -1,166 +1,166 @@
-/*
-* 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.ssl.emptystore;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.HashMap;
-
-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.security.SSLSocketBuilder;
-
-
-/**
- * Unit test for JBREM-1172.
- *
- * @author <a href="mailto:ron.sigal@jboss.com">Ron Sigal</a>
- * <p>
- * Copyright Dec 19, 2009
- * <p>
- * @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");
- }
+/*
+* 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.ssl.emptystore;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.HashMap;
+
+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.security.SSLSocketBuilder;
+
+
+/**
+ * Unit test for JBREM-1172.
+ *
+ * @author <a href="mailto:ron.sigal@jboss.com">Ron Sigal</a>
+ * <p>
+ * Copyright Dec 19, 2009
+ * <p>
+ * @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");
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/ssl/emptystore/EmptyStoreTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5994 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:17:10 -0400 (Wed, 04 Aug 2010)
New Revision: 5994
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SSLSocketFactoryClassNameTestRoot.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SSLSocketFactoryClassNameTestRoot.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SSLSocketFactoryClassNameTestRoot.java 2010-08-05 01:16:09 UTC (rev 5993)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SSLSocketFactoryClassNameTestRoot.java 2010-08-05 01:17:10 UTC (rev 5994)
@@ -1,100 +1,100 @@
-
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Jul 18, 2008
- * </p>
- */
-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);
- }
- }
-}
-
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jul 18, 2008
+ * </p>
+ */
+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);
+ }
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SSLSocketFactoryClassNameTestRoot.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java 2010-08-05 01:16:09 UTC (rev 5993)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java 2010-08-05 01:17:10 UTC (rev 5994)
@@ -1,303 +1,303 @@
-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.logging.XLevel;
-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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Jul 18, 2008
- * </p>
- */
-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(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 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);
- }
- }
+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.logging.XLevel;
+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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jul 18, 2008
+ * </p>
+ */
+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(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 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);
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java 2010-08-05 01:16:09 UTC (rev 5993)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java 2010-08-05 01:17:10 UTC (rev 5994)
@@ -1,320 +1,320 @@
-/*
-* 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Rev$
- * <p>
- * Copyright Apr 21, 2009
- * </p>
- */
-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");
- }
- }
+/*
+* 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Apr 21, 2009
+ * </p>
+ */
+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");
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/socketfactory/UseAllSocketFactoryParamsTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5993 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/shutdown.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:16:09 -0400 (Wed, 04 Aug 2010)
New Revision: 5993
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/shutdown/ShutdownExceptionTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/shutdown/ShutdownExceptionTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/shutdown/ShutdownExceptionTestCase.java 2010-08-05 01:15:35 UTC (rev 5992)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/shutdown/ShutdownExceptionTestCase.java 2010-08-05 01:16:09 UTC (rev 5993)
@@ -1,238 +1,238 @@
-/*
- * 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.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.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.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-
-/**
- * Unit test for JBREM-1073.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Dec 26, 2008
- * </p>
- */
-public class ShutdownExceptionTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ShutdownExceptionTestCase.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 testDefaultBehavior() throws Throwable
- {
- log.info("entering " + getName());
- HashMap config = new HashMap();
- doTestDefaultBehavior(config);
- log.info(getName() + " PASSES");
- }
-
-
- public void testChangeInvalidStateToCannotConnectFalse() throws Throwable
- {
- System.out.println("");
- log.info("entering " + getName());
- HashMap config = new HashMap();
- config.put(Remoting.CHANGE_INVALID_STATE_TO_CANNOT_CONNECT, "false");
- doTestDefaultBehavior(config);
- log.info(getName() + " PASSES");
- }
-
-
- public void testChangeInvalidStateToCannotConnectTrue() throws Throwable
- {
- System.out.println("");
- log.info("entering " + getName());
-
- try
- {
- HashMap config = new HashMap();
- config.put(Remoting.CHANGE_INVALID_STATE_TO_CANNOT_CONNECT, "true");
- doTest(config);
- fail("No Exception: expected CannotConnectException");
- }
- catch (CannotConnectException e)
- {
- log.info("got expected CannotConnectException");
- }
- catch (Throwable t)
- {
- log.error("Expected CannotConnectException", t);
- fail("Expected CannotConnectException: got " + t);
- }
-
- log.info(getName() + " PASSES");
- }
-
-
- protected void doTestDefaultBehavior(Map config) throws Throwable
- {
- try
- {
- doTest(config);
- fail("No Exception: expected InvalidStateException");
- }
- catch (ServerInvoker.InvalidStateException e)
- {
- log.info("got expected InvalidStateException");
- }
- catch (Throwable t)
- {
- log.error("Expected InvalidStateException", t);
- fail("Expected InvalidStateException: got " + t);
- }
- }
-
-
- protected void doTest(Map config) throws Throwable
- {
- // Start server.
- setupServer();
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(config);
- Client client = new Client(clientLocator, config);
- client.connect();
- log.info("client is connected");
-
- // Test connection.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- // Give ServerThread time to start to read version (socket and bisocket transports).
- Thread.sleep(1000);
-
- // Shut down server.
- shutdownServer();
-
- // Try invocation.
- client.invoke("xyz");
-
- client.disconnect();
- }
-
-
- 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) {}
- }
+/*
+ * 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.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.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.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+/**
+ * Unit test for JBREM-1073.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Dec 26, 2008
+ * </p>
+ */
+public class ShutdownExceptionTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(ShutdownExceptionTestCase.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 testDefaultBehavior() throws Throwable
+ {
+ log.info("entering " + getName());
+ HashMap config = new HashMap();
+ doTestDefaultBehavior(config);
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testChangeInvalidStateToCannotConnectFalse() throws Throwable
+ {
+ System.out.println("");
+ log.info("entering " + getName());
+ HashMap config = new HashMap();
+ config.put(Remoting.CHANGE_INVALID_STATE_TO_CANNOT_CONNECT, "false");
+ doTestDefaultBehavior(config);
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testChangeInvalidStateToCannotConnectTrue() throws Throwable
+ {
+ System.out.println("");
+ log.info("entering " + getName());
+
+ try
+ {
+ HashMap config = new HashMap();
+ config.put(Remoting.CHANGE_INVALID_STATE_TO_CANNOT_CONNECT, "true");
+ doTest(config);
+ fail("No Exception: expected CannotConnectException");
+ }
+ catch (CannotConnectException e)
+ {
+ log.info("got expected CannotConnectException");
+ }
+ catch (Throwable t)
+ {
+ log.error("Expected CannotConnectException", t);
+ fail("Expected CannotConnectException: got " + t);
+ }
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void doTestDefaultBehavior(Map config) throws Throwable
+ {
+ try
+ {
+ doTest(config);
+ fail("No Exception: expected InvalidStateException");
+ }
+ catch (ServerInvoker.InvalidStateException e)
+ {
+ log.info("got expected InvalidStateException");
+ }
+ catch (Throwable t)
+ {
+ log.error("Expected InvalidStateException", t);
+ fail("Expected InvalidStateException: got " + t);
+ }
+ }
+
+
+ protected void doTest(Map config) throws Throwable
+ {
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(config);
+ Client client = new Client(clientLocator, config);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Give ServerThread time to start to read version (socket and bisocket transports).
+ Thread.sleep(1000);
+
+ // Shut down server.
+ shutdownServer();
+
+ // Try invocation.
+ client.invoke("xyz");
+
+ client.disconnect();
+ }
+
+
+ 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) {}
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/shutdown/ShutdownExceptionTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5992 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/registry.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:15:35 -0400 (Wed, 04 Aug 2010)
New Revision: 5992
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRaceTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRaceTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRaceTestCase.java 2010-08-05 01:14:57 UTC (rev 5991)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRaceTestCase.java 2010-08-05 01:15:35 UTC (rev 5992)
@@ -1,304 +1,304 @@
-package org.jboss.test.remoting.registry;
-
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-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.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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- *
- * <p>
- * Copyright Nov 8, 2008
- * </p>
- */
-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(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 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
- {
- InvokerRegistry.updateServerInvokerLocator(locator, locator);
- 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);
- }
- }
- }
+package org.jboss.test.remoting.registry;
+
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+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.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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ *
+ * <p>
+ * Copyright Nov 8, 2008
+ * </p>
+ */
+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(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 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
+ {
+ InvokerRegistry.updateServerInvokerLocator(locator, locator);
+ 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);
+ }
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/registry/InvokerRegistryRaceTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months
JBoss Remoting SVN: r5991 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:14:57 -0400 (Wed, 04 Aug 2010)
New Revision: 5991
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,351 +1,351 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 21, 2009
- * </p>
- */
-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, 16));
- 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, 8));
- 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");
- }
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+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, 16));
+ 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, 8));
+ 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");
+ }
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,73 +1,73 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 24, 2009
- * </p>
- */
-public class ConfigTestMarshaller extends SerializableMarshaller
-{
- protected static Logger log = Logger.getLogger(ConfigTestMarshaller.class);
- private static final long serialVersionUID = 1L;
- public static int cloned;
- public static boolean wrote;
-
- public void write(Object dataObject, OutputStream output, int version) throws IOException
- {
- log.info(this + "writing Wrapper");
- super.write(new Wrapper(dataObject), output, version);
- wrote = true;
- }
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- cloned++;
-// log.info("cloned ConfigTestMarshaller", new Exception());
-// log.info("cloned ConfigTestMarshaller", new Exception());
- return new ConfigTestMarshaller();
- }
-
- public static boolean ok(boolean b, int count)
- {
- log.info("wrote: " + wrote + ", cloned: " + cloned);
- return wrote == b && cloned == count;
- }
-
- public static void reset()
- {
- cloned = 0;
- wrote = false;
- log.info("reset: wrote: " + wrote + ", cloned: " + cloned);
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+public class ConfigTestMarshaller extends SerializableMarshaller
+{
+ protected static Logger log = Logger.getLogger(ConfigTestMarshaller.class);
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean wrote;
+
+ public void write(Object dataObject, OutputStream output, int version) throws IOException
+ {
+ log.info(this + "writing Wrapper");
+ super.write(new Wrapper(dataObject), output, version);
+ wrote = true;
+ }
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+// log.info("cloned ConfigTestMarshaller", new Exception());
+// log.info("cloned ConfigTestMarshaller", new Exception());
+ return new ConfigTestMarshaller();
+ }
+
+ public static boolean ok(boolean b, int count)
+ {
+ log.info("wrote: " + wrote + ", cloned: " + cloned);
+ return wrote == b && cloned == count;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ wrote = false;
+ log.info("reset: wrote: " + wrote + ", cloned: " + cloned);
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,80 +1,80 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 24, 2009
- * </p>
- */
-public class ConfigTestUnmarshaller extends SerializableUnMarshaller
-{
- protected static Logger log = Logger.getLogger(ConfigTestUnmarshaller.class);
- private static final long serialVersionUID = 1L;
- public static int cloned;
- public static 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;
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+public class ConfigTestUnmarshaller extends SerializableUnMarshaller
+{
+ protected static Logger log = Logger.getLogger(ConfigTestUnmarshaller.class);
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static 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;
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,404 +1,404 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 20, 2009
- * </p>
- */
-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.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);
- }
-
- 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;
- 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();
- }
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 20, 2009
+ * </p>
+ */
+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.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);
+ }
+
+ 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;
+ 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();
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,40 +1,40 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 21, 2009
- * </p>
- */
-public class HttpConfigurationMapTestCase extends ConfigurationMapTestParent
-{
- protected String getTransport()
- {
- return "http";
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class HttpConfigurationMapTestCase extends ConfigurationMapTestParent
+{
+ protected String getTransport()
+ {
+ return "http";
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,58 +1,58 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 24, 2009
- * </p>
- */
-public class LocatorTestMarshaller extends ConfigTestMarshaller
-{
- private static final long serialVersionUID = 1L;
- public static int cloned;
- public static 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;
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+public class LocatorTestMarshaller extends ConfigTestMarshaller
+{
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static 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;
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,59 +1,59 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 24, 2009
- * </p>
- */
-public class LocatorTestUnmarshaller extends ConfigTestUnmarshaller
-{
- private static final long serialVersionUID = 1L;
- public static int cloned;
- public static 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;
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+public class LocatorTestUnmarshaller extends ConfigTestUnmarshaller
+{
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static 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;
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,40 +1,40 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 21, 2009
- * </p>
- */
-public class RMIConfigurationMapTestCase extends ConfigurationMapTestParent
-{
- protected String getTransport()
- {
- return "rmi";
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class RMIConfigurationMapTestCase extends ConfigurationMapTestParent
+{
+ protected String getTransport()
+ {
+ return "rmi";
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,40 +1,40 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 21, 2009
- * </p>
- */
-public class SocketConfigurationMapTestCase extends ConfigurationMapTestParent
-{
- protected String getTransport()
- {
- return "socket";
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class SocketConfigurationMapTestCase extends ConfigurationMapTestParent
+{
+ protected String getTransport()
+ {
+ return "socket";
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,49 +1,49 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 24, 2009
- * </p>
- */
- 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) {}
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+ 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) {}
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java 2010-08-05 01:13:36 UTC (rev 5990)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java 2010-08-05 01:14:57 UTC (rev 5991)
@@ -1,44 +1,44 @@
-/*
- * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Mar 24, 2009
- * </p>
- */
-class Wrapper implements Serializable
-{
- private static final long serialVersionUID = 1L;
- public Object wrappee;
-
- public Wrapper(Object o)
- {
- wrappee = o;
- }
-}
-
+/*
+ * 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 <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+class Wrapper implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ public Object wrappee;
+
+ public Wrapper(Object o)
+ {
+ wrappee = o;
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java
___________________________________________________________________
Name: svn:eol-style
+ native
15 years, 3 months