cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r489568 - in /incubator/cxf/trunk/api/src: main/java/org/apache/cxf/phase/PhaseInterceptorChain.java test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
Date Fri, 22 Dec 2006 07:03:29 GMT
Author: jliu
Date: Thu Dec 21 23:03:28 2006
New Revision: 489568

URL: http://svn.apache.org/viewvc?view=rev&rev=489568
Log:
Apply patch cxf-320 on behalf of Unreal Jiang.  If add a user interceptor into pre_stream
phase and addBefore to SoapPreProtocolOutInterceptor, cxf will throw out "Invalid ordering"
exception

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java?view=diff&rev=489568&r1=489567&r2=489568
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
Thu Dec 21 23:03:28 2006
@@ -270,9 +270,9 @@
     public ListIterator<Interceptor<? extends Message>> getIterator() {
         return new PhaseInterceptorIterator();
     }
-    
 
     protected void insertInterceptor(List<Interceptor> intercs, PhaseInterceptor interc)
{
+
         if (intercs.size() == 0) {
             intercs.add(interc);
             return;
@@ -294,9 +294,15 @@
             if (before.contains(cmp.getId()) && i < end) {
                 end = i;
             }
-
             if (cmp.getBefore().contains(interc.getId()) && i > begin) {
                 begin = i;
+                if (end < begin) {
+                    intercs.remove(cmp);
+                    intercs.add(end, cmp);
+                    i = end;
+                    begin = end;
+                    end = begin + 1;
+                }
             }
 
             if (after.contains(cmp.getId()) && i > begin) {
@@ -313,6 +319,7 @@
         }
 
         intercs.add(begin + 1, interc);
+        
     }
 
     void outputChainToLog(boolean modified) {

Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java?view=diff&rev=489568&r1=489567&r2=489568
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
(original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/phase/PhaseInterceptorChainTest.java
Thu Dec 21 23:03:28 2006
@@ -85,6 +85,41 @@
         assertSame("Unexpected interceptor at this position.", p2, it.next());
         assertTrue(!it.hasNext());
     }
+    
+    AbstractPhaseInterceptor setUpPhaseInterceptor(String phase, String id,
+                                                   Set<String> b, boolean be) {
+        AbstractPhaseInterceptor p = control
+            .createMock(AbstractPhaseInterceptor.class);
+        EasyMock.expect(p.getPhase()).andReturn(phase).anyTimes();
+        EasyMock.expect(p.getId()).andReturn(id).anyTimes();
+        Set<String> after = new HashSet<String>();
+        Set<String> before = null == b ? new HashSet<String>() : b;
+        EasyMock.expect(p.getBefore()).andReturn(before).anyTimes();
+        EasyMock.expect(p.getAfter()).andReturn(after).anyTimes();
+
+        return p;
+    }
+    
+    public void testThreeInterceptorSamePhaseWithOrder() {
+        AbstractPhaseInterceptor p1 = setUpPhaseInterceptor("phase1", "p1");
+        Set<String> before = new HashSet<String>();
+        before.add("p1");
+        AbstractPhaseInterceptor p2 = setUpPhaseInterceptor("phase1", "p2", before, true);
+        Set<String> before1 = new HashSet<String>();
+        before1.add("p2");
+        AbstractPhaseInterceptor p3 = setUpPhaseInterceptor("phase1", "p3", before1, true);
+        control.replay();
+        chain.add(p3);
+        chain.add(p1);
+        chain.add(p2);
+        
+        Iterator<Interceptor<? extends Message>> it = chain.iterator();
+
+        assertSame("Unexpected interceptor at this position.", p3, it.next());
+        assertSame("Unexpected interceptor at this position.", p2, it.next());
+        assertSame("Unexpected interceptor at this position.", p1, it.next());
+        assertTrue(!it.hasNext());
+    }
 
     public void testSingleInterceptorPass() {
         AbstractPhaseInterceptor p = setUpPhaseInterceptor("phase1", "p1");
@@ -298,7 +333,7 @@
 
         return p;
     }
-
+    
     @SuppressWarnings("unchecked")
     void setUpPhaseInterceptorInvocations(AbstractPhaseInterceptor p,
             boolean fail, boolean expectFault) {



Mime
View raw message