[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/transporter/multiInterface ...
Tom Elrod
tom.elrod at jboss.com
Mon Jul 17 12:54:47 EDT 2006
User: telrod
Date: 06/07/17 12:54:47
Added: src/tests/org/jboss/test/remoting/transporter/multiInterface
TestClient.java TestServer.java TestServer2.java
TestServerImpl.java TransporterTestCase.java
Log:
JBREM-547 - adding test case for exposing all interfaces for target pojo for transporter server.
Revision Changes Path
1.1 date: 2006/07/17 16:54:47; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/transporter/multiInterface/TestClient.java
Index: TestClient.java
===================================================================
package org.jboss.test.remoting.transporter.multiInterface;
import junit.framework.TestCase;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.transporter.TransporterClient;
import java.io.IOException;
/**
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
*/
public class TestClient extends TestCase
{
public void testClientCall() throws Exception
{
String locatorURI = "socket://localhost:5400";
InvokerLocator locator = new InvokerLocator(locatorURI);
TestServer test = (TestServer) TransporterClient.createTransporterClient(locator, TestServer.class);
Object response = test.processTestMessage("Hello");
System.out.println("response is: " + response);
assertEquals("response should be 'Hello - has been processed'", "Hello - has been processed", response);
// now make call that should throw exception
try
{
test.throwException();
assertTrue("Should have received IOException thrown by server.", false);
}
catch(IOException ioex)
{
assertTrue("Should have received IOException thrown by server.", true);
}
TransporterClient.destroyTransporterClient(test);
TestServer2 test2 = (TestServer2) TransporterClient.createTransporterClient(locator, TestServer2.class);
Object response2 = test2.doIt("foobar");
System.out.println("response2 is: " + response2);
assertEquals("response should be 'foobar'", "foobar", response2);
TransporterClient.destroyTransporterClient(test2);
}
}
1.1 date: 2006/07/17 16:54:47; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/transporter/multiInterface/TestServer.java
Index: TestServer.java
===================================================================
package org.jboss.test.remoting.transporter.multiInterface;
import java.io.IOException;
/**
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
*/
public interface TestServer
{
public String processTestMessage(String msg);
public void throwException() throws IOException;
}
1.1 date: 2006/07/17 16:54:47; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/transporter/multiInterface/TestServer2.java
Index: TestServer2.java
===================================================================
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, 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.transporter.multiInterface;
/**
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
*/
public interface TestServer2
{
public String doIt(String msg);
}
1.1 date: 2006/07/17 16:54:47; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/transporter/multiInterface/TestServerImpl.java
Index: TestServerImpl.java
===================================================================
package org.jboss.test.remoting.transporter.multiInterface;
import org.jboss.jrunit.extensions.ServerTestCase;
import org.jboss.remoting.transporter.TransporterServer;
import java.io.IOException;
/**
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
*/
public class TestServerImpl extends ServerTestCase implements TestServer, TestServer2
{
private String locatorURI = "socket://localhost:5400";
private TransporterServer server = null;
public String processTestMessage(String msg)
{
return msg + " - has been processed";
}
public void throwException() throws IOException
{
throw new IOException("This is an expected exception thrown by impl on purpose.");
}
public void setUp() throws Exception
{
server = TransporterServer.createTransporterServer(locatorURI, new TestServerImpl());
}
public void tearDown()
{
if(server != null)
{
server.stop();
}
}
/**
* Just here so can run from a few line within a main
*
* @param args
*/
public static void main(String[] args)
{
String locatorURI = "socket://localhost:5400";
try
{
TestServerImpl testServer = new TestServerImpl();
testServer.setUp();
Thread.currentThread().sleep(60000);
testServer.tearDown();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public String doIt(String msg)
{
return msg;
}
}
1.1 date: 2006/07/17 16:54:47; author: telrod; state: Exp;JBossRemoting/src/tests/org/jboss/test/remoting/transporter/multiInterface/TransporterTestCase.java
Index: TransporterTestCase.java
===================================================================
package org.jboss.test.remoting.transporter.multiInterface;
import org.apache.log4j.Level;
import org.jboss.jrunit.harness.TestDriver;
/**
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
*/
public class TransporterTestCase extends TestDriver
{
public void declareTestClasses()
{
addTestClasses(TestClient.class.getName(),
1,
TestServerImpl.class.getName());
}
protected Level getTestHarnessLogLevel()
{
return Level.DEBUG;
}
}
More information about the jboss-cvs-commits
mailing list