Search in sources :

Example 16 with ProviderFactory

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);
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) ProviderFactory(org.apache.cxf.jaxrs.provider.ProviderFactory) ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) JAXBContext(javax.xml.bind.JAXBContext) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 17 with ProviderFactory

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;
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) ServerProviderFactory(org.apache.cxf.jaxrs.provider.ServerProviderFactory) ProviderFactory(org.apache.cxf.jaxrs.provider.ProviderFactory) MessageImpl(org.apache.cxf.message.MessageImpl) Application(javax.ws.rs.core.Application) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Aggregations

ProviderFactory (org.apache.cxf.jaxrs.provider.ProviderFactory)17 ServerProviderFactory (org.apache.cxf.jaxrs.provider.ServerProviderFactory)13 Message (org.apache.cxf.message.Message)12 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)10 MessageImpl (org.apache.cxf.message.MessageImpl)10 Endpoint (org.apache.cxf.endpoint.Endpoint)9 Exchange (org.apache.cxf.message.Exchange)9 Application (javax.ws.rs.core.Application)6 IOException (java.io.IOException)4 MediaType (javax.ws.rs.core.MediaType)4 ReaderInterceptor (javax.ws.rs.ext.ReaderInterceptor)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 Reader (java.io.Reader)2 ClientErrorException (javax.ws.rs.ClientErrorException)2 ProcessingException (javax.ws.rs.ProcessingException)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 ResponseProcessingException (javax.ws.rs.client.ResponseProcessingException)2 NoContentException (javax.ws.rs.core.NoContentException)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2