use of org.apache.cxf.jaxrs.JAXBContextProvider in project cxf by apache.
the class JAXRSUtilsTest method testContextResolverParam.
@Test
public void testContextResolverParam() throws Exception {
ClassResourceInfo cri = new ClassResourceInfo(Customer.class, true);
OperationResourceInfo ori = new OperationResourceInfo(Customer.class.getMethod("testContextResolvers", new Class[] { ContextResolver.class }), cri);
ori.setHttpMethod("GET");
Message m = createMessage();
ContextResolver<JAXBContext> cr = new JAXBContextProvider();
ProviderFactory.getInstance(m).registerUserProvider(cr);
m.put(Message.BASE_PATH, "/");
List<Object> params = JAXRSUtils.processParameters(ori, new MetadataMap<String, String>(), m);
assertEquals("1 parameters expected", 1, params.size());
assertSame(cr.getClass(), params.get(0).getClass());
}
use of org.apache.cxf.jaxrs.JAXBContextProvider 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);
}
use of org.apache.cxf.jaxrs.JAXBContextProvider 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);
}
use of org.apache.cxf.jaxrs.JAXBContextProvider in project cxf by apache.
the class ProviderFactoryTest method testRegisterCustomResolver.
@Test
public void testRegisterCustomResolver() throws Exception {
ProviderFactory pf = ServerProviderFactory.getInstance();
pf.registerUserProvider(new JAXBContextProvider());
Message message = prepareMessage("*/*", null);
ContextResolver<JAXBContext> cr = pf.createContextResolver(JAXBContext.class, message);
assertFalse(cr instanceof ProviderFactory.ContextResolverProxy);
assertTrue("JAXBContext ContextProvider can not be found", cr instanceof JAXBContextProvider);
}
use of org.apache.cxf.jaxrs.JAXBContextProvider 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);
}
Aggregations