cxf 3.1 side effects on tests
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/be3996fa Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/be3996fa Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/be3996fa Branch: refs/heads/fb_tomee2_owb16 Commit: be3996fa42a51d8e2848891fd63bf479d39d2212 Parents: 1518875 Author: Romain Manni-Bucau <[email protected]> Authored: Wed May 6 14:11:10 2015 +0200 Committer: Romain Manni-Bucau <[email protected]> Committed: Wed May 6 14:11:10 2015 +0200 ---------------------------------------------------------------------- .../jaxrs/context/EjbContextInjectionTest.java | 16 +++++++++++++--- .../EjbInterceptorContextInjectionTest.java | 13 ++++++++++++- .../tests/jaxrs/suspended/SuspendedTest.java | 5 +++-- .../openejb/maven/plugin/test/JAXRSReloadTest.java | 17 ++++++++++++++--- 4 files changed, 42 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/be3996fa/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbContextInjectionTest.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbContextInjectionTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbContextInjectionTest.java index 7334acc..5914800 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbContextInjectionTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbContextInjectionTest.java @@ -27,6 +27,9 @@ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; import javax.ejb.Singleton; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -39,8 +42,6 @@ import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Providers; -import java.io.IOException; -import java.net.URL; import static org.junit.Assert.assertEquals; @@ -63,10 +64,19 @@ public class EjbContextInjectionTest { @Test public void rest() throws IOException { - final String response = IO.slurp(new URL(url.toExternalForm() + "injections/check")); + final String response = slurp(new URL(url.toExternalForm() + "injections/check")); assertEquals("true", response); } + private static String slurp(final URL url) throws IOException { + final HttpURLConnection urlConnection = HttpURLConnection.class.cast(url.openConnection()); + try { + urlConnection.setRequestProperty("Accept", "text/plain"); + return IO.slurp(urlConnection.getInputStream()); + } finally { + urlConnection.disconnect(); + } + } @Singleton @Path("/injections") http://git-wip-us.apache.org/repos/asf/tomee/blob/be3996fa/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbInterceptorContextInjectionTest.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbInterceptorContextInjectionTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbInterceptorContextInjectionTest.java index 2039035..c470989 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbInterceptorContextInjectionTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/context/EjbInterceptorContextInjectionTest.java @@ -44,6 +44,7 @@ import javax.ws.rs.core.UriInfo; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Providers; import java.io.IOException; +import java.net.HttpURLConnection; import java.net.URL; import static org.junit.Assert.assertEquals; @@ -70,10 +71,20 @@ public class EjbInterceptorContextInjectionTest { @Test public void rest() throws IOException { - final String response = IO.slurp(new URL(url.toExternalForm() + "injections/check")); + final String response = slurp(new URL(url.toExternalForm() + "injections/check")); assertEquals("true", response); } + private static String slurp(final URL url) throws IOException { + final HttpURLConnection urlConnection = HttpURLConnection.class.cast(url.openConnection()); + try { + urlConnection.setRequestProperty("Accept", "text/plain"); + return IO.slurp(urlConnection.getInputStream()); + } finally { + urlConnection.disconnect(); + } + } + @Singleton @Interceptors(RsEjbInterceptor.class) http://git-wip-us.apache.org/repos/asf/tomee/blob/be3996fa/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/suspended/SuspendedTest.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/suspended/SuspendedTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/suspended/SuspendedTest.java index cd97a61..3d8741c 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/suspended/SuspendedTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/suspended/SuspendedTest.java @@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicReference; import javax.ws.rs.core.Response; import static java.lang.Thread.sleep; +import static javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE; import static org.junit.Assert.assertEquals; @RunWith(Arquillian.class) @@ -51,12 +52,12 @@ public class SuspendedTest { new Thread() { @Override public void run() { - response.set(WebClient.create(url.toExternalForm() + "touch").get()); + response.set(WebClient.create(url.toExternalForm() + "touch").accept(TEXT_PLAIN_TYPE).get()); end.countDown(); } }.start(); final WebClient client = WebClient.create(url.toExternalForm() + "touch"); - while (!client.reset().path("check").get(Boolean.class)) { + while (!client.reset().path("check").accept(TEXT_PLAIN_TYPE).get(Boolean.class)) { sleep(1000); } client.reset().path("answer").post("hello"); http://git-wip-us.apache.org/repos/asf/tomee/blob/be3996fa/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java ---------------------------------------------------------------------- diff --git a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java index bd334dc..b921b25 100644 --- a/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java +++ b/maven/tomee-maven-plugin/src/test/java/org/apache/openejb/maven/plugin/test/JAXRSReloadTest.java @@ -30,6 +30,7 @@ import org.junit.Test; import java.io.File; import java.io.IOException; +import java.net.HttpURLConnection; import java.net.URL; import static java.lang.Thread.sleep; @@ -83,7 +84,7 @@ public class JAXRSReloadTest { @Test public void simpleStart() throws Exception { // eager check setup is ok and it works (avoid to mix redeployment checks with simple deployment) - assertThat(IO.slurp(new URL(url + "/app-jaxrs/ping")).trim(), is("pong")); + assertThat(slurp(new URL(url + "/app-jaxrs/ping")).trim(), is("pong")); long lastTime = 0; for (int i = 0; i < 10; i++) { @@ -91,14 +92,24 @@ public class JAXRSReloadTest { mojo.reload(); // it still works - assertThat(IO.slurp(new URL(url + "/app-jaxrs/ping")).trim(), is("pong")); + assertThat(slurp(new URL(url + "/app-jaxrs/ping")).trim(), is("pong")); // we redeployed since we have a new deployment date - final long time = Long.parseLong(IO.slurp(new URL(url + "/app-jaxrs/ping/time")).trim()); + final long time = Long.parseLong(slurp(new URL(url + "/app-jaxrs/ping/time")).trim()); if (i > 0) { assertTrue(time >= lastTime); } lastTime = time; } } + + private static String slurp(final URL url) throws IOException { + final HttpURLConnection urlConnection = HttpURLConnection.class.cast(url.openConnection()); + try { + urlConnection.setRequestProperty("Accept", "text/plain"); + return IO.slurp(urlConnection.getInputStream()); + } finally { + urlConnection.disconnect(); + } + } }
