cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r521646 [2/2] - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/endpoint/ core/src/main/java/org/apache/cxf/service/ frontend/simple/src/main/java/org/apache/cxf/service/factory/ ws/rm/ ws/rm/src/main/java/org/apache/cxf/ws/rm...
Date Fri, 23 Mar 2007 09:37:34 GMT
Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMContextUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMContextUtilsTest.java?view=auto&rev=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMContextUtilsTest.java
(added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMContextUtilsTest.java
Fri Mar 23 02:37:32 2007
@@ -0,0 +1,188 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.ws.addressing.AddressingProperties;
+import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
+import org.apache.cxf.ws.addressing.JAXWSAConstants;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class RMContextUtilsTest extends TestCase {
+    
+    private IMocksControl control;
+    
+    @Before
+    public void setUp() {
+        control = EasyMock.createNiceControl();
+    }
+    
+    @After
+    public void tearDown() {
+        control.verify();
+    }
+    
+    @Test
+    public void testCtor() {
+        control.replay();
+        assertNotNull(new RMContextUtils());
+    }
+    
+    @Test
+    public void testGenerateUUID() {
+        control.replay();
+        assertNotNull(RMContextUtils.generateUUID());
+    }
+    
+    @Test
+    public void testIsOutbound() {
+        Message msg = control.createMock(Message.class); 
+        Exchange ex = control.createMock(Exchange.class);
+        EasyMock.expect(msg.getExchange()).andReturn(ex);
+        EasyMock.expect(ex.getOutMessage()).andReturn(null);
+        EasyMock.expect(ex.getOutFaultMessage()).andReturn(null);
+        control.replay();
+        assertTrue(!RMContextUtils.isOutbound(msg));
+    }
+    
+    @Test
+    public void testIsRequestor() {
+        Message msg = control.createMock(Message.class); 
+        EasyMock.expect(msg.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE);
+        control.replay();
+        assertTrue(RMContextUtils.isRequestor(msg));
+    }
+    
+    @Test
+    public void testIsServerSide() {
+        Message msg = control.createMock(Message.class); 
+        Exchange ex = control.createMock(Exchange.class);
+        EasyMock.expect(msg.getExchange()).andReturn(ex);
+        EasyMock.expect(ex.getDestination()).andReturn(null);
+        control.replay();
+        assertTrue(!RMContextUtils.isServerSide(msg));
+    }
+    
+    @Test
+    public void testIsPartialResponse() {
+        Message msg = control.createMock(Message.class); 
+        Exchange ex = control.createMock(Exchange.class);
+        EasyMock.expect(msg.getExchange()).andReturn(ex).times(2);
+        EasyMock.expect(ex.getOutMessage()).andReturn(msg);
+        EasyMock.expect(msg.getContent(List.class)).andReturn(null);
+        EasyMock.expect(ex.getOutFaultMessage()).andReturn(null);
+        EasyMock.expect(ex.getInFaultMessage()).andReturn(null);
+        control.replay();
+        assertTrue(RMContextUtils.isPartialResponse(msg));
+    }
+    
+    @Test
+    public void testIsApplicationMessage() {
+        control.replay();
+        String action = null;
+        assertTrue(RMContextUtils.isAplicationMessage(action));
+        action = "";
+        assertTrue(RMContextUtils.isAplicationMessage(action));
+        action = "greetMe";
+        assertTrue(RMContextUtils.isAplicationMessage(action));
+        action = RMConstants.getCreateSequenceAction();
+        assertTrue(!RMContextUtils.isAplicationMessage(action));        
+    }
+    
+    @Test
+    public void testRetrieveOutboundRMProperties() {
+        Message msg = control.createMock(Message.class);
+        RMProperties rmps = control.createMock(RMProperties.class);
+        EasyMock.expect(msg.get(RMMessageConstants.RM_PROPERTIES_OUTBOUND)).andReturn(rmps);
+        control.replay();
+        assertSame(rmps, RMContextUtils.retrieveRMProperties(msg, true));        
+    }
+    
+    @Test
+    public void testRetrieveInboundRMPropertiesFromOutboundMessage() {
+        Message outMsg = control.createMock(Message.class);
+        Exchange ex = control.createMock(Exchange.class);
+        EasyMock.expect(outMsg.getExchange()).andReturn(ex).times(3);
+        EasyMock.expect(ex.getOutMessage()).andReturn(outMsg);
+        Message inMsg = control.createMock(Message.class);
+        EasyMock.expect(ex.getInMessage()).andReturn(null);
+        EasyMock.expect(ex.getInFaultMessage()).andReturn(inMsg);
+        RMProperties rmps = control.createMock(RMProperties.class);
+        EasyMock.expect(inMsg.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
+        control.replay();
+        assertSame(rmps, RMContextUtils.retrieveRMProperties(outMsg, false));        
+    }
+    
+    @Test
+    public void testRetrieveInboundRMPropertiesFromInboundMessage() {
+        Message inMsg = control.createMock(Message.class);
+        Exchange ex = control.createMock(Exchange.class);
+        EasyMock.expect(inMsg.getExchange()).andReturn(ex);
+        EasyMock.expect(ex.getOutMessage()).andReturn(null);
+        EasyMock.expect(ex.getOutFaultMessage()).andReturn(null);
+        RMProperties rmps = control.createMock(RMProperties.class);
+        EasyMock.expect(inMsg.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
+        control.replay();
+        assertSame(rmps, RMContextUtils.retrieveRMProperties(inMsg, false));        
+    }
+    
+    @Test
+    public void testStoreRMProperties() {
+        Message msg = control.createMock(Message.class);
+        RMProperties rmps = control.createMock(RMProperties.class);
+        EasyMock.expect(msg.put(RMMessageConstants.RM_PROPERTIES_INBOUND, rmps)).andReturn(null);
+        control.replay();
+        RMContextUtils.storeRMProperties(msg, rmps, false);
+    }
+    
+    @Test
+    public void testRetrieveMAPs() {
+        Message msg = control.createMock(Message.class);
+        EasyMock.expect(msg.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE);
+        AddressingPropertiesImpl maps = control.createMock(AddressingPropertiesImpl.class);
+        EasyMock.expect(msg.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND)).andReturn(maps);
+        control.replay();
+        assertSame(maps, RMContextUtils.retrieveMAPs(msg, false, true));     
+    }
+    
+    @Test
+    public void testStoreMAPs() {
+        Message msg = control.createMock(Message.class);
+        AddressingProperties maps = control.createMock(AddressingProperties.class);
+        EasyMock.expect(msg.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, maps)).andReturn(null);
+        control.replay();
+        RMContextUtils.storeMAPs(maps, msg, true, true);
+    }
+    
+    
+    
+
+}

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMContextUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMContextUtilsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java Fri
Mar 23 02:37:32 2007
@@ -19,39 +19,229 @@
 
 package org.apache.cxf.ws.rm;
 
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+
 import javax.xml.namespace.QName;
 
 import junit.framework.TestCase;
-
+import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.ws.policy.EndpointPolicyInfo;
+import org.apache.cxf.ws.policy.OutPolicyInfo;
+import org.apache.cxf.ws.policy.PolicyEngine;
+import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 public class RMEndpointTest extends TestCase {
     
     private IMocksControl control;
+    private RMManager manager;
+    private Endpoint ae;
+    private RMEndpoint rme;
     
+    @Before
     public void setUp() {
         control = EasyMock.createNiceControl();
+        manager = control.createMock(RMManager.class);
+        ae = control.createMock(Endpoint.class);
+        rme = new RMEndpoint(manager, ae);
     }
     
+    @After
     public void tearDown() {
         control.verify();
     }
-      
-    public void testCreateService() throws NoSuchMethodException {
-        Service appService = control.createMock(Service.class);
-        Endpoint appEndpoint = control.createMock(Endpoint.class);
-        EasyMock.expect(appEndpoint.getService()).andReturn(appService);
+    
+    @Test
+    public void testConstructor() {
+        control.replay();
+        assertNotNull(rme);
+        assertNull(rme.getEndpoint());
+        assertNull(rme.getService());
+        assertNull(rme.getConduit());
+        assertNull(rme.getReplyTo());
+    }
+    
+    @Test
+    public void testGetName() {
+        EndpointInfo aei = control.createMock(EndpointInfo.class);        
+        EasyMock.expect(ae.getEndpointInfo()).andReturn(aei);
+        QName qn = new QName("cxf");
+        EasyMock.expect(aei.getName()).andReturn(qn);
+        control.replay();
+        assertSame(qn, rme.getName());
+    }
+    
+    @Test
+    public void testGetManager() {
+        control.replay();
+        assertSame(manager, rme.getManager());
+    }
+    
+    @Test
+    public void testGetApplicationEndpoint() {
+        control.replay();
+        assertSame(ae, rme.getApplicationEndpoint());
+    }
+    
+    @Test
+    public void testGetProxy() {
+        control.replay();
+        assertSame(rme, rme.getProxy().getReliableEndpoint());
+    }
+    
+    @Test
+    public void testGetServant() {
+        control.replay();
+        assertNotNull(rme.getServant());
+    }
+    
+    @Test
+    public void testGetSetDestination() {
+        Destination d = control.createMock(Destination.class);
         control.replay();
+        assertSame(rme, rme.getDestination().getReliableEndpoint());
+        rme.setDestination(d);
+        assertSame(d, rme.getDestination());        
+    }
+    
+    @Test
+    public void testGetSetSource() {
+        Source s = control.createMock(Source.class);
+        control.replay();
+        assertSame(rme, rme.getSource().getReliableEndpoint());
+        rme.setSource(s);
+        assertSame(s, rme.getSource());        
+    }
+    
+    @Test
+    public void testInitialise() throws NoSuchMethodException {
+        Method m1 = RMEndpoint.class.getDeclaredMethod("createService", new Class[] {});
+        Method m2 = RMEndpoint.class.getDeclaredMethod("createEndpoint", new Class[] {});
+        Method m3 = RMEndpoint.class.getDeclaredMethod("setPolicies", new Class[] {});
         
-        RMEndpoint rme = new RMEndpoint(null, appEndpoint);
+        rme = control.createMock(RMEndpoint.class, new Method[] {m1, m2, m3});
         rme.createService();
-        
+        EasyMock.expectLastCall();
+        rme.createEndpoint();
+        EasyMock.expectLastCall();
+        rme.setPolicies();
+        EasyMock.expectLastCall();
+        Conduit c = control.createMock(Conduit.class);
+        org.apache.cxf.ws.addressing.EndpointReferenceType epr = 
+            control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
       
+        control.replay();
+        rme.initialise(c, epr);
+        assertSame(c, rme.getConduit());
+        assertSame(epr, rme.getReplyTo());  
+    }
+    
+    @Test
+    public void testCreateService() {
+        Service as = control.createMock(Service.class);
+        EasyMock.expect(ae.getService()).andReturn(as);
+        control.replay();
+        rme.createService();
+        Service s = rme.getService();
+        assertNotNull(s);
+        WrappedService ws = (WrappedService)s;
+        assertSame(as, ws.getWrappedService());
+        assertSame(rme.getServant(), s.getInvoker());
+        verifyService();
+    }
+    
+    @Test
+    public void testCreateEndpoint() throws NoSuchMethodException {
+        Method m = RMEndpoint.class.getDeclaredMethod("getUsingAddressing", new Class[] {EndpointInfo.class});
+        rme = control.createMock(RMEndpoint.class, new Method[] {m});
+        rme.setAplicationEndpoint(ae);
+        rme.setManager(manager);  
+        Service as = control.createMock(Service.class);
+        EasyMock.expect(ae.getService()).andReturn(as);
+        EndpointInfo aei = control.createMock(EndpointInfo.class);
+        EasyMock.expect(ae.getEndpointInfo()).andReturn(aei).times(2);
+        BindingInfo bi = control.createMock(BindingInfo.class);
+        EasyMock.expect(aei.getBinding()).andReturn(bi);
+        String ns = "http://schemas.xmlsoap.org/wsdl/soap/";
+        EasyMock.expect(bi.getBindingId()).andReturn(ns);
+        EasyMock.expect(aei.getTransportId()).andReturn(ns);
+        String addr = "addr";
+        EasyMock.expect(aei.getAddress()).andReturn(addr);
+        Object ua = new Object();
+        EasyMock.expect(rme.getUsingAddressing(aei)).andReturn(ua);
+        control.replay();
+        rme.createService();
+        rme.createEndpoint();
+        Endpoint e = rme.getEndpoint();
+        WrappedEndpoint we = (WrappedEndpoint)e;
+        assertSame(ae, we.getWrappedEndpoint());  
+        Service s = rme.getService();
+        assertEquals(1, s.getEndpoints().size());
+        assertSame(e, s.getEndpoints().get(new QName(RMConstants.getWsdlNamespace(), 
+                                                     "SequenceAbstractSoapPort")));   
+    }
+    
+    @Test
+    public void testSetPolicies() throws NoSuchMethodException {
+        Method m = RMEndpoint.class.getDeclaredMethod("getEndpoint", new Class[] {});
+        rme = control.createMock(RMEndpoint.class, new Method[] {m});
+        rme.setAplicationEndpoint(ae);
+        rme.setManager(manager);
+        Endpoint e = control.createMock(Endpoint.class);
+        EasyMock.expect(rme.getEndpoint()).andReturn(e);
+        Bus bus = control.createMock(Bus.class);
+        EasyMock.expect(manager.getBus()).andReturn(bus);
+        PolicyEngine pe = control.createMock(PolicyEngine.class);
+        EasyMock.expect(bus.getExtension(PolicyEngine.class)).andReturn(pe);
+        EndpointPolicyInfo epi = control.createMock(EndpointPolicyInfo.class);
+        EasyMock.expect(pe.getEndpointPolicyInfo(ae, (Conduit)null)).andReturn(epi);
+        Policy policy = new Policy();
+        EasyMock.expect(epi.getPolicy()).andReturn(policy);
+        EasyMock.expect(epi.getChosenAlternative()).andReturn(new ArrayList<Assertion>());
+        EasyMock.expect(pe.getBus()).andReturn(bus);
+        PolicyInterceptorProviderRegistry reg = control.createMock(PolicyInterceptorProviderRegistry.class);
+        EasyMock.expect(bus.getExtension(PolicyInterceptorProviderRegistry.class)).andReturn(reg);
+        pe.setEndpointPolicyInfo(e, epi);
+        EasyMock.expectLastCall();
+        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EasyMock.expect(e.getEndpointInfo()).andReturn(ei);
+        BindingInfo bi = control.createMock(BindingInfo.class);
+        EasyMock.expect(ei.getBinding()).andReturn(bi);
+        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
+        EasyMock.expect(bi.getOperations()).andReturn(Collections.singletonList(boi));
+        pe.setServerRequestPolicyInfo(EasyMock.eq(e), EasyMock.eq(boi), 
+                                      EasyMock.isA(OutPolicyInfo.class));
+        EasyMock.expectLastCall();
+        pe.setServerResponsePolicyInfo(EasyMock.eq(e), EasyMock.eq(boi), 
+                                      EasyMock.isA(OutPolicyInfo.class));
+        EasyMock.expectLastCall();
+        pe.setClientRequestPolicyInfo(EasyMock.eq(e), EasyMock.eq(boi), 
+                                      EasyMock.isA(OutPolicyInfo.class));
+        EasyMock.expectLastCall();
+        pe.setClientResponsePolicyInfo(EasyMock.eq(e), EasyMock.eq(boi), 
+                                      EasyMock.isA(OutPolicyInfo.class));
+        EasyMock.expectLastCall();
+        control.replay();
+        rme.setPolicies();
+    }
+       
+    private void verifyService() {        
         Service service = rme.getService();
         ServiceInfo si = service.getServiceInfo();
         assertNotNull("service info is null", si);

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
Fri Mar 23 02:37:32 2007
@@ -19,19 +19,47 @@
 
 package org.apache.cxf.ws.rm;
 
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 
 import junit.framework.TestCase;
-
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseInterceptorChain;
+import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.JAXWSAConstants;
 import org.apache.cxf.ws.addressing.MAPAggregator;
+import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 public class RMInInterceptorTest extends TestCase {
     
+    private IMocksControl control;
+    private RMProperties rmps;
+    
+    @Before
+    public void setUp() {
+        control = EasyMock.createNiceControl();
+        rmps = control.createMock(RMProperties.class);
+    }
+
+    @After
+    public void tearDown() {
+        control.verify();
+    }
     
+    @Test
     public void testOrdering() {
+        control.replay();
         Phase p = new Phase(Phase.PRE_LOGICAL, 1);
         PhaseInterceptorChain chain = 
             new PhaseInterceptorChain(Collections.singletonList(p));
@@ -42,6 +70,203 @@
         Iterator it = chain.iterator();
         assertSame("Unexpected order.", rmi, it.next());
         assertSame("Unexpected order.", map, it.next());
-                              
     } 
+    
+    
+    @Test
+    public void testHandleCreateSequenceOnServer() throws SequenceFault {
+        RMInInterceptor interceptor = new RMInInterceptor();         
+        Message message = setupInboundMessage(RMConstants.getCreateSequenceAction(), true);
  
+        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
+        
+        control.replay();
+        interceptor.handle(message);
+    }
+    
+    @Test
+    public void testHandleCreateSequenceOnClient() throws SequenceFault {
+        RMInInterceptor interceptor = new RMInInterceptor();         
+        Message message = setupInboundMessage(RMConstants.getCreateSequenceAction(), false);
      
+        RMManager manager = control.createMock(RMManager.class);
+        interceptor.setManager(manager);
+        RMEndpoint rme = control.createMock(RMEndpoint.class);
+        EasyMock.expect(manager.getReliableEndpoint(message)).andReturn(rme);
+        Servant servant = control.createMock(Servant.class);
+        EasyMock.expect(rme.getServant()).andReturn(servant);
+        CreateSequenceResponseType csr = control.createMock(CreateSequenceResponseType.class);
+        EasyMock.expect(servant.createSequence(message)).andReturn(csr);
+        Proxy proxy = control.createMock(Proxy.class);
+        EasyMock.expect(rme.getProxy()).andReturn(proxy);
+        proxy.createSequenceResponse(csr);
+        EasyMock.expectLastCall();
+        
+        control.replay();
+        interceptor.handle(message);
+    }
+    
+    @Test
+    public void testHandleSequenceAckOnClient() throws SequenceFault, NoSuchMethodException
{
+        testHandleSequenceAck(false);
+    }
+    
+    @Test
+    public void testHandleSequenceAckOnServer() throws SequenceFault, NoSuchMethodException
{
+        testHandleSequenceAck(true);
+    }
+    
+    private void testHandleSequenceAck(boolean onServer) throws SequenceFault, NoSuchMethodException
{
+        Method m = RMInInterceptor.class.getDeclaredMethod("processAcknowledgments",
+            new Class[] {RMProperties.class});
+        RMInInterceptor interceptor = control.createMock(RMInInterceptor.class, new Method[]
{m});
+        Message message = setupInboundMessage(RMConstants.getSequenceAckAction(), onServer);
+        interceptor.processAcknowledgments(rmps);
+        EasyMock.expectLastCall();
+        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
+
+        control.replay();
+        interceptor.handle(message);
+    }
+    
+    @Test
+    public void testHandleTerminateSequenceOnServer() throws SequenceFault {
+        testHandleTerminateSequence(true);        
+    }
+    
+    @Test
+    public void testHandleTerminateSequenceOnClient() throws SequenceFault {
+        testHandleTerminateSequence(false);        
+    }
+    
+    private void testHandleTerminateSequence(boolean onServer) throws SequenceFault {
+        RMInInterceptor interceptor = new RMInInterceptor();
+        Message message = setupInboundMessage(RMConstants.getTerminateSequenceAction(), onServer);
+        EasyMock.expectLastCall();
+        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
+
+        control.replay();
+        interceptor.handle(message);
+    }
+    
+    @Test
+    public void testAppRequest() throws SequenceFault, NoSuchMethodException {
+        testAppMessage(true);
+    }
+    
+    @Test
+    public void testAppResponse() throws SequenceFault, NoSuchMethodException {
+        testAppMessage(false);
+    }
+    
+    private void testAppMessage(boolean onServer) throws SequenceFault, NoSuchMethodException
{
+        Method m1 = RMInInterceptor.class.getDeclaredMethod("processAcknowledgments",
+                                                            new Class[] {RMProperties.class});
+        Method m2 = RMInInterceptor.class.getDeclaredMethod("processAcknowledgmentRequests",
+                                                            new Class[] {RMProperties.class});
+        Method m3 = RMInInterceptor.class.getDeclaredMethod("processSequence",
+                                                            new Class[] {Destination.class,
Message.class});
+        Method m4 = RMInInterceptor.class.getDeclaredMethod("processDeliveryAssurance",
+                                                            new Class[] {RMProperties.class});
+        RMInInterceptor interceptor = control
+            .createMock(RMInInterceptor.class, new Method[] {m1, m2, m3, m4});
+        Message message = setupInboundMessage("greetMe", true);
+        RMManager manager = control.createMock(RMManager.class);
+        interceptor.setManager(manager);
+        Destination d = control.createMock(Destination.class);
+        EasyMock.expect(manager.getDestination(message)).andReturn(d);
+        interceptor.processAcknowledgments(rmps);
+        EasyMock.expectLastCall();
+        interceptor.processAcknowledgmentRequests(rmps);
+        EasyMock.expectLastCall();
+        interceptor.processSequence(d, message);
+        EasyMock.expectLastCall();
+        interceptor.processDeliveryAssurance(rmps);
+        EasyMock.expectLastCall();
+        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
+
+        control.replay();
+        interceptor.handle(message);
+    }  
+    
+    @Test
+    public void testProcessAcknowledgments() {
+        RMInInterceptor interceptor = new RMInInterceptor();
+        RMManager manager = control.createMock(RMManager.class);
+        interceptor.setManager(manager);
+        SequenceAcknowledgement ack1 = control.createMock(SequenceAcknowledgement.class);
+        SequenceAcknowledgement ack2 = control.createMock(SequenceAcknowledgement.class);
+        Collection<SequenceAcknowledgement> acks = new ArrayList<SequenceAcknowledgement>();
+        acks.add(ack1);
+        acks.add(ack2);
+        EasyMock.expect(rmps.getAcks()).andReturn(acks);
+        Identifier id1 = control.createMock(Identifier.class);
+        EasyMock.expect(ack1.getIdentifier()).andReturn(id1);
+        SourceSequence ss1 = control.createMock(SourceSequence.class);
+        EasyMock.expect(manager.getSourceSequence(id1)).andReturn(ss1);
+        ss1.setAcknowledged(ack1);
+        EasyMock.expectLastCall();
+        Identifier id2 = control.createMock(Identifier.class);
+        EasyMock.expect(ack2.getIdentifier()).andReturn(id2);
+        EasyMock.expect(manager.getSourceSequence(id2)).andReturn(null);
+        EasyMock.expect(id2.getValue()).andReturn("s2");
+        
+        control.replay();
+        try {
+            interceptor.processAcknowledgments(rmps);
+            fail("Expected SequenceFault not thrown");
+        } catch (SequenceFault sf) {
+            assertEquals(RMConstants.getUnknownSequenceFaultCode(), sf.getFaultInfo().getFaultCode());
+        }
+    }
+    
+    @Test
+    public void testProcessAcknowledgmentRequests() {
+        control.replay();
+        // TODI
+    }
+    
+    @Test
+    public void testProcessSequence() throws SequenceFault {
+        Destination destination = control.createMock(Destination.class);
+        Message message = control.createMock(Message.class);
+        destination.acknowledge(message);
+        EasyMock.expectLastCall();        
+        control.replay();
+        RMInInterceptor interceptor = new RMInInterceptor();
+        interceptor.processSequence(destination, message);
+    }
+    
+    @Test
+    public void testProcessDeliveryAssurance() {
+        control.replay(); 
+        // TODO
+    }
+    
+    
+    
+
+    private Message setupInboundMessage(String action, boolean serverSide) {
+        Message message = control.createMock(Message.class);
+        Exchange exchange = control.createMock(Exchange.class);
+        EasyMock.expect(message.getExchange()).andReturn(exchange).times(2);
+        EasyMock.expect(exchange.getOutMessage()).andReturn(null);
+        EasyMock.expect(exchange.getOutFaultMessage()).andReturn(null);        
+        EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
+        
+        EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(!serverSide);
+        AddressingPropertiesImpl maps = control.createMock(AddressingPropertiesImpl.class);
+        EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps);
+        
+        AttributedURIType actionURI = control.createMock(AttributedURIType.class);
+        EasyMock.expect(maps.getAction()).andReturn(actionURI).times(2);
+        EasyMock.expect(actionURI.getValue()).andReturn(action);
+        
+        EasyMock.expect(message.get(RMMessageConstants.ORIGINAL_REQUESTOR_ROLE)).andReturn(Boolean.FALSE);
+        EasyMock.expect(message.put(Message.REQUESTOR_ROLE, Boolean.FALSE)).andReturn(null);
+        
+        org.apache.cxf.transport.Destination td = 
+            serverSide ? control.createMock(org.apache.cxf.transport.Destination.class) :
null;
+        EasyMock.expect(exchange.getDestination()).andReturn(td);
+        return message;
+    }
+    
 }

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java Fri
Mar 23 02:37:32 2007
@@ -26,7 +26,6 @@
 import java.util.TimerTask;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.endpoint.Endpoint;
@@ -43,15 +42,20 @@
 import org.apache.cxf.ws.rm.policy.RMAssertion;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
 
 public class RMManagerTest extends TestCase {
     
     private IMocksControl control;
     
+    @Before
     public void setUp() {
         control = EasyMock.createNiceControl();
     }
    
+    @Test
     public void testAccessors() {
         RMManager manager = new RMManager();
         assertNull(manager.getStore());
@@ -70,6 +74,7 @@
         
     }
     
+    @Test
     public void testInitialisation() {
         RMManager manager = new RMManager();
         assertTrue("RMAssertion is set.", !manager.isSetRMAssertion());
@@ -103,6 +108,8 @@
    
     }   
     
+    @Ignore
+    @Test
     public void xtestGetReliableEndpoint() {
         
         RMManager manager = new RMManager();
@@ -122,6 +129,7 @@
         control.verify();
     }
     
+    @Test
     public void testGetDestination() throws NoSuchMethodException {
         Method  m = RMManager.class
             .getDeclaredMethod("getReliableEndpoint", new Class[] {Message.class});     
  
@@ -142,7 +150,8 @@
         assertNull(manager.getDestination(message));
         control.verify();        
     }
-        
+    
+    @Test
     public void testGetSource() throws NoSuchMethodException {
         Method m = RMManager.class
             .getDeclaredMethod("getReliableEndpoint", new Class[] {Message.class});
@@ -163,7 +172,8 @@
         assertNull(manager.getSource(message));
         control.verify();
     }
-        
+     
+    @Test
     public void testGetExistingSequence() throws NoSuchMethodException, SequenceFault {
         Method m = RMManager.class
            .getDeclaredMethod("getSource", new Class[] {Message.class});
@@ -180,6 +190,7 @@
         control.verify();
     }
     
+    @Test
     public void testGetNewSequence() throws NoSuchMethodException, SequenceFault, IOException
{
         Method m = RMManager.class.getDeclaredMethod("getSource", new Class[] {Message.class});
         RMManager manager = control.createMock(RMManager.class, new Method[] {m});
@@ -207,8 +218,7 @@
         Proxy proxy = control.createMock(Proxy.class);
         EasyMock.expect(rme.getProxy()).andReturn(proxy);
         CreateSequenceResponseType createResponse = control.createMock(CreateSequenceResponseType.class);
-        proxy.createSequence(EasyMock.isA(EndpointReferenceType.class),
-                             EasyMock.isA(org.apache.cxf.ws.addressing.v200408.EndpointReferenceType.class),
+        proxy.createSequence(EasyMock.isA(org.apache.cxf.ws.addressing.v200408.EndpointReferenceType.class),
                              (RelatesToType)EasyMock.isNull(),
                              EasyMock.eq(false));
         EasyMock.expectLastCall().andReturn(createResponse);
@@ -226,6 +236,7 @@
         control.verify();
     }
 
+    @Test
     public void testShutdown() {
 
         Bus bus = new SpringBusFactory().createBus("org/apache/cxf/ws/rm/rmmanager.xml",
false);

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMOutInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMOutInterceptorTest.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMOutInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMOutInterceptorTest.java
Fri Mar 23 02:37:32 2007
@@ -26,7 +26,6 @@
 import java.util.List;
 
 import junit.framework.TestCase;
-
 import org.apache.cxf.interceptor.InterceptorChain;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -40,15 +39,19 @@
 import org.apache.cxf.ws.addressing.v200408.AttributedURI;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
+import org.junit.Before;
+import org.junit.Test;
 
 public class RMOutInterceptorTest extends TestCase {
     
     private IMocksControl control;
     
+    @Before
     public void setUp() {
         control = EasyMock.createNiceControl();
     }
     
+    @Test
     public void testOrdering() {
         Phase p = new Phase(Phase.PRE_LOGICAL, 1);
         PhaseInterceptorChain chain = 
@@ -62,6 +65,7 @@
         assertSame("Unexpected order.", rmi, it.next());                      
     } 
     
+    @Test
     public void testHandleApplicationMessage() throws NoSuchMethodException, SequenceFault
{
         AddressingPropertiesImpl maps = createMAPs("greetMe", "localhost:9000/GreeterPort",

             org.apache.cxf.ws.addressing.Names.WSA_NONE_ADDRESS);
@@ -114,7 +118,7 @@
 
         
         control.replay();
-        interceptor.handleMessage(message, false);
+        interceptor.handle(message);
         assertSame(sid, rmpsOut.getSequence().getIdentifier());        
         assertEquals(BigInteger.TEN, rmpsOut.getSequence().getMessageNumber());
         assertNull(rmpsOut.getSequence().getLastMessage());

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java
Fri Mar 23 02:37:32 2007
@@ -32,6 +32,9 @@
 import org.apache.cxf.ws.rm.manager.SourcePolicyType;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 public class SourceSequenceTest extends TestCase {
 
@@ -45,6 +48,7 @@
     private SequenceTerminationPolicyType stp;
     private RetransmissionQueue rq;
   
+    @Before
     public void setUp() {        
         factory = new ObjectFactory();
         id = factory.createIdentifier();
@@ -53,6 +57,7 @@
         control = EasyMock.createNiceControl();
     }
     
+    @After
     public void tearDown() {
         source = null;
         manager = null;
@@ -79,7 +84,7 @@
         EasyMock.expect(manager.getSourcePolicy()).andReturn(sp).anyTimes();
     }
     
-
+    @Test
     public void testConstructors() {
 
         Identifier otherId = factory.createIdentifier();
@@ -114,6 +119,7 @@
         assertFalse(seq.offeredBy(id));
     }
     
+    @Test
     public void testSetExpires() {
         SourceSequence seq = new SourceSequence(id);
         
@@ -142,6 +148,7 @@
         assertTrue(seq.isExpired());   
     }
 
+    @Test
     public void testEqualsAndHashCode() {
         SourceSequence seq = new SourceSequence(id);
         SourceSequence otherSeq = null;
@@ -157,7 +164,7 @@
         assertTrue(!seq.equals(this));
     }
     
-
+    @Test
     public void testSetAcknowledged() {
         SourceSequence seq = new SourceSequence(id);
         setUpSource();
@@ -190,6 +197,7 @@
         control.verify();
     } 
 
+    @Test
     public void testAllAcknowledged() throws SequenceFault {
         
         SourceSequence seq = new SourceSequence(id, null, null, new BigInteger("4"), false);
       
@@ -216,6 +224,7 @@
         control.verify();
     }
     
+    @Test
     public void testNextMessageNumber() {     
         SourceSequence seq = null;        
         setUpSource();
@@ -270,6 +279,7 @@
         // termination policy max unacknowledged 
     }
     
+    @Test
     public void testGetEndpointIdentfier() {
         setUpSource();
         QName qn = new QName("abc", "xyz");
@@ -282,6 +292,7 @@
         control.verify();
     }
     
+    @Test
     public void testCheckOfferingSequenceClosed() {
         SourceSequence seq = null;
         



Mime
View raw message