http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestTransforms.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestTransforms.java b/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestTransforms.java deleted file mode 100755 index 49a9030..0000000 --- a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestTransforms.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 CT_TestTransforms { - - 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/2c3a7cb5/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestUris.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestUris.java b/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestUris.java deleted file mode 100755 index d5b1f04..0000000 --- a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestUris.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 CT_TestUris { - - 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; - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestUrlContent.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestUrlContent.java b/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestUrlContent.java deleted file mode 100755 index 6e291bf..0000000 --- a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_TestUrlContent.java +++ /dev/null @@ -1,74 +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.junit.*; - -public class CT_TestUrlContent { - - private static String URL = "/testUrlContent"; - private static RestClient client; - - @BeforeClass - public static void beforeClass() { - client = new TestRestClient().setHeader("Accept", "text/plain"); - } - - @AfterClass - public static void afterClass() { - client.closeQuietly(); - } - - //==================================================================================================== - // Test URL &Content parameter containing a String - //==================================================================================================== - @Test - public void testString() throws Exception { - String r; - r = client.doGet(URL + "/testString?content=\'xxx\'&Content-Type=text/json").getResponseAsString(); - assertEquals("class=java.lang.String, value=xxx", r); - } - - //==================================================================================================== - // Test URL &Content parameter containing an Enum - //==================================================================================================== - @Test - public void testEnum() throws Exception { - String r; - r = client.doGet(URL + "/testEnum?content='X1'&Content-Type=text/json").getResponseAsString(); - assertEquals("class=org.apache.juneau.server.TestUrlContent$TestEnum, value=X1", r); - } - - //==================================================================================================== - // Test URL &Content parameter containing a Bean - //==================================================================================================== - @Test - public void testBean() throws Exception { - String r; - r = client.doGet(URL + "/testBean?content=%7Bf1:1,f2:'foobar'%7D&Content-Type=text/json").getResponseAsString(); - assertEquals("class=org.apache.juneau.server.TestUrlContent$TestBean, value={f1:1,f2:'foobar'}", r); - } - - //==================================================================================================== - // Test URL &Content parameter containing an int - //==================================================================================================== - @Test - public void testInt() throws Exception { - String r; - r = client.doGet(URL + "/testInt?content=123&Content-Type=text/json").getResponseAsString(); - assertEquals("class=java.lang.Integer, value=123", r); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_UrlPathPattern.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_UrlPathPattern.java b/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_UrlPathPattern.java deleted file mode 100755 index d4fb434..0000000 --- a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/CT_UrlPathPattern.java +++ /dev/null @@ -1,39 +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.*; - -import org.apache.juneau.json.*; -import org.junit.*; - -public class CT_UrlPathPattern { - @Test - public void testComparison() throws Exception { - List<UrlPathPattern> l = new LinkedList<UrlPathPattern>(); - - l.add(new UrlPathPattern("/foo")); - l.add(new UrlPathPattern("/foo/*")); - l.add(new UrlPathPattern("/foo/bar")); - l.add(new UrlPathPattern("/foo/bar/*")); - l.add(new UrlPathPattern("/foo/{id}")); - l.add(new UrlPathPattern("/foo/{id}/*")); - l.add(new UrlPathPattern("/foo/{id}/bar")); - l.add(new UrlPathPattern("/foo/{id}/bar/*")); - - Collections.sort(l); - assertEquals("['/foo/bar','/foo/bar/*','/foo/{id}/bar','/foo/{id}/bar/*','/foo/{id}','/foo/{id}/*','/foo','/foo/*']", JsonSerializer.DEFAULT_LAX.serialize(l)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/Constants.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/Constants.java b/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/Constants.java deleted file mode 100755 index c6c38ec..0000000 --- a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/Constants.java +++ /dev/null @@ -1,53 +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.net.*; - - -public class Constants { - - private static String juneauSampleUrl = System.getProperty("JUNO_SAMPLE_URL", "http://localhost:10000"); - private static URI juneauSampleUri = (juneauSampleUrl == null ? null : URI.create(juneauSampleUrl)); - - /** - * Returns the value of the "JUNO_SAMPLE_URL" system property, or throws a {@link RuntimeException} - * if it's not set. - */ - public static String getJuneauSamplesUrl() { - if (juneauSampleUrl == null) - throw new RuntimeException("'JUNO_SAMPLE_URL' system property not set to URL of juneau.sample.war location."); - return juneauSampleUrl; - } - - public static URI getJuneauSamplesUri() { - if (juneauSampleUri == null) - throw new RuntimeException("'JUNO_SAMPLE_URL' system property not set to URL of juneau.sample.war location."); - return juneauSampleUri; - } - - private static String juneauServerTestUrl = System.getProperty("JUNO_SERVER_TEST_URL", "http://localhost:10001"); - private static URI juneauServerTestUri = (juneauServerTestUrl == null ? null : URI.create(juneauServerTestUrl)); - - public static String getServerTestUrl() { - if (juneauServerTestUrl == null) - throw new RuntimeException("'JUNO_SERVER_TEST_URL' system property not set to URL of juneau.sample.war location."); - return juneauServerTestUrl; - } - - public static URI getServerTestUri() { - if (juneauServerTestUri == null) - throw new RuntimeException("'JUNO_SERVER_TEST_URL' system property not set to URL of juneau.sample.war location."); - return juneauServerTestUri; - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/DTOs.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/DTOs.java b/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/DTOs.java deleted file mode 100755 index bf3f2f1..0000000 --- a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/DTOs.java +++ /dev/null @@ -1,136 +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.util.*; - -import org.apache.juneau.urlencoding.annotation.*; - -public class DTOs { - - public static class A { - public String a; - public int b; - public boolean c; - - public static A create() { - A t = new A(); - t.a = "a"; - t.b = 1; - t.c = true; - return t; - } - - } - - @SuppressWarnings("serial") - public static class B { - public String[] f1; - public List<String> f2; - public int[] f3; - public List<Integer> f4; - public String[][] f5; - public List<String[]> f6; - public A[] f7; - public List<A> f8; - public A[][] f9; - public List<List<A>> f10; - - private String[] f11; - private List<String> f12; - private int[] f13; - private List<Integer> f14; - private String[][] f15; - private List<String[]> f16; - private A[] f17; - private List<A> f18; - private A[][] f19; - private List<List<A>> f20; - - public String[] getF11() { return f11; } - public List<String> getF12() { return f12; } - public int[] getF13() { return f13; } - public List<Integer> getF14() { return f14; } - public String[][] getF15() { return f15; } - public List<String[]> getF16() { return f16; } - public A[] getF17() { return f17; } - public List<A> getF18() { return f18; } - public A[][] getF19() { return f19; } - public List<List<A>> getF20() { return f20; } - - public void setF11(String[] f11) { this.f11 = f11; } - public void setF12(List<String> f12) { this.f12 = f12; } - public void setF13(int[] f13) { this.f13 = f13; } - public void setF14(List<Integer> f14) { this.f14 = f14; } - public void setF15(String[][] f15) { this.f15 = f15; } - public void setF16(List<String[]> f16) { this.f16 = f16; } - public void setF17(A[] f17) { this.f17 = f17; } - public void setF18(List<A> f18) { this.f18 = f18; } - public void setF19(A[][] f19) { this.f19 = f19; } - public void setF20(List<List<A>> f20) { this.f20 = f20; } - - static B create() { - B t = new B(); - t.f1 = new String[]{"a","b"}; - t.f2 = new ArrayList<String>(){{add("c");add("d");}}; - t.f3 = new int[]{1,2}; - t.f4 = new ArrayList<Integer>(){{add(3);add(4);}}; - t.f5 = new String[][]{{"e","f"},{"g","h"}}; - t.f6 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}}; - t.f7 = new A[]{A.create(),A.create()}; - t.f8 = new ArrayList<A>(){{add(A.create());add(A.create());}}; - t.f9 = new A[][]{{A.create()},{A.create()}}; - t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}}; - t.setF11(new String[]{"a","b"}); - t.setF12(new ArrayList<String>(){{add("c");add("d");}}); - t.setF13(new int[]{1,2}); - t.setF14(new ArrayList<Integer>(){{add(3);add(4);}}); - t.setF15(new String[][]{{"e","f"},{"g","h"}}); - t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}}); - t.setF17(new A[]{A.create(),A.create()}); - t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}}); - t.setF19(new A[][]{{A.create()},{A.create()}}); - t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}}); - return t; - } - } - - @UrlEncoding(expandedParams=true) - public static class C extends B { - @SuppressWarnings("serial") - static C create() { - C t = new C(); - t.f1 = new String[]{"a","b"}; - t.f2 = new ArrayList<String>(){{add("c");add("d");}}; - t.f3 = new int[]{1,2}; - t.f4 = new ArrayList<Integer>(){{add(3);add(4);}}; - t.f5 = new String[][]{{"e","f"},{"g","h"}}; - t.f6 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}}; - t.f7 = new A[]{A.create(),A.create()}; - t.f8 = new ArrayList<A>(){{add(A.create());add(A.create());}}; - t.f9 = new A[][]{{A.create()},{A.create()}}; - t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}}; - t.setF11(new String[]{"a","b"}); - t.setF12(new ArrayList<String>(){{add("c");add("d");}}); - t.setF13(new int[]{1,2}); - t.setF14(new ArrayList<Integer>(){{add(3);add(4);}}); - t.setF15(new String[][]{{"e","f"},{"g","h"}}); - t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}}); - t.setF17(new A[]{A.create(),A.create()}); - t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}}); - t.setF19(new A[][]{{A.create()},{A.create()}}); - t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}}); - return t; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/2c3a7cb5/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/TestRestClient.java ---------------------------------------------------------------------- diff --git a/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/TestRestClient.java b/com.ibm.team.juno.server.test/src/test/java/org/apache/juneau/server/TestRestClient.java deleted file mode 100755 index 5ea3b37..0000000 --- a/com.ibm.team.juno.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; - } - } -}
