use of org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper in project cxf by apache.
the class ProviderFactoryTest method testRegisterInFeature.
@Test
public void testRegisterInFeature() {
ServerProviderFactory pf = ServerProviderFactory.getInstance();
final Object provider = new WebApplicationExceptionMapper();
pf.registerUserProvider((Feature) context -> {
context.register(provider);
return true;
});
ExceptionMapper<WebApplicationException> em = pf.createExceptionMapper(WebApplicationException.class, new MessageImpl());
assertSame(provider, em);
}
use of org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper in project cxf by apache.
the class ProviderFactoryTest method testExceptionMappersHierarchy5.
@Test
public void testExceptionMappersHierarchy5() throws Exception {
Message m = new MessageImpl();
ServerProviderFactory pf = ServerProviderFactory.getInstance();
ExceptionMapper<WebApplicationException> em = pf.createExceptionMapper(WebApplicationException.class, m);
assertTrue(em instanceof WebApplicationExceptionMapper);
}
use of org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper in project cxf by apache.
the class ProviderFactoryTest method testExceptionMappersHierarchy1.
@Test
public void testExceptionMappersHierarchy1() throws Exception {
ServerProviderFactory pf = ServerProviderFactory.getInstance();
WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper();
pf.registerUserProvider(wm);
assertSame(wm, pf.createExceptionMapper(WebApplicationException.class, new MessageImpl()));
assertNull(pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
TestRuntimeExceptionMapper rm = new TestRuntimeExceptionMapper();
pf.registerUserProvider(rm);
assertSame(wm, pf.createExceptionMapper(WebApplicationException.class, new MessageImpl()));
assertSame(rm, pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
}
use of org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper in project cxf by apache.
the class ProviderFactoryTest method testExceptionMappersHierarchy2.
@Test
public void testExceptionMappersHierarchy2() throws Exception {
ServerProviderFactory pf = ServerProviderFactory.getInstance();
TestRuntimeExceptionMapper rm = new TestRuntimeExceptionMapper();
pf.registerUserProvider(rm);
ExceptionMapper<WebApplicationException> em = pf.createExceptionMapper(WebApplicationException.class, new MessageImpl());
assertTrue(em instanceof WebApplicationExceptionMapper);
assertSame(rm, pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
WebApplicationExceptionMapper wm = new WebApplicationExceptionMapper();
pf.registerUserProvider(wm);
assertSame(wm, pf.createExceptionMapper(WebApplicationException.class, new MessageImpl()));
assertSame(rm, pf.createExceptionMapper(RuntimeException.class, new MessageImpl()));
}
Aggregations