cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r507867 [2/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/phase/ api/src/main/java/org/apache/cxf/ws/policy/ api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/ api/src/main/java/org/apache/cxf/ws/policy/builders/...
Date Thu, 15 Feb 2007 09:36:44 GMT
Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
Thu Feb 15 01:36:42 2007
@@ -22,19 +22,23 @@
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import junit.framework.TestCase;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.phase.PhaseInterceptor;
 import org.apache.cxf.service.model.BindingFaultInfo;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
 import org.apache.neethi.Policy;
 import org.apache.neethi.PolicyRegistry;
 import org.easymock.classextension.EasyMock;
@@ -54,17 +58,21 @@
     
     public void testAccessors() {
         engine = new PolicyEngine();
+        assertNull(engine.getBus());
         assertNull(engine.getPolicyProviders());
         assertNull(engine.getRegistry());
+        assertTrue(!engine.getRegisterInterceptors());
         Bus bus = control.createMock(Bus.class);
         engine.setBus(bus);
         List<PolicyProvider> providers = CastUtils.cast(Collections.EMPTY_LIST, PolicyProvider.class);
         engine.setPolicyProviders(providers);
         PolicyRegistry reg = control.createMock(PolicyRegistry.class);
         engine.setRegistry(reg);
+        engine.setRegisterInterceptors(true);
         assertSame(bus, engine.getBus());
         assertSame(providers, engine.getPolicyProviders());
         assertSame(reg, engine.getRegistry());
+        assertTrue(engine.getRegisterInterceptors());
     }
     
     public void testInit() {  
@@ -80,28 +88,58 @@
         control.verify();
     }
     
+    public void testDontAddBusInterceptors() {        
+        doTestAddBusInterceptors(false);
+    }
+    
     public void testAddBusInterceptors() {        
+        doTestAddBusInterceptors(true);
+    }
+    
+    private void doTestAddBusInterceptors(boolean add) {        
         engine = new PolicyEngine();
-        engine.addBusInterceptors();
-        
+        engine.setRegisterInterceptors(add);
+    
         Bus bus = control.createMock(Bus.class);
         engine.setBus(bus);
         List<Interceptor> out = new ArrayList<Interceptor>();
         List<Interceptor> in = new ArrayList<Interceptor>();
         List<Interceptor> inFault = new ArrayList<Interceptor>();
-        EasyMock.expect(bus.getOutInterceptors()).andReturn(out);
-        EasyMock.expect(bus.getInInterceptors()).andReturn(in);
-        EasyMock.expect(bus.getInFaultInterceptors()).andReturn(inFault);
+        List<Interceptor> outFault = new ArrayList<Interceptor>();
+        if (add) {
+            EasyMock.expect(bus.getOutInterceptors()).andReturn(out).times(2);
+            EasyMock.expect(bus.getInInterceptors()).andReturn(in).times(2);
+            EasyMock.expect(bus.getInFaultInterceptors()).andReturn(inFault);
+            EasyMock.expect(bus.getOutFaultInterceptors()).andReturn(outFault);
+            control.replay();
+        }
         
-        control.replay();
         engine.addBusInterceptors();
-        assertEquals(1, out.size());
-        assertTrue(out.get(0) instanceof ClientPolicyOutInterceptor);
-        assertEquals(1, in.size());
-        assertTrue(in.get(0) instanceof ClientPolicyInInterceptor);
-        assertEquals(1, inFault.size());
-        assertTrue(inFault.get(0) instanceof ClientPolicyInFaultInterceptor);
-        control.verify();
+        
+        if (add) {
+            Set<String> idsOut = getInterceptorIds(out);
+            Set<String> idsIn = getInterceptorIds(in);
+            Set<String> idsInFault = getInterceptorIds(inFault);
+            Set<String> idsOutFault = getInterceptorIds(outFault);
+            assertEquals(2, out.size());
+            assertTrue(idsOut.contains(PolicyConstants.CLIENT_POLICY_OUT_INTERCEPTOR_ID));
+            assertTrue(idsOut.contains(PolicyConstants.SERVER_POLICY_OUT_INTERCEPTOR_ID));
+            assertEquals(2, in.size());
+            assertTrue(idsIn.contains(PolicyConstants.CLIENT_POLICY_IN_INTERCEPTOR_ID));
+            assertTrue(idsIn.contains(PolicyConstants.SERVER_POLICY_IN_INTERCEPTOR_ID));
+            assertEquals(1, inFault.size());
+            assertTrue(idsInFault.contains(PolicyConstants.CLIENT_POLICY_IN_FAULT_INTERCEPTOR_ID));
+            assertEquals(1, outFault.size());
+            assertTrue(idsOutFault.contains(PolicyConstants.SERVER_POLICY_OUT_FAULT_INTERCEPTOR_ID));
+        } else {
+            assertEquals(0, out.size());
+            assertEquals(0, in.size());
+            assertEquals(0, inFault.size());
+            assertEquals(0, outFault.size());
+        }
+        if (add) {
+            control.verify();
+        }
     }
     
     public void testGetAggregatedServicePolicy() {
@@ -279,69 +317,113 @@
         control.verify();      
     }
     
-    public void testGetClientOutInterceptors() throws NoSuchMethodException { 
-        doTestGetClientInterceptors(true, false);                
+    public void testGetClientOutInterceptors() throws NoSuchMethodException {
+        Method m = PolicyEngine.class.getDeclaredMethod("getClientRequestPolicyInfo",
+                                                        new Class[] {BindingOperationInfo.class,
+                                                                     EndpointInfo.class,
Conduit.class});
+        engine = control.createMock(PolicyEngine.class, new Method[] {m});
+        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
+        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        Conduit conduit = control.createMock(Conduit.class);
+        ClientRequestPolicyInfo cpi = control.createMock(ClientRequestPolicyInfo.class);
+        EasyMock.expect(engine.getClientRequestPolicyInfo(boi, ei, conduit)).andReturn(cpi);
+        Interceptor i = control.createMock(Interceptor.class);
+        List<Interceptor> li = Collections.singletonList(i);
+        EasyMock.expect(cpi.getOutInterceptors()).andReturn(li);        
+
+        control.replay();
+        List<Interceptor> clientInterceptors = engine.getClientOutInterceptors(boi,
ei, conduit); 
+        assertSame(li, clientInterceptors);
+        control.verify();
     }
     
     public void testGetClientInInterceptors() throws NoSuchMethodException { 
-        doTestGetClientInterceptors(false, false);       
+        doTestGetInterceptors(false, false);
     }
     
     public void testGetClientInFaultInterceptors() throws NoSuchMethodException { 
-        doTestGetClientInterceptors(false, true);       
+        doTestGetInterceptors(false, true);
+    }
+    
+    public void testGetServerInFaultInterceptors() throws NoSuchMethodException { 
+        doTestGetInterceptors(true, false);
+    }
+    
+    public void testServerOutInterceptors() throws NoSuchMethodException {
+        doTestGetServerOutInterceptors(false);
     }
     
-    public void doTestGetClientInterceptors(boolean out, boolean fault) throws NoSuchMethodException
{ 
-        Method m = PolicyEngine.class.getDeclaredMethod("getClientPolicyInfo", 
-            new Class[] {BindingOperationInfo.class, EndpointInfo.class, Conduit.class});
+    public void testServerOutFaultInterceptors() throws NoSuchMethodException {
+        doTestGetServerOutInterceptors(true);
+    }
+     
+    private void doTestGetInterceptors(boolean isServer, boolean fault) throws NoSuchMethodException
{
+        Method m = PolicyEngine.class.getDeclaredMethod("getEndpointPolicyInfo",
+            new Class[] {EndpointInfo.class, isServer ? Destination.class : Conduit.class});
         engine = control.createMock(PolicyEngine.class, new Method[] {m});
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
         EndpointInfo ei = control.createMock(EndpointInfo.class);
-        Conduit conduit = control.createMock(Conduit.class);
+        Conduit conduit = null;
+        Destination destination = null;
+        EndpointPolicyInfo epi = control.createMock(EndpointPolicyInfo.class);
+        
+        if (isServer) {
+            destination = control.createMock(Destination.class);
+            EasyMock.expect(engine.getEndpointPolicyInfo(ei, destination)).andReturn(epi);
+        } else {
+            conduit = control.createMock(Conduit.class);
+            EasyMock.expect(engine.getEndpointPolicyInfo(ei, conduit)).andReturn(epi);
+        }
         
-        ClientPolicyInfo cpi = control.createMock(ClientPolicyInfo.class);
-        EasyMock.expect(engine.getClientPolicyInfo(boi, ei, conduit)).andReturn(cpi);
         Interceptor i = control.createMock(Interceptor.class);
         List<Interceptor> li = Collections.singletonList(i);
-        if (out) {
-            EasyMock.expect(cpi.getOutInterceptors()).andReturn(li);
+        if (fault) {
+            EasyMock.expect(epi.getInFaultInterceptors()).andReturn(li); 
         } else {
-            if (fault) {
-                EasyMock.expect(cpi.getInFaultInterceptors()).andReturn(li);
-            } else {
-                EasyMock.expect(cpi.getInInterceptors()).andReturn(li);
-            }
+            EasyMock.expect(epi.getInInterceptors()).andReturn(li);  
         }
-        
+
         control.replay();
-        List<Interceptor> clientInterceptors = out ? engine.getClientOutInterceptors(boi,
ei, conduit)
-            : (fault ? engine.getClientInFaultInterceptors(boi, ei, conduit) 
-                : engine.getClientInInterceptors(boi, ei, conduit));        
-        assertSame(li, clientInterceptors);        
-        control.verify();                
-    }
-    
-    public void xtestSupportsAlternative() {
-        doTestSupportsAlternative(true);
-    }    
-    
-    void doTestSupportsAlternative(boolean supported) {
-        /*
-        PolicyInterceptorProviderRegistry pipr = control.createMock(PolicyInterceptorProviderRegistry.class);
-        EasyMock.expect(bus.getExtension(PolicyInterceptorProviderRegistry.class)).andReturn(pipr);
-        Assertion a = control.createMock(Assertion.class);
-        List<Assertion> alternative = Collections.singletonList(a);
-        EasyMock.expect(a.isOptional()).andReturn(false);
-        QName qn = new QName("http://x.y.z", "a");
-        EasyMock.expect(a.getName()).andReturn(qn);
-        EasyMock.expect(pipr.get(qn)).andReturn(null);
-        AssertingConduit ac = control.createMock(AssertingConduit.class);
-        EasyMock.expect(ac.asserts(a)).andReturn(supported);
-                
+        List<Interceptor> interceptors = fault 
+            ? engine.getClientInFaultInterceptors(ei, conduit) 
+            : (isServer 
+                ? engine.getServerInInterceptors(ei, destination)
+                : engine.getClientInInterceptors(ei, conduit));
+        assertSame(li, interceptors);
+        control.verify(); 
+    }
+    
+    private void doTestGetServerOutInterceptors(boolean fault) throws NoSuchMethodException
{
+
+        Method m = PolicyEngine.class.getDeclaredMethod("getServerResponsePolicyInfo",
+                                                        new Class[] {BindingOperationInfo.class,
+                                                                     EndpointInfo.class,
Destination.class});
+        engine = control.createMock(PolicyEngine.class, new Method[] {m});
+        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
+        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        Destination destination = control.createMock(Destination.class);
+        ServerResponsePolicyInfo srpi = control.createMock(ServerResponsePolicyInfo.class);
+        EasyMock.expect(engine.getServerResponsePolicyInfo(boi, ei, destination)).andReturn(srpi);
+        Interceptor i = control.createMock(Interceptor.class);
+        List<Interceptor> li = Collections.singletonList(i);
+        if (fault) {
+            EasyMock.expect(srpi.getOutFaultInterceptors()).andReturn(li);
+        } else {
+            EasyMock.expect(srpi.getOutInterceptors()).andReturn(li);
+        }
+
         control.replay();
-        assertEquals(supported, engine.supportsAlternative(alternative, ac));
+        List<Interceptor> interceptors = fault ? engine.getServerOutFaultInterceptors(boi,
ei, destination)
+            : engine.getServerOutInterceptors(boi, ei, destination);
+        assertSame(li, interceptors);
         control.verify();
-        */
+    }
+    
+    private Set<String> getInterceptorIds(List<Interceptor> interceptors) {
+        Set<String> ids = new HashSet<String>();
+        for (Interceptor i : interceptors) {
+            ids.add(((PhaseInterceptor)i).getId());
+        }
+        return ids;
     }
     
     

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
Thu Feb 15 01:36:42 2007
@@ -31,6 +31,7 @@
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
 
@@ -46,6 +47,7 @@
     private Bus bus;
     private PolicyEngine pe;
     private Conduit conduit;
+    private Destination destination;
     
     
     public void setUp() {
@@ -57,10 +59,10 @@
         ClientPolicyOutInterceptor interceptor = new ClientPolicyOutInterceptor();
         interceptor.setBus(bus);
        
-        doTestBasics(interceptor);
+        doTestBasics(interceptor, true, true);
         
         control.reset();
-        setupMessage(true, true, true, true);
+        setupMessage(true, true, true, true, true, true);
         Interceptor i = control.createMock(Interceptor.class);
         EasyMock.expect(pe.getClientOutInterceptors(boi, ei, conduit))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
@@ -77,12 +79,12 @@
         ClientPolicyInInterceptor interceptor = new ClientPolicyInInterceptor();
         interceptor.setBus(bus);
         
-        doTestBasics(interceptor);
+        doTestBasics(interceptor, true, false);
         
         control.reset();
-        setupMessage(true, true, true, true);
+        setupMessage(true, true, false, false, true, true);
         Interceptor i = control.createMock(Interceptor.class);
-        EasyMock.expect(pe.getClientInInterceptors(boi, ei, conduit))
+        EasyMock.expect(pe.getClientInInterceptors(ei, conduit))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
@@ -97,12 +99,12 @@
         ClientPolicyInFaultInterceptor interceptor = new ClientPolicyInFaultInterceptor();
         interceptor.setBus(bus);
         
-        doTestBasics(interceptor);
+        doTestBasics(interceptor, true, false);
         
         control.reset();
-        setupMessage(true, true, true, true);
+        setupMessage(true, true, false, false, true, true);
         Interceptor i = control.createMock(Interceptor.class);
-        EasyMock.expect(pe.getClientInFaultInterceptors(boi, ei, conduit))
+        EasyMock.expect(pe.getClientInFaultInterceptors(ei, conduit))
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
@@ -113,50 +115,115 @@
         control.verify();        
     }
     
-    private void doTestBasics(Interceptor<Message> interceptor) {
-        setupMessage(false, false, false, false);
+    public void testServerPolicyInInterceptor() {
+        ServerPolicyInInterceptor interceptor = new ServerPolicyInInterceptor();
+        interceptor.setBus(bus);
+        
+        doTestBasics(interceptor, false, false);
+        
+        control.reset();
+        setupMessage(false, false, false, false, true, true);
+        Interceptor i = control.createMock(Interceptor.class);
+        EasyMock.expect(pe.getServerInInterceptors(ei, destination))
+            .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
+        InterceptorChain ic = control.createMock(InterceptorChain.class);
+        EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
+        ic.add(i);
+        EasyMock.expectLastCall();
+        control.replay();
+        interceptor.handleMessage(message);
+        control.verify();        
+    }
+    
+    public void testServerPolicyOutInterceptor() {
+        ServerPolicyOutInterceptor interceptor = new ServerPolicyOutInterceptor();
+        interceptor.setBus(bus);
+        
+        doTestBasics(interceptor, false, true);
+        
+        control.reset();
+        setupMessage(false, false, true, true, true, true);
+        Interceptor i = control.createMock(Interceptor.class);
+        EasyMock.expect(pe.getServerOutInterceptors(boi, ei, destination))
+            .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
+        InterceptorChain ic = control.createMock(InterceptorChain.class);
+        EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
+        ic.add(i);
+        EasyMock.expectLastCall();
+        control.replay();
+        interceptor.handleMessage(message);
+        control.verify();        
+    }
+    
+    public void testServerPolicyOutFaultInterceptor() {
+        ServerPolicyOutFaultInterceptor interceptor = new ServerPolicyOutFaultInterceptor();
+        interceptor.setBus(bus);
+        
+        doTestBasics(interceptor, false, true);
+        
+        control.reset();
+        setupMessage(false, false, true, true, true, true);
+        Interceptor i = control.createMock(Interceptor.class);
+        EasyMock.expect(pe.getServerOutFaultInterceptors(boi, ei, destination))
+            .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
+        InterceptorChain ic = control.createMock(InterceptorChain.class);
+        EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
+        ic.add(i);
+        EasyMock.expectLastCall();
+        control.replay();
+        interceptor.handleMessage(message);
+        control.verify();        
+    }
+    
+    private void doTestBasics(Interceptor<Message> interceptor, boolean isClient, boolean
usesOperationInfo) {
+        setupMessage(!isClient, isClient, usesOperationInfo, false, false, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
         
         control.reset();
-        setupMessage(true, false, false, false);
+        setupMessage(isClient, isClient, usesOperationInfo, !usesOperationInfo, false, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
         
         control.reset();
-        setupMessage(true, true, false, false);
+        setupMessage(true, isClient, usesOperationInfo, usesOperationInfo, false, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
             
         control.reset();
-        setupMessage(true, true, true, false);
+        setupMessage(true, isClient, usesOperationInfo, usesOperationInfo, true, false);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
     }
     
-    void setupMessage(boolean setupRequestor, 
+    void setupMessage(boolean setupRequestor,
+                      boolean isClient,
+                      boolean usesOperationInfo,
                       boolean setupOperation, 
-                      boolean setupEndpoint, 
-                      boolean setupEngine) {
+                      Boolean setupEndpoint, 
+                      Boolean setupEngine) {
+
         message = control.createMock(Message.class);
+        
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE))
             .andReturn(setupRequestor ? Boolean.TRUE : Boolean.FALSE);
-        if (!setupRequestor) {
+        if (setupRequestor != isClient) {
             return;
-        }        
-
-        if (null == boi) {
-            boi = control.createMock(BindingOperationInfo.class);
         }
-        EasyMock.expect(message.get(BindingOperationInfo.class)).andReturn(setupOperation
? boi : null);
-        if (!setupOperation) {
-            return;
+        if (usesOperationInfo) {
+            if (null == boi) {
+                boi = control.createMock(BindingOperationInfo.class);
+            }
+            EasyMock.expect(message.get(BindingOperationInfo.class)).andReturn(setupOperation
? boi : null);
+            if (!setupOperation) {
+                return;
+            }
         }
-               
+        
         if (null == ei) {
             ei = control.createMock(EndpointInfo.class);
         }
@@ -164,6 +231,7 @@
         if (!setupEndpoint) {
             return;
         }
+        
         if (null == pe) {
             pe = control.createMock(PolicyEngine.class);
         }
@@ -172,10 +240,13 @@
             return;
         }
             
-        if (null == conduit) {
+        if (isClient) {
             conduit = control.createMock(Conduit.class);
+            EasyMock.expect(message.getConduit()).andReturn(conduit);
+        } else {
+            destination = control.createMock(Destination.class);
+            EasyMock.expect(message.getDestination()).andReturn(destination);
         }
-        EasyMock.expect(message.getConduit()).andReturn(conduit);
       
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java
Thu Feb 15 01:36:42 2007
@@ -24,7 +24,9 @@
 import junit.framework.TestCase;
 
 import org.apache.cxf.ws.policy.builders.primitive.PrimitiveAssertion;
+import org.apache.neethi.All;
 import org.apache.neethi.Assertion;
+import org.apache.neethi.ExactlyOne;
 import org.apache.neethi.Policy;
 
 /**
@@ -81,7 +83,45 @@
         p = getTwoOptionalAssertions();
         doNormalise(p, true);
      
-    }   
+    }  
+    
+    public void xtestMergePolciesWithAlternatives() {
+        String uri1 = "http://x.y.z";
+        Policy p1 = new Policy();
+        ExactlyOne ea = new ExactlyOne();
+        p1.addPolicyComponent(ea);
+        All all = new All();
+        ea.addPolicyComponent(all);
+        all.addPolicyComponent(new PrimitiveAssertion(new QName(uri1, "a1")));
+        all = new All();
+        ea.addPolicyComponent(all);
+        all.addPolicyComponent(new PrimitiveAssertion(new QName(uri1, "a2")));
+        
+        String uri2 = "http://a.b.c";
+        Policy p2 = new Policy();
+        ea = new ExactlyOne();
+        p2.addPolicyComponent(ea);
+        all = new All();
+        ea.addPolicyComponent(all);
+        all.addPolicyComponent(new PrimitiveAssertion(new QName(uri2, "x1")));
+        all = new All();
+        ea.addPolicyComponent(all);
+        all.addPolicyComponent(new PrimitiveAssertion(new QName(uri2, "x2")));
+        
+        System.out.println("p1:");
+        PolicyUtils.printPolicyComponent(p1);
+        System.out.println();
+        System.out.println("p2:");
+        PolicyUtils.printPolicyComponent(p1);
+        System.out.println();
+        Policy p = p1.merge(p2);
+        System.out.println("p1 merge p2:");
+        PolicyUtils.printPolicyComponent(p);
+        System.out.println();
+        System.out.println("normalised merge:");
+        PolicyUtils.printPolicyComponent(p.normalize(true));
+        System.out.println();
+    }
     
     Policy getOneAssertion() {
         String uri = "http://www.w3.org/2007/01/addressing/metadata";

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/GreeterImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/GreeterImpl.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/GreeterImpl.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/GreeterImpl.java
Thu Feb 15 01:36:42 2007
@@ -28,6 +28,7 @@
 
 import org.apache.cxf.greeter_control.Greeter;
 import org.apache.cxf.greeter_control.PingMeFault;
+import org.apache.cxf.greeter_control.types.FaultDetail;
 import org.apache.cxf.greeter_control.types.GreetMeResponse;
 import org.apache.cxf.greeter_control.types.PingMeResponse;
 import org.apache.cxf.greeter_control.types.SayHiResponse;
@@ -45,6 +46,7 @@
     private static final Logger LOG = Logger.getLogger(GreeterImpl.class.getName());
     private long delay;
     private String lastOnewayArg;
+    private int pingMeCount;
      
     public long getDelay() {
         return delay;
@@ -89,7 +91,16 @@
     }
 
     public void pingMe() throws PingMeFault {
-        LOG.fine("Executing operation pingMe");        
+        pingMeCount++;
+        if ((pingMeCount % 2) > 0) {
+            LOG.fine("Executing operation pingMe");        
+        } else {
+            LOG.fine("Throwing PingMeFault while executiong operation pingMe");
+            FaultDetail fd = new FaultDetail();
+            fd.setMajor((short)2);
+            fd.setMinor((short)1);
+            throw new PingMeFault("Pings succeed only every other time.", fd);
+        }
     }
 
     public Response<PingMeResponse> pingMeAsync() {



Mime
View raw message