Search in sources :

Example 1 with PhaseManagerImpl

use of org.apache.cxf.bus.managers.PhaseManagerImpl in project cxf by apache.

the class SpringBusFactoryTest method testPhases.

@Test
public void testPhases() {
    Bus bus = new SpringBusFactory().createBus();
    PhaseManager cxfPM = bus.getExtension(PhaseManager.class);
    PhaseManager defaultPM = new PhaseManagerImpl();
    SortedSet<Phase> cxfPhases = cxfPM.getInPhases();
    SortedSet<Phase> defaultPhases = defaultPM.getInPhases();
    assertEquals(defaultPhases.size(), cxfPhases.size());
    assertTrue(cxfPhases.equals(defaultPhases));
    cxfPhases = cxfPM.getOutPhases();
    defaultPhases = defaultPM.getOutPhases();
    assertEquals(defaultPhases.size(), cxfPhases.size());
    assertTrue(cxfPhases.equals(defaultPhases));
}
Also used : Bus(org.apache.cxf.Bus) Phase(org.apache.cxf.phase.Phase) PhaseManager(org.apache.cxf.phase.PhaseManager) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) Test(org.junit.Test)

Example 2 with PhaseManagerImpl

use of org.apache.cxf.bus.managers.PhaseManagerImpl in project cxf by apache.

the class OutgoingChainInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    control = EasyMock.createNiceControl();
    phases = new ArrayList<>();
    phases.add(new Phase(Phase.SEND, 1000));
    empty = new ArrayList<Interceptor<? extends Message>>();
    bus = control.createMock(Bus.class);
    PhaseManager pm = new PhaseManagerImpl();
    EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(pm).anyTimes();
    service = control.createMock(Service.class);
    endpoint = control.createMock(Endpoint.class);
    binding = control.createMock(Binding.class);
    EasyMock.expect(endpoint.getBinding()).andStubReturn(binding);
    MessageImpl m = new MessageImpl();
    EasyMock.expect(binding.createMessage()).andStubReturn(m);
    EasyMock.expect(endpoint.getService()).andReturn(service).anyTimes();
    EasyMock.expect(endpoint.getOutInterceptors()).andReturn(empty);
    EasyMock.expect(service.getOutInterceptors()).andReturn(empty);
    EasyMock.expect(bus.getOutInterceptors()).andReturn(empty);
    bopInfo = control.createMock(BindingOperationInfo.class);
    opInfo = control.createMock(OperationInfo.class);
    mInfo = control.createMock(MessageInfo.class);
    bmInfo = control.createMock(BindingMessageInfo.class);
    EasyMock.expect(bopInfo.getOperationInfo()).andReturn(opInfo).times(3);
    EasyMock.expect(opInfo.getOutput()).andReturn(mInfo);
    EasyMock.expect(opInfo.isOneWay()).andReturn(false);
    EasyMock.expect(bopInfo.getOutput()).andReturn(bmInfo);
    control.replay();
}
Also used : Binding(org.apache.cxf.binding.Binding) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Bus(org.apache.cxf.Bus) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Phase(org.apache.cxf.phase.Phase) Message(org.apache.cxf.message.Message) PhaseManager(org.apache.cxf.phase.PhaseManager) Service(org.apache.cxf.service.Service) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) MessageImpl(org.apache.cxf.message.MessageImpl) Before(org.junit.Before)

Example 3 with PhaseManagerImpl

use of org.apache.cxf.bus.managers.PhaseManagerImpl in project cxf by apache.

the class ColocMessageObserverTest method testObserverOnMessage.

@Test
public void testObserverOnMessage() throws Exception {
    msg.setExchange(ex);
    Binding binding = control.createMock(Binding.class);
    EasyMock.expect(ep.getBinding()).andReturn(binding);
    Message inMsg = new MessageImpl();
    EasyMock.expect(binding.createMessage()).andReturn(inMsg);
    EasyMock.expect(ep.getService()).andReturn(srv).anyTimes();
    EasyMock.expect(bus.getExtension(PhaseManager.class)).andReturn(new PhaseManagerImpl()).times(2);
    EasyMock.expect(bus.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>());
    EasyMock.expect(ep.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>());
    EasyMock.expect(srv.getInInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>());
    EasyMock.expect(bus.getExtension(ClassLoader.class)).andReturn(this.getClass().getClassLoader());
    control.replay();
    observer = new TestColocMessageObserver(ep, bus);
    observer.onMessage(msg);
    control.verify();
    Exchange inEx = inMsg.getExchange();
    assertNotNull("Should Have a valid Exchange", inEx);
    assertEquals("Message.REQUESTOR_ROLE should be false", Boolean.FALSE, inMsg.get(Message.REQUESTOR_ROLE));
    assertEquals("Message.INBOUND_MESSAGE should be true", Boolean.TRUE, inMsg.get(Message.INBOUND_MESSAGE));
    assertNotNull("Chain should be set", inMsg.getInterceptorChain());
    Exchange ex1 = msg.getExchange();
    assertNotNull("Exchange should be set", ex1);
}
Also used : Binding(org.apache.cxf.binding.Binding) Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) PhaseManager(org.apache.cxf.phase.PhaseManager) MessageImpl(org.apache.cxf.message.MessageImpl) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) Interceptor(org.apache.cxf.interceptor.Interceptor) Test(org.junit.Test)

Example 4 with PhaseManagerImpl

use of org.apache.cxf.bus.managers.PhaseManagerImpl in project cxf by apache.

the class ColocUtilTest method testSetColocOutPhases.

@Test
public void testSetColocOutPhases() throws Exception {
    PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
    SortedSet<Phase> list = phaseMgr.getOutPhases();
    int size1 = list.size();
    ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
    assertNotSame("The list size should not be same", size1, list.size());
    assertEquals("Expecting Phase.SETUP", list.first().getName(), Phase.SETUP);
    assertEquals("Expecting Phase.POST_LOGICAL", list.last().getName(), Phase.POST_LOGICAL);
}
Also used : Phase(org.apache.cxf.phase.Phase) PhaseManagerImpl(org.apache.cxf.bus.managers.PhaseManagerImpl) Endpoint(org.apache.cxf.endpoint.Endpoint) Test(org.junit.Test)

Example 5 with PhaseManagerImpl

use of org.apache.cxf.bus.managers.PhaseManagerImpl in project cxf by apache.

the class ColocUtilTest method testGetOutInterceptorChain.

@Test
public void testGetOutInterceptorChain() throws Exception {
    PhaseManagerImpl phaseMgr = new PhaseManagerImpl();
    SortedSet<Phase> list = phaseMgr.getInPhases();
    ColocUtil.setPhases(list, Phase.SETUP, Phase.POST_LOGICAL);
    Endpoint ep = control.createMock(Endpoint.class);
    Service srv = control.createMock(Service.class);
    Exchange ex = new ExchangeImpl();
    ex.put(Bus.class, bus);
    ex.put(Endpoint.class, ep);
    ex.put(Service.class, srv);
    EasyMock.expect(ep.getOutInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    EasyMock.expect(ep.getService()).andReturn(srv).atLeastOnce();
    EasyMock.expect(srv.getOutInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    EasyMock.expect(bus.getOutInterceptors()).andReturn(new ArrayList<Interceptor<? extends Message>>()).atLeastOnce();
    control.replay();
    InterceptorChain chain = ColocUtil.getOutInterceptorChain(ex, list);
    control.verify();
    assertNotNull("Should have chain instance", chain);
    Iterator<Interceptor<? extends Message>> iter = chain.iterator();
    assertEquals("Should not have interceptors in chain", false, iter.hasNext());
}
Also used : Exchange(org.apache.cxf.message.Exchange) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Phase(org.apache.cxf.phase.Phase) 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) Interceptor(org.apache.cxf.interceptor.Interceptor) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Aggregations

PhaseManagerImpl (org.apache.cxf.bus.managers.PhaseManagerImpl)11 Test (org.junit.Test)9 Endpoint (org.apache.cxf.endpoint.Endpoint)6 Exchange (org.apache.cxf.message.Exchange)6 Phase (org.apache.cxf.phase.Phase)6 ArrayList (java.util.ArrayList)5 Message (org.apache.cxf.message.Message)5 MessageImpl (org.apache.cxf.message.MessageImpl)5 Bus (org.apache.cxf.Bus)4 InterceptorChain (org.apache.cxf.interceptor.InterceptorChain)4 PhaseManager (org.apache.cxf.phase.PhaseManager)4 Service (org.apache.cxf.service.Service)4 Binding (org.apache.cxf.binding.Binding)3 Interceptor (org.apache.cxf.interceptor.Interceptor)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 QName (javax.xml.namespace.QName)2 SOAPBodyElement (javax.xml.soap.SOAPBodyElement)2 SOAPElement (javax.xml.soap.SOAPElement)2