activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r449045 - in /incubator/activemq/trunk/activemq-core: pom.xml src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java
Date Fri, 22 Sep 2006 18:40:43 GMT
Author: jstrachan
Date: Fri Sep 22 11:40:43 2006
New Revision: 449045

URL: http://svn.apache.org/viewvc?view=rev&rev=449045
Log:
fixed failing test

Modified:
    incubator/activemq/trunk/activemq-core/pom.xml
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java

Modified: incubator/activemq/trunk/activemq-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/pom.xml?view=diff&rev=449045&r1=449044&r2=449045
==============================================================================
--- incubator/activemq/trunk/activemq-core/pom.xml (original)
+++ incubator/activemq/trunk/activemq-core/pom.xml Fri Sep 22 11:40:43 2006
@@ -296,10 +296,6 @@
             <!--  see  http://issues.apache.org/activemq/browse/AMQ-826 -->
             <!--  have not yet figured out the way to configure ApacheDS via Spring  -->
             <exclude>**/LDAPAuthorizationMapTest.*</exclude>
-
-            <!-- TODO fix ASAP -->
-            <exclude>**/SslTransportFactoryTest.*</exclude>
-
           </excludes>
         </configuration>
       </plugin>

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java?view=diff&rev=449045&r1=449044&r2=449045
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/SslTransportFactoryTest.java
Fri Sep 22 11:40:43 2006
@@ -19,7 +19,6 @@
 package org.apache.activemq.transport.tcp;
 
 import junit.framework.TestCase;
-
 import org.apache.activemq.openwire.OpenWireFormat;
 
 import java.io.IOException;
@@ -29,7 +28,8 @@
 
 public class SslTransportFactoryTest extends TestCase {
     private SslTransportFactory factory;
-    
+    private boolean verbose;
+
     protected void setUp() throws Exception {
         factory = new SslTransportFactory();
     }
@@ -37,93 +37,114 @@
     protected void tearDown() throws Exception {
         super.tearDown();
     }
-    
+
     public void testBindServerOptions() throws IOException {
-                
+
         SslTransportServer sslTransportServer = null;
-        
+
         for (int i = 0; i < 4; ++i) {
             final boolean wantClientAuth = ((i & 0x1) == 1);
             final boolean needClientAuth = ((i & 0x2) == 1);
-            
+
             String options = "wantClientAuth=" + (wantClientAuth ? "true" : "false") +
-                "&needClientAuth=" + (needClientAuth ? "true" : "false");
-        
+                    "&needClientAuth=" + (needClientAuth ? "true" : "false");
+
             try {
                 sslTransportServer = (SslTransportServer)
-                    factory.doBind("brokerId", new URI("ssl://localhost:61616?" + options));
-            } catch (Exception e) {
+                        factory.doBind("brokerId", new URI("ssl://localhost:61616?" + options));
+            }
+            catch (Exception e) {
                 fail("Unable to bind to address: " + e.getMessage());
             }
-            
+
             assertEquals("Created ServerSocket did not have correct wantClientAuth status.",
-                sslTransportServer.getWantClientAuth(), wantClientAuth);
-            
+                    sslTransportServer.getWantClientAuth(), wantClientAuth);
+
             assertEquals("Created ServerSocket did not have correct needClientAuth status.",
-                sslTransportServer.getNeedClientAuth(), needClientAuth);
-            
+                    sslTransportServer.getNeedClientAuth(), needClientAuth);
+
             try {
                 sslTransportServer.stop();
-            } catch (Exception e) {
+            }
+            catch (Exception e) {
                 fail("Unable to stop TransportServer: " + e.getMessage());
             }
         }
     }
-    
+
     private int getMthNaryDigit(int number, int digitIdx, int numBase) {
-        return (number / ((int)Math.pow(numBase, digitIdx)) ) % numBase;
+        return (number / ((int) Math.pow(numBase, digitIdx))) % numBase;
     }
-    
+
     public void testCompositeConfigure() throws IOException {
         // The 5 options being tested.
         int optionSettings[] = new int[5];
-        
+
         String optionNames[] = {
-          "wantClientAuth",
-          "needClientAuth",
-          "socket.wantClientAuth",
-          "socket.needClientAuth",
-          "socket.useClientMode"
+                "wantClientAuth",
+                "needClientAuth",
+                "socket.wantClientAuth",
+                "socket.needClientAuth",
+                "socket.useClientMode"
         };
-        
+
         // Using a trinary interpretation of i to set all possible values of stub options
for socket and transport.
         // 2 transport options, 3 socket options, 3 settings for each option => 3^5 =
243 combos.
         for (int i = 0; i < 243; ++i) {
             Map options = new HashMap();
-            
+
             for (int j = 0; j < 5; ++j) {
                 // -1 since the option range is [-1,1], not [0,2].
                 optionSettings[j] = getMthNaryDigit(i, j, 3) - 1;
-                
-                if ( optionSettings[j] != -1) {
+
+                if (optionSettings[j] != -1) {
                     options.put(optionNames[j], (optionSettings[j] == 1 ? "true" : "false"));
                 }
             }
-            
+
             StubSSLSocket socketStub = new StubSSLSocket(null);
             StubSslTransport transport = null;
-            
+
             try {
                 transport = new StubSslTransport(null, socketStub);
-            } catch (Exception e) {
+            }
+            catch (Exception e) {
                 fail("Unable to create StubSslTransport: " + e.getMessage());
             }
-            
+
+            if (verbose) {
+                System.out.println();
+                System.out.println("Iteration: " + i);
+                System.out.println("Map settings: " + options);
+                for (int x = 0; x < optionSettings.length; x++) {
+                    System.out.println("optionSetting[" + x + "] = " + optionSettings[x]);
+                }
+            }
+
             factory.compositeConfigure(transport, new OpenWireFormat(), options);
-            
-            if (socketStub.getWantClientAuthStatus() != optionSettings[2])
+
+            // lets start the transport to force the introspection
+            try {
+                transport.start();
+            }
+            catch (Exception e) {
+                // ignore bad connection
+            }
+
+            if (socketStub.getWantClientAuthStatus() != optionSettings[2]) {
                 System.out.println("sheiite");
-            
-            assertEquals("wantClientAuth was not properly set",
-                optionSettings[0], transport.getWantClientAuthStatus());
-            assertEquals("needClientAuth was not properly set",
-                optionSettings[1], transport.getNeedClientAuthStatus());
-            assertEquals("socket.wantClientAuth was not properly set",
-                optionSettings[2], socketStub.getWantClientAuthStatus());
-            assertEquals("socket.needClientAuth was not properly set",
-                optionSettings[3], socketStub.getNeedClientAuthStatus());
-            assertEquals("socket.useClientMode was not properly set",
-                optionSettings[4], socketStub.getUseClientModeStatus());
+            }
+
+            assertEquals("wantClientAuth was not properly set for iteration: " + i,
+                    optionSettings[0], transport.getWantClientAuthStatus());
+            assertEquals("needClientAuth was not properly set for iteration: " + i,
+                    optionSettings[1], transport.getNeedClientAuthStatus());
+            assertEquals("socket.wantClientAuth was not properly set for iteration: " + i,
+                    optionSettings[2], socketStub.getWantClientAuthStatus());
+            assertEquals("socket.needClientAuth was not properly set for iteration: " + i,
+                    optionSettings[3], socketStub.getNeedClientAuthStatus());
+            assertEquals("socket.useClientMode was not properly set for iteration: " + i,
+                    optionSettings[4], socketStub.getUseClientModeStatus());
         }
     }
 }



Mime
View raw message