use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class LogicalMessageImplTest method testGetPayloadOfJAXB.
@Test
public void testGetPayloadOfJAXB() throws Exception {
// using Dispatch
JAXBContext ctx = JAXBContext.newInstance(ObjectFactory.class);
Message message = new MessageImpl();
Exchange e = new ExchangeImpl();
message.setExchange(e);
LogicalMessageContextImpl lmci = new LogicalMessageContextImpl(message);
JAXBElement<AddNumbers> el = new ObjectFactory().createAddNumbers(req);
LogicalMessageImpl lmi = new LogicalMessageImpl(lmci);
lmi.setPayload(el, ctx);
Object obj = lmi.getPayload(ctx);
assertTrue(obj instanceof JAXBElement);
JAXBElement<?> el2 = (JAXBElement<?>) obj;
assertTrue(el2.getValue() instanceof AddNumbers);
AddNumbers resp = (AddNumbers) el2.getValue();
assertEquals(req.getArg0(), resp.getArg0());
assertEquals(req.getArg1(), resp.getArg1());
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class JsonpInterceptorTest method testJsonWithPadding.
@Test
public void testJsonWithPadding() throws Exception {
Message message = new MessageImpl();
message.put(Message.CONTENT_TYPE, MediaType.APPLICATION_JSON);
message.setExchange(new ExchangeImpl());
message.put(Message.QUERY_STRING, JsonpInInterceptor.CALLBACK_PARAM + "=" + "myCallback");
ByteArrayOutputStream bos = new ByteArrayOutputStream();
message.setContent(OutputStream.class, bos);
// Process the message
in.handleMessage(message);
preStream.handleMessage(message);
postStream.handleMessage(message);
assertEquals("myCallback();", bos.toString());
}
use of org.apache.cxf.message.MessageImpl 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<>();
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.message.MessageImpl in project cxf by apache.
the class JAASLoginInterceptorTest method testLoginWithDefaultHandler.
/**
* Using default CallbackhandlerProviders and no authentication information
*/
@Test(expected = AuthenticationException.class)
public void testLoginWithDefaultHandler() {
JAASLoginInterceptor jaasInt = createTestJaasLoginInterceptor();
Message message = new MessageImpl();
jaasInt.handleMessage(message);
}
use of org.apache.cxf.message.MessageImpl in project cxf by apache.
the class JAASLoginInterceptorTest method testLoginWithDefaultHandlerAndAuthPolWrongPass.
@Test(expected = AuthenticationException.class)
public void testLoginWithDefaultHandlerAndAuthPolWrongPass() {
JAASLoginInterceptor jaasInt = createTestJaasLoginInterceptor();
Message message = new MessageImpl();
addAuthPolicy(message, TestUserPasswordLoginModule.TESTUSER, "wrong");
jaasInt.handleMessage(message);
}
Aggregations