[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom ...
Ron Sigal
ron_sigal at yahoo.com
Wed Dec 27 01:14:53 EST 2006
User: rsigal
Date: 06/12/27 01:14:53
Added: src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom
SSLBisocketInvokerTestCase.java
SSLBisocketInvokerClientTest.java
SSLBisocketInvokerServerTest.java
Log:
JBREM-650: Unit tests for sslbisocket transport.
Revision Changes Path
1.2 +85 -0 JBossRemoting/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom/SSLBisocketInvokerTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SSLBisocketInvokerTestCase.java
===================================================================
RCS file: SSLBisocketInvokerTestCase.java
diff -N SSLBisocketInvokerTestCase.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SSLBisocketInvokerTestCase.java 27 Dec 2006 06:14:53 -0000 1.2
@@ -0,0 +1,85 @@
+ /*
+* 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.transport.bisocket.ssl.custom;
+
+import org.apache.log4j.Level;
+import org.jboss.jrunit.harness.TestDriver;
+
+
+/**
+ * This should be used as the main test case for the invoker client/server.
+ * It will start one instance of the client and one of the server and will
+ * gather the test results and report them in standard JUnit format. When
+ * wanting to run JUnit test for invoker, this is the class to use.
+ *
+ * @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ */
+public class SSLBisocketInvokerTestCase extends TestDriver
+{
+ public void declareTestClasses()
+ {
+ addTestClasses(SSLBisocketInvokerClientTest.class.getName(),
+ 1,
+ SSLBisocketInvokerServerTest.class.getName());
+ }
+
+ protected Level getTestLogLevel()
+ {
+ return Level.DEBUG;
+ }
+
+ /**
+ * How long to wait for test results to be returned from the client(s). If goes longer than the
+ * specified limit, will throw an exception and kill the running test cases. Default value is
+ * RESULTS_TIMEOUT.
+ *
+ * @return
+ */
+ protected long getResultsTimeout()
+ {
+ return 600000;
+ }
+
+ /**
+ * How long for the server test case to wait for tear down message. If exceeds timeout,
+ * will throw exception. The default value is TEARDOWN_TIMEOUT.
+ *
+ * @return
+ */
+ protected long getTearDownTimeout()
+ {
+ return 600000;
+ }
+
+ /**
+ * How long to allow each of the test cases to run their tests. If exceeds this timeout
+ * will throw exception and kill tests. The default value is RUN_TEST_TIMEOUT.
+ *
+ * @return
+ */
+ protected long getRunTestTimeout()
+ {
+ return 600000;
+ }
+}
\ No newline at end of file
1.2 +97 -0 JBossRemoting/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom/SSLBisocketInvokerClientTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SSLBisocketInvokerClientTest.java
===================================================================
RCS file: SSLBisocketInvokerClientTest.java
diff -N SSLBisocketInvokerClientTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SSLBisocketInvokerClientTest.java 27 Dec 2006 06:14:53 -0000 1.2
@@ -0,0 +1,97 @@
+/*
+ * 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.transport.bisocket.ssl.custom;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.security.SSLSocketBuilder;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.bisocket.Bisocket;
+import org.jboss.test.remoting.transport.socket.ssl.custom.InvokerClientTest;
+
+
+/**
+ * @author <a href="mailto:tom at jboss.com">Tom Elrod</a>
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.2 $
+ * <p>
+ * Copyright (c) Dec 15, 2006
+ * </p>
+ */
+public class SSLBisocketInvokerClientTest extends InvokerClientTest
+{
+ private static Logger log = Logger.getLogger(SSLBisocketInvokerClientTest.class);
+
+ public void testCallbacks()
+ {
+ try
+ {
+ InvokerLocator locator = new InvokerLocator(getTransport() + "://localhost:" + callbackPort);
+ HashMap config = new HashMap();
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
+ String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");
+ config.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ Connector callbackConnector = new Connector(locator.getLocatorURI(), config);
+ callbackConnector.setServerSocketFactory(createServerSocketFactory());
+ callbackConnector.create();
+ callbackConnector.addInvocationHandler("sample", new SampleInvocationHandler());
+ callbackConnector.start();
+
+ CallbackHandler callbackHandler = new CallbackHandler();
+ String callbackHandleObject = "myCallbackHandleObject";
+ client.addListener(callbackHandler, locator, callbackHandleObject);
+ solicitCallback("abc");
+
+ // need to wait for brief moment so server can callback
+ Thread.sleep(500);
+
+ // remove callback handler from server
+ client.removeListener(callbackHandler);
+
+ // shut down callback server
+ callbackConnector.stop();
+ callbackConnector.destroy();
+ callbackConnector = null;
+
+ List callbacks = callbackHandler.getCallbacks();
+ assertEquals(callbacks.size(), 1);
+// assertEquals(callbacks.get(0), "abc");
+ }
+ catch (Throwable t)
+ {
+ log.error(t);
+ t.printStackTrace();
+ fail();
+ }
+ }
+
+ protected String getTransport()
+ {
+ return "sslbisocket";
+ }
+}
1.2 +52 -0 JBossRemoting/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/custom/SSLBisocketInvokerServerTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SSLBisocketInvokerServerTest.java
===================================================================
RCS file: SSLBisocketInvokerServerTest.java
diff -N SSLBisocketInvokerServerTest.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SSLBisocketInvokerServerTest.java 27 Dec 2006 06:14:53 -0000 1.2
@@ -0,0 +1,52 @@
+/*
+* 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.transport.bisocket.ssl.custom;
+
+import org.jboss.test.remoting.transport.socket.ssl.custom.InvokerServerTest;
+
+/**
+ * @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
+ * @author <a href="ron.sigal at jboss.com">Ron Sigal</a>
+ */
+public class SSLBisocketInvokerServerTest extends InvokerServerTest
+{
+ public static void main(String[] args)
+ {
+ SSLBisocketInvokerServerTest test = new SSLBisocketInvokerServerTest();
+ try
+ {
+ test.setUp();
+ Thread.sleep(20000);
+ test.tearDown();
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ protected String getTransport()
+ {
+ return "sslbisocket";
+ }
+}
More information about the jboss-cvs-commits
mailing list