JBoss Remoting SVN: r5880 - remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-24 20:19:09 -0400 (Thu, 24 Jun 2010)
New Revision: 5880
Modified:
remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor
Log:
JBREM-1228: Reverting to previous, correct version.
Modified: remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor 2010-06-25 00:17:07 UTC (rev 5879)
+++ remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor 2010-06-25 00:19:09 UTC (rev 5880)
@@ -1,5 +1,5 @@
#
-# Remoting "mockTransport" protocol descriptor
+# Remoting "remote" protocol descriptors
#
org.jboss.remoting3.remote.RemoteProtocolDescriptor
-org.jboss.remoting3.remote.RemoteSslProtocolDescriptor
\ No newline at end of file
+org.jboss.remoting3.remote.RemoteSslProtocolDescriptor
14 years, 2 months
JBoss Remoting SVN: r5879 - remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-24 20:17:07 -0400 (Thu, 24 Jun 2010)
New Revision: 5879
Removed:
remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.marshalling.ProviderDescriptor
Log:
JBREM-1228: Put this file in the wrong directory.
Deleted: remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.marshalling.ProviderDescriptor
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.marshalling.ProviderDescriptor 2010-06-25 00:02:04 UTC (rev 5878)
+++ remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.marshalling.ProviderDescriptor 2010-06-25 00:17:07 UTC (rev 5879)
@@ -1,5 +0,0 @@
-#
-# MockMarshaller provider descriptor
-#
-
-org.jboss.remoting3.test.EndpointConfigurationTestCase$MockMarshallerProviderDescriptor
14 years, 2 months
JBoss Remoting SVN: r5878 - remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-24 20:02:04 -0400 (Thu, 24 Jun 2010)
New Revision: 5878
Modified:
remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor
Log:
JBREM-1228: Added stuff to the wrong RemotingServiceDescriptor.
Modified: remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor 2010-06-24 23:25:30 UTC (rev 5877)
+++ remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor 2010-06-25 00:02:04 UTC (rev 5878)
@@ -1,13 +1,5 @@
#
# Remoting "mockTransport" protocol descriptor
#
-
org.jboss.remoting3.remote.RemoteProtocolDescriptor
-org.jboss.remoting3.remote.RemoteSslProtocolDescriptor
-
-org.jboss.remoting3.test.EndpointConfigurationTestCase$MockProtocolDescriptor
-org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassExternalizerFactoryServiceDescriptor
-org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassResolverServiceDescriptor
-org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassTableServiceDescriptor
-org.jboss.remoting3.test.EndpointConfigurationTestCase$MockObjectResolverServiceDescriptor
-org.jboss.remoting3.test.EndpointConfigurationTestCase$MockObjectTableServiceDescriptor
\ No newline at end of file
+org.jboss.remoting3.remote.RemoteSslProtocolDescriptor
\ No newline at end of file
14 years, 2 months
JBoss Remoting SVN: r5877 - remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-24 19:25:30 -0400 (Thu, 24 Jun 2010)
New Revision: 5877
Modified:
remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor
Log:
JBREM-1228: Forgot to commit RemotingServiceDescriptor file for EndpointConfigurationTestCase.
Modified: remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor 2010-06-23 14:12:55 UTC (rev 5876)
+++ remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.remoting3.spi.RemotingServiceDescriptor 2010-06-24 23:25:30 UTC (rev 5877)
@@ -1,5 +1,13 @@
#
-# Remoting "remote" protocol descriptors
+# Remoting "mockTransport" protocol descriptor
#
+
org.jboss.remoting3.remote.RemoteProtocolDescriptor
org.jboss.remoting3.remote.RemoteSslProtocolDescriptor
+
+org.jboss.remoting3.test.EndpointConfigurationTestCase$MockProtocolDescriptor
+org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassExternalizerFactoryServiceDescriptor
+org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassResolverServiceDescriptor
+org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassTableServiceDescriptor
+org.jboss.remoting3.test.EndpointConfigurationTestCase$MockObjectResolverServiceDescriptor
+org.jboss.remoting3.test.EndpointConfigurationTestCase$MockObjectTableServiceDescriptor
\ No newline at end of file
14 years, 2 months
JBoss Remoting SVN: r5876 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-23 10:12:55 -0400 (Wed, 23 Jun 2010)
New Revision: 5876
Added:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java
Modified:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java
Log:
JBREM-1228: Added RemotingTestBase as parent class.
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java 2010-06-22 22:30:04 UTC (rev 5875)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java 2010-06-23 14:12:55 UTC (rev 5876)
@@ -63,7 +63,6 @@
import org.jboss.xnio.Options;
import org.jboss.xnio.TcpServer;
import org.jboss.xnio.Xnio;
-import org.jboss.xnio.IoFuture.Status;
import org.jboss.xnio.channels.BoundChannel;
import org.jboss.xnio.channels.ConnectedStreamChannel;
import org.jboss.xnio.log.Logger;
@@ -81,39 +80,12 @@
* Copyright Jun 7, 2010
*/
@Test(suiteName = "ClientServerRemoteConfiguration")
-public class ClientServerRemoteConfigurationTestCase {
+public class ClientServerRemoteConfigurationTestCase extends RemotingTestBase {
private static final Logger log = Logger.getLogger(ClientServerRemoteConfigurationTestCase.class);
private static int counter;
- static void enter() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
- }
-
- static void exit() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
- log.info("-------------------------------------------------------------");
- }
-
- static <T> T getFutureResult(IoFuture<T> future, String errorMessage) throws IOException {
- Status status = null;
- switch (status = future.await(5000, TimeUnit.MILLISECONDS)) {
- case DONE: {
- return future.get();
- }
- case FAILED: {
- log.error(errorMessage);
- throw future.getException();
- }
- default: {
- throw new RuntimeException("unexpected future state: " + status);
- }
- }
- }
-
@BeforeMethod
public void setUp() {
ServiceLoader.load(RemotingServiceDescriptor.class);
@@ -178,7 +150,7 @@
}
assertEquals(20, sp0.requestListener.counter, "Should be equal");
assertEquals(20, sp1.requestListener.counter, "Should be equal");
- log.info("testAllDistinct() PASSES");
+ log.info(getName() + " PASSES");
} finally {
clients.close();
connections.close();
@@ -248,7 +220,7 @@
}
assertEquals(20, sp0.requestListener.counter, "Should be equal");
assertEquals(20, sp1.requestListener.counter, "Should be equal");
- log.info("testSharedExecutor() PASSES");
+ log.info(getName() + " PASSES");
} finally {
clients.close();
connections.close();
@@ -317,7 +289,7 @@
}
assertEquals(20, sp0.requestListener.counter, "Should be equal");
assertEquals(20, sp1.requestListener.counter, "Should be equal");
- log.info("testSharedExecutorEndpoint() PASSES");
+ log.info(getName() + " PASSES");
} finally {
clients.close();
connections.close();
@@ -386,7 +358,7 @@
}
assertEquals(20, sp0.requestListener.counter, "Should be equal");
assertEquals(20, sp1.requestListener.counter, "Should be equal");
- log.info("testSharedExecutorEndpointXnio() PASSES");
+ log.info(getName() + " PASSES");
} finally {
clients.close();
connections.close();
@@ -474,7 +446,7 @@
assertEquals(10, sp01.requestListener.counter, "Should be equal");
assertEquals(10, sp10.requestListener.counter, "Should be equal");
assertEquals(10, sp11.requestListener.counter, "Should be equal");
- log.info("testSharedExecutorEndpointXnioTcpServer() PASSES");
+ log.info(getName() + " PASSES");
} finally {
clients.close();
connections.close();
@@ -558,7 +530,7 @@
assertEquals(id0, client111.invoke("dummy"), "Should be equal");
}
assertEquals(40, sp00.requestListener.counter, "Should be equal");
- log.info("testSharedExecutorEndpointXnioTcpServerRequestListener() PASSES");
+ log.info(getName() + " PASSES");
} finally {
clients.close();
connections.close();
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java 2010-06-22 22:30:04 UTC (rev 5875)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java 2010-06-23 14:12:55 UTC (rev 5876)
@@ -73,21 +73,10 @@
* Copyright Jun 21, 2010
*/
@Test(suiteName = "EndpointConfiguration")
-public class EndpointConfigurationTestCase {
+public class EndpointConfigurationTestCase extends RemotingTestBase {
private static final Logger log = Logger.getLogger(EndpointConfigurationTestCase.class);
- static void enter() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
- }
-
- static void exit() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
- log.info("-------------------------------------------------------------");
- }
-
@BeforeMethod
public void setUp() {
System.clearProperty("remoting.property.file");
@@ -148,7 +137,7 @@
assertSame(mockClassTable, context.getProtocolServiceProvider(ProtocolServiceType.CLASS_TABLE, "mockClassTable"));
assertSame(mockObjectResolver, context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver"));
assertSame(mockObjectTable, context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable"));
- log.info("testProgrammaticConfiguration() PASSES");
+ log.info(getName() + " PASSES");
} finally {
if (regClassExternalizerFactoryProvider != null) {
@@ -195,7 +184,7 @@
assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.CLASS_TABLE, "mockClassTable_sd") instanceof MockClassTable);
assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver_sd") instanceof MockObjectResolver);
assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable_sd") instanceof MockObjectTable);
- log.info("testConfigurationByServiceDescriptorFile() PASSES");
+ log.info(getName() + " PASSES");
} finally {
exit();
}
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/RemotingTestBase.java 2010-06-23 14:12:55 UTC (rev 5876)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.test;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.IoFuture.Status;
+import org.jboss.xnio.log.Logger;
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 23, 2010
+ */
+public class RemotingTestBase {
+ private static final Logger log = Logger.getLogger(RemotingTestBase.class);
+
+ protected String getName() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ return e.getMethodName();
+ }
+
+ protected static void enter() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+ }
+
+ protected static void exit() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
+ log.info("-------------------------------------------------------------");
+ }
+
+ protected static <T> T getFutureResult(IoFuture<T> future, String errorMessage) throws IOException {
+ return getFutureResult(future, 5000, errorMessage);
+ }
+
+ protected static <T> T getFutureResult(IoFuture<T> future, int timeout, String errorMessage) throws IOException {
+ Status status = null;
+ switch (status = future.await(timeout, TimeUnit.MILLISECONDS)) {
+ case DONE: {
+ return future.get();
+ }
+ case FAILED: {
+ log.error(errorMessage);
+ throw future.getException();
+ }
+ default: {
+ throw new RuntimeException("unexpected future state: " + status);
+ }
+ }
+ }
+}
Modified: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java 2010-06-22 22:30:04 UTC (rev 5875)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java 2010-06-23 14:12:55 UTC (rev 5876)
@@ -58,22 +58,11 @@
* @param <O>
*/
@Test(suiteName = "ServiceRegistration")
-public class ServiceRegistrationTestCase<O> {
+public class ServiceRegistrationTestCase<O> extends RemotingTestBase {
private static final Logger log = Logger.getLogger(ServiceRegistrationTestCase.class);
private static Object lock = new Object();
- static void enter() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
- }
-
- static void exit() {
- final StackTraceElement e = new Throwable().getStackTrace()[1];
- log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
- log.info("-------------------------------------------------------------");
- }
-
@BeforeMethod
public void setUp() {
}
@@ -115,6 +104,8 @@
assertEquals(SubReplyType.class, registrationListener.info.getReplyClass());
assertSame(optionMap, registrationListener.info.getOptionMap());
+ log.info(getName() + " PASSES");
+
} finally {
if (registration != null) {
registration.close();
@@ -172,6 +163,5 @@
lock.notify();
}
}
-
}
}
14 years, 2 months
JBoss Remoting SVN: r5875 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-22 18:30:04 -0400 (Tue, 22 Jun 2010)
New Revision: 5875
Added:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java
Log:
JBREM-1228: Added unit test for configuration of services.
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ServiceRegistrationTestCase.java 2010-06-22 22:30:04 UTC (rev 5875)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertSame;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.jboss.remoting3.ClientContext;
+import org.jboss.remoting3.ClientListener;
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remoting3.Registration;
+import org.jboss.remoting3.RemoteExecutionException;
+import org.jboss.remoting3.Remoting;
+import org.jboss.remoting3.RemotingOptions;
+import org.jboss.remoting3.RequestContext;
+import org.jboss.remoting3.RequestListener;
+import org.jboss.remoting3.ServiceRegistrationListener;
+import org.jboss.remoting3.Endpoint.ServiceBuilder;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Options;
+import org.jboss.xnio.OptionMap.Builder;
+import org.jboss.xnio.log.Logger;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests the configuration of services registered with an Endpoint.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 22, 2010
+ * @param <O>
+ */
+@Test(suiteName = "ServiceRegistration")
+public class ServiceRegistrationTestCase<O> {
+
+ private static final Logger log = Logger.getLogger(ServiceRegistrationTestCase.class);
+ private static Object lock = new Object();
+
+ static void enter() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+ }
+
+ static void exit() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
+ log.info("-------------------------------------------------------------");
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ }
+
+ @AfterMethod
+ public void tearDown() throws IOException {
+ }
+
+ @Test
+ public void testRegistration() throws Exception {
+ enter();
+ Endpoint endpoint = Remoting.getConfiguredEndpoint();
+ TestServiceRegistrationListener registrationListener = new TestServiceRegistrationListener();
+ endpoint.addServiceRegistrationListener(registrationListener, null);
+ TestClassLoader testClassLoader = new TestClassLoader();
+ ClientListener<RequestType, ReplyType> testClientListener = new TestClientListener();
+ Registration registration = null;
+
+ try {
+ ServiceBuilder<RequestType, ReplyType> sb = endpoint.serviceBuilder(RequestType.class, ReplyType.class);
+ sb.setClassLoader(testClassLoader);
+ sb.setInstanceName("instance");
+ sb.setServiceType("service");
+ sb.setRequestType(SuperRequestType.class);
+ sb.setReplyType(SubReplyType.class);
+ OptionMap optionMap = buildOptionMap();
+ sb.setOptionMap(optionMap);
+ sb.setClientListener(testClientListener);
+ registration = sb.register();
+
+ synchronized (lock) {
+ lock.wait();
+ }
+ assertNotNull(registrationListener.info);
+ assertSame(testClassLoader, registrationListener.info.getServiceClassLoader());
+ assertEquals("instance", registrationListener.info.getInstanceName());
+ assertEquals("service", registrationListener.info.getServiceType());
+ assertEquals(SuperRequestType.class, registrationListener.info.getRequestClass());
+ assertEquals(SubReplyType.class, registrationListener.info.getReplyClass());
+ assertSame(optionMap, registrationListener.info.getOptionMap());
+
+ } finally {
+ if (registration != null) {
+ registration.close();
+ }
+ if (endpoint != null) {
+ endpoint.close();
+ }
+ exit();
+ }
+ }
+
+ protected OptionMap buildOptionMap() {
+ Builder builder = OptionMap.builder();
+ builder.set(RemotingOptions.METRIC, 1);
+ builder.setSequence(Options.SASL_MECHANISMS, "EXTERNAL", "DIGEST-MD5");
+ HashMap<Object, Object> map = new HashMap<Object, Object>();
+ map.put(RemotingOptions.REMOTELY_VISIBLE, true);
+ map.put(RemotingOptions.REQUIRE_SECURE, false);
+ builder.add(map);
+ return builder.getMap();
+ }
+
+ static class TestClassLoader extends ClassLoader {
+ }
+
+ static class TestRequestListener implements RequestListener<RequestType, ReplyType> {
+ public void handleRequest(RequestContext<ReplyType> context, RequestType request) throws RemoteExecutionException {
+ }
+ }
+
+ static class TestClientListener implements ClientListener<RequestType, ReplyType> {
+ public RequestListener<RequestType, ReplyType> handleClientOpen(final ClientContext clientContext, final OptionMap optionMap) {
+ return new TestRequestListener();
+ }
+ }
+
+ static class SuperRequestType {
+ }
+
+ static class RequestType extends SuperRequestType {
+ }
+
+ static class ReplyType {
+ }
+
+ static class SubReplyType extends ReplyType {
+ }
+
+ static class TestServiceRegistrationListener implements ServiceRegistrationListener {
+ public ServiceInfo info;
+
+ public void serviceRegistered(Registration listenerHandle, ServiceInfo info) {
+ this.info = info;
+ synchronized (lock) {
+ lock.notify();
+ }
+ }
+
+ }
+}
14 years, 2 months
JBoss Remoting SVN: r5874 - remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-22 16:29:57 -0400 (Tue, 22 Jun 2010)
New Revision: 5874
Added:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteSSLConfigurationTestCase.java
Log:
JBREM-1228: Added unit tests for a variety of shared and unshared components.
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java 2010-06-22 20:29:57 UTC (rev 5874)
@@ -0,0 +1,771 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotSame;
+import static org.testng.Assert.assertSame;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.ServiceLoader;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.marshalling.river.RiverProviderDescriptor;
+import org.jboss.remoting3.Client;
+import org.jboss.remoting3.ClientContext;
+import org.jboss.remoting3.ClientListener;
+import org.jboss.remoting3.CloseHandler;
+import org.jboss.remoting3.Connection;
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remoting3.Registration;
+import org.jboss.remoting3.RemoteExecutionException;
+import org.jboss.remoting3.Remoting;
+import org.jboss.remoting3.RequestContext;
+import org.jboss.remoting3.RequestListener;
+import org.jboss.remoting3.Endpoint.ServiceBuilder;
+import org.jboss.remoting3.remote.RemoteProtocolDescriptor;
+import org.jboss.remoting3.security.SimpleServerAuthenticationProvider;
+import org.jboss.remoting3.spi.ConnectionProviderFactory;
+import org.jboss.remoting3.spi.NetworkServerProvider;
+import org.jboss.remoting3.spi.ProtocolServiceType;
+import org.jboss.remoting3.spi.RemotingServiceDescriptor;
+import org.jboss.xnio.AcceptingServer;
+import org.jboss.xnio.ChannelListener;
+import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Options;
+import org.jboss.xnio.TcpServer;
+import org.jboss.xnio.Xnio;
+import org.jboss.xnio.IoFuture.Status;
+import org.jboss.xnio.channels.BoundChannel;
+import org.jboss.xnio.channels.ConnectedStreamChannel;
+import org.jboss.xnio.log.Logger;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests various Client and Connection configurations to various
+ * server configurations of Executors, Endpoints, Xnio's, TcpServers, and RequestListeners.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 7, 2010
+ */
+@Test(suiteName = "ClientServerRemoteConfiguration")
+public class ClientServerRemoteConfigurationTestCase {
+
+ private static final Logger log = Logger.getLogger(ClientServerRemoteConfigurationTestCase.class);
+
+ private static int counter;
+
+ static void enter() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+ }
+
+ static void exit() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
+ log.info("-------------------------------------------------------------");
+ }
+
+ static <T> T getFutureResult(IoFuture<T> future, String errorMessage) throws IOException {
+ Status status = null;
+ switch (status = future.await(5000, TimeUnit.MILLISECONDS)) {
+ case DONE: {
+ return future.get();
+ }
+ case FAILED: {
+ log.error(errorMessage);
+ throw future.getException();
+ }
+ default: {
+ throw new RuntimeException("unexpected future state: " + status);
+ }
+ }
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ ServiceLoader.load(RemotingServiceDescriptor.class);
+ }
+
+ @AfterMethod
+ public void tearDown() throws IOException {
+ }
+
+ /**
+ * Distinct Executors, Endpoints, Xnio's, TcpServers, RequestListeners.
+ * One instance of one service in each Endpoint.
+ * Two Connections per TcpServer, two Clients per Connection.
+ */
+ @Test
+ public void testAllDistinct() throws Exception {
+ enter();
+ ServerPackage sp0 = null;
+ ServerPackage sp1 = null;
+ ConnectionSet connections = new ConnectionSet();
+ ClientSet clients = new ClientSet();
+
+ try {
+ int id0 = counter++;
+ int id1 = counter++;
+
+ // Set up services.
+ sp0 = setupServer(null, id0, null, "test", "test", 4444);
+ sp1 = setupServer(null, id1, null, "test", "test", 5555);
+
+ // Verify configuration.
+ assertNotSame(sp0.executor, sp1.executor, "Should be distinct");
+ assertNotSame(sp0.endpoint, sp1.endpoint, "Should be distinct");
+ assertNotSame(sp0.xnio, sp1.xnio, "Should be distinct");
+ assertNotSame(sp0.tcpServer, sp1.tcpServer, "Should be distinct");
+ assertNotSame(sp0.requestListener, sp1.requestListener, "Should be distinct");
+
+ // Set up connections and clients.
+ Connection connection00 = setupConnection(4444); connections.add(connection00);
+ Connection connection01 = setupConnection(4444); connections.add(connection01);
+ Connection connection10 = setupConnection(5555); connections.add(connection10);
+ Connection connection11 = setupConnection(5555); connections.add(connection11);
+ Client<Object, Object> client000 = setupClient(connection00, "test", "test"); clients.add(client000);
+ Client<Object, Object> client001 = setupClient(connection00, "test", "test"); clients.add(client001);
+ Client<Object, Object> client010 = setupClient(connection01, "test", "test"); clients.add(client010);
+ Client<Object, Object> client011 = setupClient(connection01, "test", "test"); clients.add(client011);
+ Client<Object, Object> client100 = setupClient(connection10, "test", "test"); clients.add(client100);
+ Client<Object, Object> client101 = setupClient(connection10, "test", "test"); clients.add(client101);
+ Client<Object, Object> client110 = setupClient(connection11, "test", "test"); clients.add(client110);
+ Client<Object, Object> client111 = setupClient(connection11, "test", "test"); clients.add(client111);
+
+ // Test invocations.
+ for (int i = 0; i < 5; i++) {
+ assertEquals(id0, client000.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client001.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client010.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client011.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client100.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client101.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client110.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client111.invoke("dummy"), "Should be equal");
+ }
+ assertEquals(20, sp0.requestListener.counter, "Should be equal");
+ assertEquals(20, sp1.requestListener.counter, "Should be equal");
+ log.info("testAllDistinct() PASSES");
+ } finally {
+ clients.close();
+ connections.close();
+ sp0.close();
+ sp1.close();
+ exit();
+ }
+ }
+
+ /**
+ * Distinct Endpoints, Xnio's, TcpServers, RequestListeners.
+ * One instance of one service in each Endpoint.
+ * Two Connections per TcpServer, two Clients per Connection.
+ */
+ @Test
+ public void testSharedExecutor() throws Exception {
+ enter();
+ ServerPackage sp0 = null;
+ ServerPackage sp1 = null;
+ ConnectionSet connections = new ConnectionSet();
+ ClientSet clients = new ClientSet();
+
+ try {
+ int id0 = counter++;
+ int id1 = counter++;
+ String serviceType0 = "test" + id0;
+ String instanceName0 = serviceType0;
+ String serviceType1 = "test" + id1;
+ String instanceName1 = serviceType1;
+
+ // Set up services.
+ sp0 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ sp1 = new ServerPackage(sp0.executor, null, null, null, null, null, -1);
+ setupServer(sp1, id1, null, serviceType1, instanceName1, 0);
+
+ // Verify configuration.
+ assertSame(sp0.executor, sp1.executor, "Should be same");
+ assertNotSame(sp0.endpoint, sp1.endpoint, "Should be distinct");
+ assertNotSame(sp0.xnio, sp1.xnio, "Should be distinct");
+ assertNotSame(sp0.tcpServer, sp1.tcpServer, "Should be distinct");
+ assertNotSame(sp0.requestListener, sp1.requestListener, "Should be distinct");
+
+ // Set up connections and clients.
+ Connection connection00 = setupConnection(sp0.port); connections.add(connection00);
+ Connection connection01 = setupConnection(sp0.port); connections.add(connection01);
+ Connection connection10 = setupConnection(sp1.port); connections.add(connection10);
+ Connection connection11 = setupConnection(sp1.port); connections.add(connection11);
+ Client<Object, Object> client000 = setupClient(connection00, serviceType0, instanceName0); clients.add(client000);
+ Client<Object, Object> client001 = setupClient(connection00, serviceType0, instanceName0); clients.add(client001);
+ Client<Object, Object> client010 = setupClient(connection01, serviceType0, instanceName0); clients.add(client010);
+ Client<Object, Object> client011 = setupClient(connection01, serviceType0, instanceName0); clients.add(client011);
+ Client<Object, Object> client100 = setupClient(connection10, serviceType1, instanceName1); clients.add(client100);
+ Client<Object, Object> client101 = setupClient(connection10, serviceType1, instanceName1); clients.add(client101);
+ Client<Object, Object> client110 = setupClient(connection11, serviceType1, instanceName1); clients.add(client110);
+ Client<Object, Object> client111 = setupClient(connection11, serviceType1, instanceName1); clients.add(client111);
+
+ // Test invocations.
+ for (int i = 0; i < 5; i++) {
+ assertEquals(id0, client000.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client001.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client010.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client011.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client100.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client101.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client110.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client111.invoke("dummy"), "Should be equal");
+ }
+ assertEquals(20, sp0.requestListener.counter, "Should be equal");
+ assertEquals(20, sp1.requestListener.counter, "Should be equal");
+ log.info("testSharedExecutor() PASSES");
+ } finally {
+ clients.close();
+ connections.close();
+ sp0.close();
+ sp1.close();
+ exit();
+ }
+ }
+
+ /**
+ * Distinct Xnio's, TcpServers, RequestListeners: one instance each of two distinct services in single Endpoint
+ * Two Connections per TcpServer, two Clients per Connection, one connected to service1 and the other connected to service2.
+ */
+ @Test
+ public void testSharedExecutorEndpoint() throws Exception {
+ enter();
+ ServerPackage sp0 = null;
+ ServerPackage sp1 = null;
+ ConnectionSet connections = new ConnectionSet();
+ ClientSet clients = new ClientSet();
+
+ try {
+ int id0 = counter++;
+ int id1 = counter++;
+ String serviceType0 = "test" + id0;
+ String instanceName0 = serviceType0;
+ String serviceType1 = "test" + id1;
+ String instanceName1 = serviceType1;
+
+ // Set up services.
+ sp0 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ sp1 = new ServerPackage(sp0.executor, sp0.endpoint, null, null, null, null, -1);
+ setupServer(sp1, id1, null, serviceType1, instanceName1, 0);
+
+ // Verify configuration.
+ assertSame(sp0.executor, sp1.executor, "Should be same");
+ assertSame(sp0.endpoint, sp1.endpoint, "Should be same");
+ assertNotSame(sp0.xnio, sp1.xnio, "Should be distinct");
+ assertNotSame(sp0.tcpServer, sp1.tcpServer, "Should be distinct");
+ assertNotSame(sp0.requestListener, sp1.requestListener, "Should be distinct");
+
+ // Set up connections and clients.
+ Connection connection00 = setupConnection(sp0.port); connections.add(connection00);
+ Connection connection01 = setupConnection(sp0.port); connections.add(connection01);
+ Connection connection10 = setupConnection(sp1.port); connections.add(connection10);
+ Connection connection11 = setupConnection(sp1.port); connections.add(connection11);
+ Client<Object, Object> client000 = setupClient(connection00, serviceType0, instanceName0); clients.add(client000);
+ Client<Object, Object> client001 = setupClient(connection00, serviceType1, instanceName1); clients.add(client001);
+ Client<Object, Object> client010 = setupClient(connection01, serviceType0, instanceName0); clients.add(client010);
+ Client<Object, Object> client011 = setupClient(connection01, serviceType1, instanceName1); clients.add(client011);
+ Client<Object, Object> client100 = setupClient(connection10, serviceType0, instanceName0); clients.add(client100);
+ Client<Object, Object> client101 = setupClient(connection10, serviceType1, instanceName1); clients.add(client101);
+ Client<Object, Object> client110 = setupClient(connection11, serviceType0, instanceName0); clients.add(client110);
+ Client<Object, Object> client111 = setupClient(connection11, serviceType1, instanceName1); clients.add(client111);
+
+ // Test invocations.
+ for (int i = 0; i < 5; i++) {
+ assertEquals(id0, client000.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client001.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client010.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client011.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client100.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client101.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client110.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client111.invoke("dummy"), "Should be equal");
+ }
+ assertEquals(20, sp0.requestListener.counter, "Should be equal");
+ assertEquals(20, sp1.requestListener.counter, "Should be equal");
+ log.info("testSharedExecutorEndpoint() PASSES");
+ } finally {
+ clients.close();
+ connections.close();
+ sp0.close();
+ sp1.close();
+ exit();
+ }
+ }
+
+ /**
+ * Distinct TcpServers, RequestListeners: one instance each of two distinct services in single Endpoint
+ * Two Connections per TcpServer, two Clients per Connection, one connected to service1 and the other connected to service2.
+ */
+ @Test
+ public void testSharedExecutorEndpointXnio() throws Exception {
+ enter();
+ ServerPackage sp0 = null;
+ ServerPackage sp1 = null;
+ ConnectionSet connections = new ConnectionSet();
+ ClientSet clients = new ClientSet();
+
+ try {
+ int id0 = counter++;
+ int id1 = counter++;
+ String serviceType0 = "test" + id0;
+ String instanceName0 = serviceType0;
+ String serviceType1 = "test" + id1;
+ String instanceName1 = serviceType1;
+
+ // Set up services.
+ sp0 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ sp1 = new ServerPackage(sp0.executor, sp0.endpoint, sp0.xnio, null, null, null, -1);
+ setupServer(sp1, id1, null, serviceType1, instanceName1, 0);
+
+ // Verify configuration.
+ assertSame(sp0.executor, sp1.executor, "Should be same");
+ assertSame(sp0.endpoint, sp1.endpoint, "Should be same");
+ assertSame(sp0.xnio, sp1.xnio, "Should be same");
+ assertNotSame(sp0.tcpServer, sp1.tcpServer, "Should be distinct");
+ assertNotSame(sp0.requestListener, sp1.requestListener, "Should be distinct");
+
+ // Set up connections and clients.
+ Connection connection00 = setupConnection(sp0.port); connections.add(connection00);
+ Connection connection01 = setupConnection(sp0.port); connections.add(connection01);
+ Connection connection10 = setupConnection(sp1.port); connections.add(connection10);
+ Connection connection11 = setupConnection(sp1.port); connections.add(connection11);
+ Client<Object, Object> client000 = setupClient(connection00, serviceType0, instanceName0); clients.add(client000);
+ Client<Object, Object> client001 = setupClient(connection00, serviceType1, instanceName1); clients.add(client001);
+ Client<Object, Object> client010 = setupClient(connection01, serviceType0, instanceName0); clients.add(client010);
+ Client<Object, Object> client011 = setupClient(connection01, serviceType1, instanceName1); clients.add(client011);
+ Client<Object, Object> client100 = setupClient(connection10, serviceType0, instanceName0); clients.add(client100);
+ Client<Object, Object> client101 = setupClient(connection10, serviceType1, instanceName1); clients.add(client101);
+ Client<Object, Object> client110 = setupClient(connection11, serviceType0, instanceName0); clients.add(client110);
+ Client<Object, Object> client111 = setupClient(connection11, serviceType1, instanceName1); clients.add(client111);
+
+ // Test invocations.
+ for (int i = 0; i < 5; i++) {
+ assertEquals(id0, client000.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client001.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client010.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client011.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client100.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client101.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client110.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client111.invoke("dummy"), "Should be equal");
+ }
+ assertEquals(20, sp0.requestListener.counter, "Should be equal");
+ assertEquals(20, sp1.requestListener.counter, "Should be equal");
+ log.info("testSharedExecutorEndpointXnio() PASSES");
+ } finally {
+ clients.close();
+ connections.close();
+ sp0.close();
+ sp1.close();
+ exit();
+ }
+ }
+
+ /**
+ * Two instances each of two distinct services in single Endpoint, each with a distinct RequestListener.
+ * Two Connections to the single TcpServer, four Clients per Connection, one per service instance.
+ */
+ @Test
+ public void testSharedExecutorEndpointXnioTcpServer() throws Exception {
+ enter();
+ ServerPackage sp00 = null;
+ ServerPackage sp01 = null;
+ ServerPackage sp10 = null;
+ ServerPackage sp11 = null;
+ ConnectionSet connections = new ConnectionSet();
+ ClientSet clients = new ClientSet();
+
+ try {
+ int id0 = counter++;
+ int id1 = counter++;
+ String serviceType0 = "test" + id0;
+ String serviceType1 = "test" + id1;
+ String instanceName0 = "instance0";
+ String instanceName1 = "instance1";
+
+ // Set up services.
+ sp00 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ sp01 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
+ setupServer(sp01, id0, null, serviceType0, instanceName1, 0);
+ sp10 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
+ setupServer(sp10, id1, null, serviceType1, instanceName0, 0);
+ sp11 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
+ setupServer(sp11, id1, null, serviceType1, instanceName1, 0);
+
+ // Verify configuration.
+ assertSame(sp00.executor, sp01.executor, "Should be same");
+ assertSame(sp00.executor, sp10.executor, "Should be same");
+ assertSame(sp00.executor, sp11.executor, "Should be same");
+ assertSame(sp00.endpoint, sp01.endpoint, "Should be same");
+ assertSame(sp00.endpoint, sp10.endpoint, "Should be same");
+ assertSame(sp00.endpoint, sp11.endpoint, "Should be same");
+ assertSame(sp00.xnio, sp01.xnio, "Should be same");
+ assertSame(sp00.xnio, sp10.xnio, "Should be same");
+ assertSame(sp00.xnio, sp11.xnio, "Should be same");
+ assertSame(sp00.tcpServer, sp01.tcpServer, "Should be same");
+ assertSame(sp00.tcpServer, sp10.tcpServer, "Should be same");
+ assertSame(sp00.tcpServer, sp11.tcpServer, "Should be same");
+ assertNotSame(sp00.requestListener, sp01.requestListener, "Should be distinct");
+ assertNotSame(sp00.requestListener, sp10.requestListener, "Should be distinct");
+ assertNotSame(sp00.requestListener, sp11.requestListener, "Should be distinct");
+ assertNotSame(sp01.requestListener, sp10.requestListener, "Should be distinct");
+ assertNotSame(sp01.requestListener, sp11.requestListener, "Should be distinct");
+ assertNotSame(sp10.requestListener, sp11.requestListener, "Should be distinct");
+
+ // Set up connections and clients.
+ Connection connection0 = setupConnection(sp00.port); connections.add(connection0);
+ Connection connection1 = setupConnection(sp00.port); connections.add(connection1);
+ Client<Object, Object> client000 = setupClient(connection0, serviceType0, instanceName0); clients.add(client000);
+ Client<Object, Object> client001 = setupClient(connection0, serviceType0, instanceName1); clients.add(client001);
+ Client<Object, Object> client010 = setupClient(connection0, serviceType1, instanceName0); clients.add(client010);
+ Client<Object, Object> client011 = setupClient(connection0, serviceType1, instanceName1); clients.add(client011);
+ Client<Object, Object> client100 = setupClient(connection1, serviceType0, instanceName0); clients.add(client100);
+ Client<Object, Object> client101 = setupClient(connection1, serviceType0, instanceName1); clients.add(client101);
+ Client<Object, Object> client110 = setupClient(connection1, serviceType1, instanceName0); clients.add(client110);
+ Client<Object, Object> client111 = setupClient(connection1, serviceType1, instanceName1); clients.add(client111);
+
+ // Test invocations.
+ for (int i = 0; i < 5; i++) {
+ assertEquals(id0, client000.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client001.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client010.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client011.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client100.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client101.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client110.invoke("dummy"), "Should be equal");
+ assertEquals(id1, client111.invoke("dummy"), "Should be equal");
+ }
+ assertEquals(10, sp00.requestListener.counter, "Should be equal");
+ assertEquals(10, sp01.requestListener.counter, "Should be equal");
+ assertEquals(10, sp10.requestListener.counter, "Should be equal");
+ assertEquals(10, sp11.requestListener.counter, "Should be equal");
+ log.info("testSharedExecutorEndpointXnioTcpServer() PASSES");
+ } finally {
+ clients.close();
+ connections.close();
+ sp00.close();
+ sp01.close();
+ sp10.close();
+ sp11.close();
+ exit();
+ }
+ }
+
+ /**
+ * Two instances each of two distinct services in single Endpoint, all sharing a single RequestListener.
+ * Two Connections to the single TcpServer, four Clients per Connection, one per service instance.
+ */
+ @Test
+ public void testSharedExecutorEndpointXnioTcpServerRequestListener() throws Exception {
+ enter();
+ ServerPackage sp00 = null;
+ ServerPackage sp01 = null;
+ ServerPackage sp10 = null;
+ ServerPackage sp11 = null;
+ ConnectionSet connections = new ConnectionSet();
+ ClientSet clients = new ClientSet();
+
+ try {
+ int id0 = counter++;
+ int id1 = counter++;
+ String serviceType0 = "test" + id0;
+ String serviceType1 = "test" + id1;
+ String instanceName0 = "instance0";
+ String instanceName1 = "instance1";
+
+ // Set up services.
+ sp00 = setupServer(null, id0, null, serviceType0, instanceName0, 0);
+ sp01 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
+ setupServer(sp01, -1, sp00.requestListener, serviceType0, instanceName1, 0);
+ sp10 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
+ setupServer(sp10, -1, sp00.requestListener, serviceType1, instanceName0, 0);
+ sp11 = new ServerPackage(sp00.executor, sp00.endpoint, sp00.xnio, sp00.tcpServer, null, null, -1);
+ setupServer(sp11, -1, sp00.requestListener, serviceType1, instanceName1, 0);
+
+ // Verify configuration.
+ assertSame(sp00.executor, sp01.executor, "Should be same");
+ assertSame(sp00.executor, sp10.executor, "Should be same");
+ assertSame(sp00.executor, sp11.executor, "Should be same");
+ assertSame(sp00.endpoint, sp01.endpoint, "Should be same");
+ assertSame(sp00.endpoint, sp10.endpoint, "Should be same");
+ assertSame(sp00.endpoint, sp11.endpoint, "Should be same");
+ assertSame(sp00.xnio, sp01.xnio, "Should be same");
+ assertSame(sp00.xnio, sp10.xnio, "Should be same");
+ assertSame(sp00.xnio, sp11.xnio, "Should be same");
+ assertSame(sp00.tcpServer, sp01.tcpServer, "Should be same");
+ assertSame(sp00.tcpServer, sp10.tcpServer, "Should be same");
+ assertSame(sp00.tcpServer, sp11.tcpServer, "Should be same");
+ assertSame(sp00.requestListener, sp01.requestListener, "Should be same");
+ assertSame(sp00.requestListener, sp10.requestListener, "Should be same");
+ assertSame(sp00.requestListener, sp11.requestListener, "Should be same");
+
+ // Set up connections and clients.
+ Connection connection0 = setupConnection(sp00.port); connections.add(connection0);
+ Connection connection1 = setupConnection(sp00.port); connections.add(connection1);
+ Client<Object, Object> client000 = setupClient(connection0, serviceType0, instanceName0); clients.add(client000);
+ Client<Object, Object> client001 = setupClient(connection0, serviceType0, instanceName1); clients.add(client001);
+ Client<Object, Object> client010 = setupClient(connection0, serviceType1, instanceName0); clients.add(client010);
+ Client<Object, Object> client011 = setupClient(connection0, serviceType1, instanceName1); clients.add(client011);
+ Client<Object, Object> client100 = setupClient(connection1, serviceType0, instanceName0); clients.add(client100);
+ Client<Object, Object> client101 = setupClient(connection1, serviceType0, instanceName1); clients.add(client101);
+ Client<Object, Object> client110 = setupClient(connection1, serviceType1, instanceName0); clients.add(client110);
+ Client<Object, Object> client111 = setupClient(connection1, serviceType1, instanceName1); clients.add(client111);
+
+ // Test invocations.
+ for (int i = 0; i < 5; i++) {
+ assertEquals(id0, client000.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client001.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client010.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client011.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client100.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client101.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client110.invoke("dummy"), "Should be equal");
+ assertEquals(id0, client111.invoke("dummy"), "Should be equal");
+ }
+ assertEquals(40, sp00.requestListener.counter, "Should be equal");
+ log.info("testSharedExecutorEndpointXnioTcpServerRequestListener() PASSES");
+ } finally {
+ clients.close();
+ connections.close();
+ sp00.close();
+ sp01.close();
+ sp10.close();
+ sp11.close();
+ exit();
+ }
+ }
+
+ protected String getRemotingScheme() {
+ return "remote";
+ }
+
+ protected RemotingServiceDescriptor<ConnectionProviderFactory> getProtocolDescriptor() {
+ return new RemoteProtocolDescriptor();
+ }
+
+ protected ServerPackage setupServer(ServerPackage sp, int id, TestRequestListener requestListener, String serviceType, String instanceName, int port) throws IOException {
+
+ if (sp == null) {
+ sp = new ServerPackage();
+ }
+
+ // Create and configure endpoint.
+ if (sp.endpoint == null) {
+ if (sp.executor == null) {
+ sp.executor = new ThreadPoolExecutor(8, 64, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(64));
+ }
+ sp.endpoint = Remoting.createEndpoint("endpoint" + id, sp.executor, OptionMap.EMPTY);
+ final Registration reg1 = sp.endpoint.addProtocolService(ProtocolServiceType.MARSHALLER_PROVIDER_DESCRIPTOR, "river", new RiverProviderDescriptor());
+ final Registration reg2 = sp.endpoint.addConnectionProvider(getRemotingScheme(), getProtocolDescriptor().getService(new Properties()));
+ sp.endpoint.addCloseHandler(new CloseHandler<Endpoint>() {
+ public void handleClose(final Endpoint closed) {
+ reg1.close();
+ reg2.close();
+ }});
+ }
+
+ // Set up XNIO layer.
+ OptionMap serverOptions = OptionMap.builder().setSequence(Options.SASL_MECHANISMS, "EXTERNAL", "DIGEST-MD5").getMap();
+ SimpleServerAuthenticationProvider authenticationProvider = new SimpleServerAuthenticationProvider();
+ authenticationProvider.addUser("user", sp.endpoint.getName(), "password".toCharArray());
+ NetworkServerProvider provider = sp.endpoint.getConnectionProviderInterface(getRemotingScheme(), NetworkServerProvider.class);
+ ChannelListener<ConnectedStreamChannel<InetSocketAddress>> listener = provider.getServerListener(serverOptions, authenticationProvider);
+ if (sp.xnio == null) {
+ sp.xnio = Xnio.getInstance(String.valueOf(id));
+ }
+ if (sp.tcpServer == null) {
+ createTcpServer(sp, listener, port);
+ }
+
+ // Register service with endpoint.
+ sp.requestListener = (requestListener == null) ? new TestRequestListener(id) : requestListener;
+ if (sp.registration == null) {
+ ServiceBuilder<Object, Object> sb = sp.endpoint.serviceBuilder(Object.class, Object.class);
+ sb.setInstanceName(instanceName).setServiceType(serviceType);
+ sb.setClientListener(new TestClientListener(sp.requestListener));
+ sp.registration = sb.register();
+ }
+ return sp;
+ }
+
+ protected void createTcpServer(ServerPackage sp, ChannelListener<ConnectedStreamChannel<InetSocketAddress>> listener, int port) throws IOException {
+ log.info(this + " creating TcpServer");
+ TcpServer tcpServer = sp.xnio.createTcpServer(listener, OptionMap.EMPTY);
+ IoFuture<? extends BoundChannel<InetSocketAddress>> future = tcpServer.bind(new InetSocketAddress("localhost", port));
+ getFutureResult(future, "unable to bind " + sp.tcpServer);
+ sp.tcpServer = tcpServer;
+ sp.port = tcpServer.getChannels().iterator().next().getLocalAddress().getPort();
+ }
+
+ protected Connection setupConnection(int port) throws IOException, URISyntaxException {
+ Endpoint endpoint = Remoting.getConfiguredEndpoint();
+ URI uri = new URI(getRemotingScheme() + "://localhost:" + port);
+ Connection connection = getFutureResult(endpoint.connect(uri, getConnectionOptionMap(), "user", null, "password".toCharArray()), "unable to connect to " + uri);
+ return connection;
+ }
+
+ protected OptionMap getConnectionOptionMap() {
+ return OptionMap.EMPTY;
+ }
+
+ protected Client<Object, Object> setupClient(Connection connection, String serviceType, String instanceName) throws IOException, URISyntaxException {
+ Client<Object, Object> client = getFutureResult(connection.openClient(serviceType, instanceName, Object.class, Object.class), "unable to open client to " + serviceType + ":" + instanceName);
+ return client;
+ }
+
+ static class TestRequestListener implements RequestListener<Object, Object> {
+ public int counter = 0;
+ private int answer;
+
+ public TestRequestListener(int answer) {
+ this.answer = answer;
+ }
+
+ public void handleRequest(RequestContext<Object> context, Object request) throws RemoteExecutionException {
+ try {
+ counter++;
+ context.sendReply(answer);
+ } catch (IOException e) {
+ try {
+ context.sendFailure("error returning response", e);
+ } catch (IOException e1) {
+ e.printStackTrace();
+ throw new RemoteExecutionException("error returning exception", e1);
+ }
+ }
+ }
+ }
+
+ static class TestClientListener implements ClientListener<Object, Object> {
+ private RequestListener<Object, Object> requestListener;
+
+ TestClientListener(RequestListener<Object, Object> requestListener) {
+ this.requestListener = requestListener;
+ }
+
+ public RequestListener<Object, Object> handleClientOpen(final ClientContext clientContext, final OptionMap optionMap) {
+ clientContext.addCloseHandler(new CloseHandler<ClientContext>() {
+ public void handleClose(final ClientContext closed) {
+ log.info("Client closed");
+ }
+ });
+ return requestListener;
+ }
+ }
+
+ static class ServerPackage {
+ public ThreadPoolExecutor executor;
+ public Endpoint endpoint;
+ public Xnio xnio;
+ public AcceptingServer<?, ?, ?> tcpServer;
+ public TestRequestListener requestListener;
+ public Registration registration;
+ public int port;
+
+ public ServerPackage(ThreadPoolExecutor executor, Endpoint endpoint, Xnio xnio, AcceptingServer<?, ?, ?> tcpServer, TestRequestListener requestListener, Registration registration, int port) {
+ this.executor = executor;
+ this.endpoint = endpoint;
+ this.xnio = xnio;
+ this.tcpServer = tcpServer;
+ this.requestListener = requestListener;
+ this.registration = registration;
+ this.port = port;
+ }
+
+ public ServerPackage() {
+ }
+
+ public void close() {
+ if (executor != null) {
+ executor.shutdown();
+ }
+ if (endpoint != null) {
+ try {
+ endpoint.close();
+ } catch (IOException e) {
+ log.error("unable to close " + endpoint);
+ }
+ }
+ if (xnio != null) {
+ try {
+ xnio.close();
+ } catch (IOException e) {
+ log.error("unable to close " + xnio);
+ }
+ }
+ if (tcpServer != null) {
+ try {
+ tcpServer.close();
+ } catch (IOException e) {
+ log.error("unable to close " + tcpServer);
+ }
+ }
+ if (registration != null) {
+ registration.close();
+ }
+ }
+ }
+
+ static class ConnectionSet extends HashSet<Connection> {
+ private static final long serialVersionUID = 1L;
+
+ public void close() {
+ for (Connection connection: this) {
+ try {
+ connection.close();
+ } catch (IOException e) {
+ log.error("unable to close " + connection);
+ }
+ }
+ }
+ }
+
+ static class ClientSet extends HashSet<Client<?, ?>> {
+ private static final long serialVersionUID = 1L;
+
+ public void close() {
+ for (Client<?,?> client: this) {
+ try {
+ client.close();
+ } catch (IOException e) {
+ log.error("unable to close " + client);
+ }
+ }
+ }
+ }
+}
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteSSLConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteSSLConfigurationTestCase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteSSLConfigurationTestCase.java 2010-06-22 20:29:57 UTC (rev 5874)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.test;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+
+import org.jboss.remoting3.remote.RemoteSslProtocolDescriptor;
+import org.jboss.remoting3.spi.ConnectionProviderFactory;
+import org.jboss.remoting3.spi.RemotingServiceDescriptor;
+import org.jboss.xnio.ChannelListener;
+import org.jboss.xnio.IoFuture;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Options;
+import org.jboss.xnio.SslTcpServer;
+import org.jboss.xnio.Xnio;
+import org.jboss.xnio.OptionMap.Builder;
+import org.jboss.xnio.channels.BoundChannel;
+import org.jboss.xnio.channels.ConnectedStreamChannel;
+import org.jboss.xnio.log.Logger;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 10, 2010
+ */
+@Test(suiteName = "ClientServerRemoteSSLConfiguration")
+public class ClientServerRemoteSSLConfigurationTestCase extends ClientServerRemoteConfigurationTestCase {
+
+ private static final Logger log = Logger.getLogger(ClientServerRemoteSSLConfigurationTestCase.class);
+
+ // Use anonymous ciphers so we don't need a trust store configuration of any sort
+ private static final String[] CIPHER_SUITES = {
+ "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
+ "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
+ "TLS_DH_anon_WITH_AES_128_CBC_SHA",
+ "TLS_DH_anon_WITH_AES_256_CBC_SHA",
+ "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",
+ "SSL_DH_anon_WITH_DES_CBC_SHA",
+ "SSL_DH_anon_WITH_RC4_128_MD5",
+ "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
+ "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
+ };
+
+ private static final String[] PROTOCOLS = {
+ "TLSv1",
+ };
+
+ protected String getRemotingScheme() {
+ return "remote+ssl";
+ }
+
+ protected RemotingServiceDescriptor<ConnectionProviderFactory> getProtocolDescriptor() {
+ return new RemoteSslProtocolDescriptor();
+ }
+
+ protected OptionMap getConnectionOptionMap() {
+ Builder builder = OptionMap.builder();
+ builder.setSequence(Options.SSL_ENABLED_CIPHER_SUITES, CIPHER_SUITES);
+ builder.setSequence(Options.SSL_ENABLED_PROTOCOLS, PROTOCOLS);
+ return builder.getMap();
+ }
+
+ @Override
+ protected void createTcpServer(ServerPackage sp, ChannelListener<ConnectedStreamChannel<InetSocketAddress>> listener, int port) throws IOException {
+ log.info(this + " creating SslTcpServer");
+ Builder builder = OptionMap.builder();
+ builder.setSequence(Options.SSL_ENABLED_CIPHER_SUITES, CIPHER_SUITES);
+ builder.setSequence(Options.SSL_ENABLED_PROTOCOLS, PROTOCOLS);
+ SslTcpServer sslTcpServer;
+ try {
+ sslTcpServer = sp.xnio.createSslTcpServer(listener, builder.getMap());
+ } catch (NoSuchProviderException e) {
+ throw new IOException(e);
+ } catch (NoSuchAlgorithmException e) {
+ throw new IOException(e);
+ }
+ IoFuture<? extends BoundChannel<InetSocketAddress>> future = sslTcpServer.bind(new InetSocketAddress("localhost", port));
+ getFutureResult(future, "unable to bind " + sp.tcpServer);
+ sp.tcpServer = sslTcpServer;
+ sp.port = sslTcpServer.getChannels().iterator().next().getLocalAddress().getPort();
+ }
+
+ protected SslTcpServer getServer(final ChannelListener<ConnectedStreamChannel<InetSocketAddress>> listener, final Xnio xnio) throws NoSuchProviderException, NoSuchAlgorithmException {
+ final OptionMap serverOptions = OptionMap.builder()
+ .setSequence(Options.SSL_ENABLED_CIPHER_SUITES, CIPHER_SUITES)
+ .setSequence(Options.SSL_ENABLED_PROTOCOLS, PROTOCOLS)
+ .getMap();
+ return xnio.createSslTcpServer(listener, serverOptions);
+ }
+}
14 years, 2 months
JBoss Remoting SVN: r5873 - in remoting3/trunk/jboss-remoting/src: test/java/org/jboss/remoting3/test and 1 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-22 16:28:30 -0400 (Tue, 22 Jun 2010)
New Revision: 5873
Added:
remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.marshalling.ProviderDescriptor
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java
remoting3/trunk/jboss-remoting/src/test/resources/protocols.test.remoting.properties
Log:
JBREM-1228: Added unit tests for Endpoint configuration.
Added: remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.marshalling.ProviderDescriptor
===================================================================
--- remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.marshalling.ProviderDescriptor (rev 0)
+++ remoting3/trunk/jboss-remoting/src/main/resources/META-INF/services/org.jboss.marshalling.ProviderDescriptor 2010-06-22 20:28:30 UTC (rev 5873)
@@ -0,0 +1,5 @@
+#
+# MockMarshaller provider descriptor
+#
+
+org.jboss.remoting3.test.EndpointConfigurationTestCase$MockMarshallerProviderDescriptor
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/EndpointConfigurationTestCase.java 2010-06-22 20:28:30 UTC (rev 5873)
@@ -0,0 +1,395 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.remoting3.test;
+
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.Properties;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import javax.security.auth.callback.CallbackHandler;
+
+import org.jboss.marshalling.ClassExternalizerFactory;
+import org.jboss.marshalling.ClassResolver;
+import org.jboss.marshalling.ClassTable;
+import org.jboss.marshalling.Externalizer;
+import org.jboss.marshalling.Marshaller;
+import org.jboss.marshalling.MarshallerFactory;
+import org.jboss.marshalling.ObjectResolver;
+import org.jboss.marshalling.ObjectTable;
+import org.jboss.marshalling.ProviderDescriptor;
+import org.jboss.marshalling.Unmarshaller;
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remoting3.Registration;
+import org.jboss.remoting3.Remoting;
+import org.jboss.remoting3.spi.ConnectionHandlerFactory;
+import org.jboss.remoting3.spi.ConnectionProvider;
+import org.jboss.remoting3.spi.ConnectionProviderContext;
+import org.jboss.remoting3.spi.ConnectionProviderFactory;
+import org.jboss.remoting3.spi.ProtocolServiceType;
+import org.jboss.remoting3.spi.RemotingServiceDescriptor;
+import org.jboss.xnio.Cancellable;
+import org.jboss.xnio.OptionMap;
+import org.jboss.xnio.Result;
+import org.jboss.xnio.log.Logger;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * EndpointConfigurationTestCase tests various ways of configuring an Endpoint with transport protocols
+ * and marshalling components.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 21, 2010
+ */
+@Test(suiteName = "EndpointConfiguration")
+public class EndpointConfigurationTestCase {
+
+ private static final Logger log = Logger.getLogger(EndpointConfigurationTestCase.class);
+
+ static void enter() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+ }
+
+ static void exit() {
+ final StackTraceElement e = new Throwable().getStackTrace()[1];
+ log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
+ log.info("-------------------------------------------------------------");
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ System.clearProperty("remoting.property.file");
+ try {
+ Field configuredEndpoint = Remoting.class.getDeclaredField("configuredEndpoint");
+ configuredEndpoint.setAccessible(true);
+ configuredEndpoint.set(null, null);
+ System.out.println(configuredEndpoint.get(null));
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @AfterMethod
+ public void tearDown() throws IOException {
+ }
+
+ /**
+ * Tests configuration of Endpoint by programmatically adding a transport and marshalling components.
+ */
+ @Test
+ public void testProgrammaticConfiguration() throws Exception {
+ enter();
+ Endpoint endpoint = null;
+ Registration regConnectionProvider = null;
+ Registration regMarshallerProvider = null;
+ Registration regClassExternalizerFactoryProvider = null;
+ Registration regClassResolverProvider = null;
+ Registration regClassTableProvider = null;
+ Registration regObjectResolverProvider = null;
+ Registration regObjectTableProvider = null;
+
+ ProviderDescriptor marshallerProviderDescriptor = new MockMarshallerProviderDescriptor();
+ MockClassExternalizerFactory mockClassExternalizerFactory = new MockClassExternalizerFactory();
+ MockClassResolver mockClassResolver = new MockClassResolver();
+ MockClassTable mockClassTable = new MockClassTable();
+ MockObjectResolver mockObjectResolver = new MockObjectResolver();
+ MockObjectTable mockObjectTable = new MockObjectTable();
+
+ try {
+ Executor executor = new ThreadPoolExecutor(8, 64, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(64));
+ endpoint = Remoting.createEndpoint("endpoint", executor, OptionMap.EMPTY);
+ regConnectionProvider = endpoint.addConnectionProvider("mockTransport", new MockConnectionProviderFactory());
+ regMarshallerProvider = endpoint.addProtocolService(ProtocolServiceType.MARSHALLER_PROVIDER_DESCRIPTOR, "mockMarshaller", marshallerProviderDescriptor);
+ regClassExternalizerFactoryProvider = endpoint.addProtocolService(ProtocolServiceType.CLASS_EXTERNALIZER_FACTORY, "mockClassExternalizerFactory", mockClassExternalizerFactory);
+ regClassResolverProvider = endpoint.addProtocolService(ProtocolServiceType.CLASS_RESOLVER, "mockClassResolver", mockClassResolver);
+ regClassTableProvider = endpoint.addProtocolService(ProtocolServiceType.CLASS_TABLE, "mockClassTable", mockClassTable);
+ regObjectResolverProvider = endpoint.addProtocolService(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver", mockObjectResolver);
+ regObjectTableProvider = endpoint.addProtocolService(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable", mockObjectTable);
+
+ assertSame(MockConnectionProviderFactory.providerInterface, endpoint.getConnectionProviderInterface("mockTransport", MockConnectionProviderFactory.MockProviderInterface.class));
+ ConnectionProviderContext context = MockConnectionProviderFactory.context;
+ assertSame(marshallerProviderDescriptor, context.getProtocolServiceProvider(ProtocolServiceType.MARSHALLER_PROVIDER_DESCRIPTOR, "mockMarshaller"));
+ assertSame(mockClassExternalizerFactory, context.getProtocolServiceProvider(ProtocolServiceType.CLASS_EXTERNALIZER_FACTORY, "mockClassExternalizerFactory"));
+ assertSame(mockClassResolver, context.getProtocolServiceProvider(ProtocolServiceType.CLASS_RESOLVER, "mockClassResolver"));
+ assertSame(mockClassTable, context.getProtocolServiceProvider(ProtocolServiceType.CLASS_TABLE, "mockClassTable"));
+ assertSame(mockObjectResolver, context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver"));
+ assertSame(mockObjectTable, context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable"));
+ log.info("testProgrammaticConfiguration() PASSES");
+
+ } finally {
+ if (regClassExternalizerFactoryProvider != null) {
+ regClassExternalizerFactoryProvider.close();
+ }
+ if (regClassResolverProvider != null) {
+ regClassResolverProvider.close();
+ }
+ if (regClassTableProvider != null) {
+ regClassTableProvider.close();
+ }
+ if (regObjectResolverProvider != null) {
+ regObjectResolverProvider.close();
+ }
+ if (regObjectTableProvider != null) {
+ regObjectTableProvider.close();
+ }
+ if (regMarshallerProvider != null) {
+ regMarshallerProvider.close();
+ }
+ if (regConnectionProvider != null) {
+ regConnectionProvider.close();
+ }
+ if (endpoint != null) {
+ endpoint.close();
+ }
+ exit();
+ }
+ }
+
+ /**
+ * Tests configuration of Endpoint by listing transport and marshalling components descriptions in a RemotingServiceDescriptor file.
+ */
+ @Test
+ public void testConfigurationByServiceDescriptorFile() throws Exception {
+ enter();
+
+ try {
+ Endpoint endpoint = Remoting.getConfiguredEndpoint();
+ assertSame(MockConnectionProviderFactory.providerInterface, endpoint.getConnectionProviderInterface("mockTransport", MockConnectionProviderFactory.MockProviderInterface.class));
+ ConnectionProviderContext context = MockConnectionProviderFactory.context;
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.CLASS_EXTERNALIZER_FACTORY, "mockClassExternalizerFactory_sd") instanceof MockClassExternalizerFactory);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.CLASS_RESOLVER, "mockClassResolver_sd") instanceof MockClassResolver);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.CLASS_TABLE, "mockClassTable_sd") instanceof MockClassTable);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver_sd") instanceof MockObjectResolver);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable_sd") instanceof MockObjectTable);
+ log.info("testConfigurationByServiceDescriptorFile() PASSES");
+ } finally {
+ exit();
+ }
+ }
+
+ /**
+ * Tests configuration of Endpoint by listing transport and marshalling components descriptions in a properties file.
+ * Note that the properties file includes examples of multiple instances in the object table list.
+ */
+ @Test
+ public void testConfigurationByPropertiesFile() throws Exception {
+ enter();
+
+ try {
+ System.setProperty("remoting.property.file", "protocols.test.remoting.properties");
+ @SuppressWarnings("unused")
+ Endpoint endpoint = Remoting.getConfiguredEndpoint();
+ ConnectionProviderContext context = MockConnectionProviderFactory.context;
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.CLASS_EXTERNALIZER_FACTORY, "mockClassExternalizerFactory_pf") instanceof MockClassExternalizerFactory);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.CLASS_RESOLVER, "mockClassResolver_pf") instanceof MockClassResolver);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.CLASS_TABLE, "mockClassTable_pf") instanceof MockClassTable);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver_pf") instanceof MockObjectResolver);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable_pf") instanceof MockObjectTable);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable_pf1") instanceof MockObjectTable);
+ assertTrue(context.getProtocolServiceProvider(ProtocolServiceType.OBJECT_TABLE, "mockObjectTable_pf2") instanceof MockObjectTable2);
+ log.info("testConfigurationByPropertiesFile() PASSES");
+ } finally {
+ exit();
+ }
+ }
+
+ /**
+ * This class is used to gain access to the Endpoint's ConnectionProviderContext.
+ */
+ public static class MockConnectionProviderFactory implements ConnectionProviderFactory {
+ public static ConnectionProviderContext context;
+ public interface MockProviderInterface {};
+ public static MockProviderInterface providerInterface = new MockProviderInterface() {};
+
+ public ConnectionProvider createInstance(ConnectionProviderContext context) {
+ MockConnectionProviderFactory.context = context;
+ return new ConnectionProvider() {
+ public Cancellable connect(URI uri, OptionMap connectOptions, Result<ConnectionHandlerFactory> result, CallbackHandler callbackHandler) throws IllegalArgumentException {
+ return null;
+ }
+ public Object getProviderInterface() {
+ return providerInterface;
+ }
+ };
+ }
+ }
+
+ public static class MockProtocolDescriptor implements RemotingServiceDescriptor<ConnectionProviderFactory> {
+ public Class<ConnectionProviderFactory> getType() {
+ return ConnectionProviderFactory.class;
+ }
+ public String getName() {
+ return "mockTransport";
+ }
+ public ConnectionProviderFactory getService(final Properties properties) throws IOException {
+ return new MockConnectionProviderFactory();
+ }
+ }
+
+ public static class MockMarshallerProviderDescriptor implements ProviderDescriptor {
+ public MarshallerFactory getMarshallerFactory() {
+ return null;
+ }
+ public String getName() {
+ return "mockMarshaller";
+ }
+ public int[] getSupportedVersions() {
+ return new int[]{0};
+ }
+ }
+
+ public static class MockClassExternalizerFactory implements ClassExternalizerFactory {
+ public Externalizer getExternalizer(Class<?> type) {
+ return null;
+ }
+ }
+
+ public static class MockClassResolver implements ClassResolver {
+ public void annotateClass(Marshaller marshaller, Class<?> clazz) throws IOException {
+ }
+ public void annotateProxyClass(Marshaller marshaller, Class<?> proxyClass) throws IOException {
+ }
+ public String getClassName(Class<?> clazz) throws IOException {
+ return null;
+ }
+ public String[] getProxyInterfaces(Class<?> proxyClass) throws IOException {
+ return null;
+ }
+ public Class<?> resolveClass(Unmarshaller unmarshaller, String name, long serialVersionUID) throws IOException, ClassNotFoundException {
+ return null;
+ }
+ public Class<?> resolveProxyClass(Unmarshaller unmarshaller, String[] interfaces) throws IOException, ClassNotFoundException {
+ return null;
+ }
+ }
+
+ public static class MockClassTable implements ClassTable {
+ public Writer getClassWriter(Class<?> clazz) throws IOException {
+ return null;
+ }
+ public Class<?> readClass(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
+ return null;
+ }
+ }
+
+ public static class MockObjectResolver implements ObjectResolver {
+ public Object readResolve(Object replacement) {
+ return null;
+ }
+ public Object writeReplace(Object original) {
+ return null;
+ }
+ }
+
+ public static class MockObjectTable implements ObjectTable {
+ public Writer getObjectWriter(Object object) throws IOException {
+ return null;
+ }
+ public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
+ return null;
+ }
+ }
+
+ public static class MockObjectTable2 implements ObjectTable {
+ public Writer getObjectWriter(Object object) throws IOException {
+ return null;
+ }
+ public Object readObject(Unmarshaller unmarshaller) throws IOException, ClassNotFoundException {
+ return null;
+ }
+ }
+
+ public static class MockClassExternalizerFactoryServiceDescriptor implements RemotingServiceDescriptor<ClassExternalizerFactory> {
+ public Class<ClassExternalizerFactory> getType() {
+ return ClassExternalizerFactory.class;
+ }
+ public String getName() {
+ return "mockClassExternalizerFactory_sd";
+ }
+ public ClassExternalizerFactory getService(final Properties properties) throws IOException {
+ return new MockClassExternalizerFactory();
+ }
+ }
+
+ public static class MockClassResolverServiceDescriptor implements RemotingServiceDescriptor<ClassResolver> {
+ public Class<ClassResolver> getType() {
+ return ClassResolver.class;
+ }
+ public String getName() {
+ return "mockClassResolver_sd";
+ }
+ public ClassResolver getService(final Properties properties) throws IOException {
+ return new MockClassResolver();
+ }
+ }
+
+ public static class MockClassTableServiceDescriptor implements RemotingServiceDescriptor<ClassTable> {
+ public Class<ClassTable> getType() {
+ return ClassTable.class;
+ }
+ public String getName() {
+ return "mockClassTable_sd";
+ }
+ public ClassTable getService(final Properties properties) throws IOException {
+ return new MockClassTable();
+ }
+ }
+
+ public static class MockObjectResolverServiceDescriptor implements RemotingServiceDescriptor<ObjectResolver> {
+ public Class<ObjectResolver> getType() {
+ return ObjectResolver.class;
+ }
+ public String getName() {
+ return "mockObjectResolver_sd";
+ }
+ public ObjectResolver getService(final Properties properties) throws IOException {
+ return new MockObjectResolver();
+ }
+ }
+
+ public static class MockObjectTableServiceDescriptor implements RemotingServiceDescriptor<ObjectTable> {
+ public Class<ObjectTable> getType() {
+ return ObjectTable.class;
+ }
+ public String getName() {
+ return "mockObjectTable_sd";
+ }
+ public ObjectTable getService(final Properties properties) throws IOException {
+ return new MockObjectTable();
+ }
+ }
+}
Added: remoting3/trunk/jboss-remoting/src/test/resources/protocols.test.remoting.properties
===================================================================
--- remoting3/trunk/jboss-remoting/src/test/resources/protocols.test.remoting.properties (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/resources/protocols.test.remoting.properties 2010-06-22 20:28:30 UTC (rev 5873)
@@ -0,0 +1,36 @@
+#
+# JBoss, Home of Professional Open Source
+# Copyright 2010, JBoss Inc., and individual contributors as indicated
+# by the @authors tag. See the copyright.txt in the distribution for a
+# full listing of individual contributors.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+#
+
+endpoint.name=protocols.test
+protocols.test.class_externalizer_factory_list=mockClassExternalizerFactory_pf
+protocols.test.class_resolver_list=mockClassResolver_pf
+protocols.test.class_table_list=mockClassTable_pf
+protocols.test.object_resolver_list=mockObjectResolver_pf
+protocols.test.object_table_list=mockObjectTable_pf,mockObjectTable_pf1,mockObjectTable_pf2
+
+mockClassExternalizerFactory_pf.class_externalizer_factory.mockClassExternalizerFactory_pf.class=org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassExternalizerFactory
+mockClassResolver_pf.class_resolver.mockClassResolver_pf.class=org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassResolver
+mockClassTable_pf.class_table.mockClassTable_pf.class=org.jboss.remoting3.test.EndpointConfigurationTestCase$MockClassTable
+mockObjectResolver_pf.object_resolver.mockObjectResolver_pf.class=org.jboss.remoting3.test.EndpointConfigurationTestCase$MockObjectResolver
+mockObjectTable_pf.object_table.mockObjectTable_pf.class=org.jboss.remoting3.test.EndpointConfigurationTestCase$MockObjectTable
+mockObjectTable_pf1.object_table.mockObjectTable_pf1.class=org.jboss.remoting3.test.EndpointConfigurationTestCase$MockObjectTable
+mockObjectTable_pf2.object_table.mockObjectTable_pf2.class=org.jboss.remoting3.test.EndpointConfigurationTestCase$MockObjectTable2
\ No newline at end of file
14 years, 2 months
JBoss Remoting SVN: r5872 - remoting2/branches/2.2/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-15 15:14:36 -0400 (Tue, 15 Jun 2010)
New Revision: 5872
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-1229: Fixed alignment of locator display.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2010-06-15 19:13:31 UTC (rev 5871)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2010-06-15 19:14:36 UTC (rev 5872)
@@ -1201,7 +1201,7 @@
locator = InvokerLocator.validateLocator(locator);
if (!locator.getLocatorURI().equals(originalLocator.getLocatorURI())) {
log.debug(this + " original locator: " + originalLocator);
- log.debug(this + " new locator: " + locator);
+ log.debug(this + " new locator: " + locator);
}
// need to update the locator key used in the invoker registry
14 years, 2 months
JBoss Remoting SVN: r5871 - remoting2/branches/2.x/src/main/org/jboss/remoting.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-06-15 15:13:31 -0400 (Tue, 15 Jun 2010)
New Revision: 5871
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
Log:
JBREM-1229: Prints old and new locator when InvokerLocator.validateLocator() results in changes.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2010-06-15 19:10:28 UTC (rev 5870)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2010-06-15 19:13:31 UTC (rev 5871)
@@ -1160,6 +1160,10 @@
// need to check invoker locator to see if need to provide binding address (in the case 0.0.0.0 was used)
InvokerLocator originalLocator = locator;
locator = InvokerLocator.validateLocator(locator);
+ if (!locator.getLocatorURI().equals(originalLocator.getLocatorURI())) {
+ log.debug(this + " original locator: " + originalLocator);
+ log.debug(this + " new locator: " + locator);
+ }
// need to update the locator key used in the invoker registry
InvokerRegistry.updateServerInvokerLocator(originalLocator, locator);
14 years, 2 months