http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/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 deleted file mode 100755 index 4667b24..0000000 --- a/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrisResource.java +++ /dev/null @@ -1,121 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server.test; - -import 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/91a388d0/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 deleted file mode 100755 index bfd82fd..0000000 --- a/juneau-server-test/src/main/java/org/apache/juneau/server/test/UrlContentResource.java +++ /dev/null @@ -1,59 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server.test; - -import 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(@Body String content) { - return String.format("class=%s, value=%s", content.getClass().getName(), content.toString()); - } - - @RestMethod(name="GET", path="/testEnum") - public String testEnum(@Body 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(@Body 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(@Body 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/91a388d0/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 deleted file mode 100755 index 9a5fe73..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/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/91a388d0/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 deleted file mode 100755 index d107ee8..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/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/91a388d0/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 deleted file mode 100755 index a833256..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/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/91a388d0/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 deleted file mode 100755 index d461923..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/NlsResource.properties +++ /dev/null @@ -1,71 +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. * -# * * -# *************************************************************************************************************************** - -title = Test2.a -description = Test2.b -test2.summary = Test2.c -test2.req.path.a.description = Test2.d -test2.req.query.b.description = Test2.e -test2.req.body.description = Test2.f -test2.req.header.D.description = Test2.g -test2.req.path.a2.description = Test2.h -test2.req.query.b2.description = Test2.i -test2.req.header.D2.description = Test2.j -test2.res.200.description = OK2 -test2.res.201.description = Test2.l - -Test3.title = Test3.a -Test3.description = Test3.b -Test3.test3.summary = Test3.c -Test3.test3.req.path.a.description = Test3.d -Test3.test3.req.query.b.description = Test3.e -Test3.test3.req.body.description = Test3.f -Test3.test3.req.header.D.description = Test3.g -Test3.test3.req.path.a2.description = Test3.h -Test3.test3.req.query.b2.description = Test3.i -Test3.test3.req.header.D2.description = Test3.j -Test3.test3.res.200.description = OK3 -Test3.test3.res.201.description = Test3.l - -Test4.title = $L{foo} -Test4.description = $L{foo} -Test4.test4.summary = $L{foo} -Test4.test4.req.path.a.description = $L{foo} -Test4.test4.req.query.b.description = $L{foo} -Test4.test4.req.body.description = $L{foo} -Test4.test4.req.header.D.description = $L{foo} -Test4.test4.req.path.a2.description = $L{foo} -Test4.test4.req.query.b2.description = $L{foo} -Test4.test4.req.header.D2.description = $L{foo} -Test4.test4.res.200.description = foo$L{foo}foo$L{foo}foo -Test4.test4.res.201.description = $L{foo} - -foo = $L{bar} -bar = baz - -Test5.title = $L{foo2} -Test5.description = $R{servletTitle} -Test5.test5.summary = $R{servletTitle} -Test5.test5.req.path.a.description = $R{servletTitle} -Test5.test5.req.query.b.description = $R{servletTitle} -Test5.test5.req.body.description = $R{servletTitle} -Test5.test5.req.header.D.description = $R{servletTitle} -Test5.test5.req.path.a2.description = $R{servletTitle} -Test5.test5.req.query.b2.description = $R{servletTitle} -Test5.test5.req.header.D2.description = $R{servletTitle} -Test5.test5.res.200.description = foo$R{servletTitle}foo$R{servletTitle}foo -Test5.test5.res.201.description = $R{servletTitle} -Test5.foo2 = $L{bar2} -Test5.bar2 = baz2 - http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/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 deleted file mode 100755 index b4ea91c..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/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/91a388d0/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 deleted file mode 100755 index e3db156..0000000 --- a/juneau-server-test/src/main/resources/org/apache/juneau/server/test/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/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/AcceptCharsetTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/AcceptCharsetTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/AcceptCharsetTest.java deleted file mode 100755 index 3464661..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/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.test; - -import static javax.servlet.http.HttpServletResponse.*; -import static org.apache.juneau.server.test.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/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/BeanContextPropertiesTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/BeanContextPropertiesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/BeanContextPropertiesTest.java deleted file mode 100755 index 671bfed..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/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.test; - -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/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/CallbackStringsTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/CallbackStringsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/CallbackStringsTest.java deleted file mode 100755 index 8e487c0..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/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.test; - -import static org.junit.Assert.*; - -import org.apache.juneau.client.*; -import org.junit.*; - -public class CallbackStringsTest { - - //==================================================================================================== - // Basic tests using @Body 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(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/CharsetEncodingsTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/CharsetEncodingsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/CharsetEncodingsTest.java deleted file mode 100755 index bf50a13..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/CharsetEncodingsTest.java +++ /dev/null @@ -1,96 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server.test; - -import static javax.servlet.http.HttpServletResponse.*; -import static org.apache.juneau.server.test.TestUtils.*; -import static org.junit.Assert.*; - -import java.io.*; - -import org.apache.juneau.client.*; -import org.apache.juneau.internal.*; -import org.junit.*; - - -public class CharsetEncodingsTest { - - private static boolean debug = false; - - /** - * Basic tests to ensure that the correct charsets are found and used - * under a variety of scenarios. - */ - @Test - public void test() throws Exception { - String url = "/testCharsetEncodings"; - RestClient client = new TestRestClient().setAccept("text/s").setContentType("text/p"); - InputStream is; - String r; - - r = client.doPut(url, new StringReader("foo")).getResponseAsString(); - if (debug) System.err.println(r); - assertEquals("utf-8/foo/utf-8", r); - - is = client.doPut(url, new StringReader("foo")).getInputStream(); - r = IOUtils.read(new InputStreamReader(is, "utf-8")); - if (debug) System.err.println(r); - assertEquals("utf-8/foo/utf-8", r); - - client.setHeader("Accept-Charset", "utf-8").setContentType("text/p;charset=utf-8"); - is = client.doPut(url, new StringReader("foo")).getInputStream(); - r = IOUtils.read(new InputStreamReader(is, "utf-8")); - if (debug) System.err.println(r); - assertEquals("utf-8/foo/utf-8", r); - - client.setHeader("Accept-Charset", "Shift_JIS").setContentType("text/p;charset=shift_jis"); - is = client.doPut(url, new StringReader("foo")).getInputStream(); - r = IOUtils.read(new InputStreamReader(is, "Shift_JIS")); - if (debug) System.err.println(r); - assertEquals("shift_jis/foo/shift_jis", r); - - try { - client.setHeader("Accept-Charset", "BAD").setContentType("text/p;charset=sjis"); - is = client.doPut(url + "?noTrace=true", new StringReader("foo")).getInputStream(); - r = IOUtils.read(new InputStreamReader(is, "sjis")); - if (debug) System.err.println(r); - fail("Exception expected"); - } catch (RestCallException e) { - checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE, "No supported charsets in header 'Accept-Charset': 'BAD'"); - } - - client.setAccept("text/s").setHeader("Accept-Charset", "utf-8").setContentType("text/p"); - is = client.doPut(url+"?Content-Type=text/p", new StringReader("foo")).getInputStream(); - r = IOUtils.read(new InputStreamReader(is, "utf-8")); - if (debug) System.err.println(r); - assertEquals("utf-8/foo/utf-8", r); - - client.setAccept("text/s").setContentType("text/bad").setHeader("Accept-Charset", "utf-8"); - is = client.doPut(url+"?Content-Type=text/p;charset=utf-8", new StringReader("foo")).getInputStream(); - r = IOUtils.read(new InputStreamReader(is, "utf-8")); - if (debug) System.err.println(r); - assertEquals("utf-8/foo/utf-8", r); - - try { - client.setAccept("text/s").setContentType("text/p").setHeader("Accept-Charset", "utf-8"); - is = client.doPut(url+"?Content-Type=text/p;charset=BAD&noTrace=true", new StringReader("foo")).getInputStream(); - r = IOUtils.read(new InputStreamReader(is, "utf-8")); - if (debug) System.err.println(r); - assertEquals("utf-8/foo/utf-8", r); - fail("Exception expected"); - } catch (RestCallException e) { - checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE, "Unsupported charset in header 'Content-Type': 'text/p;charset=BAD'"); - } - client.closeQuietly(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/ClientVersionTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/ClientVersionTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ClientVersionTest.java deleted file mode 100644 index aab4852..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/ClientVersionTest.java +++ /dev/null @@ -1,90 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server.test; - -import static org.junit.Assert.*; - -import org.apache.juneau.client.*; -import org.apache.juneau.plaintext.*; -import org.junit.*; - -public class ClientVersionTest { - - private static String URL = "/testClientVersion"; - - //==================================================================================================== - // Basic tests - default X-Client-Version header. - //==================================================================================================== - @Test - public void testDefaultHeader() throws Exception { - RestClient c = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class); - String url = URL + "/defaultHeader"; - - assertEquals("no-version", c.doGet(url).getResponseAsString()); - -// for (String s : "0, 0.0, 0.1, .1, .9, .99".split("\\s*,\\s*")) { -// c.setClientVersion(s); -// assertEquals(s, "[0.0,1.0)", c.doGet(url).getResponseAsString()); -// } - - for (String s : "1, 1.0, 1.0.0, 1.0.1".split("\\s*,\\s*")) { - c.setClientVersion(s); - assertEquals(s, "[1.0,1.0]", c.doGet(url).getResponseAsString()); - } - - for (String s : "1.1, 1.1.1, 1.2, 1.9.9".split("\\s*,\\s*")) { - c.setClientVersion(s); - assertEquals(s, "[1.1,2)", c.doGet(url).getResponseAsString()); - } - - for (String s : "2, 2.0, 2.1, 9, 9.9".split("\\s*,\\s*")) { - c.setClientVersion(s); - assertEquals(s, "2", c.doGet(url).getResponseAsString()); - } - - c.closeQuietly(); - } - - //==================================================================================================== - // Basic tests - Custom-Client-Version header. - //==================================================================================================== - @Test - public void testCustomHeader() throws Exception { - RestClient c = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class); - String url = URL + "/customHeader"; - - assertEquals("no-version", c.doGet(url).getResponseAsString()); - - for (String s : "0, 0.0, 0.1, .1, .9, .99".split("\\s*,\\s*")) { - c.setHeader("Custom-Client-Version", s); - assertEquals("[0.0,1.0)", c.doGet(url).getResponseAsString()); - } - - for (String s : "1, 1.0, 1.0.0, 1.0.1".split("\\s*,\\s*")) { - c.setHeader("Custom-Client-Version", s); - assertEquals("[1.0,1.0]", c.doGet(url).getResponseAsString()); - } - - for (String s : "1.1, 1.1.1, 1.2, 1.9.9".split("\\s*,\\s*")) { - c.setHeader("Custom-Client-Version", s); - assertEquals("[1.1,2)", c.doGet(url).getResponseAsString()); - } - - for (String s : "2, 2.0, 2.1, 9, 9.9".split("\\s*,\\s*")) { - c.setHeader("Custom-Client-Version", s); - assertEquals("2", c.doGet(url).getResponseAsString()); - } - - c.closeQuietly(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/ConfigTest.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/ConfigTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ConfigTest.java deleted file mode 100755 index ee3ca09..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/ConfigTest.java +++ /dev/null @@ -1,59 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server.test; - -import static org.apache.juneau.server.test.TestUtils.*; -import static org.junit.Assert.*; - -import org.apache.juneau.client.*; -import org.apache.juneau.ini.*; -import org.apache.juneau.json.*; -import org.apache.juneau.server.*; -import org.junit.*; - -public class ConfigTest { - - private static String URL = "/testConfig"; - - //==================================================================================================== - // Basic tests - //==================================================================================================== - @Test - public void test() throws Exception { - RestClient c = new TestRestClient(JsonSerializer.class, JsonParser.class).setAccept("text/json+simple"); - - ConfigFile cf = c.doGet(URL).getResponse(ConfigFileImpl.class); - - assertObjectEquals("{int1:'1',int2:'1,2,3',int3:'$C{Test/int1, -1}',int4:'$C{Test/int3, -1}',int5:'$C{XXX, -1}',boolean1:'true',boolean2:'true,true',path:'$E{PATH}',testManifestEntry:'$MF{Test-Entry}'}", cf.get("Test")); - - assertEquals("'1'", c.doGet(URL + "/Test%2Fint1/" + getName(String.class)).getResponseAsString()); - assertEquals("['1']", c.doGet(URL + "/Test%2Fint1/" + getName(String[].class)).getResponseAsString()); - assertEquals("'1,2,3'", c.doGet(URL + "/Test%2Fint2/" + getName(String.class)).getResponseAsString()); - assertEquals("['1','2','3']", c.doGet(URL + "/Test%2Fint2/" + getName(String[].class)).getResponseAsString()); - assertEquals("[1,2,3]", c.doGet(URL + "/Test%2Fint2/" + getName(int[].class)).getResponseAsString()); - assertEquals("[1,2,3]", c.doGet(URL + "/Test%2Fint2/" + getName(Integer[].class)).getResponseAsString()); - assertEquals("[1]", c.doGet(URL + "/Test%2Fint3/" + getName(int[].class)).getResponseAsString()); - assertEquals("[1]", c.doGet(URL + "/Test%2Fint4/" + getName(int[].class)).getResponseAsString()); - assertEquals("[-1]", c.doGet(URL + "/Test%2Fint5/" + getName(int[].class)).getResponseAsString()); - assertEquals("true", c.doGet(URL + "/Test%2Fboolean1/" + getName(Boolean.class)).getResponseAsString()); - assertEquals("[true,true]", c.doGet(URL + "/Test%2Fboolean2/" + getName(Boolean[].class)).getResponseAsString()); - assertTrue(c.doGet(URL + "/Test%2Fpath/" + getName(String.class)).getResponseAsString().length() > 10); - assertEquals("'test-value'", c.doGet(URL + "/Test%2FtestManifestEntry/" + getName(String.class)).getResponseAsString()); - - c.closeQuietly(); - } - - private String getName(Class<?> c) { - return RestUtils.encode(c.getName()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/91a388d0/juneau-server-test/src/test/java/org/apache/juneau/server/test/Constants.java ---------------------------------------------------------------------- diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/Constants.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/Constants.java deleted file mode 100755 index 7e6c26c..0000000 --- a/juneau-server-test/src/test/java/org/apache/juneau/server/test/Constants.java +++ /dev/null @@ -1,53 +0,0 @@ -// *************************************************************************************************************************** -// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * -// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * -// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * -// * with the License. You may obtain a copy of the License at * -// * * -// * http://www.apache.org/licenses/LICENSE-2.0 * -// * * -// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * -// * specific language governing permissions and limitations under the License. * -// *************************************************************************************************************************** -package org.apache.juneau.server.test; - -import java.net.*; - - -public class Constants { - - private static String juneauSampleUrl = System.getProperty("JUNO_SAMPLE_URL", "http://localhost:10000"); - private static URI juneauSampleUri = (juneauSampleUrl == null ? null : URI.create(juneauSampleUrl)); - - /** - * Returns the value of the "JUNO_SAMPLE_URL" system property, or throws a {@link RuntimeException} - * if it's not set. - */ - public static String getJuneauSamplesUrl() { - if (juneauSampleUrl == null) - throw new RuntimeException("'JUNO_SAMPLE_URL' system property not set to URL of juneau.sample.war location."); - return juneauSampleUrl; - } - - public static URI getJuneauSamplesUri() { - if (juneauSampleUri == null) - throw new RuntimeException("'JUNO_SAMPLE_URL' system property not set to URL of juneau.sample.war location."); - return juneauSampleUri; - } - - private static String juneauServerTestUrl = System.getProperty("JUNO_SERVER_TEST_URL", "http://localhost:10001"); - private static URI juneauServerTestUri = (juneauServerTestUrl == null ? null : URI.create(juneauServerTestUrl)); - - public static String getServerTestUrl() { - if (juneauServerTestUrl == null) - throw new RuntimeException("'JUNO_SERVER_TEST_URL' system property not set to URL of juneau.sample.war location."); - return juneauServerTestUrl; - } - - public static URI getServerTestUri() { - if (juneauServerTestUri == null) - throw new RuntimeException("'JUNO_SERVER_TEST_URL' system property not set to URL of juneau.sample.war location."); - return juneauServerTestUri; - } -}
