Repository: incubator-juneau Updated Branches: refs/heads/master 495c648d1 -> 750916a91
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/TransformsTest.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/TransformsTest.java b/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/TransformsTest.java deleted file mode 100644 index 3d405c4..0000000 --- a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/TransformsTest.java +++ /dev/null @@ -1,63 +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.rest.test; - -import static org.junit.Assert.*; - -import org.apache.juneau.rest.client.*; -import org.junit.*; - -public class TransformsTest extends RestTestcase { - - 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 = TestMicroservice.DEFAULT_CLIENT; - 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); - } - - //==================================================================================================== - // Test method transform overrides class transform - // Should return "A3-1". - //==================================================================================================== - @Test - public void testMethodTransformOverridesClassTransform() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - 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); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrisTest.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrisTest.java b/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrisTest.java deleted file mode 100644 index 48f3ba6..0000000 --- a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrisTest.java +++ /dev/null @@ -1,432 +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.rest.test; - -import static org.junit.Assert.*; - -import org.apache.juneau.*; -import org.apache.juneau.rest.client.*; -import org.junit.*; - -/** - * Verifies that all the RestRequest.getXXX() methods involving URIs work correctly. - */ -public class UrisTest extends RestTestcase { - - private static int port = TestMicroservice.getURI().getPort(); // 9443 - private static String path = TestMicroservice.getURI().getPath(); // /jazz/juneau/sample - - //==================================================================================================== - // testRoot - http://localhost:8080/sample/testuris - //==================================================================================================== - @Test - public void testRoot() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - 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(path + "/testuris", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris", r.getString("servletURI")); - } - - //==================================================================================================== - // testChild - http://localhost:8080/sample/testuris/child - //==================================================================================================== - @Test - public void testChild() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - 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(path + "/testuris/child", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child", r.getString("servletURI")); - } - - //==================================================================================================== - // testGrandChild - http://localhost:8080/sample/testuris/child/grandchild - //==================================================================================================== - @Test - public void testGrandChild() throws Exception { - RestClient client = TestMicroservice.DEFAULT_CLIENT; - 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - - //-------------------------------------------------------------------------------- - // 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(path + "/testuris/child/grandchild", r.getString("servletURI")); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrlContentTest.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrlContentTest.java b/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrlContentTest.java deleted file mode 100644 index 0f03f94..0000000 --- a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrlContentTest.java +++ /dev/null @@ -1,65 +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.rest.test; - -import static org.junit.Assert.*; - -import org.apache.juneau.rest.client.*; -import org.junit.*; - -public class UrlContentTest extends RestTestcase { - - private static String URL = "/testUrlContent"; - private RestClient client = TestMicroservice.DEFAULT_CLIENT_PLAINTEXT; - - - //==================================================================================================== - // 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.rest.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.rest.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/750916a9/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrlPathPatternTest.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrlPathPatternTest.java b/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/UrlPathPatternTest.java deleted file mode 100644 index 5e19738..0000000 --- a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/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.rest.test; - -import static org.junit.Assert.*; - -import java.util.*; - -import org.apache.juneau.json.*; -import org.apache.juneau.rest.*; -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("[{patternString:'/foo/bar',vars:[]},{patternString:'/foo/bar/*',vars:[]},{patternString:'/foo/{id}/bar',vars:['id']},{patternString:'/foo/{id}/bar/*',vars:['id']},{patternString:'/foo/{id}',vars:['id']},{patternString:'/foo/{id}/*',vars:['id']},{patternString:'/foo',vars:[]},{patternString:'/foo/*',vars:[]}]", JsonSerializer.DEFAULT_LAX.builder().sortProperties(true).build().serialize(l)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java b/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java deleted file mode 100644 index 794b617..0000000 --- a/juneau-rest/juneau-rest-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java +++ /dev/null @@ -1,84 +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.rest.test; - -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.rest.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, - ClientFuturesTest.class, - ClientVersionTest.class, - ConfigTest.class, - ContentTest.class, - DefaultContentTypesTest.class, - ErrorConditionsTest.class, - FormDataTest.class, - GroupsTest.class, - GzipTest.class, - HeadersTest.class, - HtmlDocTest.class, - HtmlDocLinksTest.class, - InheritanceTest.class, - InterfaceProxyTest.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, - PathVariableTest.class, - PropertiesTest.class, - QueryTest.class, - RequestBeanProxyTest.class, - RestClientTest.class, - RestUtilsTest.class, - SerializersTest.class, - StaticFilesTest.class, - ThirdPartyProxyTest.class, - TransformsTest.class, - UrisTest.class, - UrlContentTest.class, - UrlPathPatternTest.class -}) -public class _TestSuite { - - @BeforeClass - public static void setUp() { - TestMicroservice.startMicroservice(); - } - - @AfterClass - public static void tearDown() { - TestMicroservice.stopMicroservice(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/pom.xml ---------------------------------------------------------------------- diff --git a/juneau-rest/pom.xml b/juneau-rest/pom.xml index b17f809..551331c 100644 --- a/juneau-rest/pom.xml +++ b/juneau-rest/pom.xml @@ -35,9 +35,6 @@ <module>juneau-rest-server</module> <module>juneau-rest-server-jaxrs</module> <module>juneau-rest-client</module> - <module>juneau-microservice</module> - <module>juneau-microservice-template</module> - <module>juneau-rest-test</module> </modules> </project> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 98e2733..a72f81d 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,7 @@ <modules> <module>juneau-core</module> <module>juneau-rest</module> + <module>juneau-microservice</module> <module>juneau-examples</module> <module>juneau-releng</module> </modules>
