http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrisTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrisTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrisTest.java deleted file mode 100755 index eb67231..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/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.test; - -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; - } -}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlContentTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlContentTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlContentTest.java deleted file mode 100755 index 4de26b9..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlContentTest.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.test; - -import static org.junit.Assert.*; - -import org.apache.juneau.client.*; -import org.junit.*; - -public class UrlContentTest { - - 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 &Body parameter containing a String - //==================================================================================================== - @Test - public void testString() throws Exception { - String r; - r = client.doGet(URL + "/testString?body=\'xxx\'&Content-Type=text/json").getResponseAsString(); - assertEquals("class=java.lang.String, value=xxx", r); - } - - //==================================================================================================== - // Test URL &Body parameter containing an Enum - //==================================================================================================== - @Test - public void testEnum() throws Exception { - String r; - r = client.doGet(URL + "/testEnum?body='X1'&Content-Type=text/json").getResponseAsString(); - assertEquals("class=org.apache.juneau.server.test.UrlContentResource$TestEnum, value=X1", r); - } - - //==================================================================================================== - // Test URL &Body parameter containing a Bean - //==================================================================================================== - @Test - public void testBean() throws Exception { - String r; - r = client.doGet(URL + "/testBean?body=%7Bf1:1,f2:'foobar'%7D&Content-Type=text/json").getResponseAsString(); - assertEquals("class=org.apache.juneau.server.test.UrlContentResource$TestBean, value={f1:1,f2:'foobar'}", r); - } - - //==================================================================================================== - // Test URL &Body parameter containing an int - //==================================================================================================== - @Test - public void testInt() throws Exception { - String r; - r = client.doGet(URL + "/testInt?body=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/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlPathPatternTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlPathPatternTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlPathPatternTest.java deleted file mode 100755 index 42d367c..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlPathPatternTest.java +++ /dev/null @@ -1,40 +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.test; - -import static org.junit.Assert.*; - -import java.util.*; - -import org.apache.juneau.json.*; -import org.apache.juneau.server.*; -import org.junit.*; - -public class UrlPathPatternTest { - @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/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/_TestSuite.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/_TestSuite.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/_TestSuite.java deleted file mode 100644 index ebb6728..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/_TestSuite.java +++ /dev/null @@ -1,92 +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.test; - -import java.util.*; - -import org.apache.juneau.microservice.*; -import org.junit.*; -import org.junit.runner.*; -import org.junit.runners.*; -import org.junit.runners.Suite.*; - -/** - * Runs all the testcases in this project. - * Starts a REST service running org.apache.juneau.server.test.Root on port 10001. - * Stops the REST service after running the tests. - */ -@RunWith(Suite.class) -@SuiteClasses({ - AcceptCharsetTest.class, - BeanContextPropertiesTest.class, - CallbackStringsTest.class, - CharsetEncodingsTest.class, - ClientVersionTest.class, - ConfigTest.class, - ContentTest.class, - DefaultContentTypesTest.class, - ErrorConditionsTest.class, - GroupsTest.class, - GzipTest.class, - InheritanceTest.class, - JacocoDummyTest.class, - LargePojosTest.class, - MessagesTest.class, - NlsPropertyTest.class, - NlsTest.class, - NoParserInputTest.class, - OnPostCallTest.class, - OnPreCallTest.class, - OptionsWithoutNlsTest.class, - OverlappingMethodsTest.class, - ParamsTest.class, - ParsersTest.class, - PathsTest.class, - PathTest.class, - PropertiesTest.class, - RestClientTest.class, - RestUtilsTest.class, - SerializersTest.class, - StaticFilesTest.class, - TransformsTest.class, - UrisTest.class, - UrlContentTest.class, - UrlPathPatternTest.class -}) -public class _TestSuite { - static Microservice microservice; - - @BeforeClass - public static void setUp() { - try { - Locale.setDefault(Locale.US); - microservice = new RestMicroservice() - .setConfig("juneau-server-test.cfg", false) - .setManifestContents( - "Test-Entry: test-value" - ); - microservice.start(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @AfterClass - public static void tearDown() { - try { - microservice.stop(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server/.gitignore ---------------------------------------------------------------------- diff --git a/juneau-server/.gitignore b/juneau-server/.gitignore deleted file mode 100644 index b5ffa7e..0000000 --- a/juneau-server/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -/.settings/ -/.classpath http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server/.project ---------------------------------------------------------------------- diff --git a/juneau-server/.project b/juneau-server/.project deleted file mode 100644 index c707360..0000000 --- a/juneau-server/.project +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - *************************************************************************************************************************** - * 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. * - *************************************************************************************************************************** ---> -<projectDescription> - <name>juneau-server</name> - <comment>REST servlet API. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment> - <projects> - <project>juneau-core</project> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server/pom.xml ---------------------------------------------------------------------- diff --git a/juneau-server/pom.xml b/juneau-server/pom.xml deleted file mode 100644 index 626f12f..0000000 --- a/juneau-server/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - *************************************************************************************************************************** - * 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. * - *************************************************************************************************************************** ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - - <modelVersion>4.0.0</modelVersion> - <artifactId>juneau-server</artifactId> - <name>Apache Juneau Server</name> - <description>REST servlet API</description> - <packaging>bundle</packaging> - - <parent> - <groupId>org.apache.juneau</groupId> - <artifactId>juneau</artifactId> - <version>6.0.2-incubating-SNAPSHOT</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <dependencies> - <dependency> - <groupId>org.apache.juneau</groupId> - <artifactId>juneau-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>javax.ws.rs</groupId> - <artifactId>jsr311-api</artifactId> - <optional>true</optional> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - </dependency> - </dependencies> - - <properties> - <!-- Skip javadoc generation since we generate them in the aggregate pom --> - <maven.javadoc.skip>true</maven.javadoc.skip> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <version>3.0.1</version> - <executions> - <execution> - <id>attach-sources</id> - <phase>verify</phase> - <goals> - <goal>jar-no-fork</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <version>3.2.0</version> - <extensions>true</extensions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>2.19.1</version> - <configuration> - <includes> - <include>**/*Test.class</include> - </includes> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server/src/main/java/org/apache/juneau/server/ClientVersionMatcher.java ---------------------------------------------------------------------- diff --git a/juneau-server/src/main/java/org/apache/juneau/server/ClientVersionMatcher.java b/juneau-server/src/main/java/org/apache/juneau/server/ClientVersionMatcher.java deleted file mode 100644 index f8bf0ca..0000000 --- a/juneau-server/src/main/java/org/apache/juneau/server/ClientVersionMatcher.java +++ /dev/null @@ -1,50 +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 org.apache.juneau.internal.*; -import org.apache.juneau.server.annotation.*; - -/** - * Specialized matcher for matching client versions. - * <p> - * See {@link RestResource#clientVersionHeader} and {@link RestMethod#clientVersion} for more info. - */ -public class ClientVersionMatcher extends RestMatcherReflecting { - - private final String clientVersionHeader; - private final VersionRange range; - - /** - * Constructor. - * - * @param servlet The servlet. - * @param javaMethod The version string that the client version must match. - */ - protected ClientVersionMatcher(RestServlet servlet, java.lang.reflect.Method javaMethod) { - super(servlet, javaMethod); - this.clientVersionHeader = servlet.getClientVersionHeader(); - RestMethod m = javaMethod.getAnnotation(RestMethod.class); - range = new VersionRange(m.clientVersion()); - } - - @Override /* RestMatcher */ - public boolean matches(RestRequest req) { - return range.matches(req.getHeader(clientVersionHeader)); - } - - @Override /* RestMatcher */ - public boolean mustMatch() { - return true; - } -}
