ws-wss4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r783287 - in /webservices/wss4j/trunk: src/org/apache/ws/security/handler/WSHandler.java test/wssec/TestWSSecurityResultsOrder.java
Date Wed, 10 Jun 2009 11:02:56 GMT
Author: coheigea
Date: Wed Jun 10 11:02:56 2009
New Revision: 783287

URL: http://svn.apache.org/viewvc?rev=783287&view=rev
Log:
[WSS-147] - Fixed a bug with checkReceiverResultsAnyOrder and added a test.

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityResultsOrder.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java?rev=783287&r1=783286&r2=783287&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/handler/WSHandler.java Wed Jun 10 11:02:56
2009
@@ -298,7 +298,12 @@
     
     protected boolean checkReceiverResultsAnyOrder(List wsResult, List actions) {
         
-        int ai = 0;
+        List recordedActions = new Vector(actions.size());
+        for (int i = 0; i < actions.size(); i++) {
+            Integer action = (Integer)actions.get(i);
+            recordedActions.add(action);
+        }
+        
         for (int i = 0; i < wsResult.size(); i++) {
             final Integer actInt = (Integer) ((WSSecurityEngineResult) wsResult
                     .get(i)).get(WSSecurityEngineResult.TAG_ACTION);
@@ -307,13 +312,12 @@
                 continue;
             }
             
-            if (actions.indexOf(actInt) == -1) {
+            if (!recordedActions.remove(actInt)) {
                 return false;
             }
-            ai++;
         }
 
-        if (ai != actions.size()) {
+        if (!recordedActions.isEmpty()) {
             return false;
         }
 

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityResultsOrder.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityResultsOrder.java?rev=783287&r1=783286&r2=783287&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityResultsOrder.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityResultsOrder.java Wed Jun 10 11:02:56
2009
@@ -108,6 +108,7 @@
         
         assertFalse (handler.checkResults(results, actions));
         assertTrue (handler.checkResultsAnyOrder(results, actions));
+        assertTrue (results.size() == 4 && actions.size() == 3);
     }
     
     /**
@@ -255,4 +256,30 @@
         assertFalse (handler.checkResultsAnyOrder(results, actions));
     }
     
+    /**
+     */
+    public void 
+    testMultipleIdenticalResults() throws Exception {
+        MyHandler handler = new MyHandler();
+        
+        java.util.List results = new java.util.Vector();
+        results.add(
+            new WSSecurityEngineResult(WSConstants.ENCR, (Object)null)
+        );
+        results.add(
+            new WSSecurityEngineResult(WSConstants.UT, (Object)null)
+        );
+        results.add(
+            new WSSecurityEngineResult(WSConstants.ENCR, (Object)null)
+        );
+        
+        java.util.List actions = new java.util.Vector();
+        actions.add(new Integer(WSConstants.ENCR));
+        actions.add(new Integer(WSConstants.UT));
+        actions.add(new Integer(WSConstants.UT));
+        
+        assertFalse (handler.checkResults(results, actions));
+        assertFalse (handler.checkResultsAnyOrder(results, actions));
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org


Mime
View raw message