cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1346488 - /cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java
Date Tue, 05 Jun 2012 17:39:06 GMT
Author: ay
Date: Tue Jun  5 17:39:05 2012
New Revision: 1346488

URL: http://svn.apache.org/viewvc?rev=1346488&view=rev
Log:
fixed ManagedEndpointsTest for its execution order issue

Modified:
    cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java

Modified: cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java?rev=1346488&r1=1346487&r2=1346488&view=diff
==============================================================================
--- cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java
(original)
+++ cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/ManagedEndpointsTest.java
Tue Jun  5 17:39:05 2012
@@ -103,16 +103,6 @@ public class ManagedEndpointsTest extend
     }
     
     @Test
-    public void runTests() throws Exception {
-        //There is a problem if testSuspendAndResumeSourceSequence is run first
-        //Need to get Aki to look at it.  For now, just force them into 
-        //an order that works
-        testManagedEndpointsOneway();
-        stopBus();
-        testSuspendAndResumeSourceSequence();
-    }
-    
-    //@Test
     public void testManagedEndpointsOneway() throws Exception {
         checkServerReady(30000);
         
@@ -145,10 +135,10 @@ public class ManagedEndpointsTest extend
         greeter.greetMeOneWay("one"); // sent
 
         o = mbs.invoke(clientManagerName, "getEndpointIdentifiers", null, null);
-        verifyArray("Expected endpoint identifier", o, new String[]{epId});
+        verifyArray("Expected endpoint identifier", o, new String[]{epId}, true);
 
         o = mbs.invoke(serverManagerName, "getEndpointIdentifiers", null, null);
-        verifyArray("Expected endpoint identifier", o, new String[]{epId});
+        verifyArray("Expected endpoint identifier", o, new String[]{epId}, true);
         
         ObjectName clientEndpointName = RMUtils.getManagedObjectName(clientManager, ep);
         ObjectName serverEndpointName = RMUtils.getManagedObjectName(serverManager, ep);
@@ -162,7 +152,7 @@ public class ManagedEndpointsTest extend
         assertTrue("Expected sequence identifier", o instanceof String && sseqId.equals(o));
         
         o = mbs.invoke(serverEndpointName, "getDestinationSequenceIds", null, null);
-        verifyArray("Expected sequence identifier", o, new String[]{sseqId}); 
+        verifyArray("Expected sequence identifier", o, new String[]{sseqId}, false); 
         
         o = mbs.invoke(clientEndpointName, "getDestinationSequenceIds", null, null);
         assertTrue("One sequence expected", o instanceof String[] && 1 == ((String[])o).length);
@@ -170,7 +160,7 @@ public class ManagedEndpointsTest extend
 
         o = mbs.invoke(serverEndpointName, "getSourceSequenceIds", 
                        new Object[]{true}, new String[]{"boolean"});
-        verifyArray("Expected sequence identifier", o, new String[]{dseqId}); 
+        verifyArray("Expected sequence identifier", o, new String[]{dseqId}, false); 
         
         o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", 
                        new Object[]{true}, new String[]{"boolean"});
@@ -190,7 +180,7 @@ public class ManagedEndpointsTest extend
 
         o = mbs.invoke(clientEndpointName, "getSourceSequenceAcknowledgedRange", 
                        new Object[]{sseqId}, new String[]{"java.lang.String"});
-        verifyArray("Expected range", o, new Long[]{1L, 1L});
+        verifyArray("Expected range", o, new Long[]{1L, 1L}, true);
         
         o = mbs.invoke(clientEndpointName, "getUnAcknowledgedMessageIdentifiers", 
                        new Object[]{sseqId}, new String[]{"java.lang.String"});
@@ -205,7 +195,7 @@ public class ManagedEndpointsTest extend
 
         o = mbs.invoke(clientEndpointName, "getSourceSequenceAcknowledgedRange", 
                        new Object[]{sseqId}, new String[]{"java.lang.String"});
-        verifyArray("Expected range", o, new Long[]{1L, 1L, 3L, 3L});
+        verifyArray("Expected range", o, new Long[]{1L, 1L, 3L, 3L}, true);
         
         o = mbs.invoke(clientEndpointName, "getUnAcknowledgedMessageIdentifiers", 
                        new Object[]{sseqId}, new String[]{"java.lang.String"});
@@ -217,7 +207,7 @@ public class ManagedEndpointsTest extend
 
         o = mbs.invoke(serverEndpointName, "getDestinationSequenceAcknowledgedRange", 
                        new Object[]{sseqId}, new String[]{"java.lang.String"});
-        verifyArray("Expected range", o, new Long[]{1L, 1L, 3L, 3L});
+        verifyArray("Expected range", o, new Long[]{1L, 1L, 3L, 3L}, true);
 
         // 7 sec retry interval + 5 sec
         LOG.info("waiting for 12 secs for the retry to complete ...");
@@ -229,11 +219,11 @@ public class ManagedEndpointsTest extend
 
         o = mbs.invoke(clientEndpointName, "getSourceSequenceAcknowledgedRange", 
                        new Object[]{sseqId}, new String[]{"java.lang.String"});
-        verifyArray("Expected range", o, new Long[]{1L, 3L});
+        verifyArray("Expected range", o, new Long[]{1L, 3L}, true);
         
         o = mbs.invoke(serverEndpointName, "getDestinationSequenceAcknowledgedRange", 
                        new Object[]{sseqId}, new String[]{"java.lang.String"});
-        verifyArray("Expected range", o, new Long[]{1L, 3L});
+        verifyArray("Expected range", o, new Long[]{1L, 3L}, true);
 
         o = mbs.invoke(clientEndpointName, "getUnAcknowledgedMessageIdentifiers", 
                        new Object[]{sseqId}, new String[]{"java.lang.String"});
@@ -241,7 +231,7 @@ public class ManagedEndpointsTest extend
 
     }
     
-    //@Test
+    @Test
     public void testSuspendAndResumeSourceSequence() throws Exception {
         checkServerReady(30000);
         
@@ -326,12 +316,26 @@ public class ManagedEndpointsTest extend
         fail("server not ready");
     }
 
-    private <T> void verifyArray(String desc, Object value, T[] target) {
+    private <T> void verifyArray(String desc, Object value, T[] target, boolean exact)
{
         assertTrue(desc, target.getClass().isInstance(value));
         @SuppressWarnings("unchecked")
         T[] values = (T[])value;
+        if (exact) {
+            // exact-match
+            assertEquals(desc + " length", target.length, values.length);
+        } else {
+            // partial-match (the values must contain the target) 
+            assertTrue(desc + " length", target.length <= values.length);
+        }
+        int d = 0;
         for (int i = 0; i < target.length; i++) {
-            assertEquals(desc, target[i], values[i]);
+            while (!target[i].equals(values[i + d])) {
+                if (d >= values.length - target.length) {
+                    break;
+                }
+                d++;
+            }
+            assertEquals(desc, target[i], values[i + d]);
         }
     }
 



Mime
View raw message