http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/TransformsTest.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/TransformsTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/TransformsTest.java new file mode 100644 index 0000000..3d405c4 --- /dev/null +++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/TransformsTest.java @@ -0,0 +1,63 @@ +// *************************************************************************************************************************** +// * 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-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrisTest.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrisTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrisTest.java new file mode 100644 index 0000000..48f3ba6 --- /dev/null +++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrisTest.java @@ -0,0 +1,432 @@ +// *************************************************************************************************************************** +// * 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-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrlContentTest.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrlContentTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrlContentTest.java new file mode 100644 index 0000000..0f03f94 --- /dev/null +++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrlContentTest.java @@ -0,0 +1,65 @@ +// *************************************************************************************************************************** +// * 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-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrlPathPatternTest.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrlPathPatternTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrlPathPatternTest.java new file mode 100644 index 0000000..5e19738 --- /dev/null +++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/UrlPathPatternTest.java @@ -0,0 +1,40 @@ +// *************************************************************************************************************************** +// * 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-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java new file mode 100644 index 0000000..794b617 --- /dev/null +++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java @@ -0,0 +1,84 @@ +// *************************************************************************************************************************** +// * 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-microservice/pom.xml ---------------------------------------------------------------------- diff --git a/juneau-microservice/pom.xml b/juneau-microservice/pom.xml new file mode 100644 index 0000000..1892c3a --- /dev/null +++ b/juneau-microservice/pom.xml @@ -0,0 +1,40 @@ +<?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> + + <parent> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau</artifactId> + <version>6.3.2-incubating-SNAPSHOT</version> + </parent> + + <artifactId>juneau-microservice</artifactId> + <packaging>pom</packaging> + <name>Apache Juneau - Microservice APIs</name> + <description>Apache Juneau Microservice APIs</description> + + <modules> + <module>juneau-microservice-server</module> + <module>juneau-microservice-template</module> + <module>juneau-microservice-test</module> + </modules> + +</project> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-releng/juneau-all/pom.xml ---------------------------------------------------------------------- diff --git a/juneau-releng/juneau-all/pom.xml b/juneau-releng/juneau-all/pom.xml index 66f7275..6602f83 100644 --- a/juneau-releng/juneau-all/pom.xml +++ b/juneau-releng/juneau-all/pom.xml @@ -52,7 +52,7 @@ </dependency> <dependency> <groupId>org.apache.juneau</groupId> - <artifactId>juneau-microservice</artifactId> + <artifactId>juneau-microservice-server</artifactId> <version>${project.version}</version> </dependency> </dependencies> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/.DS_Store ---------------------------------------------------------------------- diff --git a/juneau-rest/.DS_Store b/juneau-rest/.DS_Store new file mode 100644 index 0000000..ffe0c74 Binary files /dev/null and b/juneau-rest/.DS_Store differ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/.classpath ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/.classpath b/juneau-rest/juneau-microservice-template/.classpath deleted file mode 100755 index fd7ad7f..0000000 --- a/juneau-rest/juneau-microservice-template/.classpath +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" output="target/classes" path="src/main/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="output" path="target/classes"/> -</classpath> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/.gitignore ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/.gitignore b/juneau-rest/juneau-microservice-template/.gitignore deleted file mode 100644 index d274d47..0000000 --- a/juneau-rest/juneau-microservice-template/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -/.settings/ -/.DS_Store http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/.project ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/.project b/juneau-rest/juneau-microservice-template/.project deleted file mode 100755 index 5036cd8..0000000 --- a/juneau-rest/juneau-microservice-template/.project +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>juneau-microservice-template</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.m2e.core.maven2Builder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.m2e.core.maven2Nature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - <nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature> - </natures> -</projectDescription> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/META-INF/MANIFEST.MF ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/META-INF/MANIFEST.MF b/juneau-rest/juneau-microservice-template/META-INF/MANIFEST.MF deleted file mode 100755 index 22d1630..0000000 --- a/juneau-rest/juneau-microservice-template/META-INF/MANIFEST.MF +++ /dev/null @@ -1,29 +0,0 @@ -Copyright: - *************************************************************************************************************************** - * 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. * - *************************************************************************************************************************** -Manifest-Version: 1.0 -Main-Class: org.apache.juneau.microservice.RestMicroservice -Rest-Resources: - org.apache.juneau.microservice.sample.RootResources -Main-ConfigFile: microservice.cfg -Class-Path: - lib/commons-codec-1.9.jar - lib/commons-io-1.2.jar - lib/commons-logging-1.1.1.jar - lib/httpclient-4.5.jar - lib/httpcore-4.4.1.jar - lib/httpmime-4.5.jar - lib/javax.servlet-api-3.0.jar - lib/jetty-all-8.1.0.jar - lib/juneau-all-5.2.jar - lib/org.apache.commons.fileupload_1.3.1.jar \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/build.xml ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/build.xml b/juneau-rest/juneau-microservice-template/build.xml deleted file mode 100644 index 814a0a5..0000000 --- a/juneau-rest/juneau-microservice-template/build.xml +++ /dev/null @@ -1,55 +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. * - *************************************************************************************************************************** ---> -<!-- - Provides a VERY basic ANT script for creating a microservice zip file. ---> -<project name='Microservice' default='Microservice.Build'> - - <target name='Microservice.Build'> - <tstamp/> - <loadproperties srcFile='build.properties'/> - - <path id='classpath'> - <fileset dir='lib' includes='*.jar'/> - </path> - - <delete dir='build' quiet='true'/> - - <copy todir='build/bin'> - <fileset dir='src' excludes='**/*.java'/> - </copy> - <copy todir='build/microservice'> - <fileset dir='.' includes='*.cfg,lib/**'/> - </copy> - - <javac srcdir='src' destdir='build/bin' fork='true' source='1.6' target='1.6' debug='true' includeantruntime='false'> - <classpath refid='classpath'/> - </javac> - - <jar jarfile='build/microservice/${jar}' basedir='build/bin' duplicate='fail' level='9' manifest='META-INF/MANIFEST.MF'> - <manifest> - <attribute name='Built-By' value='${user.name}'/> - <attribute name='Build-Date' value='${TODAY}'/> - <attribute name='Bundle-Version' value='${version}'/> - </manifest> - </jar> - - <zip basedir='build/microservice' destfile='build/${zip}'/> - - <delete dir='build/bin' quiet='true'/> - </target> - -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/dependency-reduced-pom.xml ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/dependency-reduced-pom.xml b/juneau-rest/juneau-microservice-template/dependency-reduced-pom.xml deleted file mode 100644 index e5c46a1..0000000 --- a/juneau-rest/juneau-microservice-template/dependency-reduced-pom.xml +++ /dev/null @@ -1,66 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<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/maven-v4_0_0.xsd"> - <parent> - <artifactId>juneau-rest</artifactId> - <groupId>org.apache.juneau</groupId> - <version>6.3.2-incubating-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>juneau-microservice-template</artifactId> - <name>Apache Juneau Microservice Template</name> - <description>A template project developers use to start with to create a microservice.</description> - <build> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.6</source> - <target>1.6</target> - </configuration> - </plugin> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <mainClass>org.apache.juneau.microservice.RestMicroservice</mainClass> - </manifest> - <manifestEntries> - <Rest-Resources>org.apache.juneau.microservice.sample.RootResources</Rest-Resources> - <Main-ConfigFile>microservice.cfg</Main-ConfigFile> - </manifestEntries> - </archive> - </configuration> - </plugin> - <plugin> - <artifactId>maven-shade-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - <configuration> - <filters> - <filter> - <artifact>*:*</artifact> - <excludes> - <exclude>META-INF/*.SF</exclude> - <exclude>META-INF/*.RSA</exclude> - <exclude>META-INF/*.INF</exclude> - </excludes> - </filter> - </filters> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - <properties> - <juneau.version>6.3.2-incubating-SNAPSHOT</juneau.version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> -</project> - http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/jetty.xml ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/jetty.xml b/juneau-rest/juneau-microservice-template/jetty.xml deleted file mode 100644 index e5f7543..0000000 --- a/juneau-rest/juneau-microservice-template/jetty.xml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"> -<!-- - *************************************************************************************************************************** - * 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. * - *************************************************************************************************************************** ---> - -<Configure id="ExampleServer" class="org.eclipse.jetty.server.Server"> - - <Set name="connectors"> - <Array type="org.eclipse.jetty.server.Connector"> - <Item> - <New class="org.eclipse.jetty.server.ServerConnector"> - <Arg> - <Ref refid="ExampleServer" /> - </Arg> - <Set name="port">10000</Set> - </New> - </Item> - </Array> - </Set> - - <New id="context" class="org.eclipse.jetty.servlet.ServletContextHandler"> - <Set name="contextPath">/</Set> - <Call name="addServlet"> - <Arg>org.apache.juneau.microservice.sample.RootResources</Arg> - <Arg>/*</Arg> - </Call> - <Set name="sessionHandler"> - <New class="org.eclipse.jetty.server.session.SessionHandler" /> - </Set> - </New> - - <Set name="handler"> - <New class="org.eclipse.jetty.server.handler.HandlerCollection"> - <Set name="handlers"> - <Array type="org.eclipse.jetty.server.Handler"> - <Item> - <Ref refid="context" /> - </Item> - <Item> - <New class="org.eclipse.jetty.server.handler.DefaultHandler" /> - </Item> - </Array> - </Set> - </New> - </Set> -</Configure> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/microservice.cfg ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/microservice.cfg b/juneau-rest/juneau-microservice-template/microservice.cfg deleted file mode 100755 index e5fdd9a..0000000 --- a/juneau-rest/juneau-microservice-template/microservice.cfg +++ /dev/null @@ -1,118 +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. * -# *************************************************************************************************************************** - -#================================================================================ -# Basic configuration file for SaaS microservices -# Subprojects can use this as a starting point. -#================================================================================ - -#================================================================================ -# Services -#================================================================================ -[Services] -REST = org.apache.juneau.microservice.rest.RestApplication - -#================================================================================ -# REST settings -#================================================================================ -[REST] - -jettyXml = jetty.xml - -# Stylesheet to use for HTML views. -# The default options are: -# - servlet:/styles/juneau.css -# - servlet:/styles/devops.css -# Other stylesheets can be referenced relative to the servlet package or working directory. -stylesheet = servlet:/styles/devops.css - -# What to do when the config file is saved. -# Possible values: -# NOTHING - Don't do anything. (default) -# RESTART_SERVER - Restart the Jetty server. -# RESTART_SERVICE - Shutdown and exit with code '3'. -saveConfigAction = RESTART_SERVER - -#================================================================================ -# Logger settings -# See FileHandler Java class for details. -#================================================================================ -[Logging] - -# The directory where to create the log file. -# Default is "." -logDir = logs - -# The name of the log file to create for the main logger. -# The logDir and logFile make up the pattern that's passed to the FileHandler -# constructor. -# If value is not specified, then logging to a file will not be set up. -logFile = microservice.%g.log - -# Whether to append to the existing log file or create a new one. -# Default is false. -append = - -# The SimpleDateFormat format to use for dates. -# Default is "yyyy.MM.dd hh:mm:ss". -dateFormat = - -# The log message format. -# The value can contain any of the following variables: -# {date} - The date, formatted per dateFormat. -# {class} - The class name. -# {method} - The method name. -# {logger} - The logger name. -# {level} - The log level name. -# {msg} - The log message. -# {threadid} - The thread ID. -# {exception} - The localized exception message. -# Default is "[{date} {level}] {msg}%n". -format = - -# The maximum log file size. -# Suffixes available for numbers. -# See ConfigFile.getInt(String,int) for details. -# Default is 1M. -limit = 10M - -# Max number of log files. -# Default is 1. -count = 5 - -# Default log levels. -# Keys are logger names. -# Values are serialized Level POJOs. -levels = { org.apache.juneau:'INFO' } - -# Only print unique stack traces once and then refer to them by a simple 8 character hash identifier. -# Useful for preventing log files from filling up with duplicate stack traces. -# Default is false. -useStackTraceHashes = true - -# The default level for the console logger. -# Default is WARNING. -consoleLevel = - -#================================================================================ -# System properties -#-------------------------------------------------------------------------------- -# These are arbitrary system properties that are set during startup. -#================================================================================ -[SystemProperties] - -# Configure Jetty for StdErrLog Logging -org.eclipse.jetty.util.log.class = org.eclipse.jetty.util.log.StrErrLog - -# Jetty logging level -org.eclipse.jetty.LEVEL = WARN http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/pom.xml ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/pom.xml b/juneau-rest/juneau-microservice-template/pom.xml deleted file mode 100644 index d376802..0000000 --- a/juneau-rest/juneau-microservice-template/pom.xml +++ /dev/null @@ -1,107 +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. * - *************************************************************************************************************************** ---> -<!-- - This project is meant to be used as a starting point for developers to use in creating their own REST microservices. - It creates a parent REST interface on port 10000 with a single child hello-world resource. - This POM is likewise meant to be used as a starting point for developers. It creates an uber-jar - to run the microserice from the command line. Copy the jar as well as the .cfg file and start it - with java -jar juneau-microservice-template-1.0.0.jar microservice.cfg - The group/artifact/version information is meant to be overwritten by developers to match their own needs. ---> -<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/xsd/maven-4.0.0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.juneau</groupId> - <artifactId>juneau-rest</artifactId> - <version>6.3.2-incubating-SNAPSHOT</version> - </parent> - - <artifactId>juneau-microservice-template</artifactId> - <name>Apache Juneau Microservice Template</name> - <description>A template project developers use to start with to create a microservice.</description> - - <properties> - <juneau.version>6.3.2-incubating-SNAPSHOT</juneau.version> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.juneau</groupId> - <artifactId>juneau-microservice</artifactId> - <version>${juneau.version}</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.6</source> - <target>1.6</target> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <mainClass>org.apache.juneau.microservice.RestMicroservice - </mainClass> - </manifest> - <manifestEntries> - <Rest-Resources>org.apache.juneau.microservice.sample.RootResources - </Rest-Resources> - <Main-ConfigFile>microservice.cfg</Main-ConfigFile> - </manifestEntries> - </archive> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-shade-plugin</artifactId> - <version>3.0.0</version> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>shade</goal> - </goals> - <configuration> - <filters> - <filter> - <artifact>*:*</artifact> - <excludes> - <exclude>META-INF/*.SF</exclude> - <exclude>META-INF/*.RSA</exclude> - <exclude>META-INF/*.INF</exclude> <!-- This one may not be required --> - </excludes> - </filter> - </filters> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/HelloWorldResource.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/HelloWorldResource.java b/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/HelloWorldResource.java deleted file mode 100755 index 04edc2e..0000000 --- a/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/HelloWorldResource.java +++ /dev/null @@ -1,35 +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.microservice.sample; - -import org.apache.juneau.microservice.Resource; -import org.apache.juneau.rest.annotation.RestMethod; -import org.apache.juneau.rest.annotation.RestResource; - -/** - * Sample REST resource that prints out a simple "Hello world!" message. - */ -@RestResource( - title="Hello World example", - path="/helloworld", - description="Simplest possible REST resource" -) -public class HelloWorldResource extends Resource { - private static final long serialVersionUID = 1L; - - /** GET request handler */ - @RestMethod(name="GET", path="/*") - public String sayHello() { - return "Hello world!"; - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/RootResources.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/RootResources.java b/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/RootResources.java deleted file mode 100755 index 140baaf..0000000 --- a/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/RootResources.java +++ /dev/null @@ -1,41 +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.microservice.sample; - -import static org.apache.juneau.html.HtmlDocSerializerContext.HTMLDOC_links; - -import org.apache.juneau.microservice.ResourceGroup; -import org.apache.juneau.microservice.resources.ConfigResource; -import org.apache.juneau.microservice.resources.LogsResource; -import org.apache.juneau.rest.annotation.Property; -import org.apache.juneau.rest.annotation.RestResource; - -/** - * Root microservice page. - */ -@RestResource( - path="/", - title="Juneau Microservice Template", - description="Template for creating REST microservices", - properties={ - @Property(name=HTMLDOC_links, value="{options:'?method=OPTIONS'}") - }, - children={ - HelloWorldResource.class, - ConfigResource.class, - LogsResource.class - } -) -public class RootResources extends ResourceGroup { - private static final long serialVersionUID = 1L; -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/nls/Messages.properties ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/nls/Messages.properties b/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/nls/Messages.properties deleted file mode 100755 index d4a7d06..0000000 --- a/juneau-rest/juneau-microservice-template/src/main/java/org/apache/juneau/microservice/sample/nls/Messages.properties +++ /dev/null @@ -1,19 +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. -# * -# *************************************************************************************************************************** - -#-------------------------------------------------------------------------------- -# RootResources -#-------------------------------------------------------------------------------- -RootResources.title = Juneau Microservice Template -RootResources.description = Template for creating REST microservices http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice-template/src/test/java/.gitignore ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice-template/src/test/java/.gitignore b/juneau-rest/juneau-microservice-template/src/test/java/.gitignore deleted file mode 100644 index 8a0051a..0000000 --- a/juneau-rest/juneau-microservice-template/src/test/java/.gitignore +++ /dev/null @@ -1,12 +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. * - *************************************************************************************************************************** http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice/.classpath ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice/.classpath b/juneau-rest/juneau-microservice/.classpath deleted file mode 100644 index b4c1fc3..0000000 --- a/juneau-rest/juneau-microservice/.classpath +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/classes" path="src/main/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="output" path="target/classes"/> -</classpath> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/750916a9/juneau-rest/juneau-microservice/.gitignore ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-microservice/.gitignore b/juneau-rest/juneau-microservice/.gitignore deleted file mode 100644 index d274d47..0000000 --- a/juneau-rest/juneau-microservice/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/target/ -/.settings/ -/.DS_Store
