You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2016/09/15 21:25:32 UTC
[07/20] incubator-juneau git commit: Clean up Javadocs
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/SerializersTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/SerializersTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/SerializersTest.java
deleted file mode 100755
index b5b46c0..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/SerializersTest.java
+++ /dev/null
@@ -1,152 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import static javax.servlet.http.HttpServletResponse.*;
-import static org.apache.juneau.server.TestUtils.*;
-import static org.junit.Assert.*;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-public class SerializersTest {
-
- private static String URL = "/testSerializers";
- private static boolean debug = false;
- private static RestClient client;
-
- @BeforeClass
- public static void beforeClass() {
- client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- }
-
- @AfterClass
- public static void afterClass() {
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Serializer defined on class.
- //====================================================================================================
- @Test
- public void testSerializerOnClass() throws Exception {
- String url = URL + "/testSerializerOnClass";
-
- client.setAccept("text/a");
- String r = client.doGet(url).getResponseAsString();
- assertEquals("text/a - test1", r);
-
- try {
- client.setAccept("text/b");
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/b'",
- "Supported media-types: [text/a, ");
- }
-
- client.setAccept("text/json");
- r = client.doGet(url).getResponseAsString();
- assertEquals("\"test1\"", r);
- }
-
- //====================================================================================================
- // Serializer defined on method.
- //====================================================================================================
- @Test
- public void testSerializerOnMethod() throws Exception {
- String url = URL + "/testSerializerOnMethod";
-
- try {
- client.setAccept("text/a");
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/a'",
- "Supported media-types: [text/b]"
- );
- }
-
- try {
- client.setAccept("text/json");
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/json'",
- "Supported media-types: [text/b]"
- );
- }
- }
-
- //====================================================================================================
- // Serializer overridden on method.
- //====================================================================================================
- @Test
- public void testSerializerOverriddenOnMethod() throws Exception {
- String url = URL + "/testSerializerOverriddenOnMethod";
-
- client.setAccept("text/a");
- String r = client.doGet(url).getResponseAsString();
- assertEquals("text/c - test3", r);
-
- client.setAccept("text/b");
- r = client.doGet(url).getResponseAsString();
- assertEquals("text/b - test3", r);
-
- client.setAccept("text/json");
- r = client.doGet(url).getResponseAsString();
- assertEquals("\"test3\"", r);
- }
-
- //====================================================================================================
- // Serializer with different Accept than Content-Type.
- //====================================================================================================
- @Test
- public void testSerializerWithDifferentMediaTypes() throws Exception {
- String url = URL + "/testSerializerWithDifferentMediaTypes";
-
- client.setAccept("text/a");
- String r = client.doGet(url).getResponseAsString();
- assertEquals("text/d - test4", r);
-
- client.setAccept("text/d");
- r = client.doGet(url).getResponseAsString();
- assertEquals("text/d - test4", r);
-
- client.setAccept("text/json");
- r = client.doGet(url).getResponseAsString();
- assertEquals("\"test4\"", r);
- }
-
- //====================================================================================================
- // Check for valid 406 error response.
- //====================================================================================================
- @Test
- public void test406() throws Exception {
- String url = URL + "/test406";
-
- try {
- client.setAccept("text/bad");
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/bad'",
- "Supported media-types: [text/a");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/StaticFilesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/StaticFilesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/StaticFilesTest.java
deleted file mode 100755
index cb8a7ad..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/StaticFilesTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import static org.junit.Assert.*;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.plaintext.*;
-import org.junit.*;
-
-public class StaticFilesTest {
-
- private static String URL = "/testStaticFiles";
-
- //====================================================================================================
- // Tests the @RestResource(staticFiles) annotation.
- //====================================================================================================
- @Test
- public void testXdocs() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String r;
- String url = URL + "/xdocs";
-
- r = client.doGet(url + "/test.txt").getResponseAsString();
- assertTrue(r.endsWith("OK-1"));
- r = client.doGet(url + "/xdocs/test.txt").getResponseAsString();
- assertTrue(r.endsWith("OK-2"));
-
- // For security reasons, paths containing ".." should always return 404.
- try {
- client.doGet(url + "/xdocs/../test.txt?noTrace=true").connect();
- fail("404 exception expected");
- } catch (RestCallException e) {
- assertEquals(404, e.getResponseCode());
- }
-
- try {
- client.doGet(url + "/xdocs/%2E%2E/test.txt?noTrace=true").connect();
- fail("404 exception expected");
- } catch (RestCallException e) {
- assertEquals(404, e.getResponseCode());
- }
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/TestRestClient.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/TestRestClient.java b/juneau-server-test/src/test/java/org/apache/juneau/server/TestRestClient.java
deleted file mode 100755
index 8fcaa2d..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/TestRestClient.java
+++ /dev/null
@@ -1,69 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import java.security.*;
-
-import javax.net.ssl.*;
-
-import org.apache.http.conn.ssl.*;
-import org.apache.http.impl.client.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-
-/**
- * REST client with lenient SSL support and lax redirection strategy.
- */
-class TestRestClient extends RestClient {
-
- public TestRestClient(Class<? extends Serializer> s, Class<? extends Parser> p) throws InstantiationException {
- super(s,p);
- setRootUrl(Constants.getServerTestUrl());
- }
-
- public TestRestClient(Serializer s, Parser p) {
- super(s,p);
- setRootUrl(Constants.getServerTestUrl());
- }
-
- public TestRestClient() {
- setRootUrl(Constants.getServerTestUrl());
- }
-
- public TestRestClient(CloseableHttpClient c) {
- super(c);
- setRootUrl(Constants.getServerTestUrl());
- }
-
- public static SSLConnectionSocketFactory getSSLSocketFactory() throws Exception {
- SSLContext sslContext = SSLContext.getInstance("SSL");
- TrustManager tm = new SimpleX509TrustManager(true);
- sslContext.init(null, new TrustManager[]{tm}, new SecureRandom());
- return new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
- }
-
- @Override /* RestClient */
- protected CloseableHttpClient createHttpClient() throws Exception {
- try {
- return HttpClients.custom().setSSLSocketFactory(getSSLSocketFactory()).setRedirectStrategy(new LaxRedirectStrategy()).build();
- } catch (KeyStoreException e) {
- throw new RuntimeException(e);
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- } catch (Throwable e) {
- e.printStackTrace();
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/TestUtils.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/TestUtils.java b/juneau-server-test/src/test/java/org/apache/juneau/server/TestUtils.java
deleted file mode 100755
index 6c4d3d6..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/TestUtils.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import java.text.*;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.transforms.*;
-import org.junit.Assert;
-
-import junit.framework.*;
-
-public class TestUtils {
-
- private static JsonSerializer js2 = new JsonSerializer.Simple()
- .addPojoSwaps(IteratorSwap.class, EnumerationSwap.class);
-
- /**
- * Assert that the object equals the specified string after running it through JsonSerializer.DEFAULT_LAX.toString().
- */
- public static void assertObjectEquals(String s, Object o) {
- assertObjectEquals(s, o, js2);
- }
-
- /**
- * Assert that the object equals the specified string after running it through ws.toString().
- */
- public static void assertObjectEquals(String s, Object o, WriterSerializer ws) {
- Assert.assertEquals(s, ws.toString(o));
- }
-
- public static void checkErrorResponse(boolean debug, RestCallException e, int status, String...contains) throws AssertionFailedError {
- String r = e.getResponseMessage();
- if (debug) {
- System.err.println(r);
- e.printStackTrace();
- }
- if (status != e.getResponseCode())
- throw new AssertionFailedError(MessageFormat.format("Response status code was not correct. Expected: ''{0}''. Actual: ''{1}''", status, e.getResponseCode()));
- for (String s : contains) {
- if (r == null || ! r.contains(s)) {
- if (! debug)
- System.err.println(r);
- throw new AssertionFailedError(MessageFormat.format("Response did not have the following expected text: ''{0}''", s));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/TransformsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/TransformsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/TransformsTest.java
deleted file mode 100755
index 29208b5..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/TransformsTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import static org.junit.Assert.*;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-public class TransformsTest {
-
- private static String URL = "/testTransforms";
-
- //====================================================================================================
- // test1 - Test class transform overrides parent class transform
- // Should return "A2-1".
- //====================================================================================================
- @Test
- public void testClassTransformOverridesParentClassTransform() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
- String url = URL + "/testClassTransformOverridesParentClassTransform";
-
- r = client.doGet(url).getResponse(String.class);
- assertEquals("A2-0", r);
-
- r = client.doPut(url, "A2-1").getResponse(String.class);
- assertEquals("A2-1", r);
-
- r = client.doPut(url + "/A2-2", "").getResponse(String.class);
- assertEquals("A2-2", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test method transform overrides class transform
- // Should return "A3-1".
- //====================================================================================================
- @Test
- public void testMethodTransformOverridesClassTransform() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
- String url = URL + "/testMethodTransformOverridesClassTransform";
-
- r = client.doGet(url).getResponse(String.class);
- assertEquals("A3-0", r);
-
- r = client.doPut(url, "A3-1").getResponse(String.class);
- assertEquals("A3-1", r);
-
- r = client.doPut(url + "/A3-2", "").getResponse(String.class);
- assertEquals("A3-2", r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/UrisTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/UrisTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/UrisTest.java
deleted file mode 100755
index f75adba..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/UrisTest.java
+++ /dev/null
@@ -1,918 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import static org.junit.Assert.*;
-
-import java.util.regex.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-/**
- * Verifies that all the RestRequest.getXXX() methods involving URIs work correctly.
- */
-public class UrisTest {
-
- private static String URL2 = Constants.getServerTestUrl() + "/testuris"; // /jazz/juneau/sample/testuris
- private static int port = getPort(Constants.getServerTestUrl()); // 9443
- private static String path = Constants.getServerTestUri().getPath(); // /jazz/juneau/sample
-
- //====================================================================================================
- // testRoot - http://localhost:8080/sample/testuris
- //====================================================================================================
- @Test
- public void testRoot() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r;
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris").getResponse(ObjectMap.class);
- assertEquals("root.test1", r.getString("testMethod"));
- assertNull(r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/foo").getResponse(ObjectMap.class);
- assertEquals("root.test1", r.getString("testMethod"));
- assertEquals("/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/foo/bar").getResponse(ObjectMap.class);
- assertEquals("root.test1", r.getString("testMethod"));
- assertEquals("/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("root.test1", r.getString("testMethod"));
- assertEquals("/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test2
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test2").getResponse(ObjectMap.class);
- assertEquals("root.test2", r.getString("testMethod"));
- assertEquals("/test2", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test2", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test2/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test2/foo").getResponse(ObjectMap.class);
- assertEquals("root.test2", r.getString("testMethod"));
- assertEquals("/test2/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test2", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test2/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2/foo"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test2/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test2/foo/bar").getResponse(ObjectMap.class);
- assertEquals("root.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test2/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test3%2Ftest3
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test3%2Ftest3").getResponse(ObjectMap.class);
- assertEquals("root.test3", r.getString("testMethod"));
- assertEquals("/test3/test3", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test3%2Ftest3", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test3%2Ftest3/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test3%2Ftest3/foo").getResponse(ObjectMap.class);
- assertEquals("root.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test3%2Ftest3", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test3%2Ftest3/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
- assertEquals("root.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test3%2Ftest3/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("root.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test4/test4
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test4/test4").getResponse(ObjectMap.class);
- assertEquals("root.test4", r.getString("testMethod"));
- assertEquals("/test4/test4", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test4/test4", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test4/test4/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test4/test4/foo").getResponse(ObjectMap.class);
- assertEquals("root.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test4/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test4/test4/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test4/test4/foo/bar").getResponse(ObjectMap.class);
- assertEquals("root.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test4/test4/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test4/test4/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("root.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // testChild - http://localhost:8080/sample/testuris/child
- //====================================================================================================
- @Test
- public void testChild() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r;
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child").getResponse(ObjectMap.class);
- assertEquals("child.test1", r.getString("testMethod"));
- assertNull(r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/foo").getResponse(ObjectMap.class);
- assertEquals("child.test1", r.getString("testMethod"));
- assertEquals("/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/foo/bar").getResponse(ObjectMap.class);
- assertEquals("child.test1", r.getString("testMethod"));
- assertEquals("/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("child.test1", r.getString("testMethod"));
- assertEquals("/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test2").getResponse(ObjectMap.class);
- assertEquals("child.test2", r.getString("testMethod"));
- assertEquals("/test2", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test2", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test2/foo").getResponse(ObjectMap.class);
- assertEquals("child.test2", r.getString("testMethod"));
- assertEquals("/test2/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test2", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test2/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test2/foo/bar").getResponse(ObjectMap.class);
- assertEquals("child.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test2/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test2/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("child.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test2/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test3%2Ftest3").getResponse(ObjectMap.class);
- assertEquals("child.test3", r.getString("testMethod"));
- assertEquals("/test3/test3", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test3%2Ftest3", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test3%2Ftest3/foo").getResponse(ObjectMap.class);
- assertEquals("child.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test3%2Ftest3", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
- assertEquals("child.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("child.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test4/test4").getResponse(ObjectMap.class);
- assertEquals("child.test4", r.getString("testMethod"));
- assertEquals("/test4/test4", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test4/test4", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test4/test4/foo").getResponse(ObjectMap.class);
- assertEquals("child.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test4/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test4/test4/foo/bar").getResponse(ObjectMap.class);
- assertEquals("child.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test4/test4/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("child.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // testGrandChild - http://localhost:8080/sample/testuris/child/grandchild
- //====================================================================================================
- @Test
- public void testGrandChild() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r;
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild").getResponse(ObjectMap.class);
- assertEquals("grandchild.test1", r.getString("testMethod"));
- assertNull(r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/foo").getResponse(ObjectMap.class);
- assertEquals("grandchild.test1", r.getString("testMethod"));
- assertEquals("/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/foo/bar").getResponse(ObjectMap.class);
- assertEquals("grandchild.test1", r.getString("testMethod"));
- assertEquals("/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("grandchild.test1", r.getString("testMethod"));
- assertEquals("/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test2").getResponse(ObjectMap.class);
- assertEquals("grandchild.test2", r.getString("testMethod"));
- assertEquals("/test2", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test2", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test2/foo").getResponse(ObjectMap.class);
- assertEquals("grandchild.test2", r.getString("testMethod"));
- assertEquals("/test2/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test2", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test2/foo/bar").getResponse(ObjectMap.class);
- assertEquals("grandchild.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test2/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("grandchild.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test3%2Ftest3").getResponse(ObjectMap.class);
- assertEquals("grandchild.test3", r.getString("testMethod"));
- assertEquals("/test3/test3", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo").getResponse(ObjectMap.class);
- assertEquals("grandchild.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
- assertEquals("grandchild.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("grandchild.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test4/test4").getResponse(ObjectMap.class);
- assertEquals("grandchild.test4", r.getString("testMethod"));
- assertEquals("/test4/test4", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test4/test4/foo").getResponse(ObjectMap.class);
- assertEquals("grandchild.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test4/test4/foo/bar").getResponse(ObjectMap.class);
- assertEquals("grandchild.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("grandchild.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- client.closeQuietly();
- }
-
- private static int getPort(String url) {
- Pattern p = Pattern.compile("\\:(\\d{2,5})");
- Matcher m = p.matcher(url);
- if (m.find())
- return Integer.parseInt(m.group(1));
- return -1;
- }
-}