use of org.apache.cxf.jaxrs.provider.ProviderFactory in project cxf by apache.
the class MessageContextImplTest method testContextResolver.
@SuppressWarnings("unchecked")
@Test
public void testContextResolver() {
ContextResolver<JAXBContext> resolver = new CustomContextResolver();
ProviderFactory factory = ServerProviderFactory.getInstance();
factory.registerUserProvider(resolver);
Message m = new MessageImpl();
Exchange ex = new ExchangeImpl();
m.setExchange(ex);
ex.setInMessage(m);
Endpoint e = EasyMock.createMock(Endpoint.class);
e.get(ServerProviderFactory.class.getName());
EasyMock.expectLastCall().andReturn(factory);
EasyMock.replay(e);
ex.put(Endpoint.class, e);
MessageContext mc = new MessageContextImpl(m);
ContextResolver<JAXBContext> resolver2 = mc.getResolver(ContextResolver.class, JAXBContext.class);
assertNotNull(resolver2);
assertSame(resolver2, resolver);
}
use of org.apache.cxf.jaxrs.provider.ProviderFactory in project cxf by apache.
the class PerRequestResourceProviderTest method createMessage.
private Message createMessage() {
ProviderFactory factory = ServerProviderFactory.getInstance();
Message m = new MessageImpl();
m.put("org.apache.cxf.http.case_insensitive_queries", false);
Exchange e = new ExchangeImpl();
m.setExchange(e);
e.setInMessage(m);
Endpoint endpoint = EasyMock.createMock(Endpoint.class);
endpoint.getEndpointInfo();
EasyMock.expectLastCall().andReturn(null).anyTimes();
endpoint.get(Application.class.getName());
EasyMock.expectLastCall().andReturn(null);
endpoint.size();
EasyMock.expectLastCall().andReturn(0).anyTimes();
endpoint.isEmpty();
EasyMock.expectLastCall().andReturn(true).anyTimes();
endpoint.get(ServerProviderFactory.class.getName());
EasyMock.expectLastCall().andReturn(factory).anyTimes();
EasyMock.replay(endpoint);
e.put(Endpoint.class, endpoint);
return m;
}
Aggregations