use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project jersey by jersey.
the class Jersey2689ITCase method testByteArray.
/**
* Checks if a thread gets stuck when an {@code IOException} is thrown from the {@code
* MessageBodyWriter#writeTo}.
*/
@Test
public void testByteArray() throws Exception {
// Executor.
final ExecutorService executor = Executors.newSingleThreadExecutor();
final Future<Response> responseFuture = executor.submit(new Callable<Response>() {
@Override
public Response call() throws Exception {
SampleBean bean = new SampleBean();
bean.setArray(new byte[] {});
ObjectMapper mapper = new ObjectMapper();
mapper.enable(SerializationFeature.INDENT_OUTPUT);
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(mapper);
client().register(provider);
return target().path("post-bean").request().post(Entity.entity(bean, MediaType.APPLICATION_JSON));
}
});
executor.shutdown();
final boolean inTime = executor.awaitTermination(5000, TimeUnit.MILLISECONDS);
// Asserts.
assertTrue(inTime);
// Response.
final Response response = responseFuture.get();
//Make sure we get a 400 error and not a 500 error
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusInfo().getStatusCode());
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project pulsar by yahoo.
the class WebService method addRestResources.
public void addRestResources(String basePath, String javaPackages, boolean requiresAuthentication) {
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider();
provider.setMapper(ObjectMapperFactory.create());
ResourceConfig config = new ResourceConfig();
config.packages("jersey.config.server.provider.packages", javaPackages);
config.register(provider);
ServletHolder servletHolder = new ServletHolder(new ServletContainer(config));
servletHolder.setAsyncSupported(true);
addServlet(basePath, servletHolder, requiresAuthentication);
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project bamboobsc by billchen198318.
the class CxfServerBean method getProvider.
public static List<Object> getProvider() {
List<Object> providers = new ArrayList<Object>();
providers.add(new JSONProvider<Object>());
providers.add(new JAXBElementProvider<Object>());
providers.add(new MultipartProvider());
providers.add(new XPathProvider<Object>());
providers.add(new DataBindingProvider<Object>());
providers.add(new BinaryDataProvider<Object>());
providers.add(new JacksonJaxbJsonProvider());
return providers;
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project cxf by apache.
the class BookServer20 method run.
protected void run() {
Bus bus = BusFactory.getDefaultBus();
setBus(bus);
JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setBus(bus);
sf.setResourceClasses(BookStore.class);
List<Object> providers = new ArrayList<>();
providers.add(new PreMatchContainerRequestFilter2());
providers.add(new PreMatchContainerRequestFilter());
providers.add(new PostMatchContainerResponseFilter());
providers.add((Feature) context -> {
context.register(new PostMatchContainerResponseFilter3());
return true;
});
providers.add(new PostMatchContainerResponseFilter2());
providers.add(new CustomReaderBoundInterceptor());
providers.add(new CustomReaderInterceptor());
providers.add(new CustomWriterInterceptor());
providers.add(new CustomDynamicFeature());
providers.add(new PostMatchContainerRequestFilter());
providers.add(new FaultyContainerRequestFilter());
providers.add(new PreMatchReplaceStreamOrAddress());
providers.add(new ServerTestFeature());
providers.add(new JacksonJaxbJsonProvider());
providers.add(new IOExceptionMapper());
sf.setApplication(new Application());
sf.setProviders(providers);
sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true));
sf.setAddress("http://localhost:" + PORT + "/");
server = sf.create();
BusFactory.setDefaultBus(null);
BusFactory.setThreadDefaultBus(null);
}
use of com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider in project archiva by apache.
the class AbstractDownloadTest method getProxyConnectorService.
protected ProxyConnectorService getProxyConnectorService() {
ProxyConnectorService service = JAXRSClientFactory.create(getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", ProxyConnectorService.class, Collections.singletonList(new JacksonJaxbJsonProvider()));
WebClient.client(service).header("Authorization", authorizationHeader);
WebClient.client(service).header("Referer", "http://localhost:" + port);
WebClient.getConfig(service).getHttpConduit().getClient().setReceiveTimeout(300000L);
return service;
}
Aggregations