fixing few tests + don't override jaxrs by *.xxx servlet mappings
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/25b6a814 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/25b6a814 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/25b6a814 Branch: refs/heads/develop Commit: 25b6a814e522b5f48fb1d8fe4de390216dc60f23 Parents: d7f3efe Author: Romain Manni-Bucau <[email protected]> Authored: Mon Jan 26 14:46:57 2015 +0100 Committer: Romain Manni-Bucau <[email protected]> Committed: Mon Jan 26 14:46:57 2015 +0100 ---------------------------------------------------------------------- .../jaxrs/httpheaders/JAXRSHttpHeadersTest.java | 34 ++++++++++---------- .../staticresources/AvoidConflictTest.java | 2 +- .../AvoidConflictWithWebXmlTest.java | 4 ++- ...ictWithWebXmlWithNoResourceMatchingTest.java | 4 ++- ...thNoResourceMatchingWithRestSubPathTest.java | 4 ++- .../tomee/webservices/CXFJAXRSFilter.java | 3 +- 6 files changed, 29 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/25b6a814/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/httpheaders/JAXRSHttpHeadersTest.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/httpheaders/JAXRSHttpHeadersTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/httpheaders/JAXRSHttpHeadersTest.java index 102d78b..6fc3f82 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/httpheaders/JAXRSHttpHeadersTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/httpheaders/JAXRSHttpHeadersTest.java @@ -143,7 +143,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testMediaTypesRequestTextPlain() throws IOException { - HttpPost post = new HttpPost(uri("/context/httpheaders/requestmediatype")); + HttpPost post = new HttpPost(uri("context/httpheaders/requestmediatype")); post.setHeader("Content-Type", "text/plain"); post.setEntity(new StringEntity("Hello world!", "UTF-8")); @@ -162,7 +162,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testMediaTypesRequestCustomContentType() throws IOException { - HttpPost post = new HttpPost(uri("/context/httpheaders/requestmediatype")); + HttpPost post = new HttpPost(uri("context/httpheaders/requestmediatype")); post.setHeader("Content-Type", "defg/abcd"); post.setEntity(new StringEntity("Hello world!", "UTF-8")); @@ -180,7 +180,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testMediaTypesRequestNoRequestEntity() throws IOException { - HttpPost post = new HttpPost(uri("/context/httpheaders/requestmediatype")); + HttpPost post = new HttpPost(uri("context/httpheaders/requestmediatype")); final HttpResponse response = client.execute(post); assertEquals(response.getStatusLine().getStatusCode(), 200); @@ -197,7 +197,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testLanguageNoneGiven() throws IOException { - HttpPost post = new HttpPost(uri("/context/httpheaders/language")); + HttpPost post = new HttpPost(uri("context/httpheaders/language")); post.setHeader("Content-Type", "text/plain"); post.setEntity(new StringEntity("Hello world!", "UTF-8")); @@ -216,7 +216,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testLanguageEnglishGiven() throws IOException { - HttpPost post = new HttpPost(uri("/context/httpheaders/language")); + HttpPost post = new HttpPost(uri("context/httpheaders/language")); post.setHeader("Content-Type", "text/plain"); post.setEntity(new StringEntity("Hello world!", "UTF-8")); post.addHeader("Content-Language", "en"); @@ -236,7 +236,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testLanguageChineseGiven() throws IOException { - HttpPost post = new HttpPost(uri("/context/httpheaders/language")); + HttpPost post = new HttpPost(uri("context/httpheaders/language")); post.setHeader("Content-Type", "text/plain"); post.setEntity(new StringEntity("Hello world!", "UTF-8")); post.addHeader("Content-Language", "zh"); @@ -255,7 +255,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testCookiesNone() throws IOException { - HttpPost HttpPost = new HttpPost(uri("/context/httpheaders/cookies")); + HttpPost HttpPost = new HttpPost(uri("context/httpheaders/cookies")); final HttpResponse response = client.execute(HttpPost); assertEquals(response.getStatusLine().getStatusCode(), 200); @@ -271,7 +271,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testCookiesOneGiven() throws IOException { - final HttpPost HttpPost = new HttpPost(uri("/context/httpheaders/cookies")); + final HttpPost HttpPost = new HttpPost(uri("context/httpheaders/cookies")); HttpPost.addHeader("Cookie", "foo=bar"); final HttpResponse response = client.execute(HttpPost); assertEquals(response.getStatusLine().getStatusCode(), 200); @@ -286,7 +286,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testCookiesManyGiven() throws IOException { - final HttpPost post = new HttpPost(uri("/context/httpheaders/cookies")); + final HttpPost post = new HttpPost(uri("context/httpheaders/cookies")); post.addHeader("Cookie", "foo=bar"); post.addHeader("Cookie", "foo2=bar2"); @@ -303,7 +303,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { * @throws java.io.IOException */ public void testRequestHeaderNoneGivenIllegalArgument() throws IOException { - HttpGet get = new HttpGet(uri("/context/httpheaders/")); + HttpGet get = new HttpGet(uri("context/httpheaders/")); final HttpResponse response = client.execute(get); assertStatusCode(200, response); String responseBody = asString(response); @@ -317,7 +317,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { * @throws java.io.IOException */ public void testRequestHeaderNonexistentHeader() throws IOException { - HttpGet get = new HttpGet(uri("/context/httpheaders/?name=foo")); + HttpGet get = new HttpGet(uri("context/httpheaders/?name=foo")); final HttpResponse response = client.execute(get); assertStatusCode(200, response); String responseBody = asString(response); @@ -332,7 +332,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testRequestHeaderSingleValue() throws IOException { - HttpGet getMethod = new HttpGet(uri("/context/httpheaders/?name=foo")); + HttpGet getMethod = new HttpGet(uri("context/httpheaders/?name=foo")); getMethod.addHeader("foo", "bar"); final HttpResponse response = client.execute(getMethod); assertStatusCode(200, response); @@ -348,7 +348,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testRequestHeaderMultipleValue() throws IOException { - HttpGet getMethod = new HttpGet(uri("/context/httpheaders/?name=foo")); + HttpGet getMethod = new HttpGet(uri("context/httpheaders/?name=foo")); getMethod.addHeader("foo", "bar"); getMethod.addHeader("foo", "bar2"); final HttpResponse response = client.execute(getMethod); @@ -366,7 +366,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testRequestHeaderCaseInsensitive() throws IOException { - HttpGet getMethod = new HttpGet(uri("/context/httpheaders/?name=foo")); + HttpGet getMethod = new HttpGet(uri("context/httpheaders/?name=foo")); getMethod.addHeader("FOO", "bar"); getMethod.addHeader("FoO", "bar2"); final HttpResponse response = client.execute(getMethod); @@ -383,7 +383,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testRequestHeadersBasicHeader() throws IOException { - HttpGet getMethod = new HttpGet(uri("/context/httpheaders/requestheaders")); + HttpGet getMethod = new HttpGet(uri("context/httpheaders/requestheaders")); final HttpResponse response = client.execute(getMethod); assertStatusCode(200, response); String responseBody = asString(response); @@ -402,7 +402,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testRequestHeadersSingleValue() throws IOException { - HttpGet getMethod = new HttpGet(uri("/context/httpheaders/requestheaders")); + HttpGet getMethod = new HttpGet(uri("context/httpheaders/requestheaders")); getMethod.addHeader("fOo", "bAr"); final HttpResponse response = client.execute(getMethod); assertStatusCode(200, response); @@ -419,7 +419,7 @@ public class JAXRSHttpHeadersTest extends JaxrsTest { */ @Test public void testRequestHeadersMultipleValues() throws IOException { - HttpGet getMethod = new HttpGet(uri("/context/httpheaders/requestheaders")); + HttpGet getMethod = new HttpGet(uri("context/httpheaders/requestheaders")); getMethod.addHeader("fOo", "bAr"); getMethod.addHeader("abc", "xyz"); getMethod.addHeader("fOo", "2bAr"); http://git-wip-us.apache.org/repos/asf/tomee/blob/25b6a814/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictTest.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictTest.java index 3977d98..111bf6b 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictTest.java @@ -36,7 +36,7 @@ import static org.junit.Assert.assertEquals; public class AvoidConflictTest { @Deployment(testable = false) public static Archive<?> war() { - return ShrinkWrap.create(WebArchive.class, "app.war") + return ShrinkWrap.create(WebArchive.class, "AvoidConflictTest.war") .addClasses(TheResource.class, SimpleServlet.class, PreviousFilter.class) .addAsWebResource(new StringAsset("static"), "index.html") .addAsWebResource(new StringAsset("JSP <%= 5 %>"), "sample.jsp"); http://git-wip-us.apache.org/repos/asf/tomee/blob/25b6a814/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlTest.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlTest.java index 747d452..91f7e50 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlTest.java @@ -26,6 +26,7 @@ import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppVersionType; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,11 +39,12 @@ import static org.junit.Assert.assertEquals; public class AvoidConflictWithWebXmlTest { @Deployment(testable = false) public static Archive<?> war() { - return ShrinkWrap.create(WebArchive.class, "app.war") + return ShrinkWrap.create(WebArchive.class, "AvoidConflictWithWebXmlTest.war") .addClasses(TheResource.class, SimpleServlet.class, PreviousFilter.class) .addAsWebResource(new StringAsset("JSP <%= 5 %>"), "index.jsp") // works cause name is welcome-file .setWebXML(new StringAsset( Descriptors.create(WebAppDescriptor.class) + .version(WebAppVersionType._3_0) .createServlet() .servletName("home") .jspFile("/index.jsp") http://git-wip-us.apache.org/repos/asf/tomee/blob/25b6a814/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingTest.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingTest.java index 929032b..dd8de77 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingTest.java @@ -26,6 +26,7 @@ import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppVersionType; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,11 +40,12 @@ import static org.junit.Assert.assertEquals; public class AvoidConflictWithWebXmlWithNoResourceMatchingTest { @Deployment(testable = false) public static Archive<?> war() { - return ShrinkWrap.create(WebArchive.class, "app.war") + return ShrinkWrap.create(WebArchive.class, "AvoidConflictWithWebXmlWithNoResourceMatchingTest.war") .addClasses(TheResource.class, SimpleServlet.class, PreviousFilter.class) .addAsWebResource(new StringAsset("JSP <%= 5 %>"), "sample.jsp") .setWebXML(new StringAsset( Descriptors.create(WebAppDescriptor.class) + .version(WebAppVersionType._3_0) .createServlet() .servletName("home") .jspFile("/sample.jsp") http://git-wip-us.apache.org/repos/asf/tomee/blob/25b6a814/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingWithRestSubPathTest.java ---------------------------------------------------------------------- diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingWithRestSubPathTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingWithRestSubPathTest.java index d2a6b88..86bdbbf 100644 --- a/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingWithRestSubPathTest.java +++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-jaxrs-tests/src/test/java/org/apache/openejb/arquillian/tests/jaxrs/staticresources/AvoidConflictWithWebXmlWithNoResourceMatchingWithRestSubPathTest.java @@ -26,6 +26,7 @@ import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.descriptor.api.Descriptors; import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor; +import org.jboss.shrinkwrap.descriptor.api.webcommon30.WebAppVersionType; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,11 +40,12 @@ import static org.junit.Assert.assertEquals; public class AvoidConflictWithWebXmlWithNoResourceMatchingWithRestSubPathTest { @Deployment(testable = false) public static Archive<?> war() { - return ShrinkWrap.create(WebArchive.class, "app.war") + return ShrinkWrap.create(WebArchive.class, "AvoidConflictWithWebXmlWithNoResourceMatchingWithRestSubPathTest.war") .addClasses(TheResource.class, SimpleServlet.class, PreviousFilter.class) .addAsWebResource(new StringAsset("JSP <%= 5 %>"), "sample.jsp") .setWebXML(new StringAsset( Descriptors.create(WebAppDescriptor.class) + .version(WebAppVersionType._3_0) .createServlet() .servletName("home") .jspFile("/sample.jsp") http://git-wip-us.apache.org/repos/asf/tomee/blob/25b6a814/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/CXFJAXRSFilter.java ---------------------------------------------------------------------- diff --git a/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/CXFJAXRSFilter.java b/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/CXFJAXRSFilter.java index 4085175..088cff5 100644 --- a/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/CXFJAXRSFilter.java +++ b/tomee/tomee-jaxrs/src/main/java/org/apache/tomee/webservices/CXFJAXRSFilter.java @@ -121,7 +121,8 @@ public class CXFJAXRSFilter implements Filter { accept = false; if (!"org.apache.catalina.servlets.DefaultServlet".equals(wrapper.getServletClass())) { for (final String mapping : wrapper.findMappings()) { - if (!mapping.isEmpty() && !"/*".equals(mapping) && !"/".equals(mapping) && mapping.startsWith(this.mapping)) { + if (!mapping.isEmpty() && !"/*".equals(mapping) && !"/".equals(mapping) && !mapping.startsWith("*") + && mapping.startsWith(this.mapping)) { accept = true; break; }
