use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.
the class CorbaConduitTest method testBuildReturn.
@Test
public void testBuildReturn() throws Exception {
Message msg = new MessageImpl();
CorbaMessage message = new CorbaMessage(msg);
Exchange exchange = new ExchangeImpl();
exchange.put(Bus.class, bus);
message.setExchange(exchange);
QName objName = new QName("returnName");
QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
CorbaStreamable arg = message.createStreamableObject(obj1, objName);
CorbaConduit conduit = setupCorbaConduit(false);
NamedValue ret = conduit.getReturn(message);
assertNotNull("Return should not be null", ret != null);
assertEquals("name should be equal", ret.name(), "return");
message.setStreamableReturn(arg);
NamedValue ret2 = conduit.getReturn(message);
assertNotNull("Return2 should not be null", ret2 != null);
assertEquals("name should be equal", ret2.name(), "returnName");
}
use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.
the class CorbaConduitTest method testBuildArguments.
@Test
public void testBuildArguments() throws Exception {
Message msg = new MessageImpl();
CorbaMessage message = new CorbaMessage(msg);
Exchange exchange = new ExchangeImpl();
exchange.put(Bus.class, bus);
message.setExchange(exchange);
CorbaStreamable[] arguments = new CorbaStreamable[1];
QName objName = new QName("object");
QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
CorbaStreamable arg = message.createStreamableObject(obj1, objName);
arguments[0] = arg;
arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
CorbaConduit conduit = setupCorbaConduit(false);
NVList list = conduit.getArguments(message);
assertNotNull("list should not be null", list != null);
message.setStreamableArguments(arguments);
NVList listArgs = conduit.getArguments(message);
assertNotNull("listArgs should not be null", listArgs != null);
assertNotNull("listArgs Item should not be null", listArgs.item(0) != null);
assertEquals("Name should be equal", listArgs.item(0).name(), "object");
assertEquals("flags should be 2", listArgs.item(0).flags(), 2);
assertNotNull("Any Value should not be null", listArgs.item(0).value() != null);
}
use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.
the class SingletonResourceProvider method init.
public void init(Endpoint ep) {
if (resourceInstance instanceof Constructor) {
Constructor<?> c = (Constructor<?>) resourceInstance;
Message m = new MessageImpl();
ExchangeImpl exchange = new ExchangeImpl();
exchange.put(Endpoint.class, ep);
m.setExchange(exchange);
Object[] values = ResourceUtils.createConstructorArguments(c, m, false, Collections.emptyMap());
try {
resourceInstance = values.length > 0 ? c.newInstance(values) : c.newInstance(new Object[] {});
} catch (Exception ex) {
throw new ServiceConstructionException(ex);
}
}
if (callPostConstruct) {
InjectionUtils.invokeLifeCycleMethod(resourceInstance, ResourceUtils.findPostConstructMethod(ClassHelper.getRealClass(resourceInstance)));
}
}
use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.
the class JAXBElementProviderTest method createMessage.
private Message createMessage() {
ServerProviderFactory factory = ServerProviderFactory.getInstance();
Message m = new MessageImpl();
m.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/bar");
m.put("org.apache.cxf.http.case_insensitive_queries", false);
Exchange e = new ExchangeImpl();
m.setExchange(e);
e.setInMessage(m);
Endpoint endpoint = EasyMock.mock(Endpoint.class);
EasyMock.expect(endpoint.getEndpointInfo()).andReturn(null).anyTimes();
EasyMock.expect(endpoint.get(Application.class.getName())).andReturn(null);
EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
EasyMock.expect(endpoint.get(ServerProviderFactory.class.getName())).andReturn(factory).anyTimes();
EasyMock.replay(endpoint);
e.put(Endpoint.class, endpoint);
return m;
}
use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.
the class UriInfoImplTest method mockMessage.
private Message mockMessage(String baseAddress, String pathInfo, String query, String fragment) {
Message m = new MessageImpl();
control.reset();
Exchange e = new ExchangeImpl();
m.setExchange(e);
ServletDestination d = control.createMock(ServletDestination.class);
e.setDestination(d);
EndpointInfo epr = new EndpointInfo();
epr.setAddress(baseAddress);
d.getEndpointInfo();
EasyMock.expectLastCall().andReturn(epr).anyTimes();
m.put(Message.REQUEST_URI, pathInfo);
m.put(Message.QUERY_STRING, query);
control.replay();
return m;
}
Aggregations