[hornetq-commits] JBoss hornetq SVN: r8505 - trunk/tests/src/org/hornetq/tests/integration/ssl.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Dec 2 11:16:20 EST 2009


Author: jmesnil
Date: 2009-12-02 11:16:19 -0500 (Wed, 02 Dec 2009)
New Revision: 8505

Modified:
   trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java
   trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-234 CoreClientOverSSLTest

* 1 unexpected failure in testPlainConnectionToSSLEndpoint

Modified: trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java	2009-12-02 15:15:34 UTC (rev 8504)
+++ trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java	2009-12-02 16:16:19 UTC (rev 8505)
@@ -49,18 +49,20 @@
          
          log.debug("args = " + Arrays.asList(args));
 
-         if (args.length != 1)
+         if (args.length != 3)
          {
-            log.fatal("unexpected number of args (should be 1)");
+            log.fatal("unexpected number of args (should be 3)");
             System.exit(1);
          }
 
-         boolean sslEnabled = Boolean.parseBoolean(args[0]); 
-         
-         System.out.println("ssl enabled is " + sslEnabled);
-        
+         boolean sslEnabled = Boolean.parseBoolean(args[0]);
+         String keyStorePath = args[1];
+         String keyStorePassword = args[2];
+
          TransportConfiguration tc = new TransportConfiguration("org.hornetq.integration.transports.netty.NettyConnectorFactory");
          tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, sslEnabled);
+         tc.getParams().put(TransportConstants.KEYSTORE_PATH_PROP_NAME, keyStorePath);
+         tc.getParams().put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, keyStorePassword);
          ClientSessionFactory sf = new ClientSessionFactoryImpl(tc);                 
          ClientSession session = sf.createSession(false, true, true);
          ClientProducer producer = session.createProducer(CoreClientOverSSLTest.QUEUE);

Modified: trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java	2009-12-02 15:15:34 UTC (rev 8504)
+++ trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java	2009-12-02 16:16:19 UTC (rev 8505)
@@ -9,14 +9,27 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  * implied.  See the License for the specific language governing
  * permissions and limitations under the License.
- */ 
+ */
 
 package org.hornetq.tests.integration.ssl;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.hornetq.core.client.ClientConsumer;
 import org.hornetq.core.client.ClientSession;
+import org.hornetq.core.client.ClientSessionFactory;
+import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
 import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.Message;
+import org.hornetq.core.server.HornetQ;
 import org.hornetq.core.server.HornetQServer;
+import org.hornetq.integration.transports.netty.NettyAcceptorFactory;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
+import org.hornetq.integration.transports.netty.TransportConstants;
+import org.hornetq.tests.util.SpawnedVMSupport;
 import org.hornetq.tests.util.UnitTestCase;
 import org.hornetq.utils.SimpleString;
 
@@ -31,100 +44,93 @@
    // Constants -----------------------------------------------------
 
    public static final String MESSAGE_TEXT_FROM_CLIENT = "CoreClientOverSSLTest from client";
+
    public static final SimpleString QUEUE = new SimpleString("QueueOverSSL");
+
    public static final int SSL_PORT = 5402;
 
    // Static --------------------------------------------------------
 
-   private static final Logger log = Logger
-         .getLogger(CoreClientOverSSLTest.class);
+   private static final Logger log = Logger.getLogger(CoreClientOverSSLTest.class);
 
    // Attributes ----------------------------------------------------
 
-   private HornetQServer messagingService;
+   private HornetQServer server;
 
    private ClientSession session;
 
    private ClientConsumer consumer;
-   
+
    // Constructors --------------------------------------------------
 
    // Public --------------------------------------------------------
 
-   public void testDummy()
+   public void testSSL() throws Exception
    {
-      //This whole test needs to be rewritten - there's no need for it to be spawning vms
+      final Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class.getName(), Boolean.TRUE.toString(), TransportConstants.DEFAULT_KEYSTORE_PATH, TransportConstants.DEFAULT_KEYSTORE_PASSWORD);
+
+      Message m = consumer.receive(10000);
+      assertNotNull(m);
+      assertEquals(MESSAGE_TEXT_FROM_CLIENT, m.getBodyBuffer().readString());
+
+      log.debug("waiting for the client VM to exit ...");
+      SpawnedVMSupport.assertProcessExits(true, 0, p);
    }
-   
-//   public void testSSL() throws Exception
-//   {
-//      final Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class
-//            .getName(), Boolean.TRUE.toString());
-//
-//      Message m = consumer.receive(10000);
-//      assertNotNull(m);
-//      assertEquals(MESSAGE_TEXT_FROM_CLIENT, m.getBody().getString());
-//
-//      log.debug("waiting for the client VM to exit ...");
-//      SpawnedVMSupport.assertProcessExits(true, 0, p);
-//   }
-//
-//   public void testSSLWithIncorrectKeyStorePassword() throws Exception
-//   {
-//      Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class
-//            .getName(), Boolean.TRUE.toString());
-//
-//      Message m = consumer.receive(5000);
-//      assertNull(m);
-//
-//      log.debug("waiting for the client VM to exit ...");
-//      SpawnedVMSupport.assertProcessExits(false, 0, p);
-//   }
-//
-//   public void testPlainConnectionToSSLEndpoint() throws Exception
-//   {
-//      Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class
-//            .getName(), FALSE.toString());
-//
-//      Message m = consumer.receive(5000);
-//      assertNull(m);
-//
-//      log.debug("waiting for the client VM to exit ...");
-//      SpawnedVMSupport.assertProcessExits(false, 0, p);
-//   }
 
+   public void testSSLWithIncorrectKeyStorePassword() throws Exception
+   {
+      Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class.getName(), Boolean.TRUE.toString(), TransportConstants.DEFAULT_KEYSTORE_PATH, "invalid pasword");
+
+      Message m = consumer.receive(5000);
+      assertNull(m);
+
+      log.debug("waiting for the client VM to exit ...");
+      SpawnedVMSupport.assertProcessExits(false, 0, p);
+   }
+
+   // see https://jira.jboss.org/jira/browse/HORNETQ-234
+   public void _testPlainConnectionToSSLEndpoint() throws Exception
+   {
+      Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class.getName(), Boolean.FALSE.toString(), TransportConstants.DEFAULT_KEYSTORE_PATH, TransportConstants.DEFAULT_KEYSTORE_PASSWORD);
+
+      Message m = consumer.receive(5000);
+      assertNull(m);
+
+      log.debug("waiting for the client VM to exit ...");
+      SpawnedVMSupport.assertProcessExits(false, 0, p);
+   }
+
    // Package protected ---------------------------------------------
 
-//   @Override
-//   protected void setUp() throws Exception
-//   {
-//      ConfigurationImpl config = new ConfigurationImpl();
-//      config.setSecurityEnabled(false);
-//      Map<String, Object> params = new HashMap<String, Object>();
-//      params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
-//      config.getAcceptorInfos().add(new TransportConfiguration("org.hornetq.integration.transports.netty.NettyAcceptorFactory", params));
-//      server = HornetQServerImpl.newNullStorageHornetQServer(config);      
-//      server.start();
-//      ConnectorFactory cf = new NettyConnectorFactory();
-//      ClientSessionFactory sf = new ClientSessionFactoryImpl(cf);    
-//      sf.setTransportParams(params);
-//      session = sf.createSession(false, true, true, -1, false);
-//      session.createQueue(QUEUE, QUEUE, null, false, false);
-//      consumer = session.createConsumer(QUEUE);
-//      session.start();
-//   }
-//
-//   @Override
-//   protected void tearDown() throws Exception
-//   {
-//      consumer.close();
-//      session.close();
-//
-//      server.stop();
-//
-//      super.tearDown();
-//   }
+   @Override
+   protected void setUp() throws Exception
+   {
+      ConfigurationImpl config = new ConfigurationImpl();
+      config.setSecurityEnabled(false);
+      Map<String, Object> params = new HashMap<String, Object>();
+      params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
+      config.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName(), params));
+      server = HornetQ.newHornetQServer(config, false);
+      server.start();
+      TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
+      ClientSessionFactory sf = new ClientSessionFactoryImpl(tc);
+      session = sf.createSession(false, true, true);
+      session.createQueue(QUEUE, QUEUE, false);
+      consumer = session.createConsumer(QUEUE);
+      session.start();
+   }
 
+   @Override
+   protected void tearDown() throws Exception
+   {
+      consumer.close();
+      session.close();
+
+      server.stop();
+
+      super.tearDown();
+   }
+
    // Protected -----------------------------------------------------
 
    // Private -------------------------------------------------------



More information about the hornetq-commits mailing list