http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/PathsResource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/PathsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/PathsResource.java new file mode 100755 index 0000000..5530e1a --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/PathsResource.java @@ -0,0 +1,73 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import org.apache.juneau.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; + +/** + * JUnit automated testcase resource. + * Tests the URL-related methods on RestRequest. + */ +@RestResource( + path="/testPaths", + children={ + PathsResource.A.class + } +) +public class PathsResource extends RestServletDefault { + private static final long serialVersionUID = 1L; + + @RestMethod(name="GET", path="/*") + public ObjectMap doGet1(RestRequest req, @PathRemainder String r) { + return getPaths(req).append("pathRemainder2", r).append("method",1); + } + + @RestMethod(name="GET", path="/test2/*") + public ObjectMap doGet2(RestRequest req, @PathRemainder String r) { + return getPaths(req).append("pathRemainder2", r).append("method",2); + } + + @RestResource( + path="/a" + ) + public static class A extends RestServletDefault { + private static final long serialVersionUID = 1L; + @RestMethod(name="GET", path="/*") + public ObjectMap doGet1(RestRequest req, @PathRemainder String r) { + return getPaths(req).append("pathRemainder2", r).append("method",3); + } + @RestMethod(name="GET", path="/test2/*") + public ObjectMap doGet2(RestRequest req, @PathRemainder String r) { + return getPaths(req).append("pathRemainder2", r).append("method",4); + } + } + + private static ObjectMap getPaths(RestRequest req) { + return new ObjectMap() + .append("pathInfo", req.getPathInfo()) + .append("pathInfoUndecoded", req.getPathInfoUndecoded()) + .append("pathInfoParts", req.getPathInfoParts()) + .append("pathRemainder", req.getPathRemainder()) + .append("pathRemainderUndecoded", req.getPathRemainderUndecoded()) + .append("requestURI", req.getRequestURI()) + .append("requestParentURI", req.getRequestParentURI()) + .append("requestURL", req.getRequestURL()) + .append("servletPath", req.getServletPath()) + .append("servletURI", req.getServletURI()) + .append("servletParentURI", req.getServletParentURI()) + .append("relativeServletURI", req.getRelativeServletURI()); + + } +}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/PropertiesResource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/PropertiesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/PropertiesResource.java new file mode 100755 index 0000000..198595c --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/PropertiesResource.java @@ -0,0 +1,90 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import static java.lang.String.*; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; + +/** + * JUnit automated testcase resource. + */ +@RestResource( + path="/testProperties", + properties={ + @Property(name="A1",value="a1"), + @Property(name="A2",value="a2"), + @Property(name="foo",value="bar"), + @Property(name="bar",value="baz"), + @Property(name="R1a",value="$R{requestURI}"), + @Property(name="R1b",value="$R{requestParentURI}"), + @Property(name="R2",value="$R{foo}"), + @Property(name="R3",value="$R{$R{foo}}"), + @Property(name="R4",value="$R{A1}"), + @Property(name="R5",value="$R{A2}"), + @Property(name="R6",value="$R{C}"), + } +) +public class PropertiesResource extends RestServletDefault { + private static final long serialVersionUID = 1L; + + //==================================================================================================== + // Properties defined on method. + //==================================================================================================== + @RestMethod(name="GET", path="/testPropertiesDefinedOnMethod", + properties={ + @Property(name="B1",value="b1"), + @Property(name="B2",value="b2") + }, + serializers=PropertySerializer1.class + ) + public void testPropertiesDefinedOnMethod(RestResponse res) { + res.setProperty("A2", "c"); + res.setProperty("B2", "c"); + res.setProperty("C", "c"); + res.setOutput(null); + } + + @Produces({"application/json","text/json"}) + public static class PropertySerializer1 extends WriterSerializer { + @Override /* Serializer */ + protected void doSerialize(SerializerSession session, Object output) throws Exception { + ObjectMap p = session.getProperties(); + session.getWriter().write(format("A1=%s,A2=%s,B1=%s,B2=%s,C=%s,R1a=%s,R1b=%s,R2=%s,R3=%s,R4=%s,R5=%s,R6=%s", + p.get("A1"), p.get("A2"), p.get("B1"), p.get("B2"), p.get("C"), + p.get("R1a"), p.get("R1b"), p.get("R2"), p.get("R3"), p.get("R4"), p.get("R5"), p.get("R6"))); + } + } + + //==================================================================================================== + // Make sure attributes/parameters/headers are available through ctx.getProperties(). + //==================================================================================================== + @RestMethod(name="GET", path="/testProperties/{A}", serializers=PropertySerializer2.class) + public void testProperties(RestResponse res) { + res.setOutput(null); + } + + @Produces({"application/json","text/json"}) + public static class PropertySerializer2 extends WriterSerializer { + @Override /* Serializer */ + protected void doSerialize(SerializerSession session, Object output) throws Exception { + ObjectMap p = session.getProperties(); + session.getWriter().write(format("A=%s,P=%s,H=%s", p.get("A"), p.get("P"), p.get("h"))); + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/RestClient2Resource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/RestClient2Resource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/RestClient2Resource.java new file mode 100755 index 0000000..57e8a17 --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/RestClient2Resource.java @@ -0,0 +1,36 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import java.io.*; + +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; + +/** + * JUnit automated testcase resource. + */ +@RestResource( + path="/testRestClient" +) +public class RestClient2Resource extends RestServletDefault { + private static final long serialVersionUID = 1L; + + //==================================================================================================== + // Echo response + //==================================================================================================== + @RestMethod(name="POST", path="/") + public Reader test1(RestRequest req) throws Exception { + return new StringReader(req.getInputAsString()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/Root.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/Root.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/Root.java new file mode 100755 index 0000000..9ebd621 --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/Root.java @@ -0,0 +1,71 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import org.apache.juneau.microservice.resources.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; +import org.apache.juneau.server.labels.*; + +@RestResource( + path="/", + children={ + AcceptCharsetResource.class, + BeanContextPropertiesResource.class, + CallbackStringsResource.class, + CharsetEncodingsResource.class, + ClientVersionResource.class, + ConfigResource.class, + ContentResource.class, + DefaultContentTypesResource.class, + ErrorConditionsResource.class, + TransformsResource.class, + GroupsResource.class, + GzipResource.TestGzipOff.class, + GzipResource.TestGzipOn.class, + InheritanceResource.TestEncoders.class, + InheritanceResource.TestTransforms.class, + InheritanceResource.TestParsers.class, + InheritanceResource.TestProperties.class, + InheritanceResource.TestSerializers.class, + LargePojosResource.class, + MessagesResource.Messages2Resource.class, + MessagesResource.class, + NlsResource.class, + NlsPropertyResource.class, + NoParserInputResource.class, + OnPostCallResource.class, + OnPreCallResource.class, + OptionsWithoutNlsResource.class, + OverlappingMethodsResource.class, + ParamsResource.class, + ParsersResource.class, + PathResource.class, + PathsResource.class, + PropertiesResource.class, + RestClient2Resource.class, + SerializersResource.class, + StaticFilesResource.class, + UrisResource.class, + UrlContentResource.class, + ShutdownResource.class + } +) +public class Root extends RestServletDefault { + private static final long serialVersionUID = 1L; + + @RestMethod(name="GET", path="/") + public ChildResourceDescriptions doGet(RestRequest req) { + return new ChildResourceDescriptions(this, req); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/SerializersResource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/SerializersResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/SerializersResource.java new file mode 100755 index 0000000..82230a4 --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/SerializersResource.java @@ -0,0 +1,103 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import static org.apache.juneau.server.annotation.Inherit.*; + +import org.apache.juneau.annotation.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; + +/** + * JUnit automated testcase resource. + */ +@RestResource( + path="/testSerializers", + serializers=SerializersResource.TestSerializerA.class +) +public class SerializersResource extends RestServletDefault { + private static final long serialVersionUID = 1L; + + @Produces("text/a") + public static class TestSerializerA extends WriterSerializer { + @Override /* Serializer */ + protected void doSerialize(SerializerSession session, Object o) throws Exception { + session.getWriter().write("text/a - " + o); + } + } + + @Produces("text/b") + public static class TestSerializerB extends WriterSerializer { + @Override /* Serializer */ + protected void doSerialize(SerializerSession session, Object o) throws Exception { + session.getWriter().write("text/b - " + o); + } + } + + //==================================================================================================== + // Serializer defined on class. + //==================================================================================================== + @RestMethod(name="GET", path="/testSerializerOnClass") + public String testSerializerOnClass() { + return "test1"; + } + + //==================================================================================================== + // Serializer defined on method. + //==================================================================================================== + @RestMethod(name="GET", path="/testSerializerOnMethod", serializers=TestSerializerB.class) + public String testSerializerOnMethod() { + return "test2"; + } + + //==================================================================================================== + // Serializer overridden on method. + //==================================================================================================== + @RestMethod(name="GET", path="/testSerializerOverriddenOnMethod", serializers={TestSerializerB.class,TestSerializerC.class}, serializersInherit=SERIALIZERS) + public String testSerializerOverriddenOnMethod() { + return "test3"; + } + + @Produces("text/a") + public static class TestSerializerC extends WriterSerializer { + @Override /* Serializer */ + protected void doSerialize(SerializerSession session, Object o) throws Exception { + session.getWriter().write("text/c - " + o); + } + } + + //==================================================================================================== + // Serializer with different Accept than Content-Type. + //==================================================================================================== + @RestMethod(name="GET", path="/testSerializerWithDifferentMediaTypes", serializers={TestSerializerD.class}, serializersInherit=SERIALIZERS) + public String testSerializerWithDifferentMediaTypes() { + return "test4"; + } + + @Produces(value={"text/a","text/d"},contentType="text/d") + public static class TestSerializerD extends WriterSerializer { + @Override /* Serializer */ + protected void doSerialize(SerializerSession session, Object o) throws Exception { + session.getWriter().write("text/d - " + o); + } + } + + //==================================================================================================== + // Check for valid 406 error response. + //==================================================================================================== + @RestMethod(name="GET", path="/test406") + public String test406() { + return "test406"; + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/StaticFilesResource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/StaticFilesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/StaticFilesResource.java new file mode 100755 index 0000000..59e7dfe --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/StaticFilesResource.java @@ -0,0 +1,36 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; + +/** + * JUnit automated testcase resource. + */ +@RestResource( + path="/testStaticFiles", + staticFiles="{xdocs:'xdocs'}" +) +public class StaticFilesResource extends RestServlet { + private static final long serialVersionUID = 1L; + + //==================================================================================================== + // Tests the @RestResource(staticFiles) annotation. + //==================================================================================================== + @RestMethod(name="GET", path="/*") + public String testXdocs() { + return null; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/TransformsParentResource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/TransformsParentResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/TransformsParentResource.java new file mode 100755 index 0000000..7507650 --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/TransformsParentResource.java @@ -0,0 +1,26 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; + +/** + * JUnit automated testcase resource. + */ +@RestResource( + pojoSwaps={TransformsResource.SwapA1.class} +) +public class TransformsParentResource extends RestServletDefault { + private static final long serialVersionUID = 1L; +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/TransformsResource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/TransformsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/TransformsResource.java new file mode 100755 index 0000000..3b98afa --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/TransformsResource.java @@ -0,0 +1,113 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import org.apache.juneau.parser.*; +import org.apache.juneau.serializer.*; +import org.apache.juneau.server.annotation.*; +import org.apache.juneau.transform.*; + +/** + * JUnit automated testcase resource. + */ +@RestResource( + path="/testTransforms", + pojoSwaps={TransformsResource.SwapA2.class} +) +public class TransformsResource extends TransformsParentResource { + private static final long serialVersionUID = 1L; + + //==================================================================================================== + // Test class transform overrides parent class transform + // Should return "A2-1". + //==================================================================================================== + @RestMethod(name="GET", path="/testClassTransformOverridesParentClassTransform") + public A testClassTransformOverridesParentClassTransform() { + return new A(); + } + @RestMethod(name="PUT", path="/testClassTransformOverridesParentClassTransform") + public A test1b(@Content A a) { + return a; + } + @RestMethod(name="PUT", path="/testClassTransformOverridesParentClassTransform/{a}") + public A test1c(@Attr A a) { + return a; + } + + //==================================================================================================== + // Test method transform overrides class transform + // Should return "A3-1". + //==================================================================================================== + @RestMethod(name="GET", path="/testMethodTransformOverridesClassTransform", pojoSwaps={SwapA3.class}) + public A test2a() { + return new A(); + } + @RestMethod(name="PUT", path="/testMethodTransformOverridesClassTransform", pojoSwaps={SwapA3.class}) + public A test2b(@Content A a) { + return a; + } + @RestMethod(name="PUT", path="/testMethodTransformOverridesClassTransform/{a}", pojoSwaps={SwapA3.class}) + public A test2c(@Attr A a) { + return a; + } + + + public static class A { + public int f1; + } + + public static class SwapA1 extends PojoSwap<A,String> { + @Override /* PojoSwap */ + public String swap(A a) throws SerializeException { + return "A1-" + a.f1; + } + @Override /* PojoSwap */ + public A unswap(String in) throws ParseException { + if (! in.startsWith("A1")) + throw new RuntimeException("Invalid input for SwapA1!"); + A a = new A(); + a.f1 = Integer.parseInt(in.substring(3)); + return a; + } + } + + public static class SwapA2 extends PojoSwap<A,String> { + @Override /* PojoSwap */ + public String swap(A a) throws SerializeException { + return "A2-" + a.f1; + } + @Override /* PojoSwap */ + public A unswap(String in) throws ParseException { + if (! in.startsWith("A2")) + throw new RuntimeException("Invalid input for SwapA2!"); + A a = new A(); + a.f1 = Integer.parseInt(in.substring(3)); + return a; + } + } + + public static class SwapA3 extends PojoSwap<A,String> { + @Override /* PojoSwap */ + public String swap(A a) throws SerializeException { + return "A3-" + a.f1; + } + @Override /* PojoSwap */ + public A unswap(String in) throws ParseException { + if (! in.startsWith("A3")) + throw new RuntimeException("Invalid input for SwapA3!"); + A a = new A(); + a.f1 = Integer.parseInt(in.substring(3)); + return a; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrisResource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrisResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrisResource.java new file mode 100755 index 0000000..4667b24 --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrisResource.java @@ -0,0 +1,121 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import org.apache.juneau.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; + +@RestResource( + path="/testuris", + children={ + UrisResource.Child.class + } +) +public class UrisResource extends RestServletDefault { + private static final long serialVersionUID = 1L; + + @RestMethod(name="GET", path="/*") + public ObjectMap test1(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "root.test1"); + } + + @RestMethod(name="GET", path="/test2/*") + public ObjectMap test2(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "root.test2"); + } + + @RestMethod(name="GET", path="/test3%2Ftest3/*") + public ObjectMap test3(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "root.test3"); + } + + @RestMethod(name="GET", path="/test4/test4/*") + public ObjectMap test4(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "root.test4"); + } + + @RestResource( + path="/child", + children={ + GrandChild.class + } + ) + public static class Child extends RestServletDefault { + private static final long serialVersionUID = 1L; + + @RestMethod(name="GET", path="/*") + public ObjectMap test1(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "child.test1"); + } + + @RestMethod(name="GET", path="/test2/*") + public ObjectMap test2(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "child.test2"); + } + + @RestMethod(name="GET", path="/test3%2Ftest3/*") + public ObjectMap test3(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "child.test3"); + } + + @RestMethod(name="GET", path="/test4/test4/*") + public ObjectMap test4(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "child.test4"); + } + } + + @RestResource( + path="/grandchild" + ) + public static class GrandChild extends RestServletDefault { + private static final long serialVersionUID = 1L; + + @RestMethod(name="GET", path="/*") + public ObjectMap test1(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "grandchild.test1"); + } + + @RestMethod(name="GET", path="/test2/*") + public ObjectMap test2(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "grandchild.test2"); + } + + @RestMethod(name="GET", path="/test3%2Ftest3/*") + public ObjectMap test3(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "grandchild.test3"); + } + + @RestMethod(name="GET", path="/test4/test4/*") + public ObjectMap test4(RestRequest req) throws Exception { + return getPathInfoObject(req).append("testMethod", "grandchild.test4"); + } + } + + static ObjectMap getPathInfoObject(RestRequest req) throws Exception { + ObjectMap m = new ObjectMap(); + m.put("contextPath", req.getContextPath()); + m.put("pathInfo", req.getPathInfo()); + m.put("pathRemainder", req.getPathRemainder()); + m.put("pathTranslated", req.getPathTranslated()); + m.put("requestParentURI", req.getRequestParentURI()); + m.put("requestURI", req.getRequestURI()); + m.put("requestURL", req.getRequestURL()); + m.put("servletPath", req.getServletPath()); + m.put("servletURI", req.getServletURI()); + m.put("testURL1", req.getURL("testURL")); + m.put("testURL2", req.getURL("/testURL")); + m.put("testURL3", req.getURL("http://testURL")); + return m; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrlContentResource.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrlContentResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrlContentResource.java new file mode 100755 index 0000000..290dd0b --- /dev/null +++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrlContentResource.java @@ -0,0 +1,59 @@ +// *************************************************************************************************************************** +// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * +// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * +// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * +// * with the License. You may obtain a copy of the License at * +// * * +// * http://www.apache.org/licenses/LICENSE-2.0 * +// * * +// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * +// * specific language governing permissions and limitations under the License. * +// *************************************************************************************************************************** +package org.apache.juneau.server.test; + +import org.apache.juneau.json.*; +import org.apache.juneau.plaintext.*; +import org.apache.juneau.server.*; +import org.apache.juneau.server.annotation.*; + +/** + * JUnit automated testcase resource. + */ +@RestResource( + path="/testUrlContent", + serializers={PlainTextSerializer.class}, + parsers={JsonParser.class} +) +public class UrlContentResource extends RestServlet { + private static final long serialVersionUID = 1L; + + @RestMethod(name="GET", path="/testString") + public String testString(@Content String content) { + return String.format("class=%s, value=%s", content.getClass().getName(), content.toString()); + } + + @RestMethod(name="GET", path="/testEnum") + public String testEnum(@Content TestEnum content) { + return String.format("class=%s, value=%s", content.getClass().getName(), content.toString()); + } + + public static enum TestEnum { + X1 + } + + @RestMethod(name="GET", path="/testBean") + public String testBean(@Content TestBean content) throws Exception { + return String.format("class=%s, value=%s", content.getClass().getName(), JsonSerializer.DEFAULT_LAX.serialize(content)); + } + + public static class TestBean { + public int f1; + public String f2; + } + + @RestMethod(name="GET", path="/testInt") + public String testString(@Content Integer content) { + return String.format("class=%s, value=%s", content.getClass().getName(), content.toString()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/Messages2Resource.properties ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/Messages2Resource.properties b/juneau-server-test/src/main/resources/org/apache/juneau/server/Messages2Resource.properties deleted file mode 100755 index 9a5fe73..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/Messages2Resource.properties +++ /dev/null @@ -1,16 +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. * -# * * -# *************************************************************************************************************************** - -key2 = value2b -key3 = value3b \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/MessagesResource.properties ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/MessagesResource.properties b/juneau-server-test/src/main/resources/org/apache/juneau/server/MessagesResource.properties deleted file mode 100755 index d107ee8..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/MessagesResource.properties +++ /dev/null @@ -1,16 +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. * -# * * -# *************************************************************************************************************************** - -key1 = value1a -key2 = value2a \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/NlsPropertyResource.properties ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/NlsPropertyResource.properties b/juneau-server-test/src/main/resources/org/apache/juneau/server/NlsPropertyResource.properties deleted file mode 100755 index a833256..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/NlsPropertyResource.properties +++ /dev/null @@ -1,16 +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. * -# * * -# *************************************************************************************************************************** - -key1 = value1 -key2 = value2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/NlsResource.properties ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/NlsResource.properties b/juneau-server-test/src/main/resources/org/apache/juneau/server/NlsResource.properties deleted file mode 100755 index 9833d00..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/NlsResource.properties +++ /dev/null @@ -1,79 +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. * -# * * -# *************************************************************************************************************************** - -label = Test2.a -description = Test2.b -test2 = Test2.c -test2.req.attr.a = Test2.d -test2.req.param.b = Test2.e -test2.req.content = Test2.f -test2.req.header.D = Test2.g -test2.req.attr.a2 = Test2.h -test2.req.param.b2 = Test2.i -test2.req.header.D2 = Test2.j -test2.req.foo.bar = Test2.k -test2.res.200 = OK2 -test2.res.201 = Test2.l -test2.res.201.foo.bar = Test2.m - -Test3.label = Test3.a -Test3.description = Test3.b -Test3.test3 = Test3.c -Test3.test3.req.attr.a = Test3.d -Test3.test3.req.param.b = Test3.e -Test3.test3.req.content = Test3.f -Test3.test3.req.header.D = Test3.g -Test3.test3.req.attr.a2 = Test3.h -Test3.test3.req.param.b2 = Test3.i -Test3.test3.req.header.D2 = Test3.j -Test3.test3.req.foo.bar = Test3.k -Test3.test3.res.200 = OK3 -Test3.test3.res.201 = Test3.l -Test3.test3.res.201.foo.bar = Test3.m - -Test4.label = $L{foo} -Test4.description = $L{foo} -Test4.test4 = $L{foo} -Test4.test4.req.attr.a = $L{foo} -Test4.test4.req.param.b = $L{foo} -Test4.test4.req.content = $L{foo} -Test4.test4.req.header.D = $L{foo} -Test4.test4.req.attr.a2 = $L{foo} -Test4.test4.req.param.b2 = $L{foo} -Test4.test4.req.header.D2 = $L{foo} -Test4.test4.req.foo.bar = $L{foo} -Test4.test4.res.200 = foo$L{foo}foo$L{foo}foo -Test4.test4.res.201 = $L{foo} -Test4.test4.res.201.foo.bar = $L{foo} - -foo = $L{bar} -bar = baz - -Test5.label = $L{foo2} -Test5.description = $R{servletLabel} -Test5.test5 = $R{servletLabel} -Test5.test5.req.attr.a = $R{servletLabel} -Test5.test5.req.param.b = $R{servletLabel} -Test5.test5.req.content = $R{servletLabel} -Test5.test5.req.header.D = $R{servletLabel} -Test5.test5.req.attr.a2 = $R{servletLabel} -Test5.test5.req.param.b2 = $R{servletLabel} -Test5.test5.req.header.D2 = $R{servletLabel} -Test5.test5.req.foo.bar = $R{servletLabel} -Test5.test5.res.200 = foo$R{servletLabel}foo$R{servletLabel}foo -Test5.test5.res.201 = $R{servletLabel} -Test5.test5.res.201.foo.bar = $R{servletLabel} -Test5.foo2 = $L{bar2} -Test5.bar2 = baz2 - http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/test/Messages2Resource.properties ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/Messages2Resource.properties b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/Messages2Resource.properties new file mode 100755 index 0000000..9a5fe73 --- /dev/null +++ b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/Messages2Resource.properties @@ -0,0 +1,16 @@ +# *************************************************************************************************************************** +# * 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. * +# * * +# *************************************************************************************************************************** + +key2 = value2b +key3 = value3b \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/test/MessagesResource.properties ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/MessagesResource.properties b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/MessagesResource.properties new file mode 100755 index 0000000..d107ee8 --- /dev/null +++ b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/MessagesResource.properties @@ -0,0 +1,16 @@ +# *************************************************************************************************************************** +# * 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. * +# * * +# *************************************************************************************************************************** + +key1 = value1a +key2 = value2a \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsPropertyResource.properties ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsPropertyResource.properties b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsPropertyResource.properties new file mode 100755 index 0000000..a833256 --- /dev/null +++ b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsPropertyResource.properties @@ -0,0 +1,16 @@ +# *************************************************************************************************************************** +# * 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. * +# * * +# *************************************************************************************************************************** + +key1 = value1 +key2 = value2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsResource.properties ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsResource.properties b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsResource.properties new file mode 100755 index 0000000..9833d00 --- /dev/null +++ b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsResource.properties @@ -0,0 +1,79 @@ +# *************************************************************************************************************************** +# * 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. * +# * * +# *************************************************************************************************************************** + +label = Test2.a +description = Test2.b +test2 = Test2.c +test2.req.attr.a = Test2.d +test2.req.param.b = Test2.e +test2.req.content = Test2.f +test2.req.header.D = Test2.g +test2.req.attr.a2 = Test2.h +test2.req.param.b2 = Test2.i +test2.req.header.D2 = Test2.j +test2.req.foo.bar = Test2.k +test2.res.200 = OK2 +test2.res.201 = Test2.l +test2.res.201.foo.bar = Test2.m + +Test3.label = Test3.a +Test3.description = Test3.b +Test3.test3 = Test3.c +Test3.test3.req.attr.a = Test3.d +Test3.test3.req.param.b = Test3.e +Test3.test3.req.content = Test3.f +Test3.test3.req.header.D = Test3.g +Test3.test3.req.attr.a2 = Test3.h +Test3.test3.req.param.b2 = Test3.i +Test3.test3.req.header.D2 = Test3.j +Test3.test3.req.foo.bar = Test3.k +Test3.test3.res.200 = OK3 +Test3.test3.res.201 = Test3.l +Test3.test3.res.201.foo.bar = Test3.m + +Test4.label = $L{foo} +Test4.description = $L{foo} +Test4.test4 = $L{foo} +Test4.test4.req.attr.a = $L{foo} +Test4.test4.req.param.b = $L{foo} +Test4.test4.req.content = $L{foo} +Test4.test4.req.header.D = $L{foo} +Test4.test4.req.attr.a2 = $L{foo} +Test4.test4.req.param.b2 = $L{foo} +Test4.test4.req.header.D2 = $L{foo} +Test4.test4.req.foo.bar = $L{foo} +Test4.test4.res.200 = foo$L{foo}foo$L{foo}foo +Test4.test4.res.201 = $L{foo} +Test4.test4.res.201.foo.bar = $L{foo} + +foo = $L{bar} +bar = baz + +Test5.label = $L{foo2} +Test5.description = $R{servletLabel} +Test5.test5 = $R{servletLabel} +Test5.test5.req.attr.a = $R{servletLabel} +Test5.test5.req.param.b = $R{servletLabel} +Test5.test5.req.content = $R{servletLabel} +Test5.test5.req.header.D = $R{servletLabel} +Test5.test5.req.attr.a2 = $R{servletLabel} +Test5.test5.req.param.b2 = $R{servletLabel} +Test5.test5.req.header.D2 = $R{servletLabel} +Test5.test5.req.foo.bar = $R{servletLabel} +Test5.test5.res.200 = foo$R{servletLabel}foo$R{servletLabel}foo +Test5.test5.res.201 = $R{servletLabel} +Test5.test5.res.201.foo.bar = $R{servletLabel} +Test5.foo2 = $L{bar2} +Test5.bar2 = baz2 + http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/test/xdocs/test.txt ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/xdocs/test.txt b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/xdocs/test.txt new file mode 100755 index 0000000..b4ea91c --- /dev/null +++ b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/xdocs/test.txt @@ -0,0 +1,13 @@ + *************************************************************************************************************************** + * 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. * + *************************************************************************************************************************** + OK-1 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/test/xdocs/xdocs/test.txt ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/xdocs/xdocs/test.txt b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/xdocs/xdocs/test.txt new file mode 100755 index 0000000..e3db156 --- /dev/null +++ b/juneau-server-test/src/main/resources/org/apache/juneau/server/test/xdocs/xdocs/test.txt @@ -0,0 +1,13 @@ + *************************************************************************************************************************** + * 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. * + *************************************************************************************************************************** + OK-2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/xdocs/test.txt ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/xdocs/test.txt b/juneau-server-test/src/main/resources/org/apache/juneau/server/xdocs/test.txt deleted file mode 100755 index b4ea91c..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/xdocs/test.txt +++ /dev/null @@ -1,13 +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. * - *************************************************************************************************************************** - OK-1 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/resources/org/apache/juneau/server/xdocs/xdocs/test.txt ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/main/resources/org/apache/juneau/server/xdocs/xdocs/test.txt b/juneau-server-test/src/main/resources/org/apache/juneau/server/xdocs/xdocs/test.txt deleted file mode 100755 index e3db156..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/xdocs/xdocs/test.txt +++ /dev/null @@ -1,13 +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. * - *************************************************************************************************************************** - OK-2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/AcceptCharsetTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/AcceptCharsetTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/AcceptCharsetTest.java deleted file mode 100755 index 97ffbb4..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/AcceptCharsetTest.java +++ /dev/null @@ -1,123 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server; - -import static javax.servlet.http.HttpServletResponse.*; -import static org.apache.juneau.server.TestUtils.*; -import static org.junit.Assert.*; - -import java.io.*; - -import org.apache.juneau.client.*; -import org.apache.juneau.internal.*; -import org.junit.*; - -public class AcceptCharsetTest { - - boolean debug = false; - - //==================================================================================================== - // Test that Q-values are being resolved correctly. - //==================================================================================================== - @Test - public void testQValues() throws Exception { - RestClient client = new TestRestClient().setHeader("Accept", "text/plain"); - - check1(client, "utf-8", "utf-8"); - check1(client, "iso-8859-1", "iso-8859-1"); - check1(client, "bad,utf-8", "utf-8"); - check1(client, "utf-8,bad", "utf-8"); - check1(client, "bad;q=0.9,utf-8;q=0.1", "utf-8"); - check1(client, "bad;q=0.1,utf-8;q=0.9", "utf-8"); - check1(client, "utf-8,iso-8859-1", "utf-8"); - check1(client, "iso-8859-1,utf-8", "utf-8"); - check1(client, "utf-8;q=0.9,iso-8859-1;q=0.1", "utf-8"); - check1(client, "utf-8;q=0.1,iso-8859-1;q=0.9", "iso-8859-1"); - check1(client, "*", "utf-8"); - check1(client, "bad,iso-8859-1;q=0.5,*;q=0.1", "iso-8859-1"); - check1(client, "bad,iso-8859-1;q=0.1,*;q=0.5", "utf-8"); - - client.closeQuietly(); - } - - private void check1(RestClient client, String requestCharset, String responseCharset) throws Exception { - RestCall r; - InputStream is; - String url = "/testAcceptCharset/testQValues"; - r = client.doGet(url).setHeader("Accept-Charset", requestCharset).connect(); - assertTrue(r.getResponse().getFirstHeader("Content-Type").getValue().toLowerCase().contains(responseCharset)); - is = r.getInputStream(); - assertEquals("foo", IOUtils.read(new InputStreamReader(is, responseCharset))); - } - - //==================================================================================================== - // Validate various Accept-Charset variations. - //==================================================================================================== - @Test - public void testCharsetOnResponse() throws Exception { - RestClient client = new TestRestClient().setAccept("text/plain").setContentType("text/plain"); - String url = "/testAcceptCharset/testCharsetOnResponse"; - String r; - - r = client.doPut(url, new StringReader("")).getResponseAsString(); - assertEquals("utf-8/utf-8", r.toLowerCase()); - - r = client.doPut(url, new StringReader("")).setHeader("Accept-Charset", "Shift_JIS").getResponseAsString(); - assertEquals("utf-8/shift_jis", r.toLowerCase()); - - try { - r = client.doPut(url+"?noTrace=true", new StringReader("")).setHeader("Accept-Charset", "BAD").getResponseAsString(); - fail("Exception expected"); - } catch (RestCallException e) { - checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE, "No supported charsets in header 'Accept-Charset': 'BAD'"); - } - - r = client.doPut(url, new StringReader("")).setHeader("Accept-Charset", "UTF-8").getResponseAsString(); - assertEquals("utf-8/utf-8", r.toLowerCase()); - - r = client.doPut(url, new StringReader("")).setHeader("Accept-Charset", "bad,iso-8859-1").getResponseAsString(); - assertEquals("utf-8/iso-8859-1", r.toLowerCase()); - - r = client.doPut(url, new StringReader("")).setHeader("Accept-Charset", "bad;q=0.9,iso-8859-1;q=0.1").getResponseAsString(); - assertEquals("utf-8/iso-8859-1", r.toLowerCase()); - - r = client.doPut(url, new StringReader("")).setHeader("Accept-Charset", "bad;q=0.1,iso-8859-1;q=0.9").getResponseAsString(); - assertEquals("utf-8/iso-8859-1", r.toLowerCase()); - - client.setHeader("Accept-Charset", "utf-8"); - - r = client.doPut(url, new StringReader("")).setHeader("Content-Type", "text/plain").getResponseAsString(); - assertEquals("utf-8/utf-8", r.toLowerCase()); - - r = client.doPut(url, new StringReader("")).setHeader("Content-Type", "text/plain;charset=utf-8").getResponseAsString(); - assertEquals("utf-8/utf-8", r.toLowerCase()); - - r = client.doPut(url, new StringReader("")).setHeader("Content-Type", "text/plain;charset=UTF-8").getResponseAsString(); - assertEquals("utf-8/utf-8", r.toLowerCase()); - - r = client.doPut(url, new StringReader("")).setHeader("Content-Type", "text/plain;charset=iso-8859-1").getResponseAsString(); - assertEquals("iso-8859-1/utf-8", r.toLowerCase()); - - r = client.doPut(url, new StringReader("")).setHeader("Content-Type", "text/plain;charset=Shift_JIS").getResponseAsString(); - assertEquals("shift_jis/utf-8", r.toLowerCase()); - - try { - r = client.doPut(url + "?noTrace=true&Content-Type=text/plain;charset=BAD", new StringReader("")).getResponseAsString(); - fail("Exception expected"); - } catch (RestCallException e) { - checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported charset in header 'Content-Type': 'text/plain;charset=BAD'"); - } - - client.closeQuietly(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/BeanContextPropertiesTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/BeanContextPropertiesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/BeanContextPropertiesTest.java deleted file mode 100755 index 4a73449..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/BeanContextPropertiesTest.java +++ /dev/null @@ -1,37 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server; - -import static org.junit.Assert.*; - -import org.apache.juneau.client.*; -import org.apache.juneau.json.*; -import org.junit.*; - -public class BeanContextPropertiesTest { - - boolean debug = false; - - //==================================================================================================== - // Validate that filters defined on class filter to underlying bean context. - //==================================================================================================== - @Test - public void testClassTransforms() throws Exception { - RestClient client = new TestRestClient(JsonSerializer.class, JsonParser.class); - String r; - r = client.doGet("/testBeanContext/testClassTransforms/2001-07-04T15:30:45Z?d2=2001-07-05T15:30:45Z").setHeader("X-D3", "2001-07-06T15:30:45Z").getResponseAsString(); - assertEquals("d1=2001-07-04T15:30:45Z,d2=2001-07-05T15:30:45Z,d3=2001-07-06T15:30:45Z", r); - - client.closeQuietly(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/CallbackStringsTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/CallbackStringsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/CallbackStringsTest.java deleted file mode 100755 index 64a776c..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/CallbackStringsTest.java +++ /dev/null @@ -1,50 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server; - -import static org.junit.Assert.*; - -import org.apache.juneau.client.*; -import org.junit.*; - -public class CallbackStringsTest { - - //==================================================================================================== - // Basic tests using &Content parameter - //==================================================================================================== - @Test - public void test() throws Exception { - RestClient c = new TestRestClient().setAccept("text/json+simple"); - String r; - - r = c.doCallback("GET /testCallback").getResponseAsString(); - assertEquals("{method:'GET',headers:{},content:''}", r); - - r = c.doCallback("GET /testCallback some sample content").getResponseAsString(); - assertEquals("{method:'GET',headers:{},content:'some sample content'}", r); - - r = c.doCallback("GET {Foo-X:123,Foo-Y:'abc'} /testCallback").getResponseAsString(); - assertEquals("{method:'GET',headers:{'Foo-X':'123','Foo-Y':'abc'},content:''}", r); - - r = c.doCallback("GET { Foo-X : 123, Foo-Y : 'abc' } /testCallback").getResponseAsString(); - assertEquals("{method:'GET',headers:{'Foo-X':'123','Foo-Y':'abc'},content:''}", r); - - r = c.doCallback("GET {Foo-X:123,Foo-Y:'abc'} /testCallback some sample content ").getResponseAsString(); - assertEquals("{method:'GET',headers:{'Foo-X':'123','Foo-Y':'abc'},content:'some sample content'}", r); - - r = c.doCallback("PUT {Foo-X:123,Foo-Y:'abc'} /testCallback some sample content ").getResponseAsString(); - assertEquals("{method:'PUT',headers:{'Foo-X':'123','Foo-Y':'abc'},content:'some sample content'}", r); - - c.closeQuietly(); - } -}
