You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by rm...@apache.org on 2018/03/27 13:48:11 UTC
[10/12] johnzon git commit: Test fix - JsonBindingProvider added to
secondary server to not influence pre existing tests
Test fix - JsonBindingProvider added to secondary server to not influence pre existing tests
Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/293e40c7
Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/293e40c7
Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/293e40c7
Branch: refs/heads/master
Commit: 293e40c78b7321abaff42d1e0db7ddd0d5475d86
Parents: 5f01fe2
Author: amoscatelli <al...@live.com>
Authored: Tue Mar 27 14:56:01 2018 +0200
Committer: amoscatelli <al...@live.com>
Committed: Tue Mar 27 14:56:01 2018 +0200
----------------------------------------------------------------------
.../johnzon/jsonb/jaxrs/JsonbJaxRsTest.java | 26 ++++++++++++++------
1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/johnzon/blob/293e40c7/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/jaxrs/JsonbJaxRsTest.java
----------------------------------------------------------------------
diff --git a/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/jaxrs/JsonbJaxRsTest.java b/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/jaxrs/JsonbJaxRsTest.java
index 0013f38..83dabb9 100644
--- a/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/jaxrs/JsonbJaxRsTest.java
+++ b/johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/jaxrs/JsonbJaxRsTest.java
@@ -54,7 +54,9 @@ import static org.junit.Assert.assertTrue;
public class JsonbJaxRsTest {
private final static String ENDPOINT_ADDRESS = "local://johnzon";
+ private final static String ENDPOINT_ADDRESS_JSONB_CONFIG = "local://johnzonjsonbconfig";
private static Server server;
+ private static Server serverJsonbConfig;
public static class JsonBindingProvider implements ContextResolver<Jsonb> {
@@ -71,18 +73,26 @@ public class JsonbJaxRsTest {
@BeforeClass
public static void bindEndpoint() throws Exception {
- final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+ JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(JohnzonResource.class);
- sf.setProviders(Arrays.asList(new JsonbJaxrsProvider<>(), new JsonBindingProvider()));
+ sf.setProviders(singletonList(new JsonbJaxrsProvider<>()));
sf.setResourceProvider(JohnzonResource.class, new SingletonResourceProvider(new JohnzonResource(), false));
sf.setAddress(ENDPOINT_ADDRESS);
server = sf.create();
+ sf = new JAXRSServerFactoryBean();
+ sf.setResourceClasses(JohnzonResource.class);
+ sf.setProviders(Arrays.asList(new JsonbJaxrsProvider<>(), new JsonBindingProvider()));
+ sf.setResourceProvider(JohnzonResource.class, new SingletonResourceProvider(new JohnzonResource(), false));
+ sf.setAddress(ENDPOINT_ADDRESS_JSONB_CONFIG);
+ serverJsonbConfig = sf.create();
}
@AfterClass
public static void unbind() throws Exception {
server.stop();
server.destroy();
+ serverJsonbConfig.stop();
+ serverJsonbConfig.destroy();
}
@Test
@@ -93,7 +103,7 @@ public class JsonbJaxRsTest {
@Test
public void jsonbconfigProvider() {
- client().path("johnzon").get(String.class);
+ client(ENDPOINT_ADDRESS_JSONB_CONFIG, MediaType.APPLICATION_JSON_TYPE).path("johnzon").get(String.class);
assertEquals(JsonBindingProvider.called, Boolean.TRUE);
}
@@ -113,7 +123,7 @@ public class JsonbJaxRsTest {
@Test
public void primitive() {
- final String val = client(MediaType.TEXT_PLAIN_TYPE).path("johnzon/primitive").get(String.class);
+ final String val = client(ENDPOINT_ADDRESS, MediaType.TEXT_PLAIN_TYPE).path("johnzon/primitive").get(String.class);
assertEquals("1986", val);
}
@@ -130,7 +140,7 @@ public class JsonbJaxRsTest {
@Test
public void testBinaryDownload() {
- byte[] content = client(MediaType.TEXT_PLAIN_TYPE)
+ byte[] content = client(ENDPOINT_ADDRESS, MediaType.TEXT_PLAIN_TYPE)
.path("johnzon/mybinary")
.get(byte[].class);
@@ -168,11 +178,11 @@ public class JsonbJaxRsTest {
}
private static WebClient client() {
- return client(MediaType.APPLICATION_JSON_TYPE);
+ return client(ENDPOINT_ADDRESS, MediaType.APPLICATION_JSON_TYPE);
}
- private static WebClient client(final MediaType mediaType) {
- final WebClient client = WebClient.create(ENDPOINT_ADDRESS, singletonList(new JsonbJaxrsProvider<>())).accept(mediaType);
+ private static WebClient client(final String endpoint, final MediaType mediaType) {
+ final WebClient client = WebClient.create(endpoint, singletonList(new JsonbJaxrsProvider<>())).accept(mediaType);
WebClient.getConfig(client).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
return client;
}