Search in sources :

Example 16 with PhaseManager

use of org.apache.cxf.phase.PhaseManager in project cxf by apache.

the class ColocOutInterceptorTest method testInvokeInboundChain.

@Test
public void testInvokeInboundChain() {
    // Reset Exchange on msg
    msg.setExchange(null);
    Bus bus = setupBus();
    colocOut.setBus(bus);
    PhaseManager pm = new PhaseManagerImpl();
    EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).times(2);
    Endpoint ep = control.createMock(Endpoint.class);
    Binding bd = control.createMock(Binding.class);
    Service srv = control.createMock(Service.class);
    ex.setInMessage(msg);
    ex.put(Bus.class, bus);
    ex.put(Endpoint.class, ep);
    ex.put(Service.class, srv);
    EasyMock.expect(ep.getBinding()).andReturn(bd);
    EasyMock.expect(bd.createMessage()).andReturn(new MessageImpl());
    EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce();
    EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    control.replay();
    colocOut.invokeInboundChain(ex, ep);
    Message inMsg = ex.getInMessage();
    assertNotSame(msg, inMsg);
    assertTrue("Requestor role should be set to true.", (Boolean) inMsg.get(Message.REQUESTOR_ROLE));
    assertTrue("Inbound Message should be set to true.", (Boolean) inMsg.get(Message.INBOUND_MESSAGE));
    assertNotNull("Inbound Message should have interceptor chain set.", inMsg.getInterceptorChain());
    assertTrue("Client Invoke state should be FINISHED", (Boolean) ex.get(ClientImpl.FINISHED));
    control.verify();
}
Also used : Binding(org.apache.cxf.binding.Binding) Bus(org.apache.cxf.Bus) PhaseManager(org.apache.cxf.phase.PhaseManager) Endpoint(org.apache.cxf.endpoint.Endpoint) Message(org.apache.cxf.message.Message) ArrayList(java.util.ArrayList) Service(org.apache.cxf.service.Service) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Aggregations

PhaseManager (org.apache.cxf.phase.PhaseManager)16 Message (org.apache.cxf.message.Message)12 Bus (org.apache.cxf.Bus)9 Interceptor (org.apache.cxf.interceptor.Interceptor)8 PhaseInterceptorChain (org.apache.cxf.phase.PhaseInterceptorChain)8 InterceptorProvider (org.apache.cxf.interceptor.InterceptorProvider)5 Phase (org.apache.cxf.phase.Phase)5 Endpoint (org.apache.cxf.endpoint.Endpoint)4 AbstractBasicInterceptorProvider (org.apache.cxf.interceptor.AbstractBasicInterceptorProvider)4 HashMap (java.util.HashMap)3 Binding (org.apache.cxf.binding.Binding)3 PhaseManagerImpl (org.apache.cxf.bus.managers.PhaseManagerImpl)3 AbstractOutDatabindingInterceptor (org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor)3 AbstractPhaseInterceptor (org.apache.cxf.phase.AbstractPhaseInterceptor)3 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 Map (java.util.Map)2 TreeSet (java.util.TreeSet)2 WeakHashMap (java.util.WeakHashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2