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));
}
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();
}
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);
}
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);
}
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());
}
Aggregations