JBoss Remoting SVN: r4078 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 03:41:28 -0400 (Fri, 25 Apr 2008)
New Revision: 4078
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.java
Log:
JBREM-955: Added assertion to verify thrown exception is not a CannotConnectException.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.java 2008-04-25 07:22:05 UTC (rev 4077)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.java 2008-04-25 07:41:28 UTC (rev 4078)
@@ -34,6 +34,7 @@
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;
@@ -142,6 +143,7 @@
Throwable t = t2.throwable;
log.info("throwable: " + t);
assertTrue(t instanceof RuntimeException);
+ assertFalse(t instanceof CannotConnectException);
assertTrue(t.getCause() instanceof InterruptedException);
client.disconnect();
16 years, 7 months
JBoss Remoting SVN: r4077 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket: interrupt and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 03:22:05 -0400 (Fri, 25 Apr 2008)
New Revision: 4077
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.java
Log:
JBREM-955: New unit test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/interrupt/InterruptedExceptionTestCase.java 2008-04-25 07:22:05 UTC (rev 4077)
@@ -0,0 +1,238 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.remoting.transport.socket.interrupt;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.socket.MicroSocketClientInvoker;
+
+
+/**
+ * Unit test for JBREM-955.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Apr 25, 2008
+ * </p>
+ */
+public class InterruptedExceptionTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(InterruptedExceptionTestCase.class);
+
+ private static boolean firstTime = true;
+ private static String FAST = "fast";
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testInterruptedException() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(MicroSocketClientInvoker.MAX_POOL_SIZE_FLAG, "1");
+ clientConfig.put("numberOfCallRetries", "1");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals(FAST, client.invoke(FAST));
+ log.info("connection is good");
+
+ InvokerThread t1 = new InvokerThread(client, "abc");
+ InvokerThread t2 = new InvokerThread(client, "xyz");
+
+ // Start first invocation.
+ t1.start();
+ log.info("started first invocation");
+
+ // Give first invocation time to start.
+ Thread.sleep(5000);
+
+ // Start second invocation.
+ t2.start();
+ log.info("started second invocation");
+
+ // Give second invocation time to start.
+ Thread.sleep(5000);
+
+ // Interrupt second invocation as it waits for a semaphore.
+ t2.interrupt();
+ log.info("interrupted second invocation");
+
+ // Wait until second invocation throws an exception.
+ synchronized (t2)
+ {
+ t2.wait(10000);
+ }
+
+ // Verify exception is an InterruptedException wrapped in a RuntimeExceptio.
+ Throwable t = t2.throwable;
+ log.info("throwable: " + t);
+ assertTrue(t instanceof RuntimeException);
+ assertTrue(t.getCause() instanceof InterruptedException);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Object o = invocation.getParameter();
+ if (!FAST.equals(o))
+ {
+ Thread.sleep(20000);
+ }
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class InvokerThread extends Thread
+ {
+ static int counter;
+ Client client;
+ String message;
+ Throwable throwable;
+
+ public InvokerThread(Client client, String message)
+ {
+ this.client = client;
+ this.message = message;
+ setName("InvokerThread:" + counter++);
+ }
+
+ public void run()
+ {
+ try
+ {
+ log.info("invocation succeeded: " + client.invoke(message));
+ }
+ catch (Throwable t)
+ {
+ throwable = t;
+ log.error("invocation error: " + t.getMessage());
+ }
+
+ synchronized (this)
+ {
+ notify();
+ }
+ }
+ }
+}
\ No newline at end of file
16 years, 7 months
JBoss Remoting SVN: r4076 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 03:21:20 -0400 (Fri, 25 Apr 2008)
New Revision: 4076
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
Log:
JBREM-955: Wraps InterruptedException in a RuntimeException.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java 2008-04-25 07:20:36 UTC (rev 4075)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java 2008-04-25 07:21:20 UTC (rev 4076)
@@ -130,6 +130,12 @@
throw new InvocationFailureException(message, ex);
}
+ if (ex instanceof InterruptedException)
+ {
+ log.debug(this, ex);
+ throw new RuntimeException(ex);
+ }
+
throw new InvocationFailureException("Unable to perform invocation", ex);
}
16 years, 7 months
JBoss Remoting SVN: r4075 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 03:20:36 -0400 (Fri, 25 Apr 2008)
New Revision: 4075
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
Log:
JBREM-955: Wraps InterruptedException in a RuntimeException.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-04-25 05:55:04 UTC (rev 4074)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-04-25 07:20:36 UTC (rev 4075)
@@ -730,6 +730,12 @@
long d = System.currentTimeMillis() - l;
if (trace) log.trace("took " + d + " ms to get socket " + socketWrapper);
}
+ catch (InterruptedException e)
+ {
+ semaphore.release();
+ if (trace) log.trace(this + " released semaphore: " + semaphore.permits(), e);
+ throw new RuntimeException(e);
+ }
catch (Exception e)
{
// if (bailOut)
@@ -918,6 +924,12 @@
log.debug(this, ex);
throw (CannotConnectException) ex;
}
+
+ if (ex instanceof InterruptedException)
+ {
+ log.debug(this, ex);
+ throw new RuntimeException(ex);
+ }
throw new InvocationFailureException("Unable to perform invocation", ex);
}
16 years, 7 months
JBoss Remoting SVN: r4074 - in remoting2/branches/2.x/src/etc/lib: remoting_2_2_2_SP7 and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 01:55:04 -0400 (Fri, 25 Apr 2008)
New Revision: 4074
Added:
remoting2/branches/2.x/src/etc/lib/remoting_2_2_2_SP7/
remoting2/branches/2.x/src/etc/lib/remoting_2_2_2_SP7/jboss-remoting.jar
Log:
JBREM-967: Added 2.2.2.SP7 jboss-remoting.jar.
Added: remoting2/branches/2.x/src/etc/lib/remoting_2_2_2_SP7/jboss-remoting.jar
===================================================================
(Binary files differ)
Property changes on: remoting2/branches/2.x/src/etc/lib/remoting_2_2_2_SP7/jboss-remoting.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 7 months
JBoss Remoting SVN: r4073 - remoting2/branches/2.x/src/etc.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 01:53:27 -0400 (Fri, 25 Apr 2008)
New Revision: 4073
Modified:
remoting2/branches/2.x/src/etc/remoting.security.policy.tests.minimal
Log:
JBREM-920, JBREM-934: Moved "jboss-junit-configuration" property permission to tests.
Modified: remoting2/branches/2.x/src/etc/remoting.security.policy.tests.minimal
===================================================================
--- remoting2/branches/2.x/src/etc/remoting.security.policy.tests.minimal 2008-04-25 05:52:43 UTC (rev 4072)
+++ remoting2/branches/2.x/src/etc/remoting.security.policy.tests.minimal 2008-04-25 05:53:27 UTC (rev 4073)
@@ -25,13 +25,6 @@
//**** Minimal set of permissions for tests ****
//******************************************************************
//******************************************************************
-
-grant codeBase "file:${build.home}/output/lib/jboss-remoting.jar"
-{
- // org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter calls
- // org.jboss.remoting.util.SystemUtility
- permission java.util.PropertyPermission "jboss-junit-configuration", "read";
-};
grant codeBase "file:${build.home}/output/tests/classes/-"
{
@@ -41,6 +34,7 @@
// org.jboss.test.taskdefs.XMLJUnitMultipleResultFormatter
permission java.net.SocketPermission "*:*", "connect";
+ permission java.util.PropertyPermission "jboss-junit-configuration", "read";
/////////////////////////////////////////////////////////////////////////////////////////////
// TODO - We should use a version of JBoss logging + log4j that does this stuff in privileged blocks
16 years, 7 months
JBoss Remoting SVN: r4072 - remoting2/branches/2.x/src/etc.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 01:52:43 -0400 (Fri, 25 Apr 2008)
New Revision: 4072
Modified:
remoting2/branches/2.x/src/etc/remoting.security.policy.tests
Log:
JBREM-920, JBREM-934: Move "jboss-junit-configuration" property permission to tests.
Modified: remoting2/branches/2.x/src/etc/remoting.security.policy.tests
===================================================================
--- remoting2/branches/2.x/src/etc/remoting.security.policy.tests 2008-04-25 05:00:30 UTC (rev 4071)
+++ remoting2/branches/2.x/src/etc/remoting.security.policy.tests 2008-04-25 05:52:43 UTC (rev 4072)
@@ -36,10 +36,6 @@
// org.jboss.test.remoting.detection.metadata.MetadataTestCase
permission javax.management.MBeanPermission "org.jboss.test.remoting.detection.metadata.MetadataTestCase$TestNetworkRegistry#-[remoting:type=NetworkRegistry]", "isInstanceOf";
-
- // org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter calls
- // org.jboss.remoting.util.SystemUtility
- permission java.util.PropertyPermission "jboss-junit-configuration", "read";
};
@@ -87,6 +83,9 @@
// org.jboss.test.remoting.transport.connector.ObjectNameWithZeroesAddressTestCase
permission javax.management.MBeanPermission "*#-[*:*]", "queryMBeans";
+ // org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter
+ permission java.util.PropertyPermission "jboss-junit-configuration", "read";
+
// This is technically the JNP server, but it seems intentional - note that this might mask other problems though
permission java.net.SocketPermission "*:*", "accept, connect, resolve";
16 years, 7 months
JBoss Remoting SVN: r4071 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 01:00:30 -0400 (Fri, 25 Apr 2008)
New Revision: 4071
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/SoakConstants.java
Log:
JBREM-969: Cnanged DURATION..
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/SoakConstants.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/SoakConstants.java 2008-04-25 04:59:31 UTC (rev 4070)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/SoakConstants.java 2008-04-25 05:00:30 UTC (rev 4071)
@@ -35,7 +35,7 @@
public static final int CALLBACK_LISTENERS = 5;
- public static final int DURATION = 36000000;
+ public static final int DURATION = 12 * 60 * 60 * 1000;
public static final int INTERVAL = 1000000;
16 years, 7 months
JBoss Remoting SVN: r4070 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 00:59:31 -0400 (Fri, 25 Apr 2008)
New Revision: 4070
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java
Log:
JBREM-969: Can now shut down Connectors at end of run.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java 2008-04-25 04:58:36 UTC (rev 4069)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ServerLauncher.java 2008-04-25 04:59:31 UTC (rev 4070)
@@ -57,6 +57,7 @@
{
private static Logger log = Logger.getLogger(ServerLauncher.class);
private static Map locators = new HashMap();
+ private static Connector[] connectors = new Connector[4];
public static Map getLocators()
{
@@ -76,19 +77,31 @@
String host = InetAddress.getLocalHost().getHostAddress();
- Connector connector = setupServer(host, 6666, "bisocket");
- locators.put("bisocket", connector.getLocator().getLocatorURI());
+ connectors[0] = setupServer(host, 6666, "bisocket");
+ locators.put("bisocket", connectors[0].getLocator().getLocatorURI());
- connector = setupServer(host, 6667, "http");
- locators.put("http", connector.getLocator().getLocatorURI());
+ connectors[1] = setupServer(host, 6667, "http");
+ locators.put("http", connectors[1].getLocator().getLocatorURI());
- connector = setupServer(host, 6668, "rmi");
- locators.put("rmi", connector.getLocator().getLocatorURI());
+ connectors[2] = setupServer(host, 6668, "rmi");
+ locators.put("rmi", connectors[2].getLocator().getLocatorURI());
- connector = setupServer(host, 6669, "socket");
- locators.put("socket", connector.getLocator().getLocatorURI());
+ connectors[3] = setupServer(host, 6669, "socket");
+ locators.put("socket", connectors[3].getLocator().getLocatorURI());
log.info("SERVERS CREATED: " + locators);
+
+ System.in.read();
+ System.in.read();
+ System.in.read();
+
+ log.info("SHUTTING DOWN SERVERS");
+ for (int i = 0; i < connectors.length; i++)
+ {
+ connectors[i].stop();
+ }
+ log.info("SERVERS SHUT DOWN");
+
}
catch (Exception e)
{
16 years, 7 months
JBoss Remoting SVN: r4069 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-04-25 00:58:36 -0400 (Fri, 25 Apr 2008)
New Revision: 4069
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java
Log:
JBREM-969: Removed some comments; synchronized printSet().
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java 2008-04-25 01:37:25 UTC (rev 4068)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/soak/ClientLauncher.java 2008-04-25 04:58:36 UTC (rev 4069)
@@ -71,9 +71,6 @@
private static boolean creationDone;
// Configuration parameters.
-// private static long DURATION = 12 * 60 * 60 * 1000;
-// private static long DURATION = 1 * 60 * 60 * 1000;
- private static long DURATION = 30000;
private static int MAX_CLIENTS = 30;
private static int NUMBER_OF_EJB_CALLS = 4000;
private static int NUMBER_OF_JBM_CALLS = 2000;
@@ -235,10 +232,13 @@
private void printSet(Set set)
{
- Iterator it = set.iterator();
- while(it.hasNext())
+ synchronized (set)
{
- System.out.println(it.next().toString());
+ Iterator it = set.iterator();
+ while(it.hasNext())
+ {
+ System.out.println(it.next().toString());
+ }
}
}
}
16 years, 7 months