Author: ron.sigal(a)jboss.com
Date: 2010-11-13 11:34:06 -0500 (Sat, 13 Nov 2010)
New Revision: 6147
Modified:
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java
Log:
JBREM-1256: Uses Random from RemotingRootTestBase and
Remoting.getConfiguredEndpoint(OptionMap optionMap).
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-11-13
16:29:03 UTC (rev 6146)
+++
remoting3/trunk/jboss-remoting/src/test/java/org/jboss/remoting3/test/ClientServerRemoteConfigurationTestCase.java 2010-11-13
16:34:06 UTC (rev 6147)
@@ -29,9 +29,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Date;
import java.util.HashSet;
-import java.util.Random;
import java.util.ServiceLoader;
import org.jboss.remoting3.Client;
@@ -42,6 +40,7 @@
import org.jboss.remoting3.RequestContext;
import org.jboss.remoting3.RequestListener;
import org.jboss.remoting3.spi.RemotingServiceDescriptor;
+import org.jboss.xnio.OptionMap;
import org.jboss.xnio.log.Logger;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -61,8 +60,6 @@
private static final Logger log =
Logger.getLogger(ClientServerRemoteConfigurationTestCase.class);
- private static int counter = Math.abs(new Random(new Date().getTime()).nextInt());
-
@BeforeMethod
public void setUp() {
ServiceLoader.load(RemotingServiceDescriptor.class);
@@ -86,8 +83,8 @@
ClientSet clients = new ClientSet();
try {
- int id0 = counter++;
- int id1 = counter++;
+ int id0 = Math.abs(random.nextInt());
+ int id1 = Math.abs(random.nextInt());
// Set up services.
TestRequestListener testRequestListener0 = new TestRequestListener(id0);
@@ -161,8 +158,8 @@
ClientSet clients = new ClientSet();
try {
- int id0 = counter++;
- int id1 = counter++;
+ int id0 = Math.abs(random.nextInt());
+ int id1 = Math.abs(random.nextInt());
String serviceType0 = "test" + id0;
String instanceName0 = serviceType0;
String serviceType1 = "test" + id1;
@@ -240,8 +237,8 @@
ClientSet clients = new ClientSet();
try {
- int id0 = counter++;
- int id1 = counter++;
+ int id0 = Math.abs(random.nextInt());
+ int id1 = Math.abs(random.nextInt());
String serviceType0 = "test" + id0;
String instanceName0 = serviceType0;
String serviceType1 = "test" + id1;
@@ -319,8 +316,8 @@
ClientSet clients = new ClientSet();
try {
- int id0 = counter++;
- int id1 = counter++;
+ int id0 = Math.abs(random.nextInt());
+ int id1 = Math.abs(random.nextInt());
String serviceType0 = "test" + id0;
String instanceName0 = serviceType0;
String serviceType1 = "test" + id1;
@@ -400,8 +397,8 @@
ClientSet clients = new ClientSet();
try {
- int id0 = counter++;
- int id1 = counter++;
+ int id0 = Math.abs(random.nextInt());
+ int id1 = Math.abs(random.nextInt());
String serviceType0 = "test" + id0;
String serviceType1 = "test" + id1;
String instanceName0 = "instance0";
@@ -506,8 +503,8 @@
ClientSet clients = new ClientSet();
try {
- int id0 = counter++;
- int id1 = counter++;
+ int id0 = Math.abs(random.nextInt());
+ int id1 = Math.abs(random.nextInt());
String serviceType0 = "test" + id0;
String serviceType1 = "test" + id1;
String instanceName0 = "instance0";
@@ -589,7 +586,10 @@
}
protected Connection setupConnection(int port) throws IOException, URISyntaxException
{
- Endpoint endpoint = Remoting.getConfiguredEndpoint();
+ String s = "xnio" + String.valueOf(Math.abs(random.nextInt()));
+ log.info(this + " creating xnio: " + s);
+ OptionMap optionMap = OptionMap.builder().set(XNIO_ID, s).getMap();
+ Endpoint endpoint = Remoting.getConfiguredEndpoint(optionMap);
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;