Search in sources :

Example 1 with JAXBContextProvider2

use of org.apache.cxf.jaxrs.JAXBContextProvider2 in project cxf by apache.

the class ProviderFactoryTest method testRegisterCustomResolver2.

@Test
public void testRegisterCustomResolver2() throws Exception {
    ProviderFactory pf = ServerProviderFactory.getInstance();
    pf.registerUserProvider(new JAXBContextProvider());
    pf.registerUserProvider(new JAXBContextProvider2());
    Message message = prepareMessage("text/xml+b", null);
    ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class, message);
    assertFalse(cr instanceof ProviderFactory.ContextResolverProxy);
    assertTrue("JAXBContext ContextProvider can not be found", cr instanceof JAXBContextProvider2);
}
Also used : JAXBContextProvider2(org.apache.cxf.jaxrs.JAXBContextProvider2) Message(org.apache.cxf.message.Message) JAXBContextProvider(org.apache.cxf.jaxrs.JAXBContextProvider) JAXBContext(javax.xml.bind.JAXBContext) Test(org.junit.Test)

Example 2 with JAXBContextProvider2

use of org.apache.cxf.jaxrs.JAXBContextProvider2 in project cxf by apache.

the class ProviderFactoryTest method testNoCustomResolver.

@Test
public void testNoCustomResolver() throws Exception {
    ProviderFactory pf = ServerProviderFactory.getInstance();
    pf.registerUserProvider(new JAXBContextProvider());
    pf.registerUserProvider(new JAXBContextProvider2());
    Message message = prepareMessage("text/xml+c", null);
    ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class, message);
    assertNull(cr);
}
Also used : JAXBContextProvider2(org.apache.cxf.jaxrs.JAXBContextProvider2) Message(org.apache.cxf.message.Message) JAXBContextProvider(org.apache.cxf.jaxrs.JAXBContextProvider) JAXBContext(javax.xml.bind.JAXBContext) Test(org.junit.Test)

Example 3 with JAXBContextProvider2

use of org.apache.cxf.jaxrs.JAXBContextProvider2 in project cxf by apache.

the class ProviderFactoryTest method testCustomResolverProxy.

@Test
public void testCustomResolverProxy() throws Exception {
    ProviderFactory pf = ServerProviderFactory.getInstance();
    pf.registerUserProvider(new JAXBContextProvider());
    pf.registerUserProvider(new JAXBContextProvider2());
    Message message = prepareMessage("text/xml+*", null);
    ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class, message);
    assertTrue(cr instanceof ProviderFactory.ContextResolverProxy);
    assertTrue(((ProviderFactory.ContextResolverProxy<?>) cr).getResolvers().get(0) instanceof JAXBContextProvider);
    assertTrue(((ProviderFactory.ContextResolverProxy<?>) cr).getResolvers().get(1) instanceof JAXBContextProvider2);
}
Also used : JAXBContextProvider2(org.apache.cxf.jaxrs.JAXBContextProvider2) Message(org.apache.cxf.message.Message) JAXBContextProvider(org.apache.cxf.jaxrs.JAXBContextProvider) JAXBContext(javax.xml.bind.JAXBContext) Test(org.junit.Test)

Aggregations

JAXBContext (javax.xml.bind.JAXBContext)3 JAXBContextProvider (org.apache.cxf.jaxrs.JAXBContextProvider)3 JAXBContextProvider2 (org.apache.cxf.jaxrs.JAXBContextProvider2)3 Message (org.apache.cxf.message.Message)3 Test (org.junit.Test)3