Author: ron.sigal(a)jboss.com
Date: 2009-04-21 01:34:17 -0400 (Tue, 21 Apr 2009)
New Revision: 5076
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java
Log:
JBREM-1121: Added variation of existing test methods with
"useAllSocketFactoryParams=true" in InvokerLocator.
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java 2009-04-21
05:29:34 UTC (rev 5075)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/socketfactory/SocketFactoryClassNameTestRoot.java 2009-04-21
05:34:17 UTC (rev 5076)
@@ -1,3 +1,24 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
package org.jboss.test.remoting.socketfactory;
import java.io.IOException;
@@ -16,7 +37,6 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
-import org.jboss.logging.XLevel;
import org.jboss.remoting.AbstractInvoker;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvocationRequest;
@@ -57,7 +77,7 @@
if (firstTime)
{
firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
PatternLayout layout = new PatternLayout(pattern);
@@ -77,11 +97,11 @@
log.info("entering " + getName());
// Start server.
- setupServer();
+ setupServer(false);
// Create client.
String clientLocatorURI = locatorURI;
- clientLocatorURI += "/?" + Remoting.SOCKET_FACTORY_CLASS_NAME +
"=" + getSocketFactoryClass().getName();
+ clientLocatorURI += "&" + Remoting.SOCKET_FACTORY_CLASS_NAME +
"=" + getSocketFactoryClass().getName();
InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
HashMap clientConfig = new HashMap();
clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
@@ -111,7 +131,7 @@
log.info("entering " + getName());
// Start server.
- setupServer();
+ setupServer(false);
// Create client.
InvokerLocator clientLocator = new InvokerLocator(locatorURI);
@@ -139,6 +159,73 @@
}
+ public void testSocketFactoryClassNameInLocatorWithUseAllParams() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true);
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&" + Remoting.SOCKET_FACTORY_CLASS_NAME +
"=" + getSocketFactoryClass().getName();
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to " + clientLocatorURI);
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify client invoker is using configured SocketFactory.
+ AbstractInvoker invoker = (AbstractInvoker) client.getInvoker();
+ SocketFactory socketFactory = invoker.getSocketFactory();
+ log.info("SocketFactory: " + socketFactory);
+ assertTrue(getSocketFactoryClass().isInstance(socketFactory));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testSocketFactoryClassNameInConfigMapWithUseAllParams() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Remoting.SOCKET_FACTORY_CLASS_NAME,
getSocketFactoryClass().getName());
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Verify client invoker is using configured SocketFactory.
+ AbstractInvoker invoker = (AbstractInvoker) client.getInvoker();
+ SocketFactory socketFactory = invoker.getSocketFactory();
+ log.info("SocketFactory: " + socketFactory);
+ assertTrue(getSocketFactoryClass().isInstance(socketFactory));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
protected abstract String getTransport();
@@ -152,11 +239,20 @@
protected void addExtraServerConfig(Map config) {}
- protected void setupServer() throws Exception
+ protected void setupServer(boolean useAllParams) throws Exception
{
host = InetAddress.getLocalHost().getHostAddress();
port = PortUtil.findFreePort(host);
- locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI = getTransport() + "://" + host + ":" + port +
"/?x=x";
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "&" + metadata;
+ }
+ if (useAllParams)
+ {
+ locatorURI += "&" + Remoting.USE_ALL_SOCKET_FACTORY_PARAMS +
"=true";
+ }
serverLocator = new InvokerLocator(locatorURI);
log.info("Starting remoting server with locator uri of: " + locatorURI);
HashMap config = new HashMap();