2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23
package org.jboss.test.remoting.transport;
25
import java.util.HashMap;
26
import java.util.Iterator;
29
import org.jboss.jrunit.extensions.ServerTestCase;
30
import org.jboss.logging.Logger;
31
import org.jboss.remoting.InvokerLocator;
32
import org.jboss.remoting.ServerInvocationHandler;
33
import org.jboss.remoting.transport.Connector;
34
import org.jboss.test.remoting.TestUtil;
35
import org.jboss.test.remoting.performance.synchronous.PerformanceServerTest;
36
import org.jboss.test.remoting.performance.synchronous.PerformanceTestCase;
37
import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler;
40
* This is the concrete test for invoker server.
42
* @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
44
public abstract class InvokerServerTest extends ServerTestCase
46
protected int serverPort = 9091; // default port
47
protected Connector connector = null;
49
protected static final Logger log = Logger.getLogger(InvokerServerTest.class);
51
public abstract String getTransport();
53
public String getSerializationType()
58
public void init(Map metatdata) throws Exception
63
serverPort = TestUtil.getRandomPort();
65
log.debug("port = " + serverPort);
67
connector = new Connector();
68
InvokerLocator locator = new InvokerLocator(buildLocatorURI(metatdata));
69
connector.setInvokerLocator(locator.getLocatorURI());
70
System.out.println("Creating connector with locator of " + locator);
72
connector.addInvocationHandler(getSubsystem(), getServerInvocationHandler());
76
protected String buildLocatorURI(Map metadata)
78
String host = System.getProperty("jrunit.bind_addr", "localhost");
80
if(metadata == null || metadata.size() == 0)
82
return getTransport() + "://" + host + ":" + serverPort;
86
StringBuffer uriBuffer = new StringBuffer(getTransport() + "://" + host + ":" + serverPort);
88
Set keys = metadata.keySet();
91
uriBuffer.append("/?");
93
Iterator itr = keys.iterator();
96
String key = (String) itr.next();
97
String value = (String) metadata.get(key);
98
uriBuffer.append(key).append("=").append(value).append("&");
100
return uriBuffer.substring(0, uriBuffer.length() - 1);
104
protected String getSubsystem()
109
protected ServerInvocationHandler getServerInvocationHandler()
111
return new MockServerInvocationHandler();
114
public void setUp() throws Exception
116
Map metadata = new HashMap();
117
String newMetadata = System.getProperty(PerformanceTestCase.REMOTING_METADATA);
118
if(newMetadata != null && newMetadata.length() > 0)
120
metadata.putAll(PerformanceServerTest.parseMetadataString(newMetadata));
125
public void tearDown() throws Exception
127
if(connector != null)