From jboss-remoting-commits at lists.jboss.org Tue Jun 15 04:37:06 2010
Content-Type: multipart/mixed; boundary="===============0434705659302855630=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r5869 -
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/management.
Date: Tue, 15 Jun 2010 04:37:06 -0400
Message-ID: <201006150837.o5F8b6Ic018785@svn01.web.mwc.hst.phx2.redhat.com>
--===============0434705659302855630==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: trustin
Date: 2010-06-15 04:37:05 -0400 (Tue, 15 Jun 2010)
New Revision: 5869
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/managem=
ent/ConnectionMXBean.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/managem=
ent/Counters.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/managem=
ent/EndpointMXBean.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/managem=
ent/ServiceMXBean.java
Log:
* Javadoc (forgot to check in last week)
* Renamed getRequestCounters() to getInboundRequestCounters() or getOutboun=
dRequestCounters()
* Split EndpointMXBean.getRequestCounters() into the inbound version and th=
e outbound version
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/=
management/ConnectionMXBean.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/manage=
ment/ConnectionMXBean.java 2010-05-28 15:52:52 UTC (rev 5868)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/manage=
ment/ConnectionMXBean.java 2010-06-15 08:37:05 UTC (rev 5869)
@@ -23,13 +23,42 @@
=
import javax.management.ObjectName;
=
+import org.jboss.remoting3.Client;
+import org.jboss.remoting3.Connection;
+
+/**
+ * Statistics and management information for a {@link Connection}.
+ *
+ * @author Trustin Lee
+ * @version $Rev$, $Date$
+ */
public interface ConnectionMXBean {
=
+ /**
+ * Returns the {@link ObjectName} of the {@link EndpointMXBean} which
+ * created the {@link Connection}.
+ */
ObjectName getEndpoint();
=
- Counters getRequestCounters();
+ /**
+ * Returns the statistics information of the outbound requests handled
+ * (or being handled) by the {@link Connection}.
+ */
+ Counters getOutboundRequestCounters();
+
+ /**
+ * Returns the statistics information of the {@link Client}s created b=
y the
+ * the {@link Connection}.
+ */
Counters getClientCounters();
=
+ /**
+ * Closes all open {@link Client}s created by the {@link Connection}.
+ */
void close();
+
+ /**
+ * Closes all open {@link Client}s created by the {@link Connection} f=
orcibly.
+ */
void forceClose();
}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/=
management/Counters.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/manage=
ment/Counters.java 2010-05-28 15:52:52 UTC (rev 5868)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/manage=
ment/Counters.java 2010-06-15 08:37:05 UTC (rev 5869)
@@ -23,11 +23,25 @@
=
import java.beans.ConstructorProperties;
=
+/**
+ * Provides the number of the currently running (or in-progress) activitie=
s and
+ * the cumulative number of the succeeded or failed activities so far.
+ *
+ * @author Trustin Lee
+ * @version $Rev$, $Date$
+ */
public class Counters {
private final long active;
private final long success;
private final long failure;
=
+ /**
+ * Creates a new instance.
+ *
+ * @param active the number of the currently running (or in-progress)=
activities
+ * @param success the cumulative number of the succeeded activities so=
far
+ * @param failure the cumulative number of the failed activities so far
+ */
@ConstructorProperties({"active", "success", "failure"})
public Counters(long active, long success, long failure) {
this.active =3D active;
@@ -35,14 +49,23 @@
this.failure =3D failure;
}
=
+ /**
+ * Returns the number of the currently running (or in-progress) activi=
ties.
+ */
public long getActive() {
return active;
}
=
+ /**
+ * Returns the cumulative number of the succeeded activities so far.
+ */
public long getSuccess() {
return success;
}
=
+ /**
+ * Returns the cumulative number of the failed activities so far.
+ */
public long getFailure() {
return failure;
}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/=
management/EndpointMXBean.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/manage=
ment/EndpointMXBean.java 2010-05-28 15:52:52 UTC (rev 5868)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/manage=
ment/EndpointMXBean.java 2010-06-15 08:37:05 UTC (rev 5869)
@@ -25,13 +25,51 @@
=
import javax.management.ObjectName;
=
+import org.jboss.remoting3.Client;
+import org.jboss.remoting3.Connection;
+import org.jboss.remoting3.Endpoint;
=
+/**
+ * Statistics and management information for an {@link Endpoint}.
+ *
+ * @author Trustin Lee
+ * @version $Rev$, $Date$
+ */
public interface EndpointMXBean {
=
+ /**
+ * Returns the {@link ObjectName}s of all {@link ServiceMXBean}s where
+ * the services they represent are registered to the {@link Endpoint}.
+ */
List getServices();
+
+ /**
+ * Returns the {@link ObjectName}s of all {@link ConnectionMXBean}s wh=
ere
+ * the {@link Connection}s they represent are created by the {@link En=
dpoint}.
+ */
List getConnections();
=
- Counters getRequestCounters();
+ /**
+ * Returns the statistics information of the inbound requests handled
+ * (or being handled) by the services registered to the {@link Endpoin=
t}.
+ */
+ Counters getInboundRequestCounters();
+
+ /**
+ * Returns the statistics information of the outbound requests made by
+ * the {@link Connection}s created by the {@link Endpoint}.
+ */
+ Counters getOutboundRequestCounters();
+
+ /**
+ * Returns the statistics information of the {@link Connection}s creat=
ed by
+ * the {@link Endpoint}.
+ */
Counters getConnectionCounters();
+
+ /**
+ * Returns the statistics information of the {@link Client}s created b=
y the
+ * {@link Endpoint}.
+ */
Counters getClientCounters();
}
Modified: remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/=
management/ServiceMXBean.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/manage=
ment/ServiceMXBean.java 2010-05-28 15:52:52 UTC (rev 5868)
+++ remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/manage=
ment/ServiceMXBean.java 2010-06-15 08:37:05 UTC (rev 5869)
@@ -25,15 +25,55 @@
=
import javax.management.ObjectName;
=
+import org.jboss.remoting3.Endpoint;
+
+/**
+ * Statistics and management information for the service registered to an
+ * {@link Endpoint}.
+ *
+ * @author Trustin Lee
+ * @version $Rev$, $Date$
+ */
public interface ServiceMXBean {
=
+ /**
+ * Returns the {@link ObjectName} of the {@link EndpointMXBean} where =
the
+ * service is registered to.
+ */
ObjectName getEndpoint();
=
+ /**
+ * Returns the instance name of the service.
+ */
String getInstanceName();
+
+ /**
+ * Returns the service type string which follows the convention for Ja=
va
+ * package names (reversed domain names).
+ */
String getServiceType();
+
+ /**
+ * Returns the expected fully qualified class name of the request obje=
ct
+ * handled by the service.
+ */
String getRequestType();
+
+ /**
+ * Returns the expected fully qualified class name of the reply object
+ * returned by the service.
+ */
String getReplyType();
+
+ /**
+ * Returns the additional configuration options provided when the serv=
ice
+ * was created.
+ */
Map getOptions();
=
- Counters getRequestCounters();
+ /**
+ * Returns the statistics information of the inbound requests handled
+ * (or being handled) by the service.
+ */
+ Counters getInboundRequestCounters();
}
--===============0434705659302855630==--
From jboss-remoting-commits at lists.jboss.org Tue Jun 15 15:10:28 2010
Content-Type: multipart/mixed; boundary="===============8043691175927882151=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r5870 -
remoting2/branches/2.2/src/main/org/jboss/remoting.
Date: Tue, 15 Jun 2010 15:10:28 -0400
Message-ID: <201006151910.o5FJASP8026434@svn01.web.mwc.hst.phx2.redhat.com>
--===============8043691175927882151==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: ron.sigal(a)jboss.com
Date: 2010-06-15 15:10:28 -0400 (Tue, 15 Jun 2010)
New Revision: 5870
Modified:
remoting2/branches/2.2/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.2/src/main/org/jboss/remoting/ServerInvoker.=
java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2=
010-06-15 08:37:05 UTC (rev 5869)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2=
010-06-15 19:10:28 UTC (rev 5870)
@@ -1199,6 +1199,10 @@
// need to check invoker locator to see if need to provide binding a=
ddress (in the case 0.0.0.0 was used)
InvokerLocator originalLocator =3D locator;
locator =3D 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);
--===============8043691175927882151==--
From jboss-remoting-commits at lists.jboss.org Tue Jun 15 15:13:31 2010
Content-Type: multipart/mixed; boundary="===============3576705744260651183=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r5871 -
remoting2/branches/2.x/src/main/org/jboss/remoting.
Date: Tue, 15 Jun 2010 15:13:31 -0400
Message-ID: <201006151913.o5FJDVJl026509@svn01.web.mwc.hst.phx2.redhat.com>
--===============3576705744260651183==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2=
010-06-15 19:10:28 UTC (rev 5870)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ServerInvoker.java 2=
010-06-15 19:13:31 UTC (rev 5871)
@@ -1160,6 +1160,10 @@
// need to check invoker locator to see if need to provide binding a=
ddress (in the case 0.0.0.0 was used)
InvokerLocator originalLocator =3D locator;
locator =3D 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);
--===============3576705744260651183==--
From jboss-remoting-commits at lists.jboss.org Tue Jun 15 15:14:37 2010
Content-Type: multipart/mixed; boundary="===============2578261845659371133=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r5872 -
remoting2/branches/2.2/src/main/org/jboss/remoting.
Date: Tue, 15 Jun 2010 15:14:37 -0400
Message-ID: <201006151914.o5FJEb8n026533@svn01.web.mwc.hst.phx2.redhat.com>
--===============2578261845659371133==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2=
010-06-15 19:13:31 UTC (rev 5871)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/ServerInvoker.java 2=
010-06-15 19:14:36 UTC (rev 5872)
@@ -1201,7 +1201,7 @@
locator =3D 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
--===============2578261845659371133==--
From jboss-remoting-commits at lists.jboss.org Tue Jun 22 16:28:31 2010
Content-Type: multipart/mixed; boundary="===============5065459952221902756=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r5873 - in
remoting3/trunk/jboss-remoting/src: test/java/org/jboss/remoting3/test and 1
other directories.
Date: Tue, 22 Jun 2010 16:28:31 -0400
Message-ID: <201006222028.o5MKSV9I007297@svn01.web.mwc.hst.phx2.redhat.com>
--===============5065459952221902756==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/En=
dpointConfigurationTestCase.java
remoting3/trunk/jboss-remoting/src/test/resources/protocols.test.remotin=
g.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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- 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$MockMarshallerProvi=
derDescriptor
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/tes=
t/EndpointConfigurationTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/E=
ndpointConfigurationTestCase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/E=
ndpointConfigurationTestCase.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 Endp=
oint with transport protocols
+ * and marshalling components.
+ * =
+ * @author Ron Sigal
+ * @version $Revision: 1.1 $
+ *
+ * Copyright Jun 21, 2010
+ */
+(a)Test(suiteName =3D "EndpointConfiguration")
+public class EndpointConfigurationTestCase {
+
+ private static final Logger log =3D Logger.getLogger(EndpointConfigurat=
ionTestCase.class);
+
+ static void enter() {
+ final StackTraceElement e =3D new Throwable().getStackTrace()[1];
+ log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+ }
+
+ static void exit() {
+ final StackTraceElement e =3D 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 =3D Remoting.class.getDeclaredField("con=
figuredEndpoint");
+ 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 transpo=
rt and marshalling components.
+ */
+ @Test
+ public void testProgrammaticConfiguration() throws Exception {
+ enter();
+ Endpoint endpoint =3D null;
+ Registration regConnectionProvider =3D null;
+ Registration regMarshallerProvider =3D null;
+ Registration regClassExternalizerFactoryProvider =3D null;
+ Registration regClassResolverProvider =3D null;
+ Registration regClassTableProvider =3D null;
+ Registration regObjectResolverProvider =3D null;
+ Registration regObjectTableProvider =3D null;
+ =
+ ProviderDescriptor marshallerProviderDescriptor =3D new MockMarshall=
erProviderDescriptor();
+ MockClassExternalizerFactory mockClassExternalizerFactory =3D new Mo=
ckClassExternalizerFactory();
+ MockClassResolver mockClassResolver =3D new MockClassResolver();
+ MockClassTable mockClassTable =3D new MockClassTable();
+ MockObjectResolver mockObjectResolver =3D new MockObjectResolver();
+ MockObjectTable mockObjectTable =3D new MockObjectTable();
+ =
+ try {
+ Executor executor =3D new ThreadPoolExecutor(8, 64, 30, TimeUnit.=
SECONDS, new ArrayBlockingQueue(64));
+ endpoint =3D Remoting.createEndpoint("endpoint", executor, Option=
Map.EMPTY);
+ regConnectionProvider =3D endpoint.addConnectionProvider("mockTra=
nsport", new MockConnectionProviderFactory());
+ regMarshallerProvider =3D endpoint.addProtocolService(ProtocolSer=
viceType.MARSHALLER_PROVIDER_DESCRIPTOR, "mockMarshaller", marshallerProvid=
erDescriptor);
+ regClassExternalizerFactoryProvider =3D endpoint.addProtocolServi=
ce(ProtocolServiceType.CLASS_EXTERNALIZER_FACTORY, "mockClassExternalizerFa=
ctory", mockClassExternalizerFactory);
+ regClassResolverProvider =3D endpoint.addProtocolService(Protocol=
ServiceType.CLASS_RESOLVER, "mockClassResolver", mockClassResolver);
+ regClassTableProvider =3D endpoint.addProtocolService(ProtocolSer=
viceType.CLASS_TABLE, "mockClassTable", mockClassTable);
+ regObjectResolverProvider =3D endpoint.addProtocolService(Protoco=
lServiceType.OBJECT_RESOLVER, "mockObjectResolver", mockObjectResolver);
+ regObjectTableProvider =3D endpoint.addProtocolService(ProtocolSe=
rviceType.OBJECT_TABLE, "mockObjectTable", mockObjectTable);
+
+ assertSame(MockConnectionProviderFactory.providerInterface, endpo=
int.getConnectionProviderInterface("mockTransport", MockConnectionProviderF=
actory.MockProviderInterface.class));
+ ConnectionProviderContext context =3D MockConnectionProviderFacto=
ry.context;
+ assertSame(marshallerProviderDescriptor, context.getProtocolServi=
ceProvider(ProtocolServiceType.MARSHALLER_PROVIDER_DESCRIPTOR, "mockMarshal=
ler"));
+ assertSame(mockClassExternalizerFactory, context.getProtocolServi=
ceProvider(ProtocolServiceType.CLASS_EXTERNALIZER_FACTORY, "mockClassExtern=
alizerFactory"));
+ assertSame(mockClassResolver, context.getProtocolServiceProvider(=
ProtocolServiceType.CLASS_RESOLVER, "mockClassResolver"));
+ assertSame(mockClassTable, context.getProtocolServiceProvider(Pro=
tocolServiceType.CLASS_TABLE, "mockClassTable"));
+ assertSame(mockObjectResolver, context.getProtocolServiceProvider=
(ProtocolServiceType.OBJECT_RESOLVER, "mockObjectResolver"));
+ assertSame(mockObjectTable, context.getProtocolServiceProvider(Pr=
otocolServiceType.OBJECT_TABLE, "mockObjectTable"));
+ log.info("testProgrammaticConfiguration() PASSES");
+ =
+ } finally {
+ if (regClassExternalizerFactoryProvider !=3D null) {
+ regClassExternalizerFactoryProvider.close();
+ }
+ if (regClassResolverProvider !=3D null) {
+ regClassResolverProvider.close();
+ }
+ if (regClassTableProvider !=3D null) {
+ regClassTableProvider.close();
+ }
+ if (regObjectResolverProvider !=3D null) {
+ regObjectResolverProvider.close();
+ }
+ if (regObjectTableProvider !=3D null) {
+ regObjectTableProvider.close();
+ }
+ if (regMarshallerProvider !=3D null) {
+ regMarshallerProvider.close();
+ }
+ if (regConnectionProvider !=3D null) {
+ regConnectionProvider.close();
+ }
+ if (endpoint !=3D 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 =3D Remoting.getConfiguredEndpoint();
+ assertSame(MockConnectionProviderFactory.providerInterface, endpo=
int.getConnectionProviderInterface("mockTransport", MockConnectionProviderF=
actory.MockProviderInterface.class));
+ ConnectionProviderContext context =3D MockConnectionProviderFacto=
ry.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 instance=
s in the object table list.
+ */
+ @Test
+ public void testConfigurationByPropertiesFile() throws Exception {
+ enter();
+ =
+ try {
+ System.setProperty("remoting.property.file", "protocols.test.remo=
ting.properties");
+ @SuppressWarnings("unused")
+ Endpoint endpoint =3D Remoting.getConfiguredEndpoint();
+ ConnectionProviderContext context =3D MockConnectionProviderFacto=
ry.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 ConnectionProvid=
erContext.
+ */
+ public static class MockConnectionProviderFactory implements Connection=
ProviderFactory {
+ public static ConnectionProviderContext context;
+ public interface MockProviderInterface {};
+ public static MockProviderInterface providerInterface =3D new MockPr=
oviderInterface() {};
+ =
+ public ConnectionProvider createInstance(ConnectionProviderContext c=
ontext) {
+ MockConnectionProviderFactory.context =3D context;
+ return new ConnectionProvider() {
+ public Cancellable connect(URI uri, OptionMap connectOptions, =
Result result, CallbackHandler callbackHandler) t=
hrows IllegalArgumentException {
+ return null;
+ }
+ public Object getProviderInterface() {
+ return providerInterface;
+ }
+ };
+ } =
+ }
+ =
+ public static class MockProtocolDescriptor implements RemotingServiceDe=
scriptor {
+ public Class getType() {
+ return ConnectionProviderFactory.class;
+ }
+ public String getName() {
+ return "mockTransport";
+ }
+ public ConnectionProviderFactory getService(final Properties propert=
ies) throws IOException {
+ return new MockConnectionProviderFactory();
+ }
+ }
+ =
+ public static class MockMarshallerProviderDescriptor implements Provide=
rDescriptor {
+ public MarshallerFactory getMarshallerFactory() {
+ return null;
+ }
+ public String getName() {
+ return "mockMarshaller";
+ }
+ public int[] getSupportedVersions() {
+ return new int[]{0};
+ }
+ }
+
+ public static class MockClassExternalizerFactory implements ClassExtern=
alizerFactory {
+ public Externalizer getExternalizer(Class> type) {
+ return null;
+ }
+ }
+ =
+ public static class MockClassResolver implements ClassResolver {
+ public void annotateClass(Marshaller marshaller, Class> clazz) thr=
ows IOException { =
+ }
+ public void annotateProxyClass(Marshaller marshaller, Class> proxy=
Class) throws IOException { =
+ }
+ public String getClassName(Class> clazz) throws IOException {
+ return null;
+ }
+ public String[] getProxyInterfaces(Class> proxyClass) throws IOExc=
eption {
+ 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 IOExcept=
ion, 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 IOExcepti=
on, ClassNotFoundException {
+ return null;
+ } =
+ }
+ =
+ public static class MockObjectTable2 implements ObjectTable {
+ public Writer getObjectWriter(Object object) throws IOException {
+ return null;
+ }
+ public Object readObject(Unmarshaller unmarshaller) throws IOExcepti=
on, ClassNotFoundException {
+ return null;
+ } =
+ }
+ =
+ public static class MockClassExternalizerFactoryServiceDescriptor imple=
ments RemotingServiceDescriptor {
+ public Class getType() {
+ return ClassExternalizerFactory.class;
+ }
+ public String getName() {
+ return "mockClassExternalizerFactory_sd";
+ }
+ public ClassExternalizerFactory getService(final Properties properti=
es) throws IOException {
+ return new MockClassExternalizerFactory();
+ }
+ }
+ =
+ public static class MockClassResolverServiceDescriptor implements Remot=
ingServiceDescriptor {
+ public Class 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 Remoting=
ServiceDescriptor {
+ public Class getType() {
+ return ClassTable.class;
+ }
+ public String getName() {
+ return "mockClassTable_sd";
+ }
+ public ClassTable getService(final Properties properties) throws IOE=
xception {
+ return new MockClassTable();
+ }
+ }
+ =
+ public static class MockObjectResolverServiceDescriptor implements Remo=
tingServiceDescriptor {
+ public Class 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 Remotin=
gServiceDescriptor {
+ public Class getType() {
+ return ObjectTable.class;
+ }
+ public String getName() {
+ return "mockObjectTable_sd";
+ }
+ public ObjectTable getService(final Properties properties) throws IO=
Exception {
+ return new MockObjectTable();
+ }
+ }
+}
Added: remoting3/trunk/jboss-remoting/src/test/resources/protocols.test.rem=
oting.properties
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/jboss-remoting/src/test/resources/protocols.test.remoti=
ng.properties (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/resources/protocols.test.remoti=
ng.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=3Dprotocols.test
+protocols.test.class_externalizer_factory_list=3DmockClassExternalizerFact=
ory_pf
+protocols.test.class_resolver_list=3DmockClassResolver_pf
+protocols.test.class_table_list=3DmockClassTable_pf
+protocols.test.object_resolver_list=3DmockObjectResolver_pf
+protocols.test.object_table_list=3DmockObjectTable_pf,mockObjectTable_pf1,=
mockObjectTable_pf2
+
+mockClassExternalizerFactory_pf.class_externalizer_factory.mockClassExtern=
alizerFactory_pf.class=3Dorg.jboss.remoting3.test.EndpointConfigurationTest=
Case$MockClassExternalizerFactory
+mockClassResolver_pf.class_resolver.mockClassResolver_pf.class=3Dorg.jboss=
.remoting3.test.EndpointConfigurationTestCase$MockClassResolver
+mockClassTable_pf.class_table.mockClassTable_pf.class=3Dorg.jboss.remoting=
3.test.EndpointConfigurationTestCase$MockClassTable
+mockObjectResolver_pf.object_resolver.mockObjectResolver_pf.class=3Dorg.jb=
oss.remoting3.test.EndpointConfigurationTestCase$MockObjectResolver
+mockObjectTable_pf.object_table.mockObjectTable_pf.class=3Dorg.jboss.remot=
ing3.test.EndpointConfigurationTestCase$MockObjectTable
+mockObjectTable_pf1.object_table.mockObjectTable_pf1.class=3Dorg.jboss.rem=
oting3.test.EndpointConfigurationTestCase$MockObjectTable
+mockObjectTable_pf2.object_table.mockObjectTable_pf2.class=3Dorg.jboss.rem=
oting3.test.EndpointConfigurationTestCase$MockObjectTable2
\ No newline at end of file
--===============5065459952221902756==--
From jboss-remoting-commits at lists.jboss.org Tue Jun 22 16:29:58 2010
Content-Type: multipart/mixed; boundary="===============3433118405482743363=="
MIME-Version: 1.0
From: jboss-remoting-commits at lists.jboss.org
To: jboss-remoting-commits at lists.jboss.org
Subject: [jboss-remoting-commits] JBoss Remoting SVN: r5874 -
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test.
Date: Tue, 22 Jun 2010 16:29:57 -0400
Message-ID: <201006222029.o5MKTvPc007309@svn01.web.mwc.hst.phx2.redhat.com>
--===============3433118405482743363==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/Cl=
ientServerRemoteConfigurationTestCase.java
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/Cl=
ientServerRemoteSSLConfigurationTestCase.java
Log:
JBREM-1228: Added unit tests for a variety of shared and unshared component=
s.
Added: remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/tes=
t/ClientServerRemoteConfigurationTestCase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/C=
lientServerRemoteConfigurationTestCase.java (rev 0)
+++ remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/C=
lientServerRemoteConfigurationTestCase.java 2010-06-22 20:29:57 UTC (rev 58=
74)
@@ -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 Ron Sigal
+ * @version $Revision: 1.1 $
+ *
+ * Copyright Jun 7, 2010
+ */
+(a)Test(suiteName =3D "ClientServerRemoteConfiguration")
+public class ClientServerRemoteConfigurationTestCase {
+
+ private static final Logger log =3D Logger.getLogger(ClientServerRemote=
ConfigurationTestCase.class);
+
+ private static int counter;
+
+ static void enter() {
+ final StackTraceElement e =3D new Throwable().getStackTrace()[1];
+ log.info("Entering: %s#%s", e.getClassName(), e.getMethodName());
+ }
+
+ static void exit() {
+ final StackTraceElement e =3D new Throwable().getStackTrace()[1];
+ log.info("Exiting: %s#%s", e.getClassName(), e.getMethodName());
+ log.info("----------------------------------------------------------=
---");
+ }
+ =
+ static T getFutureResult(IoFuture future, String errorMessage) t=
hrows IOException {
+ Status status =3D null;
+ switch (status =3D 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: " + statu=
s);
+ }
+ }
+ }
+
+ @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 =3D null;
+ ServerPackage sp1 =3D null;
+ ConnectionSet connections =3D new ConnectionSet();
+ ClientSet clients =3D new ClientSet();
+ =
+ try {
+ int id0 =3D counter++;
+ int id1 =3D counter++;
+ =
+ // Set up services.
+ sp0 =3D setupServer(null, id0, null, "test", "test", 4444);
+ sp1 =3D 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 b=
e distinct");
+ =
+ // Set up connections and clients.
+ Connection connection00 =3D setupConnection(4444); connections.ad=
d(connection00);
+ Connection connection01 =3D setupConnection(4444); connections.ad=
d(connection01);
+ Connection connection10 =3D setupConnection(5555); connections.ad=
d(connection10);
+ Connection connection11 =3D setupConnection(5555); connections.ad=
d(connection11);
+ Client