You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2016/09/15 21:25:26 UTC
[01/20] incubator-juneau git commit: Clean up Javadocs
Repository: incubator-juneau
Updated Branches:
refs/heads/master a8d50ab1f -> d45e1351d
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrisTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrisTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrisTest.java
new file mode 100755
index 0000000..eb67231
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrisTest.java
@@ -0,0 +1,918 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import static org.junit.Assert.*;
+
+import java.util.regex.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+/**
+ * Verifies that all the RestRequest.getXXX() methods involving URIs work correctly.
+ */
+public class UrisTest {
+
+ private static String URL2 = Constants.getServerTestUrl() + "/testuris"; // /jazz/juneau/sample/testuris
+ private static int port = getPort(Constants.getServerTestUrl()); // 9443
+ private static String path = Constants.getServerTestUri().getPath(); // /jazz/juneau/sample
+
+ //====================================================================================================
+ // testRoot - http://localhost:8080/sample/testuris
+ //====================================================================================================
+ @Test
+ public void testRoot() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r;
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris").getResponse(ObjectMap.class);
+ assertEquals("root.test1", r.getString("testMethod"));
+ assertNull(r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/foo").getResponse(ObjectMap.class);
+ assertEquals("root.test1", r.getString("testMethod"));
+ assertEquals("/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("root.test1", r.getString("testMethod"));
+ assertEquals("/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("root.test1", r.getString("testMethod"));
+ assertEquals("/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test2
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test2").getResponse(ObjectMap.class);
+ assertEquals("root.test2", r.getString("testMethod"));
+ assertEquals("/test2", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test2", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test2/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test2/foo").getResponse(ObjectMap.class);
+ assertEquals("root.test2", r.getString("testMethod"));
+ assertEquals("/test2/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test2", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test2/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test2/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test2/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("root.test2", r.getString("testMethod"));
+ assertEquals("/test2/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test2/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test2/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test3%2Ftest3
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test3%2Ftest3").getResponse(ObjectMap.class);
+ assertEquals("root.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test3%2Ftest3", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test3%2Ftest3/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test3%2Ftest3/foo").getResponse(ObjectMap.class);
+ assertEquals("root.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test3%2Ftest3", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test3%2Ftest3/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("root.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test3%2Ftest3/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test3%2Ftest3/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("root.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test4/test4
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test4/test4").getResponse(ObjectMap.class);
+ assertEquals("root.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test4", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test4/test4", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test4/test4/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test4/test4/foo").getResponse(ObjectMap.class);
+ assertEquals("root.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test4/test4", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test4/test4/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test4/test4/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("root.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test4/test4/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/test4/test4/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("root.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2, r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // testChild - http://localhost:8080/sample/testuris/child
+ //====================================================================================================
+ @Test
+ public void testChild() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r;
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child").getResponse(ObjectMap.class);
+ assertEquals("child.test1", r.getString("testMethod"));
+ assertNull(r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/foo").getResponse(ObjectMap.class);
+ assertEquals("child.test1", r.getString("testMethod"));
+ assertEquals("/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("child.test1", r.getString("testMethod"));
+ assertEquals("/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("child.test1", r.getString("testMethod"));
+ assertEquals("/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test2
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test2").getResponse(ObjectMap.class);
+ assertEquals("child.test2", r.getString("testMethod"));
+ assertEquals("/test2", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test2", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test2/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test2/foo").getResponse(ObjectMap.class);
+ assertEquals("child.test2", r.getString("testMethod"));
+ assertEquals("/test2/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test2", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test2/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test2/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test2/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("child.test2", r.getString("testMethod"));
+ assertEquals("/test2/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test2/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test2/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test2/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test2/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("child.test2", r.getString("testMethod"));
+ assertEquals("/test2/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test2/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test2/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test3%2Ftest3
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test3%2Ftest3").getResponse(ObjectMap.class);
+ assertEquals("child.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test3%2Ftest3", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test3%2Ftest3/foo").getResponse(ObjectMap.class);
+ assertEquals("child.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test3%2Ftest3", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("child.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test3%2Ftest3/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("child.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test4/test4
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test4/test4").getResponse(ObjectMap.class);
+ assertEquals("child.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test4", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test4/test4", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test4/test4/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test4/test4/foo").getResponse(ObjectMap.class);
+ assertEquals("child.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test4/test4", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test4/test4/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("child.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test4/test4/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("child.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // testGrandChild - http://localhost:8080/sample/testuris/child/grandchild
+ //====================================================================================================
+ @Test
+ public void testGrandChild() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r;
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test1", r.getString("testMethod"));
+ assertNull(r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/foo").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test1", r.getString("testMethod"));
+ assertEquals("/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test1", r.getString("testMethod"));
+ assertEquals("/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test1", r.getString("testMethod"));
+ assertEquals("/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test2
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test2").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test2", r.getString("testMethod"));
+ assertEquals("/test2", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test2", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test2/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test2/foo").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test2", r.getString("testMethod"));
+ assertEquals("/test2/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test2", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test2/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test2/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test2", r.getString("testMethod"));
+ assertEquals("/test2/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test2/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test2/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test2/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test2", r.getString("testMethod"));
+ assertEquals("/test2/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test2/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test3%2Ftest3
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test3%2Ftest3").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test3", r.getString("testMethod"));
+ assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test4/test4
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test4/test4").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4", r.getString("pathInfo"));
+ assertNull(r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test4", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test4/test4", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test4/test4/foo
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test4/test4/foo").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo", r.getString("pathInfo"));
+ assertEquals("foo", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test4/test4", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test4/test4/foo/bar").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test4/test4/foo/bar", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo/bar"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ //--------------------------------------------------------------------------------
+ // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar%2Fbaz
+ //--------------------------------------------------------------------------------
+ r = client.doGet("/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
+ assertEquals("grandchild.test4", r.getString("testMethod"));
+ assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
+ assertEquals("foo/bar/baz", r.getString("pathRemainder"));
+ assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestParentURI"));
+ assertEquals(path + "/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
+ assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz"));
+ // Same for servlet
+ assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
+ assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
+ assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
+ // Always the same
+ assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
+ assertEquals("http://testURL", r.getString("testURL3"));
+
+ client.closeQuietly();
+ }
+
+ private static int getPort(String url) {
+ Pattern p = Pattern.compile("\\:(\\d{2,5})");
+ Matcher m = p.matcher(url);
+ if (m.find())
+ return Integer.parseInt(m.group(1));
+ return -1;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlContentTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlContentTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlContentTest.java
new file mode 100755
index 0000000..ca8dd1d
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlContentTest.java
@@ -0,0 +1,74 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import static org.junit.Assert.*;
+
+import org.apache.juneau.client.*;
+import org.junit.*;
+
+public class UrlContentTest {
+
+ private static String URL = "/testUrlContent";
+ private static RestClient client;
+
+ @BeforeClass
+ public static void beforeClass() {
+ client = new TestRestClient().setHeader("Accept", "text/plain");
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test URL &Content parameter containing a String
+ //====================================================================================================
+ @Test
+ public void testString() throws Exception {
+ String r;
+ r = client.doGet(URL + "/testString?content=\'xxx\'&Content-Type=text/json").getResponseAsString();
+ assertEquals("class=java.lang.String, value=xxx", r);
+ }
+
+ //====================================================================================================
+ // Test URL &Content parameter containing an Enum
+ //====================================================================================================
+ @Test
+ public void testEnum() throws Exception {
+ String r;
+ r = client.doGet(URL + "/testEnum?content='X1'&Content-Type=text/json").getResponseAsString();
+ assertEquals("class=org.apache.juneau.server.test.UrlContentResource$TestEnum, value=X1", r);
+ }
+
+ //====================================================================================================
+ // Test URL &Content parameter containing a Bean
+ //====================================================================================================
+ @Test
+ public void testBean() throws Exception {
+ String r;
+ r = client.doGet(URL + "/testBean?content=%7Bf1:1,f2:'foobar'%7D&Content-Type=text/json").getResponseAsString();
+ assertEquals("class=org.apache.juneau.server.test.UrlContentResource$TestBean, value={f1:1,f2:'foobar'}", r);
+ }
+
+ //====================================================================================================
+ // Test URL &Content parameter containing an int
+ //====================================================================================================
+ @Test
+ public void testInt() throws Exception {
+ String r;
+ r = client.doGet(URL + "/testInt?content=123&Content-Type=text/json").getResponseAsString();
+ assertEquals("class=java.lang.Integer, value=123", r);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlPathPatternTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlPathPatternTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlPathPatternTest.java
new file mode 100755
index 0000000..42d367c
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/UrlPathPatternTest.java
@@ -0,0 +1,40 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.apache.juneau.json.*;
+import org.apache.juneau.server.*;
+import org.junit.*;
+
+public class UrlPathPatternTest {
+ @Test
+ public void testComparison() throws Exception {
+ List<UrlPathPattern> l = new LinkedList<UrlPathPattern>();
+
+ l.add(new UrlPathPattern("/foo"));
+ l.add(new UrlPathPattern("/foo/*"));
+ l.add(new UrlPathPattern("/foo/bar"));
+ l.add(new UrlPathPattern("/foo/bar/*"));
+ l.add(new UrlPathPattern("/foo/{id}"));
+ l.add(new UrlPathPattern("/foo/{id}/*"));
+ l.add(new UrlPathPattern("/foo/{id}/bar"));
+ l.add(new UrlPathPattern("/foo/{id}/bar/*"));
+
+ Collections.sort(l);
+ assertEquals("['/foo/bar','/foo/bar/*','/foo/{id}/bar','/foo/{id}/bar/*','/foo/{id}','/foo/{id}/*','/foo','/foo/*']", JsonSerializer.DEFAULT_LAX.serialize(l));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server/src/main/java/org/apache/juneau/server/RestServletContext.java
----------------------------------------------------------------------
diff --git a/juneau-server/src/main/java/org/apache/juneau/server/RestServletContext.java b/juneau-server/src/main/java/org/apache/juneau/server/RestServletContext.java
index 10bf747..8931047 100755
--- a/juneau-server/src/main/java/org/apache/juneau/server/RestServletContext.java
+++ b/juneau-server/src/main/java/org/apache/juneau/server/RestServletContext.java
@@ -32,12 +32,65 @@ import org.apache.juneau.server.annotation.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the REST servlet</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #REST_allowHeaderParams}</td>
+ * <td>Enable header URL parameters.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #REST_allowMethodParam}</td>
+ * <td>Enable <js>"method"</js> URL parameter for specific HTTP methods.</td>
+ * <td><code>String</code></td>
+ * <td><js>""</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #REST_allowContentParam}</td>
+ * <td>Enable <js>"content"</js> URL parameter.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #REST_renderResponseStackTraces}</td>
+ * <td>Render stack traces in HTTP response bodies when errors occur.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #REST_useStackTraceHashes}</td>
+ * <td>Use stack trace hashes.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #REST_defaultCharset}</td>
+ * <td>Default character encoding.</td>
+ * <td><code>String</code></td>
+ * <td><js>"utf-8"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #REST_paramFormat}</td>
+ * <td>Expected format of request parameters.</td>
+ * <td><code>String</code></td>
+ * <td><js>"UON"</js></td>
+ * </tr>
+ * </table>
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class RestServletContext extends Context {
/**
- * Allow header URL parameters ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Enable header URL parameters.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RestServlet.allowHeaderParams"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* When enabled, headers such as <js>"Accept"</js> and <js>"Content-Type"</js> to be passed in as URL query parameters.
* For example: <js>"?Accept=text/json&Content-Type=text/json"</js>
@@ -51,22 +104,39 @@ public final class RestServletContext extends Context {
public static final String REST_allowHeaderParams = "RestServlet.allowHeaderParams";
/**
- * Allow <js>"method"</js> URL parameter for specific HTTP methods (String, default=<js>""</js>, example=<js>"HEAD,OPTIONS"</js>).
+ * <b>Configuration property:</b> Enable <js>"method"</js> URL parameter for specific HTTP methods.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RestServlet.allowMethodParam"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>""</js>
+ * </ul>
* <p>
* When specified, the HTTP method can be overridden by passing in a <js>"method"</js> URL parameter on a regular GET request.
* For example: <js>"?method=OPTIONS"</js>
* <p>
- * Parameter name is case-insensitive. Use "*" to represent all methods. For backwards compatibility, "true" also means "*".
+ * Format is a comma-delimited list of HTTP method names that can be passed in as a method parameter.
+ * Parameter name is case-insensitive.
+ * Use "*" to represent all methods.
+ * For backwards compatibility, "true" also means "*".
* <p>
* Note that per the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html">HTTP specification</a>, special care should
* be taken when allowing non-safe (POST, PUT, DELETE) methods to be invoked through GET requests.
* <p>
* Applicable to servlet class only.
+ * <p>
+ * Example: <js>"HEAD,OPTIONS"</js>
*/
public static final String REST_allowMethodParam = "RestServlet.allowMethodParam";
/**
- * Allow <js>"content"</js> URL parameter ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Enable <js>"content"</js> URL parameter.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RestServlet.allowContentParam"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* When enabled, the HTTP body content on PUT and POST requests can be passed in as text using the <js>"content"</js> URL parameter.
* For example: <js>"?content={name:'John%20Smith',age:45}"</js>
@@ -80,7 +150,15 @@ public final class RestServletContext extends Context {
public static final String REST_allowContentParam = "RestServlet.allowContentParam";
/**
- * Render stack traces in HTTP response bodies when errors occur ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Render stack traces.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RestServlet.renderResponseStackTraces"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
+ * <p>
+ * Render stack traces in HTTP response bodies when errors occur.
* <p>
* When enabled, Java stack traces will be rendered in the output response.
* Useful for debugging, although allowing stack traces to be rendered may cause security concerns.
@@ -90,7 +168,13 @@ public final class RestServletContext extends Context {
public static final String REST_renderResponseStackTraces = "RestServlet.renderResponseStackTraces";
/**
- * Use stack trace hashes ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Use stack trace hashes.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RestServlet.useStackTraceHashes"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* When enabled, the number of times an exception has occurred will be determined based on stack trace hashsums,
* made available through the {@link RestException#getOccurrence()} method.
@@ -100,14 +184,28 @@ public final class RestServletContext extends Context {
public static final String REST_useStackTraceHashes = "RestServlet.useStackTraceHashes";
/**
- * The default character encoding for the request and response if not specified on the request ({@link String}>, default=<js>"utf-8"</js>).
+ * <b>Configuration property:</b> Default character encoding.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RestServlet.defaultCharset"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"utf-8"</js>
+ * </ul>
+ * <p>
+ * The default character encoding for the request and response if not specified on the request.
* <p>
* Applicable to servlet class and methods.
*/
public static final String REST_defaultCharset = "RestServlet.defaultCharset";
/**
- * The expected format of request parameters ({@link String}, default=<js>"UON"</js>).
+ * <b>Configuration property:</b> Expected format of request parameters.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RestServlet.paramFormat"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"UON"</js>
+ * </ul>
* <p>
* Possible values:
* <ul class='spaced-list'>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server/src/main/java/org/apache/juneau/server/vars/package.html
----------------------------------------------------------------------
diff --git a/juneau-server/src/main/java/org/apache/juneau/server/vars/package.html b/juneau-server/src/main/java/org/apache/juneau/server/vars/package.html
new file mode 100755
index 0000000..ac4588d
--- /dev/null
+++ b/juneau-server/src/main/java/org/apache/juneau/server/vars/package.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<!--
+/***************************************************************************************************************************
+ * 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.
+ *
+ ***************************************************************************************************************************/
+ -->
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+ /* For viewing in Page Designer */
+ @IMPORT url("../../../../javadoc.css");
+
+ /* For viewing in REST interface */
+ @IMPORT url("../htdocs/javadoc.css");
+ body {
+ margin: 20px;
+ }
+ </style>
+ <script>
+ /* Replace all @code and @link tags. */
+ window.onload = function() {
+ document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>');
+ document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>');
+ }
+ </script>
+</head>
+<body>
+<p>Predefined SVL variables</p>
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e2aa388..297bcdb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,7 +89,7 @@
<use>true</use>
<additionalparam>-sourcetab 3 -notimestamp -Xdoclint:none</additionalparam>
<verbose>false</verbose>
- <excludePackageNames>*proto*</excludePackageNames>
+ <excludePackageNames>*proto*:*samples*:*test*</excludePackageNames>
<links>
<link>http://docs.oracle.com/javase/7/docs/api/</link>
<link>http://docs.oracle.com/javaee/5/api/</link>
[18/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/xml/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/package.html b/juneau-core/src/main/java/org/apache/juneau/xml/package.html
index 9c7a2a3..c59df27 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/package.html
@@ -73,7 +73,6 @@
<ol>
<li><p><a class='doclink' href='#AutoDetectNamespaces'>Auto-detection of namespaces</a></p>
</ol>
- <li><p><a class='doclink' href='#UriProperties'>URI properties</a></p>
<li><p><a class='doclink' href='#BeanAnnotations'>@Bean and @BeanProperty annotations</a></p>
<li><p><a class='doclink' href='#Collections'>Collections</a></p>
<li><p><a class='doclink' href='#XmlSchemaSupport'>XML-Schema support</a></p>
@@ -304,14 +303,14 @@
<!-- ======================================================================================================== -->
<a id="XmlName"></a>
- <h4 class='topic' onclick='toggle(this)'>2.1.1 - @Xml.name()</h4>
+ <h4 class='topic' onclick='toggle(this)'>2.1.1 - @Bean.typeName()</h4>
<div class='topic'>
<p>
- The {@link org.apache.juneau.xml.annotation.Xml#name()} annotation can be used to override the Juneau default name on unnamed objects.
+ The {@link org.apache.juneau.annotation.Bean#typeName()} annotation can be used to override the Juneau default name on unnamed objects.
</p>
<h6 class='figure'>Example</h6>
<p class='bcode'>
- <ja>@Xml</ja>(name=<js>"person"</js>)
+ <ja>@Bean</ja>(typeName=<js>"person"</js>)
<jk>public class</jk> Person {
...
</p>
@@ -427,7 +426,7 @@
</p>
<h6 class='figure'>Example</h6>
<p class='bcode'>
- <ja>@Xml</ja>(name=<js>"MyBean"</js>)
+ <ja>@Bean</ja>(typeName=<js>"MyBean"</js>)
<jk>public class</jk> MyBean {
<ja>@Xml</ja>(format=XmlFormat.<jsf>CONTENT</jsf>)
@@ -634,7 +633,8 @@
On our bean class, we'll specify to use the <js>"http://www.ibm.com/person/"</js> namespace:
</p>
<p class='bcode'>
- <ja>@Xml</ja>(name=<js>"person"</js>, prefix=<js>"per"</js>)
+ <ja>@Xml</ja>(prefix=<js>"per"</js>)
+ <ja>@Bean</ja>(typeName=<js>"person"</js>)
<jk>public class</jk> Person {
...
</p>
@@ -698,137 +698,10 @@
</div>
</div>
-
- <!-- ======================================================================================================== -->
- <a id="UriProperties"></a>
- <h3 class='topic' onclick='toggle(this)'>2.3 - URI properties</h3>
- <div class='topic'>
- <p>
- The {@link org.apache.juneau.annotation.BeanProperty#beanUri} annotation is used to identify the URI
- of a bean.<br>
- Typically, this property will have a class type of {@link java.net.URI} or {@link java.net.URL}, although
- it can essentially be any type that resolves to a simple serializable type.
- </p>
- <p>
- In the following code, we're adding 2 new properties.<br>
- The first property is annotated with <ja>@BeanProperty</ja> to identify that this property is the
- resource identifier for this bean.<br>
- The second unannotated property is interpreted as a normal property.
- </p>
- <p class='bcode'>
- <ja>@Xml</ja>(name=<js>"person"</js>, prefix=<js>"per"</js>)
- <jk>public class</jk> Person {
-
- <jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>)
- <jk>public</jk> URI <jf>uri</jf>;
-
- <jk>public</jk> URI <jf>addressBookUri</jf>;
-
- ...
-
- <jc>// Normal constructor</jc>
- <jk>public</jk> Person(<jk>int</jk> id, String name, String uri, String addressBookUri) <jk>throws</jk> URISyntaxException {
- <jk>this</jk>.<jf>id</jf> = id;
- <jk>this</jk>.<jf>name</jf> = name;
- <jk>this</jk>.<jf>uri</jf> = <jk>new</jk> URI(uri);
- <jk>this</jk>.<jf>addressBookUri</jf> = <jk>new</jk> URI(addressBookUri);
- }
- }
- </p>
- <p>
- We alter our code to pass in values for these new properties.
- </p>
- <p class='bcode'>
- <jc>// Create our bean.</jc>
- Person p = <jk>new</jk> Person(1, <js>"John Smith"</js>, <js>"http://sample/addressBook/person/1"</js>, <js>"http://sample/addressBook"</js>);
- </p>
- <p>
- Now when we run the sample code, we get the following:
- </p>
- <p class='bcode'>
- <xt><per:person</xt>
- <xa>xmlns</xa>=<xs>'http://www.ibm.com/2013/Juneau'</xs>
- <xa>xmlns:per</xa>=<xs>'http://www.ibm.com/person/'</xs>
- <xa>xmlns:xsi</xa>=<xs>'http://www.w3.org/2001/XMLSchema-instance'</xs>
- <xa>uri</xa>=<xs>'http://sample/addressBook/person/1'</xs><xt>></xt>
- <xt><per:id></xt>1<xt></per:id></xt>
- <xt><per:name></xt>John Smith<xt></per:name></xt>
- <xt><per:addressBookUri></xt>http://sample/addressBook<xt></per:addressBookUri></xt>
- <xt></per:person></xt>
- </p>
- <p>
- Notice how the bean URI property is serialized as an XML attribute while the normal URI property is
- serialized normally as an element.
- </p>
- <p>
- Bean properties that resolve as XML attributes can also be assigned namespaces.<br>
- For example, let's assign our bean URI to another namespace.
- </p>
- <p class='bcode'>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>)
- <ja>@Xml</ja>(prefix=<js>"ab"</js>)
- <jk>public</jk> URI <jf>uri</jf>;
- </p>
- <p>
- Now when we run the sample code, we see that our <xa>uri</xa> attribute is assigned that namespace prefix.
- </p>
- <p class='bcode'>
- <xt><per:person</xt>
- <xa>xmlns</xa>=<xs>'http://www.ibm.com/2013/Juneau'</xs>
- <xa>xmlns:per</xa>=<xs>'http://www.ibm.com/person/'</xs>
- <xa>xmlns:ab</xa>=<xs>'http://www.ibm.com/addressBook/'</xs>
- <xa>xmlns:xsi</xa>=<xs>'http://www.w3.org/2001/XMLSchema-instance'</xs>
- <xa>ab:uri</xa>=<xs>'http://sample/addressBook/person/1'</xs><xt>></xt>
- <xt><per:id></xt>1<xt></per:id></xt>
- <xt><per:name></xt>John Smith<xt></per:name></xt>
- <xt><per:addressBookUri></xt>http://sample/addressBook<xt></per:addressBookUri></xt>
- <xt></per:person></xt>
- </p>
- <p>
- The {@link org.apache.juneau.annotation.URI} annotation can also be used on classes and properties
- to identify them as URLs when they're not instances of <code>java.net.URI</code> or <code>java.net.URL</code>
- (not needed if <code><ja>@BeanProperty</ja>(beanUri=<jk>true</jk>)</code> is already specified).
- </p>
- <p>
- The following properties would have produced the same output as before.
- </p>
- <p class='bcode'>
- <jk>public class</jk> Person {
-
- <jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> String <jf>uri</jf>;
- </p>
- <p>
- Also take note of the {@link org.apache.juneau.serializer.SerializerContext#SERIALIZER_absolutePathUriBase SERIALIZER_absolutePathUriBase} and
- {@link org.apache.juneau.serializer.SerializerContext#SERIALIZER_relativeUriBase SERIALIZER_relativeUriBase}
- settings that can be specified on the serializer to resolve relative and context-root-relative URIs to fully-qualfied URIs.
- </p>
- <p>
- This can be useful if you want to keep the URI authority and context root information out of the bean logic layer.
- </p>
- <p>
- The following code produces the same output as before, but the URIs on the beans are relative.
- </p>
- <p class='bcode'>
- <jc>// Create a new serializer with readable output.</jc>
- XmlSerializer s = <jk>new</jk> XmlSerializer()
- .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>)
- .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>)
- .setProperty(SerializerContext.<jsf>SERIALIZER_relativeUriBase</jsf>, <js>"http://myhost/sample"</js>);
- .setProperty(SerializerContext.<jsf>SERIALIZER_absolutePathUriBase</jsf>, <js>"http://myhost"</js>);
-
- <jc>// Create our bean.</jc>
- Person p = <jk>new</jk> Person(1, <js>"John Smith"</js>, <js>"person/1"</js>, <js>"/"</js>);
-
- <jc>// Serialize the bean to RDF/XML.</jc>
- String rdfXml = s.serialize(p);
- </p>
- </div>
<!-- ======================================================================================================== -->
<a id="BeanAnnotations"></a>
- <h3 class='topic' onclick='toggle(this)'>2.4 - @Bean and @BeanProperty annotations</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.3 - @Bean and @BeanProperty annotations</h3>
<div class='topic'>
<p>
The {@link org.apache.juneau.annotation.Bean @Bean} and {@link org.apache.juneau.annotation.BeanProperty @BeanProperty} annotations
@@ -848,11 +721,12 @@
Using transforms, we can convert them to standardized string forms.
</p>
<p class='bcode'>
- <ja>@Xml</ja>(name=<js>"person"</js>, prefix=<js>"per"</js>)
+ <ja>@Xml</ja>(prefix=<js>"per"</js>)
+ <ja>@Bean</ja>(typeName=<js>"person"</js>)
<jk>public class</jk> Person {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar birthDate;
+ <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar birthDate;
...
<jc>// Normal constructor</jc>
@@ -893,8 +767,8 @@
</p>
<h6 class='figure'>Example</h6>
<p class='bcode'>
- <ja>@Xml</ja>(name=<js>"person"</js>, prefix=<js>"per"</js>)
- <ja>@Bean</ja>(propertyNamer=PropertyNamerDashedLC.<jk>class</jk>)
+ <ja>@Xml</ja>(prefix=<js>"per"</js>)
+ <ja>@Bean</ja>(typeName=<js>"person"</js>,propertyNamer=PropertyNamerDashedLC.<jk>class</jk>)
<jk>public class</jk> Person {
...
</p>
@@ -916,7 +790,7 @@
<!-- ======================================================================================================== -->
<a id="Collections"></a>
- <h3 class='topic' onclick='toggle(this)'>2.5 - Collections</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.4 - Collections</h3>
<div class='topic'>
<p>
In our example, let's add a list-of-beans property to our sample class:
@@ -933,11 +807,12 @@
The <code>Address</code> class has the following properties defined:
</p>
<p class='bcode'>
- <ja>@Xml</ja>(name=<js>"address"</js>, prefix=<js>"addr"</js>)
+ <ja>@Xml</ja>(prefix=<js>"addr"</js>)
+ <ja>@Bean</ja>(typeName=<js>"address"</js>)
<jk>public class</jk> Address {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
+ <ja>@Xml</ja>(format=<jsf>ATTR</jsf>) <jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>personUri</jf>;
<jk>public int</jk> <jf>id</jf>;
<ja>@Xml</ja>(prefix=<js>"mail"</js>) <jk>public</jk> String <jf>street</jf>, <jf>city</jf>, <jf>state</jf>;
@@ -1000,7 +875,7 @@
<!-- ======================================================================================================== -->
<a id="XmlSchemaSupport"></a>
- <h3 class='topic' onclick='toggle(this)'>2.6 - XML-Schema support</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.5 - XML-Schema support</h3>
<div class='topic'>
<p>
Juneau provides the {@link org.apache.juneau.xml.XmlSchemaSerializer} class for generating XML-Schema documents
@@ -1024,14 +899,14 @@
Since we have not defined a default namespace, everything is defined under the default Juneau namespace.
</p>
<p class='bcode'>
- <ja>@Xml</ja>(name=<js>"person"</js>)
+ <ja>@Bean</ja>(typeName=<js>"person"</js>)
<jk>public class</jk> Person {
<jc>// Bean properties</jc>
<jk>public int</jk> <jf>id</jf>;
<jk>public</jk> String <jf>name</jf>;
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
+ <ja>@Xml</ja>(format=<jsf>ATTR</jsf>) <jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>addressBookUri</jf>;
- <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
+ <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
<jk>public</jk> LinkedList<Address> <jf>addresses</jf> = <jk>new</jk> LinkedList<Address>();
<jc>// Bean constructor (needed by parser)</jc>
@@ -1048,10 +923,10 @@
}
}
- <ja>@Xml</ja>(name=<js>"address"</js>)
+ <ja>@Bean</ja>(typeName=<js>"address"</js>)
<jk>public class</jk> Address {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
+ <ja>@Xml</ja>(format=<jsf>ATTR</jsf>) <jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>personUri</jf>;
<jk>public int</jk> <jf>id</jf>;
<jk>public</jk> String <jf>street</jf>, <jf>city</jf>, <jf>state</jf>;
@@ -1164,12 +1039,14 @@
Now if we add in some namespaces, we'll see how multiple namespaces are handled.
</p>
<p class='bcode'>
- <ja>@Xml</ja></ja>(name=<js>"person"</js>, prefix=<js>"per"</js>)
+ <ja>@Xml</ja></ja>(prefix=<js>"per"</js>)
+ <ja>@Bean</ja></ja>(typeName=<js>"person"</js>)
<jk>public class</jk> Person {
...
}
- <ja>@Xml</ja>(name=<js>"address"</js>, prefix=<js>"addr"</js>)
+ <ja>@Xml</ja>(prefix=<js>"addr"</js>)
+ <ja>@Bean</ja>(typeName=<js>"address"</js>)
<jk>public class</jk> Address {
...
<ja>@Xml</ja>(prefix=<js>"mail"</js>) <jk>public</jk> String <jf>street</jf>, <jf>city</jf>, <jf>state</jf>;
@@ -1330,7 +1207,7 @@
<!-- ======================================================================================================== -->
<a id="Recursion"></a>
- <h3 class='topic' onclick='toggle(this)'>2.7 - Non-tree models and recursion detection</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.6 - Non-tree models and recursion detection</h3>
<div class='topic'>
<p>
The XML serializer is designed to be used against POJO tree structures. <br>
@@ -1348,7 +1225,7 @@
For example, let's make a POJO model out of the following classes:
</p>
<p class='bcode'>
- <ja>@Xml</ja>(name=<js>"a"</js>)
+ <ja>@Bean</ja>(typeName=<js>"a"</js>)
<jk>public class</jk> A {
<jk>public</jk> B b;
}
@@ -1403,7 +1280,7 @@
<!-- ======================================================================================================== -->
<a id="SerializerConfigurableProperties"></a>
- <h3 class='topic' onclick='toggle(this)'>2.8 - Configurable properties</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.7 - Configurable properties</h3>
<div class='topic'>
<p>
See the following classes for all configurable properties that can be used on this serializer:
@@ -1417,7 +1294,7 @@
<!-- ======================================================================================================== -->
<a id="SerializerOtherNotes"></a>
- <h3 class='topic' onclick='toggle(this)'>2.9 - Other notes</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.8 - Other notes</h3>
<div class='topic'>
<ul class='spaced-list'>
<li>Like all other Juneau serializers, the XML serializer is thread safe and maintains an internal cache of bean classes encountered.<br>
[04/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/NoParserInputTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/NoParserInputTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/NoParserInputTest.java
new file mode 100755
index 0000000..c17f658
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/NoParserInputTest.java
@@ -0,0 +1,70 @@
+// ***************************************************************************************************************************
+// * 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 org.apache.juneau.client.*;
+import org.apache.juneau.plaintext.*;
+import org.junit.*;
+
+public class NoParserInputTest {
+
+ private static String URL = "/testNoParserInput";
+ private static boolean debug = false;
+
+ //====================================================================================================
+ // @Content annotated InputStream.
+ //====================================================================================================
+ @Test
+ public void testInputStream() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String r = client.doPut(URL + "/testInputStream", "foo").getResponseAsString();
+ assertEquals("foo", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @Content annotated Reader.
+ //====================================================================================================
+ @Test
+ public void testReader() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String r = client.doPut(URL + "/testReader", "foo").getResponseAsString();
+ assertEquals("foo", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @Content annotated PushbackReader.
+ // This should always fail since the servlet reader is not a pushback reader.
+ //====================================================================================================
+ @Test
+ public void testPushbackReader() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ try {
+ client.doPut(URL + "/testPushbackReader?noTrace=true", "foo").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Invalid argument type passed to the following method:",
+ "'public java.lang.String org.apache.juneau.server.test.NoParserInputResource.testPushbackReader(java.io.PushbackReader) throws java.lang.Exception'");
+ }
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/OnPostCallTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/OnPostCallTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/OnPostCallTest.java
new file mode 100755
index 0000000..ae64011
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/OnPostCallTest.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 static org.junit.Assert.*;
+
+import java.io.*;
+
+import org.apache.juneau.client.*;
+import org.junit.*;
+
+public class OnPostCallTest {
+
+ private static String URL = "/testOnPostCall";
+
+ //====================================================================================================
+ // Properties overridden via properties annotation.
+ //====================================================================================================
+ @Test
+ public void testPropertiesOverridenByAnnotation() throws Exception {
+ RestClient client = new TestRestClient().setAccept("text/s1");
+ String url = URL + "/testPropertiesOverridenByAnnotation";
+ String r;
+ RestCall rc;
+
+ r = client.doPut(url, new StringReader("")).getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s1", r);
+
+ r = client.doPut(url, new StringReader("")).setHeader("Override-Accept", "text/s2").getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s2", r);
+
+ rc = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/s3").connect();
+ r = rc.getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s1", r);
+ assertTrue(rc.getResponse().getFirstHeader("Content-Type").getValue().startsWith("text/s3"));
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Properties overridden via properties annotation. Default Accept header.
+ //====================================================================================================
+ @Test
+ public void testPropertiesOverridenByAnnotationDefaultAccept() throws Exception {
+ RestClient client = new TestRestClient().setAccept("");
+ String url = URL + "/testPropertiesOverridenByAnnotation";
+ String r;
+ RestCall rc;
+
+ r = client.doPut(url, new StringReader("")).getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s2", r);
+
+ r = client.doPut(url, new StringReader("")).setHeader("Override-Accept", "text/s3").getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s3", r);
+
+ rc = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/s3").connect();
+ r = rc.getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s2", r);
+ assertTrue(rc.getResponse().getFirstHeader("Content-Type").getValue().startsWith("text/s3"));
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Properties overridden programmatically.
+ //====================================================================================================
+ @Test
+ public void testPropertiesOverriddenProgramatically() throws Exception {
+ RestClient client = new TestRestClient().setAccept("text/s1");
+ String url = URL + "/testPropertiesOverriddenProgramatically";
+ String r;
+ RestCall rc;
+
+ r = client.doPut(url, new StringReader("")).getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s1", r);
+
+ r = client.doPut(url, new StringReader("")).setHeader("Override-Accept", "text/s2").getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s2", r);
+
+ rc = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/s3").connect();
+ r = rc.getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s1", r);
+ assertTrue(rc.getResponse().getFirstHeader("Content-Type").getValue().startsWith("text/s3"));
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Properties overridden programmatically. Default Accept header.
+ //====================================================================================================
+ @Test
+ public void testPropertiesOverriddenProgramaticallyDefaultAccept() throws Exception {
+ RestClient client = new TestRestClient().setAccept("");
+ String url = URL + "/testPropertiesOverriddenProgramatically";
+ String r;
+ RestCall rc;
+
+ r = client.doPut(url, new StringReader("")).getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s2", r);
+
+ r = client.doPut(url, new StringReader("")).setHeader("Override-Accept", "text/s3").getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s3", r);
+
+ rc = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/s3").connect();
+ r = rc.getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s2", r);
+ assertTrue(rc.getResponse().getFirstHeader("Content-Type").getValue().startsWith("text/s3"));
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/OnPreCallTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/OnPreCallTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/OnPreCallTest.java
new file mode 100755
index 0000000..173a472
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/OnPreCallTest.java
@@ -0,0 +1,61 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import static org.junit.Assert.*;
+
+import java.io.*;
+
+import org.apache.juneau.client.*;
+import org.junit.*;
+
+public class OnPreCallTest {
+
+ private static String URL = "/testOnPreCall";
+
+ //====================================================================================================
+ // Properties overridden via properties annotation.
+ //====================================================================================================
+ @Test
+ public void testPropertiesOverriddenByAnnotation() throws Exception {
+ RestClient client = new TestRestClient().setContentType("text/a1").setAccept("text/plain");
+ String url = URL + "/testPropertiesOverriddenByAnnotation";
+ String r;
+
+ r = client.doPut(url, new StringReader("")).getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/a1", r);
+
+ r = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/a2").getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/a2", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Properties overridden programmatically.
+ //====================================================================================================
+ @Test
+ public void testPropertiesOverriddenProgrammatically() throws Exception {
+ RestClient client = new TestRestClient().setContentType("text/a1").setAccept("text/plain");
+ String url = URL + "/testPropertiesOverriddenProgrammatically";
+ String r;
+
+ r = client.doPut(url, new StringReader("")).getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=pp4,p5=xp5,contentType=text/a1", r);
+
+ r = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/a2").getResponseAsString();
+ assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=pp4,p5=xp5,contentType=text/a2", r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/OptionsWithoutNlsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/OptionsWithoutNlsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/OptionsWithoutNlsTest.java
new file mode 100755
index 0000000..5b73388
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/OptionsWithoutNlsTest.java
@@ -0,0 +1,51 @@
+// ***************************************************************************************************************************
+// * 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.apache.juneau.server.labels.*;
+import org.junit.*;
+
+public class OptionsWithoutNlsTest {
+
+ private static String URL = "/testOptionsWithoutNls";
+
+ //====================================================================================================
+ // Should get to the options page without errors
+ //====================================================================================================
+ @Test
+ public void testOptions() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ RestCall r = client.doOptions(URL + "/testOptions");
+ ResourceOptions o = r.getResponse(ResourceOptions.class);
+ assertEquals("", o.getDescription());
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Missing resource bundle should cause {!!x} string.
+ //====================================================================================================
+ @Test
+ public void testMissingResourceBundle() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ RestCall r = client.doGet(URL + "/testMissingResourceBundle");
+ String o = r.getResponse(String.class);
+ assertEquals("{!!bad}", o);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/OverlappingMethodsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/OverlappingMethodsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/OverlappingMethodsTest.java
new file mode 100755
index 0000000..0573eda
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/OverlappingMethodsTest.java
@@ -0,0 +1,170 @@
+// ***************************************************************************************************************************
+// * 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 org.apache.juneau.client.*;
+import org.junit.*;
+
+public class OverlappingMethodsTest {
+
+ private static String URL = "/testOverlappingMethods";
+ private static boolean debug = false;
+
+ //====================================================================================================
+ // Overlapping guards
+ //====================================================================================================
+ @Test
+ public void testOverlappingGuards1() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testOverlappingGuards1";
+
+ r = client.doGet(url + "?t1=1").getResponseAsString();
+ assertEquals("test1_doGet", r);
+
+ try {
+ client.doGet(url + "?noTrace=true").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_FORBIDDEN, "Access denied by guard");
+ }
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Overlapping guards
+ //====================================================================================================
+ @Test
+ public void testOverlappingGuards2() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testOverlappingGuards2";
+ try {
+ client.doGet(url + "?noTrace=true").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_FORBIDDEN, "Access denied by guard");
+ }
+
+ try {
+ client.doGet(url + "?t1=1&noTrace=true").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_FORBIDDEN, "Access denied by guard");
+ }
+
+ try {
+ client.doGet(url + "?t2=2&noTrace=true").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_FORBIDDEN, "Access denied by guard");
+ }
+
+ r = client.doGet(url + "?t1=1&t2=2").getResponseAsString();
+ assertEquals("test2_doGet", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Overlapping matchers
+ //====================================================================================================
+ @Test
+ public void testOverlappingMatchers1() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testOverlappingMatchers1";
+
+ r = client.doGet(url + "?t1=1").getResponseAsString();
+ assertEquals("test3a", r);
+
+ r = client.doGet(url + "?t2=2").getResponseAsString();
+ assertEquals("test3b", r);
+
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("test3c", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Overlapping matchers
+ //====================================================================================================
+ @Test
+ public void testOverlappingMatchers2() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testOverlappingMatchers2";
+
+ r = client.doGet(url + "?t1=1").getResponseAsString();
+ assertEquals("test4b", r);
+
+ r = client.doGet(url + "?t2=2").getResponseAsString();
+ assertEquals("test4b", r);
+
+ r = client.doGet(url + "?t1=1&t2=2").getResponseAsString();
+ assertEquals("test4b", r);
+
+ r = client.doGet(url + "?tx=x").getResponseAsString();
+ assertEquals("test4a", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Overlapping URL patterns
+ //====================================================================================================
+ @Test
+ public void testOverlappingUrlPatterns() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testOverlappingUrlPatterns";
+
+ // [/test5] = [test5a]
+ // [/test5/*] = [test5b] -- Cannot get called.
+ // [/test5/foo] = [test5c]
+ // [/test5/foo/*] = [test5d]
+ // [/test5/{id}] = [test5e]
+ // [/test5/{id}/*] = [test5f]
+ // [/test5/{id}/foo] = [test5g]
+ // [/test5/{id}/foo/*] = [test5h]
+
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("test5a", r);
+
+ r = client.doGet(url + "/foo").getResponseAsString();
+ assertEquals("test5c", r);
+
+ r = client.doGet(url + "/foo/x").getResponseAsString();
+ assertEquals("test5d", r);
+
+ r = client.doGet(url + "/x").getResponseAsString();
+ assertEquals("test5e", r);
+
+ r = client.doGet(url + "/x/x").getResponseAsString();
+ assertEquals("test5f", r);
+
+ r = client.doGet(url + "/x/foo").getResponseAsString();
+ assertEquals("test5g", r);
+
+ r = client.doGet(url + "/x/foo/x").getResponseAsString();
+ assertEquals("test5h", r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/ParamsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/ParamsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ParamsTest.java
new file mode 100755
index 0000000..2542b08
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ParamsTest.java
@@ -0,0 +1,716 @@
+// ***************************************************************************************************************************
+// * 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.util.*;
+
+import org.apache.http.*;
+import org.apache.http.client.entity.*;
+import org.apache.http.entity.*;
+import org.apache.http.message.*;
+import org.apache.juneau.*;
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+public class ParamsTest {
+
+ private static String URL = "/testParams";
+ private static boolean debug = false;
+
+ //====================================================================================================
+ // Basic tests
+ //====================================================================================================
+ @Test
+ public void testBasic() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ RestCall r;
+
+ // @Override
+ // @RestMethod(name="GET",pattern="/")
+ // public void doGet(RestRequest req, RestResponse res) {
+ // res.setOutput("No args");
+ // }
+ r = client.doGet(URL);
+ assertEquals("GET", r.getResponse(String.class));
+
+ r = client.doGet(URL + "/getx?noTrace=true");
+ try {
+ r.connect();
+ fail("Connection should have failed.");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_FOUND, "Method 'GET' not found on resource with matching pattern on path '/getx'");
+ }
+
+ // @RestMethod(name="GET",pattern="/get1")
+ // public void doGet1(RestRequest req, RestResponse res) {
+ // res.setOutput("/get1");
+ // }
+ r = client.doGet(URL + "/get1");
+ assertEquals("GET /get1", r.getResponse(String.class));
+
+ r = client.doGet(URL + "/get1a?noTrace=true");
+ try {
+ r.connect();
+ fail("Connection should have failed.");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_FOUND, "Method 'GET' not found on resource with matching pattern on path '/get1a'");
+ }
+
+ // @RestMethod(name="GET",pattern="/get1/{foo}")
+ // public void doGet(RestRequest req, RestResponse res, String foo) {
+ // res.setOutput("/get1/" + foo);
+ // }
+ r = client.doGet(URL + "/get1/foo");
+ assertEquals("GET /get1a foo", r.getResponse(String.class));
+
+ // URL-encoded part should not get decoded before finding method to invoke.
+ // This should match /get1/{foo} and not /get1/{foo}/{bar}
+ // NOTE: When testing on Tomcat, must specify the following system property:
+ // -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
+ String x = "x%2Fy+z"; // [x/y z]
+ r = client.doGet(URL + "/get1/"+x);
+ assertEquals("GET /get1a x/y z", r.getResponse(String.class));
+
+ r = client.doGet(URL + "/get1/"+x+"/"+x);
+ assertEquals("GET /get1b x/y z,x/y z", r.getResponse(String.class));
+
+ r = client.doGet(URL + "/get1/foo");
+ assertEquals("GET /get1a foo", r.getResponse(String.class));
+
+ r = client.doGet(URL + "/get1/foo/bar/baz?noTrace=true");
+ try {
+ r.connect();
+ fail("Connection should have failed.");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_FOUND, "Method 'GET' not found on resource with matching pattern on path '/get1/foo/bar/baz'");
+ }
+
+ // @RestMethod(name="GET",pattern="/get3/{foo}/{bar}/*")
+ // public void doGet3(RestRequest req, RestResponse res, String foo, int bar) {
+ // res.setOutput("/get3/"+foo+"/"+bar+", remainder="+req.getRemainder());
+ // }
+ r = client.doGet(URL + "/get3/foo/123");
+ assertEquals("GET /get3/foo/123 remainder=null", r.getResponse(String.class));
+
+ r = client.doGet(URL + "/get3/foo/123/xxx");
+ assertEquals("GET /get3/foo/123 remainder=xxx", r.getResponse(String.class));
+
+ // // Test method name with overlapping name, remainder allowed.
+ // @RestMethod(name="GET2")
+ // public void get2(RestRequest req, RestResponse res) {
+ // res.setOutput("GET2, remainder="+req.getRemainder());
+ // }
+ r = client.doGet(URL + "?method=get2");
+ assertEquals("GET2 remainder=null", r.getResponse(String.class));
+ r = client.doGet(URL + "/foo/bar?method=get2");
+ assertEquals("GET2 remainder=foo/bar", r.getResponse(String.class));
+ r = client.doGet(URL + "/foo/bar?method=GET2");
+ assertEquals("GET2 remainder=foo/bar", r.getResponse(String.class));
+
+ // // Default POST
+ // @Override
+ // public void doPost(RestRequest req, RestResponse res) {
+ // res.setOutput("POST, remainder="+req.getRemainder());
+ // }
+ r = client.doPost(URL, "");
+ assertEquals("POST remainder=null", r.getResponse(String.class));
+ r = client.doPost(URL + "/foo", "");
+ assertEquals("POST remainder=foo", r.getResponse(String.class));
+
+ // // Bunch of different argument types
+ // @RestMethod(name="POST",pattern="/person/{person}")
+ // public void doPost(RestRequest req, RestResponse res, Person p) {
+ // res.setOutput("POST, /person, name="+p.name+", age="+p.age+" remainder="+req.getRemainder());
+ // }
+ r = client.doPost(URL + "/person/(name=John+Smith,birthDate=Jan+12~,+1952)", "");
+ assertEquals("POST /person/{name=John Smith,birthDate.year=1952} remainder=null", r.getResponse(String.class));
+
+ // Fall through to top-level POST
+ r = client.doPost(URL + "/person/(name:'John+Smith',age:123)/foo", "");
+ assertEquals("POST remainder=person/(name:'John Smith',age:123)/foo", r.getResponse(String.class));
+
+ // // Various primitive types
+ // @RestMethod(name="PUT",pattern="/primitives/{xInt}.{xShort},{xLong}/{xChar}/{xFloat}/{xDouble}/{xByte}/{xBoolean}")
+ // public void doPut1(RestRequest req, RestResponse res, int xInt, short xShort, long xLong, char xChar, float xFloat, double xDouble, byte xByte, boolean xBoolean) {
+ // res.setOutput("PUT, /primitives/"+xInt+"."+xShort+","+xLong+"/"+xChar+"/"+xFloat+"/"+xDouble+"/"+xByte+"/"+xBoolean);
+ // }
+ r = client.doPut(URL + "/primitives/1/2/3/x/4/5/6/true", "");
+ assertEquals("PUT /primitives/1/2/3/x/4.0/5.0/6/true", r.getResponse(String.class));
+
+ // // Various primitive objects
+ // @RestMethod(name="PUT",pattern="/primitiveObjects/{xInt}/{xShort}/{xLong}/{xChar}/{xFloat}/{xDouble}/{xByte}/{xBoolean}")
+ // public void doPut1(RestRequest req, RestResponse res, Integer xInt, Short xShort, Long xLong, Character xChar, Float xFloat, Double xDouble, Byte xByte, Boolean xBoolean) {
+ // res.setOutput("PUT /primitives/"+xInt+"/"+xShort+"/"+xLong+"/"+xChar+"/"+xFloat+"/"+xDouble+"/"+xByte+"/"+xBoolean);
+ // }
+ r = client.doPut(URL + "/primitiveObjects/1/2/3/x/4/5/6/true", "");
+ assertEquals("PUT /primitiveObjects/1/2/3/x/4.0/5.0/6/true", r.getResponse(String.class));
+
+ // // Object with forString(String) method
+ // @RestMethod(name="PUT",pattern="/uuid/{uuid}")
+ // public void doPut1(RestRequest req, RestResponse res, UUID uuid) {
+ // res.setOutput("PUT /uuid/"+uuid);
+ // }
+ UUID uuid = UUID.randomUUID();
+ r = client.doPut(URL + "/uuid/"+uuid, "");
+ assertEquals("PUT /uuid/"+uuid, r.getResponse(String.class));
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @Param annotation - GET
+ //====================================================================================================
+ @Test
+ public void testParamGet() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testParamGet";
+
+ r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
+ assertEquals("p1=[p1,p1,p1],p2=[2,2,2]", r);
+
+ r = client.doGet(url + "?p1&p2").getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doGet(url + "?p1").getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doGet(url + "?p2").getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
+ assertEquals("p1=[foo,foo,foo],p2=[0,null,0]", r);
+
+ r = client.doGet(url + "?p1&p2=1").getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[1,1,1]", r);
+
+ String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
+ r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
+ assertEquals("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d e],p2=[1,1,1]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @Param(format=PLAIN) annotation - GET
+ //====================================================================================================
+ @Test
+ public void testPlainParamGet() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testPlainParamGet";
+
+ r = client.doGet(url + "?p1=(p1)").getResponseAsString();
+ assertEquals("p1=[(p1),(p1),p1]", r);
+
+ r = client.doGet(url + "?p1=$s(p1)").getResponseAsString();
+ assertEquals("p1=[$s(p1),$s(p1),p1]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @Param annotation - POST
+ //====================================================================================================
+ @Test
+ public void testParamPost() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testParamPost";
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
+ assertEquals("p1=[p1,p1,p1],p2=[2,$n(2),2]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null,p2:0}")).getResponseAsString();
+ assertEquals("p1=[null,\u0000,null],p2=[0,$n(0),0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null}")).getResponseAsString();
+ assertEquals("p1=[null,\u0000,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p2:0}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,$n(0),0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
+ assertEquals("p1=[foo,foo,foo],p2=[0,$n(0),0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null,p2:1}")).getResponseAsString();
+ assertEquals("p1=[null,\u0000,null],p2=[1,$n(1),1]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d e,f/g%h=i j',p2:1}")).getResponseAsString();
+ assertEquals("p1=[a/b%c=d e,f/g%h=i j,a/b%c=d e,f/g%h=i j,a/b%c=d e,f/g%h=i j],p2=[1,$n(1),1]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @Param(format=PLAIN) annotation - POST
+ //====================================================================================================
+ @Test
+ public void testPlainParamPost() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testPlainParamPost";
+
+ List<NameValuePair> nvps = new ArrayList<NameValuePair>();
+ nvps.add(new BasicNameValuePair("p1", "(p1)"));
+ HttpEntity he = new UrlEncodedFormEntity(nvps);
+
+ r = client.doPost(url, he).getResponseAsString();
+ assertEquals("p1=[(p1),(p1),p1]", r);
+
+ nvps = new ArrayList<NameValuePair>();
+ nvps.add(new BasicNameValuePair("p1", "$s(p1)"));
+ he = new UrlEncodedFormEntity(nvps);
+
+ r = client.doFormPost(url, he).getResponseAsString();
+ assertEquals("p1=[$s(p1),$s(p1),p1]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @QParam annotation - GET
+ //====================================================================================================
+ @Test
+ public void testQParamGet() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testQParamGet";
+
+ r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
+ assertEquals("p1=[p1,p1,p1],p2=[2,2,2]", r);
+
+ r = client.doGet(url + "?p1&p2").getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doGet(url + "?p1").getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doGet(url + "?p2").getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
+ assertEquals("p1=[foo,foo,foo],p2=[0,null,0]", r);
+
+ r = client.doGet(url + "?p1&p2=1").getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[1,1,1]", r);
+
+ String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
+ r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
+ assertEquals("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d e],p2=[1,1,1]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @QParam(format=PLAIN) annotation - GET
+ //====================================================================================================
+ @Test
+ public void testPlainQParamGet() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testPlainQParamGet";
+
+ r = client.doGet(url + "?p1=(p1)").getResponseAsString();
+ assertEquals("p1=[(p1),(p1),p1]", r);
+
+ r = client.doGet(url + "?p1=$s(p1)").getResponseAsString();
+ assertEquals("p1=[$s(p1),$s(p1),p1]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @QParam annotation - POST
+ //====================================================================================================
+ @Test
+ public void testQParamPost() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testQParamPost";
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null,p2:0}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p2:0}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null,p2:1}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d e,f/g%h=i j',p2:1}")).getResponseAsString();
+ assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @HasParam annotation - GET
+ //====================================================================================================
+ @Test
+ public void testHasParamGet() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testHasParamGet";
+
+ r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doGet(url + "?p1&p2").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doGet(url + "?p1").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[false,false]", r);
+
+ r = client.doGet(url + "?p2").getResponseAsString();
+ assertEquals("p1=[false,false],p2=[true,true]", r);
+
+ r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doGet(url + "?p1&p2=1").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ String x = "x%2Fy%25z%3Da+b"; // [x/y%z=a+b]
+ r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @HasParam annotation - POST
+ //====================================================================================================
+ @Test
+ public void testHasParamPost() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testHasParamPost";
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null,p2:0}")).getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null}")).getResponseAsString();
+ assertEquals("p1=[true,true],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p2:0}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[true,true]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null,p2:1}")).getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d e,f/g%h=i j',p2:1}")).getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @HasQParam annotation - GET
+ //====================================================================================================
+ @Test
+ public void testHasQParamGet() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testHasQParamGet";
+
+ r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doGet(url + "?p1&p2").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doGet(url + "?p1").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[false,false]", r);
+
+ r = client.doGet(url + "?p2").getResponseAsString();
+ assertEquals("p1=[false,false],p2=[true,true]", r);
+
+ r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ r = client.doGet(url + "?p1&p2=1").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ String x = "x%2Fy%25z%3Da+b"; // [x/y%z=a+b]
+ r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
+ assertEquals("p1=[true,true],p2=[true,true]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // @HasQParam annotation - POST
+ //====================================================================================================
+ @Test
+ public void testHasQParamPost() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testHasQParamPost";
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null,p2:0}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p2:0}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:null,p2:1}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d e,f/g%h=i j',p2:1}")).getResponseAsString();
+ assertEquals("p1=[false,false],p2=[false,false]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Form POSTS with @Content parameter
+ //====================================================================================================
+ @Test
+ public void testFormPostAsContent() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testFormPostAsContent";
+
+ r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
+ assertEquals("bean=[{p1:'p1',p2:2}],qp1=[null],qp2=[0],hqp1=[false],hqp2=[false]", r);
+
+ r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
+ assertEquals("bean=[{p2:0}],qp1=[null],qp2=[0],hqp1=[false],hqp2=[false]", r);
+
+ r = client.doFormPost(url+"?p1=p3&p2=4", new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
+ assertEquals("bean=[{p1:'p1',p2:2}],qp1=[p3],qp2=[4],hqp1=[true],hqp2=[true]", r);
+
+ r = client.doFormPost(url+"?p1=p3&p2=4", new ObjectMap("{}")).getResponseAsString();
+ assertEquals("bean=[{p2:0}],qp1=[p3],qp2=[4],hqp1=[true],hqp2=[true]", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test @Param and @QParam annotations when using multi-part parameters (e.g. &key=val1,&key=val2).
+ //====================================================================================================
+ @Test
+ public void testMultiPartParams() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testMultiPartParams";
+
+ String in = ""
+ + "?p1=a&p1=b"
+ + "&p2=1&p2=2"
+ + "&p3=a&p3=b"
+ + "&p4=1&p4=2"
+ + "&p5=a&p5=b"
+ + "&p6=1&p6=2"
+ + "&p7=a&p7=b"
+ + "&p8=1&p8=2"
+ + "&p9=(a=1,b=2,c=false)&p9=(a=3,b=4,c=true)"
+ + "&p10=(a=1,b=2,c=false)&p10=(a=3,b=4,c=true)"
+ + "&p11=(a=1,b=2,c=false)&p11=(a=3,b=4,c=true)"
+ + "&p12=(a=1,b=2,c=false)&p12=(a=3,b=4,c=true)";
+ r = client.doGet(url + in).getResponseAsString();
+ String e = "{"
+ + "p1:['a','b'],"
+ + "p2:[1,2],"
+ + "p3:['a','b'],"
+ + "p4:[1,2],"
+ + "p5:['a','b'],"
+ + "p6:[1,2],"
+ + "p7:['a','b'],"
+ + "p8:[1,2],"
+ + "p9:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
+ + "p10:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
+ + "p11:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
+ + "p12:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}]"
+ +"}";
+ assertEquals(e, r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Same as testMultiPartParams(), except make sure single values are still interpreted as collections.
+ //====================================================================================================
+ @Test
+ public void testMultiPartParamsSingleValues() throws Exception {
+ RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
+ String r;
+ String url = URL + "/testMultiPartParams";
+
+ String in = ""
+ + "?p1=a"
+ + "&p2=1"
+ + "&p3=a"
+ + "&p4=1"
+ + "&p5=a"
+ + "&p6=1"
+ + "&p7=a"
+ + "&p8=1"
+ + "&p9=(a=1,b=2,c=false)"
+ + "&p10=(a=1,b=2,c=false)"
+ + "&p11=(a=1,b=2,c=false)"
+ + "&p12=(a=1,b=2,c=false)";
+ r = client.doGet(url + in).getResponseAsString();
+ String e = "{"
+ + "p1:['a'],"
+ + "p2:[1],"
+ + "p3:['a'],"
+ + "p4:[1],"
+ + "p5:['a'],"
+ + "p6:[1],"
+ + "p7:['a'],"
+ + "p8:[1],"
+ + "p9:[{a:'1',b:2,c:false}],"
+ + "p10:[{a:'1',b:2,c:false}],"
+ + "p11:[{a:'1',b:2,c:false}],"
+ + "p12:[{a:'1',b:2,c:false}]"
+ +"}";
+ assertEquals(e, r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
+ // using URLENC_expandedParams property.
+ // A simple round-trip test to verify that both serializing and parsing works.
+ //====================================================================================================
+ @Test
+ public void testFormPostsWithMultiParamsUsingProperty() throws Exception {
+ RestClient client = new TestRestClient()
+ .setHeader("Content-Type", "application/x-www-form-urlencoded")
+ .setHeader("Accept", "application/x-www-form-urlencoded");
+ String r;
+ String url = URL + "/testFormPostsWithMultiParamsUsingProperty";
+
+ String in = ""
+ + "f01=a&f01=b"
+ + "&f02=c&f02=d"
+ + "&f03=1&f03=2"
+ + "&f04=3&f04=4"
+ + "&f05=(e,f)&f05=(g,h)"
+ + "&f06=(i,j)&f06=(k,l)"
+ + "&f07=(a=a,b=1,c=true)&f07=(a=b,b=2,c=false)"
+ + "&f08=(a=a,b=1,c=true)&f08=(a=b,b=2,c=false)"
+ + "&f09=((a=a,b=1,c=true))&f09=((a=b,b=2,c=false))"
+ + "&f10=((a=a,b=1,c=true))&f10=((a=b,b=2,c=false))"
+ + "&f11=a&f11=b"
+ + "&f12=c&f12=d"
+ + "&f13=1&f13=2"
+ + "&f14=3&f14=4"
+ + "&f15=(e,f)&f15=(g,h)"
+ + "&f16=(i,j)&f16=(k,l)"
+ + "&f17=(a=a,b=1,c=true)&f17=(a=b,b=2,c=false)"
+ + "&f18=(a=a,b=1,c=true)&f18=(a=b,b=2,c=false)"
+ + "&f19=((a=a,b=1,c=true))&f19=((a=b,b=2,c=false))"
+ + "&f20=((a=a,b=1,c=true))&f20=((a=b,b=2,c=false))";
+ r = client.doPost(url, new StringEntity(in)).getResponseAsString();
+ assertEquals(in, r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
+ // using @UrlEncoding(expandedParams=true) annotation.
+ // A simple round-trip test to verify that both serializing and parsing works.
+ //====================================================================================================
+ @Test
+ public void testFormPostsWithMultiParamsUsingAnnotation() throws Exception {
+ RestClient client = new TestRestClient()
+ .setHeader("Content-Type", "application/x-www-form-urlencoded")
+ .setHeader("Accept", "application/x-www-form-urlencoded");
+ String r;
+ String url = URL + "/testFormPostsWithMultiParamsUsingAnnotation";
+
+ String in = ""
+ + "f01=a&f01=b"
+ + "&f02=c&f02=d"
+ + "&f03=1&f03=2"
+ + "&f04=3&f04=4"
+ + "&f05=(e,f)&f05=(g,h)"
+ + "&f06=(i,j)&f06=(k,l)"
+ + "&f07=(a=a,b=1,c=true)&f07=(a=b,b=2,c=false)"
+ + "&f08=(a=a,b=1,c=true)&f08=(a=b,b=2,c=false)"
+ + "&f09=((a=a,b=1,c=true))&f09=((a=b,b=2,c=false))"
+ + "&f10=((a=a,b=1,c=true))&f10=((a=b,b=2,c=false))"
+ + "&f11=a&f11=b"
+ + "&f12=c&f12=d"
+ + "&f13=1&f13=2"
+ + "&f14=3&f14=4"
+ + "&f15=(e,f)&f15=(g,h)"
+ + "&f16=(i,j)&f16=(k,l)"
+ + "&f17=(a=a,b=1,c=true)&f17=(a=b,b=2,c=false)"
+ + "&f18=(a=a,b=1,c=true)&f18=(a=b,b=2,c=false)"
+ + "&f19=((a=a,b=1,c=true))&f19=((a=b,b=2,c=false))"
+ + "&f20=((a=a,b=1,c=true))&f20=((a=b,b=2,c=false))";
+ r = client.doPost(url, new StringEntity(in)).getResponseAsString();
+ assertEquals(in, r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/ParsersTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/ParsersTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ParsersTest.java
new file mode 100755
index 0000000..4bad9c8
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ParsersTest.java
@@ -0,0 +1,162 @@
+// ***************************************************************************************************************************
+// * 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 org.apache.juneau.client.*;
+import org.apache.juneau.plaintext.*;
+import org.junit.*;
+
+public class ParsersTest {
+
+ private static String URL = "/testParsers";
+ private static boolean debug = false;
+
+ //====================================================================================================
+ // Parser defined on class.
+ //====================================================================================================
+ @Test
+ public void testParserOnClass() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String url = URL + "/testParserOnClass";
+
+ client.setContentType("text/a");
+ String r = client.doPut(url, "test1").getResponseAsString();
+ assertEquals("text/a - test1", r);
+
+ try {
+ client.setContentType("text/b");
+ client.doPut(url + "?noTrace=true", "test1").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/b'",
+ "Supported media-types: [text/a"
+ );
+ }
+
+ client.setContentType("text/json").setAccept("text/json");
+ r = client.doPut(url, "'test1'").getResponseAsString();
+ assertEquals("\"test1\"", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Parser defined on method.
+ //====================================================================================================
+ @Test
+ public void testParserOnMethod() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String url = URL + "/testParserOnMethod";
+
+ client.setContentType("text/b");
+ String r = client.doPut(url, "test2").getResponseAsString();
+ assertEquals("text/b - test2", r);
+
+ try {
+ client.setContentType("text/a");
+ client.doPut(url + "?noTrace=true", "test2").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/a'",
+ "Supported media-types: [text/b]"
+ );
+ }
+
+ try {
+ client.setContentType("text/json");
+ r = client.doPut(url + "?noTrace=true", "'test2'").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/json'",
+ "Supported media-types: [text/b]"
+ );
+ }
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Parser overridden on method.
+ //====================================================================================================
+ @Test
+ public void testParserOverriddenOnMethod() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String url = URL + "/testParserOverriddenOnMethod";
+
+ client.setContentType("text/a");
+ String r = client.doPut(url, "test3").getResponseAsString();
+ assertEquals("text/a - test3", r);
+
+ client.setContentType("text/b");
+ r = client.doPut(url, "test3").getResponseAsString();
+ assertEquals("text/b - test3", r);
+
+ client.setContentType("text/json");
+ r = client.doPut(url, "'test3'").getResponseAsString();
+ assertEquals("test3", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Parser with different Accept than Content-Type.
+ //====================================================================================================
+ @Test
+ public void testParserWithDifferentMediaTypes() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String url = URL + "/testParserWithDifferentMediaTypes";
+
+ client.setContentType("text/a");
+ String r = client.doPut(url, "test4").getResponseAsString();
+ assertEquals("text/d - test4", r);
+
+ client.setContentType("text/d");
+ r = client.doPut(url, "test4").getResponseAsString();
+ assertEquals("text/d - test4", r);
+
+ client.setContentType("text/json");
+ r = client.doPut(url, "'test4'").getResponseAsString();
+ assertEquals("test4", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Check for valid error response.
+ //====================================================================================================
+ @Test
+ public void testValidErrorResponse() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String url = URL + "/testValidErrorResponse";
+
+ try {
+ client.setContentType("text/bad");
+ client.doPut(url + "?noTrace=true", "test1").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/bad'",
+ "Supported media-types: [text/a"
+ );
+ }
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/PathTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/PathTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/PathTest.java
new file mode 100755
index 0000000..c0ff8c4
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/PathTest.java
@@ -0,0 +1,44 @@
+// ***************************************************************************************************************************
+// * 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 PathTest {
+
+ private static String URL = "/testPath";
+
+ //====================================================================================================
+ // Basic tests
+ //====================================================================================================
+ @Test
+ public void testBasic() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r = null;
+
+ r = client.doGet(URL).getResponse(String.class);
+ assertEquals("/testPath", r);
+
+ r = client.doGet(URL + "/testPath2").getResponse(String.class);
+ assertEquals("/testPath/testPath2", r);
+
+ r = client.doGet(URL + "/testPath2/testPath3").getResponse(String.class);
+ assertEquals("/testPath/testPath2/testPath3", r);
+
+ client.closeQuietly();
+ }
+}
[13/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/InheritanceResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/InheritanceResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/InheritanceResource.java
new file mode 100755
index 0000000..02c7ffe
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/InheritanceResource.java
@@ -0,0 +1,317 @@
+// ***************************************************************************************************************************
+// * 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 java.io.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+import org.apache.juneau.server.annotation.Properties;
+import org.apache.juneau.transform.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testInheritance",
+ serializers={InheritanceResource.S1.class,InheritanceResource.S2.class},
+ parsers={InheritanceResource.P1.class,InheritanceResource.P2.class},
+ encoders={InheritanceResource.E1.class,InheritanceResource.E2.class},
+ pojoSwaps={InheritanceResource.F1Swap.class},
+ properties={@Property(name="p1",value="v1"), @Property(name="p2",value="v2")}
+)
+public class InheritanceResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ @RestResource(
+ serializers={S3.class,S4.class},
+ parsers={P3.class,P4.class},
+ encoders={E3.class,E4.class},
+ pojoSwaps={F2Swap.class},
+ properties={@Property(name="p2",value="v2a"), @Property(name="p3",value="v3"), @Property(name="p4",value="v4")}
+ )
+ public static class Sub extends InheritanceResource {
+ private static final long serialVersionUID = 1L;
+ }
+
+ //====================================================================================================
+ // Test serializer inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceSerializers")
+ public static class TestSerializers extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show ['text/s3','text/s4','text/s1','text/s2']
+ @RestMethod(
+ name="GET",
+ path="/test1"
+ )
+ public Reader test1(RestResponse res) {
+ return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
+ }
+
+ // Should show ['text/s5']
+ @RestMethod(
+ name="GET",
+ path="/test2",
+ serializers=S5.class
+ )
+ public Reader test2(RestResponse res) {
+ return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
+ }
+
+ // Should show ['text/s5','text/s3','text/s4','text/s1','text/s2']
+ @RestMethod(
+ name="GET",
+ path="/test3",
+ serializers=S5.class,
+ serializersInherit=SERIALIZERS
+ )
+ public Reader test3(RestResponse res) {
+ return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
+ }
+ }
+
+ //====================================================================================================
+ // Test parser inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceParsers")
+ public static class TestParsers extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show ['text/p3','text/p4','text/p1','text/p2']
+ @RestMethod(
+ name="GET",
+ path="/test1"
+ )
+ public Reader test1(RestRequest req) {
+ return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
+ }
+
+ // Should show ['text/p5']
+ @RestMethod(
+ name="GET",
+ path="/test2",
+ parsers=P5.class
+ )
+ public Reader test2(RestRequest req) {
+ return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
+ }
+
+ // Should show ['text/p5','text/p3','text/p4','text/p1','text/p2']
+ @RestMethod(
+ name="GET",
+ path="/test3",
+ parsers=P5.class,
+ parsersInherit=PARSERS
+ )
+ public Reader test3(RestRequest req) {
+ return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
+ }
+ }
+
+ //====================================================================================================
+ // Test encoder inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceEncoders")
+ public static class TestEncoders extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show ['e3','e4','e1','e2','identity']
+ @RestMethod(name="GET", path="/test")
+ public Reader test(RestResponse res) throws RestServletException {
+ return new StringReader(new ObjectList(res.getSupportedEncodings()).toString());
+ }
+ }
+
+ //====================================================================================================
+ // Test filter inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceTransforms", serializers=JsonSerializer.Simple.class)
+ public static class TestTransforms extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show ['F1Swap','F2Swap','Foo3']
+ @RestMethod(name="GET", path="/test1")
+ public Object[] test1() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1Swap','F2Swap','F3Swap']
+ // Inherited serializer already has parent filters applied.
+ @RestMethod(name="GET", path="/test2", pojoSwaps=F3Swap.class)
+ public Object[] test2() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1Swap','F2Swap','F3Swap']
+ @RestMethod(name="GET", path="/test3", pojoSwaps=F3Swap.class, serializersInherit=TRANSFORMS)
+ public Object[] test3() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['Foo1','Foo2','F3Swap']
+ // Overriding serializer does not have parent filters applied.
+ @RestMethod(name="GET", path="/test4", serializers=JsonSerializer.Simple.class, pojoSwaps=F3Swap.class)
+ public Object[] test4() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1Swap','F2Swap','F3Swap']
+ // Overriding serializer does have parent filters applied.
+ @RestMethod(name="GET", path="/test5", serializers=JsonSerializer.Simple.class, pojoSwaps=F3Swap.class, serializersInherit=TRANSFORMS)
+ public Object[] test5() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+ }
+
+ //====================================================================================================
+ // Test properties inheritance.
+ //====================================================================================================
+ @RestResource(path="/testInheritanceProperties", serializers=JsonSerializer.Simple.class)
+ public static class TestProperties extends Sub {
+ private static final long serialVersionUID = 1L;
+
+ // Should show {p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}
+ @RestMethod(name="GET", path="/test1")
+ public ObjectMap test1(@Properties ObjectMap properties) {
+ return transform(properties);
+ }
+
+ // Should show {p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'} when override is false.
+ // Should show {p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'} when override is true.
+ @RestMethod(name="GET", path="/test2",
+ properties={@Property(name="p4",value="v4a"), @Property(name="p5", value="v5")})
+ public ObjectMap test2(@Properties ObjectMap properties, @HasParam("override") boolean override) {
+ if (override) {
+ properties.put("p1", "x");
+ properties.put("p2", "x");
+ properties.put("p3", "x");
+ properties.put("p4", "x");
+ properties.put("p5", "x");
+ }
+ return transform(properties);
+ }
+
+ private ObjectMap transform(ObjectMap properties) {
+ ObjectMap m = new ObjectMap();
+ for (Map.Entry<String,Object> e : properties.entrySet()) {
+ if (e.getKey().startsWith("p"))
+ m.put(e.getKey(), e.getValue());
+ }
+ return m;
+ }
+ }
+
+ public static class DummyParser extends ReaderParser {
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return null;
+ }
+ }
+
+ public static class DummySerializer extends WriterSerializer {
+ @Override /* Serializer */
+ protected void doSerialize(SerializerSession session, Object o) throws Exception {
+ session.getWriter().write(o.toString());
+ }
+ }
+
+ @Consumes("text/p1")
+ public static class P1 extends DummyParser{}
+
+ @Consumes("text/p2")
+ public static class P2 extends DummyParser{}
+
+ @Consumes("text/p3")
+ public static class P3 extends DummyParser{}
+
+ @Consumes("text/p4")
+ public static class P4 extends DummyParser{}
+
+ @Consumes("text/p5")
+ public static class P5 extends DummyParser{}
+
+ @Produces("text/s1")
+ public static class S1 extends DummySerializer{}
+
+ @Produces("text/s2")
+ public static class S2 extends DummySerializer{}
+
+ @Produces("text/s3")
+ public static class S3 extends DummySerializer{}
+
+ @Produces("text/s4")
+ public static class S4 extends DummySerializer{}
+
+ @Produces("text/s5")
+ public static class S5 extends DummySerializer{}
+
+ public static class E1 extends IdentityEncoder {
+ @Override public String[] getCodings() {
+ return new String[]{"e1"};
+ }
+ }
+
+ public static class E2 extends IdentityEncoder {
+ @Override public String[] getCodings() {
+ return new String[]{"e2"};
+ }
+ }
+
+ public static class E3 extends IdentityEncoder {
+ @Override public String[] getCodings() {
+ return new String[]{"e3"};
+ }
+ }
+
+ public static class E4 extends IdentityEncoder {
+ @Override public String[] getCodings() {
+ return new String[]{"e4"};
+ }
+ }
+
+ public static class Foo1 {@Override public String toString(){return "Foo1";}}
+ public static class Foo2 {@Override public String toString(){return "Foo2";}}
+ public static class Foo3 {@Override public String toString(){return "Foo3";}}
+
+ public static class F1Swap extends PojoSwap<Foo1,String> {
+ @Override /* PojoSwap */
+ public String swap(Foo1 o) throws SerializeException {
+ return "F1";
+ }
+ }
+
+ public static class F2Swap extends PojoSwap<Foo2,String> {
+ @Override /* PojoSwap */
+ public String swap(Foo2 o) throws SerializeException {
+ return "F2";
+ }
+ }
+
+ public static class F3Swap extends PojoSwap<Foo3,String> {
+ @Override /* PojoSwap */
+ public String swap(Foo3 o) throws SerializeException {
+ return "F3";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/LargePojo.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/LargePojo.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/LargePojo.java
new file mode 100755
index 0000000..fc97420
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/LargePojo.java
@@ -0,0 +1,45 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import java.util.*;
+
+/**
+ * A large POJO object.
+ */
+@SuppressWarnings("serial")
+public class LargePojo {
+ public A1Map a1Map;
+ public A1List a1List;
+ public A1[] a1Array;
+
+ public static LargePojo create() {
+ LargePojo a = new LargePojo();
+ a.a1Map = new A1Map();
+ a.a1List = new A1List();
+ for (int i = 0; i < 20000; i++) {
+ a.a1Map.put(String.valueOf(i), new A1());
+ a.a1List.add(new A1());
+ }
+ a.a1Array = a.a1List.toArray(new A1[0]);
+ return a;
+ }
+
+ public static class A1 {
+ public String f1 = "a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789";
+ }
+
+ public static class A1Map extends LinkedHashMap<String,A1> {}
+
+ public static class A1List extends LinkedList<A1> {}
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/LargePojosResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/LargePojosResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/LargePojosResource.java
new file mode 100755
index 0000000..09e620b
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/LargePojosResource.java
@@ -0,0 +1,39 @@
+// ***************************************************************************************************************************
+// * 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.annotation.*;
+import org.apache.juneau.server.jena.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testLargePojos"
+)
+public class LargePojosResource extends RestServletJenaDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Test how long it takes to serialize/parse various content types.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/")
+ public LargePojo testGet() {
+ return LargePojo.create();
+ }
+
+ @RestMethod(name="PUT", path="/")
+ public String testPut(@Content LargePojo in) {
+ return "ok";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/MessagesResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/MessagesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/MessagesResource.java
new file mode 100755
index 0000000..c470e8a
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/MessagesResource.java
@@ -0,0 +1,62 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+import org.apache.juneau.transform.*;
+
+/**
+ * JUnit automated testcase resource.
+ * Validates that resource bundles can be defined on both parent and child classes.
+ */
+@RestResource(
+ path="/testMessages",
+ messages="MessagesResource",
+ pojoSwaps={
+ MessagesResource.ResourceBundleSwap.class
+ }
+)
+public class MessagesResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Return contents of resource bundle.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/test")
+ public Object test(@Messages ResourceBundle nls) {
+ return nls;
+ }
+
+
+ @SuppressWarnings("serial")
+ @RestResource(
+ path="/testMessages2",
+ messages="Messages2Resource"
+ )
+ public static class Messages2Resource extends MessagesResource {}
+
+ public static class ResourceBundleSwap extends PojoSwap<ResourceBundle,ObjectMap> {
+ @Override /* Transform */
+ public ObjectMap swap(ResourceBundle o) throws SerializeException {
+ ObjectMap m = new ObjectMap();
+ for (String k : o.keySet())
+ m.put(k, o.getString(k));
+ return m;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/NlsPropertyResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/NlsPropertyResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/NlsPropertyResource.java
new file mode 100755
index 0000000..47ade8f
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/NlsPropertyResource.java
@@ -0,0 +1,61 @@
+// ***************************************************************************************************************************
+// * 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.annotation.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testNlsProperty",
+ serializers={NlsPropertyResource.TestSerializer.class},
+ properties={
+ @Property(name="TestProperty",value="$L{key1}")
+ },
+ messages="NlsPropertyResource"
+)
+public class NlsPropertyResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Test getting an NLS property defined on a class.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testInheritedFromClass")
+ public String testInheritedFromClass() {
+ return null;
+ }
+
+ //====================================================================================================
+ // Test getting an NLS property defined on a method.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testInheritedFromMethod",
+ properties={
+ @Property(name="TestProperty",value="$L{key2}")
+ }
+ )
+ public String testInheritedFromMethod() {
+ return null;
+ }
+
+ @Produces("text/plain")
+ public static class TestSerializer extends WriterSerializer {
+ @Override /* Serializer */
+ protected void doSerialize(SerializerSession session, Object o) throws Exception {
+ session.getWriter().write(session.getProperties().getString("TestProperty"));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/NlsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/NlsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/NlsResource.java
new file mode 100755
index 0000000..1929a15
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/NlsResource.java
@@ -0,0 +1,195 @@
+// ***************************************************************************************************************************
+// * 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.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testNls",
+ children={
+ NlsResource.Test1.class,
+ NlsResource.Test2.class,
+ NlsResource.Test3.class,
+ NlsResource.Test4.class,
+ NlsResource.Test5.class,
+ NlsResource.Test6.class
+ }
+)
+@SuppressWarnings({"serial"})
+public class NlsResource extends RestServletGroupDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // test1 - Pull labels from annotations only.
+ //====================================================================================================
+ @RestResource(
+ path="/test1",
+ messages="NlsResource",
+ label="Test1.a",
+ description="Test1.b"
+ )
+ public static class Test1 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}",
+ description="Test1.c",
+ input={
+ @Var(category="attr", name="a", description="Test1.d"),
+ @Var(category="param", name="b", description="Test1.e"),
+ @Var(category="content", description="Test1.f"),
+ @Var(category="header", name="D", description="Test1.g"),
+ @Var(category="attr", name="a2", description="Test1.h"),
+ @Var(category="param", name="b2", description="Test1.i"),
+ @Var(category="header", name="D2", description="Test1.j"),
+ @Var(category="foo", name="bar", description="Test1.k"),
+ },
+ responses={
+ @Response(200),
+ @Response(value=201,
+ description="Test1.l",
+ output={
+ @Var(category="foo", name="bar", description="Test1.m"),
+ }
+ )
+ }
+ )
+ public String test1(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
+ @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
+ return null;
+ }
+ }
+
+ //====================================================================================================
+ // test2 - Pull labels from resource bundles only - simple keys.
+ //====================================================================================================
+ @RestResource(
+ path="/test2",
+ messages="NlsResource"
+ )
+ public static class Test2 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}"
+ )
+ public String test2(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
+ @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
+ return null;
+ }
+ }
+
+ //====================================================================================================
+ // test3 - Pull labels from resource bundles only - keys with class names.
+ //====================================================================================================
+ @RestResource(
+ path="/test3",
+ messages="NlsResource"
+ )
+ public static class Test3 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}"
+ )
+ public String test3(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
+ @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
+ return null;
+ }
+
+ @RestMethod(
+ name="GET", path="/"
+ )
+ public Object test3a(@Messages MessageBundle mb) {
+ return mb;
+ }
+ }
+
+ //====================================================================================================
+ // test4 - Pull labels from resource bundles only. Values have localized variables to resolve.
+ //====================================================================================================
+ @RestResource(
+ path="/test4",
+ messages="NlsResource"
+ )
+ public static class Test4 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}"
+ )
+ public String test4(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
+ @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
+ return null;
+ }
+ }
+
+ //====================================================================================================
+ // test5 - Pull labels from resource bundles only. Values have request variables to resolve.
+ //====================================================================================================
+ @RestResource(
+ path="/test5",
+ messages="NlsResource"
+ )
+ public static class Test5 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}"
+ )
+ public String test5(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
+ @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
+ return null;
+ }
+ }
+
+ //====================================================================================================
+ // test6 - Pull labels from annotations only, but annotations contain variables.
+ //====================================================================================================
+ @RestResource(
+ path="/test6",
+ messages="NlsResource",
+ label="$L{foo}",
+ description="$L{foo}"
+ )
+ public static class Test6 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}",
+ description="$L{foo}",
+ input={
+ @Var(category="attr", name="a", description="$L{foo}"),
+ @Var(category="param", name="b", description="$L{foo}"),
+ @Var(category="content", description="$L{foo}"),
+ @Var(category="header", name="D", description="$L{foo}"),
+ @Var(category="attr", name="a2", description="$L{foo}"),
+ @Var(category="param", name="b2", description="$L{foo}"),
+ @Var(category="header", name="D2", description="$L{foo}"),
+ @Var(category="foo", name="bar", description="$L{foo}"),
+ },
+ responses={
+ @Response(200),
+ @Response(value=201,
+ description="$L{foo}",
+ output={
+ @Var(category="foo", name="bar", description="$L{foo}"),
+ }
+ )
+ }
+ )
+ public String test6(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
+ @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
+ 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/NoParserInputResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/NoParserInputResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/NoParserInputResource.java
new file mode 100755
index 0000000..66a9170
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/NoParserInputResource.java
@@ -0,0 +1,56 @@
+// ***************************************************************************************************************************
+// * 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.internal.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testNoParserInput",
+ serializers=PlainTextSerializer.class
+)
+public class NoParserInputResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // @Content annotated InputStream.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testInputStream")
+ public String testInputStream(@Content InputStream in) throws Exception {
+ return IOUtils.read(in);
+ }
+
+ //====================================================================================================
+ // @Content annotated Reader.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testReader")
+ public String testReader(@Content Reader in) throws Exception {
+ return IOUtils.read(in);
+ }
+
+ //====================================================================================================
+ // @Content annotated PushbackReader.
+ // This should always fail since the servlet reader is not a pushback reader.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testPushbackReader")
+ public String testPushbackReader(@Content PushbackReader in) throws Exception {
+ return IOUtils.read(in);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/OnPostCallResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/OnPostCallResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/OnPostCallResource.java
new file mode 100755
index 0000000..9e4c2b7
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/OnPostCallResource.java
@@ -0,0 +1,94 @@
+// ***************************************************************************************************************************
+// * 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.annotation.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ * Validates that headers
+ */
+@RestResource(
+ path="/testOnPostCall",
+ serializers=OnPostCallResource.TestSerializer.class,
+ properties={
+ @Property(name="p1",value="sp1"), // Unchanged servlet-level property.
+ @Property(name="p2",value="sp2"), // Servlet-level property overridden by onPostCall.
+ @Property(name="p3",value="sp3"), // Servlet-level property overridded by method.
+ @Property(name="p4",value="sp4") // Servlet-level property overridden by method then onPostCall.
+ }
+)
+public class OnPostCallResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Produces({"text/s1","text/s2","text/s3"})
+ public static class TestSerializer extends WriterSerializer {
+ @Override /* Serializer */
+ protected void doSerialize(SerializerSession session, Object o) throws Exception {
+ ObjectMap p = session.getProperties();
+ session.getWriter().write("p1="+p.get("p1")+",p2="+p.get("p2")+",p3="+p.get("p3")+",p4="+p.get("p4")+",p5="+p.get("p5")+",contentType="+session.getProperties().getString("mediaType"));
+ }
+ @Override /* Serializer */
+ public ObjectMap getResponseHeaders(ObjectMap properties) {
+ if (properties.containsKey("Override-Content-Type"))
+ return new ObjectMap().append("Content-Type", properties.get("Override-Content-Type"));
+ return null;
+ }
+ }
+
+ @Override /* RestServlet */
+ protected void onPostCall(RestRequest req, RestResponse res) {
+ ObjectMap properties = req.getProperties();
+ properties.put("p2", "xp2");
+ properties.put("p4", "xp4");
+ properties.put("p5", "xp5"); // New property
+ String overrideAccept = req.getHeader("Override-Accept");
+ if (overrideAccept != null)
+ req.setHeader("Accept", overrideAccept);
+ String overrideContentType = req.getHeader("Override-Content-Type");
+ if (overrideContentType != null)
+ properties.put("Override-Content-Type", overrideContentType);
+ }
+
+
+ //====================================================================================================
+ // Test1 - Properties overridden via properties annotation.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testPropertiesOverridenByAnnotation",
+ properties={
+ @Property(name="p3",value="mp3"),
+ @Property(name="p4",value="mp4")
+ },
+ defaultRequestHeaders="Accept: text/s2"
+ )
+ public String testPropertiesOverridenByAnnotation() {
+ return "";
+ }
+
+ //====================================================================================================
+ // Test2 - Properties overridden programmatically.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testPropertiesOverriddenProgramatically")
+ public String testPropertiesOverriddenProgramatically(RestRequest req, @Properties ObjectMap properties) throws Exception {
+ properties.put("p3", "pp3");
+ properties.put("p4", "pp4");
+ String accept = req.getHeader("Accept");
+ if (accept == null || accept.isEmpty())
+ req.setHeader("Accept", "text/s2");
+ return "";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/OnPreCallResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/OnPreCallResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/OnPreCallResource.java
new file mode 100755
index 0000000..69bcf21
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/OnPreCallResource.java
@@ -0,0 +1,85 @@
+// ***************************************************************************************************************************
+// * 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.annotation.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ * Validates that headers
+ */
+@RestResource(
+ path="/testOnPreCall",
+ parsers=OnPreCallResource.TestParserA.class,
+ serializers=PlainTextSerializer.class,
+ properties={
+ @Property(name="p1",value="sp1"), // Unchanged servlet-level property.
+ @Property(name="p2",value="sp2"), // Servlet-level property overridden by onPreCall.
+ @Property(name="p3",value="sp3"), // Servlet-level property overridded by method.
+ @Property(name="p4",value="sp4") // Servlet-level property overridden by method then onPreCall.
+ }
+)
+public class OnPreCallResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Consumes({"text/a1","text/a2","text/a3"})
+ public static class TestParserA extends ReaderParser {
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ ObjectMap p = session.getProperties();
+ String matchingContentType = session.getProperties().getString("mediaType");
+ return (T)("p1="+p.get("p1")+",p2="+p.get("p2")+",p3="+p.get("p3")+",p4="+p.get("p4")+",p5="+p.get("p5")+",contentType="+matchingContentType);
+ }
+ }
+
+ @Override /* RestServlet */
+ protected void onPreCall(RestRequest req) {
+ ObjectMap properties = req.getProperties();
+ properties.put("p2", "xp2");
+ properties.put("p4", "xp4");
+ properties.put("p5", "xp5"); // New property
+ String overrideContentType = req.getHeader("Override-Content-Type");
+ if (overrideContentType != null)
+ req.setHeader("Content-Type", overrideContentType);
+ }
+
+
+ //====================================================================================================
+ // Properties overridden via properties annotation.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testPropertiesOverriddenByAnnotation",
+ properties={
+ @Property(name="p3",value="mp3"),
+ @Property(name="p4",value="mp4")
+ }
+ )
+ public String testPropertiesOverriddenByAnnotation(@Content String in) {
+ return in;
+ }
+
+ //====================================================================================================
+ // Properties overridden programmatically.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testPropertiesOverriddenProgrammatically")
+ public String testPropertiesOverriddenProgrammatically(RestRequest req, @Properties ObjectMap properties) throws Exception {
+ properties.put("p3", "pp3");
+ properties.put("p4", "pp4");
+ return req.getInput(String.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/OptionsWithoutNlsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/OptionsWithoutNlsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/OptionsWithoutNlsResource.java
new file mode 100755
index 0000000..fb34878
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/OptionsWithoutNlsResource.java
@@ -0,0 +1,44 @@
+// ***************************************************************************************************************************
+// * 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.*;
+import org.apache.juneau.server.labels.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testOptionsWithoutNls"
+)
+public class OptionsWithoutNlsResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Should get to the options page without errors
+ //====================================================================================================
+ @RestMethod(name="OPTIONS", path="/testOptions/*")
+ public ResourceOptions testOptions(RestRequest req) {
+ return new ResourceOptions(this, req);
+ }
+
+ //====================================================================================================
+ // Missing resource bundle should cause {!!x} string.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testMissingResourceBundle")
+ public String test(RestRequest req) {
+ return req.getMessage("bad", 1, 2, 3);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/OverlappingMethodsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/OverlappingMethodsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/OverlappingMethodsResource.java
new file mode 100755
index 0000000..f3dc673
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/OverlappingMethodsResource.java
@@ -0,0 +1,146 @@
+// ***************************************************************************************************************************
+// * 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.plaintext.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testOverlappingMethods",
+ serializers=PlainTextSerializer.class
+)
+public class OverlappingMethodsResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Overlapping guards
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingGuards1", guards=Test1Guard.class)
+ public String testOverlappingGuards1() {
+ return "test1_doGet";
+ }
+
+ //====================================================================================================
+ // Overlapping guards
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingGuards2", guards={Test1Guard.class, Test2Guard.class})
+ public String testOverlappingGuards2() {
+ return "test2_doGet";
+ }
+
+ public static class Test1Guard extends RestGuard {
+ @Override /* RestGuard */
+ public boolean isRequestAllowed(RestRequest req) {
+ return req.getParameter("t1","").equals("1");
+ }
+ }
+
+ public static class Test2Guard extends RestGuard {
+ @Override /* RestGuard */
+ public boolean isRequestAllowed(RestRequest req) {
+ return req.getParameter("t2","").equals("2");
+ }
+ }
+
+ //====================================================================================================
+ // Overlapping matchers
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingMatchers1", matchers=Test3aMatcher.class)
+ public String testOverlappingMatchers1() {
+ return "test3a";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingMatchers1", matchers=Test3bMatcher.class)
+ public String test3b_doGet() {
+ return "test3b";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingMatchers1")
+ public String test3c_doGet() {
+ return "test3c";
+ }
+
+ public static class Test3aMatcher extends RestMatcher {
+ @Override /* RestMatcher */
+ public boolean matches(RestRequest req) {
+ return req.getParameter("t1","").equals("1");
+ }
+ }
+
+ public static class Test3bMatcher extends RestMatcher {
+ @Override /* RestMatcher */
+ public boolean matches(RestRequest req) {
+ return req.getParameter("t2","").equals("2");
+ }
+ }
+
+ //====================================================================================================
+ // Overlapping matchers
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingMatchers2")
+ public String test4a_doGet() {
+ return "test4a";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingMatchers2", matchers={Test3aMatcher.class, Test3bMatcher.class})
+ public String test4b_doGet() {
+ return "test4b";
+ }
+
+ //====================================================================================================
+ // Overlapping URL patterns
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns")
+ public String testOverlappingUrlPatterns1() {
+ return "test5a";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/*")
+ public String testOverlappingUrlPatterns2() {
+ return "test5b";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/foo")
+ public String testOverlappingUrlPatterns3() {
+ return "test5c";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/foo/*")
+ public String testOverlappingUrlPatterns4() {
+ return "test5d";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}")
+ public String testOverlappingUrlPatterns5() {
+ return "test5e";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/*")
+ public String testOverlappingUrlPatterns6() {
+ return "test5f";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/foo")
+ public String testOverlappingUrlPatterns7() {
+ return "test5g";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/foo/*")
+ public String testOverlappingUrlPatterns8() {
+ return "test5h";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/ParamsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/ParamsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ParamsResource.java
new file mode 100755
index 0000000..9e2d339
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ParamsResource.java
@@ -0,0 +1,293 @@
+// ***************************************************************************************************************************
+// * 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.RestServletContext.*;
+import static org.apache.juneau.urlencoding.UrlEncodingContext.*;
+
+import java.util.*;
+
+import javax.servlet.http.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.samples.addressbook.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+import org.apache.juneau.transforms.*;
+import org.apache.juneau.urlencoding.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testParams",
+ serializers=PlainTextSerializer.class,
+ properties={
+ @Property(name=REST_allowMethodParam, value="*")
+ }
+)
+public class ParamsResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Basic tests
+ //====================================================================================================
+ @RestMethod(name="GET", path="/")
+ public void doGet(RestResponse res) {
+ res.setOutput("GET");
+ }
+
+ @RestMethod(name="GET", path="/get1")
+ public String doGet1() {
+ return "GET /get1";
+ }
+
+ @RestMethod(name="GET", path="/get1/{foo}")
+ public void doGet1a(RestResponse res, String foo) {
+ res.setOutput("GET /get1a " + foo);
+ }
+
+ @RestMethod(name="GET", path="/get1/{foo}/{bar}")
+ public void doGet1b(RestResponse res, String foo, String bar) {
+ res.setOutput("GET /get1b " + foo + "," + bar);
+ }
+
+ @RestMethod(name="GET", path="/get3/{foo}/{bar}/*")
+ public void doGet3(HttpServletRequest reqx, HttpServletResponse resx, String foo, int bar) {
+ RestRequest req = (RestRequest)reqx;
+ RestResponse res = (RestResponse)resx;
+ res.setOutput("GET /get3/"+foo+"/"+bar+" remainder="+req.getPathRemainder());
+ }
+
+ // Test method name with overlapping name, remainder allowed.
+ @RestMethod(name="GET2")
+ public void get2(RestRequest req, RestResponse res) {
+ res.setOutput("GET2 remainder="+req.getPathRemainder());
+ }
+
+ // Default POST
+ @RestMethod(name="POST")
+ public void doPost(RestRequest req, RestResponse res) {
+ res.setOutput("POST remainder="+req.getPathRemainder());
+ }
+
+ // Bean parameter
+ @RestMethod(name="POST", path="/person/{person}")
+ public void doPost(RestRequest req, RestResponse res, Person p) {
+ res.setOutput("POST /person/{name="+p.name+",birthDate.year="+p.birthDate.get(Calendar.YEAR)+"} remainder="+req.getPathRemainder());
+ }
+
+ // Various primitive types
+ @RestMethod(name="PUT", path="/primitives/{xInt}/{xShort}/{xLong}/{xChar}/{xFloat}/{xDouble}/{xByte}/{xBoolean}")
+ public void doPut1(RestResponse res, int xInt, short xShort, long xLong, char xChar, float xFloat, double xDouble, byte xByte, boolean xBoolean) {
+ res.setOutput("PUT /primitives/"+xInt+"/"+xShort+"/"+xLong+"/"+xChar+"/"+xFloat+"/"+xDouble+"/"+xByte+"/"+xBoolean);
+ }
+
+ // Various primitive objects
+ @RestMethod(name="PUT", path="/primitiveObjects/{xInt}/{xShort}/{xLong}/{xChar}/{xFloat}/{xDouble}/{xByte}/{xBoolean}")
+ public void doPut2(RestResponse res, Integer xInt, Short xShort, Long xLong, Character xChar, Float xFloat, Double xDouble, Byte xByte, Boolean xBoolean) {
+ res.setOutput("PUT /primitiveObjects/"+xInt+"/"+xShort+"/"+xLong+"/"+xChar+"/"+xFloat+"/"+xDouble+"/"+xByte+"/"+xBoolean);
+ }
+
+ // Object with forString(String) method
+ @RestMethod(name="PUT", path="/uuid/{uuid}")
+ public void doPut1(RestResponse res, UUID uuid) {
+ res.setOutput("PUT /uuid/"+uuid);
+ }
+
+ @Override /* RestServlet */
+ public Class<?>[] createPojoSwaps() {
+ return new Class[]{CalendarSwap.Medium.class};
+ }
+
+ //====================================================================================================
+ // @Param annotation - GET
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testParamGet/*")
+ public String testParamGet(RestRequest req, @Param("p1") String p1, @Param("p2") int p2) throws Exception {
+ return "p1=["+p1+","+req.getParameter("p1")+","+req.getParameter("p1", String.class)+"],p2=["+p2+","+req.getParameter("p2")+","+req.getParameter("p2", int.class)+"]";
+ }
+
+ //====================================================================================================
+ // @Param annotation - POST
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testParamPost/*")
+ public String testParamPost(RestRequest req, @Param("p1") String p1, @Param("p2") int p2) throws Exception {
+ return "p1=["+p1+","+req.getParameter("p1")+","+req.getParameter("p1", String.class)+"],p2=["+p2+","+req.getParameter("p2")+","+req.getParameter("p2", int.class)+"]";
+ }
+
+ //====================================================================================================
+ // @QParam annotation - GET
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testQParamGet/*")
+ public String testQParamGet(RestRequest req, @QParam("p1") String p1, @QParam("p2") int p2) throws Exception {
+ return "p1=["+p1+","+req.getQueryParameter("p1")+","+req.getQueryParameter("p1", String.class)+"],p2=["+p2+","+req.getQueryParameter("p2")+","+req.getQueryParameter("p2", int.class)+"]";
+ }
+
+ //====================================================================================================
+ // @QParam annotation - POST
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testQParamPost/*")
+ public String testQParamPost(RestRequest req, @QParam("p1") String p1, @QParam("p2") int p2) throws Exception {
+ return "p1=["+p1+","+req.getQueryParameter("p1")+","+req.getQueryParameter("p1", String.class)+"],p2=["+p2+","+req.getQueryParameter("p2")+","+req.getQueryParameter("p2", int.class)+"]";
+ }
+
+ //====================================================================================================
+ // @Param(format=PLAIN) annotation - GET
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testPlainParamGet/*")
+ public String testPlainParamGet(RestRequest req, @Param(value="p1",format="PLAIN") String p1) throws Exception {
+ return "p1=["+p1+","+req.getParameter("p1")+","+req.getParameter("p1", String.class)+"]";
+ }
+
+ //====================================================================================================
+ // @Param(format=PLAIN) annotation - POST
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testPlainParamPost/*")
+ public String testPlainParamPost(RestRequest req, @Param(value="p1",format="PLAIN") String p1) throws Exception {
+ return "p1=["+p1+","+req.getParameter("p1")+","+req.getParameter("p1", String.class)+"]";
+ }
+
+ //====================================================================================================
+ // @QParam(format=PLAIN) annotation - GET
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testPlainQParamGet/*")
+ public String testPlainQParamGet(RestRequest req, @QParam(value="p1",format="PLAIN") String p1) throws Exception {
+ return "p1=["+p1+","+req.getQueryParameter("p1")+","+req.getQueryParameter("p1", String.class)+"]";
+ }
+
+ //====================================================================================================
+ // @QParam(format=PLAIN) annotation - POST
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testPlainQParamPost/*")
+ public String testPlainQParamPost(RestRequest req, @QParam(value="p1",format="PLAIN") String p1) throws Exception {
+ return "p1=["+p1+","+req.getQueryParameter("p1")+","+req.getQueryParameter("p1", String.class)+"]";
+ }
+
+ //====================================================================================================
+ // @HasParam annotation - GET
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testHasParamGet/*")
+ public String testHasParamGet(RestRequest req, @HasParam("p1") boolean p1, @HasParam("p2") Boolean p2) throws Exception {
+ return "p1=["+p1+","+req.hasParameter("p1")+"],p2=["+p2+","+req.hasParameter("p2")+"]";
+ }
+
+ //====================================================================================================
+ // @HasParam annotation - POST
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testHasParamPost/*")
+ public String testHasParamPost(RestRequest req, @HasParam("p1") boolean p1, @HasParam("p2") Boolean p2) throws Exception {
+ return "p1=["+p1+","+req.hasParameter("p1")+"],p2=["+p2+","+req.hasParameter("p2")+"]";
+ }
+
+ //====================================================================================================
+ // @HasQParam annotation - GET
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testHasQParamGet/*")
+ public String testHasQParamGet(RestRequest req, @HasQParam("p1") boolean p1, @HasQParam("p2") Boolean p2) throws Exception {
+ return "p1=["+p1+","+req.hasQueryParameter("p1")+"],p2=["+p2+","+req.hasQueryParameter("p2")+"]";
+ }
+
+ //====================================================================================================
+ // @HasQParam annotation - POST
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testHasQParamPost/*")
+ public String testHasQParamPost_post(RestRequest req, @HasQParam("p1") boolean p1, @HasQParam("p2") Boolean p2) throws Exception {
+ return "p1=["+p1+","+req.hasQueryParameter("p1")+"],p2=["+p2+","+req.hasQueryParameter("p2")+"]";
+ }
+
+ //====================================================================================================
+ // Form POSTS with @Content parameter
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testFormPostAsContent/*")
+ public String testFormPostAsContent(@Content Test6Bean bean,
+ @HasQParam("p1") boolean hqp1, @HasQParam("p2") boolean hqp2,
+ @QParam("p1") String qp1, @QParam("p2") int qp2) throws Exception {
+ return "bean=["+JsonSerializer.DEFAULT_LAX.toString(bean)+"],qp1=["+qp1+"],qp2=["+qp2+"],hqp1=["+hqp1+"],hqp2=["+hqp2+"]";
+ }
+
+ public static class Test6Bean {
+ public String p1;
+ public int p2;
+ }
+
+ //====================================================================================================
+ // Test @Param and @QParam annotations when using multi-part parameters (e.g. &key=val1,&key=val2).
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testMultiPartParams")
+ public String testMultiPartParams(
+ @QParam(value="p1",multipart=true) String[] p1,
+ @QParam(value="p2",multipart=true) int[] p2,
+ @QParam(value="p3",multipart=true) List<String> p3,
+ @QParam(value="p4",multipart=true) List<Integer> p4,
+ @Param(value="p5",multipart=true) String[] p5,
+ @Param(value="p6",multipart=true) int[] p6,
+ @Param(value="p7",multipart=true) List<String> p7,
+ @Param(value="p8",multipart=true) List<Integer> p8,
+ @QParam(value="p9",multipart=true) A[] p9,
+ @QParam(value="p10",multipart=true) List<A> p10,
+ @Param(value="p11",multipart=true) A[] p11,
+ @Param(value="p12",multipart=true) List<A> p12) throws Exception {
+ ObjectMap m = new ObjectMap()
+ .append("p1", p1)
+ .append("p2", p2)
+ .append("p3", p3)
+ .append("p4", p4)
+ .append("p5", p5)
+ .append("p6", p6)
+ .append("p7", p7)
+ .append("p8", p8)
+ .append("p9", p9)
+ .append("p10", p10)
+ .append("p11", p11)
+ .append("p12", p12);
+ return JsonSerializer.DEFAULT_LAX.toString(m);
+ }
+
+ public static class A {
+ public String a;
+ public int b;
+ public boolean c;
+ }
+
+ //====================================================================================================
+ // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
+ // using URLENC_expandedParams property.
+ // A simple round-trip test to verify that both serializing and parsing works.
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testFormPostsWithMultiParamsUsingProperty",
+ properties={
+ @Property(name=URLENC_expandedParams, value="true"),
+ @Property(name=UonSerializerContext.UON_simpleMode, value="true")
+ }
+ )
+ public DTO2s.B testFormPostsWithMultiParamsViaProperty(@Content DTO2s.B content) throws Exception {
+ return content;
+ }
+
+ //====================================================================================================
+ // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
+ // using @UrlEncoding(expandedParams=true) annotation.
+ // A simple round-trip test to verify that both serializing and parsing works.
+ //====================================================================================================
+ @RestMethod(name="POST", path="/testFormPostsWithMultiParamsUsingAnnotation",
+ properties={
+ @Property(name=UonSerializerContext.UON_simpleMode, value="true")
+ }
+ )
+ public DTO2s.C testFormPostsWithMultiParamsUsingAnnotation(@Content DTO2s.C content) throws Exception {
+ return content;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/ParsersResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/ParsersResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ParsersResource.java
new file mode 100755
index 0000000..d6a8ac5
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ParsersResource.java
@@ -0,0 +1,112 @@
+// ***************************************************************************************************************************
+// * 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.*;
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ * Validates correct parser is used.
+ */
+@RestResource(
+ path="/testParsers",
+ parsers=ParsersResource.TestParserA.class,
+ serializers=PlainTextSerializer.class
+)
+public class ParsersResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ @Consumes("text/a")
+ public static class TestParserA extends ReaderParser {
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return (T)("text/a - " + IOUtils.read(session.getReader()).trim());
+ }
+ }
+
+ //====================================================================================================
+ // Parser defined on class.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testParserOnClass")
+ public String testParserOnClass(@Content String in) {
+ return in;
+ }
+
+ //====================================================================================================
+ // Parser defined on method.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testParserOnMethod", parsers=TestParserB.class)
+ public String testParserOnMethod(@Content String in) {
+ return in;
+ }
+
+ @Consumes("text/b")
+ public static class TestParserB extends ReaderParser {
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return (T)("text/b - " + IOUtils.read(session.getReader()).trim());
+ }
+ }
+
+ //====================================================================================================
+ // Parser overridden on method.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testParserOverriddenOnMethod", parsers={TestParserB.class,TestParserC.class}, parsersInherit=PARSERS)
+ public String testParserOverriddenOnMethod(@Content String in) {
+ return in;
+ }
+
+ @Consumes("text/c")
+ public static class TestParserC extends ReaderParser {
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return (T)("text/c - " + IOUtils.read(session.getReader()).trim());
+ }
+ }
+
+ //====================================================================================================
+ // Parser with different Accept than Content-Type.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testParserWithDifferentMediaTypes", parsers={TestParserD.class}, parsersInherit=PARSERS)
+ public String testParserWithDifferentMediaTypes(@Content String in) {
+ return in;
+ }
+
+ @Consumes({"text/a","text/d"})
+ public static class TestParserD extends ReaderParser {
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return (T)("text/d - " + IOUtils.read(session.getReader()).trim());
+ }
+ }
+
+ //====================================================================================================
+ // Check for valid error response.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testValidErrorResponse")
+ public String testValidErrorResponse(@Content String in) {
+ return in;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/PathResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/PathResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/PathResource.java
new file mode 100755
index 0000000..e6aa718
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/PathResource.java
@@ -0,0 +1,69 @@
+// ***************************************************************************************************************************
+// * 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.
+ * Tests the RestServlet.getPath() method.
+ */
+@RestResource(
+ path="/testPath",
+ children={
+ PathResource.TestPath2.class
+ }
+)
+public class PathResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Basic tests
+ //====================================================================================================
+ @RestMethod(name="GET", path="/")
+ public String doGet() {
+ return getPath();
+ }
+
+ @RestResource(
+ path="/testPath2",
+ children={
+ PathResource.TestPath3.class
+ }
+ )
+ public static class TestPath2 extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+ // Basic tests
+ @RestMethod(name="GET", path="/")
+ public String doGet() {
+ return getPath();
+ }
+ }
+
+ @RestResource(
+ path="/testPath3"
+ )
+ public static class TestPath3a extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+ // Basic tests
+ @RestMethod(name="GET", path="/")
+ public String doGet() {
+ return getPath();
+ }
+ }
+
+ public static class TestPath3 extends TestPath3a {
+ private static final long serialVersionUID = 1L;
+ }
+}
[08/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/PathsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/PathsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/PathsTest.java
deleted file mode 100755
index e0c020a..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/PathsTest.java
+++ /dev/null
@@ -1,1368 +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.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-public class PathsTest {
-
- private static String URL = "/testPaths";
-
- //====================================================================================================
- // Basic tests
- //====================================================================================================
- @Test
- public void testBasic() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r;
- String url;
-
- // [/test/testPaths]
- // {
- // pathInfo:null,
- // pathInfoUndecoded:null,
- // pathInfoParts:[],
- // pathRemainder:null,
- // pathRemainderUndecoded:null,
- // requestURI:'/jazz/juneau/test/testPaths',
- // requestParentURI:'/jazz/juneau/test',
- // requestURL:'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletPath:'/juneau/test/testPaths',
- // relativeServletURI:'/jazz/juneau/test/testPaths',
- // pathRemainder2:null
- // }
- url = URL;
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertNull(r.getString("pathInfo"));
- assertNull(r.getString("pathInfoUndecoded"));
- assertEquals("[]", r.getObjectList("pathInfoParts").toString());
- assertNull(r.getString("pathRemainder"));
- assertNull(r.getString("pathRemainderUndecoded"));
- assertNull(r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestParentURI").endsWith("/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
-
- // [/test/testPaths/]
- // {
- // pathInfo: '/',
- // pathInfoUndecoded: '/',
- // pathInfoParts: [
- // ],
- // pathRemainder: '',
- // pathRemainderUndecoded: '',
- // requestURI: '/jazz/juneau/test/testPaths/',
- // requestParentURI: '/jazz/juneau/test',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/',
- // servletPath: '/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: ''
- // }
- url = URL + '/';
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/", r.getString("pathInfo"));
- assertEquals("/", r.getString("pathInfoUndecoded"));
- assertEquals("[]", r.getObjectList("pathInfoParts").toString());
- assertEquals("", r.getString("pathRemainder"));
- assertEquals("", r.getString("pathRemainderUndecoded"));
- assertEquals("", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/"));
- assertTrue(r.getString("requestParentURI").endsWith("/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- // [/test/testPaths//]
- // {
- // pathInfo: '//',
- // pathInfoParts: [''],
- // pathRemainder: '/',
- // requestURI: '/jazz/juneau/test/testPaths//',
- // requestParentURI: '/jazz/juneau/test',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths//',
- // servletPath: '/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '/'
- // }
- url = URL + "//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("//", r.getString("pathInfo"));
- assertEquals("['']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/", r.getString("pathRemainder"));
- assertEquals("/", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths//"));
- assertTrue(r.getString("requestParentURI").endsWith("/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- // [/test/testPaths///]
- // {
- // pathInfo: '///',
- // pathInfoParts: ['',''],
- // pathRemainder: '//',
- // requestURI: '/jazz/juneau/test/testPaths///',
- // requestParentURI: '/jazz/juneau/test',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths///',
- // servletPath: '/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '//'
- // }
- url = URL + "///";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("///", r.getString("pathInfo"));
- assertEquals("['','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("//", r.getString("pathRemainder"));
- assertEquals("//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths///"));
- assertTrue(r.getString("requestParentURI").endsWith("/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths///"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- // [/test/testPaths/foo/bar]
- // {
- // pathInfo: '/foo/bar',
- // pathInfoParts: [
- // 'foo',
- // 'bar'
- // ],
- // pathRemainder: 'foo/bar',
- // requestURI: '/jazz/juneau/test/testPaths/foo/bar',
- // requestParentURI: '/jazz/juneau/test/testPaths/foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/foo/bar',
- // servletPath: '/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: 'foo/bar'
- // }
- url = URL + "/foo/bar";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/foo/bar", r.getString("pathInfo"));
- assertEquals("['foo','bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals("foo/bar", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/foo/bar"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/foo"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/foo/bar"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- // [/test/testPaths/foo/bar/]
- // {
- // pathInfo: '/foo/bar/',
- // pathInfoParts: [
- // 'foo',
- // 'bar'
- // ],
- // pathRemainder: 'foo/bar/',
- // requestURI: '/jazz/juneau/test/testPaths/foo/bar/',
- // requestParentURI: '/jazz/juneau/test/testPaths/foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/foo/bar/',
- // servletPath: '/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: 'foo/bar/'
- // }
- url = URL + "/foo/bar/";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/foo/bar/", r.getString("pathInfo"));
- assertEquals("['foo','bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo/bar/", r.getString("pathRemainder"));
- assertEquals("foo/bar/", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/foo/bar/"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/foo"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/foo/bar/"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- // [/test/testPaths//foo//bar//]
- // {
- // pathInfo: '//foo//bar//',
- // pathInfoParts: [
- // '',
- // 'foo',
- // '',
- // 'bar',
- // ''
- // ],
- // pathRemainder: '/foo//bar//',
- // requestURI: '/jazz/juneau/test/testPaths//foo//bar//',
- // requestParentURI: '/jazz/juneau/test/testPaths//foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths//foo//bar//',
- // servletPath: '/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '/foo//bar//'
- // }
- url = URL + "//foo//bar//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("//foo//bar//", r.getString("pathInfo"));
- assertEquals("['','foo','','bar','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/foo//bar//", r.getString("pathRemainder"));
- assertEquals("/foo//bar//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths//foo//bar//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths//foo/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths//foo//bar//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- // [/test/testPaths/foo%2Fbar]
- // {
- // pathInfo: '/foo//bar',
- // pathInfoUndecoded: '/foo%2F%2Fbar',
- // pathInfoParts: [
- // 'foo//bar'
- // ],
- // pathRemainder: 'foo//bar',
- // pathRemainderUndecoded: 'foo%2F%2Fbar',
- // requestURI: '/jazz/juneau/test/testPaths/foo%2F%2Fbar',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/foo%2F%2Fbar',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: 'foo//bar',
- // method: 1
- // }
- url = URL + "/foo%2F%2Fbar";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/foo//bar", r.getString("pathInfo"));
- assertEquals("/foo%2F%2Fbar", r.getString("pathInfoUndecoded"));
- assertEquals("['foo//bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo//bar", r.getString("pathRemainder"));
- assertEquals("foo%2F%2Fbar", r.getString("pathRemainderUndecoded"));
- assertEquals("foo//bar", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/foo%2F%2Fbar"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/foo%2F%2Fbar"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- // [/test/testPaths//foo%2Fbar//]
- // {
- // pathInfo: '//foo//bar//',
- // pathInfoUndecoded: '//foo%2F%2Fbar//',
- // pathInfoParts: [
- // '',
- // 'foo//bar',
- // ''
- // ],
- // pathRemainder: '/foo//bar//',
- // pathRemainderUndecoded: '/foo%2F%2Fbar//',
- // requestURI: '/jazz/juneau/test/testPaths//foo%2F%2Fbar//',
- // requestParentURI: '/jazz/juneau/test/testPaths/',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths//foo%2F%2Fbar//',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '/foo//bar//',
- // method: 1
- // }
- url = URL + "//foo%2F%2Fbar//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("//foo//bar//", r.getString("pathInfo"));
- assertEquals("//foo%2F%2Fbar//", r.getString("pathInfoUndecoded"));
- assertEquals("['','foo//bar','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/foo//bar//", r.getString("pathRemainder"));
- assertEquals("/foo%2F%2Fbar//", r.getString("pathRemainderUndecoded"));
- assertEquals("/foo//bar//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths//foo%2F%2Fbar//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths//foo%2F%2Fbar//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- // [/test/testPaths/test2]
- // {
- // pathInfo: '/test2',
- // pathInfoParts: [
- // 'test2'
- // ],
- // pathRemainder: null,
- // requestURI: '/jazz/juneau/test/testPaths/test2',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: null,
- // method: 2
- // }
- url = URL + "/test2";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2", r.getString("pathInfo"));
- assertEquals("['test2']", r.getObjectList("pathInfoParts").toString());
- assertNull(r.getString("pathRemainder"));
- assertNull(r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
-
- // [/test/testPaths/test2/]
- // {
- // pathInfo: '/test2/',
- // pathInfoParts: [
- // 'test2'
- // ],
- // pathRemainder: '',
- // requestURI: '/jazz/juneau/test/testPaths/test2/',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2/',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '',
- // method: 2
- // }
- url = URL + "/test2/";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/", r.getString("pathInfo"));
- assertEquals("['test2']", r.getObjectList("pathInfoParts").toString());
- assertEquals("", r.getString("pathRemainder"));
- assertEquals("", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- // [/test/testPaths/test2//]
- // {
- // pathInfo: '/test2//',
- // pathInfoParts: [
- // 'test2',
- // ''
- // ],
- // pathRemainder: '/',
- // requestURI: '/jazz/juneau/test/testPaths/test2//',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2//',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '/',
- // method: 2
- // }
- url = URL + "/test2//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2//", r.getString("pathInfo"));
- assertEquals("['test2','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/", r.getString("pathRemainder"));
- assertEquals("/", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- // [/test/testPaths/test2///]
- // {
- // pathInfo: '/test2///',
- // pathInfoParts: [
- // 'test2',
- // '',
- // ''
- // ],
- // pathRemainder: '//',
- // requestURI: '/jazz/juneau/test/testPaths/test2///',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2///',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '//',
- // method: 2
- // }
- url = URL + "/test2///";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2///", r.getString("pathInfo"));
- assertEquals("['test2','','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("//", r.getString("pathRemainder"));
- assertEquals("//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2///"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2///"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- // [/test/testPaths/test2/foo/bar]
- // {
- // pathInfo: '/test2/foo/bar',
- // pathInfoParts: [
- // 'test2',
- // 'foo',
- // 'bar'
- // ],
- // pathRemainder: 'foo/bar',
- // requestURI: '/jazz/juneau/test/testPaths/test2/foo/bar',
- // requestParentURI: '/jazz/juneau/test/testPaths/test2/foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2/foo/bar',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: 'foo/bar',
- // method: 2
- // }
- url = URL + "/test2/foo/bar";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/foo/bar", r.getString("pathInfo"));
- assertEquals("['test2','foo','bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals("foo/bar", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/foo/bar"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2/foo"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/foo/bar"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- // [/test/testPaths/test2/foo/bar/]
- // {
- // pathInfo: '/test2/foo/bar/',
- // pathInfoParts: [
- // 'test2',
- // 'foo',
- // 'bar'
- // ],
- // pathRemainder: 'foo/bar/',
- // requestURI: '/jazz/juneau/test/testPaths/test2/foo/bar/',
- // requestParentURI: '/jazz/juneau/test/testPaths/test2/foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2/foo/bar/',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: 'foo/bar/',
- // method: 2
- // }
- url = URL + "/test2/foo/bar/";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/foo/bar/", r.getString("pathInfo"));
- assertEquals("['test2','foo','bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo/bar/", r.getString("pathRemainder"));
- assertEquals("foo/bar/", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/foo/bar/"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2/foo"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/foo/bar/"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- // [/test/testPaths/test2//foo//bar//]
- // {
- // pathInfo: '/test2//foo//bar//',
- // pathInfoParts: [
- // 'test2',
- // '',
- // 'foo',
- // '',
- // 'bar',
- // ''
- // ],
- // pathRemainder: '/foo//bar//',
- // requestURI: '/jazz/juneau/test/testPaths/test2//foo//bar//',
- // requestParentURI: '/jazz/juneau/test/testPaths/test2//foo/',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2//foo//bar//',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '/foo//bar//',
- // method: 2
- // }
- url = URL + "/test2//foo//bar//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2//foo//bar//", r.getString("pathInfo"));
- assertEquals("['test2','','foo','','bar','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/foo//bar//", r.getString("pathRemainder"));
- assertEquals("/foo//bar//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2//foo//bar//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2//foo/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2//foo//bar//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- // [/test/testPaths/test2/foo%2Fbar]
- // {
- // pathInfo: '/test2/foo//bar',
- // pathInfoUndecoded: '/test2/foo%2F%2Fbar',
- // pathInfoParts: [
- // 'test2',
- // 'foo//bar'
- // ],
- // pathRemainder: 'foo//bar',
- // pathRemainderUndecoded: 'foo%2F%2Fbar',
- // requestURI: '/jazz/juneau/test/testPaths/test2/foo%2F%2Fbar',
- // requestParentURI: '/jazz/juneau/test/testPaths/test2',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2/foo%2F%2Fbar',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: 'foo//bar',
- // method: 2
- // }
- url = URL + "/test2/foo%2F%2Fbar";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/foo//bar", r.getString("pathInfo"));
- assertEquals("/test2/foo%2F%2Fbar", r.getString("pathInfoUndecoded"));
- assertEquals("['test2','foo//bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo//bar", r.getString("pathRemainder"));
- assertEquals("foo%2F%2Fbar", r.getString("pathRemainderUndecoded"));
- assertEquals("foo//bar", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/foo%2F%2Fbar"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/foo%2F%2Fbar"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- // [/test/testPaths/test2//foo%2Fbar//]
- // {
- // pathInfo: '/test2//foo//bar//',
- // pathInfoUndecoded: '/test2//foo%2F%2Fbar//',
- // pathInfoParts: [
- // 'test2',
- // '',
- // 'foo//bar',
- // ''
- // ],
- // pathRemainder: '/foo//bar//',
- // pathRemainderUndecoded: '/foo%2F%2Fbar//',
- // requestURI: '/jazz/juneau/test/testPaths/test2//foo%2F%2Fbar//',
- // requestParentURI: '/jazz/juneau/test/testPaths/test2/',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2//foo%2F%2Fbar//',
- // servletPath: '/juneau/test/testPaths',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
- // relativeServletURI: '/jazz/juneau/test/testPaths',
- // pathRemainder2: '/foo//bar//',
- // method: 2
- // }
- url = URL + "/test2//foo%2F%2Fbar//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2//foo//bar//", r.getString("pathInfo"));
- assertEquals("/test2//foo%2F%2Fbar//", r.getString("pathInfoUndecoded"));
- assertEquals("['test2','','foo//bar','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/foo//bar//", r.getString("pathRemainder"));
- assertEquals("/foo%2F%2Fbar//", r.getString("pathRemainderUndecoded"));
- assertEquals("/foo//bar//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2//foo%2F%2Fbar//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2//foo%2F%2Fbar//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- // [/test/testPaths/a]
- // {
- // pathInfo: null,
- // pathInfoParts: [
- // ],
- // pathRemainder: null,
- // requestURI: '/jazz/juneau/test/testPaths/a',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: null,
- // method: 3
- // }
- url = URL + "/a";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertNull(r.getString("pathInfo"));
- assertEquals("[]", r.getObjectList("pathInfoParts").toString());
- assertNull(r.getString("pathRemainder"));
- assertNull(r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- // [/test/testPaths/a/]
- // {
- // pathInfo: '/',
- // pathInfoParts: [
- // ],
- // pathRemainder: '',
- // requestURI: '/jazz/juneau/test/testPaths/a/',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '',
- // method: 3
- // }
- url = URL + "/a/";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/", r.getString("pathInfo"));
- assertEquals("[]", r.getObjectList("pathInfoParts").toString());
- assertEquals("", r.getString("pathRemainder"));
- assertEquals("", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- // [/test/testPaths/a//]
- // {
- // pathInfo: '//',
- // pathInfoParts: [
- // ''
- // ],
- // pathRemainder: '/',
- // requestURI: '/jazz/juneau/test/testPaths/a//',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a//',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '/',
- // method: 3
- // }
- url = URL + "/a//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("//", r.getString("pathInfo"));
- assertEquals("['']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/", r.getString("pathRemainder"));
- assertEquals("/", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- // [/test/testPaths/a///]
- // {
- // pathInfo: '///',
- // pathInfoParts: [
- // '',
- // ''
- // ],
- // pathRemainder: '//',
- // requestURI: '/jazz/juneau/test/testPaths/a///',
- // requestParentURI: '/jazz/juneau/test/testPaths',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a///',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '//',
- // method: 3
- // }
- url = URL + "/a///";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("///", r.getString("pathInfo"));
- assertEquals("['','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("//", r.getString("pathRemainder"));
- assertEquals("//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a///"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a///"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- // [/test/testPaths/a/foo/bar]
- // {
- // pathInfo: '/foo/bar',
- // pathInfoParts: [
- // 'foo',
- // 'bar'
- // ],
- // pathRemainder: 'foo/bar',
- // requestURI: '/jazz/juneau/test/testPaths/a/foo/bar',
- // requestParentURI: '/jazz/juneau/test/testPaths/a/foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/foo/bar',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: 'foo/bar',
- // method: 3
- // }
- url = URL + "/a/foo/bar";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/foo/bar", r.getString("pathInfo"));
- assertEquals("['foo','bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals("foo/bar", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/foo/bar"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/foo"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/foo/bar"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- // [/test/testPaths/a/foo/bar/]
- // {
- // pathInfo: '/foo/bar/',
- // pathInfoParts: [
- // 'foo',
- // 'bar'
- // ],
- // pathRemainder: 'foo/bar/',
- // requestURI: '/jazz/juneau/test/testPaths/a/foo/bar/',
- // requestParentURI: '/jazz/juneau/test/testPaths/a/foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/foo/bar/',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: 'foo/bar/',
- // method: 3
- // }
- url = URL + "/a/foo/bar/";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/foo/bar/", r.getString("pathInfo"));
- assertEquals("['foo','bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo/bar/", r.getString("pathRemainder"));
- assertEquals("foo/bar/", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/foo/bar/"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/foo"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/foo/bar/"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- // [/test/testPaths/a//foo//bar//]
- // {
- // pathInfo: '//foo//bar//',
- // pathInfoParts: [
- // '',
- // 'foo',
- // '',
- // 'bar',
- // ''
- // ],
- // pathRemainder: '/foo//bar//',
- // requestURI: '/jazz/juneau/test/testPaths/a//foo//bar//',
- // requestParentURI: '/jazz/juneau/test/testPaths/a//foo/',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a//foo//bar//',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '/foo//bar//',
- // method: 3
- // }
- url = URL + "/a//foo//bar//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("//foo//bar//", r.getString("pathInfo"));
- assertEquals("['','foo','','bar','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/foo//bar//", r.getString("pathRemainder"));
- assertEquals("/foo//bar//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a//foo//bar//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a//foo/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a//foo//bar//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- // [/test/testPaths/a/foo%2Fbar]
- // {
- // pathInfo: '/foo//bar',
- // pathInfoUndecoded: '/foo%2F%2Fbar',
- // pathInfoParts: [
- // 'foo//bar'
- // ],
- // pathRemainder: 'foo//bar',
- // pathRemainderUndecoded: 'foo%2F%2Fbar',
- // requestURI: '/jazz/juneau/test/testPaths/a/foo%2F%2Fbar',
- // requestParentURI: '/jazz/juneau/test/testPaths/a',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/foo%2F%2Fbar',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: 'foo//bar',
- // method: 3
- // }
- url = URL + "/a/foo%2F%2Fbar";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/foo//bar", r.getString("pathInfo"));
- assertEquals("/foo%2F%2Fbar", r.getString("pathInfoUndecoded"));
- assertEquals("['foo//bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo//bar", r.getString("pathRemainder"));
- assertEquals("foo%2F%2Fbar", r.getString("pathRemainderUndecoded"));
- assertEquals("foo//bar", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/foo%2F%2Fbar"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/foo%2F%2Fbar"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- // [/test/testPaths/a//foo%2Fbar//]
- // {
- // pathInfo: '//foo//bar//',
- // pathInfoUndecoded: '//foo%2F%2Fbar//',
- // pathInfoParts: [
- // '',
- // 'foo//bar',
- // ''
- // ],
- // pathRemainder: '/foo//bar//',
- // pathRemainderUndecoded: '/foo%2F%2Fbar//',
- // requestURI: '/jazz/juneau/test/testPaths/a//foo%2F%2Fbar//',
- // requestParentURI: '/jazz/juneau/test/testPaths/a/',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a//foo%2F%2Fbar//',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '/foo//bar//',
- // method: 3
- // }
- url = URL + "/a//foo%2F%2Fbar//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("//foo//bar//", r.getString("pathInfo"));
- assertEquals("//foo%2F%2Fbar//", r.getString("pathInfoUndecoded"));
- assertEquals("['','foo//bar','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/foo//bar//", r.getString("pathRemainder"));
- assertEquals("/foo%2F%2Fbar//", r.getString("pathRemainderUndecoded"));
- assertEquals("/foo//bar//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a//foo%2F%2Fbar//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a//foo%2F%2Fbar//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
-
- // [/test/testPaths/a/test2]
- // {
- // pathInfo: '/test2',
- // pathInfoParts: [
- // 'test2'
- // ],
- // pathRemainder: null,
- // requestURI: '/jazz/juneau/test/testPaths/a/test2',
- // requestParentURI: '/jazz/juneau/test/testPaths/a',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: null,
- // method: 4
- // }
- url = URL + "/a/test2";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2", r.getString("pathInfo"));
- assertEquals("['test2']", r.getObjectList("pathInfoParts").toString());
- assertNull(r.getString("pathRemainder"));
- assertNull(r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- // [/test/testPaths/a/test2/]
- // {
- // pathInfo: '/test2/',
- // pathInfoParts: [
- // 'test2'
- // ],
- // pathRemainder: '',
- // requestURI: '/jazz/juneau/test/testPaths/a/test2/',
- // requestParentURI: '/jazz/juneau/test/testPaths/a',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2/',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '',
- // method: 4
- // }
- url = URL + "/a/test2/";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/", r.getString("pathInfo"));
- assertEquals("['test2']", r.getObjectList("pathInfoParts").toString());
- assertEquals("", r.getString("pathRemainder"));
- assertEquals("", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- // [/test/testPaths/a/test2//]
- // {
- // pathInfo: '/test2//',
- // pathInfoParts: [
- // 'test2',
- // ''
- // ],
- // pathRemainder: '/',
- // requestURI: '/jazz/juneau/test/testPaths/a/test2//',
- // requestParentURI: '/jazz/juneau/test/testPaths/a',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2//',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '/',
- // method: 4
- // }
- url = URL + "/a/test2//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2//", r.getString("pathInfo"));
- assertEquals("['test2','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/", r.getString("pathRemainder"));
- assertEquals("/", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- // [/test/testPaths/a/test2///]
- // {
- // pathInfo: '/test2///',
- // pathInfoParts: [
- // 'test2',
- // '',
- // ''
- // ],
- // pathRemainder: '//',
- // requestURI: '/jazz/juneau/test/testPaths/a/test2///',
- // requestParentURI: '/jazz/juneau/test/testPaths/a',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2///',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '//',
- // method: 4
- // }
- url = URL + "/a/test2///";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2///", r.getString("pathInfo"));
- assertEquals("['test2','','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("//", r.getString("pathRemainder"));
- assertEquals("//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2///"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2///"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- // [/test/testPaths/a/test2/foo/bar]
- // {
- // pathInfo: '/test2/foo/bar',
- // pathInfoParts: [
- // 'test2',
- // 'foo',
- // 'bar'
- // ],
- // pathRemainder: 'foo/bar',
- // requestURI: '/jazz/juneau/test/testPaths/a/test2/foo/bar',
- // requestParentURI: '/jazz/juneau/test/testPaths/a/test2/foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2/foo/bar',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: 'foo/bar',
- // method: 4
- // }
- url = URL + "/a/test2/foo/bar";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/foo/bar", r.getString("pathInfo"));
- assertEquals("['test2','foo','bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals("foo/bar", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/foo/bar"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2/foo"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/foo/bar"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- // [/test/testPaths/a/test2/foo/bar/]
- // {
- // pathInfo: '/test2/foo/bar/',
- // pathInfoParts: [
- // 'test2',
- // 'foo',
- // 'bar'
- // ],
- // pathRemainder: 'foo/bar/',
- // requestURI: '/jazz/juneau/test/testPaths/a/test2/foo/bar/',
- // requestParentURI: '/jazz/juneau/test/testPaths/a/test2/foo',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2/foo/bar/',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: 'foo/bar/',
- // method: 4
- // }
- url = URL + "/a/test2/foo/bar/";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/foo/bar/", r.getString("pathInfo"));
- assertEquals("['test2','foo','bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo/bar/", r.getString("pathRemainder"));
- assertEquals("foo/bar/", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/foo/bar/"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2/foo"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/foo/bar/"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- // [/test/testPaths/a/test2//foo//bar//]
- // {
- // pathInfo: '/test2//foo//bar//',
- // pathInfoParts: [
- // 'test2',
- // '',
- // 'foo',
- // '',
- // 'bar',
- // ''
- // ],
- // pathRemainder: '/foo//bar//',
- // requestURI: '/jazz/juneau/test/testPaths/a/test2//foo//bar//',
- // requestParentURI: '/jazz/juneau/test/testPaths/a/test2//foo/',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2//foo//bar//',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '/foo//bar//',
- // method: 4
- // }
- url = URL + "/a/test2//foo//bar//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2//foo//bar//", r.getString("pathInfo"));
- assertEquals("['test2','','foo','','bar','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/foo//bar//", r.getString("pathRemainder"));
- assertEquals("/foo//bar//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2//foo//bar//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2//foo/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2//foo//bar//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- // [/test/testPaths/a/test2/foo%2Fbar]
- // {
- // pathInfo: '/test2/foo//bar',
- // pathInfoUndecoded: '/test2/foo%2F%2Fbar',
- // pathInfoParts: [
- // 'test2',
- // 'foo//bar'
- // ],
- // pathRemainder: 'foo//bar',
- // pathRemainderUndecoded: 'foo%2F%2Fbar',
- // requestURI: '/jazz/juneau/test/testPaths/a/test2/foo%2F%2Fbar',
- // requestParentURI: '/jazz/juneau/test/testPaths/a/test2',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2/foo%2F%2Fbar',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: 'foo//bar',
- // method: 4
- // }
- url = URL + "/a/test2/foo%2F%2Fbar";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/foo//bar", r.getString("pathInfo"));
- assertEquals("/test2/foo%2F%2Fbar", r.getString("pathInfoUndecoded"));
- assertEquals("['test2','foo//bar']", r.getObjectList("pathInfoParts").toString());
- assertEquals("foo//bar", r.getString("pathRemainder"));
- assertEquals("foo%2F%2Fbar", r.getString("pathRemainderUndecoded"));
- assertEquals("foo//bar", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/foo%2F%2Fbar"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/foo%2F%2Fbar"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- // [/test/testPaths/a/test2//foo%2Fbar//]
- // {
- // pathInfo: '/test2//foo//bar//',
- // pathInfoUndecoded: '/test2//foo%2F%2Fbar//',
- // pathInfoParts: [
- // 'test2',
- // '',
- // 'foo//bar',
- // ''
- // ],
- // pathRemainder: '/foo//bar//',
- // pathRemainderUndecoded: '/foo%2F%2Fbar//',
- // requestURI: '/jazz/juneau/test/testPaths/a/test2//foo%2F%2Fbar//',
- // requestParentURI: '/jazz/juneau/test/testPaths/a/test2/',
- // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2//foo%2F%2Fbar//',
- // servletPath: '/juneau/test/testPaths/a',
- // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
- // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
- // relativeServletURI: '/jazz/juneau/test/testPaths/a',
- // pathRemainder2: '/foo//bar//',
- // method: 4
- // }
- url = URL + "/a/test2//foo%2F%2Fbar//";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2//foo//bar//", r.getString("pathInfo"));
- assertEquals("/test2//foo%2F%2Fbar//", r.getString("pathInfoUndecoded"));
- assertEquals("['test2','','foo//bar','']", r.getObjectList("pathInfoParts").toString());
- assertEquals("/foo//bar//", r.getString("pathRemainder"));
- assertEquals("/foo%2F%2Fbar//", r.getString("pathRemainderUndecoded"));
- assertEquals("/foo//bar//", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2//foo%2F%2Fbar//"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2/"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2//foo%2F%2Fbar//"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- //--------------------------------------------------------------------------------
- // Spaces
- //--------------------------------------------------------------------------------
- url = URL + "/%20";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/ ", r.getString("pathInfo"));
- assertEquals("/%20", r.getString("pathInfoUndecoded"));
- assertEquals("[' ']", r.getObjectList("pathInfoParts").toString());
- assertEquals(" ", r.getString("pathRemainder"));
- assertEquals("%20", r.getString("pathRemainderUndecoded"));
- assertEquals(" ", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/%20"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/%20"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- url = URL + "/test2/%20";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/ ", r.getString("pathInfo"));
- assertEquals("/test2/%20", r.getString("pathInfoUndecoded"));
- assertEquals("['test2',' ']", r.getObjectList("pathInfoParts").toString());
- assertEquals(" ", r.getString("pathRemainder"));
- assertEquals("%20", r.getString("pathRemainderUndecoded"));
- assertEquals(" ", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/%20"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/%20"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- url = URL + "/a/%20";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/ ", r.getString("pathInfo"));
- assertEquals("/%20", r.getString("pathInfoUndecoded"));
- assertEquals("[' ']", r.getObjectList("pathInfoParts").toString());
- assertEquals(" ", r.getString("pathRemainder"));
- assertEquals("%20", r.getString("pathRemainderUndecoded"));
- assertEquals(" ", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/%20"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/%20"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- url = URL + "/a/test2/%20";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/ ", r.getString("pathInfo"));
- assertEquals("/test2/%20", r.getString("pathInfoUndecoded"));
- assertEquals("['test2',' ']", r.getObjectList("pathInfoParts").toString());
- assertEquals(" ", r.getString("pathRemainder"));
- assertEquals("%20", r.getString("pathRemainderUndecoded"));
- assertEquals(" ", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/%20"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/%20"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- url = URL + "/+";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/ ", r.getString("pathInfo"));
- assertEquals("/+", r.getString("pathInfoUndecoded"));
- assertEquals("[' ']", r.getObjectList("pathInfoParts").toString());
- assertEquals(" ", r.getString("pathRemainder"));
- assertEquals("+", r.getString("pathRemainderUndecoded"));
- assertEquals(" ", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/+"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/+"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(1, (int)r.getInt("method"));
-
- url = URL + "/test2/+";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/ ", r.getString("pathInfo"));
- assertEquals("/test2/+", r.getString("pathInfoUndecoded"));
- assertEquals("['test2',' ']", r.getObjectList("pathInfoParts").toString());
- assertEquals(" ", r.getString("pathRemainder"));
- assertEquals("+", r.getString("pathRemainderUndecoded"));
- assertEquals(" ", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/+"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/+"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
- assertEquals(2, (int)r.getInt("method"));
-
- url = URL + "/a/+";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/ ", r.getString("pathInfo"));
- assertEquals("/+", r.getString("pathInfoUndecoded"));
- assertEquals("[' ']", r.getObjectList("pathInfoParts").toString());
- assertEquals(" ", r.getString("pathRemainder"));
- assertEquals("+", r.getString("pathRemainderUndecoded"));
- assertEquals(" ", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/+"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/+"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(3, (int)r.getInt("method"));
-
- url = URL + "/a/test2/+";
- r = client.doGet(url).getResponse(ObjectMap.class);
- assertEquals("/test2/ ", r.getString("pathInfo"));
- assertEquals("/test2/+", r.getString("pathInfoUndecoded"));
- assertEquals("['test2',' ']", r.getObjectList("pathInfoParts").toString());
- assertEquals(" ", r.getString("pathRemainder"));
- assertEquals("+", r.getString("pathRemainderUndecoded"));
- assertEquals(" ", r.getString("pathRemainder2"));
- assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/+"));
- assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2"));
- assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/+"));
- assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
- assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
- assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
- assertEquals(4, (int)r.getInt("method"));
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/PropertiesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/PropertiesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/PropertiesTest.java
deleted file mode 100755
index ffc054e..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/PropertiesTest.java
+++ /dev/null
@@ -1,48 +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 PropertiesTest {
-
- private static String URL = "/testProperties";
-
- //====================================================================================================
- // Properties defined on method.
- //====================================================================================================
- @Test
- public void testPropertiesDefinedOnMethod() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r = client.doGet(URL + "/testPropertiesDefinedOnMethod").getResponseAsString();
- assertTrue(r.matches("A1=a1,A2=c,B1=b1,B2=c,C=c,R1a=.*/testProperties/testPropertiesDefinedOnMethod,R1b=.*/testProperties,R2=bar,R3=baz,R4=a1,R5=c,R6=c"));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Make sure attributes/parameters/headers are available through ctx.getProperties().
- //====================================================================================================
- @Test
- public void testProperties() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r = client.doGet(URL + "/testProperties/a1?P=p1").setHeader("H", "h1").getResponseAsString();
- assertEquals("A=a1,P=p1,H=h1", r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/RestClientTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/RestClientTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/RestClientTest.java
deleted file mode 100755
index c1270fd..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/RestClientTest.java
+++ /dev/null
@@ -1,199 +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.apache.juneau.server.TestUtils.*;
-import static org.junit.Assert.*;
-
-import java.util.*;
-import java.util.regex.*;
-
-import org.apache.http.entity.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-public class RestClientTest {
-
- private static String URL = "/testRestClient";
-
- //====================================================================================================
- // successPattern()
- //====================================================================================================
- @Test
- public void testSuccessPattern() throws Exception {
- RestClient c = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
- int rc;
-
- r = c.doPost(URL, new StringEntity("xxxSUCCESSxxx")).successPattern("SUCCESS").getResponseAsString();
- assertEquals("xxxSUCCESSxxx", r);
- rc = c.doPost(URL, new StringEntity("xxxSUCCESSxxx")).successPattern("SUCCESS").run();
- assertEquals(200, rc);
-
- try {
- r = c.doPost(URL, new StringEntity("xxxFAILURExxx")).successPattern("SUCCESS").getResponseAsString();
- fail();
- } catch (RestCallException e) {
- assertEquals("Success pattern not detected.", e.getLocalizedMessage());
- }
-
- c.closeQuietly();
- }
-
- //====================================================================================================
- // failurePattern()
- //====================================================================================================
- @Test
- public void testFailurePattern() throws Exception {
- RestClient c = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
- int rc;
-
- r = c.doPost(URL, new StringEntity("xxxSUCCESSxxx")).failurePattern("FAILURE").getResponseAsString();
- assertEquals("xxxSUCCESSxxx", r);
- rc = c.doPost(URL, new StringEntity("xxxSUCCESSxxx")).failurePattern("FAILURE").run();
- assertEquals(200, rc);
-
- try {
- r = c.doPost(URL, new StringEntity("xxxFAILURExxx")).failurePattern("FAILURE").getResponseAsString();
- fail();
- } catch (RestCallException e) {
- assertEquals("Failure pattern detected.", e.getLocalizedMessage());
- }
-
- try {
- r = c.doPost(URL, new StringEntity("xxxERRORxxx")).failurePattern("FAILURE|ERROR").getResponseAsString();
- fail();
- } catch (RestCallException e) {
- assertEquals("Failure pattern detected.", e.getLocalizedMessage());
- }
-
- c.closeQuietly();
- }
-
- //====================================================================================================
- // captureResponse()/getCapturedResponse()
- //====================================================================================================
- @Test
- public void testCaptureResponse() throws Exception {
- RestClient c = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- RestCall rc = c.doPost(URL, new StringEntity("xxx")).captureResponse();
-
- try {
- rc.getCapturedResponse();
- fail();
- } catch (IllegalStateException e) {
- assertEquals("This method cannot be called until the response has been consumed.", e.getLocalizedMessage());
- }
- rc.run();
- assertEquals("xxx", rc.getCapturedResponse());
- assertEquals("xxx", rc.getCapturedResponse());
-
- rc = c.doPost(URL, new StringEntity("xxx")).captureResponse();
- assertEquals("xxx", rc.getResponseAsString());
- assertEquals("xxx", rc.getCapturedResponse());
- assertEquals("xxx", rc.getCapturedResponse());
-
- try {
- rc.getResponseAsString();
- fail();
- } catch (IllegalStateException e) {
- assertEquals("Method cannot be called. Response has already been consumed.", e.getLocalizedMessage());
- }
-
- c.closeQuietly();
- }
-
- //====================================================================================================
- // addResponsePattern()
- //====================================================================================================
- @Test
- public void testAddResponsePattern() throws Exception {
- RestClient c = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
-
- final List<String> l = new ArrayList<String>();
- ResponsePattern p = new ResponsePattern("x=(\\d+),y=(\\S+)") {
- @Override
- public void onMatch(RestCall restCall, Matcher m) throws RestCallException {
- l.add(m.group(1)+'/'+m.group(2));
- }
- @Override
- public void onNoMatch(RestCall restCall) throws RestCallException {
- throw new RestCallException("Pattern not found!");
- }
- };
-
- r = c.doPost(URL, new StringEntity("x=1,y=2")).addResponsePattern(p).getResponseAsString();
- assertEquals("x=1,y=2", r);
- assertObjectEquals("['1/2']", l);
-
- l.clear();
-
- r = c.doPost(URL, new StringEntity("x=1,y=2\nx=3,y=4")).addResponsePattern(p).getResponseAsString();
- assertEquals("x=1,y=2\nx=3,y=4", r);
- assertObjectEquals("['1/2','3/4']", l);
-
- try {
- c.doPost(URL, new StringEntity("x=1")).addResponsePattern(p).run();
- fail();
- } catch (RestCallException e) {
- assertEquals("Pattern not found!", e.getLocalizedMessage());
- assertEquals(0, e.getResponseCode());
- }
-
- // Two patterns!
- ResponsePattern p1 = new ResponsePattern("x=(\\d+)") {
- @Override
- public void onMatch(RestCall restCall, Matcher m) throws RestCallException {
- l.add("x="+m.group(1));
- }
- @Override
- public void onNoMatch(RestCall restCall) throws RestCallException {
- throw new RestCallException("Pattern x not found!");
- }
- };
- ResponsePattern p2 = new ResponsePattern("y=(\\S+)") {
- @Override
- public void onMatch(RestCall restCall, Matcher m) throws RestCallException {
- l.add("y="+m.group(1));
- }
- @Override
- public void onNoMatch(RestCall restCall) throws RestCallException {
- throw new RestCallException("Pattern y not found!");
- }
- };
-
- l.clear();
- r = c.doPost(URL, new StringEntity("x=1,y=2\nx=3,y=4")).addResponsePattern(p1).addResponsePattern(p2).getResponseAsString();
- assertEquals("x=1,y=2\nx=3,y=4", r);
- assertObjectEquals("['x=1','x=3','y=2','y=4']", l);
-
- try {
- c.doPost(URL, new StringEntity("x=1\nx=3")).addResponsePattern(p1).addResponsePattern(p2).getResponseAsString();
- } catch (RestCallException e) {
- assertEquals("Pattern y not found!", e.getLocalizedMessage());
- assertEquals(0, e.getResponseCode());
- }
-
- try {
- c.doPost(URL, new StringEntity("y=1\ny=3")).addResponsePattern(p1).addResponsePattern(p2).getResponseAsString();
- } catch (RestCallException e) {
- assertEquals("Pattern x not found!", e.getLocalizedMessage());
- assertEquals(0, e.getResponseCode());
- }
-
- c.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/RestUtilsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/RestUtilsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/RestUtilsTest.java
deleted file mode 100755
index 2b33dc4..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/RestUtilsTest.java
+++ /dev/null
@@ -1,188 +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.apache.juneau.server.RestUtils.*;
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-public class RestUtilsTest {
-
- //====================================================================================================
- // decode(String)
- //====================================================================================================
- @Test
- public void testDecode() throws Exception {
- assertNull(decode(null));
- assertEquals("foo/bar baz bing", decode("foo%2Fbar+baz++bing"));
- }
-
- //====================================================================================================
- // encode(String)
- //====================================================================================================
- @Test
- public void testEncode() throws Exception {
- assertNull(encode(null));
- assertEquals("foo%2Fbar+baz++bing", encode("foo/bar baz bing"));
- assertEquals("foobar", encode("foobar"));
- assertEquals("+", encode(" "));
- assertEquals("%2F", encode("/"));
- }
-
- //====================================================================================================
- // trimPathInfo(String,String)
- //====================================================================================================
- @Test
- public void testGetServletURI() throws Exception {
- String e, sp, cp;
-
- e = "http://hostname";
- sp = "";
- cp = "";
-
- for (String s : new String[]{
- "http://hostname",
- "http://hostname/foo",
- "http://hostname?foo",
- "http://hostname/?foo"})
- assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
-
- for (String s : new String[]{
- "http:/hostname?foo"}) {
- try {
- trimPathInfo(new StringBuffer(s), cp, sp);
- fail("Exception expected - " + s);
- } catch (RuntimeException ex) {}
- }
-
-
- e = "http://hostname";
- sp = "/";
- cp = "/";
-
- for (String s : new String[]{
- "http://hostname",
- "http://hostname/foo",
- "http://hostname?foo",
- "http://hostname/?foo"})
- assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
-
- e = "http://hostname/foo";
- sp = "/foo";
- cp = "/";
-
- for (String s : new String[]{
- "http://hostname/foo",
- "http://hostname/foo/bar",
- "http://hostname/foo?bar"})
- assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
-
- for (String s : new String[]{
- "http://hostname/foo2",
- "http://hostname/fo2",
- "http://hostname?foo",
- "http://hostname/fo?bar",
- "http:/hostname/foo"}) {
- try {
- trimPathInfo(new StringBuffer(s), cp, sp);
- fail("Exception expected - " + s);
- } catch (RuntimeException ex) {}
- }
-
- e = "http://hostname/foo/bar";
- sp = "/foo/bar";
- cp = "/";
-
- for (String s : new String[]{
- "http://hostname/foo/bar",
- "http://hostname/foo/bar/baz",
- "http://hostname/foo/bar?baz"})
- assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
-
- for (String s : new String[]{
- "http://hostname/foo2/bar",
- "http://hostname/foo/bar2"
- }) {
- try {
- trimPathInfo(new StringBuffer(s), cp, sp);
- fail("Exception expected - " + s);
- } catch (RuntimeException ex) {}
- }
-
- e = "http://hostname/foo/bar";
- sp = "/bar";
- cp = "/foo";
-
- for (String s : new String[]{
- "http://hostname/foo/bar",
- "http://hostname/foo/bar/baz",
- "http://hostname/foo/bar?baz"})
- assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
-
- for (String s : new String[]{
- "http://hostname/foo2/bar",
- "http://hostname/foo/bar2"
- }) {
- try {
- trimPathInfo(new StringBuffer(s), cp, sp);
- fail("Exception expected - " + s);
- } catch (RuntimeException ex) {}
- }
- }
-
- //====================================================================================================
- // trimSlashes(String)
- //====================================================================================================
- @Test
- public void testTrimSlashes() throws Exception {
- assertNull(trimSlashes(null));
- assertEquals("", trimSlashes(""));
- assertEquals("", trimSlashes("/"));
- assertEquals("", trimSlashes("//"));
- assertEquals("foo/bar", trimSlashes("foo/bar"));
- assertEquals("foo/bar", trimSlashes("foo/bar//"));
- assertEquals("foo/bar", trimSlashes("/foo/bar//"));
- assertEquals("foo/bar", trimSlashes("//foo/bar//"));
- }
-
- //====================================================================================================
- // trimTrailingSlashes(String)
- //====================================================================================================
- @Test
- public void testTrimTrailingSlashes() throws Exception {
- assertNull(trimTrailingSlashes((String)null));
- assertEquals("", trimTrailingSlashes(""));
- assertEquals("", trimTrailingSlashes("/"));
- assertEquals("", trimTrailingSlashes("//"));
- assertEquals("foo/bar", trimTrailingSlashes("foo/bar"));
- assertEquals("foo/bar", trimTrailingSlashes("foo/bar//"));
- assertEquals("/foo/bar", trimTrailingSlashes("/foo/bar//"));
- assertEquals("//foo/bar", trimTrailingSlashes("//foo/bar//"));
- }
-
- //====================================================================================================
- // trimTrailingSlashes(StringBuffer)
- //====================================================================================================
- @Test
- public void testTrimTrailingSlashes2() throws Exception {
- assertNull(trimTrailingSlashes((StringBuffer)null));
- assertEquals("", trimTrailingSlashes(new StringBuffer("")).toString());
- assertEquals("", trimTrailingSlashes(new StringBuffer("/")).toString());
- assertEquals("", trimTrailingSlashes(new StringBuffer("//")).toString());
- assertEquals("foo/bar", trimTrailingSlashes(new StringBuffer("foo/bar")).toString());
- assertEquals("foo/bar", trimTrailingSlashes(new StringBuffer("foo/bar//")).toString());
- assertEquals("/foo/bar", trimTrailingSlashes(new StringBuffer("/foo/bar//")).toString());
- assertEquals("//foo/bar", trimTrailingSlashes(new StringBuffer("//foo/bar//")).toString());
- }
-}
[19/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java
index 91aa7c9..9f047ad 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java
@@ -37,18 +37,48 @@ import org.apache.juneau.xml.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the RDF parsers</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #RDF_trimWhitespace}</td>
+ * <td>Trim whitespace from text elements.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties inherited by the RDF parsers</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers.
+ * <ul>
+ * <li class='i'><a class='doclink' href='RdfCommonContext.html#ConfigProperties'>RdfCommonContext</a> - Configurable properties common to the RDF serializers and parsers.
+ * </ul>
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class RdfParserContext extends ParserContext implements RdfCommonContext {
/**
- * Trim whitespace from text elements ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Trim whitespace from text elements.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RdfParser.trimWhitespace"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, whitespace in text elements will be automatically trimmed.
*/
public static final String RDF_trimWhitespace = "RdfParser.trimWhitespace";
- final boolean trimWhitespace, looseCollection;
+ final boolean trimWhitespace, looseCollections;
final String rdfLanguage;
final Namespace juneauNs, juneauBpNs;
final RdfCollectionFormat collectionFormat;
@@ -64,7 +94,7 @@ public final class RdfParserContext extends ParserContext implements RdfCommonCo
public RdfParserContext(ContextFactory cf) {
super(cf);
trimWhitespace = cf.getProperty(RDF_trimWhitespace, boolean.class, false);
- looseCollection = cf.getProperty(RDF_looseCollection, boolean.class, false);
+ looseCollections = cf.getProperty(RDF_looseCollections, boolean.class, false);
rdfLanguage = cf.getProperty(RDF_language, String.class, "RDF/XML-ABBREV");
juneauNs = cf.getProperty(RDF_juneauNs, Namespace.class, new Namespace("j", "http://www.ibm.com/juneau/"));
juneauBpNs = cf.getProperty(RDF_juneauBpNs, Namespace.class, new Namespace("j", "http://www.ibm.com/juneaubp/"));
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java
index a493e36..e7cfce9 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java
@@ -38,7 +38,7 @@ public class RdfParserSession extends ParserSession {
private final Namespace juneauNs, juneauBpNs;
private final Property pRoot, pValue, pClass, pType;
private final Model model;
- private final boolean trimWhitespace, looseCollection;
+ private final boolean trimWhitespace, looseCollections;
private final RDFReader rdfReader;
private final Set<Resource> urisVisited = new HashSet<Resource>();
private final RdfCollectionFormat collectionFormat;
@@ -72,14 +72,14 @@ public class RdfParserSession extends ParserSession {
this.juneauBpNs = ctx.juneauBpNs;
this.trimWhitespace = ctx.trimWhitespace;
this.collectionFormat = ctx.collectionFormat;
- this.looseCollection = ctx.looseCollection;
+ this.looseCollections = ctx.looseCollections;
} else {
this.rdfLanguage = op.getString(RDF_language, ctx.rdfLanguage);
this.juneauNs = (op.containsKey(RDF_juneauNs) ? NamespaceFactory.parseNamespace(op.get(RDF_juneauNs)) : ctx.juneauNs);
this.juneauBpNs = (op.containsKey(RDF_juneauBpNs) ? NamespaceFactory.parseNamespace(op.get(RDF_juneauBpNs)) : ctx.juneauBpNs);
this.trimWhitespace = op.getBoolean(RdfParserContext.RDF_trimWhitespace, ctx.trimWhitespace);
this.collectionFormat = RdfCollectionFormat.valueOf(op.getString(RDF_collectionFormat, "DEFAULT"));
- this.looseCollection = op.getBoolean(RDF_looseCollection, ctx.looseCollection);
+ this.looseCollections = op.getBoolean(RDF_looseCollections, ctx.looseCollections);
}
this.model = ModelFactory.createDefaultModel();
addModelPrefix(juneauNs);
@@ -171,12 +171,12 @@ public class RdfParserSession extends ParserSession {
}
/**
- * Returns the {@link RdfCommonContext#RDF_looseCollection} setting value for this session.
+ * Returns the {@link RdfCommonContext#RDF_looseCollections} setting value for this session.
*
- * @return The {@link RdfCommonContext#RDF_looseCollection} setting value for this session.
+ * @return The {@link RdfCommonContext#RDF_looseCollections} setting value for this session.
*/
- public final boolean isLooseCollection() {
- return looseCollection;
+ public final boolean isLooseCollections() {
+ return looseCollections;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java
index 0ac2a62..a9beabb 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java
@@ -131,7 +131,7 @@ public class RdfSerializer extends WriterSerializer {
Resource r = null;
ClassMeta<?> cm = s.getBeanContext().getClassMetaForObject(o);
- if (s.isLooseCollection() && cm != null && (cm.isCollection() || cm.isArray())) {
+ if (s.isLooseCollections() && cm != null && (cm.isCollection() || cm.isArray())) {
Collection c = s.sort(cm.isCollection() ? (Collection)o : toList(cm.getInnerClass(), o));
for (Object o2 : c)
serializeAnything(s, o2, false, object(), "root", null, null);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java
index 5dd4bfa..6819f66 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java
@@ -37,17 +37,71 @@ import org.apache.juneau.xml.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the RDF serializers</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #RDF_addLiteralTypes}</td>
+ * <td>Add XSI data types to non-<code>String</code> literals.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_addRootProperty}</td>
+ * <td>Add RDF root identifier property to root node.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_autoDetectNamespaces}</td>
+ * <td>Auto-detect namespace usage.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_namespaces}</td>
+ * <td>Default namespaces.</td>
+ * <td><code>List<{@link Namespace}></code></td>
+ * <td>empty list</td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties inherited by the RDF serializers</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='RdfCommonContext.html#ConfigProperties'>RdfCommonContext</a> - Configurable properties common to the RDF serializers and parsers.
+ * </ul>
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class RdfSerializerContext extends SerializerContext implements RdfCommonContext {
/**
- * Add XSI data types to non-<code>String</code> literals ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Add XSI data types to non-<code>String</code> literals.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RdfSerializer.addLiteralTypes"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
*/
public static final String RDF_addLiteralTypes = "RdfSerializer.addLiteralTypes";
/**
- * Add RDF root identifier property to root node ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Add RDF root identifier property to root node.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RdfSerializer.addRootProperty"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* When enabled an RDF property <code>http://www.ibm.com/juneau/root</code> is added with a value of <js>"true"</js>
* to identify the root node in the graph.
@@ -60,7 +114,13 @@ public final class RdfSerializerContext extends SerializerContext implements Rdf
public static final String RDF_addRootProperty = "RdfSerializer.addRootProperty";
/**
- * Auto-detect namespace usage ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Auto-detect namespace usage.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RdfSerializer.autoDetectNamespaces"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* Detect namespace usage before serialization.
* <p>
@@ -71,14 +131,20 @@ public final class RdfSerializerContext extends SerializerContext implements Rdf
public static final String RDF_autoDetectNamespaces = "RdfSerializer.autoDetectNamespaces";
/**
- * Default namespaces (<code>List<Namespace></code>, default=<code>Namespace[0]</code>).
+ * <b>Configuration property:</b> Default namespaces.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"RdfSerializer.namespaces.list"</js>
+ * <li><b>Data type:</b> <code>List<{@link Namespace}></code>
+ * <li><b>Default:</b> empty list
+ * </ul>
* <p>
* The default list of namespaces associated with this serializer.
*/
public static final String RDF_namespaces = "RdfSerializer.namespaces.list";
- final boolean addLiteralTypes, addRootProperty, useXmlNamespaces, looseCollection, autoDetectNamespaces;
+ final boolean addLiteralTypes, addRootProperty, useXmlNamespaces, looseCollections, autoDetectNamespaces;
final String rdfLanguage;
final Namespace juneauNs;
final Namespace juneauBpNs;
@@ -98,7 +164,7 @@ public final class RdfSerializerContext extends SerializerContext implements Rdf
addLiteralTypes = cf.getProperty(RDF_addLiteralTypes, boolean.class, false);
addRootProperty = cf.getProperty(RDF_addRootProperty, boolean.class, false);
useXmlNamespaces = cf.getProperty(RDF_useXmlNamespaces, boolean.class, true);
- looseCollection = cf.getProperty(RDF_looseCollection, boolean.class, false);
+ looseCollections = cf.getProperty(RDF_looseCollections, boolean.class, false);
autoDetectNamespaces = cf.getProperty(RDF_autoDetectNamespaces, boolean.class, true);
rdfLanguage = cf.getProperty(RDF_language, String.class, "RDF/XML-ABBREV");
juneauNs = cf.getProperty(RDF_juneauNs, Namespace.class, new Namespace("j", "http://www.ibm.com/juneau/"));
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
index b4fa7aa..a1a73e7 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
@@ -37,7 +37,7 @@ public final class RdfSerializerSession extends SerializerSession {
private final String rdfLanguage;
private final Namespace juneauNs, juneauBpNs;
- private final boolean addLiteralTypes, addRootProperty, useXmlNamespaces, looseCollection, autoDetectNamespaces;
+ private final boolean addLiteralTypes, addRootProperty, useXmlNamespaces, looseCollections, autoDetectNamespaces;
private final Property pRoot, pValue, pClass;
private final Model model;
private final RDFWriter writer;
@@ -68,7 +68,7 @@ public final class RdfSerializerSession extends SerializerSession {
this.addLiteralTypes = ctx.addLiteralTypes;
this.addRootProperty = ctx.addRootProperty;
this.collectionFormat = ctx.collectionFormat;
- this.looseCollection = ctx.looseCollection;
+ this.looseCollections = ctx.looseCollections;
this.useXmlNamespaces = ctx.useXmlNamespaces;
this.autoDetectNamespaces = ctx.autoDetectNamespaces;
this.namespaces = ctx.namespaces;
@@ -84,7 +84,7 @@ public final class RdfSerializerSession extends SerializerSession {
jenaSettings.put(key.substring(9), e.getValue());
}
this.collectionFormat = RdfCollectionFormat.valueOf(op.getString(RDF_collectionFormat, "DEFAULT"));
- this.looseCollection = op.getBoolean(RDF_looseCollection, ctx.looseCollection);
+ this.looseCollections = op.getBoolean(RDF_looseCollections, ctx.looseCollections);
this.useXmlNamespaces = op.getBoolean(RDF_useXmlNamespaces, ctx.useXmlNamespaces);
this.autoDetectNamespaces = op.getBoolean(RDF_autoDetectNamespaces, ctx.autoDetectNamespaces);
this.namespaces = op.get(Namespace[].class, RDF_namespaces, ctx.namespaces);
@@ -137,12 +137,12 @@ public final class RdfSerializerSession extends SerializerSession {
}
/**
- * Returns the {@link RdfCommonContext#RDF_looseCollection} setting value for this session.
+ * Returns the {@link RdfCommonContext#RDF_looseCollections} setting value for this session.
*
- * @return The {@link RdfCommonContext#RDF_looseCollection} setting value for this session.
+ * @return The {@link RdfCommonContext#RDF_looseCollections} setting value for this session.
*/
- public final boolean isLooseCollection() {
- return looseCollection;
+ public final boolean isLooseCollections() {
+ return looseCollections;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/package.html b/juneau-core/src/main/java/org/apache/juneau/jena/package.html
index 0a25043..2a08529 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/package.html
@@ -372,7 +372,7 @@
<jk>public class</jk> Person {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>)
+ <ja>@Rdf</ja>(beanUri=<jk>true</jk>)
<jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>addressBookUri</jf>;
@@ -414,7 +414,7 @@
<p>
The {@link org.apache.juneau.annotation.URI} annotation can also be used on classes and properties
to identify them as URLs when they're not instances of <code>java.net.URI</code> or <code>java.net.URL</code>
- (not needed if <code><ja>@BeanProperty</ja>(beanUri=<jk>true</jk>)</code> is already specified).
+ (not needed if <code><ja>@Rdf</ja>(beanUri=<jk>true</jk>)</code> is already specified).
</p>
<p>
The following properties would have produced the same output as before. Note that the <ja>@URI</ja> annotation is only needed
@@ -424,7 +424,7 @@
<jk>public class</jk> Person {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> String <jf>uri</jf>;
+ <ja>@Rdf</ja>(beanUri=<jk>true</jk>) <jk>public</jk> String <jf>uri</jf>;
<ja>@URI</ja> <jk>public</jk> String <jf>addressBookUri</jf>;
</p>
@@ -478,7 +478,7 @@
<jk>public class</jk> Person {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar birthDate;
+ <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar birthDate;
...
<jc>// Normal constructor</jc>
@@ -540,7 +540,7 @@
<jk>public class</jk> Address {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
+ <ja>@Rdf</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>personUri</jf>;
<jk>public int</jk> <jf>id</jf>;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java
index 5a37d4a..0801000 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java
@@ -34,12 +34,38 @@ import org.apache.juneau.parser.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the JSON parser</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #JSON_strictMode}</td>
+ * <td>Strict mode</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers.
+ * </ul>
+ * </ul>
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class JsonParserContext extends ParserContext {
/**
- * Set strict mode ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Strict mode.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"JsonParser.strictMode"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* When in strict mode, parser throws exceptions on the following invalid JSON syntax:
* <ul class='spaced-list'>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java
index cf41764..e8d0144 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java
@@ -34,12 +34,51 @@ import org.apache.juneau.serializer.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the JSON serializer</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #JSON_simpleMode}</td>
+ * <td>Simple JSON mode.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #JSON_useWhitespace}</td>
+ * <td>Use whitespace.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #JSON_escapeSolidus}</td>
+ * <td>Prefix solidus <js>'/'</js> characters with escapes.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class JsonSerializerContext extends SerializerContext {
/**
- * Simple JSON mode ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Simple JSON mode.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"JsonSerializer.simpleMode"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, JSON attribute names will only be quoted when necessary.
* Otherwise, they are always quoted.
@@ -47,14 +86,26 @@ public final class JsonSerializerContext extends SerializerContext {
public static final String JSON_simpleMode = "JsonSerializer.simpleMode";
/**
- * Use whitespace in output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Use whitespace.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"JsonSerializer.useWhitespace"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, whitespace is added to the output to improve readability.
*/
public static final String JSON_useWhitespace = "JsonSerializer.useWhitespace";
/**
- * Prefix solidus <js>'/'</js> characters with escapes ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Prefix solidus <js>'/'</js> characters with escapes.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"JsonSerializer.escapeSolidus"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, solidus (e.g. slash) characters should be escaped.
* The JSON specification allows for either format.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/json/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/json/package.html b/juneau-core/src/main/java/org/apache/juneau/json/package.html
index 2012db3..4c16767 100644
--- a/juneau-core/src/main/java/org/apache/juneau/json/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/json/package.html
@@ -324,7 +324,7 @@
<jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>addressBookUri</jf>;
- <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
+ <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
<jc>// Bean constructor (needed by parser)</jc>
@@ -487,7 +487,7 @@
<jk>public</jk> String <jf>name</jf>;
<jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>addressBookUri</jf>;
- <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
+ <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
<jk>public</jk> LinkedList<Address> <jf>addresses</jf> = <jk>new</jk> LinkedList<Address>();
<jc>// Bean constructor (needed by parser)</jc>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java
index 2d7d4dc..8d4556c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java
@@ -34,6 +34,20 @@ import org.apache.juneau.parser.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the MessagePack parser</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers.
+ * </ul>
+ * </ul>
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class MsgPackParserContext extends ParserContext {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java
index fcc9f0d..e354c4f 100644
--- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java
@@ -34,6 +34,19 @@ import org.apache.juneau.serializer.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the MessagePack serializer</h6>
+ * <p>
+ * None.
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ * </ul>
+ * </ul>
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class MsgPackSerializerContext extends SerializerContext {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java b/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java
index 9100cb3..a6920aa 100644
--- a/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java
@@ -15,14 +15,39 @@ package org.apache.juneau.parser;
import org.apache.juneau.*;
/**
- * Parent class for all parser contexts.
+ * Configurable properties common to all parsers.
+ *
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties common to all parsers</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #PARSER_debug}</td>
+ * <td>Debug mode.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #PARSER_trimStrings}</td>
+ * <td>Trim parsed strings.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
*
* @author James Bognar (james.bognar@salesforce.com)
*/
public class ParserContext extends Context {
/**
- * Debug mode ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Debug mode.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Parser.debug"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* Enables the following additional information during parsing:
* <ul class='spaced-list'>
@@ -33,7 +58,13 @@ public class ParserContext extends Context {
public static final String PARSER_debug = "Parser.debug";
/**
- * Trim parsed strings ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Trim parsed strings.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Parser.trimStrings"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to the POJO.
*/
@@ -44,8 +75,6 @@ public class ParserContext extends Context {
/**
* Constructor.
- * <p>
- * Typically only called from {@link ContextFactory#getContext(Class)}.
*
* @param cf The factory that created this context.
*/
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
index ff3b2cf..c4a67d5 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java
@@ -16,14 +16,123 @@ import org.apache.juneau.*;
import org.apache.juneau.internal.*;
/**
- * Parent class for all serializer contexts.
+ * Configurable properties common to all serializers.
+ *
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties common to all serializers</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_maxDepth}</td>
+ * <td>Max serialization depth.</td>
+ * <td><code>Integer</code></td>
+ * <td><code>100</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_initialDepth}</td>
+ * <td>Initial depth.</td>
+ * <td><code>Integer</code></td>
+ * <td><code>0</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_detectRecursions}</td>
+ * <td>Automatically detect POJO recursions.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_ignoreRecursions}</td>
+ * <td>Ignore recursion errors.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_debug}</td>
+ * <td>Debug mode.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_useIndentation}</td>
+ * <td>Use indentation.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_addBeanTypeProperties}</td>
+ * <td>Add <js>"_type"</js> properties when needed.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_quoteChar}</td>
+ * <td>Quote character.</td>
+ * <td><code>Character</code></td>
+ * <td><js>'"'</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_trimNullProperties}</td>
+ * <td>Trim null bean property values.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_trimEmptyCollections}</td>
+ * <td>Trim empty lists and arrays.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_trimEmptyMaps}</td>
+ * <td>Trim empty maps.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_trimStrings}</td>
+ * <td>Trim strings.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_relativeUriBase}</td>
+ * <td>URI base for relative URIs.</td>
+ * <td><code>String</code></td>
+ * <td><js>""</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_absolutePathUriBase}</td>
+ * <td>URI base for relative URIs with absolute paths.</td>
+ * <td><code>String</code></td>
+ * <td><js>""</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_sortCollections}</td>
+ * <td>Sort arrays and collections alphabetically.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #SERIALIZER_sortMaps}</td>
+ * <td>Sort maps alphabetically.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
*
* @author James Bognar (james.bognar@salesforce.com)
*/
public class SerializerContext extends Context {
/**
- * Max serialization depth ({@link Integer}, default=<code>100</code>).
+ * <b>Configuration property:</b> Max serialization depth.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.maxDepth"</js>
+ * <li><b>Data type:</b> <code>Integer</code>
+ * <li><b>Default:</b> <code>100</code>
+ * </ul>
* <p>
* Abort serialization if specified depth is reached in the POJO tree.
* If this depth is exceeded, an exception is thrown.
@@ -32,7 +141,13 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_maxDepth = "Serializer.maxDepth";
/**
- * Initial depth ({@link Integer}, default=<code>0</code>).
+ * <b>Configuration property:</b> Initial depth.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.initialDepth"</js>
+ * <li><b>Data type:</b> <code>Integer</code>
+ * <li><b>Default:</b> <code>0</code>
+ * </ul>
* <p>
* The initial indentation level at the root.
* Useful when constructing document fragments that need to be indented at a certain level.
@@ -40,7 +155,13 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_initialDepth = "Serializer.initialDepth";
/**
- * Automatically detect POJO recursions ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Automatically detect POJO recursions.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.detectRecursions"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* Specifies that recursions should be checked for during serialization.
* <p>
@@ -57,7 +178,13 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_detectRecursions = "Serializer.detectRecursions";
/**
- * Ignore recursion errors ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Ignore recursion errors.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.ignoreRecursions"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* Used in conjunction with {@link #SERIALIZER_detectRecursions}.
* Setting is ignored if <jsf>SERIALIZER_detectRecursions</jsf> is <jk>false</jk>.
@@ -69,7 +196,13 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_ignoreRecursions = "Serializer.ignoreRecursions";
/**
- * Debug mode ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Debug mode.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.debug"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* Enables the following additional information during serialization:
* <ul class='spaced-list'>
@@ -81,14 +214,26 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_debug = "Serializer.debug";
/**
- * Use indentation in output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Use indentation.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.useIndentation"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, newlines and indentation is added to the output to improve readability.
*/
public static final String SERIALIZER_useIndentation = "Serializer.useIndentation";
/**
- * Add <js>"_type"</js> properties to output when needed.({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Add <js>"_type"</js> properties when needed.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.addBeanTypeProperties"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred through reflection.
* This is used to recreate the correct objects during parsing if the object types cannot be inferred.
@@ -97,14 +242,26 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_addBeanTypeProperties = "Serializer.addBeanTypeProperties";
/**
- * Quote character ({@link Character}, default=<js>'"'</js>).
+ * <b>Configuration property:</b> Quote character.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.quoteChar"</js>
+ * <li><b>Data type:</b> <code>Character</code>
+ * <li><b>Default:</b> <js>'"'</js>
+ * </ul>
* <p>
* This is the character used for quoting attributes and values.
*/
public static final String SERIALIZER_quoteChar = "Serializer.quoteChar";
/**
- * Trim null bean property values from output ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Trim null bean property values.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.trimNullProperties"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, null bean values will not be serialized to the output.
* <p>
@@ -116,7 +273,13 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_trimNullProperties = "Serializer.trimNullProperties";
/**
- * Trim empty lists and arrays from output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Trim empty lists and arrays.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.trimEmptyLists"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, empty list values will not be serialized to the output.
* <p>
@@ -126,10 +289,16 @@ public class SerializerContext extends Context {
* <li>Bean properties with empty list values will not be set.
* </ul>
*/
- public static final String SERIALIZER_trimEmptyLists = "Serializer.trimEmptyLists";
+ public static final String SERIALIZER_trimEmptyCollections = "Serializer.trimEmptyLists";
/**
- * Trim empty maps from output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Trim empty maps.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.trimEmptyMaps"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, empty map values will not be serialized to the output.
* <p>
@@ -141,14 +310,26 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_trimEmptyMaps = "Serializer.trimEmptyMaps";
/**
- * Trim strings in output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Trim strings.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.trimStrings"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being serialized.
*/
public static final String SERIALIZER_trimStrings = "Serializer.trimStrings";
/**
- * URI base for relative URIs ({@link String}, default=<js>""</js>).
+ * <b>Configuration property:</b> URI base for relative URIs.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.relativeUriBase"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>""</js>
+ * </ul>
* <p>
* Prepended to relative URIs during serialization (along with the {@link #SERIALIZER_absolutePathUriBase} if specified.
* (i.e. URIs not containing a schema and not starting with <js>'/'</js>).
@@ -181,21 +362,13 @@ public class SerializerContext extends Context {
public static final String SERIALIZER_relativeUriBase = "Serializer.relativeUriBase";
/**
- * Sort arrays and collections alphabetically before serializing ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> URI base for relative URIs with absolute paths.
* <p>
- * Note that this introduces a performance penalty.
- */
- public static final String SERIALIZER_sortCollections = "Serializer.sortCollections";
-
- /**
- * Sort maps alphabetically before serializing ({@link Boolean}, default=<jk>false</jk>).
- * <p>
- * Note that this introduces a performance penalty.
- */
- public static final String SERIALIZER_sortMaps = "Serializer.sortMaps";
-
- /**
- * URI base for relative URIs with absolute paths ({@link String}, default=<js>""</js>).
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.absolutePathUriBase"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>""</js>
+ * </ul>
* <p>
* Prepended to relative absolute-path URIs during serialization.
* (i.e. URIs starting with <js>'/'</js>).
@@ -227,6 +400,32 @@ public class SerializerContext extends Context {
*/
public static final String SERIALIZER_absolutePathUriBase = "Serializer.absolutePathUriBase";
+ /**
+ * <b>Configuration property:</b> Sort arrays and collections alphabetically.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.sortCollections"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
+ * <p>
+ * Note that this introduces a performance penalty.
+ */
+ public static final String SERIALIZER_sortCollections = "Serializer.sortCollections";
+
+ /**
+ * <b>Configuration property:</b> Sort maps alphabetically.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Serializer.sortMaps"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
+ * <p>
+ * Note that this introduces a performance penalty.
+ */
+ public static final String SERIALIZER_sortMaps = "Serializer.sortMaps";
+
final int maxDepth, initialDepth;
final boolean
@@ -236,7 +435,7 @@ public class SerializerContext extends Context {
useIndentation,
addBeanTypeProperties,
trimNulls,
- trimEmptyLists,
+ trimEmptyCollections,
trimEmptyMaps,
trimStrings,
sortCollections,
@@ -246,8 +445,6 @@ public class SerializerContext extends Context {
/**
* Constructor.
- * <p>
- * Typically only called from {@link ContextFactory#getContext(Class)}.
*
* @param cf The factory that created this context.
*/
@@ -261,7 +458,7 @@ public class SerializerContext extends Context {
useIndentation = cf.getProperty(SERIALIZER_useIndentation, boolean.class, false);
addBeanTypeProperties = cf.getProperty(SERIALIZER_addBeanTypeProperties, boolean.class, false);
trimNulls = cf.getProperty(SERIALIZER_trimNullProperties, boolean.class, true);
- trimEmptyLists = cf.getProperty(SERIALIZER_trimEmptyLists, boolean.class, false);
+ trimEmptyCollections = cf.getProperty(SERIALIZER_trimEmptyCollections, boolean.class, false);
trimEmptyMaps = cf.getProperty(SERIALIZER_trimEmptyMaps, boolean.class, false);
trimStrings = cf.getProperty(SERIALIZER_trimStrings, boolean.class, false);
sortCollections = cf.getProperty(SERIALIZER_sortCollections, boolean.class, false);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
index 49aefe7..7821542 100644
--- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
+++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java
@@ -51,7 +51,7 @@ public class SerializerSession extends Session {
useIndentation,
addBeanTypeProperties,
trimNulls,
- trimEmptyLists,
+ trimEmptyCollections,
trimEmptyMaps,
trimStrings,
sortCollections,
@@ -115,7 +115,7 @@ public class SerializerSession extends Session {
useIndentation = ctx.useIndentation;
addBeanTypeProperties = ctx.addBeanTypeProperties;
trimNulls = ctx.trimNulls;
- trimEmptyLists = ctx.trimEmptyLists;
+ trimEmptyCollections = ctx.trimEmptyCollections;
trimEmptyMaps = ctx.trimEmptyMaps;
trimStrings = ctx.trimStrings;
quoteChar = ctx.quoteChar;
@@ -133,7 +133,7 @@ public class SerializerSession extends Session {
useIndentation = op.getBoolean(SERIALIZER_useIndentation, ctx.useIndentation);
addBeanTypeProperties = op.getBoolean(SERIALIZER_addBeanTypeProperties, ctx.addBeanTypeProperties);
trimNulls = op.getBoolean(SERIALIZER_trimNullProperties, ctx.trimNulls);
- trimEmptyLists = op.getBoolean(SERIALIZER_trimEmptyLists, ctx.trimEmptyLists);
+ trimEmptyCollections = op.getBoolean(SERIALIZER_trimEmptyCollections, ctx.trimEmptyCollections);
trimEmptyMaps = op.getBoolean(SERIALIZER_trimEmptyMaps, ctx.trimEmptyMaps);
trimStrings = op.getBoolean(SERIALIZER_trimStrings, ctx.trimStrings);
quoteChar = op.getString(SERIALIZER_quoteChar, ""+ctx.quoteChar).charAt(0);
@@ -347,12 +347,12 @@ public class SerializerSession extends Session {
}
/**
- * Returns the {@link SerializerContext#SERIALIZER_trimEmptyLists} setting value for this session.
+ * Returns the {@link SerializerContext#SERIALIZER_trimEmptyCollections} setting value for this session.
*
- * @return The {@link SerializerContext#SERIALIZER_trimEmptyLists} setting value for this session.
+ * @return The {@link SerializerContext#SERIALIZER_trimEmptyCollections} setting value for this session.
*/
- public final boolean isTrimEmptyLists() {
- return trimEmptyLists;
+ public final boolean isTrimEmptyCollections() {
+ return trimEmptyCollections;
}
/**
@@ -563,7 +563,7 @@ public class SerializerSession extends Session {
if (cm == null)
cm = getBeanContext().object();
- if (trimEmptyLists) {
+ if (trimEmptyCollections) {
if (cm.isArray() || (cm.isObject() && value.getClass().isArray())) {
if (((Object[])value).length == 0)
return true;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java
index ca57a29..bebfcd5 100644
--- a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java
@@ -12,17 +12,41 @@
// ***************************************************************************************************************************
package org.apache.juneau.soap;
+
/**
* Properties associated with the {@link SoapXmlSerializer} class.
*
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the SOAP/XML serializer</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #SOAPXML_SOAPAction}</td>
+ * <td>The <code>SOAPAction</code> HTTP header value to set on responses.</td>
+ * <td><code>String</code></td>
+ * <td><js>"http://www.w3.org/2003/05/soap-envelope"</js></td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ * </ul>
+ * </ul>
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class SoapXmlSerializerContext {
/**
- * The <code>SOAPAction</code> HTTP header value to set on responses.
+ * <b>Configuration property:</b> The <code>SOAPAction</code> HTTP header value to set on responses.
* <p>
- * Default is <js>"http://www.w3.org/2003/05/soap-envelope"</js>.
+ * <ul>
+ * <li><b>Name:</b> <js>"SoapXmlSerializer.SOAPAction"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"http://www.w3.org/2003/05/soap-envelope"</js>
+ * </ul>
*/
public static final String SOAPXML_SOAPAction = "SoapXmlSerializer.SOAPAction";
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/svl/vars/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/vars/package.html b/juneau-core/src/main/java/org/apache/juneau/svl/vars/package.html
new file mode 100644
index 0000000..5344cc6
--- /dev/null
+++ b/juneau-core/src/main/java/org/apache/juneau/svl/vars/package.html
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML>
+<!--
+/***************************************************************************************************************************
+ * 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.
+ *
+ ***************************************************************************************************************************/
+ -->
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+ /* For viewing in Page Designer */
+ @IMPORT url("../../../../../../../javadoc.css");
+
+ /* For viewing in REST interface */
+ @IMPORT url("../htdocs/javadoc.css");
+ body {
+ margin: 20px;
+ }
+ </style>
+ <script>
+ /* Replace all @code and @link tags. */
+ window.onload = function() {
+ document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>');
+ document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>');
+ }
+ </script>
+</head>
+<body>
+<p>Simple Variable Language - Predefined variables</p>
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java
index f64b800..2446341 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java
@@ -34,12 +34,45 @@ import org.apache.juneau.parser.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the URL-Encoding and UON parsers</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #UON_decodeChars}</td>
+ * <td>Decode <js>"%xx"</js> sequences</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk> for {@link UonParser}<br><jk>true</jk> for {@link UrlEncodingParser}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #UON_whitespaceAware}</td>
+ * <td>Whitespace aware</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers.
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public class UonParserContext extends ParserContext {
/**
- * Decode <js>"%xx"</js> sequences. ({@link Boolean}, default=<jk>false</jk> for {@link UonParser}, <jk>true</jk> for {@link UrlEncodingParser}).
+ * <b>Configuration property:</b> Decode <js>"%xx"</js> sequences.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"UonParser.decodeChars"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk> for {@link UonParser}, <jk>true</jk> for {@link UrlEncodingParser}
+ * </ul>
* <p>
* Specify <jk>true</jk> if URI encoded characters should be decoded, <jk>false</jk>
* if they've already been decoded before being passed to this parser.
@@ -47,7 +80,15 @@ public class UonParserContext extends ParserContext {
public static final String UON_decodeChars = "UonParser.decodeChars";
/**
- * Expect input to contain readable whitespace characters from using the {@link UonSerializerContext#UON_useWhitespace} setting ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Whitespace aware.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"UonParser.whitespaceAware"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
+ * <p>
+ * Expect input to contain readable whitespace characters from using the {@link UonSerializerContext#UON_useWhitespace} setting.
*/
public static final String UON_whitespaceAware = "UonParser.whitespaceAware";
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java
index cfcb1c6..94f4700 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java
@@ -34,12 +34,51 @@ import org.apache.juneau.serializer.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the URL-Encoding and UON serializers</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #UON_simpleMode}</td>
+ * <td>Use simplified output.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #UON_useWhitespace}</td>
+ * <td>Use whitespace.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #UON_encodeChars}</td>
+ * <td>Encode non-valid URI characters.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk> for {@link UonSerializer}<br><jk>true</jk> for {@link UrlEncodingSerializer}</td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public class UonSerializerContext extends SerializerContext {
/**
- * Use simplified output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Use simplified output.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"UonSerializer.simpleMode"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, type flags will not be prepended to values in most cases.
* <p>
@@ -92,14 +131,28 @@ public class UonSerializerContext extends SerializerContext {
public static final String UON_simpleMode = "UonSerializer.simpleMode";
/**
- * Use whitespace in output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Use whitespace.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"UonSerializer.useWhitespace"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, whitespace is added to the output to improve readability.
*/
public static final String UON_useWhitespace = "UonSerializer.useWhitespace";
/**
- * Encode non-valid URI characters to <js>"%xx"</js> constructs. ({@link Boolean}, default=<jk>false</jk> for {@link UonSerializer}, <jk>true</jk> for {@link UrlEncodingSerializer}).
+ * <b>Configuration property:</b> Encode non-valid URI characters.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"UonSerializer.encodeChars"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk> for {@link UonSerializer}, <jk>true</jk> for {@link UrlEncodingSerializer}
+ * </ul>
+ * <p>
+ * Encode non-valid URI characters with <js>"%xx"</js> constructs.
* <p>
* If <jk>true</jk>, non-valid URI characters will be converted to <js>"%xx"</js> sequences.
* Set to <jk>false</jk> if parameter value is being passed to some other code that will already
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html b/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html
index 269c7c1..b7cc2ec 100644
--- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html
@@ -368,7 +368,7 @@
<jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>addressBookUri</jf>;
- <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
+ <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
<jc>// Bean constructor (needed by parser)</jc>
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java
index 22bf648..017cb70 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java
@@ -37,26 +37,113 @@ import org.apache.juneau.parser.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the XML parser</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #XML_xsiNs}</td>
+ * <td>XMLSchema-instance namespace URI.</td>
+ * <td><code>String<code></td>
+ * <td><js>"http://www.w3.org/2001/XMLSchema-instance"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_trimWhitespace}</td>
+ * <td>Trim whitespace from text elements.</td>
+ * <td><code>Boolean<code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_validating}</td>
+ * <td>Enable validation.</td>
+ * <td><code>Boolean<code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_coalescing}</td>
+ * <td>Enable text element coalescing.</td>
+ * <td><code>Boolean<code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_replaceEntityReferences}</td>
+ * <td>Replace entity references.</td>
+ * <td><code>Boolean<code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_reporter}</td>
+ * <td>XML reporter.</td>
+ * <td>{@link XMLReporter}</td>
+ * <td><jk>null</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_resolver}</td>
+ * <td>XML resolver.</td>
+ * <td>{@link XMLResolver}</td>
+ * <td><jk>null</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_eventAllocator}</td>
+ * <td>XML event allocator.</td>
+ * <td>{@link XMLEventAllocator}</td>
+ * <td><jk>null</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_preserveRootElement}</td>
+ * <td>Preserve root element during generalized parsing.</td>
+ * <td><code>Boolean<code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers.
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class XmlParserContext extends ParserContext {
/**
- * XMLSchema-instance namespace URI ({@link String}, default=<js>"http://www.w3.org/2001/XMLSchema-instance"</js>).
+ * <b>Configuration property:</b> XMLSchema-instance namespace URI.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.xsiNs"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"http://www.w3.org/2001/XMLSchema-instance"</js>
+ * </ul>
* <p>
* The XMLSchema namespace.
*/
public static final String XML_xsiNs = "XmlParser.xsiNs";
/**
- * Trim whitespace from text elements ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Trim whitespace from text elements.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.trimWhitespace"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, whitespace in text elements will be automatically trimmed.
*/
public static final String XML_trimWhitespace = "XmlParser.trimWhitespace";
/**
- * Set validating mode ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Enable validation.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.validating"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, XML document will be validated.
* See {@link XMLInputFactory#IS_VALIDATING} for more info.
@@ -64,7 +151,13 @@ public final class XmlParserContext extends ParserContext {
public static final String XML_validating = "XmlParser.validating";
/**
- * Set coalescing mode ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Enable text element coalescing.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.coalescing"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, XML text elements will be coalesced.
* See {@link XMLInputFactory#IS_COALESCING} for more info.
@@ -72,7 +165,13 @@ public final class XmlParserContext extends ParserContext {
public static final String XML_coalescing = "XmlParser.coalescing";
/**
- * Replace entity references ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Replace entity references.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.replaceEntityReferences"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, entity references will be replace during parsing.
* See {@link XMLInputFactory#IS_REPLACING_ENTITY_REFERENCES} for more info.
@@ -80,7 +179,13 @@ public final class XmlParserContext extends ParserContext {
public static final String XML_replaceEntityReferences = "XmlParser.replaceEntityReferences";
/**
- * XML reporter ({@link XMLReporter}, default=<jk>null</jk>).
+ * <b>Configuration property:</b> XML reporter.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.reporter"</js>
+ * <li><b>Data type:</b> {@link XMLReporter}
+ * <li><b>Default:</b> <jk>null</jk>
+ * </ul>
* <p>
* Associates an {@link XMLReporter} with this parser.
* <p>
@@ -89,21 +194,39 @@ public final class XmlParserContext extends ParserContext {
public static final String XML_reporter = "XmlParser.reporter";
/**
- * XML resolver ({@link XMLResolver}, default=<jk>null</jk>).
+ * <b>Configuration property:</b> XML resolver.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.resolver"</js>
+ * <li><b>Data type:</b> {@link XMLResolver}
+ * <li><b>Default:</b> <jk>null</jk>
+ * </ul>
* <p>
* Associates an {@link XMLResolver} with this parser.
*/
public static final String XML_resolver = "XmlParser.resolver";
/**
- * XML event allocator. ({@link XMLEventAllocator}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> XML event allocator.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.eventAllocator"</js>
+ * <li><b>Data type:</b> {@link XMLEventAllocator}
+ * <li><b>Default:</b> <jk>null</jk>
+ * </ul>
* <p>
* Associates an {@link XMLEventAllocator} with this parser.
*/
public static final String XML_eventAllocator = "XmlParser.eventAllocator";
/**
- * Preserve root element during generalized parsing ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Preserve root element during generalized parsing.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlParser.preserveRootElement"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, when parsing into a generic {@link ObjectMap}, the map will
* contain a single entry whose key is the root element name.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
index b3e6b83..ff4f40b 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java
@@ -61,24 +61,44 @@ import org.apache.juneau.xml.annotation.*;
* <js>'fico score'</js>: <js>' > 640'</js>
* }
* <p>
- * ...maps to the following XML...
+ * ...maps to the following XML using the default serializer...
* <p class='bcode'>
* <xt><object></xt>
- * <xt><name</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt>John Smith<xt></name></xt>
- * <xt><address</xt> <xa>type</xa>=<xs>'object'</xs><xt>></xt>
- * <xt><streetAddress</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt>21 2nd Street<xt></streetAddress></xt>
- * <xt><city</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt>New York<xt></city></xt>
- * <xt><state</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt>NY<xt></state></xt>
- * <xt><postalCode</xt> <xa>type</xa>=<xs>'number'</xs><xt>></xt>10021<xt></postalCode></xt>
+ * <xt><name></xt>John Smith<xt></name></xt>
+ * <xt><address></xt>
+ * <xt><streetAddress></xt>21 2nd Street<xt></streetAddress></xt>
+ * <xt><city></xt>New York<xt></city></xt>
+ * <xt><state></xt>NY<xt></state></xt>
+ * <xt><postalCode></xt>10021<xt></postalCode></xt>
* <xt></address></xt>
- * <xt><phoneNumbers</xt> <xa>type</xa>=<xs>'array'</xs><xt>></xt>
+ * <xt><phoneNumbers></xt>
* <xt><string></xt>212 555-1111<xt></string></xt>
* <xt><string></xt>212 555-2222<xt></string></xt>
* <xt></phoneNumbers></xt>
- * <xt><additionalInfo</xt> <xa>type</xa>=<xs>'null'</xs><xt>></additionalInfo></xt>
- * <xt><remote</xt> <xa>type</xa>=<xs>'boolean'</xs><xt>></xt>false<xt></remote></xt>
- * <xt><height</xt> <xa>type</xa>=<xs>'number'</xs><xt>></xt>62.4<xt></height></xt>
- * <xt><fico_x0020_score</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt> &gt; 640<xt></fico_x0020_score></xt>
+ * <xt><additionalInfo</xt> <xa>_type</xa>=<xs>'null'</xs><xt>></additionalInfo></xt>
+ * <xt><remote></xt>false<xt></remote></xt>
+ * <xt><height></xt>62.4<xt></height></xt>
+ * <xt><fico_x0020_score></xt> &gt; 640<xt></fico_x0020_score></xt>
+ * <xt></object></xt>
+ * <p>
+ * An additional "add-json-properties" mode is also provided to prevent loss of JSON data types...
+ * <p class='bcode'>
+ * <xt><object></xt>
+ * <xt><name</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt>John Smith<xt></name></xt>
+ * <xt><address</xt> <xa>_type</xa>=<xs>'object'</xs><xt>></xt>
+ * <xt><streetAddress</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt>21 2nd Street<xt></streetAddress></xt>
+ * <xt><city</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt>New York<xt></city></xt>
+ * <xt><state</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt>NY<xt></state></xt>
+ * <xt><postalCode</xt> <xa>_type</xa>=<xs>'number'</xs><xt>></xt>10021<xt></postalCode></xt>
+ * <xt></address></xt>
+ * <xt><phoneNumbers</xt> <xa>_type</xa>=<xs>'array'</xs><xt>></xt>
+ * <xt><string></xt>212 555-1111<xt></string></xt>
+ * <xt><string></xt>212 555-2222<xt></string></xt>
+ * <xt></phoneNumbers></xt>
+ * <xt><additionalInfo</xt> <xa>_type</xa>=<xs>'null'</xs><xt>></additionalInfo></xt>
+ * <xt><remote</xt> <xa>_type</xa>=<xs>'boolean'</xs><xt>></xt>false<xt></remote></xt>
+ * <xt><height</xt> <xa>_type</xa>=<xs>'number'</xs><xt>></xt>62.4<xt></height></xt>
+ * <xt><fico_x0020_score</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt> &gt; 640<xt></fico_x0020_score></xt>
* <xt></object></xt>
* <p>
* This serializer provides several serialization options. Typically, one of the predefined <jsf>DEFAULT</jsf> serializers will be sufficient.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java
index c1fba2e..ad2001c 100644
--- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java
@@ -34,19 +34,100 @@ import org.apache.juneau.serializer.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the XML serializer</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #XML_addJsonTypeAttrs}</td>
+ * <td>Add JSON type attributes to output.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_addJsonStringTypeAttrs}</td>
+ * <td>Add JSON type attributes for strings to output.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_enableNamespaces}</td>
+ * <td>Enable support for XML namespaces.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_autoDetectNamespaces}</td>
+ * <td>Auto-detect namespace usage.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_addNamespaceUrisToRoot}</td>
+ * <td>Add namespace URLs to the root element.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_defaultNamespaceUri}</td>
+ * <td>Default namespace URI.</td>
+ * <td><code>String</code></td>
+ * <td><jk>null</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_xsNamespace}</td>
+ * <td>XMLSchema namespace.</td>
+ * <td>{@link Namespace}</td>
+ * <td><code>{name:<js>'xs'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema'</js>}</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_xsiNamespace}</td>
+ * <td>XMLSchema-Instance namespace.</td>
+ * <td>{@link Namespace}</td>
+ * <td><code>{name:<js>'xsi'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema-instance'</js>}</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #XML_namespaces}</td>
+ * <td>Default namespaces.</td>
+ * <td><code>Set<{@link Namespace}></code></td>
+ * <td>empty set</td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ * </ul>
+ * </ul>
+*
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public class XmlSerializerContext extends SerializerContext {
/**
- * Add JSON type attributes to output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Add JSON type attributes to output.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.addJsonTypeAttrs"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <js>true</jk>, {@code type} attributes will be added to elements in the XML for number/boolean/null nodes.
*/
public static final String XML_addJsonTypeAttrs = "XmlSerializer.addJsonTypeAttrs";
/**
- * Add JSON type attributes for strings to output ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Add JSON type attributes for strings to output.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.addJsonStringTypeAttrs"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, {@code type} attributes will be added to elements in the XML for string nodes.
* <p>
@@ -58,14 +139,26 @@ public class XmlSerializerContext extends SerializerContext {
public static final String XML_addJsonStringTypeAttrs = "XmlSerializer.addJsonStringTypeAttrs";
/**
- * Enable support for XML namespaces ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Enable support for XML namespaces.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.enableNamespaces"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If not enabled, XML output will not contain any namespaces regardless of any other settings.
*/
public static final String XML_enableNamespaces = "XmlSerializer.enableNamespaces";
/**
- * Auto-detect namespace usage ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Auto-detect namespace usage.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.autoDetectNamespaces"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* Detect namespace usage before serialization.
* <p>
@@ -87,7 +180,13 @@ public class XmlSerializerContext extends SerializerContext {
public static final String XML_autoDetectNamespaces = "XmlSerializer.autoDetectNamespaces";
/**
- * Add namespace URLs to the root element ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Add namespace URLs to the root element.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.addNamespaceUrisToRoot"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* Use this setting to add {@code xmlns:x} attributes to the root
* element for the default and all mapped namespaces.
@@ -97,14 +196,26 @@ public class XmlSerializerContext extends SerializerContext {
public static final String XML_addNamespaceUrisToRoot = "XmlSerializer.addNamespaceUrisToRoot";
/**
- * Default namespace URI ({@link String}, default=<jk>null</jk>).
+ * <b>Configuration property:</b> Default namespace URI.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.defaultNamespaceUri"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * </ul>
* <p>
* Specifies the default namespace URI for this document.
*/
public static final String XML_defaultNamespaceUri = "XmlSerializer.defaultNamespaceUri";
/**
- * XMLSchema namespace ({@link Namespace}, default=<code>{name:<js>'xs'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema'</js>}</code>).
+ * <b>Configuration property:</b> XMLSchema namespace.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.xsNamespace"</js>
+ * <li><b>Data type:</b> {@link Namespace}
+ * <li><b>Default:</b> <code>{name:<js>'xs'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema'</js>}</code>
+ * </ul>
* <p>
* Specifies the namespace for the <code>XMLSchema</code> namespace, used by the schema generated
* by the {@link XmlSchemaSerializer} class.
@@ -112,14 +223,26 @@ public class XmlSerializerContext extends SerializerContext {
public static final String XML_xsNamespace = "XmlSerializer.xsNamespace";
/**
- * XMLSchema-Instance namespace ({@link Namespace}, default=<code>{name:<js>'xsi'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema-instance'</js>}</code>).
+ * <b>Configuration property:</b> XMLSchema-Instance namespace.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.xsiNamespace"</js>
+ * <li><b>Data type:</b> {@link Namespace}
+ * <li><b>Default:</b> <code>{name:<js>'xsi'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema-instance'</js>}</code>
+ * </ul>
* <p>
* Specifies the namespace of the <code>XMLSchema-instance</code> namespace used for<code>nil=<jk>true</jk></code> attributes.
*/
public static final String XML_xsiNamespace = "XmlSerializer.xsiNamespace";
/**
- * Default namespaces (<code>Set<Namespace></code>, default=empty set).
+ * <b>Configuration property:</b> Default namespaces.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"XmlSerializer.namespaces"</js>
+ * <li><b>Data type:</b> <code>Set<{@link Namespace}></code>
+ * <li><b>Default:</b> empty set
+ * </ul>
* <p>
* The default list of namespaces associated with this serializer.
*/
[06/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/UrlContentTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/UrlContentTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/UrlContentTest.java
deleted file mode 100755
index c1d961d..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/UrlContentTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import static org.junit.Assert.*;
-
-import org.apache.juneau.client.*;
-import org.junit.*;
-
-public class UrlContentTest {
-
- private static String URL = "/testUrlContent";
- private static RestClient client;
-
- @BeforeClass
- public static void beforeClass() {
- client = new TestRestClient().setHeader("Accept", "text/plain");
- }
-
- @AfterClass
- public static void afterClass() {
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test URL &Content parameter containing a String
- //====================================================================================================
- @Test
- public void testString() throws Exception {
- String r;
- r = client.doGet(URL + "/testString?content=\'xxx\'&Content-Type=text/json").getResponseAsString();
- assertEquals("class=java.lang.String, value=xxx", r);
- }
-
- //====================================================================================================
- // Test URL &Content parameter containing an Enum
- //====================================================================================================
- @Test
- public void testEnum() throws Exception {
- String r;
- r = client.doGet(URL + "/testEnum?content='X1'&Content-Type=text/json").getResponseAsString();
- assertEquals("class=org.apache.juneau.server.UrlContentResource$TestEnum, value=X1", r);
- }
-
- //====================================================================================================
- // Test URL &Content parameter containing a Bean
- //====================================================================================================
- @Test
- public void testBean() throws Exception {
- String r;
- r = client.doGet(URL + "/testBean?content=%7Bf1:1,f2:'foobar'%7D&Content-Type=text/json").getResponseAsString();
- assertEquals("class=org.apache.juneau.server.UrlContentResource$TestBean, value={f1:1,f2:'foobar'}", r);
- }
-
- //====================================================================================================
- // Test URL &Content parameter containing an int
- //====================================================================================================
- @Test
- public void testInt() throws Exception {
- String r;
- r = client.doGet(URL + "/testInt?content=123&Content-Type=text/json").getResponseAsString();
- assertEquals("class=java.lang.Integer, value=123", r);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/UrlPathPatternTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/UrlPathPatternTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/UrlPathPatternTest.java
deleted file mode 100755
index e93139c..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/UrlPathPatternTest.java
+++ /dev/null
@@ -1,39 +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 java.util.*;
-
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-public class UrlPathPatternTest {
- @Test
- public void testComparison() throws Exception {
- List<UrlPathPattern> l = new LinkedList<UrlPathPattern>();
-
- l.add(new UrlPathPattern("/foo"));
- l.add(new UrlPathPattern("/foo/*"));
- l.add(new UrlPathPattern("/foo/bar"));
- l.add(new UrlPathPattern("/foo/bar/*"));
- l.add(new UrlPathPattern("/foo/{id}"));
- l.add(new UrlPathPattern("/foo/{id}/*"));
- l.add(new UrlPathPattern("/foo/{id}/bar"));
- l.add(new UrlPathPattern("/foo/{id}/bar/*"));
-
- Collections.sort(l);
- assertEquals("['/foo/bar','/foo/bar/*','/foo/{id}/bar','/foo/{id}/bar/*','/foo/{id}','/foo/{id}/*','/foo','/foo/*']", JsonSerializer.DEFAULT_LAX.serialize(l));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/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
new file mode 100755
index 0000000..3464661
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/AcceptCharsetTest.java
@@ -0,0 +1,123 @@
+// ***************************************************************************************************************************
+// * 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/d45e1351/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
new file mode 100755
index 0000000..671bfed
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/BeanContextPropertiesTest.java
@@ -0,0 +1,37 @@
+// ***************************************************************************************************************************
+// * 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/d45e1351/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
new file mode 100755
index 0000000..c370f69
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/CallbackStringsTest.java
@@ -0,0 +1,50 @@
+// ***************************************************************************************************************************
+// * 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 &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();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/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
new file mode 100755
index 0000000..bf50a13
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/CharsetEncodingsTest.java
@@ -0,0 +1,96 @@
+// ***************************************************************************************************************************
+// * 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/d45e1351/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
new file mode 100644
index 0000000..aab4852
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ClientVersionTest.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 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/d45e1351/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
new file mode 100755
index 0000000..98f644d
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ConfigTest.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 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}',mainClass:'$MF{Main-Class}',importPackage:'$MF{Import-Package}'}", 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("'org.apache.juneau.microservice.RestMicroservice'", c.doGet(URL + "/Test%2FmainClass/" + 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/d45e1351/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
new file mode 100755
index 0000000..7e6c26c
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/Constants.java
@@ -0,0 +1,53 @@
+// ***************************************************************************************************************************
+// * 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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/ContentTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/ContentTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ContentTest.java
new file mode 100755
index 0000000..95c1da8
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ContentTest.java
@@ -0,0 +1,706 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import static org.junit.Assert.*;
+
+import java.io.*;
+import java.net.*;
+
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.urlencoding.*;
+import org.junit.*;
+
+public class ContentTest {
+
+ private static String URL = "/testContent";
+
+ //====================================================================================================
+ // Basic tests using &Content parameter
+ //====================================================================================================
+ @Test
+ public void testUsingContentParam() throws Exception {
+ RestClient c = new TestRestClient().setAccept("text/json+simple");
+ String r;
+
+ // @RestMethod(name="POST", path="/boolean")
+ // public boolean testBool(@Content boolean b) {
+ // return b;
+ // }
+ r = c.doPost(URL + "/boolean?content=true", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/boolean?content=(true)", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/boolean?content=$b(true)", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/boolean?content=false", null).getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/boolean?content=(false)", null).getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/boolean?content=$b(false)", null).getResponseAsString();
+ assertEquals("false", r);
+ try {
+ r = c.doPost(URL + "/boolean?content=%00&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/boolean?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+
+ // @RestMethod(name="POST", path="/Boolean")
+ // public Boolean testBoolean(@Content Boolean b) {
+ // return b;
+ // }
+ r = c.doPost(URL + "/Boolean?content=true", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/Boolean?content=(true)", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/Boolean?content=$b(true)", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/Boolean?content=false", null).getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/Boolean?content=(false)", null).getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/Boolean?content=$b(false)", null).getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/Boolean?content=%00", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Boolean?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/int")
+ // public int testInt(@Content int i) {
+ // return i;
+ // }
+ r = c.doPost(URL + "/int?content=-123", null).getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/int?content=(-123)", null).getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/int?content=$n(-123)", null).getResponseAsString();
+ assertEquals("-123", r);
+ try {
+ r = c.doPost(URL + "/int?content=%00&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/int?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Integer")
+ // public Integer testInteger(@Content Integer i) {
+ // return i;
+ // }
+ r = c.doPost(URL + "/Integer?content=-123", null).getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/Integer?content=(-123)", null).getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/Integer?content=$n(-123)", null).getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/Integer?content=%00", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Integer?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/float")
+ // public float testFloat(@Content float f) {
+ // return f;
+ // }
+ r = c.doPost(URL + "/float?content=-1.23", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/float?content=(-1.23)", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/float?content=$n(-1.23)", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ try {
+ r = c.doPost(URL + "/float?content=%00&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/float?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Float")
+ // public Float testFloat2(@Content Float f) {
+ // return f;
+ // }
+ r = c.doPost(URL + "/Float?content=-1.23", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/Float?content=(-1.23)", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/Float?content=$n(-1.23)", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/Float?content=%00", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Float?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Map")
+ // public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
+ // return m;
+ // }
+ r = c.doPost(URL + "/Map?content=(a=b,c=d)", null).getResponseAsString();
+ assertEquals("{a:'b',c:'d'}", r);
+ r = c.doPost(URL + "/Map?content=%00", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Map?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/B")
+ // public DTO2s.B testPojo1(@Content DTO2s.B b) {
+ // return b;
+ // }
+ DTOs.B b = DTOs.B.create();
+ r = c.doPost(URL + "/B?content=" + UonSerializer.DEFAULT.serialize(b), null).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+ r = c.doPost(URL + "/B?content=" + UonSerializer.DEFAULT_SIMPLE.serialize(b), null).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+
+ // @RestMethod(name="POST", path="/C")
+ // public DTO2s.C testPojo2(@Content DTO2s.C c) {
+ // return c;
+ // }
+ DTOs.C x = DTOs.C.create();
+ r = c.doPost(URL + "/C?content=" + UonSerializer.DEFAULT.serialize(x), null).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+ r = c.doPost(URL + "/C?content=" + UonSerializer.DEFAULT_SIMPLE.serialize(x), null).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+
+ c.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Basic tests using &Content parameter with &Accept=text/json
+ //====================================================================================================
+ @Test
+ public void testUsingContentParamJsonHeader() throws Exception {
+ RestClient c = new TestRestClient().setAccept("text/json+simple").setHeader("Content-Type", "text/json");
+ String r;
+
+ // @RestMethod(name="POST", path="/boolean")
+ // public boolean testBool(@Content boolean b) {
+ // return b;
+ // }
+ r = c.doPost(URL + "/boolean?content=true", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/boolean?content=false", null).getResponseAsString();
+ assertEquals("false", r);
+ try {
+ r = c.doPost(URL + "/boolean?content=null&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/boolean?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+
+ // @RestMethod(name="POST", path="/Boolean")
+ // public Boolean testBoolean(@Content Boolean b) {
+ // return b;
+ // }
+ r = c.doPost(URL + "/Boolean?content=true", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/Boolean?content=false", null).getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/Boolean?content=null", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Boolean?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/int")
+ // public int testInt(@Content int i) {
+ // return i;
+ // }
+ r = c.doPost(URL + "/int?content=-123", null).getResponseAsString();
+ assertEquals("-123", r);
+ try {
+ r = c.doPost(URL + "/int?content=null&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/int?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Integer")
+ // public Integer testInteger(@Content Integer i) {
+ // return i;
+ // }
+ r = c.doPost(URL + "/Integer?content=-123", null).getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/Integer?content=null", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Integer?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/float")
+ // public float testFloat(@Content float f) {
+ // return f;
+ // }
+ r = c.doPost(URL + "/float?content=-1.23", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ try {
+ r = c.doPost(URL + "/float?content=null&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/float?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Float")
+ // public Float testFloat2(@Content Float f) {
+ // return f;
+ // }
+ r = c.doPost(URL + "/Float?content=-1.23", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/Float?content=null", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Float?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Map")
+ // public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
+ // return m;
+ // }
+ r = c.doPost(URL + "/Map?content=" + encode("{a:'b',c:'d'}"), null).getResponseAsString();
+ assertEquals("{a:'b',c:'d'}", r);
+ r = c.doPost(URL + "/Map?content=null", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Map?content=bad&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/B")
+ // public DTO2s.B testPojo1(@Content DTO2s.B b) {
+ // return b;
+ // }
+ DTOs.B b = DTOs.B.create();
+ r = c.doPost(URL + "/B?content=" + encode(JsonSerializer.DEFAULT_LAX.serialize(b)), null).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+
+ // @RestMethod(name="POST", path="/C")
+ // public DTO2s.C testPojo2(@Content DTO2s.C c) {
+ // return c;
+ // }
+ DTOs.C x = DTOs.C.create();
+ r = c.doPost(URL + "/C?content=" + encode(JsonSerializer.DEFAULT_LAX.serialize(x)), null).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+
+ c.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Basic tests using &Content parameter with &Accept=text/json
+ //====================================================================================================
+ @Test
+ public void testUsingContentParamJsonParam() throws Exception {
+ RestClient c = new TestRestClient().setAccept("text/json+simple");
+ String r;
+
+ // @RestMethod(name="POST", path="/boolean")
+ // public boolean testBool(@Content boolean b) {
+ // return b;
+ // }
+ r = c.doPost(URL + "/boolean?content=true&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/boolean?content=false&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("false", r);
+ try {
+ r = c.doPost(URL + "/boolean?content=null&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/boolean?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+
+ // @RestMethod(name="POST", path="/Boolean")
+ // public Boolean testBoolean(@Content Boolean b) {
+ // return b;
+ // }
+ r = c.doPost(URL + "/Boolean?content=true&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/Boolean?content=false&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/Boolean?content=null&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Boolean?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/int")
+ // public int testInt(@Content int i) {
+ // return i;
+ // }
+ r = c.doPost(URL + "/int?content=-123&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("-123", r);
+ try {
+ r = c.doPost(URL + "/int?content=null&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/int?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Integer")
+ // public Integer testInteger(@Content Integer i) {
+ // return i;
+ // }
+ r = c.doPost(URL + "/Integer?content=-123&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/Integer?content=null&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Integer?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/float")
+ // public float testFloat(@Content float f) {
+ // return f;
+ // }
+ r = c.doPost(URL + "/float?content=-1.23&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ try {
+ r = c.doPost(URL + "/float?content=null&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/float?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Float")
+ // public Float testFloat2(@Content Float f) {
+ // return f;
+ // }
+ r = c.doPost(URL + "/Float?content=-1.23&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/Float?content=null&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Float?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Map")
+ // public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
+ // return m;
+ // }
+ r = c.doPost(URL + "/Map?content=" + encode("{a:'b',c:'d'}") + "&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("{a:'b',c:'d'}", r);
+ r = c.doPost(URL + "/Map?content=null&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Map?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/B")
+ // public DTO2s.B testPojo1(@Content DTO2s.B b) {
+ // return b;
+ // }
+ DTOs.B b = DTOs.B.create();
+ r = c.doPost(URL + "/B?content=" + encode(JsonSerializer.DEFAULT_LAX.serialize(b)) + "&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+
+ // @RestMethod(name="POST", path="/C")
+ // public DTO2s.C testPojo2(@Content DTO2s.C c) {
+ // return c;
+ // }
+ DTOs.C x = DTOs.C.create();
+ r = c.doPost(URL + "/C?content=" + encode(JsonSerializer.DEFAULT_LAX.serialize(x)) + "&Content-Type=text/json", null).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+
+ c.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Basic tests using HTTP body content
+ //====================================================================================================
+ @Test
+ public void testUsingContent() throws Exception {
+ RestClient c = new TestRestClient().setAccept("text/json+simple").setHeader("Content-Type", "text/uon").setSerializer(PlainTextSerializer.class);
+ String r;
+
+ // @RestMethod(name="POST", path="/boolean")
+ // public boolean testBool(@Content boolean b) {
+ // return b;
+ // }
+ r = c.doPost(URL + "/boolean", "true").getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/boolean", "(true)").getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/boolean", "$b(true)").getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/boolean", "false").getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/boolean", "(false)").getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/boolean", "$b(false)").getResponseAsString();
+ assertEquals("false", r);
+ try {
+ r = c.doPost(URL + "/boolean?noTrace=true", "%00").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/boolean?noTrace=true", "bad").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+
+ // @RestMethod(name="POST", path="/Boolean")
+ // public Boolean testBoolean(@Content Boolean b) {
+ // return b;
+ // }
+ r = c.doPost(URL + "/Boolean", "true").getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/Boolean", "(true)").getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/Boolean", "$b(true)").getResponseAsString();
+ assertEquals("true", r);
+ r = c.doPost(URL + "/Boolean", "false").getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/Boolean", "(false)").getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/Boolean", "$b(false)").getResponseAsString();
+ assertEquals("false", r);
+ r = c.doPost(URL + "/Boolean", "\u0000").getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Boolean?noTrace=true", "bad").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/int")
+ // public int testInt(@Content int i) {
+ // return i;
+ // }
+ r = c.doPost(URL + "/int", "-123").getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/int", "(-123)").getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/int", "$n(-123)").getResponseAsString();
+ assertEquals("-123", r);
+ try {
+ r = c.doPost(URL + "/int?noTrace=true", "%00").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/int?noTrace=true", "bad").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Integer")
+ // public Integer testInteger(@Content Integer i) {
+ // return i;
+ // }
+ r = c.doPost(URL + "/Integer", "-123").getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/Integer", "(-123)").getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/Integer", "$n(-123)").getResponseAsString();
+ assertEquals("-123", r);
+ r = c.doPost(URL + "/Integer", "\u0000").getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Integer?noTrace=true", "bad").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/float")
+ // public float testFloat(@Content float f) {
+ // return f;
+ // }
+ r = c.doPost(URL + "/float", "-1.23").getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/float", "(-1.23)").getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/float", "$n(-1.23)").getResponseAsString();
+ assertEquals("-1.23", r);
+ try {
+ r = c.doPost(URL + "/float?noTrace=true", "\u0000").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+ try {
+ r = c.doPost(URL + "/float?noTrace=true", "bad").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Float")
+ // public Float testFloat2(@Content Float f) {
+ // return f;
+ // }
+ r = c.doPost(URL + "/Float", "-1.23").getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/Float", "(-1.23)").getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/Float", "$n(-1.23)").getResponseAsString();
+ assertEquals("-1.23", r);
+ r = c.doPost(URL + "/Float", "\u0000").getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Float?noTrace=true", "bad").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/Map")
+ // public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
+ // return m;
+ // }
+ r = c.doPost(URL + "/Map", "(a=b,c=d)").getResponseAsString();
+ assertEquals("{a:'b',c:'d'}", r);
+ r = c.doPost(URL + "/Map", "\u0000").getResponseAsString();
+ assertEquals("null", r);
+ try {
+ r = c.doPost(URL + "/Map?noTrace=true", "bad").getResponseAsString();
+ fail("Exception expected!");
+ } catch (RestCallException e) {
+ assertEquals(400, e.getResponseCode());
+ }
+
+ // @RestMethod(name="POST", path="/B")
+ // public DTO2s.B testPojo1(@Content DTO2s.B b) {
+ // return b;
+ // }
+ DTOs.B b = DTOs.B.create();
+ r = c.doPost(URL + "/B", "" + UonSerializer.DEFAULT.serialize(b)).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+ r = c.doPost(URL + "/B", "" + UonSerializer.DEFAULT_SIMPLE.serialize(b)).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+
+ // @RestMethod(name="POST", path="/C")
+ // public DTO2s.C testPojo2(@Content DTO2s.C c) {
+ // return c;
+ // }
+ DTOs.C x = DTOs.C.create();
+ r = c.doPost(URL + "/C", "" + UonSerializer.DEFAULT.serialize(x)).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+ r = c.doPost(URL + "/C", "" + UonSerializer.DEFAULT_SIMPLE.serialize(x)).getResponseAsString();
+ assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
+
+ c.closeQuietly();
+ }
+
+
+ private String encode(String s) {
+ try {
+ return URLEncoder.encode(s, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/DTOs.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/DTOs.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/DTOs.java
new file mode 100755
index 0000000..a6e1246
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/DTOs.java
@@ -0,0 +1,139 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import java.util.*;
+
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.urlencoding.annotation.*;
+
+public class DTOs {
+
+ @Bean(sort=true)
+ public static class A {
+ public String a;
+ public int b;
+ public boolean c;
+
+ public static A create() {
+ A t = new A();
+ t.a = "a";
+ t.b = 1;
+ t.c = true;
+ return t;
+ }
+
+ }
+
+ @SuppressWarnings("serial")
+ @Bean(sort=true)
+ public static class B {
+ public String[] f01;
+ public List<String> f02;
+ public int[] f03;
+ public List<Integer> f04;
+ public String[][] f05;
+ public List<String[]> f06;
+ public A[] f07;
+ public List<A> f08;
+ public A[][] f09;
+ public List<List<A>> f10;
+
+ private String[] f11;
+ private List<String> f12;
+ private int[] f13;
+ private List<Integer> f14;
+ private String[][] f15;
+ private List<String[]> f16;
+ private A[] f17;
+ private List<A> f18;
+ private A[][] f19;
+ private List<List<A>> f20;
+
+ public String[] getF11() { return f11; }
+ public List<String> getF12() { return f12; }
+ public int[] getF13() { return f13; }
+ public List<Integer> getF14() { return f14; }
+ public String[][] getF15() { return f15; }
+ public List<String[]> getF16() { return f16; }
+ public A[] getF17() { return f17; }
+ public List<A> getF18() { return f18; }
+ public A[][] getF19() { return f19; }
+ public List<List<A>> getF20() { return f20; }
+
+ public void setF11(String[] f11) { this.f11 = f11; }
+ public void setF12(List<String> f12) { this.f12 = f12; }
+ public void setF13(int[] f13) { this.f13 = f13; }
+ public void setF14(List<Integer> f14) { this.f14 = f14; }
+ public void setF15(String[][] f15) { this.f15 = f15; }
+ public void setF16(List<String[]> f16) { this.f16 = f16; }
+ public void setF17(A[] f17) { this.f17 = f17; }
+ public void setF18(List<A> f18) { this.f18 = f18; }
+ public void setF19(A[][] f19) { this.f19 = f19; }
+ public void setF20(List<List<A>> f20) { this.f20 = f20; }
+
+ static B create() {
+ B t = new B();
+ t.f01 = new String[]{"a","b"};
+ t.f02 = new ArrayList<String>(){{add("c");add("d");}};
+ t.f03 = new int[]{1,2};
+ t.f04 = new ArrayList<Integer>(){{add(3);add(4);}};
+ t.f05 = new String[][]{{"e","f"},{"g","h"}};
+ t.f06 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}};
+ t.f07 = new A[]{A.create(),A.create()};
+ t.f08 = new ArrayList<A>(){{add(A.create());add(A.create());}};
+ t.f09 = new A[][]{{A.create()},{A.create()}};
+ t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}};
+ t.setF11(new String[]{"a","b"});
+ t.setF12(new ArrayList<String>(){{add("c");add("d");}});
+ t.setF13(new int[]{1,2});
+ t.setF14(new ArrayList<Integer>(){{add(3);add(4);}});
+ t.setF15(new String[][]{{"e","f"},{"g","h"}});
+ t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}});
+ t.setF17(new A[]{A.create(),A.create()});
+ t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}});
+ t.setF19(new A[][]{{A.create()},{A.create()}});
+ t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}});
+ return t;
+ }
+ }
+
+ @UrlEncoding(expandedParams=true)
+ public static class C extends B {
+ @SuppressWarnings("serial")
+ static C create() {
+ C t = new C();
+ t.f01 = new String[]{"a","b"};
+ t.f02 = new ArrayList<String>(){{add("c");add("d");}};
+ t.f03 = new int[]{1,2};
+ t.f04 = new ArrayList<Integer>(){{add(3);add(4);}};
+ t.f05 = new String[][]{{"e","f"},{"g","h"}};
+ t.f06 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}};
+ t.f07 = new A[]{A.create(),A.create()};
+ t.f08 = new ArrayList<A>(){{add(A.create());add(A.create());}};
+ t.f09 = new A[][]{{A.create()},{A.create()}};
+ t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}};
+ t.setF11(new String[]{"a","b"});
+ t.setF12(new ArrayList<String>(){{add("c");add("d");}});
+ t.setF13(new int[]{1,2});
+ t.setF14(new ArrayList<Integer>(){{add(3);add(4);}});
+ t.setF15(new String[][]{{"e","f"},{"g","h"}});
+ t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}});
+ t.setF17(new A[]{A.create(),A.create()});
+ t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}});
+ t.setF19(new A[][]{{A.create()},{A.create()}});
+ t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}});
+ return t;
+ }
+ }
+}
[02/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/RestUtilsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/RestUtilsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/RestUtilsTest.java
new file mode 100755
index 0000000..a0dae9e
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/RestUtilsTest.java
@@ -0,0 +1,188 @@
+// ***************************************************************************************************************************
+// * 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.RestUtils.*;
+import static org.junit.Assert.*;
+
+import org.junit.*;
+
+public class RestUtilsTest {
+
+ //====================================================================================================
+ // decode(String)
+ //====================================================================================================
+ @Test
+ public void testDecode() throws Exception {
+ assertNull(decode(null));
+ assertEquals("foo/bar baz bing", decode("foo%2Fbar+baz++bing"));
+ }
+
+ //====================================================================================================
+ // encode(String)
+ //====================================================================================================
+ @Test
+ public void testEncode() throws Exception {
+ assertNull(encode(null));
+ assertEquals("foo%2Fbar+baz++bing", encode("foo/bar baz bing"));
+ assertEquals("foobar", encode("foobar"));
+ assertEquals("+", encode(" "));
+ assertEquals("%2F", encode("/"));
+ }
+
+ //====================================================================================================
+ // trimPathInfo(String,String)
+ //====================================================================================================
+ @Test
+ public void testGetServletURI() throws Exception {
+ String e, sp, cp;
+
+ e = "http://hostname";
+ sp = "";
+ cp = "";
+
+ for (String s : new String[]{
+ "http://hostname",
+ "http://hostname/foo",
+ "http://hostname?foo",
+ "http://hostname/?foo"})
+ assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
+
+ for (String s : new String[]{
+ "http:/hostname?foo"}) {
+ try {
+ trimPathInfo(new StringBuffer(s), cp, sp);
+ fail("Exception expected - " + s);
+ } catch (RuntimeException ex) {}
+ }
+
+
+ e = "http://hostname";
+ sp = "/";
+ cp = "/";
+
+ for (String s : new String[]{
+ "http://hostname",
+ "http://hostname/foo",
+ "http://hostname?foo",
+ "http://hostname/?foo"})
+ assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
+
+ e = "http://hostname/foo";
+ sp = "/foo";
+ cp = "/";
+
+ for (String s : new String[]{
+ "http://hostname/foo",
+ "http://hostname/foo/bar",
+ "http://hostname/foo?bar"})
+ assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
+
+ for (String s : new String[]{
+ "http://hostname/foo2",
+ "http://hostname/fo2",
+ "http://hostname?foo",
+ "http://hostname/fo?bar",
+ "http:/hostname/foo"}) {
+ try {
+ trimPathInfo(new StringBuffer(s), cp, sp);
+ fail("Exception expected - " + s);
+ } catch (RuntimeException ex) {}
+ }
+
+ e = "http://hostname/foo/bar";
+ sp = "/foo/bar";
+ cp = "/";
+
+ for (String s : new String[]{
+ "http://hostname/foo/bar",
+ "http://hostname/foo/bar/baz",
+ "http://hostname/foo/bar?baz"})
+ assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
+
+ for (String s : new String[]{
+ "http://hostname/foo2/bar",
+ "http://hostname/foo/bar2"
+ }) {
+ try {
+ trimPathInfo(new StringBuffer(s), cp, sp);
+ fail("Exception expected - " + s);
+ } catch (RuntimeException ex) {}
+ }
+
+ e = "http://hostname/foo/bar";
+ sp = "/bar";
+ cp = "/foo";
+
+ for (String s : new String[]{
+ "http://hostname/foo/bar",
+ "http://hostname/foo/bar/baz",
+ "http://hostname/foo/bar?baz"})
+ assertEquals(e, trimPathInfo(new StringBuffer(s), cp, sp).toString());
+
+ for (String s : new String[]{
+ "http://hostname/foo2/bar",
+ "http://hostname/foo/bar2"
+ }) {
+ try {
+ trimPathInfo(new StringBuffer(s), cp, sp);
+ fail("Exception expected - " + s);
+ } catch (RuntimeException ex) {}
+ }
+ }
+
+ //====================================================================================================
+ // trimSlashes(String)
+ //====================================================================================================
+ @Test
+ public void testTrimSlashes() throws Exception {
+ assertNull(trimSlashes(null));
+ assertEquals("", trimSlashes(""));
+ assertEquals("", trimSlashes("/"));
+ assertEquals("", trimSlashes("//"));
+ assertEquals("foo/bar", trimSlashes("foo/bar"));
+ assertEquals("foo/bar", trimSlashes("foo/bar//"));
+ assertEquals("foo/bar", trimSlashes("/foo/bar//"));
+ assertEquals("foo/bar", trimSlashes("//foo/bar//"));
+ }
+
+ //====================================================================================================
+ // trimTrailingSlashes(String)
+ //====================================================================================================
+ @Test
+ public void testTrimTrailingSlashes() throws Exception {
+ assertNull(trimTrailingSlashes((String)null));
+ assertEquals("", trimTrailingSlashes(""));
+ assertEquals("", trimTrailingSlashes("/"));
+ assertEquals("", trimTrailingSlashes("//"));
+ assertEquals("foo/bar", trimTrailingSlashes("foo/bar"));
+ assertEquals("foo/bar", trimTrailingSlashes("foo/bar//"));
+ assertEquals("/foo/bar", trimTrailingSlashes("/foo/bar//"));
+ assertEquals("//foo/bar", trimTrailingSlashes("//foo/bar//"));
+ }
+
+ //====================================================================================================
+ // trimTrailingSlashes(StringBuffer)
+ //====================================================================================================
+ @Test
+ public void testTrimTrailingSlashes2() throws Exception {
+ assertNull(trimTrailingSlashes((StringBuffer)null));
+ assertEquals("", trimTrailingSlashes(new StringBuffer("")).toString());
+ assertEquals("", trimTrailingSlashes(new StringBuffer("/")).toString());
+ assertEquals("", trimTrailingSlashes(new StringBuffer("//")).toString());
+ assertEquals("foo/bar", trimTrailingSlashes(new StringBuffer("foo/bar")).toString());
+ assertEquals("foo/bar", trimTrailingSlashes(new StringBuffer("foo/bar//")).toString());
+ assertEquals("/foo/bar", trimTrailingSlashes(new StringBuffer("/foo/bar//")).toString());
+ assertEquals("//foo/bar", trimTrailingSlashes(new StringBuffer("//foo/bar//")).toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/SerializersTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/SerializersTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/SerializersTest.java
new file mode 100755
index 0000000..a8bba98
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/SerializersTest.java
@@ -0,0 +1,152 @@
+// ***************************************************************************************************************************
+// * 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 org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+public class SerializersTest {
+
+ private static String URL = "/testSerializers";
+ private static boolean debug = false;
+ private static RestClient client;
+
+ @BeforeClass
+ public static void beforeClass() {
+ client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Serializer defined on class.
+ //====================================================================================================
+ @Test
+ public void testSerializerOnClass() throws Exception {
+ String url = URL + "/testSerializerOnClass";
+
+ client.setAccept("text/a");
+ String r = client.doGet(url).getResponseAsString();
+ assertEquals("text/a - test1", r);
+
+ try {
+ client.setAccept("text/b");
+ client.doGet(url + "?noTrace=true").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/b'",
+ "Supported media-types: [text/a, ");
+ }
+
+ client.setAccept("text/json");
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("\"test1\"", r);
+ }
+
+ //====================================================================================================
+ // Serializer defined on method.
+ //====================================================================================================
+ @Test
+ public void testSerializerOnMethod() throws Exception {
+ String url = URL + "/testSerializerOnMethod";
+
+ try {
+ client.setAccept("text/a");
+ client.doGet(url + "?noTrace=true").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/a'",
+ "Supported media-types: [text/b]"
+ );
+ }
+
+ try {
+ client.setAccept("text/json");
+ client.doGet(url + "?noTrace=true").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/json'",
+ "Supported media-types: [text/b]"
+ );
+ }
+ }
+
+ //====================================================================================================
+ // Serializer overridden on method.
+ //====================================================================================================
+ @Test
+ public void testSerializerOverriddenOnMethod() throws Exception {
+ String url = URL + "/testSerializerOverriddenOnMethod";
+
+ client.setAccept("text/a");
+ String r = client.doGet(url).getResponseAsString();
+ assertEquals("text/c - test3", r);
+
+ client.setAccept("text/b");
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("text/b - test3", r);
+
+ client.setAccept("text/json");
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("\"test3\"", r);
+ }
+
+ //====================================================================================================
+ // Serializer with different Accept than Content-Type.
+ //====================================================================================================
+ @Test
+ public void testSerializerWithDifferentMediaTypes() throws Exception {
+ String url = URL + "/testSerializerWithDifferentMediaTypes";
+
+ client.setAccept("text/a");
+ String r = client.doGet(url).getResponseAsString();
+ assertEquals("text/d - test4", r);
+
+ client.setAccept("text/d");
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("text/d - test4", r);
+
+ client.setAccept("text/json");
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("\"test4\"", r);
+ }
+
+ //====================================================================================================
+ // Check for valid 406 error response.
+ //====================================================================================================
+ @Test
+ public void test406() throws Exception {
+ String url = URL + "/test406";
+
+ try {
+ client.setAccept("text/bad");
+ client.doGet(url + "?noTrace=true").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/bad'",
+ "Supported media-types: [text/a");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/StaticFilesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/StaticFilesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/StaticFilesTest.java
new file mode 100755
index 0000000..0a1449a
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/StaticFilesTest.java
@@ -0,0 +1,56 @@
+// ***************************************************************************************************************************
+// * 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 StaticFilesTest {
+
+ private static String URL = "/testStaticFiles";
+
+ //====================================================================================================
+ // Tests the @RestResource(staticFiles) annotation.
+ //====================================================================================================
+ @Test
+ public void testXdocs() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String r;
+ String url = URL + "/xdocs";
+
+ r = client.doGet(url + "/test.txt").getResponseAsString();
+ assertTrue(r.endsWith("OK-1"));
+ r = client.doGet(url + "/xdocs/test.txt").getResponseAsString();
+ assertTrue(r.endsWith("OK-2"));
+
+ // For security reasons, paths containing ".." should always return 404.
+ try {
+ client.doGet(url + "/xdocs/../test.txt?noTrace=true").connect();
+ fail("404 exception expected");
+ } catch (RestCallException e) {
+ assertEquals(404, e.getResponseCode());
+ }
+
+ try {
+ client.doGet(url + "/xdocs/%2E%2E/test.txt?noTrace=true").connect();
+ fail("404 exception expected");
+ } catch (RestCallException e) {
+ assertEquals(404, e.getResponseCode());
+ }
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/TestRestClient.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/TestRestClient.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/TestRestClient.java
new file mode 100755
index 0000000..e7537d9
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/TestRestClient.java
@@ -0,0 +1,69 @@
+// ***************************************************************************************************************************
+// * 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.security.*;
+
+import javax.net.ssl.*;
+
+import org.apache.http.conn.ssl.*;
+import org.apache.http.impl.client.*;
+import org.apache.juneau.client.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.serializer.*;
+
+/**
+ * REST client with lenient SSL support and lax redirection strategy.
+ */
+class TestRestClient extends RestClient {
+
+ public TestRestClient(Class<? extends Serializer> s, Class<? extends Parser> p) throws InstantiationException {
+ super(s,p);
+ setRootUrl(Constants.getServerTestUrl());
+ }
+
+ public TestRestClient(Serializer s, Parser p) {
+ super(s,p);
+ setRootUrl(Constants.getServerTestUrl());
+ }
+
+ public TestRestClient() {
+ setRootUrl(Constants.getServerTestUrl());
+ }
+
+ public TestRestClient(CloseableHttpClient c) {
+ super(c);
+ setRootUrl(Constants.getServerTestUrl());
+ }
+
+ public static SSLConnectionSocketFactory getSSLSocketFactory() throws Exception {
+ SSLContext sslContext = SSLContext.getInstance("SSL");
+ TrustManager tm = new SimpleX509TrustManager(true);
+ sslContext.init(null, new TrustManager[]{tm}, new SecureRandom());
+ return new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
+ }
+
+ @Override /* RestClient */
+ protected CloseableHttpClient createHttpClient() throws Exception {
+ try {
+ return HttpClients.custom().setSSLSocketFactory(getSSLSocketFactory()).setRedirectStrategy(new LaxRedirectStrategy()).build();
+ } catch (KeyStoreException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException(e);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/TestUtils.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/TestUtils.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/TestUtils.java
new file mode 100755
index 0000000..831fdc0
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/TestUtils.java
@@ -0,0 +1,60 @@
+// ***************************************************************************************************************************
+// * 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.text.*;
+
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.transforms.*;
+import org.junit.Assert;
+
+import junit.framework.*;
+
+public class TestUtils {
+
+ private static JsonSerializer js2 = new JsonSerializer.Simple()
+ .addPojoSwaps(IteratorSwap.class, EnumerationSwap.class);
+
+ /**
+ * Assert that the object equals the specified string after running it through JsonSerializer.DEFAULT_LAX.toString().
+ */
+ public static void assertObjectEquals(String s, Object o) {
+ assertObjectEquals(s, o, js2);
+ }
+
+ /**
+ * Assert that the object equals the specified string after running it through ws.toString().
+ */
+ public static void assertObjectEquals(String s, Object o, WriterSerializer ws) {
+ Assert.assertEquals(s, ws.toString(o));
+ }
+
+ public static void checkErrorResponse(boolean debug, RestCallException e, int status, String...contains) throws AssertionFailedError {
+ String r = e.getResponseMessage();
+ if (debug) {
+ System.err.println(r);
+ e.printStackTrace();
+ }
+ if (status != e.getResponseCode())
+ throw new AssertionFailedError(MessageFormat.format("Response status code was not correct. Expected: ''{0}''. Actual: ''{1}''", status, e.getResponseCode()));
+ for (String s : contains) {
+ if (r == null || ! r.contains(s)) {
+ if (! debug)
+ System.err.println(r);
+ throw new AssertionFailedError(MessageFormat.format("Response did not have the following expected text: ''{0}''", s));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/TransformsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/TransformsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/TransformsTest.java
new file mode 100755
index 0000000..cdb1b5d
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/TransformsTest.java
@@ -0,0 +1,68 @@
+// ***************************************************************************************************************************
+// * 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 TransformsTest {
+
+ private static String URL = "/testTransforms";
+
+ //====================================================================================================
+ // test1 - Test class transform overrides parent class transform
+ // Should return "A2-1".
+ //====================================================================================================
+ @Test
+ public void testClassTransformOverridesParentClassTransform() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+ String url = URL + "/testClassTransformOverridesParentClassTransform";
+
+ r = client.doGet(url).getResponse(String.class);
+ assertEquals("A2-0", r);
+
+ r = client.doPut(url, "A2-1").getResponse(String.class);
+ assertEquals("A2-1", r);
+
+ r = client.doPut(url + "/A2-2", "").getResponse(String.class);
+ assertEquals("A2-2", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test method transform overrides class transform
+ // Should return "A3-1".
+ //====================================================================================================
+ @Test
+ public void testMethodTransformOverridesClassTransform() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+ String url = URL + "/testMethodTransformOverridesClassTransform";
+
+ r = client.doGet(url).getResponse(String.class);
+ assertEquals("A3-0", r);
+
+ r = client.doPut(url, "A3-1").getResponse(String.class);
+ assertEquals("A3-1", r);
+
+ r = client.doPut(url + "/A3-2", "").getResponse(String.class);
+ assertEquals("A3-2", r);
+
+ client.closeQuietly();
+ }
+}
[11/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/CharsetEncodingsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/CharsetEncodingsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/CharsetEncodingsTest.java
deleted file mode 100755
index b6f5593..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/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;
-
-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 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/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/ClientVersionTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/ClientVersionTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/ClientVersionTest.java
deleted file mode 100644
index 30428ad..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/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;
-
-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/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/ConfigTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/ConfigTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/ConfigTest.java
deleted file mode 100755
index 7c6e532..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/ConfigTest.java
+++ /dev/null
@@ -1,58 +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.apache.juneau.server.TestUtils.*;
-import static org.junit.Assert.*;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.ini.*;
-import org.apache.juneau.json.*;
-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}',mainClass:'$MF{Main-Class}',importPackage:'$MF{Import-Package}'}", 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("'org.apache.juneau.microservice.RestMicroservice'", c.doGet(URL + "/Test%2FmainClass/" + 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/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/Constants.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/Constants.java b/juneau-server-test/src/test/java/org/apache/juneau/server/Constants.java
deleted file mode 100755
index 7d51c7d..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/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;
-
-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;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/ContentTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/ContentTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/ContentTest.java
deleted file mode 100755
index 03f6a89..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/ContentTest.java
+++ /dev/null
@@ -1,706 +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 java.io.*;
-import java.net.*;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.plaintext.*;
-import org.apache.juneau.urlencoding.*;
-import org.junit.*;
-
-public class ContentTest {
-
- private static String URL = "/testContent";
-
- //====================================================================================================
- // Basic tests using &Content parameter
- //====================================================================================================
- @Test
- public void testUsingContentParam() throws Exception {
- RestClient c = new TestRestClient().setAccept("text/json+simple");
- String r;
-
- // @RestMethod(name="POST", path="/boolean")
- // public boolean testBool(@Content boolean b) {
- // return b;
- // }
- r = c.doPost(URL + "/boolean?content=true", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/boolean?content=(true)", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/boolean?content=$b(true)", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/boolean?content=false", null).getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/boolean?content=(false)", null).getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/boolean?content=$b(false)", null).getResponseAsString();
- assertEquals("false", r);
- try {
- r = c.doPost(URL + "/boolean?content=%00&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/boolean?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
-
- // @RestMethod(name="POST", path="/Boolean")
- // public Boolean testBoolean(@Content Boolean b) {
- // return b;
- // }
- r = c.doPost(URL + "/Boolean?content=true", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/Boolean?content=(true)", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/Boolean?content=$b(true)", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/Boolean?content=false", null).getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/Boolean?content=(false)", null).getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/Boolean?content=$b(false)", null).getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/Boolean?content=%00", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Boolean?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/int")
- // public int testInt(@Content int i) {
- // return i;
- // }
- r = c.doPost(URL + "/int?content=-123", null).getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/int?content=(-123)", null).getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/int?content=$n(-123)", null).getResponseAsString();
- assertEquals("-123", r);
- try {
- r = c.doPost(URL + "/int?content=%00&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/int?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Integer")
- // public Integer testInteger(@Content Integer i) {
- // return i;
- // }
- r = c.doPost(URL + "/Integer?content=-123", null).getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/Integer?content=(-123)", null).getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/Integer?content=$n(-123)", null).getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/Integer?content=%00", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Integer?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/float")
- // public float testFloat(@Content float f) {
- // return f;
- // }
- r = c.doPost(URL + "/float?content=-1.23", null).getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/float?content=(-1.23)", null).getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/float?content=$n(-1.23)", null).getResponseAsString();
- assertEquals("-1.23", r);
- try {
- r = c.doPost(URL + "/float?content=%00&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/float?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Float")
- // public Float testFloat2(@Content Float f) {
- // return f;
- // }
- r = c.doPost(URL + "/Float?content=-1.23", null).getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/Float?content=(-1.23)", null).getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/Float?content=$n(-1.23)", null).getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/Float?content=%00", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Float?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Map")
- // public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
- // return m;
- // }
- r = c.doPost(URL + "/Map?content=(a=b,c=d)", null).getResponseAsString();
- assertEquals("{a:'b',c:'d'}", r);
- r = c.doPost(URL + "/Map?content=%00", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Map?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/B")
- // public DTO2s.B testPojo1(@Content DTO2s.B b) {
- // return b;
- // }
- DTOs.B b = DTOs.B.create();
- r = c.doPost(URL + "/B?content=" + UonSerializer.DEFAULT.serialize(b), null).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
- r = c.doPost(URL + "/B?content=" + UonSerializer.DEFAULT_SIMPLE.serialize(b), null).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
-
- // @RestMethod(name="POST", path="/C")
- // public DTO2s.C testPojo2(@Content DTO2s.C c) {
- // return c;
- // }
- DTOs.C x = DTOs.C.create();
- r = c.doPost(URL + "/C?content=" + UonSerializer.DEFAULT.serialize(x), null).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
- r = c.doPost(URL + "/C?content=" + UonSerializer.DEFAULT_SIMPLE.serialize(x), null).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
-
- c.closeQuietly();
- }
-
- //====================================================================================================
- // Basic tests using &Content parameter with &Accept=text/json
- //====================================================================================================
- @Test
- public void testUsingContentParamJsonHeader() throws Exception {
- RestClient c = new TestRestClient().setAccept("text/json+simple").setHeader("Content-Type", "text/json");
- String r;
-
- // @RestMethod(name="POST", path="/boolean")
- // public boolean testBool(@Content boolean b) {
- // return b;
- // }
- r = c.doPost(URL + "/boolean?content=true", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/boolean?content=false", null).getResponseAsString();
- assertEquals("false", r);
- try {
- r = c.doPost(URL + "/boolean?content=null&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/boolean?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
-
- // @RestMethod(name="POST", path="/Boolean")
- // public Boolean testBoolean(@Content Boolean b) {
- // return b;
- // }
- r = c.doPost(URL + "/Boolean?content=true", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/Boolean?content=false", null).getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/Boolean?content=null", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Boolean?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/int")
- // public int testInt(@Content int i) {
- // return i;
- // }
- r = c.doPost(URL + "/int?content=-123", null).getResponseAsString();
- assertEquals("-123", r);
- try {
- r = c.doPost(URL + "/int?content=null&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/int?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Integer")
- // public Integer testInteger(@Content Integer i) {
- // return i;
- // }
- r = c.doPost(URL + "/Integer?content=-123", null).getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/Integer?content=null", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Integer?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/float")
- // public float testFloat(@Content float f) {
- // return f;
- // }
- r = c.doPost(URL + "/float?content=-1.23", null).getResponseAsString();
- assertEquals("-1.23", r);
- try {
- r = c.doPost(URL + "/float?content=null&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/float?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Float")
- // public Float testFloat2(@Content Float f) {
- // return f;
- // }
- r = c.doPost(URL + "/Float?content=-1.23", null).getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/Float?content=null", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Float?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Map")
- // public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
- // return m;
- // }
- r = c.doPost(URL + "/Map?content=" + encode("{a:'b',c:'d'}"), null).getResponseAsString();
- assertEquals("{a:'b',c:'d'}", r);
- r = c.doPost(URL + "/Map?content=null", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Map?content=bad&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/B")
- // public DTO2s.B testPojo1(@Content DTO2s.B b) {
- // return b;
- // }
- DTOs.B b = DTOs.B.create();
- r = c.doPost(URL + "/B?content=" + encode(JsonSerializer.DEFAULT_LAX.serialize(b)), null).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
-
- // @RestMethod(name="POST", path="/C")
- // public DTO2s.C testPojo2(@Content DTO2s.C c) {
- // return c;
- // }
- DTOs.C x = DTOs.C.create();
- r = c.doPost(URL + "/C?content=" + encode(JsonSerializer.DEFAULT_LAX.serialize(x)), null).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
-
- c.closeQuietly();
- }
-
- //====================================================================================================
- // Basic tests using &Content parameter with &Accept=text/json
- //====================================================================================================
- @Test
- public void testUsingContentParamJsonParam() throws Exception {
- RestClient c = new TestRestClient().setAccept("text/json+simple");
- String r;
-
- // @RestMethod(name="POST", path="/boolean")
- // public boolean testBool(@Content boolean b) {
- // return b;
- // }
- r = c.doPost(URL + "/boolean?content=true&Content-Type=text/json", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/boolean?content=false&Content-Type=text/json", null).getResponseAsString();
- assertEquals("false", r);
- try {
- r = c.doPost(URL + "/boolean?content=null&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/boolean?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
-
- // @RestMethod(name="POST", path="/Boolean")
- // public Boolean testBoolean(@Content Boolean b) {
- // return b;
- // }
- r = c.doPost(URL + "/Boolean?content=true&Content-Type=text/json", null).getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/Boolean?content=false&Content-Type=text/json", null).getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/Boolean?content=null&Content-Type=text/json", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Boolean?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/int")
- // public int testInt(@Content int i) {
- // return i;
- // }
- r = c.doPost(URL + "/int?content=-123&Content-Type=text/json", null).getResponseAsString();
- assertEquals("-123", r);
- try {
- r = c.doPost(URL + "/int?content=null&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/int?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Integer")
- // public Integer testInteger(@Content Integer i) {
- // return i;
- // }
- r = c.doPost(URL + "/Integer?content=-123&Content-Type=text/json", null).getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/Integer?content=null&Content-Type=text/json", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Integer?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/float")
- // public float testFloat(@Content float f) {
- // return f;
- // }
- r = c.doPost(URL + "/float?content=-1.23&Content-Type=text/json", null).getResponseAsString();
- assertEquals("-1.23", r);
- try {
- r = c.doPost(URL + "/float?content=null&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/float?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Float")
- // public Float testFloat2(@Content Float f) {
- // return f;
- // }
- r = c.doPost(URL + "/Float?content=-1.23&Content-Type=text/json", null).getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/Float?content=null&Content-Type=text/json", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Float?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Map")
- // public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
- // return m;
- // }
- r = c.doPost(URL + "/Map?content=" + encode("{a:'b',c:'d'}") + "&Content-Type=text/json", null).getResponseAsString();
- assertEquals("{a:'b',c:'d'}", r);
- r = c.doPost(URL + "/Map?content=null&Content-Type=text/json", null).getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Map?content=bad&Content-Type=text/json&noTrace=true", null).getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/B")
- // public DTO2s.B testPojo1(@Content DTO2s.B b) {
- // return b;
- // }
- DTOs.B b = DTOs.B.create();
- r = c.doPost(URL + "/B?content=" + encode(JsonSerializer.DEFAULT_LAX.serialize(b)) + "&Content-Type=text/json", null).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
-
- // @RestMethod(name="POST", path="/C")
- // public DTO2s.C testPojo2(@Content DTO2s.C c) {
- // return c;
- // }
- DTOs.C x = DTOs.C.create();
- r = c.doPost(URL + "/C?content=" + encode(JsonSerializer.DEFAULT_LAX.serialize(x)) + "&Content-Type=text/json", null).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
-
- c.closeQuietly();
- }
-
- //====================================================================================================
- // Basic tests using HTTP body content
- //====================================================================================================
- @Test
- public void testUsingContent() throws Exception {
- RestClient c = new TestRestClient().setAccept("text/json+simple").setHeader("Content-Type", "text/uon").setSerializer(PlainTextSerializer.class);
- String r;
-
- // @RestMethod(name="POST", path="/boolean")
- // public boolean testBool(@Content boolean b) {
- // return b;
- // }
- r = c.doPost(URL + "/boolean", "true").getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/boolean", "(true)").getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/boolean", "$b(true)").getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/boolean", "false").getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/boolean", "(false)").getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/boolean", "$b(false)").getResponseAsString();
- assertEquals("false", r);
- try {
- r = c.doPost(URL + "/boolean?noTrace=true", "%00").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/boolean?noTrace=true", "bad").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
-
- // @RestMethod(name="POST", path="/Boolean")
- // public Boolean testBoolean(@Content Boolean b) {
- // return b;
- // }
- r = c.doPost(URL + "/Boolean", "true").getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/Boolean", "(true)").getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/Boolean", "$b(true)").getResponseAsString();
- assertEquals("true", r);
- r = c.doPost(URL + "/Boolean", "false").getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/Boolean", "(false)").getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/Boolean", "$b(false)").getResponseAsString();
- assertEquals("false", r);
- r = c.doPost(URL + "/Boolean", "\u0000").getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Boolean?noTrace=true", "bad").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/int")
- // public int testInt(@Content int i) {
- // return i;
- // }
- r = c.doPost(URL + "/int", "-123").getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/int", "(-123)").getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/int", "$n(-123)").getResponseAsString();
- assertEquals("-123", r);
- try {
- r = c.doPost(URL + "/int?noTrace=true", "%00").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/int?noTrace=true", "bad").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Integer")
- // public Integer testInteger(@Content Integer i) {
- // return i;
- // }
- r = c.doPost(URL + "/Integer", "-123").getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/Integer", "(-123)").getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/Integer", "$n(-123)").getResponseAsString();
- assertEquals("-123", r);
- r = c.doPost(URL + "/Integer", "\u0000").getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Integer?noTrace=true", "bad").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/float")
- // public float testFloat(@Content float f) {
- // return f;
- // }
- r = c.doPost(URL + "/float", "-1.23").getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/float", "(-1.23)").getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/float", "$n(-1.23)").getResponseAsString();
- assertEquals("-1.23", r);
- try {
- r = c.doPost(URL + "/float?noTrace=true", "\u0000").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
- try {
- r = c.doPost(URL + "/float?noTrace=true", "bad").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Float")
- // public Float testFloat2(@Content Float f) {
- // return f;
- // }
- r = c.doPost(URL + "/Float", "-1.23").getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/Float", "(-1.23)").getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/Float", "$n(-1.23)").getResponseAsString();
- assertEquals("-1.23", r);
- r = c.doPost(URL + "/Float", "\u0000").getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Float?noTrace=true", "bad").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/Map")
- // public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
- // return m;
- // }
- r = c.doPost(URL + "/Map", "(a=b,c=d)").getResponseAsString();
- assertEquals("{a:'b',c:'d'}", r);
- r = c.doPost(URL + "/Map", "\u0000").getResponseAsString();
- assertEquals("null", r);
- try {
- r = c.doPost(URL + "/Map?noTrace=true", "bad").getResponseAsString();
- fail("Exception expected!");
- } catch (RestCallException e) {
- assertEquals(400, e.getResponseCode());
- }
-
- // @RestMethod(name="POST", path="/B")
- // public DTO2s.B testPojo1(@Content DTO2s.B b) {
- // return b;
- // }
- DTOs.B b = DTOs.B.create();
- r = c.doPost(URL + "/B", "" + UonSerializer.DEFAULT.serialize(b)).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
- r = c.doPost(URL + "/B", "" + UonSerializer.DEFAULT_SIMPLE.serialize(b)).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
-
- // @RestMethod(name="POST", path="/C")
- // public DTO2s.C testPojo2(@Content DTO2s.C c) {
- // return c;
- // }
- DTOs.C x = DTOs.C.create();
- r = c.doPost(URL + "/C", "" + UonSerializer.DEFAULT.serialize(x)).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
- r = c.doPost(URL + "/C", "" + UonSerializer.DEFAULT_SIMPLE.serialize(x)).getResponseAsString();
- assertEquals("{f01:['a','b'],f02:['c','d'],f03:[1,2],f04:[3,4],f05:[['e','f'],['g','h']],f06:[['i','j'],['k','l']],f07:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f08:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f09:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f10:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f11:['a','b'],f12:['c','d'],f13:[1,2],f14:[3,4],f15:[['e','f'],['g','h']],f16:[['i','j'],['k','l']],f17:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f18:[{a:'a',b:1,c:true},{a:'a',b:1,c:true}],f19:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]],f20:[[{a:'a',b:1,c:true}],[{a:'a',b:1,c:true}]]}", r);
-
- c.closeQuietly();
- }
-
-
- private String encode(String s) {
- try {
- return URLEncoder.encode(s, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/DTOs.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/DTOs.java b/juneau-server-test/src/test/java/org/apache/juneau/server/DTOs.java
deleted file mode 100755
index 541245a..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/DTOs.java
+++ /dev/null
@@ -1,139 +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 java.util.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.urlencoding.annotation.*;
-
-public class DTOs {
-
- @Bean(sort=true)
- public static class A {
- public String a;
- public int b;
- public boolean c;
-
- public static A create() {
- A t = new A();
- t.a = "a";
- t.b = 1;
- t.c = true;
- return t;
- }
-
- }
-
- @SuppressWarnings("serial")
- @Bean(sort=true)
- public static class B {
- public String[] f01;
- public List<String> f02;
- public int[] f03;
- public List<Integer> f04;
- public String[][] f05;
- public List<String[]> f06;
- public A[] f07;
- public List<A> f08;
- public A[][] f09;
- public List<List<A>> f10;
-
- private String[] f11;
- private List<String> f12;
- private int[] f13;
- private List<Integer> f14;
- private String[][] f15;
- private List<String[]> f16;
- private A[] f17;
- private List<A> f18;
- private A[][] f19;
- private List<List<A>> f20;
-
- public String[] getF11() { return f11; }
- public List<String> getF12() { return f12; }
- public int[] getF13() { return f13; }
- public List<Integer> getF14() { return f14; }
- public String[][] getF15() { return f15; }
- public List<String[]> getF16() { return f16; }
- public A[] getF17() { return f17; }
- public List<A> getF18() { return f18; }
- public A[][] getF19() { return f19; }
- public List<List<A>> getF20() { return f20; }
-
- public void setF11(String[] f11) { this.f11 = f11; }
- public void setF12(List<String> f12) { this.f12 = f12; }
- public void setF13(int[] f13) { this.f13 = f13; }
- public void setF14(List<Integer> f14) { this.f14 = f14; }
- public void setF15(String[][] f15) { this.f15 = f15; }
- public void setF16(List<String[]> f16) { this.f16 = f16; }
- public void setF17(A[] f17) { this.f17 = f17; }
- public void setF18(List<A> f18) { this.f18 = f18; }
- public void setF19(A[][] f19) { this.f19 = f19; }
- public void setF20(List<List<A>> f20) { this.f20 = f20; }
-
- static B create() {
- B t = new B();
- t.f01 = new String[]{"a","b"};
- t.f02 = new ArrayList<String>(){{add("c");add("d");}};
- t.f03 = new int[]{1,2};
- t.f04 = new ArrayList<Integer>(){{add(3);add(4);}};
- t.f05 = new String[][]{{"e","f"},{"g","h"}};
- t.f06 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}};
- t.f07 = new A[]{A.create(),A.create()};
- t.f08 = new ArrayList<A>(){{add(A.create());add(A.create());}};
- t.f09 = new A[][]{{A.create()},{A.create()}};
- t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}};
- t.setF11(new String[]{"a","b"});
- t.setF12(new ArrayList<String>(){{add("c");add("d");}});
- t.setF13(new int[]{1,2});
- t.setF14(new ArrayList<Integer>(){{add(3);add(4);}});
- t.setF15(new String[][]{{"e","f"},{"g","h"}});
- t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}});
- t.setF17(new A[]{A.create(),A.create()});
- t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}});
- t.setF19(new A[][]{{A.create()},{A.create()}});
- t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}});
- return t;
- }
- }
-
- @UrlEncoding(expandedParams=true)
- public static class C extends B {
- @SuppressWarnings("serial")
- static C create() {
- C t = new C();
- t.f01 = new String[]{"a","b"};
- t.f02 = new ArrayList<String>(){{add("c");add("d");}};
- t.f03 = new int[]{1,2};
- t.f04 = new ArrayList<Integer>(){{add(3);add(4);}};
- t.f05 = new String[][]{{"e","f"},{"g","h"}};
- t.f06 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}};
- t.f07 = new A[]{A.create(),A.create()};
- t.f08 = new ArrayList<A>(){{add(A.create());add(A.create());}};
- t.f09 = new A[][]{{A.create()},{A.create()}};
- t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}};
- t.setF11(new String[]{"a","b"});
- t.setF12(new ArrayList<String>(){{add("c");add("d");}});
- t.setF13(new int[]{1,2});
- t.setF14(new ArrayList<Integer>(){{add(3);add(4);}});
- t.setF15(new String[][]{{"e","f"},{"g","h"}});
- t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}});
- t.setF17(new A[]{A.create(),A.create()});
- t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}});
- t.setF19(new A[][]{{A.create()},{A.create()}});
- t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}});
- return t;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/DefaultContentTypesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/DefaultContentTypesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/DefaultContentTypesTest.java
deleted file mode 100755
index 731b786..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/DefaultContentTypesTest.java
+++ /dev/null
@@ -1,497 +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 org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-
-public class DefaultContentTypesTest {
-
- private static String URL = "/testDefaultContentTypes";
- private static boolean debug = false;
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on servlet annotation are picked up.
- //====================================================================================================
- @Test
- public void testDefaultHeadersOnServletAnnotation() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
-
- String url = URL + "/testDefaultHeadersOnServletAnnotation";
-
- client.setAccept("").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- client.setAccept("text/s1").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p2", r);
-
- client.setAccept("").setContentType("text/p1");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p1", r);
-
- client.setAccept("text/s1").setContentType("text/p1");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p1", r);
-
- client.setAccept("text/s2").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- client.setAccept("").setContentType("text/p2");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- client.setAccept("text/s2").setContentType("text/p2");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- try {
- client.setAccept("text/s3").setContentType("");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/s3'",
- "Supported media-types: [text/s1, text/s2]"
- );
- }
-
- try {
- client.setAccept("").setContentType("text/p3");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p3'",
- "Supported media-types: [text/p1, text/p2]"
- );
- }
-
- try {
- client.setAccept("text/s3").setContentType("text/p3");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p3'",
- "Supported media-types: [text/p1, text/p2]"
- );
- }
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on servlet annotation are picked up
- // when @RestMethod.parsers/serializers annotations are used.
- //====================================================================================================
- @Test
- public void testRestMethodParsersSerializers() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
-
- String url = URL + "/testRestMethodParsersSerializers";
-
- try {
- client.setAccept("").setContentType("");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p2'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("text/s1").setContentType("");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p2'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("").setContentType("text/p1");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p1'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("text/s1").setContentType("text/p1");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p1'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("text/s2").setContentType("");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p2'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("").setContentType("text/p2");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p2'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("text/s2").setContentType("text/p2");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p2'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("text/s3").setContentType("");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p2'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("").setContentType("text/p3");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/s2'",
- "Supported media-types: [text/s3]"
- );
- }
-
- client.setAccept("text/s3").setContentType("text/p3");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on servlet annotation are picked up
- // when @RestMethod.addParsers/addSerializers annotations are used.
- //====================================================================================================
- @Test
- public void testRestMethodAddParsersSerializers() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
-
- String url = URL + "/testRestMethodAddParsersSerializers";
-
- client.setAccept("").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- client.setAccept("text/s1").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p2", r);
-
- client.setAccept("").setContentType("text/p1");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p1", r);
-
- client.setAccept("text/s1").setContentType("text/p1");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p1", r);
-
- client.setAccept("text/s2").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- client.setAccept("").setContentType("text/p2");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- client.setAccept("text/s2").setContentType("text/p2");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- client.setAccept("text/s3").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p2", r);
-
- client.setAccept("").setContentType("text/p3");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p3", r);
-
- client.setAccept("text/s3").setContentType("text/p3");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- try {
- client.setAccept("").setContentType("text/p4");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- // Note that parsers defined on method are listed before parsers defined on class.
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p4'",
- "Supported media-types: [text/p3, text/p1, text/p2]"
- );
- }
-
- try {
- client.setAccept("text/s4").setContentType("");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- // Note that serializers defined on method are listed before serializers defined on class.
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/s4'",
- "Supported media-types: [text/s3, text/s1, text/s2]"
- );
- }
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Various Accept incantations.
- //====================================================================================================
- @Test
- public void testAccept() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT).setContentType("text/p1");
- String r;
-
- String url = URL + "/testAccept";
-
- // "*/*" should match the first serializer, not the default serializer.
- client.setAccept("*/*");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p1", r);
-
- // "text/*" should match the first serializer, not the default serializer.
- client.setAccept("text/*");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p1", r);
-
- try {
- client.setAccept("bad/*");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'bad/*'",
- "Supported media-types: [text/s1, text/s2]"
- );
- }
-
- client.setAccept("bad/*,text/*");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p1", r);
-
- client.setAccept("text/*,bad/*");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p1", r);
-
- client.setAccept("text/s1;q=0.5,text/s2");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p1", r);
-
- client.setAccept("text/s1,text/s2;q=0.5");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p1", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on method annotation are picked up
- // when @RestMethod.parsers/serializers annotations are used.
- //====================================================================================================
- @Test
- public void testRestMethodParserSerializerAnnotations() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
-
- String url = URL + "/testRestMethodParserSerializerAnnotations";
-
- client.setAccept("").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- try {
- client.setAccept("text/s1").setContentType("");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/s1'",
- "Supported media-types: [text/s3]"
- );
- }
-
- try {
- client.setAccept("").setContentType("text/p1");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p1'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("text/s1").setContentType("text/p1");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p1'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("text/s2").setContentType("");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/s2'",
- "Supported media-types: [text/s3]"
- );
- }
-
- try {
- client.setAccept("").setContentType("text/p2");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p2'",
- "Supported media-types: [text/p3]"
- );
- }
-
- try {
- client.setAccept("text/s2").setContentType("text/p2");
- r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p2'",
- "Supported media-types: [text/p3]"
- );
- }
-
- client.setAccept("text/s3").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- client.setAccept("").setContentType("text/p3");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- client.setAccept("text/s3").setContentType("text/p3");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on method annotation are picked up
- // when @RestMethod.addParsers/addSerializers annotations are used.
- //====================================================================================================
- @Test
- public void testRestMethodAddParsersSerializersAnnotations() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
-
- String url = URL + "/testRestMethodAddParsersSerializersAnnotations";
-
- client.setAccept("").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- client.setAccept("text/s1").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p3", r);
-
- client.setAccept("").setContentType("text/p1");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p1", r);
-
- client.setAccept("text/s1").setContentType("text/p1");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s1/p1", r);
-
- client.setAccept("text/s2").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p3", r);
-
- client.setAccept("").setContentType("text/p2");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p2", r);
-
- client.setAccept("text/s2").setContentType("text/p2");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s2/p2", r);
-
- client.setAccept("text/s3").setContentType("");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- client.setAccept("").setContentType("text/p3");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- client.setAccept("text/s3").setContentType("text/p3");
- r = client.doPut(url, "").getResponseAsString();
- assertEquals("s3/p3", r);
-
- client.closeQuietly();
- }
-}
[20/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
Clean up Javadocs
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/d45e1351
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/d45e1351
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/d45e1351
Branch: refs/heads/master
Commit: d45e1351dd8a1569315200e9b80911a69695d194
Parents: a8d50ab
Author: jamesbognar <ja...@gmail.com>
Authored: Thu Sep 15 17:25:20 2016 -0400
Committer: jamesbognar <ja...@gmail.com>
Committed: Thu Sep 15 17:25:20 2016 -0400
----------------------------------------------------------------------
.../.settings/org.eclipse.wst.html.core.prefs | 2 +-
.../java/org/apache/juneau/BeanContext.java | 439 +++++-
.../java/org/apache/juneau/csv/package.html | 2 -
.../juneau/html/HtmlDocSerializerContext.java | 126 +-
.../apache/juneau/html/HtmlParserContext.java | 15 +
.../juneau/html/HtmlSerializerContext.java | 72 +-
.../org/apache/juneau/internal/package.html | 42 +
.../apache/juneau/jena/RdfCommonContext.java | 442 +++++-
.../java/org/apache/juneau/jena/RdfParser.java | 2 +-
.../apache/juneau/jena/RdfParserContext.java | 36 +-
.../apache/juneau/jena/RdfParserSession.java | 14 +-
.../org/apache/juneau/jena/RdfSerializer.java | 2 +-
.../juneau/jena/RdfSerializerContext.java | 78 +-
.../juneau/jena/RdfSerializerSession.java | 14 +-
.../java/org/apache/juneau/jena/package.html | 10 +-
.../apache/juneau/json/JsonParserContext.java | 28 +-
.../juneau/json/JsonSerializerContext.java | 57 +-
.../java/org/apache/juneau/json/package.html | 4 +-
.../juneau/msgpack/MsgPackParserContext.java | 14 +
.../msgpack/MsgPackSerializerContext.java | 13 +
.../org/apache/juneau/parser/ParserContext.java | 39 +-
.../juneau/serializer/SerializerContext.java | 263 +++-
.../juneau/serializer/SerializerSession.java | 16 +-
.../juneau/soap/SoapXmlSerializerContext.java | 28 +-
.../org/apache/juneau/svl/vars/package.html | 41 +
.../juneau/urlencoding/UonParserContext.java | 45 +-
.../urlencoding/UonSerializerContext.java | 59 +-
.../org/apache/juneau/urlencoding/package.html | 2 +-
.../org/apache/juneau/xml/XmlParserContext.java | 141 +-
.../org/apache/juneau/xml/XmlSerializer.java | 44 +-
.../apache/juneau/xml/XmlSerializerContext.java | 141 +-
.../java/org/apache/juneau/xml/package.html | 183 +--
juneau-core/src/main/javadoc/overview.html | 1211 ++++++++++------
.../java/org/apache/juneau/html/CommonTest.java | 8 +-
.../java/org/apache/juneau/jena/CommonTest.java | 8 +-
.../java/org/apache/juneau/jena/RdfTest.java | 4 +-
.../java/org/apache/juneau/json/CommonTest.java | 8 +-
.../juneau/urlencoding/Common_UonTest.java | 8 +-
.../urlencoding/Common_UrlEncodingTest.java | 8 +-
.../java/org/apache/juneau/xml/CommonTest.java | 8 +-
juneau-releng/user-dictionary.txt | 12 +
juneau-server-test/META-INF/MANIFEST.MF | 2 +-
.../juneau/server/AcceptCharsetResource.java | 75 -
.../server/BeanContextPropertiesResource.java | 41 -
.../juneau/server/CallbackStringsResource.java | 52 -
.../juneau/server/CharsetEncodingsResource.java | 54 -
.../juneau/server/ClientVersionResource.java | 93 --
.../apache/juneau/server/ConfigResource.java | 37 -
.../apache/juneau/server/ContentResource.java | 80 -
.../java/org/apache/juneau/server/DTO2s.java | 139 --
.../server/DefaultContentTypesResource.java | 127 --
.../juneau/server/ErrorConditionsResource.java | 134 --
.../apache/juneau/server/GroupsResource.java | 71 -
.../org/apache/juneau/server/GzipResource.java | 110 --
.../juneau/server/InheritanceResource.java | 316 ----
.../org/apache/juneau/server/LargePojo.java | 45 -
.../juneau/server/LargePojosResource.java | 39 -
.../apache/juneau/server/MessagesResource.java | 61 -
.../juneau/server/NlsPropertyResource.java | 60 -
.../org/apache/juneau/server/NlsResource.java | 194 ---
.../juneau/server/NoParserInputResource.java | 55 -
.../juneau/server/OnPostCallResource.java | 93 --
.../apache/juneau/server/OnPreCallResource.java | 84 --
.../server/OptionsWithoutNlsResource.java | 43 -
.../server/OverlappingMethodsResource.java | 145 --
.../apache/juneau/server/ParamsResource.java | 292 ----
.../apache/juneau/server/ParsersResource.java | 111 --
.../org/apache/juneau/server/PathResource.java | 68 -
.../org/apache/juneau/server/PathsResource.java | 72 -
.../juneau/server/PropertiesResource.java | 89 --
.../juneau/server/RestClient2Resource.java | 35 -
.../java/org/apache/juneau/server/Root.java | 70 -
.../juneau/server/SerializersResource.java | 102 --
.../juneau/server/StaticFilesResource.java | 35 -
.../juneau/server/TransformsParentResource.java | 25 -
.../juneau/server/TransformsResource.java | 113 --
.../org/apache/juneau/server/UrisResource.java | 120 --
.../juneau/server/UrlContentResource.java | 58 -
.../server/test/AcceptCharsetResource.java | 76 +
.../test/BeanContextPropertiesResource.java | 42 +
.../server/test/CallbackStringsResource.java | 53 +
.../server/test/CharsetEncodingsResource.java | 55 +
.../server/test/ClientVersionResource.java | 93 ++
.../juneau/server/test/ConfigResource.java | 38 +
.../juneau/server/test/ContentResource.java | 81 ++
.../org/apache/juneau/server/test/DTO2s.java | 139 ++
.../test/DefaultContentTypesResource.java | 128 ++
.../server/test/ErrorConditionsResource.java | 135 ++
.../juneau/server/test/GroupsResource.java | 72 +
.../apache/juneau/server/test/GzipResource.java | 111 ++
.../juneau/server/test/InheritanceResource.java | 317 ++++
.../apache/juneau/server/test/LargePojo.java | 45 +
.../juneau/server/test/LargePojosResource.java | 39 +
.../juneau/server/test/MessagesResource.java | 62 +
.../juneau/server/test/NlsPropertyResource.java | 61 +
.../apache/juneau/server/test/NlsResource.java | 195 +++
.../server/test/NoParserInputResource.java | 56 +
.../juneau/server/test/OnPostCallResource.java | 94 ++
.../juneau/server/test/OnPreCallResource.java | 85 ++
.../server/test/OptionsWithoutNlsResource.java | 44 +
.../server/test/OverlappingMethodsResource.java | 146 ++
.../juneau/server/test/ParamsResource.java | 293 ++++
.../juneau/server/test/ParsersResource.java | 112 ++
.../apache/juneau/server/test/PathResource.java | 69 +
.../juneau/server/test/PathsResource.java | 73 +
.../juneau/server/test/PropertiesResource.java | 90 ++
.../juneau/server/test/RestClient2Resource.java | 36 +
.../org/apache/juneau/server/test/Root.java | 71 +
.../juneau/server/test/SerializersResource.java | 103 ++
.../juneau/server/test/StaticFilesResource.java | 36 +
.../server/test/TransformsParentResource.java | 26 +
.../juneau/server/test/TransformsResource.java | 113 ++
.../apache/juneau/server/test/UrisResource.java | 121 ++
.../juneau/server/test/UrlContentResource.java | 59 +
.../juneau/server/Messages2Resource.properties | 16 -
.../juneau/server/MessagesResource.properties | 16 -
.../server/NlsPropertyResource.properties | 16 -
.../apache/juneau/server/NlsResource.properties | 79 -
.../server/test/Messages2Resource.properties | 16 +
.../server/test/MessagesResource.properties | 16 +
.../server/test/NlsPropertyResource.properties | 16 +
.../juneau/server/test/NlsResource.properties | 79 +
.../apache/juneau/server/test/xdocs/test.txt | 13 +
.../juneau/server/test/xdocs/xdocs/test.txt | 13 +
.../org/apache/juneau/server/xdocs/test.txt | 13 -
.../apache/juneau/server/xdocs/xdocs/test.txt | 13 -
.../apache/juneau/server/AcceptCharsetTest.java | 123 --
.../server/BeanContextPropertiesTest.java | 37 -
.../juneau/server/CallbackStringsTest.java | 50 -
.../juneau/server/CharsetEncodingsTest.java | 96 --
.../apache/juneau/server/ClientVersionTest.java | 90 --
.../org/apache/juneau/server/ConfigTest.java | 58 -
.../org/apache/juneau/server/Constants.java | 53 -
.../org/apache/juneau/server/ContentTest.java | 706 ---------
.../java/org/apache/juneau/server/DTOs.java | 139 --
.../juneau/server/DefaultContentTypesTest.java | 497 -------
.../juneau/server/ErrorConditionsTest.java | 220 ---
.../org/apache/juneau/server/GroupsTest.java | 122 --
.../java/org/apache/juneau/server/GzipTest.java | 344 -----
.../apache/juneau/server/InheritanceTest.java | 126 --
.../apache/juneau/server/JacocoDummyTest.java | 37 -
.../apache/juneau/server/LargePojosTest.java | 83 --
.../org/apache/juneau/server/MessagesTest.java | 47 -
.../apache/juneau/server/NlsPropertyTest.java | 48 -
.../java/org/apache/juneau/server/NlsTest.java | 170 ---
.../apache/juneau/server/NoParserInputTest.java | 70 -
.../apache/juneau/server/OnPostCallTest.java | 121 --
.../org/apache/juneau/server/OnPreCallTest.java | 61 -
.../juneau/server/OptionsWithoutNlsTest.java | 51 -
.../juneau/server/OverlappingMethodsTest.java | 170 ---
.../org/apache/juneau/server/ParamsTest.java | 716 ---------
.../org/apache/juneau/server/ParsersTest.java | 162 ---
.../java/org/apache/juneau/server/PathTest.java | 44 -
.../org/apache/juneau/server/PathsTest.java | 1368 ------------------
.../apache/juneau/server/PropertiesTest.java | 48 -
.../apache/juneau/server/RestClientTest.java | 199 ---
.../org/apache/juneau/server/RestUtilsTest.java | 188 ---
.../apache/juneau/server/SerializersTest.java | 152 --
.../apache/juneau/server/StaticFilesTest.java | 56 -
.../apache/juneau/server/TestRestClient.java | 69 -
.../org/apache/juneau/server/TestUtils.java | 60 -
.../apache/juneau/server/TransformsTest.java | 68 -
.../java/org/apache/juneau/server/UrisTest.java | 918 ------------
.../apache/juneau/server/UrlContentTest.java | 74 -
.../juneau/server/UrlPathPatternTest.java | 39 -
.../juneau/server/test/AcceptCharsetTest.java | 123 ++
.../server/test/BeanContextPropertiesTest.java | 37 +
.../juneau/server/test/CallbackStringsTest.java | 50 +
.../server/test/CharsetEncodingsTest.java | 96 ++
.../juneau/server/test/ClientVersionTest.java | 90 ++
.../apache/juneau/server/test/ConfigTest.java | 59 +
.../apache/juneau/server/test/Constants.java | 53 +
.../apache/juneau/server/test/ContentTest.java | 706 +++++++++
.../org/apache/juneau/server/test/DTOs.java | 139 ++
.../server/test/DefaultContentTypesTest.java | 497 +++++++
.../juneau/server/test/ErrorConditionsTest.java | 220 +++
.../apache/juneau/server/test/GroupsTest.java | 122 ++
.../org/apache/juneau/server/test/GzipTest.java | 344 +++++
.../juneau/server/test/InheritanceTest.java | 126 ++
.../juneau/server/test/JacocoDummyTest.java | 38 +
.../juneau/server/test/LargePojosTest.java | 83 ++
.../apache/juneau/server/test/MessagesTest.java | 47 +
.../juneau/server/test/NlsPropertyTest.java | 48 +
.../org/apache/juneau/server/test/NlsTest.java | 170 +++
.../juneau/server/test/NoParserInputTest.java | 70 +
.../juneau/server/test/OnPostCallTest.java | 121 ++
.../juneau/server/test/OnPreCallTest.java | 61 +
.../server/test/OptionsWithoutNlsTest.java | 51 +
.../server/test/OverlappingMethodsTest.java | 170 +++
.../apache/juneau/server/test/ParamsTest.java | 716 +++++++++
.../apache/juneau/server/test/ParsersTest.java | 162 +++
.../org/apache/juneau/server/test/PathTest.java | 44 +
.../apache/juneau/server/test/PathsTest.java | 1368 ++++++++++++++++++
.../juneau/server/test/PropertiesTest.java | 48 +
.../juneau/server/test/RestClientTest.java | 199 +++
.../juneau/server/test/RestUtilsTest.java | 188 +++
.../juneau/server/test/SerializersTest.java | 152 ++
.../juneau/server/test/StaticFilesTest.java | 56 +
.../juneau/server/test/TestRestClient.java | 69 +
.../apache/juneau/server/test/TestUtils.java | 60 +
.../juneau/server/test/TransformsTest.java | 68 +
.../org/apache/juneau/server/test/UrisTest.java | 918 ++++++++++++
.../juneau/server/test/UrlContentTest.java | 74 +
.../juneau/server/test/UrlPathPatternTest.java | 40 +
.../juneau/server/RestServletContext.java | 114 +-
.../org/apache/juneau/server/vars/package.html | 41 +
pom.xml | 2 +-
207 files changed, 14160 insertions(+), 12064 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/.settings/org.eclipse.wst.html.core.prefs
----------------------------------------------------------------------
diff --git a/juneau-core/.settings/org.eclipse.wst.html.core.prefs b/juneau-core/.settings/org.eclipse.wst.html.core.prefs
index 926f31c..3b4d468 100644
--- a/juneau-core/.settings/org.eclipse.wst.html.core.prefs
+++ b/juneau-core/.settings/org.eclipse.wst.html.core.prefs
@@ -44,7 +44,7 @@ elemUnclosedEndTag=1
elemUnclosedStartTag=1
elemUnknownName=2
elemUnnecessaryEnd=2
-elementNamesToIgnore=jc,jd,jt,jk,js,jf,jsf,jsm,ja,xt,xa,xc,xs,mk,mv,cc,cs,ck,ce,cv,l,properties
+elementNamesToIgnore=jc,jd,jt,jk,js,jf,jsa,jsf,jsm,jss,ja,xt,xa,xc,xs,mk,mv,cc,cs,ck,ce,cv,l,properties
ignoreAttrNames=false
ignoreElementNames=true
piInvalidContent=2
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
index 0834363..f0225f3 100644
--- a/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/BeanContext.java
@@ -55,8 +55,8 @@ import org.apache.juneau.transform.*;
* The settings on a bean context are fixed at the point they are created by the factory.
*
*
- * <h5 class='topic'>BeanContext settings</h5>
- * <code>BeanContexts</code> have several settings that can be used to tweak behavior on how beans are handled.
+ * <h5 class='topic'>BeanContext configuration properties</h5>
+ * <code>BeanContexts</code> have several configuration properties that can be used to tweak behavior on how beans are handled.
* These are denoted as the static <jsf>BEAN_*</jsf> fields on this class.
* <p>
* Some settings (e.g. {@link BeanContext#BEAN_beansRequireDefaultConstructor}) are used to differentiate between bean and non-bean classes.
@@ -85,6 +85,189 @@ import org.apache.juneau.transform.*;
* </p>
*
*
+ * <h6 class='topic' id='ConfigProperties'>Properties associated with handling beans on serializers and parsers</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #BEAN_beansRequireDefaultConstructor}</td>
+ * <td>Beans require no-arg constructors.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_beansRequireSerializable}</td>
+ * <td>Beans require Serializable interface.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_beansRequireSettersForGetters}</td>
+ * <td>Beans require setters for getters.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_beansRequireSomeProperties}</td>
+ * <td>Beans require at least one property.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_beanMapPutReturnsOldValue}</td>
+ * <td>{@link BeanMap#put(String,Object) BeanMap.put()} method will return old property value.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_beanConstructorVisibility}</td>
+ * <td>Look for bean constructors with specified minimum visibility.</td>
+ * <td>{@link Visibility}</td>
+ * <td>{@link Visibility#PUBLIC}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_beanClassVisibility}</td>
+ * <td>Look for bean classes with specified minimum visibility.</td>
+ * <td>{@link Visibility}</td>
+ * <td>{@link Visibility#PUBLIC}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_beanFieldVisibility}</td>
+ * <td>Look for bean fields with specified minimum visibility.</td>
+ * <td>{@link Visibility}</td>
+ * <td>{@link Visibility#PUBLIC}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_methodVisibility}</td>
+ * <td>Look for bean methods with specified minimum visibility.</td>
+ * <td>{@link Visibility}</td>
+ * <td>{@link Visibility#PUBLIC}</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_useJavaBeanIntrospector}</td>
+ * <td>Use Java {@link Introspector} for determining bean properties.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_useInterfaceProxies}</td>
+ * <td>Use interface proxies.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_ignoreUnknownBeanProperties}</td>
+ * <td>Ignore unknown properties.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_ignoreUnknownNullBeanProperties}</td>
+ * <td>Ignore unknown properties with null values.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_ignorePropertiesWithoutSetters}</td>
+ * <td>Ignore bean properties without setters.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_ignoreInvocationExceptionsOnGetters}</td>
+ * <td>Ignore invocation errors on getters.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_ignoreInvocationExceptionsOnSetters}</td>
+ * <td>Ignore invocation errors on setters.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #BEAN_sortProperties}</td>
+ * <td>Sort bean properties in alphabetical order.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>
+ * {@link #BEAN_notBeanPackages}<br>
+ * {@link #BEAN_notBeanPackages_add}<br>
+ * {@link #BEAN_notBeanPackages_remove}
+ * </td>
+ * <td>Packages whose classes should not be considered beans.</td>
+ * <td><code>Set<String></code></td>
+ * <td>See details</td>
+ * </tr>
+ * <tr>
+ * <td>
+ * {@link #BEAN_notBeanClasses}<br>
+ * {@link #BEAN_notBeanClasses_add}<br>
+ * {@link #BEAN_notBeanClasses_remove}
+ * </td>
+ * <td>Classes that should not be considered beans.</td>
+ * <td><code>Set<Class></code></td>
+ * <td>empty set</td>
+ * </tr>
+ * <tr>
+ * <td>
+ * {@link #BEAN_beanFilters}<br>
+ * {@link #BEAN_beanFilters_add}<br>
+ * {@link #BEAN_beanFilters_remove}
+ * </td>
+ * <td>Bean filters to apply to beans.</td>
+ * <td><code>List<Class></code></td>
+ * <td>empty list</td>
+ * </tr>
+ * <tr>
+ * <td>
+ * {@link #BEAN_pojoSwaps}<br>
+ * {@link #BEAN_pojoSwaps_add}<br>
+ * {@link #BEAN_pojoSwaps_remove}
+ * </td>
+ * <td>POJO swaps to apply to java objects.</td>
+ * <td><code>List<Class></code></td>
+ * <td>empty list</td>
+ * </tr>
+ * <tr>
+ * <td>
+ * {@link #BEAN_implClasses}<br>
+ * {@link #BEAN_implClasses_put}
+ * </td>
+ * <td>Implementation classes for interfaces and abstract classes.</td>
+ * <td><code>Map<Class,Class></code></td>
+ * <td>empty map</td>
+ * </tr>
+ * <tr>
+ * <td>
+ * {@link #BEAN_beanDictionary}<br>
+ * {@link #BEAN_beanDictionary_add}<br>
+ * {@link #BEAN_beanDictionary_remove}
+ * </td>
+ * <td>Bean lookup dictionary.</td>
+ * <td><code>List<Class></code></td>
+ * <td>empty list</td>
+ * </tr>
+ * <tr>
+ * <td>
+ * {@link #BEAN_beanTypePropertyName}
+ * </td>
+ * <td>Name to use for the bean type property used to represent a bean type.</td>
+ * <td><code>String</code></td>
+ * <td><js>"_type"</js></td>
+ * </tr>
+ * <tr>
+ * <td>
+ * {@link #BEAN_defaultParser}
+ * </td>
+ * <td>Default parser to use when converting <code>Strings</code> to POJOs.</td>
+ * <td><code>Class</code></td>
+ * <td>{@link JsonParser}</td>
+ * </tr>
+ * </table>
+ *
+ *
* <h5 class='topic'>Bean Maps</h5>
* <p>
* {@link BeanMap BeanMaps} are wrappers around Java beans that allow properties to be retrieved and
@@ -190,9 +373,14 @@ import org.apache.juneau.transform.*;
@SuppressWarnings({"unchecked","rawtypes"})
public class BeanContext extends Context {
-
/**
- * Require no-arg constructor ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Beans require no-arg constructors.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beansRequireDefaultConstructor"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, a Java class must implement a default no-arg constructor to be considered a bean.
* <p>
@@ -201,7 +389,13 @@ public class BeanContext extends Context {
public static final String BEAN_beansRequireDefaultConstructor = "BeanContext.beansRequireDefaultConstructor";
/**
- * Require {@link Serializable} interface ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Beans require {@link Serializable} interface.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beansRequireSerializable"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, a Java class must implement the {@link Serializable} interface to be considered a bean.
* <p>
@@ -210,7 +404,13 @@ public class BeanContext extends Context {
public static final String BEAN_beansRequireSerializable = "BeanContext.beansRequireSerializable";
/**
- * Require setters for getters ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Beans require setters for getters.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beansRequireSettersForGetters"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, only getters that have equivalent setters will be considered as properties on a bean.
* Otherwise, they will be ignored.
@@ -218,7 +418,13 @@ public class BeanContext extends Context {
public static final String BEAN_beansRequireSettersForGetters = "BeanContext.beansRequireSettersForGetters";
/**
- * Require some properties ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Beans require at least one property.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beansRequireSomeProperties"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, then a Java class must contain at least 1 property to be considered a bean.
* <p>
@@ -227,7 +433,13 @@ public class BeanContext extends Context {
public static final String BEAN_beansRequireSomeProperties = "BeanContext.beansRequireSomeProperties";
/**
- * Put returns old value ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> {@link BeanMap#put(String,Object) BeanMap.put()} method will return old property value.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beanMapPutReturnsOldValue"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, then the {@link BeanMap#put(String,Object) BeanMap.put()} method will return old property values.
* <p>
@@ -236,12 +448,25 @@ public class BeanContext extends Context {
public static final String BEAN_beanMapPutReturnsOldValue = "BeanContext.beanMapPutReturnsOldValue";
/**
- * Look for bean constructors with the specified minimum visibility ({@link Visibility}, default={@link Visibility#PUBLIC}).
+ * <b>Configuration property:</b> Look for bean constructors with the specified minimum visibility.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beanConstructorVisibility"</js>
+ * <li><b>Data type:</b> {@link Visibility}
+ * <li><b>Default:</b> {@link Visibility#PUBLIC}
+ * </ul>
+ * <p>
*/
public static final String BEAN_beanConstructorVisibility = "BeanContext.beanConstructorVisibility";
/**
- * Look for bean classes with the specified minimum visibility ({@link Visibility}, default={@link Visibility#PUBLIC}).
+ * <b>Configuration property:</b> Look for bean classes with the specified minimum visibility.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beanClassVisibility"</js>
+ * <li><b>Data type:</b> {@link Visibility}
+ * <li><b>Default:</b> {@link Visibility#PUBLIC}
+ * </ul>
* <p>
* Classes are not considered beans unless they meet the minimum visibility requirements.
* For example, if the visibility is <code>PUBLIC</code> and the bean class is <jk>protected</jk>, then
@@ -250,7 +475,13 @@ public class BeanContext extends Context {
public static final String BEAN_beanClassVisibility = "BeanContext.beanClassVisibility";
/**
- * Look for bean fields with the specified minimum visibility ({@link Visibility}, default={@link Visibility#PUBLIC}).
+ * <b>Configuration property:</b> Look for bean fields with the specified minimum visibility.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beanFieldVisibility"</js>
+ * <li><b>Data type:</b> {@link Visibility}
+ * <li><b>Default:</b> {@link Visibility#PUBLIC}
+ * </ul>
* <p>
* Fields are not considered bean properties unless they meet the minimum visibility requirements.
* For example, if the visibility is <code>PUBLIC</code> and the bean field is <jk>protected</jk>, then
@@ -261,7 +492,13 @@ public class BeanContext extends Context {
public static final String BEAN_beanFieldVisibility = "BeanContext.beanFieldVisibility";
/**
- * Look for bean methods with the specified minimum visibility ({@link Visibility}, default={@link Visibility#PUBLIC}).
+ * <b>Configuration property:</b> Look for bean methods with the specified minimum visibility.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.methodVisibility"</js>
+ * <li><b>Data type:</b> {@link Visibility}
+ * <li><b>Default:</b> {@link Visibility#PUBLIC}
+ * </ul>
* <p>
* Methods are not considered bean getters/setters unless they meet the minimum visibility requirements.
* For example, if the visibility is <code>PUBLIC</code> and the bean method is <jk>protected</jk>, then
@@ -270,7 +507,13 @@ public class BeanContext extends Context {
public static final String BEAN_methodVisibility = "BeanContext.methodVisibility";
/**
- * Use Java {@link Introspector} for determining bean properties ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Use Java {@link Introspector} for determining bean properties.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.useJavaBeanIntrospector"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* Using the built-in Java bean introspector will not pick up fields or non-standard getters/setters.
* Most {@link Bean @Bean} annotations will be ignored.
@@ -278,7 +521,13 @@ public class BeanContext extends Context {
public static final String BEAN_useJavaBeanIntrospector = "BeanContext.useJavaBeanIntrospector";
/**
- * Use interface proxies ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Use interface proxies.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.useInterfaceProxies"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, then interfaces will be instantiated as proxy classes through the use of an {@link InvocationHandler}
* if there is no other way of instantiating them.
@@ -286,7 +535,13 @@ public class BeanContext extends Context {
public static final String BEAN_useInterfaceProxies = "BeanContext.useInterfaceProxies";
/**
- * Ignore unknown properties ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Ignore unknown properties.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.ignoreUnknownBeanProperties"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, trying to set a value on a non-existent bean property will silently be ignored.
* Otherwise, a {@code RuntimeException} is thrown.
@@ -294,7 +549,13 @@ public class BeanContext extends Context {
public static final String BEAN_ignoreUnknownBeanProperties = "BeanContext.ignoreUnknownBeanProperties";
/**
- * Ignore unknown properties with null values ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Ignore unknown properties with null values.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.ignoreUnknownNullBeanProperties"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, trying to set a <jk>null</jk> value on a non-existent bean property will silently be ignored.
* Otherwise, a {@code RuntimeException} is thrown.
@@ -302,7 +563,13 @@ public class BeanContext extends Context {
public static final String BEAN_ignoreUnknownNullBeanProperties = "BeanContext.ignoreUnknownNullBeanProperties";
/**
- * Ignore properties without setters ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Ignore properties without setters.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.ignorePropertiesWithoutSetters"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, trying to set a value on a bean property without a setter will silently be ignored.
* Otherwise, a {@code RuntimeException} is thrown.
@@ -310,7 +577,13 @@ public class BeanContext extends Context {
public static final String BEAN_ignorePropertiesWithoutSetters = "BeanContext.ignorePropertiesWithoutSetters";
/**
- * Ignore invocation errors on getters ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Ignore invocation errors on getters.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.ignoreInvocationExceptionsOnGetters"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, errors thrown when calling bean getter methods will silently be ignored.
* Otherwise, a {@code BeanRuntimeException} is thrown.
@@ -318,7 +591,13 @@ public class BeanContext extends Context {
public static final String BEAN_ignoreInvocationExceptionsOnGetters = "BeanContext.ignoreInvocationExceptionsOnGetters";
/**
- * Ignore invocation errors on setters ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Ignore invocation errors on setters.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.ignoreInvocationExceptionsOnSetters"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* If <jk>true</jk>, errors thrown when calling bean setter methods will silently be ignored.
* Otherwise, a {@code BeanRuntimeException} is thrown.
@@ -326,7 +605,13 @@ public class BeanContext extends Context {
public static final String BEAN_ignoreInvocationExceptionsOnSetters = "BeanContext.ignoreInvocationExceptionsOnSetters";
/**
- * Sort bean properties in alphabetical order ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Sort bean properties in alphabetical order.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.sortProperties"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* When <jk>true</jk>, all bean properties will be serialized and access in alphabetical order.
* Otherwise, the natural order of the bean properties is used which is dependent on the
@@ -341,21 +626,26 @@ public class BeanContext extends Context {
public static final String BEAN_sortProperties = "BeanContext.sortProperties";
/**
- * List of packages whose classes should not be considered beans (<code>Set<String></code>).
+ * <b>Configuration property:</b> Packages whose classes should not be considered beans.
* <p>
- * When specified, the current list of ignore packages are appended to.
- * The default list of ignore packages are as follows:
* <ul>
- * <li><code>java.lang</code>
- * <li><code>java.lang.annotation</code>
- * <li><code>java.lang.ref</code>
- * <li><code>java.lang.reflect</code>
- * <li><code>java.io</code>
- * <li><code>java.net</code>
- * <li><code>java.nio.*</code>
- * <li><code>java.util.*</code>
+ * <li><b>Name:</b> <js>"BeanContext.notBeanPackages.set"</js>
+ * <li><b>Data type:</b> <code>Set<String></code>
+ * <li><b>Default:</b>
+ * <ul>
+ * <li><code>java.lang</code>
+ * <li><code>java.lang.annotation</code>
+ * <li><code>java.lang.ref</code>
+ * <li><code>java.lang.reflect</code>
+ * <li><code>java.io</code>
+ * <li><code>java.net</code>
+ * <li><code>java.nio.*</code>
+ * <li><code>java.util.*</code>
+ * </ul>
* </ul>
* <p>
+ * When specified, the current list of ignore packages are appended to.
+ * <p>
* Any classes within these packages will be serialized to strings using {@link Object#toString()}.
* <p>
* Note that you can specify prefix patterns to include all subpackages.
@@ -363,17 +653,23 @@ public class BeanContext extends Context {
public static final String BEAN_notBeanPackages = "BeanContext.notBeanPackages.set";
/**
- * Add to the list of packages whose classes should not be considered beans.
+ * <b>Configuration property:</b> Add to packages whose classes should not be considered beans.
*/
public static final String BEAN_notBeanPackages_add = "BeanContext.notBeanPackages.set.add";
/**
- * Remove from the list of packages whose classes should not be considered beans.
+ * <b>Configuration property:</b> Remove from packages whose classes should not be considered beans.
*/
public static final String BEAN_notBeanPackages_remove = "BeanContext.notBeanPackages.set.remove";
/**
- * An explicit list of Java classes to be excluded from consideration as being beans (<code>Set<Class></code>).
+ * <b>Configuration property:</b> Classes to be excluded from consideration as being beans.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.notBeanClasses.set"</js>
+ * <li><b>Data type:</b> <code>Set<Class></code>
+ * <li><b>Default:</b> empty set
+ * </ul>
* <p>
* Not-bean classes are typically converted to <code>Strings</code> during serialization even if they
* appear to be bean-like.
@@ -381,17 +677,23 @@ public class BeanContext extends Context {
public static final String BEAN_notBeanClasses = "BeanContext.notBeanClasses.set";
/**
- * Add to the list of packages whose classes should not be considered beans.
+ * <b>Configuration property:</b> Add to classes that should not be considered beans.
*/
public static final String BEAN_notBeanClasses_add = "BeanContext.notBeanClasses.set.add";
/**
- * Remove from the list of packages whose classes should not be considered beans.
+ * <b>Configuration property:</b> Remove from classes that should not be considered beans.
*/
public static final String BEAN_notBeanClasses_remove = "BeanContext.notBeanClasses.set.remove";
/**
- * List of bean filters registered on the bean context (<code>List<Class></code>).
+ * <b>Configuration property:</b> Bean filters to apply to beans.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beanFilters.list"</js>
+ * <li><b>Data type:</b> <code>List<Class></code>
+ * <li><b>Default:</b> empty list
+ * </ul>
* <p>
* This is a programmatic equivalent to the {@link Bean @Bean} annotation.
* It's useful when you want to use the Bean annotation functionality, but you don't have the ability
@@ -399,9 +701,9 @@ public class BeanContext extends Context {
* <p>
* There are two category of classes that can be passed in through this method:
* <ul class='spaced-list'>
- * <li>Subclasses of {@link BeanFilterBuilder}.
+ * <li>Subclasses of {@link BeanFilterBuilder}.
* These must have a public no-arg constructor.
- * <li>Bean interface classes.
+ * <li>Bean interface classes.
* A shortcut for defining a {@link InterfaceBeanFilterBuilder}.
* Any subclasses of an interface class will only have properties defined on the interface.
* All other bean properties will be ignored.
@@ -410,20 +712,26 @@ public class BeanContext extends Context {
public static final String BEAN_beanFilters = "BeanContext.beanFilters.list";
/**
- * Add to the list of bean filters.
+ * <b>Configuration property:</b> Add to bean filters.
*/
public static final String BEAN_beanFilters_add = "BeanContext.beanFilters.list.add";
/**
- * Remove from the list of bean filters.
+ * <b>Configuration property:</b> Remove from bean filters.
*/
public static final String BEAN_beanFilters_remove = "BeanContext.beanFilters.list.remove";
/**
- * List of POJO swaps registered on the bean context (<code>List<Class></code>).
+ * <b>Configuration property:</b> POJO swaps to apply to Java objects.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.pojoSwaps.list"</js>
+ * <li><b>Data type:</b> <code>List<Class></code>
+ * <li><b>Default:</b> empty list
+ * </ul>
* <p>
* There are two category of classes that can be passed in through this method:
- * <ul class='spaced-list'>
+ * <ul>
* <li>Subclasses of {@link PojoSwap}.
* <li>Surrogate classes. A shortcut for defining a {@link SurrogateSwap}.
* </ul>
@@ -431,17 +739,23 @@ public class BeanContext extends Context {
public static final String BEAN_pojoSwaps = "BeanContext.pojoSwaps.list";
/**
- * Add to the list of POJO swap classes.
+ * <b>Configuration property:</b> Add to POJO swap classes.
*/
public static final String BEAN_pojoSwaps_add = "BeanContext.pojoSwaps.list.add";
/**
- * Remove from the list of POJO swap classes.
+ * <b>Configuration property:</b> Remove from POJO swap classes.
*/
public static final String BEAN_pojoSwaps_remove = "BeanContext.pojoSwaps.list.remove";
/**
- * Specifies implementation classes for an interface or abstract class (<code>Map<Class,Class></code>).
+ * <b>Configuration property:</b> Implementation classes for interfaces and abstract classes.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.implClasses.map"</js>
+ * <li><b>Data type:</b> <code>Map<Class,Class></code>
+ * <li><b>Default:</b> empty map
+ * </ul>
* <p>
* For interfaces and abstract classes this method can be used to specify an implementation
* class for the interface/abstract class so that instances of the implementation
@@ -450,12 +764,18 @@ public class BeanContext extends Context {
public static final String BEAN_implClasses = "BeanContext.implClasses.map";
/**
- * Adds a new map entry to the {@link #BEAN_implClasses} property.
+ * <b>Configuration property:</b> Add an implementation class.
*/
public static final String BEAN_implClasses_put = "BeanContext.implClasses.map.put";
/**
- * Specifies the list of classes that make up the bean dictionary for this bean context (<code>List<Class></code>).
+ * <b>Configuration property:</b> Bean lookup dictionary.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beanDictionary.list"</js>
+ * <li><b>Data type:</b> <code>List<Class></code>
+ * <li><b>Default:</b> empty list
+ * </ul>
* <p>
* This list can consist of the following class types:
* <ul>
@@ -467,22 +787,37 @@ public class BeanContext extends Context {
public static final String BEAN_beanDictionary = "BeanContext.beanDictionary.list";
/**
- * Add to the bean dictionary list.
+ * <b>Configuration property:</b> Add to bean dictionary.
*/
public static final String BEAN_beanDictionary_add = "BeanContext.beanDictionary.list.add";
/**
- * Remove from the bean dictionary list.
+ * <b>Configuration property:</b> Remove from bean dictionary.
*/
public static final String BEAN_beanDictionary_remove = "BeanContext.beanDictionary.list.remove";
/**
- * The name to use for the bean type properties used to represent a bean type. ({@link String}, default=<js>"_type"</js>).
+ * <b>Configuration property:</b> Name to use for the bean type properties used to represent a bean type.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.beanTypePropertyName"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"_type"</js>
+ * </ul>
+ * <p>
*/
public static final String BEAN_beanTypePropertyName = "BeanContext.beanTypePropertyName";
/**
- * Specifies the default parser to use when converting <code>Strings</code> to POJOs in the {@link BeanContext#convertToType(Object, Class)} method (<code>Class</code>).
+ * <b>Configuration property:</b> Default parser to use when converting <code>Strings</code> to POJOs.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"BeanContext.defaultParser"</js>
+ * <li><b>Data type:</b> <code>Class</code>
+ * <li><b>Default:</b> {@link JsonSerializer}
+ * </ul>
+ * <p>
+ * Used in the in the {@link BeanContext#convertToType(Object, Class)} method.�
*/
public static final String BEAN_defaultParser = "BeanContext.defaultParser";
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/csv/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/csv/package.html b/juneau-core/src/main/java/org/apache/juneau/csv/package.html
index 9dc8113..249baca 100644
--- a/juneau-core/src/main/java/org/apache/juneau/csv/package.html
+++ b/juneau-core/src/main/java/org/apache/juneau/csv/package.html
@@ -56,7 +56,5 @@
}
</script>
-This code is currently work-in-progress.
-
</body>
</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
index 3962821..9f12272 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
@@ -40,13 +40,73 @@ import org.apache.juneau.*;
* Several built-in runtime variable types are defined, and the API can be extended to include user-defined variables.
* </p>
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the HTML document serializer</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #HTMLDOC_title}</td>
+ * <td>Page title.</td>
+ * <td><code>String</code></td>
+ * <td><jk>null</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #HTMLDOC_description}</td>
+ * <td>Page description.</td>
+ * <td><code>String</code></td>
+ * <td><jk>null</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #HTMLDOC_links}<br>{@link #HTMLDOC_links_put}</td>
+ * <td>Page links.</td>
+ * <td><code>Map<String,String></code></td>
+ * <td>empty map</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #HTMLDOC_cssUrl}</td>
+ * <td>Stylesheet URL.</td>
+ * <td><code>String</code></td>
+ * <td><js>"style.css"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #HTMLDOC_cssImports}<br>{@link #HTMLDOC_cssImports_add}</td>
+ * <td>CSS imports.</td>
+ * <td><code>List<String></code></td>
+ * <td>empty list</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #HTMLDOC_nowrap}</td>
+ * <td>Prevent word wrap on page.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../html/HtmlSerializerContext.html#ConfigProperties'>HtmlSerializerContext</a> - Configurable properties on the HTML serializer.
+ * </ul>
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class HtmlDocSerializerContext extends HtmlSerializerContext {
/**
- * Adds a title at the top of a page.
- *
+ * <b>Configuration property:</b> Page title.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.title"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * </ul>
+ * <p>
* <dl>
* <dt>Example:</dt>
* <dd>
@@ -78,8 +138,14 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
public static final String HTMLDOC_title = "HtmlSerializer.title";
/**
- * Adds a description right below the title of a page.
- *
+ * <b>Configuration property:</b> Page description.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.description"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * </ul>
+ * <p>
* <dl>
* <dt>Example:</dt>
* <dd>
@@ -111,6 +177,14 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
public static final String HTMLDOC_description = "HtmlSerializer.description";
/**
+ * <b>Configuration property:</b> Page links.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.links.map"</js>
+ * <li><b>Data type:</b> <code>Map<String,String></code>
+ * <li><b>Default:</b> empty map
+ * </ul>
+ * <p>
* Adds a list of hyperlinks immediately under the title and description but above the content of the page.
* <p>
* This can be used to provide convenient hyperlinks when viewing the REST interface from a browser.
@@ -145,32 +219,56 @@ public final class HtmlDocSerializerContext extends HtmlSerializerContext {
* </dd>
* </dl>
*/
- public static final String HTMLDOC_links = "HtmlDocSerializer.links";
+ public static final String HTMLDOC_links = "HtmlDocSerializer.links.map";
/**
- * Similar to {@link #HTMLDOC_links} except appends on to the existing list of links.
+ * <b>Configuration property:</b> Add to the {@link #HTMLDOC_links} property.
*/
- public static final String HTMLDOC_links_add = "HtmlDocSerializer.links.add";
+ public static final String HTMLDOC_links_put = "HtmlDocSerializer.links.map.put";
/**
- * Adds a link to the specified stylesheet URL (<l>String</l>, default=<jk>null</jk>).
+ * <b>Configuration property:</b> Stylesheet URL.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.cssUrl"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"style.css"</js>
+ * </ul>
+ * <p>
+ * Adds a link to the specified stylesheet URL.
* <p>
- * If not specified, defaults to the built-in stylesheet located at <js>"/servletPath/style.css"</js>.
- * Note that this stylesheet is controlled by the <code><ja>@RestResource</ja>.style()</code> annotation.
+ * If not specified, defaults to the built-in stylesheet located at <js>"style.css"</js>.
+ * Note that this stylesheet is controlled by the <code><ja>@RestResource</ja>.stylesheet()</code> annotation.
*/
public static final String HTMLDOC_cssUrl = "HtmlDocSerializer.cssUrl";
/**
- * Imports the specified CSS page URLs into the page (<l>String[]</l>, default=<code>[]</code>).
+ * <b>Configuration property:</b> CSS imports.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.cssImports.list"</js>
+ * <li><b>Data type:</b> <code>List<String></code>
+ * <li><b>Default:</b> empty list
+ * </ul>
+ * <p>
+ * Imports the specified CSS page URLs into the page.
*/
- public static final String HTMLDOC_cssImports = "HtmlDocSerializer.cssImports";
+ public static final String HTMLDOC_cssImports = "HtmlDocSerializer.cssImports.list";
/**
- * Append to the {@link #HTMLDOC_cssImports} property.
+ * <b>Configuration property:</b> Add to the {@link #HTMLDOC_cssImports} property.
*/
- public static final String HTMLDOC_cssImports_add = "HtmlDocSerializer.cssImports.add";
+ public static final String HTMLDOC_cssImports_add = "HtmlDocSerializer.cssImports.list.add";
/**
+ * <b>Configuration property:</b> Prevent word wrap on page.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.nowrap"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
+ * <p>
* Adds <js>"* {white-space:nowrap}"</js> to the style header to prevent word wrapping.
*/
public static final String HTMLDOC_nowrap = "HtmlDocSerializer.nowrap";
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java
index 44fe215..2a145d4 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlParserContext.java
@@ -36,6 +36,21 @@ import org.apache.juneau.parser.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the HTML parser</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers.
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public final class HtmlParserContext extends ParserContext {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java
index b634645..216bfaa 100644
--- a/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java
@@ -34,12 +34,57 @@ import org.apache.juneau.xml.*;
* <p>
* See {@link ContextFactory} for more information about context properties.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties on the HTML serializer</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #HTML_uriAnchorText}</td>
+ * <td>Anchor text source.</td>
+ * <td><code>String</code></td>
+ * <td><js>"TO_STRING"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #HTML_detectLinksInStrings}</td>
+ * <td>Look for URLs in {@link String Strings}.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #HTML_lookForLabelParameters}</td>
+ * <td>Look for link labels in the <js>"label"</js> parameter of the URL.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #HTML_labelParameter}</td>
+ * <td>The parameter name to use when using {@link #HTML_lookForLabelParameters}.</td>
+ * <td><code>String</code></td>
+ * <td><js>"label"</js></td>
+ * </tr>
+ * </table>
+ *
+ * <h6 class='topic'>Configurable properties inherited from parent classes</h6>
+ * <ul class='javahierarchy'>
+ * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ * <ul>
+ * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ * </ul>
+ * </ul>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
public class HtmlSerializerContext extends XmlSerializerContext {
/**
- * Anchor text source ({@link String}, default={@link #TO_STRING}).
+ * <b>Configuration property:</b> Anchor text source.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.uriAnchorText"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"toString"</js>
+ * </ul>
* <p>
* When creating anchor tags (e.g. <code><xt><a</xt> <xa>href</xa>=<xs>'...'</xs><xt>></xt>text<xt></a></xt></code>)
* in HTML, this setting defines what to set the inner text to.
@@ -68,7 +113,13 @@ public class HtmlSerializerContext extends XmlSerializerContext {
/**
- * Look for URLs in {@link String Strings} ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Look for URLs in {@link String Strings}.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.detectLinksInStrings"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If a string looks like a URL (e.g. starts with <js>"http://"</js> or <js>"https://"</js>, then treat it like a URL
* and make it into a hyperlink based on the rules specified by {@link #HTML_uriAnchorText}.
@@ -76,7 +127,13 @@ public class HtmlSerializerContext extends XmlSerializerContext {
public static final String HTML_detectLinksInStrings = "HtmlSerializer.detectLinksInStrings";
/**
- * Look for link labels in the <js>"label"</js> parameter of the URL ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Look for link labels in the <js>"label"</js> parameter of the URL.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.lookForLabelParameters"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If the URL has a label parameter (e.g. <js>"?label=foobar"</js>), then use that as the anchor text of the link.
* <p>
@@ -85,7 +142,14 @@ public class HtmlSerializerContext extends XmlSerializerContext {
public static final String HTML_lookForLabelParameters = "HtmlSerializer.lookForLabelParameters";
/**
- * The parameter name to use when using {@link #HTML_lookForLabelParameters} ({@link String}, default=<js>"label"</js>).
+ * <b>Configuration property:</b> The parameter name to use when using {@link #HTML_lookForLabelParameters}.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.labelParameter"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"label"</js>
+ * </ul>
+ * <p>
*/
public static final String HTML_labelParameter = "HtmlSerializer.labelParameter";
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/internal/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/internal/package.html b/juneau-core/src/main/java/org/apache/juneau/internal/package.html
new file mode 100644
index 0000000..181414a
--- /dev/null
+++ b/juneau-core/src/main/java/org/apache/juneau/internal/package.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<!--
+/***************************************************************************************************************************
+ * 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.
+ *
+ ***************************************************************************************************************************/
+ -->
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <style type="text/css">
+ /* For viewing in Page Designer */
+ @IMPORT url("../../../../../../javadoc.css");
+
+ /* For viewing in REST interface */
+ @IMPORT url("../htdocs/javadoc.css");
+ body {
+ margin: 20px;
+ }
+ </style>
+ <script>
+ /* Replace all @code and @link tags. */
+ window.onload = function() {
+ document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>');
+ document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>');
+ }
+ </script>
+</head>
+<body>
+<p>Internal classes not meant for external use</p>
+
+</body>
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfCommonContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfCommonContext.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfCommonContext.java
index 449cd9a..eef8653 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfCommonContext.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfCommonContext.java
@@ -21,11 +21,204 @@ import org.apache.juneau.xml.annotation.*;
/**
* Configurable properties common to both the {@link RdfSerializer} and {@link RdfParser} classes.
*
+ *
+ * <h6 class='topic' id='ConfigProperties'>Configurable properties common to the RDF serializers and parsers</h6>
+ * <table class='styled' style='border-collapse: collapse;'>
+ * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr>
+ * <tr>
+ * <td>{@link #RDF_language}</td>
+ * <td>RDF language.</td>
+ * <td><code>String</code></td>
+ * <td><js>"RDF/XML-ABBREV"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_juneauNs}</td>
+ * <td>XML namespace for Juneau properties.</td>
+ * <td>{@link Namespace}</td>
+ * <td><code>{j:<js>'http://www.ibm.com/juneau/'</js>}</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_juneauBpNs}</td>
+ * <td>Default XML namespace for bean properties.</td>
+ * <td>{@link Namespace}</td>
+ * <td><code>{j:<js>'http://www.ibm.com/juneaubp/'</js>}</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_useXmlNamespaces}</td>
+ * <td>Reuse XML namespaces when RDF namespaces not specified.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_arp_iriRules}</td>
+ * <td>RDF/XML property: <code>iri_rules</code>.</td>
+ * <td><code>String</code></td>
+ * <td><js>"lax"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_arp_errorMode}</td>
+ * <td>RDF/XML ARP property: <code>error-mode</code>.</td>
+ * <td><code>String</code></td>
+ * <td><js>"lax"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_arp_embedding}</td>
+ * <td>RDF/XML ARP property: <code>embedding</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_arp_err_}</td>
+ * <td>RDF/XML ARP property: <code>ERR_xxx</code>.</td>
+ * <td><code>String</code></td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_arp_warn_}</td>
+ * <td>RDF/XML ARP property: <code>WARN_xxx</code>.</td>
+ * <td><code>String</code></td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_arp_ign_}</td>
+ * <td>RDF/XML ARP property: <code>IGN_xxx</code>.</td>
+ * <td><code>String</code></td>
+ * <td></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_xmlBase}</td>
+ * <td>RDF/XML property: <code>xmlbase</code>.</td>
+ * <td><code>String</code></td>
+ * <td><jk>null</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_longId}</td>
+ * <td>RDF/XML property: <code>longId</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_allowBadUris}</td>
+ * <td>RDF/XML property: <code>allowBadURIs</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_relativeUris}</td>
+ * <td>RDF/XML property: <code>relativeURIs</code>.</td>
+ * <td><code>String</code></td>
+ * <td><js>"same-document, absolute, relative, parent"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_showXmlDeclaration}</td>
+ * <td>RDF/XML property: <code>showXmlDeclaration</code>.</td>
+ * <td><code>String</code></td>
+ * <td><js>"default"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_showDoctypeDeclaration}</td>
+ * <td>RDF/XML property: <code>showDoctypeDeclaration</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_tab}</td>
+ * <td>RDF/XML property: <code>tab</code>.</td>
+ * <td><code>Integer</code></td>
+ * <td><code>2</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_attributeQuoteChar}</td>
+ * <td>RDF/XML property: <code>attributeQuoteChar</code>.</td>
+ * <td><code>Character</code></td>
+ * <td><js>'"'</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_rdfxml_blockRules}</td>
+ * <td>RDF/XML property: <code>blockRules</code>.</td>
+ * <td><code>String</code></td>
+ * <td><js>""</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_minGap}</td>
+ * <td>N3/Turtle property: <code>minGap</code>.</td>
+ * <td><code>Integer</code></td>
+ * <td><code>1</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_objectLists}</td>
+ * <td>N3/Turtle property: <code>objectLists</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_subjectColumn}</td>
+ * <td>N3/Turtle property: <code>subjectColumn</code>.</td>
+ * <td>code>Integer</code></td>
+ * <td>indent column</td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_propertyColumn}</td>
+ * <td>N3/Turtle property: <code>propertyColumn</code>.</td>
+ * <td><code>Integer</code></td>
+ * <td><code>8</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_indentProperty}</td>
+ * <td>N3/Turtle property: <code>indentProperty</code>.</td>
+ * <td><code>Integer</code></td>
+ * <td><code>6</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_widePropertyLen}</td>
+ * <td>N3/Turtle property: <code>widePropertyLen</code>.</td>
+ * <td><code>Integer</code></td>
+ * <td><code>20</code></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_abbrevBaseUri}</td>
+ * <td>N3/Turtle property: <code>abbrevBaseURI</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_usePropertySymbols}</td>
+ * <td>N3/Turtle property: <code>usePropertySymbols</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_useTripleQuotedStrings}</td>
+ * <td>N3/Turtle property: <code>useTripleQuotedStrings</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_n3_useDoubles}</td>
+ * <td>N3/Turtle property: <code>useDoubles</code>.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>true</jk></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_collectionFormat}</td>
+ * <td>RDF format for representing collections and arrays.</td>
+ * <td><code>String</code></td>
+ * <td><js>"DEFAULT"</js></td>
+ * </tr>
+ * <tr>
+ * <td>{@link #RDF_looseCollections}</td>
+ * <td>Collections should be serialized and parsed as loose collections.</td>
+ * <td><code>Boolean</code></td>
+ * <td><jk>false</jk></td>
+ * </tr>
+ * </table>
+ *
+ *
* @author James Bognar (james.bognar@salesforce.com)
*/
@SuppressWarnings("serial")
public interface RdfCommonContext {
-// TODO - RENAME?
+
/**
* Maps RDF writer names to property prefixes that apply to them.
*/
@@ -41,7 +234,13 @@ public interface RdfCommonContext {
}};
/**
- * The RDF language to serialize to ({@link String}, default=<js>"RDF/XML-ABBREV"</js>).
+ * <b>Configuration property:</b> RDF language.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.language"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"RDF/XML-ABBREV"</js>
+ * </ul>
* <p>
* Can be any of the following:
* <ul class='spaced-list'>
@@ -64,17 +263,35 @@ public interface RdfCommonContext {
public static final String RDF_language = "Rdf.language";
/**
- * The XML namespace for Juneau properties ({@link Namespace}, default=<js>{j:'http://www.ibm.com/juneau/'}</js>).
+ * <b>Configuration property:</b> XML namespace for Juneau properties.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.juneauNs"</js>
+ * <li><b>Data type:</b> {@link Namespace}
+ * <li><b>Default:</b> <code>{j:<js>'http://www.ibm.com/juneau/'</js>}</code>
+ * </ul>
*/
public static final String RDF_juneauNs = "Rdf.juneauNs";
/**
- * The default XML namespace for bean properties ({@link Namespace}, default=<js>{j:'http://www.ibm.com/juneaubp/'}</js>).
+ * <b>Configuration property:</b> Default XML namespace for bean properties.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.juneauBpNs"</js>
+ * <li><b>Data type:</b> {@link Namespace}
+ * <li><b>Default:</b> <code>{j:<js>'http://www.ibm.com/juneaubp/'</js>}</code>
+ * </ul>
*/
public static final String RDF_juneauBpNs = "Rdf.juneauBpNs";
/**
- * Reuse XML namespaces when RDF namespaces not specified ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> Reuse XML namespaces when RDF namespaces not specified.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.useXmlNamespaces"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* When specified, namespaces defined using {@link XmlNs} and {@link Xml} will be inherited by the RDF serializers.
* Otherwise, namespaces will be defined using {@link RdfNs} and {@link Rdf}.
@@ -82,7 +299,13 @@ public interface RdfCommonContext {
public static final String RDF_useXmlNamespaces = "Rdf.useXmlNamespaces";
/**
- * RDF/XML property: <code>iri_rules</code> ({@link String}, default=<js>"lax"</js>).
+ * <b>Configuration property:</b> RDF/XML property: <code>iri_rules</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.iri-rules"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"lax"</js>
+ * </ul>
* <p>
* Set the engine for checking and resolving.
* <p>
@@ -96,7 +319,13 @@ public interface RdfCommonContext {
public static final String RDF_arp_iriRules = "Rdf.jena.rdfXml.iri-rules";
/**
- * RDF/XML ARP property: <code>error-mode</code> ({@link String}, default=<js>"lax"</js>).
+ * <b>Configuration property:</b> RDF/XML ARP property: <code>error-mode</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.error-mode"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"lax"</js>
+ * </ul>
* <p>
* This allows a coarse-grained approach to control of error handling.
* <p>
@@ -122,7 +351,13 @@ public interface RdfCommonContext {
public static final String RDF_arp_errorMode = "Rdf.jena.rdfXml.error-mode";
/**
- * RDF/XML ARP property: <code>embedding</code> ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> RDF/XML ARP property: <code>embedding</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.embedding"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* Sets ARP to look for RDF embedded within an enclosing XML document.
* <p>
@@ -134,7 +369,12 @@ public interface RdfCommonContext {
public static final String RDF_arp_embedding = "Rdf.jena.rdfXml.embedding";
/**
- * RDF/XML ARP property: <code>ERR_xxx</code> ({@link String}).
+ * <b>Configuration property:</b> RDF/XML ARP property: <code>ERR_xxx</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.ERR_"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * </ul>
* <p>
* Provides fine-grained control over detected error conditions.
* <p>
@@ -155,28 +395,50 @@ public interface RdfCommonContext {
public static final String RDF_arp_err_ = "Rdf.jena.rdfXml.ERR_";
/**
- * RDF/XML ARP property: <code>WARN_xxx</code> ({@link String}).
+ * <b>Configuration property:</b> RDF/XML ARP property: <code>WARN_xxx</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.WARN_"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * </ul>
* <p>
* See {@link #RDF_arp_err_} for details.
*/
public static final String RDF_arp_warn_ = "Rdf.jena.rdfXml.WARN_";
/**
- * RDF/XML ARP property: <code>IGN_xxx</code> ({@link String}).
+ * RDF/XML ARP property: <code>IGN_xxx</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.IGN_"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * </ul>
* <p>
* See {@link #RDF_arp_err_} for details.
*/
public static final String RDF_arp_ign_ = "Rdf.jena.rdfXml.IGN_";
/**
- * RDF/XML property: <code>xmlbase</code> ({@link String}, default=<jk>null</jk>).
+ * <b>Configuration property:</b> RDF/XML property: <code>xmlbase</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.xmlbase"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * </ul>
* <p>
* The value to be included for an <xa>xml:base</xa> attribute on the root element in the file.
*/
public static final String RDF_rdfxml_xmlBase = "Rdf.jena.rdfXml.xmlbase";
/**
- * RDF/XML property: <code>longId</code> ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> RDF/XML property: <code>longId</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.longId"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* Whether to use long ID's for anon resources.
* Short ID's are easier to read, but can run out of memory on very large models.
@@ -184,14 +446,26 @@ public interface RdfCommonContext {
public static final String RDF_rdfxml_longId = "Rdf.jena.rdfXml.longId";
/**
- * RDF/XML property: <code>allowBadURIs</code> ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> RDF/XML property: <code>allowBadURIs</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.allowBadURIs"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* URIs in the graph are, by default, checked prior to serialization.
*/
public static final String RDF_rdfxml_allowBadUris = "Rdf.jena.rdfXml.allowBadURIs";
/**
- * RDF/XML property: <code>relativeURIs</code> ({@link String}).
+ * <b>Configuration property:</b> RDF/XML property: <code>relativeURIs</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.relativeURIs"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"same-document, absolute, relative, parent"</js>
+ * </ul>
* <p>
* What sort of relative URIs should be used.
* <p>
@@ -212,7 +486,13 @@ public interface RdfCommonContext {
public static final String RDF_rdfxml_relativeUris = "Rdf.jena.rdfXml.relativeURIs";
/**
- * RDF/XML property: <code>showXmlDeclaration</code> ({@link String}, default=<js>"default"</js>).
+ * <b>Configuration property:</b> RDF/XML property: <code>showXmlDeclaration</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.showXmlDeclaration"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"default"</js>
+ * </ul>
* <p>
* Possible values:
* <ul class='spaced-list'>
@@ -225,7 +505,13 @@ public interface RdfCommonContext {
public static final String RDF_rdfxml_showXmlDeclaration = "Rdf.jena.rdfXml.showXmlDeclaration";
/**
- * RDF/XML property: <code>showDoctypeDeclaration</code> ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> RDF/XML property: <code>showDoctypeDeclaration</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.showDoctypeDeclaration"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* If true, an XML Doctype declaration is included in the output.
* This declaration includes a <code>!ENTITY</code> declaration for each prefix mapping in the model, and any attribute value that starts with the URI of that mapping is written as starting with the corresponding entity invocation.
@@ -233,63 +519,117 @@ public interface RdfCommonContext {
public static final String RDF_rdfxml_showDoctypeDeclaration = "Rdf.jena.rdfXml.showDoctypeDeclaration";
/**
- * RDF/XML property: <code>tab</code> ({@link Integer}, default=<code>2</code>).
+ * <b>Configuration property:</b> RDF/XML property: <code>tab</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.tab"</js>
+ * <li><b>Data type:</b> <code>Integer</code>
+ * <li><b>Default:</b> <code>2</code>
+ * </ul>
* <p>
* The number of spaces with which to indent XML child elements.
*/
public static final String RDF_rdfxml_tab = "Rdf.jena.rdfXml.tab";
/**
- * RDF/XML property: <code>attributeQuoteChar</code> ({@link Character}, default=<js>'"'</js>).
+ * <b>Configuration property:</b> RDF/XML property: <code>attributeQuoteChar</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.attributeQuoteChar"</js>
+ * <li><b>Data type:</b> <code>Character</code>
+ * <li><b>Default:</b> <js>'"'</js>
+ * </ul>
* <p>
* The XML attribute quote character.
*/
public static final String RDF_rdfxml_attributeQuoteChar = "Rdf.jena.rdfXml.attributeQuoteChar";
/**
- * RDF/XML property: <code>blockRules</code> ({@link String}, default=<js>""</js>).
+ * <b>Configuration property:</b> RDF/XML property: <code>blockRules</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.rdfXml.blockRules"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>""</js>
+ * </ul>
* <p>
* A list of <code>Resource</code> or a <code>String</code> being a comma separated list of fragment IDs from <a href='http://www.w3.org/TR/rdf-syntax-grammar'>RDF Syntax Grammar</a> indicating grammar rules that will not be used.
*/
public static final String RDF_rdfxml_blockRules = "Rdf.jena.rdfXml.blockRules";
/**
- * N3/Turtle property: <code>minGap</code> ({@link Integer}, default=<code>1</code>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>minGap</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.minGap"</js>
+ * <li><b>Data type:</b> <code>Integer</code>
+ * <li><b>Default:</b> <code>1</code>
+ * </ul>
* <p>
* Minimum gap between items on a line.
*/
public static final String RDF_n3_minGap = "Rdf.jena.n3.minGap";
/**
- * N3/Turtle property: <code>objectLists</code> ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>objectLists</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.objectLists"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* Print object lists as comma separated lists.
*/
public static final String RDF_n3_objectLists = "Rdf.jena.n3.objectLists";
/**
- * N3/Turtle property: <code>subjectColumn</code> ({@link Integer}, default=indentProperty).
+ * <b>Configuration property:</b> N3/Turtle property: <code>subjectColumn</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.subjectColumn"</js>
+ * <li><b>Data type:</b> <code>Integer</code>
+ * <li><b>Default:</b> indentProperty
+ * </ul>
* <p>
* If the subject is shorter than this value, the first property may go on the same line.
*/
public static final String RDF_n3_subjectColumn = "Rdf.jena.n3.subjectColumn";
/**
- * N3/Turtle property: <code>propertyColumn</code> ({@link Integer}, default=<code>8</code>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>propertyColumn</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.propertyColumn"</js>
+ * <li><b>Data type:</b> <code>Integer</code>
+ * <li><b>Default:</b> <code>8</code>
+ * </ul>
* <p>
* Width of the property column.
*/
public static final String RDF_n3_propertyColumn = "Rdf.jena.n3.propertyColumn";
/**
- * N3/Turtle property: <code>indentProperty</code> ({@link Integer}, default=<code>6</code>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>indentProperty</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.indentProperty"</js>
+ * <li><b>Data type:</b> <code>Integer</code>
+ * <li><b>Default:</b> <code>6</code>
+ * </ul>
* <p>
* Width to indent properties.
*/
public static final String RDF_n3_indentProperty = "Rdf.jena.n3.indentProperty";
/**
- * N3/Turtle property: <code>widePropertyLen</code> ({@link Integer}, default=<code>20</code>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>widePropertyLen</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.widePropertyLen"</js>
+ * <li><b>Data type:</b> <code>Integer</code>
+ * <li><b>Default:</b> <code>20</code>
+ * </ul>
* <p>
* Width of the property column.
* Must be longer than <code>propertyColumn</code>.
@@ -297,35 +637,65 @@ public interface RdfCommonContext {
public static final String RDF_n3_widePropertyLen = "Rdf.jena.n3.widePropertyLen";
/**
- * N3/Turtle property: <code>abbrevBaseURI</code> ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>abbrevBaseURI</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.abbrevBaseURI"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* Control whether to use abbreviations <code><></code> or <code><#></code>.
*/
public static final String RDF_n3_abbrevBaseUri = "Rdf.jena.n3.abbrevBaseURI";
/**
- * N3/Turtle property: <code>usePropertySymbols</code> ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>usePropertySymbols</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.usePropertySymbols"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* Control whether to use <code>a</code>, <code>=</code> and <code>=></code> in output
*/
public static final String RDF_n3_usePropertySymbols = "Rdf.jena.n3.usePropertySymbols";
/**
- * N3/Turtle property: <code>useTripleQuotedStrings</code> ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>useTripleQuotedStrings</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.useTripleQuotedStrings"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* Allow the use of <code>"""</code> to delimit long strings.
*/
public static final String RDF_n3_useTripleQuotedStrings = "Rdf.jena.n3.useTripleQuotedStrings";
/**
- * N3/Turtle property: <code>useDoubles</code> ({@link Boolean}, default=<jk>true</jk>).
+ * <b>Configuration property:</b> N3/Turtle property: <code>useDoubles</code>.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.jena.n3.useDoubles"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * </ul>
* <p>
* Allow the use doubles as <code>123.456</code>.
*/
public static final String RDF_n3_useDoubles = "Rdf.jena.n3.useDoubles";
/**
- * The RDF format for representing collections and arrays. ({@link String}, default=<js>"DEFAULT"</js>).
+ * <b>Configuration property:</b> RDF format for representing collections and arrays.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.collectionFormat"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"DEFAULT"</js>
+ * </ul>
* <p>
* Possible values:
* <ul class='spaced-list'>
@@ -343,7 +713,13 @@ public interface RdfCommonContext {
public static final String RDF_collectionFormat = "Rdf.collectionFormat";
/**
- * Specifies that collections should be serialized and parsed as loose collections. ({@link Boolean}, default=<jk>false</jk>).
+ * <b>Configuration property:</b> Collections should be serialized and parsed as loose collections.
+ * <p>
+ * <ul>
+ * <li><b>Name:</b> <js>"Rdf.looseCollections"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * </ul>
* <p>
* When specified, collections of resources are handled as loose collections of resources in RDF instead of
* resources that are children of an RDF collection (e.g. Sequence, Bag).
@@ -381,5 +757,5 @@ public interface RdfCommonContext {
* </dd>
* </dl>
*/
- public static final String RDF_looseCollection = "Rdf.looseCollection";
+ public static final String RDF_looseCollections = "Rdf.looseCollections";
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java
index 7a8b741..00dd08a 100644
--- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java
+++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParser.java
@@ -124,7 +124,7 @@ public class RdfParser extends ReaderParser {
List<Resource> roots = getRoots(s, model);
// Special case where we're parsing a loose collection of resources.
- if (s.isLooseCollection() && (type.isCollection() || type.isArray())) {
+ if (s.isLooseCollections() && (type.isCollection() || type.isArray())) {
Collection c = null;
if (type.isArray())
c = new ArrayList();
[10/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/ErrorConditionsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/ErrorConditionsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/ErrorConditionsTest.java
deleted file mode 100755
index ad96ed5..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/ErrorConditionsTest.java
+++ /dev/null
@@ -1,220 +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 org.apache.juneau.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-
-public class ErrorConditionsTest {
-
- private static String URL = "/testErrorConditions";
- private static boolean debug = false;
- private static RestClient client;
-
- @BeforeClass
- public static void beforeClass() {
- client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- }
-
- @AfterClass
- public static void afterClass() {
- client.closeQuietly();
- }
- //====================================================================================================
- // Test non-existent properties
- //====================================================================================================
- @Test
- public void testNonExistentBeanProperties() throws Exception {
- String url = URL + "/testNonExistentBeanProperties";
-
- try {
- client.doPut(url + "?noTrace=true", new ObjectMap("{f2:'foo'}")).getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Could not convert request body content to class type 'org.apache.juneau.server.ErrorConditionsResource$Test1' using parser 'org.apache.juneau.json.JsonParser'",
- "Unknown property 'f2' encountered while trying to parse into class 'org.apache.juneau.server.ErrorConditionsResource$Test1'");
- }
-
- try {
- client.doPut(url + "?noTrace=true", new ObjectMap("{f1:'foo', f2:'foo'}")).getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Could not convert request body content to class type 'org.apache.juneau.server.ErrorConditionsResource$Test1' using parser 'org.apache.juneau.json.JsonParser'",
- "Unknown property 'f2' encountered while trying to parse into class 'org.apache.juneau.server.ErrorConditionsResource$Test1'");
- }
- }
-
- //====================================================================================================
- // Test trying to set properties to wrong data type
- //====================================================================================================
- @Test
- public void testWrongDataType() throws Exception {
- String url = URL + "/testWrongDataType";
- try {
- client.doPut(url + "?noTrace=true", new ObjectMap("{f1:'foo'}")).getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Could not convert request body content to class type 'org.apache.juneau.server.ErrorConditionsResource$Test2' using parser 'org.apache.juneau.json.JsonParser'.",
- "Could not convert string 'foo' to class 'int'");
- }
- }
-
- //====================================================================================================
- // Test trying to parse into class with non-public no-arg constructor.
- //====================================================================================================
- @Test
- public void testParseIntoNonConstructableBean() throws Exception {
- String url = URL + "/testParseIntoNonConstructableBean";
- try {
- client.doPut(url + "?noTrace=true", new ObjectMap("{f1:1}")).getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Class 'org.apache.juneau.server.ErrorConditionsResource$Test3a' could not be instantiated.");
- }
- }
-
- //====================================================================================================
- // Test trying to parse into non-static inner class
- //====================================================================================================
- @Test
- public void testParseIntoNonStaticInnerClass() throws Exception {
- String url = URL + "/testParseIntoNonStaticInnerClass";
- try {
- client.doPut(url + "?noTrace=true", new ObjectMap("{f1:1}")).getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Class 'org.apache.juneau.server.ErrorConditionsResource$Test3b' could not be instantiated. Reason: 'No properties detected on bean class'");
- }
- }
-
- //====================================================================================================
- // Test trying to parse into non-public inner class
- //====================================================================================================
- @Test
- public void testParseIntoNonPublicInnerClass() throws Exception {
- String url = URL + "/testParseIntoNonPublicInnerClass";
- try {
- client.doPut(url + "?noTrace=true", new ObjectMap("{f1:1}")).getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Class 'org.apache.juneau.server.ErrorConditionsResource$Test3b1' could not be instantiated",
- "Class is not public");
- }
- }
-
- //====================================================================================================
- // Test exception thrown during bean construction.
- //====================================================================================================
- @Test
- public void testThrownConstructorException() throws Exception {
- String url = URL + "/testThrownConstructorException";
- try {
- client.doPut(url + "?noTrace=true", "'foo'").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Could not convert request body content to class type 'org.apache.juneau.server.ErrorConditionsResource$Test3c' using parser 'org.apache.juneau.json.JsonParser'.",
- "Caused by (RuntimeException): Test error");
- }
- }
-
- //====================================================================================================
- // Test trying to set parameters to invalid types.
- //====================================================================================================
- @Test
- public void testSetParameterToInvalidTypes() throws Exception {
- String url = URL + "/testSetParameterToInvalidTypes";
- try {
- client.doPut(url + "/1?noTrace=true&p1=foo", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Could not convert PARAM 'p1' to type 'int' on method 'org.apache.juneau.server.ErrorConditionsResource.testSetParameterToInvalidTypes'");
- }
-
- try {
- client.doPut(url + "/foo?noTrace=true&p1=1", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Could not convert ATTR 'a1' to type 'int' on method 'org.apache.juneau.server.ErrorConditionsResource.testSetParameterToInvalidTypes'");
- }
-
- try {
- client.doPut(url + "/1?noTrace=true&p1=1", "").setHeader("h1", "foo").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Could not convert HEADER 'h1' to type 'int' on method 'org.apache.juneau.server.ErrorConditionsResource.testSetParameterToInvalidTypes'");
- }
- }
-
- //====================================================================================================
- // Test SC_NOT_FOUND & SC_METHOD_NOT_ALLOWED
- //====================================================================================================
- @Test
- public void test404and405() throws Exception {
- String url = URL + "/test404and405";
- try {
- client.doGet(URL + "/testNonExistent?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_FOUND,
- "Method 'GET' not found on resource with matching pattern on path '/testNonExistent'");
- }
-
- try {
- client.doPut(url + "?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_FOUND,
- "Method 'PUT' not found on resource with matching pattern on path '/test404and405'");
- }
-
- try {
- client.doPost(url + "?noTrace=true", "").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_METHOD_NOT_ALLOWED,
- "Method 'POST' not found on resource.");
- }
- }
-
- //====================================================================================================
- // Test SC_PRECONDITION_FAILED
- //====================================================================================================
- @Test
- public void test412() throws Exception {
- String url = URL + "/test412";
- try {
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_PRECONDITION_FAILED,
- "Method 'GET' not found on resource on path '/test412' with matching matcher.");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/GroupsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/GroupsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/GroupsTest.java
deleted file mode 100755
index 31b7d8e..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/GroupsTest.java
+++ /dev/null
@@ -1,122 +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.json.*;
-import org.junit.*;
-
-
-public class GroupsTest {
-
- private static String URL = "/testGroups";
- private static boolean debug = false;
-
- //====================================================================================================
- // Serializer defined on class.
- //====================================================================================================
- @Test
- public void testSerializerDefinedOnClass() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String url = URL + "/testSerializerDefinedOnClass";
- String r;
-
- try {
- client.setContentType("text/p1");
- r = client.doGet(url+"?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'application/json'",
- "Supported media-types: [text/s1, text/s2]"
- );
- }
-
- client.setAccept("text/s1").setContentType("");
- r = client.doGet(url).getResponseAsString();
- assertEquals("text/s,GET", r);
-
- client.setAccept("text/s2").setContentType("");
- r = client.doGet(url).getResponseAsString();
- assertEquals("text/s,GET", r);
-
- try {
- client.setAccept("text/s3").setContentType("");
- r = client.doGet(url+"?noTrace=true").getResponseAsString();
- assertEquals("text/s,GET", r);
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/s3'",
- "Supported media-types: [text/s1, text/s2]"
- );
- }
-
- try {
- client.setAccept("text/json").setContentType("text/p1");
- r = client.doPut(url+"?noTrace=true", new StringReader("foo")).getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/json'",
- "Supported media-types: [text/s1, text/s2]"
- );
- }
-
- try {
- client.setAccept("text/s1").setContentType("text/json");
- r = client.doPut(url+"?noTrace=true", new StringReader("foo")).getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/json'",
- "Supported media-types: [text/p1, text/p2]"
- );
- }
-
- client.setContentType("text/p1").setAccept("text/s1");
- r = client.doPut(url, new StringReader("foo")).getResponseAsString();
- assertEquals("text/s,foo", r);
-
- client.setContentType("text/p2").setAccept("text/s2");
- r = client.doPut(url, new StringReader("foo")).getResponseAsString();
- assertEquals("text/s,foo", r);
-
- try {
- client.setContentType("text/p1").setAccept("text/s3");
- r = client.doPut(url+"?noTrace=true", new StringReader("foo")).getResponseAsString();
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/s3'",
- "Supported media-types: [text/s1, text/s2]"
- );
- }
-
- try {
- client.setContentType("text/p3").setAccept("text/s1");
- r = client.doPut(url+"?noTrace=true", new StringReader("foo")).getResponseAsString();
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/p3'",
- "Supported media-types: [text/p1, text/p2]"
- );
- }
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/GzipTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/GzipTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/GzipTest.java
deleted file mode 100755
index 517ba5b..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/GzipTest.java
+++ /dev/null
@@ -1,344 +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 java.util.zip.*;
-
-import org.apache.http.impl.client.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.internal.*;
-import org.junit.*;
-
-/**
- * Test Accept-Encoding and Content-Encoding handling.
- *
- * Note: WAS does automatic gzip decompression on http request messages, so we have to invent
- * our own 'mycoding' compression.
- */
-public class GzipTest {
-
- private static boolean debug = false;
-
- private static String testGzipOff = "/testGzipOff";
- private static String testGzipOn = "/testGzipOn";
-
- // Converts string into a GZipped input stream.
- private static InputStream compress(String contents) throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(contents.length()>>1);
- GZIPOutputStream gos = new GZIPOutputStream(baos);
- gos.write(contents.getBytes());
- gos.finish();
- gos.close();
- return new ByteArrayInputStream(baos.toByteArray());
- }
-
- private static String decompress(InputStream is) throws Exception {
- return IOUtils.read(new GZIPInputStream(is));
- }
-
- //====================================================================================================
- // Test with no compression enabled.
- //====================================================================================================
- @Test
- public void testGzipOff() throws Exception {
- RestClient c = new TestRestClient().setAccept("text/plain").setContentType("text/plain");
- RestCall r;
- String url = testGzipOff;
-
- // *** GET ***
-
- r = c.doGet(url);
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doGet(url).setHeader("Accept-Encoding", "");
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doGet(url).setHeader("Accept-Encoding", "*");
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doGet(url).setHeader("Accept-Encoding", "identity");
- assertEquals("foo", r.getResponseAsString());
-
- // Should match identity.
- r = c.doGet(url).setHeader("Accept-Encoding", "mycoding");
- assertEquals("foo", r.getResponseAsString());
-
- // Shouldn't match.
- try {
- r = c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "mycoding,identity;q=0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': 'mycoding,identity;q=0'",
- "Supported codings: [identity]"
- );
- }
-
- // Shouldn't match.
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "mycoding,*;q=0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': 'mycoding,*;q=0'",
- "Supported codings: [identity]"
- );
- }
-
- // Should match identity
- r = c.doGet(url).setHeader("Accept-Encoding", "identity;q=0.8,mycoding;q=0.6");
- assertEquals("foo", r.getResponseAsString());
-
- // Should match identity
- r = c.doGet(url).setHeader("Accept-Encoding", "mycoding;q=0.8,identity;q=0.6");
- assertEquals("foo", r.getResponseAsString());
-
- // Should match identity
- r = c.doGet(url).setHeader("Accept-Encoding", "mycoding;q=0.8,*;q=0.6");
- assertEquals("foo", r.getResponseAsString());
-
- // Should match identity
- r = c.doGet(url).setHeader("Accept-Encoding", "*;q=0.8,myencoding;q=0.6");
- assertEquals("foo", r.getResponseAsString());
-
- // Shouldn't match
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "identity;q=0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0'",
- "Supported codings: [identity]"
- );
- }
-
- // Shouldn't match
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "identity;q=0.0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0.0'",
- "Supported codings: [identity]"
- );
- }
-
- // Shouldn't match
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "*;q=0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': '*;q=0'",
- "Supported codings: [identity]"
- );
- }
-
- // Shouldn't match
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "*;q=0.0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': '*;q=0.0'",
- "Supported codings: [identity]"
- );
- }
-
-
- // *** PUT ***
-
- r = c.doPut(url, new StringReader("foo"));
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doPut(url, new StringReader("foo")).setHeader("Content-Encoding", "");
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doPut(url, new StringReader("foo")).setHeader("Content-Encoding", "identity");
- assertEquals("foo", r.getResponseAsString());
-
- try {
- c.doPut(url+"?noTrace=true", compress("foo")).setHeader("Content-Encoding", "mycoding").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported encoding in request header 'Content-Encoding': 'mycoding'",
- "Supported codings: [identity]"
- );
- }
-
- c.closeQuietly();
- }
-
- //====================================================================================================
- // Test with compression enabled.
- //====================================================================================================
- @Test
- public void testGzipOn() throws Exception {
-
- // Create a client that disables content compression support so that we can get the gzipped content directly.
- CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(TestRestClient.getSSLSocketFactory()).disableContentCompression().build();
-
- RestClient c = new TestRestClient(httpClient).setAccept("text/plain").setContentType("text/plain");
- RestCall r;
- String url = testGzipOn;
-
- // *** GET ***
-
- r = c.doGet(url);
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doGet(url).setHeader("Accept-Encoding", "");
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doGet(url).setHeader("Accept-Encoding", "*");
- assertEquals("foo", decompress(r.getInputStream()));
-
- r = c.doGet(url).setHeader("Accept-Encoding", "identity");
- assertEquals("foo", r.getResponseAsString());
-
- // Should match identity.
- r = c.doGet(url).setHeader("Accept-Encoding", "mycoding");
- assertEquals("foo", decompress(r.getInputStream()));
-
- r = c.doGet(url).setHeader("Accept-Encoding", "mycoding,identity;q=0").connect();
- assertEquals("foo", decompress(r.getInputStream()));
-
- r = c.doGet(url).setHeader("Accept-Encoding", "mycoding,*;q=0").connect();
- assertEquals("foo", decompress(r.getInputStream()));
-
- // Should match identity
- r = c.doGet(url).setHeader("Accept-Encoding", "identity;q=0.8,mycoding;q=0.6");
- assertEquals("foo", r.getResponseAsString());
-
- // Should match mycoding
- r = c.doGet(url).setHeader("Accept-Encoding", "mycoding;q=0.8,identity;q=0.6");
- assertEquals("foo", decompress(r.getInputStream()));
-
- // Should match mycoding
- r = c.doGet(url).setHeader("Accept-Encoding", "mycoding;q=0.8,*;q=0.6");
- assertEquals("foo", decompress(r.getInputStream()));
-
- // Should match identity
- r = c.doGet(url).setHeader("Accept-Encoding", "*;q=0.8,myencoding;q=0.6");
- assertEquals("foo", decompress(r.getInputStream()));
-
- // Shouldn't match
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "identity;q=0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0'",
- "Supported codings: [mycoding, identity]"
- );
- }
-
- // Shouldn't match
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "identity;q=0.0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0.0'",
- "Supported codings: [mycoding, identity]"
- );
- }
-
- // Shouldn't match
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "*;q=0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': '*;q=0'",
- "Supported codings: [mycoding, identity]"
- );
- }
-
- // Shouldn't match
- try {
- c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "*;q=0.0").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported encoding in request header 'Accept-Encoding': '*;q=0.0'",
- "Supported codings: [mycoding, identity]"
- );
- }
-
-
- // *** PUT ***
-
- r = c.doPut(url, new StringReader("foo"));
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doPut(url, new StringReader("foo")).setHeader("Content-Encoding", "");
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doPut(url, new StringReader("foo")).setHeader("Content-Encoding", "identity");
- assertEquals("foo", r.getResponseAsString());
-
- r = c.doPut(url, compress("foo")).setHeader("Content-Encoding", "mycoding");
- assertEquals("foo", r.getResponseAsString());
-
- c.closeQuietly();
- }
-
- //====================================================================================================
- // Test with compression enabled but with servlet using output stream directly.
- //====================================================================================================
- @Test
- public void testGzipOnDirect() throws Exception {
- // Create a client that disables content compression support so that we can get the gzipped content directly.
- CloseableHttpClient httpClient = HttpClientBuilder.create().setSSLSocketFactory(TestRestClient.getSSLSocketFactory()).build();
- RestClient c = new TestRestClient(httpClient).setAccept("text/plain").setContentType("text/plain");
- RestCall r = null;
- String s = null;
-
- // res.getOutputStream() called....should bypass encoding.
- r = c.doGet(testGzipOn + "/direct").setHeader("Accept-Encoding", "mycoding");
- s = r.getResponseAsString();
- assertEquals("test", s);
- assertTrue(r.getResponse().getHeaders("Content-Type")[0].getValue().contains("text/direct")); // Should get header set manually.
- assertEquals(0, r.getResponse().getHeaders("Content-Encoding").length); // Should not be set.
-
- // res.getWriter() called....should bypass encoding.
- r = c.doGet(testGzipOn + "/direct2").setHeader("Accept-Encoding", "mycoding");
- s = r.getResponseAsString();
- assertEquals("test", s);
- assertEquals(0, r.getResponse().getHeaders("Content-Encoding").length); // Should not be set.
-
- // res.getNegotiateWriter() called....should NOT bypass encoding.
- r = c.doGet(testGzipOn + "/direct3").setHeader("Accept-Encoding", "mycoding");
- try {
- assertEquals("mycoding", r.getResponse().getHeaders("content-encoding")[0].getValue());
- } catch (RestCallException e) {
- // OK - HttpClient doesn't know what mycoding is.
- // Newer versions of HttpClient ignore this condition.
- }
-
- // res.getNegotiateWriter() called but @RestMethod(encoders={})...should bypass encoding.
- r = c.doGet(testGzipOn + "/direct4").setHeader("Accept-Encoding", "mycoding");
- s = r.getResponseAsString();
- assertEquals("test", s);
- assertEquals(0, r.getResponse().getHeaders("Content-Encoding").length); // Should not be set.
-
- c.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/InheritanceTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/InheritanceTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/InheritanceTest.java
deleted file mode 100755
index e86330a..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/InheritanceTest.java
+++ /dev/null
@@ -1,126 +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 InheritanceTest {
-
- private static RestClient client;
-
- @BeforeClass
- public static void beforeClass() {
- client = new TestRestClient();
- }
-
- @AfterClass
- public static void afterClass() {
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test serializer inheritance.
- //====================================================================================================
- @Test
- public void testSerializers() throws Exception {
- String r;
- String url = "/testInheritanceSerializers";
- r = client.doGet(url + "/test1").getResponseAsString();
- assertEquals("['text/s3','text/s4','text/s1','text/s2']", r);
-
- r = client.doGet(url + "/test2").getResponseAsString();
- assertEquals("['text/s5']", r);
-
- r = client.doGet(url + "/test3").getResponseAsString();
- assertEquals("['text/s5','text/s3','text/s4','text/s1','text/s2']", r);
- }
-
- //====================================================================================================
- // Test parser inheritance.
- //====================================================================================================
- @Test
- public void testParsers() throws Exception {
- String r;
- String url = "/testInheritanceParsers";
- r = client.doGet(url + "/test1").getResponseAsString();
- assertEquals("['text/p3','text/p4','text/p1','text/p2']", r);
-
- r = client.doGet(url + "/test2").getResponseAsString();
- assertEquals("['text/p5']", r);
-
- r = client.doGet(url + "/test3").getResponseAsString();
- assertEquals("['text/p5','text/p3','text/p4','text/p1','text/p2']", r);
- }
-
- //====================================================================================================
- // Test encoder inheritance.
- //====================================================================================================
- @Test
- public void testEncoders() throws Exception {
- String url = "/testInheritanceEncoders";
- String r = client.doGet(url + "/test").getResponseAsString();
- assertEquals("['e3','e4','e1','e2','identity']", r);
- }
-
- //====================================================================================================
- // Test filter inheritance.
- //====================================================================================================
- @Test
- public void testTransforms() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.class, JsonParser.class).setAccept("text/json+simple");
- String r;
- String url = "/testInheritanceTransforms";
-
- r = client.doGet(url + "/test1").getResponseAsString();
- assertEquals("['F1','F2','Foo3']", r);
-
- r = client.doGet(url + "/test2").getResponseAsString();
- assertEquals("['F1','F2','F3']", r);
-
- r = client.doGet(url + "/test3").getResponseAsString();
- assertEquals("['F1','F2','F3']", r);
-
- r = client.doGet(url + "/test4").getResponseAsString();
- assertEquals("['Foo1','Foo2','F3']", r);
-
- r = client.doGet(url + "/test5").getResponseAsString();
- assertEquals("['F1','F2','F3']", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test properties inheritance.
- //====================================================================================================
- @Test
- public void testProperties() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.class, JsonParser.class).setAccept("text/json+simple");
- String r;
- String url = "/testInheritanceProperties";
-
- r = client.doGet(url + "/test1").getResponseAsString();
- assertEquals("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}", r);
-
- r = client.doGet(url + "/test2?override").getResponseAsString();
- assertEquals("{p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'}", r);
-
- r = client.doGet(url + "/test2").getResponseAsString();
- assertEquals("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'}", r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/JacocoDummyTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/JacocoDummyTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/JacocoDummyTest.java
deleted file mode 100755
index f969d20..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/JacocoDummyTest.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 java.lang.reflect.*;
-
-import org.junit.*;
-
-public class JacocoDummyTest {
-
- //====================================================================================================
- // Dummy code to add test coverage in Jacoco.
- //====================================================================================================
- @Test
- public void accessPrivateConstructorsOnStaticUtilityClasses() throws Exception {
-
- Class<?>[] classes = new Class[] {
- RestUtils.class
- };
-
- for (Class<?> c : classes) {
- Constructor<?> c1 = c.getDeclaredConstructor();
- c1.setAccessible(true);
- c1.newInstance();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/LargePojosTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/LargePojosTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/LargePojosTest.java
deleted file mode 100755
index a8cfb3a..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/LargePojosTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.html.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.urlencoding.*;
-import org.apache.juneau.xml.*;
-import org.junit.*;
-
-@Ignore
-public class LargePojosTest {
-
- private static String URL = "/testLargePojos";
- boolean debug = false;
-
- //====================================================================================================
- // Test how long it takes to serialize/parse various content types.
- //====================================================================================================
- @Test
- public void test() throws Exception {
- LargePojo p;
- long t;
- RestClient c;
-
- System.err.println("\n---Testing JSON---");
- c = new TestRestClient(JsonSerializer.class, JsonParser.class);
- for (int i = 1; i <= 3; i++) {
- t = System.currentTimeMillis();
- p = c.doGet(URL).getResponse(LargePojo.class);
- System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
- t = System.currentTimeMillis();
- c.doPut(URL, p).run();
- System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
- }
-
- System.err.println("\n---Testing XML---");
- c = new TestRestClient(XmlSerializer.class, XmlParser.class);
- for (int i = 1; i <= 3; i++) {
- t = System.currentTimeMillis();
- p = c.doGet(URL).getResponse(LargePojo.class);
- System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
- t = System.currentTimeMillis();
- c.doPut(URL, p).run();
- System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
- }
-
- System.err.println("\n---Testing HTML---");
- c = new TestRestClient(HtmlSerializer.class, HtmlParser.class).setAccept("text/html+stripped");
- for (int i = 1; i <= 3; i++) {
- t = System.currentTimeMillis();
- p = c.doGet(URL).getResponse(LargePojo.class);
- System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
- t = System.currentTimeMillis();
- c.doPut(URL, p).run();
- System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
- }
-
- System.err.println("\n---Testing UrlEncoding---");
- c = new TestRestClient(UonSerializer.class, UonParser.class);
- for (int i = 1; i <= 3; i++) {
- t = System.currentTimeMillis();
- p = c.doGet(URL).getResponse(LargePojo.class);
- System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
- t = System.currentTimeMillis();
- c.doPut(URL, p).run();
- System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
- }
-
- c.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/MessagesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/MessagesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/MessagesTest.java
deleted file mode 100755
index 20ca633..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/MessagesTest.java
+++ /dev/null
@@ -1,47 +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.apache.juneau.server.TestUtils.*;
-
-import java.util.*;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-/**
- * Validates that resource bundles can be defined on both parent and child classes.
- */
-public class MessagesTest {
-
- //====================================================================================================
- // Return contents of resource bundle.
- //====================================================================================================
- @SuppressWarnings("rawtypes")
- @Test
- public void test() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.class,JsonParser.class);
-
- // Parent resource should just pick up values from its bundle.
- TreeMap r = client.doGet("/testMessages/test").getResponse(TreeMap.class);
- assertObjectEquals("{key1:'value1a',key2:'value2a'}", r);
-
- // Child resource should pick up values from both parent and child,
- // ordered child before parent.
- r = client.doGet("/testMessages2/test").getResponse(TreeMap.class);
- assertObjectEquals("{key1:'value1a',key2:'value2b',key3:'value3b'}", r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/NlsPropertyTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/NlsPropertyTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/NlsPropertyTest.java
deleted file mode 100755
index b9cf0f5..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/NlsPropertyTest.java
+++ /dev/null
@@ -1,48 +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.plaintext.*;
-import org.junit.*;
-
-public class NlsPropertyTest {
-
- private static String URL = "/testNlsProperty";
-
- //====================================================================================================
- // Test getting an NLS property defined on a class.
- //====================================================================================================
- @Test
- public void testInheritedFromClass() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String r = client.doGet(URL + "/testInheritedFromClass").getResponseAsString();
- assertEquals("value1", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test getting an NLS property defined on a method.
- //====================================================================================================
- @Test
- public void testInheritedFromMethod() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String r = client.doGet(URL + "/testInheritedFromMethod").getResponseAsString();
- assertEquals("value2", r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/NlsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/NlsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/NlsTest.java
deleted file mode 100755
index f74fc3f..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/NlsTest.java
+++ /dev/null
@@ -1,170 +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.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-public class NlsTest {
-
- private static String URL = "/testNls";
-
- // ====================================================================================================
- // test1 - Pull labels from annotations only.
- // ====================================================================================================
- @Test
- public void test1() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r = null;
- String expected = null;
-
- // Labels all pulled from annotations.
- r = client.doOptions(URL + "/test1").getResponse(ObjectMap.class);
- assertEquals("Test1.a", r.getString("label"));
- assertEquals("Test1.b", r.getString("description"));
- r = r.getObjectList("methods").getObjectMap(0);
- assertEquals("test1", r.getString("javaMethod"));
- assertEquals("POST", r.getString("httpMethod"));
- expected = "[{category:'attr',name:'a',description:'Test1.d'},{category:'attr',name:'a2',description:'Test1.h'},{category:'attr',name:'e'},{category:'content',name:'',description:'Test1.f'},{category:'foo',name:'bar',description:'Test1.k'},{category:'header',name:'D',description:'Test1.g'},{category:'header',name:'D2',description:'Test1.j'},{category:'header',name:'g'},{category:'param',name:'b',description:'Test1.e'},{category:'param',name:'b2',description:'Test1.i'},{category:'param',name:'f'}]";
- assertEquals(expected, r.getObjectList("input").toString());
- expected = "[{status:200,description:'OK',output:[]},{status:201,description:'Test1.l',output:[{category:'foo',name:'bar',description:'Test1.m'}]}]";
- assertEquals(expected, r.getObjectList("responses").toString());
-
- client.closeQuietly();
- }
-
- // ====================================================================================================
- // test2 - Pull labels from resource bundles only - simple keys.
- // ====================================================================================================
- @Test
- public void test2() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r = null;
- String expected = null;
-
- // Labels all pulled from annotations.
- r = client.doOptions(URL + "/test2").getResponse(ObjectMap.class);
- assertEquals("Test2.a", r.getString("label"));
- assertEquals("Test2.b", r.getString("description"));
- r = r.getObjectList("methods").getObjectMap(0);
- assertEquals("test2", r.getString("javaMethod"));
- assertEquals("POST", r.getString("httpMethod"));
- expected = "[{category:'attr',name:'a',description:'Test2.d'},{category:'attr',name:'a2',description:'Test2.h'},{category:'attr',name:'e'},{category:'content',name:'',description:'Test2.f'},{category:'foo',name:'bar',description:'Test2.k'},{category:'header',name:'D',description:'Test2.g'},{category:'header',name:'D2',description:'Test2.j'},{category:'header',name:'g'},{category:'param',name:'b',description:'Test2.e'},{category:'param',name:'b2',description:'Test2.i'},{category:'param',name:'f'}]";
- assertEquals(expected, r.getObjectList("input").toString());
- expected = "[{status:200,description:'OK2',output:[]},{status:201,description:'Test2.l',output:[{category:'foo',name:'bar',description:'Test2.m'}]}]";
- assertEquals(expected, r.getObjectList("responses").toString());
-
- client.closeQuietly();
- }
-
- // ====================================================================================================
- // test3 - Pull labels from resource bundles only - keys with class names.
- // ====================================================================================================
- @Test
- public void test3() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r = null;
- String expected = null;
-
- // Labels all pulled from annotations.
- r = client.doOptions(URL + "/test3").getResponse(ObjectMap.class);
- assertEquals("Test3.a", r.getString("label"));
- assertEquals("Test3.b", r.getString("description"));
- r = r.getObjectList("methods").getObjectMap(1);
- assertEquals("test3", r.getString("javaMethod"));
- assertEquals("POST", r.getString("httpMethod"));
- expected = "[{category:'attr',name:'a',description:'Test3.d'},{category:'attr',name:'a2',description:'Test3.h'},{category:'attr',name:'e'},{category:'content',name:'',description:'Test3.f'},{category:'foo',name:'bar',description:'Test3.k'},{category:'header',name:'D',description:'Test3.g'},{category:'header',name:'D2',description:'Test3.j'},{category:'header',name:'g'},{category:'param',name:'b',description:'Test3.e'},{category:'param',name:'b2',description:'Test3.i'},{category:'param',name:'f'}]";
- assertEquals(expected, r.getObjectList("input").toString());
- expected = "[{status:200,description:'OK3',output:[]},{status:201,description:'Test3.l',output:[{category:'foo',name:'bar',description:'Test3.m'}]}]";
- assertEquals(expected, r.getObjectList("responses").toString());
-
- client.closeQuietly();
- }
-
- // ====================================================================================================
- // test4 - Pull labels from resource bundles only. Values have localized variables to resolve.
- // ====================================================================================================
- @Test
- public void test4() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r = null;
- String expected = null;
-
- // Labels all pulled from annotations.
- r = client.doOptions(URL + "/test4").getResponse(ObjectMap.class);
- assertEquals("baz", r.getString("label"));
- assertEquals("baz", r.getString("description"));
- r = r.getObjectList("methods").getObjectMap(0);
- assertEquals("test4", r.getString("javaMethod"));
- assertEquals("POST", r.getString("httpMethod"));
- expected = "[{category:'attr',name:'a',description:'baz'},{category:'attr',name:'a2',description:'baz'},{category:'attr',name:'e'},{category:'content',name:'',description:'baz'},{category:'foo',name:'bar',description:'baz'},{category:'header',name:'D',description:'baz'},{category:'header',name:'D2',description:'baz'},{category:'header',name:'g'},{category:'param',name:'b',description:'baz'},{category:'param',name:'b2',description:'baz'},{category:'param',name:'f'}]";
- assertEquals(expected, r.getObjectList("input").toString());
- expected = "[{status:200,description:'foobazfoobazfoo',output:[]},{status:201,description:'baz',output:[{category:'foo',name:'bar',description:'baz'}]}]";
- assertEquals(expected, r.getObjectList("responses").toString());
-
- client.closeQuietly();
- }
-
- // ====================================================================================================
- // test5 - Pull labels from resource bundles only. Values have request variables to resolve.
- // ====================================================================================================
- @Test
- public void test5() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r = null;
- String expected = null;
-
- // Labels all pulled from annotations.
- r = client.doOptions(URL + "/test5").getResponse(ObjectMap.class);
- assertEquals("baz2", r.getString("label"));
- assertEquals("baz2", r.getString("description"));
- r = r.getObjectList("methods").getObjectMap(0);
- assertEquals("test5", r.getString("javaMethod"));
- assertEquals("POST", r.getString("httpMethod"));
- expected = "[{category:'attr',name:'a',description:'baz2'},{category:'attr',name:'a2',description:'baz2'},{category:'attr',name:'e'},{category:'content',name:'',description:'baz2'},{category:'foo',name:'bar',description:'baz2'},{category:'header',name:'D',description:'baz2'},{category:'header',name:'D2',description:'baz2'},{category:'header',name:'g'},{category:'param',name:'b',description:'baz2'},{category:'param',name:'b2',description:'baz2'},{category:'param',name:'f'}]";
- assertEquals(expected, r.getObjectList("input").toString());
- expected = "[{status:200,description:'foobaz2foobaz2foo',output:[]},{status:201,description:'baz2',output:[{category:'foo',name:'bar',description:'baz2'}]}]";
- assertEquals(expected, r.getObjectList("responses").toString());
-
- client.closeQuietly();
- }
-
- // ====================================================================================================
- // test6 - Pull labels from annotations only, but annotations contain variables.
- // ====================================================================================================
- @Test
- public void test6() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r = null;
- String expected = null;
-
- // Labels all pulled from annotations.
- r = client.doOptions(URL + "/test6").getResponse(ObjectMap.class);
- assertEquals("baz", r.getString("label"));
- assertEquals("baz", r.getString("description"));
- r = r.getObjectList("methods").getObjectMap(0);
- assertEquals("test6", r.getString("javaMethod"));
- assertEquals("POST", r.getString("httpMethod"));
- expected = "[{category:'attr',name:'a',description:'baz'},{category:'attr',name:'a2',description:'baz'},{category:'attr',name:'e'},{category:'content',name:'',description:'baz'},{category:'foo',name:'bar',description:'baz'},{category:'header',name:'D',description:'baz'},{category:'header',name:'D2',description:'baz'},{category:'header',name:'g'},{category:'param',name:'b',description:'baz'},{category:'param',name:'b2',description:'baz'},{category:'param',name:'f'}]";
- assertEquals(expected, r.getObjectList("input").toString());
- expected = "[{status:200,description:'OK',output:[]},{status:201,description:'baz',output:[{category:'foo',name:'bar',description:'baz'}]}]";
- assertEquals(expected, r.getObjectList("responses").toString());
-
- client.closeQuietly();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/NoParserInputTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/NoParserInputTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/NoParserInputTest.java
deleted file mode 100755
index 307facc..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/NoParserInputTest.java
+++ /dev/null
@@ -1,70 +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 org.apache.juneau.client.*;
-import org.apache.juneau.plaintext.*;
-import org.junit.*;
-
-public class NoParserInputTest {
-
- private static String URL = "/testNoParserInput";
- private static boolean debug = false;
-
- //====================================================================================================
- // @Content annotated InputStream.
- //====================================================================================================
- @Test
- public void testInputStream() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String r = client.doPut(URL + "/testInputStream", "foo").getResponseAsString();
- assertEquals("foo", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @Content annotated Reader.
- //====================================================================================================
- @Test
- public void testReader() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String r = client.doPut(URL + "/testReader", "foo").getResponseAsString();
- assertEquals("foo", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @Content annotated PushbackReader.
- // This should always fail since the servlet reader is not a pushback reader.
- //====================================================================================================
- @Test
- public void testPushbackReader() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- try {
- client.doPut(URL + "/testPushbackReader?noTrace=true", "foo").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_BAD_REQUEST,
- "Invalid argument type passed to the following method:",
- "'public java.lang.String org.apache.juneau.server.NoParserInputResource.testPushbackReader(java.io.PushbackReader) throws java.lang.Exception'");
- }
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/OnPostCallTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/OnPostCallTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/OnPostCallTest.java
deleted file mode 100755
index 2c22e67..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/OnPostCallTest.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;
-
-import static org.junit.Assert.*;
-
-import java.io.*;
-
-import org.apache.juneau.client.*;
-import org.junit.*;
-
-public class OnPostCallTest {
-
- private static String URL = "/testOnPostCall";
-
- //====================================================================================================
- // Properties overridden via properties annotation.
- //====================================================================================================
- @Test
- public void testPropertiesOverridenByAnnotation() throws Exception {
- RestClient client = new TestRestClient().setAccept("text/s1");
- String url = URL + "/testPropertiesOverridenByAnnotation";
- String r;
- RestCall rc;
-
- r = client.doPut(url, new StringReader("")).getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s1", r);
-
- r = client.doPut(url, new StringReader("")).setHeader("Override-Accept", "text/s2").getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s2", r);
-
- rc = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/s3").connect();
- r = rc.getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s1", r);
- assertTrue(rc.getResponse().getFirstHeader("Content-Type").getValue().startsWith("text/s3"));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Properties overridden via properties annotation. Default Accept header.
- //====================================================================================================
- @Test
- public void testPropertiesOverridenByAnnotationDefaultAccept() throws Exception {
- RestClient client = new TestRestClient().setAccept("");
- String url = URL + "/testPropertiesOverridenByAnnotation";
- String r;
- RestCall rc;
-
- r = client.doPut(url, new StringReader("")).getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s2", r);
-
- r = client.doPut(url, new StringReader("")).setHeader("Override-Accept", "text/s3").getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s3", r);
-
- rc = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/s3").connect();
- r = rc.getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/s2", r);
- assertTrue(rc.getResponse().getFirstHeader("Content-Type").getValue().startsWith("text/s3"));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Properties overridden programmatically.
- //====================================================================================================
- @Test
- public void testPropertiesOverriddenProgramatically() throws Exception {
- RestClient client = new TestRestClient().setAccept("text/s1");
- String url = URL + "/testPropertiesOverriddenProgramatically";
- String r;
- RestCall rc;
-
- r = client.doPut(url, new StringReader("")).getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s1", r);
-
- r = client.doPut(url, new StringReader("")).setHeader("Override-Accept", "text/s2").getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s2", r);
-
- rc = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/s3").connect();
- r = rc.getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s1", r);
- assertTrue(rc.getResponse().getFirstHeader("Content-Type").getValue().startsWith("text/s3"));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Properties overridden programmatically. Default Accept header.
- //====================================================================================================
- @Test
- public void testPropertiesOverriddenProgramaticallyDefaultAccept() throws Exception {
- RestClient client = new TestRestClient().setAccept("");
- String url = URL + "/testPropertiesOverriddenProgramatically";
- String r;
- RestCall rc;
-
- r = client.doPut(url, new StringReader("")).getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s2", r);
-
- r = client.doPut(url, new StringReader("")).setHeader("Override-Accept", "text/s3").getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s3", r);
-
- rc = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/s3").connect();
- r = rc.getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=xp4,p5=xp5,contentType=text/s2", r);
- assertTrue(rc.getResponse().getFirstHeader("Content-Type").getValue().startsWith("text/s3"));
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/OnPreCallTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/OnPreCallTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/OnPreCallTest.java
deleted file mode 100755
index 117196d..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/OnPreCallTest.java
+++ /dev/null
@@ -1,61 +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 java.io.*;
-
-import org.apache.juneau.client.*;
-import org.junit.*;
-
-public class OnPreCallTest {
-
- private static String URL = "/testOnPreCall";
-
- //====================================================================================================
- // Properties overridden via properties annotation.
- //====================================================================================================
- @Test
- public void testPropertiesOverriddenByAnnotation() throws Exception {
- RestClient client = new TestRestClient().setContentType("text/a1").setAccept("text/plain");
- String url = URL + "/testPropertiesOverriddenByAnnotation";
- String r;
-
- r = client.doPut(url, new StringReader("")).getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/a1", r);
-
- r = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/a2").getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=mp3,p4=xp4,p5=xp5,contentType=text/a2", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Properties overridden programmatically.
- //====================================================================================================
- @Test
- public void testPropertiesOverriddenProgrammatically() throws Exception {
- RestClient client = new TestRestClient().setContentType("text/a1").setAccept("text/plain");
- String url = URL + "/testPropertiesOverriddenProgrammatically";
- String r;
-
- r = client.doPut(url, new StringReader("")).getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=pp4,p5=xp5,contentType=text/a1", r);
-
- r = client.doPut(url, new StringReader("")).setHeader("Override-Content-Type", "text/a2").getResponseAsString();
- assertEquals("p1=sp1,p2=xp2,p3=pp3,p4=pp4,p5=xp5,contentType=text/a2", r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/OptionsWithoutNlsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/OptionsWithoutNlsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/OptionsWithoutNlsTest.java
deleted file mode 100755
index f461a8e..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/OptionsWithoutNlsTest.java
+++ /dev/null
@@ -1,51 +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.apache.juneau.server.labels.*;
-import org.junit.*;
-
-public class OptionsWithoutNlsTest {
-
- private static String URL = "/testOptionsWithoutNls";
-
- //====================================================================================================
- // Should get to the options page without errors
- //====================================================================================================
- @Test
- public void testOptions() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- RestCall r = client.doOptions(URL + "/testOptions");
- ResourceOptions o = r.getResponse(ResourceOptions.class);
- assertEquals("", o.getDescription());
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Missing resource bundle should cause {!!x} string.
- //====================================================================================================
- @Test
- public void testMissingResourceBundle() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- RestCall r = client.doGet(URL + "/testMissingResourceBundle");
- String o = r.getResponse(String.class);
- assertEquals("{!!bad}", o);
-
- client.closeQuietly();
- }
-}
[07/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/SerializersTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/SerializersTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/SerializersTest.java
deleted file mode 100755
index b5b46c0..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/SerializersTest.java
+++ /dev/null
@@ -1,152 +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 org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-public class SerializersTest {
-
- private static String URL = "/testSerializers";
- private static boolean debug = false;
- private static RestClient client;
-
- @BeforeClass
- public static void beforeClass() {
- client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- }
-
- @AfterClass
- public static void afterClass() {
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Serializer defined on class.
- //====================================================================================================
- @Test
- public void testSerializerOnClass() throws Exception {
- String url = URL + "/testSerializerOnClass";
-
- client.setAccept("text/a");
- String r = client.doGet(url).getResponseAsString();
- assertEquals("text/a - test1", r);
-
- try {
- client.setAccept("text/b");
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/b'",
- "Supported media-types: [text/a, ");
- }
-
- client.setAccept("text/json");
- r = client.doGet(url).getResponseAsString();
- assertEquals("\"test1\"", r);
- }
-
- //====================================================================================================
- // Serializer defined on method.
- //====================================================================================================
- @Test
- public void testSerializerOnMethod() throws Exception {
- String url = URL + "/testSerializerOnMethod";
-
- try {
- client.setAccept("text/a");
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/a'",
- "Supported media-types: [text/b]"
- );
- }
-
- try {
- client.setAccept("text/json");
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/json'",
- "Supported media-types: [text/b]"
- );
- }
- }
-
- //====================================================================================================
- // Serializer overridden on method.
- //====================================================================================================
- @Test
- public void testSerializerOverriddenOnMethod() throws Exception {
- String url = URL + "/testSerializerOverriddenOnMethod";
-
- client.setAccept("text/a");
- String r = client.doGet(url).getResponseAsString();
- assertEquals("text/c - test3", r);
-
- client.setAccept("text/b");
- r = client.doGet(url).getResponseAsString();
- assertEquals("text/b - test3", r);
-
- client.setAccept("text/json");
- r = client.doGet(url).getResponseAsString();
- assertEquals("\"test3\"", r);
- }
-
- //====================================================================================================
- // Serializer with different Accept than Content-Type.
- //====================================================================================================
- @Test
- public void testSerializerWithDifferentMediaTypes() throws Exception {
- String url = URL + "/testSerializerWithDifferentMediaTypes";
-
- client.setAccept("text/a");
- String r = client.doGet(url).getResponseAsString();
- assertEquals("text/d - test4", r);
-
- client.setAccept("text/d");
- r = client.doGet(url).getResponseAsString();
- assertEquals("text/d - test4", r);
-
- client.setAccept("text/json");
- r = client.doGet(url).getResponseAsString();
- assertEquals("\"test4\"", r);
- }
-
- //====================================================================================================
- // Check for valid 406 error response.
- //====================================================================================================
- @Test
- public void test406() throws Exception {
- String url = URL + "/test406";
-
- try {
- client.setAccept("text/bad");
- client.doGet(url + "?noTrace=true").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
- "Unsupported media-type in request header 'Accept': 'text/bad'",
- "Supported media-types: [text/a");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/StaticFilesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/StaticFilesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/StaticFilesTest.java
deleted file mode 100755
index cb8a7ad..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/StaticFilesTest.java
+++ /dev/null
@@ -1,56 +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.plaintext.*;
-import org.junit.*;
-
-public class StaticFilesTest {
-
- private static String URL = "/testStaticFiles";
-
- //====================================================================================================
- // Tests the @RestResource(staticFiles) annotation.
- //====================================================================================================
- @Test
- public void testXdocs() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String r;
- String url = URL + "/xdocs";
-
- r = client.doGet(url + "/test.txt").getResponseAsString();
- assertTrue(r.endsWith("OK-1"));
- r = client.doGet(url + "/xdocs/test.txt").getResponseAsString();
- assertTrue(r.endsWith("OK-2"));
-
- // For security reasons, paths containing ".." should always return 404.
- try {
- client.doGet(url + "/xdocs/../test.txt?noTrace=true").connect();
- fail("404 exception expected");
- } catch (RestCallException e) {
- assertEquals(404, e.getResponseCode());
- }
-
- try {
- client.doGet(url + "/xdocs/%2E%2E/test.txt?noTrace=true").connect();
- fail("404 exception expected");
- } catch (RestCallException e) {
- assertEquals(404, e.getResponseCode());
- }
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/TestRestClient.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/TestRestClient.java b/juneau-server-test/src/test/java/org/apache/juneau/server/TestRestClient.java
deleted file mode 100755
index 8fcaa2d..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/TestRestClient.java
+++ /dev/null
@@ -1,69 +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 java.security.*;
-
-import javax.net.ssl.*;
-
-import org.apache.http.conn.ssl.*;
-import org.apache.http.impl.client.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-
-/**
- * REST client with lenient SSL support and lax redirection strategy.
- */
-class TestRestClient extends RestClient {
-
- public TestRestClient(Class<? extends Serializer> s, Class<? extends Parser> p) throws InstantiationException {
- super(s,p);
- setRootUrl(Constants.getServerTestUrl());
- }
-
- public TestRestClient(Serializer s, Parser p) {
- super(s,p);
- setRootUrl(Constants.getServerTestUrl());
- }
-
- public TestRestClient() {
- setRootUrl(Constants.getServerTestUrl());
- }
-
- public TestRestClient(CloseableHttpClient c) {
- super(c);
- setRootUrl(Constants.getServerTestUrl());
- }
-
- public static SSLConnectionSocketFactory getSSLSocketFactory() throws Exception {
- SSLContext sslContext = SSLContext.getInstance("SSL");
- TrustManager tm = new SimpleX509TrustManager(true);
- sslContext.init(null, new TrustManager[]{tm}, new SecureRandom());
- return new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
- }
-
- @Override /* RestClient */
- protected CloseableHttpClient createHttpClient() throws Exception {
- try {
- return HttpClients.custom().setSSLSocketFactory(getSSLSocketFactory()).setRedirectStrategy(new LaxRedirectStrategy()).build();
- } catch (KeyStoreException e) {
- throw new RuntimeException(e);
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- } catch (Throwable e) {
- e.printStackTrace();
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/TestUtils.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/TestUtils.java b/juneau-server-test/src/test/java/org/apache/juneau/server/TestUtils.java
deleted file mode 100755
index 6c4d3d6..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/TestUtils.java
+++ /dev/null
@@ -1,60 +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 java.text.*;
-
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.transforms.*;
-import org.junit.Assert;
-
-import junit.framework.*;
-
-public class TestUtils {
-
- private static JsonSerializer js2 = new JsonSerializer.Simple()
- .addPojoSwaps(IteratorSwap.class, EnumerationSwap.class);
-
- /**
- * Assert that the object equals the specified string after running it through JsonSerializer.DEFAULT_LAX.toString().
- */
- public static void assertObjectEquals(String s, Object o) {
- assertObjectEquals(s, o, js2);
- }
-
- /**
- * Assert that the object equals the specified string after running it through ws.toString().
- */
- public static void assertObjectEquals(String s, Object o, WriterSerializer ws) {
- Assert.assertEquals(s, ws.toString(o));
- }
-
- public static void checkErrorResponse(boolean debug, RestCallException e, int status, String...contains) throws AssertionFailedError {
- String r = e.getResponseMessage();
- if (debug) {
- System.err.println(r);
- e.printStackTrace();
- }
- if (status != e.getResponseCode())
- throw new AssertionFailedError(MessageFormat.format("Response status code was not correct. Expected: ''{0}''. Actual: ''{1}''", status, e.getResponseCode()));
- for (String s : contains) {
- if (r == null || ! r.contains(s)) {
- if (! debug)
- System.err.println(r);
- throw new AssertionFailedError(MessageFormat.format("Response did not have the following expected text: ''{0}''", s));
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/TransformsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/TransformsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/TransformsTest.java
deleted file mode 100755
index 29208b5..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/TransformsTest.java
+++ /dev/null
@@ -1,68 +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 TransformsTest {
-
- private static String URL = "/testTransforms";
-
- //====================================================================================================
- // test1 - Test class transform overrides parent class transform
- // Should return "A2-1".
- //====================================================================================================
- @Test
- public void testClassTransformOverridesParentClassTransform() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
- String url = URL + "/testClassTransformOverridesParentClassTransform";
-
- r = client.doGet(url).getResponse(String.class);
- assertEquals("A2-0", r);
-
- r = client.doPut(url, "A2-1").getResponse(String.class);
- assertEquals("A2-1", r);
-
- r = client.doPut(url + "/A2-2", "").getResponse(String.class);
- assertEquals("A2-2", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test method transform overrides class transform
- // Should return "A3-1".
- //====================================================================================================
- @Test
- public void testMethodTransformOverridesClassTransform() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r;
- String url = URL + "/testMethodTransformOverridesClassTransform";
-
- r = client.doGet(url).getResponse(String.class);
- assertEquals("A3-0", r);
-
- r = client.doPut(url, "A3-1").getResponse(String.class);
- assertEquals("A3-1", r);
-
- r = client.doPut(url + "/A3-2", "").getResponse(String.class);
- assertEquals("A3-2", r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/UrisTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/UrisTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/UrisTest.java
deleted file mode 100755
index f75adba..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/UrisTest.java
+++ /dev/null
@@ -1,918 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import static org.junit.Assert.*;
-
-import java.util.regex.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-/**
- * Verifies that all the RestRequest.getXXX() methods involving URIs work correctly.
- */
-public class UrisTest {
-
- private static String URL2 = Constants.getServerTestUrl() + "/testuris"; // /jazz/juneau/sample/testuris
- private static int port = getPort(Constants.getServerTestUrl()); // 9443
- private static String path = Constants.getServerTestUri().getPath(); // /jazz/juneau/sample
-
- //====================================================================================================
- // testRoot - http://localhost:8080/sample/testuris
- //====================================================================================================
- @Test
- public void testRoot() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r;
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris").getResponse(ObjectMap.class);
- assertEquals("root.test1", r.getString("testMethod"));
- assertNull(r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/foo").getResponse(ObjectMap.class);
- assertEquals("root.test1", r.getString("testMethod"));
- assertEquals("/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/foo/bar").getResponse(ObjectMap.class);
- assertEquals("root.test1", r.getString("testMethod"));
- assertEquals("/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("root.test1", r.getString("testMethod"));
- assertEquals("/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test2
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test2").getResponse(ObjectMap.class);
- assertEquals("root.test2", r.getString("testMethod"));
- assertEquals("/test2", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test2", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test2/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test2/foo").getResponse(ObjectMap.class);
- assertEquals("root.test2", r.getString("testMethod"));
- assertEquals("/test2/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test2", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test2/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2/foo"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test2/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test2/foo/bar").getResponse(ObjectMap.class);
- assertEquals("root.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test2/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test2/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test3%2Ftest3
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test3%2Ftest3").getResponse(ObjectMap.class);
- assertEquals("root.test3", r.getString("testMethod"));
- assertEquals("/test3/test3", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test3%2Ftest3", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test3%2Ftest3/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test3%2Ftest3/foo").getResponse(ObjectMap.class);
- assertEquals("root.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test3%2Ftest3", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test3%2Ftest3/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
- assertEquals("root.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test3%2Ftest3/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("root.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test3%2Ftest3/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test4/test4
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test4/test4").getResponse(ObjectMap.class);
- assertEquals("root.test4", r.getString("testMethod"));
- assertEquals("/test4/test4", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test4/test4", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test4/test4/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test4/test4/foo").getResponse(ObjectMap.class);
- assertEquals("root.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test4/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test4/test4/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test4/test4/foo/bar").getResponse(ObjectMap.class);
- assertEquals("root.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test4/test4/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/test4/test4/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("root.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/test4/test4/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2, r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // testChild - http://localhost:8080/sample/testuris/child
- //====================================================================================================
- @Test
- public void testChild() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r;
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child").getResponse(ObjectMap.class);
- assertEquals("child.test1", r.getString("testMethod"));
- assertNull(r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/foo").getResponse(ObjectMap.class);
- assertEquals("child.test1", r.getString("testMethod"));
- assertEquals("/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/foo/bar").getResponse(ObjectMap.class);
- assertEquals("child.test1", r.getString("testMethod"));
- assertEquals("/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("child.test1", r.getString("testMethod"));
- assertEquals("/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test2").getResponse(ObjectMap.class);
- assertEquals("child.test2", r.getString("testMethod"));
- assertEquals("/test2", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test2", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test2/foo").getResponse(ObjectMap.class);
- assertEquals("child.test2", r.getString("testMethod"));
- assertEquals("/test2/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test2", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test2/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test2/foo/bar").getResponse(ObjectMap.class);
- assertEquals("child.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test2/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test2/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("child.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test2/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test2/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test3%2Ftest3").getResponse(ObjectMap.class);
- assertEquals("child.test3", r.getString("testMethod"));
- assertEquals("/test3/test3", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test3%2Ftest3", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test3%2Ftest3/foo").getResponse(ObjectMap.class);
- assertEquals("child.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test3%2Ftest3", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
- assertEquals("child.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("child.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test3%2Ftest3/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test4/test4").getResponse(ObjectMap.class);
- assertEquals("child.test4", r.getString("testMethod"));
- assertEquals("/test4/test4", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test4/test4", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test4/test4/foo").getResponse(ObjectMap.class);
- assertEquals("child.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test4/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test4/test4/foo/bar").getResponse(ObjectMap.class);
- assertEquals("child.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test4/test4/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("child.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/test4/test4/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // testGrandChild - http://localhost:8080/sample/testuris/child/grandchild
- //====================================================================================================
- @Test
- public void testGrandChild() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- ObjectMap r;
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild").getResponse(ObjectMap.class);
- assertEquals("grandchild.test1", r.getString("testMethod"));
- assertNull(r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/foo").getResponse(ObjectMap.class);
- assertEquals("grandchild.test1", r.getString("testMethod"));
- assertEquals("/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/foo/bar").getResponse(ObjectMap.class);
- assertEquals("grandchild.test1", r.getString("testMethod"));
- assertEquals("/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("grandchild.test1", r.getString("testMethod"));
- assertEquals("/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test2").getResponse(ObjectMap.class);
- assertEquals("grandchild.test2", r.getString("testMethod"));
- assertEquals("/test2", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test2", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test2/foo").getResponse(ObjectMap.class);
- assertEquals("grandchild.test2", r.getString("testMethod"));
- assertEquals("/test2/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test2", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test2/foo/bar").getResponse(ObjectMap.class);
- assertEquals("grandchild.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test2/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test2/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("grandchild.test2", r.getString("testMethod"));
- assertEquals("/test2/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test2/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test2/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test3%2Ftest3").getResponse(ObjectMap.class);
- assertEquals("grandchild.test3", r.getString("testMethod"));
- assertEquals("/test3/test3", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo").getResponse(ObjectMap.class);
- assertEquals("grandchild.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo/bar").getResponse(ObjectMap.class);
- assertEquals("grandchild.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test3%2Ftest3/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("grandchild.test3", r.getString("testMethod"));
- assertEquals("/test3/test3/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test3%2Ftest3/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test4/test4").getResponse(ObjectMap.class);
- assertEquals("grandchild.test4", r.getString("testMethod"));
- assertEquals("/test4/test4", r.getString("pathInfo"));
- assertNull(r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test4/test4/foo").getResponse(ObjectMap.class);
- assertEquals("grandchild.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo", r.getString("pathInfo"));
- assertEquals("foo", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test4/test4/foo/bar").getResponse(ObjectMap.class);
- assertEquals("grandchild.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar", r.getString("pathInfo"));
- assertEquals("foo/bar", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo/bar", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo/bar"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- //--------------------------------------------------------------------------------
- // http://localhost:8080/sample/testuris/child/test4/test4/foo/bar%2Fbaz
- //--------------------------------------------------------------------------------
- r = client.doGet("/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz").getResponse(ObjectMap.class);
- assertEquals("grandchild.test4", r.getString("testMethod"));
- assertEquals("/test4/test4/foo/bar/baz", r.getString("pathInfo"));
- assertEquals("foo/bar/baz", r.getString("pathRemainder"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo", r.getString("requestParentURI"));
- assertEquals(path + "/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz", r.getString("requestURI"));
- assertTrue(r.getString("requestURL").endsWith(port + path + "/testuris/child/grandchild/test4/test4/foo/bar%2Fbaz"));
- // Same for servlet
- assertEquals(path + "/testuris/child/grandchild", r.getString("contextPath") + r.getString("servletPath")); // App may not have context path, but combination should always equal path.
- assertEquals(URL2 + "/child/grandchild", r.getString("servletURI"));
- assertTrue(r.getString("testURL1").endsWith(port + path + "/testuris/child/grandchild/testURL"));
- // Always the same
- assertTrue(r.getString("testURL2").endsWith(port + "/testURL"));
- assertEquals("http://testURL", r.getString("testURL3"));
-
- client.closeQuietly();
- }
-
- private static int getPort(String url) {
- Pattern p = Pattern.compile("\\:(\\d{2,5})");
- Matcher m = p.matcher(url);
- if (m.find())
- return Integer.parseInt(m.group(1));
- return -1;
- }
-}
[15/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/MessagesResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/MessagesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/MessagesResource.java
deleted file mode 100755
index 62ed3a7..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/MessagesResource.java
+++ /dev/null
@@ -1,61 +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 java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.server.annotation.*;
-import org.apache.juneau.transform.*;
-
-/**
- * JUnit automated testcase resource.
- * Validates that resource bundles can be defined on both parent and child classes.
- */
-@RestResource(
- path="/testMessages",
- messages="MessagesResource",
- pojoSwaps={
- MessagesResource.ResourceBundleSwap.class
- }
-)
-public class MessagesResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Return contents of resource bundle.
- //====================================================================================================
- @RestMethod(name="GET", path="/test")
- public Object test(@Messages ResourceBundle nls) {
- return nls;
- }
-
-
- @SuppressWarnings("serial")
- @RestResource(
- path="/testMessages2",
- messages="Messages2Resource"
- )
- public static class Messages2Resource extends MessagesResource {}
-
- public static class ResourceBundleSwap extends PojoSwap<ResourceBundle,ObjectMap> {
- @Override /* Transform */
- public ObjectMap swap(ResourceBundle o) throws SerializeException {
- ObjectMap m = new ObjectMap();
- for (String k : o.keySet())
- m.put(k, o.getString(k));
- return m;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/NlsPropertyResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/NlsPropertyResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/NlsPropertyResource.java
deleted file mode 100755
index 9c92a61..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/NlsPropertyResource.java
+++ /dev/null
@@ -1,60 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testNlsProperty",
- serializers={NlsPropertyResource.TestSerializer.class},
- properties={
- @Property(name="TestProperty",value="$L{key1}")
- },
- messages="NlsPropertyResource"
-)
-public class NlsPropertyResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Test getting an NLS property defined on a class.
- //====================================================================================================
- @RestMethod(name="GET", path="/testInheritedFromClass")
- public String testInheritedFromClass() {
- return null;
- }
-
- //====================================================================================================
- // Test getting an NLS property defined on a method.
- //====================================================================================================
- @RestMethod(name="GET", path="/testInheritedFromMethod",
- properties={
- @Property(name="TestProperty",value="$L{key2}")
- }
- )
- public String testInheritedFromMethod() {
- return null;
- }
-
- @Produces("text/plain")
- public static class TestSerializer extends WriterSerializer {
- @Override /* Serializer */
- protected void doSerialize(SerializerSession session, Object o) throws Exception {
- session.getWriter().write(session.getProperties().getString("TestProperty"));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/NlsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/NlsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/NlsResource.java
deleted file mode 100755
index a0f3d2e..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/NlsResource.java
+++ /dev/null
@@ -1,194 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.server.annotation.*;
-import org.apache.juneau.utils.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testNls",
- children={
- NlsResource.Test1.class,
- NlsResource.Test2.class,
- NlsResource.Test3.class,
- NlsResource.Test4.class,
- NlsResource.Test5.class,
- NlsResource.Test6.class
- }
-)
-@SuppressWarnings({"serial"})
-public class NlsResource extends RestServletGroupDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // test1 - Pull labels from annotations only.
- //====================================================================================================
- @RestResource(
- path="/test1",
- messages="NlsResource",
- label="Test1.a",
- description="Test1.b"
- )
- public static class Test1 extends RestServletDefault {
-
- @RestMethod(
- name="POST", path="/{a}",
- description="Test1.c",
- input={
- @Var(category="attr", name="a", description="Test1.d"),
- @Var(category="param", name="b", description="Test1.e"),
- @Var(category="content", description="Test1.f"),
- @Var(category="header", name="D", description="Test1.g"),
- @Var(category="attr", name="a2", description="Test1.h"),
- @Var(category="param", name="b2", description="Test1.i"),
- @Var(category="header", name="D2", description="Test1.j"),
- @Var(category="foo", name="bar", description="Test1.k"),
- },
- responses={
- @Response(200),
- @Response(value=201,
- description="Test1.l",
- output={
- @Var(category="foo", name="bar", description="Test1.m"),
- }
- )
- }
- )
- public String test1(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
- @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
- return null;
- }
- }
-
- //====================================================================================================
- // test2 - Pull labels from resource bundles only - simple keys.
- //====================================================================================================
- @RestResource(
- path="/test2",
- messages="NlsResource"
- )
- public static class Test2 extends RestServletDefault {
-
- @RestMethod(
- name="POST", path="/{a}"
- )
- public String test2(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
- @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
- return null;
- }
- }
-
- //====================================================================================================
- // test3 - Pull labels from resource bundles only - keys with class names.
- //====================================================================================================
- @RestResource(
- path="/test3",
- messages="NlsResource"
- )
- public static class Test3 extends RestServletDefault {
-
- @RestMethod(
- name="POST", path="/{a}"
- )
- public String test3(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
- @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
- return null;
- }
-
- @RestMethod(
- name="GET", path="/"
- )
- public Object test3a(@Messages MessageBundle mb) {
- return mb;
- }
- }
-
- //====================================================================================================
- // test4 - Pull labels from resource bundles only. Values have localized variables to resolve.
- //====================================================================================================
- @RestResource(
- path="/test4",
- messages="NlsResource"
- )
- public static class Test4 extends RestServletDefault {
-
- @RestMethod(
- name="POST", path="/{a}"
- )
- public String test4(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
- @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
- return null;
- }
- }
-
- //====================================================================================================
- // test5 - Pull labels from resource bundles only. Values have request variables to resolve.
- //====================================================================================================
- @RestResource(
- path="/test5",
- messages="NlsResource"
- )
- public static class Test5 extends RestServletDefault {
-
- @RestMethod(
- name="POST", path="/{a}"
- )
- public String test5(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
- @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
- return null;
- }
- }
-
- //====================================================================================================
- // test6 - Pull labels from annotations only, but annotations contain variables.
- //====================================================================================================
- @RestResource(
- path="/test6",
- messages="NlsResource",
- label="$L{foo}",
- description="$L{foo}"
- )
- public static class Test6 extends RestServletDefault {
-
- @RestMethod(
- name="POST", path="/{a}",
- description="$L{foo}",
- input={
- @Var(category="attr", name="a", description="$L{foo}"),
- @Var(category="param", name="b", description="$L{foo}"),
- @Var(category="content", description="$L{foo}"),
- @Var(category="header", name="D", description="$L{foo}"),
- @Var(category="attr", name="a2", description="$L{foo}"),
- @Var(category="param", name="b2", description="$L{foo}"),
- @Var(category="header", name="D2", description="$L{foo}"),
- @Var(category="foo", name="bar", description="$L{foo}"),
- },
- responses={
- @Response(200),
- @Response(value=201,
- description="$L{foo}",
- output={
- @Var(category="foo", name="bar", description="$L{foo}"),
- }
- )
- }
- )
- public String test6(@Attr("a") String a, @Param("b") String b, @Content String c, @Header("D") String d,
- @Attr("e") String e, @Param("f") String f, @Header("g") String g) {
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/NoParserInputResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/NoParserInputResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/NoParserInputResource.java
deleted file mode 100755
index 73e1e4e..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/NoParserInputResource.java
+++ /dev/null
@@ -1,55 +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 java.io.*;
-
-import org.apache.juneau.internal.*;
-import org.apache.juneau.plaintext.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testNoParserInput",
- serializers=PlainTextSerializer.class
-)
-public class NoParserInputResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // @Content annotated InputStream.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testInputStream")
- public String testInputStream(@Content InputStream in) throws Exception {
- return IOUtils.read(in);
- }
-
- //====================================================================================================
- // @Content annotated Reader.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testReader")
- public String testReader(@Content Reader in) throws Exception {
- return IOUtils.read(in);
- }
-
- //====================================================================================================
- // @Content annotated PushbackReader.
- // This should always fail since the servlet reader is not a pushback reader.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testPushbackReader")
- public String testPushbackReader(@Content PushbackReader in) throws Exception {
- return IOUtils.read(in);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/OnPostCallResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/OnPostCallResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/OnPostCallResource.java
deleted file mode 100755
index f98509b..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/OnPostCallResource.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- * Validates that headers
- */
-@RestResource(
- path="/testOnPostCall",
- serializers=OnPostCallResource.TestSerializer.class,
- properties={
- @Property(name="p1",value="sp1"), // Unchanged servlet-level property.
- @Property(name="p2",value="sp2"), // Servlet-level property overridden by onPostCall.
- @Property(name="p3",value="sp3"), // Servlet-level property overridded by method.
- @Property(name="p4",value="sp4") // Servlet-level property overridden by method then onPostCall.
- }
-)
-public class OnPostCallResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- @Produces({"text/s1","text/s2","text/s3"})
- public static class TestSerializer extends WriterSerializer {
- @Override /* Serializer */
- protected void doSerialize(SerializerSession session, Object o) throws Exception {
- ObjectMap p = session.getProperties();
- session.getWriter().write("p1="+p.get("p1")+",p2="+p.get("p2")+",p3="+p.get("p3")+",p4="+p.get("p4")+",p5="+p.get("p5")+",contentType="+session.getProperties().getString("mediaType"));
- }
- @Override /* Serializer */
- public ObjectMap getResponseHeaders(ObjectMap properties) {
- if (properties.containsKey("Override-Content-Type"))
- return new ObjectMap().append("Content-Type", properties.get("Override-Content-Type"));
- return null;
- }
- }
-
- @Override /* RestServlet */
- protected void onPostCall(RestRequest req, RestResponse res) {
- ObjectMap properties = req.getProperties();
- properties.put("p2", "xp2");
- properties.put("p4", "xp4");
- properties.put("p5", "xp5"); // New property
- String overrideAccept = req.getHeader("Override-Accept");
- if (overrideAccept != null)
- req.setHeader("Accept", overrideAccept);
- String overrideContentType = req.getHeader("Override-Content-Type");
- if (overrideContentType != null)
- properties.put("Override-Content-Type", overrideContentType);
- }
-
-
- //====================================================================================================
- // Test1 - Properties overridden via properties annotation.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testPropertiesOverridenByAnnotation",
- properties={
- @Property(name="p3",value="mp3"),
- @Property(name="p4",value="mp4")
- },
- defaultRequestHeaders="Accept: text/s2"
- )
- public String testPropertiesOverridenByAnnotation() {
- return "";
- }
-
- //====================================================================================================
- // Test2 - Properties overridden programmatically.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testPropertiesOverriddenProgramatically")
- public String testPropertiesOverriddenProgramatically(RestRequest req, @Properties ObjectMap properties) throws Exception {
- properties.put("p3", "pp3");
- properties.put("p4", "pp4");
- String accept = req.getHeader("Accept");
- if (accept == null || accept.isEmpty())
- req.setHeader("Accept", "text/s2");
- return "";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/OnPreCallResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/OnPreCallResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/OnPreCallResource.java
deleted file mode 100755
index ac7b436..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/OnPreCallResource.java
+++ /dev/null
@@ -1,84 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.plaintext.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- * Validates that headers
- */
-@RestResource(
- path="/testOnPreCall",
- parsers=OnPreCallResource.TestParserA.class,
- serializers=PlainTextSerializer.class,
- properties={
- @Property(name="p1",value="sp1"), // Unchanged servlet-level property.
- @Property(name="p2",value="sp2"), // Servlet-level property overridden by onPreCall.
- @Property(name="p3",value="sp3"), // Servlet-level property overridded by method.
- @Property(name="p4",value="sp4") // Servlet-level property overridden by method then onPreCall.
- }
-)
-public class OnPreCallResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- @Consumes({"text/a1","text/a2","text/a3"})
- public static class TestParserA extends ReaderParser {
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- ObjectMap p = session.getProperties();
- String matchingContentType = session.getProperties().getString("mediaType");
- return (T)("p1="+p.get("p1")+",p2="+p.get("p2")+",p3="+p.get("p3")+",p4="+p.get("p4")+",p5="+p.get("p5")+",contentType="+matchingContentType);
- }
- }
-
- @Override /* RestServlet */
- protected void onPreCall(RestRequest req) {
- ObjectMap properties = req.getProperties();
- properties.put("p2", "xp2");
- properties.put("p4", "xp4");
- properties.put("p5", "xp5"); // New property
- String overrideContentType = req.getHeader("Override-Content-Type");
- if (overrideContentType != null)
- req.setHeader("Content-Type", overrideContentType);
- }
-
-
- //====================================================================================================
- // Properties overridden via properties annotation.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testPropertiesOverriddenByAnnotation",
- properties={
- @Property(name="p3",value="mp3"),
- @Property(name="p4",value="mp4")
- }
- )
- public String testPropertiesOverriddenByAnnotation(@Content String in) {
- return in;
- }
-
- //====================================================================================================
- // Properties overridden programmatically.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testPropertiesOverriddenProgrammatically")
- public String testPropertiesOverriddenProgrammatically(RestRequest req, @Properties ObjectMap properties) throws Exception {
- properties.put("p3", "pp3");
- properties.put("p4", "pp4");
- return req.getInput(String.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/OptionsWithoutNlsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/OptionsWithoutNlsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/OptionsWithoutNlsResource.java
deleted file mode 100755
index 2146ae8..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/OptionsWithoutNlsResource.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.server.annotation.*;
-import org.apache.juneau.server.labels.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testOptionsWithoutNls"
-)
-public class OptionsWithoutNlsResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Should get to the options page without errors
- //====================================================================================================
- @RestMethod(name="OPTIONS", path="/testOptions/*")
- public ResourceOptions testOptions(RestRequest req) {
- return new ResourceOptions(this, req);
- }
-
- //====================================================================================================
- // Missing resource bundle should cause {!!x} string.
- //====================================================================================================
- @RestMethod(name="GET", path="/testMissingResourceBundle")
- public String test(RestRequest req) {
- return req.getMessage("bad", 1, 2, 3);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/OverlappingMethodsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/OverlappingMethodsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/OverlappingMethodsResource.java
deleted file mode 100755
index 21926a1..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/OverlappingMethodsResource.java
+++ /dev/null
@@ -1,145 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.plaintext.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testOverlappingMethods",
- serializers=PlainTextSerializer.class
-)
-public class OverlappingMethodsResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Overlapping guards
- //====================================================================================================
- @RestMethod(name="GET", path="/testOverlappingGuards1", guards=Test1Guard.class)
- public String testOverlappingGuards1() {
- return "test1_doGet";
- }
-
- //====================================================================================================
- // Overlapping guards
- //====================================================================================================
- @RestMethod(name="GET", path="/testOverlappingGuards2", guards={Test1Guard.class, Test2Guard.class})
- public String testOverlappingGuards2() {
- return "test2_doGet";
- }
-
- public static class Test1Guard extends RestGuard {
- @Override /* RestGuard */
- public boolean isRequestAllowed(RestRequest req) {
- return req.getParameter("t1","").equals("1");
- }
- }
-
- public static class Test2Guard extends RestGuard {
- @Override /* RestGuard */
- public boolean isRequestAllowed(RestRequest req) {
- return req.getParameter("t2","").equals("2");
- }
- }
-
- //====================================================================================================
- // Overlapping matchers
- //====================================================================================================
- @RestMethod(name="GET", path="/testOverlappingMatchers1", matchers=Test3aMatcher.class)
- public String testOverlappingMatchers1() {
- return "test3a";
- }
-
- @RestMethod(name="GET", path="/testOverlappingMatchers1", matchers=Test3bMatcher.class)
- public String test3b_doGet() {
- return "test3b";
- }
-
- @RestMethod(name="GET", path="/testOverlappingMatchers1")
- public String test3c_doGet() {
- return "test3c";
- }
-
- public static class Test3aMatcher extends RestMatcher {
- @Override /* RestMatcher */
- public boolean matches(RestRequest req) {
- return req.getParameter("t1","").equals("1");
- }
- }
-
- public static class Test3bMatcher extends RestMatcher {
- @Override /* RestMatcher */
- public boolean matches(RestRequest req) {
- return req.getParameter("t2","").equals("2");
- }
- }
-
- //====================================================================================================
- // Overlapping matchers
- //====================================================================================================
- @RestMethod(name="GET", path="/testOverlappingMatchers2")
- public String test4a_doGet() {
- return "test4a";
- }
-
- @RestMethod(name="GET", path="/testOverlappingMatchers2", matchers={Test3aMatcher.class, Test3bMatcher.class})
- public String test4b_doGet() {
- return "test4b";
- }
-
- //====================================================================================================
- // Overlapping URL patterns
- //====================================================================================================
- @RestMethod(name="GET", path="/testOverlappingUrlPatterns")
- public String testOverlappingUrlPatterns1() {
- return "test5a";
- }
-
- @RestMethod(name="GET", path="/testOverlappingUrlPatterns/*")
- public String testOverlappingUrlPatterns2() {
- return "test5b";
- }
-
- @RestMethod(name="GET", path="/testOverlappingUrlPatterns/foo")
- public String testOverlappingUrlPatterns3() {
- return "test5c";
- }
-
- @RestMethod(name="GET", path="/testOverlappingUrlPatterns/foo/*")
- public String testOverlappingUrlPatterns4() {
- return "test5d";
- }
-
- @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}")
- public String testOverlappingUrlPatterns5() {
- return "test5e";
- }
-
- @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/*")
- public String testOverlappingUrlPatterns6() {
- return "test5f";
- }
-
- @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/foo")
- public String testOverlappingUrlPatterns7() {
- return "test5g";
- }
-
- @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/foo/*")
- public String testOverlappingUrlPatterns8() {
- return "test5h";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/ParamsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/ParamsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/ParamsResource.java
deleted file mode 100755
index 59460a2..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/ParamsResource.java
+++ /dev/null
@@ -1,292 +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.apache.juneau.server.RestServletContext.*;
-import static org.apache.juneau.urlencoding.UrlEncodingContext.*;
-
-import java.util.*;
-
-import javax.servlet.http.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.plaintext.*;
-import org.apache.juneau.samples.addressbook.*;
-import org.apache.juneau.server.annotation.*;
-import org.apache.juneau.transforms.*;
-import org.apache.juneau.urlencoding.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testParams",
- serializers=PlainTextSerializer.class,
- properties={
- @Property(name=REST_allowMethodParam, value="*")
- }
-)
-public class ParamsResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Basic tests
- //====================================================================================================
- @RestMethod(name="GET", path="/")
- public void doGet(RestResponse res) {
- res.setOutput("GET");
- }
-
- @RestMethod(name="GET", path="/get1")
- public String doGet1() {
- return "GET /get1";
- }
-
- @RestMethod(name="GET", path="/get1/{foo}")
- public void doGet1a(RestResponse res, String foo) {
- res.setOutput("GET /get1a " + foo);
- }
-
- @RestMethod(name="GET", path="/get1/{foo}/{bar}")
- public void doGet1b(RestResponse res, String foo, String bar) {
- res.setOutput("GET /get1b " + foo + "," + bar);
- }
-
- @RestMethod(name="GET", path="/get3/{foo}/{bar}/*")
- public void doGet3(HttpServletRequest reqx, HttpServletResponse resx, String foo, int bar) {
- RestRequest req = (RestRequest)reqx;
- RestResponse res = (RestResponse)resx;
- res.setOutput("GET /get3/"+foo+"/"+bar+" remainder="+req.getPathRemainder());
- }
-
- // Test method name with overlapping name, remainder allowed.
- @RestMethod(name="GET2")
- public void get2(RestRequest req, RestResponse res) {
- res.setOutput("GET2 remainder="+req.getPathRemainder());
- }
-
- // Default POST
- @RestMethod(name="POST")
- public void doPost(RestRequest req, RestResponse res) {
- res.setOutput("POST remainder="+req.getPathRemainder());
- }
-
- // Bean parameter
- @RestMethod(name="POST", path="/person/{person}")
- public void doPost(RestRequest req, RestResponse res, Person p) {
- res.setOutput("POST /person/{name="+p.name+",birthDate.year="+p.birthDate.get(Calendar.YEAR)+"} remainder="+req.getPathRemainder());
- }
-
- // Various primitive types
- @RestMethod(name="PUT", path="/primitives/{xInt}/{xShort}/{xLong}/{xChar}/{xFloat}/{xDouble}/{xByte}/{xBoolean}")
- public void doPut1(RestResponse res, int xInt, short xShort, long xLong, char xChar, float xFloat, double xDouble, byte xByte, boolean xBoolean) {
- res.setOutput("PUT /primitives/"+xInt+"/"+xShort+"/"+xLong+"/"+xChar+"/"+xFloat+"/"+xDouble+"/"+xByte+"/"+xBoolean);
- }
-
- // Various primitive objects
- @RestMethod(name="PUT", path="/primitiveObjects/{xInt}/{xShort}/{xLong}/{xChar}/{xFloat}/{xDouble}/{xByte}/{xBoolean}")
- public void doPut2(RestResponse res, Integer xInt, Short xShort, Long xLong, Character xChar, Float xFloat, Double xDouble, Byte xByte, Boolean xBoolean) {
- res.setOutput("PUT /primitiveObjects/"+xInt+"/"+xShort+"/"+xLong+"/"+xChar+"/"+xFloat+"/"+xDouble+"/"+xByte+"/"+xBoolean);
- }
-
- // Object with forString(String) method
- @RestMethod(name="PUT", path="/uuid/{uuid}")
- public void doPut1(RestResponse res, UUID uuid) {
- res.setOutput("PUT /uuid/"+uuid);
- }
-
- @Override /* RestServlet */
- public Class<?>[] createPojoSwaps() {
- return new Class[]{CalendarSwap.Medium.class};
- }
-
- //====================================================================================================
- // @Param annotation - GET
- //====================================================================================================
- @RestMethod(name="GET", path="/testParamGet/*")
- public String testParamGet(RestRequest req, @Param("p1") String p1, @Param("p2") int p2) throws Exception {
- return "p1=["+p1+","+req.getParameter("p1")+","+req.getParameter("p1", String.class)+"],p2=["+p2+","+req.getParameter("p2")+","+req.getParameter("p2", int.class)+"]";
- }
-
- //====================================================================================================
- // @Param annotation - POST
- //====================================================================================================
- @RestMethod(name="POST", path="/testParamPost/*")
- public String testParamPost(RestRequest req, @Param("p1") String p1, @Param("p2") int p2) throws Exception {
- return "p1=["+p1+","+req.getParameter("p1")+","+req.getParameter("p1", String.class)+"],p2=["+p2+","+req.getParameter("p2")+","+req.getParameter("p2", int.class)+"]";
- }
-
- //====================================================================================================
- // @QParam annotation - GET
- //====================================================================================================
- @RestMethod(name="GET", path="/testQParamGet/*")
- public String testQParamGet(RestRequest req, @QParam("p1") String p1, @QParam("p2") int p2) throws Exception {
- return "p1=["+p1+","+req.getQueryParameter("p1")+","+req.getQueryParameter("p1", String.class)+"],p2=["+p2+","+req.getQueryParameter("p2")+","+req.getQueryParameter("p2", int.class)+"]";
- }
-
- //====================================================================================================
- // @QParam annotation - POST
- //====================================================================================================
- @RestMethod(name="POST", path="/testQParamPost/*")
- public String testQParamPost(RestRequest req, @QParam("p1") String p1, @QParam("p2") int p2) throws Exception {
- return "p1=["+p1+","+req.getQueryParameter("p1")+","+req.getQueryParameter("p1", String.class)+"],p2=["+p2+","+req.getQueryParameter("p2")+","+req.getQueryParameter("p2", int.class)+"]";
- }
-
- //====================================================================================================
- // @Param(format=PLAIN) annotation - GET
- //====================================================================================================
- @RestMethod(name="GET", path="/testPlainParamGet/*")
- public String testPlainParamGet(RestRequest req, @Param(value="p1",format="PLAIN") String p1) throws Exception {
- return "p1=["+p1+","+req.getParameter("p1")+","+req.getParameter("p1", String.class)+"]";
- }
-
- //====================================================================================================
- // @Param(format=PLAIN) annotation - POST
- //====================================================================================================
- @RestMethod(name="POST", path="/testPlainParamPost/*")
- public String testPlainParamPost(RestRequest req, @Param(value="p1",format="PLAIN") String p1) throws Exception {
- return "p1=["+p1+","+req.getParameter("p1")+","+req.getParameter("p1", String.class)+"]";
- }
-
- //====================================================================================================
- // @QParam(format=PLAIN) annotation - GET
- //====================================================================================================
- @RestMethod(name="GET", path="/testPlainQParamGet/*")
- public String testPlainQParamGet(RestRequest req, @QParam(value="p1",format="PLAIN") String p1) throws Exception {
- return "p1=["+p1+","+req.getQueryParameter("p1")+","+req.getQueryParameter("p1", String.class)+"]";
- }
-
- //====================================================================================================
- // @QParam(format=PLAIN) annotation - POST
- //====================================================================================================
- @RestMethod(name="POST", path="/testPlainQParamPost/*")
- public String testPlainQParamPost(RestRequest req, @QParam(value="p1",format="PLAIN") String p1) throws Exception {
- return "p1=["+p1+","+req.getQueryParameter("p1")+","+req.getQueryParameter("p1", String.class)+"]";
- }
-
- //====================================================================================================
- // @HasParam annotation - GET
- //====================================================================================================
- @RestMethod(name="GET", path="/testHasParamGet/*")
- public String testHasParamGet(RestRequest req, @HasParam("p1") boolean p1, @HasParam("p2") Boolean p2) throws Exception {
- return "p1=["+p1+","+req.hasParameter("p1")+"],p2=["+p2+","+req.hasParameter("p2")+"]";
- }
-
- //====================================================================================================
- // @HasParam annotation - POST
- //====================================================================================================
- @RestMethod(name="POST", path="/testHasParamPost/*")
- public String testHasParamPost(RestRequest req, @HasParam("p1") boolean p1, @HasParam("p2") Boolean p2) throws Exception {
- return "p1=["+p1+","+req.hasParameter("p1")+"],p2=["+p2+","+req.hasParameter("p2")+"]";
- }
-
- //====================================================================================================
- // @HasQParam annotation - GET
- //====================================================================================================
- @RestMethod(name="GET", path="/testHasQParamGet/*")
- public String testHasQParamGet(RestRequest req, @HasQParam("p1") boolean p1, @HasQParam("p2") Boolean p2) throws Exception {
- return "p1=["+p1+","+req.hasQueryParameter("p1")+"],p2=["+p2+","+req.hasQueryParameter("p2")+"]";
- }
-
- //====================================================================================================
- // @HasQParam annotation - POST
- //====================================================================================================
- @RestMethod(name="POST", path="/testHasQParamPost/*")
- public String testHasQParamPost_post(RestRequest req, @HasQParam("p1") boolean p1, @HasQParam("p2") Boolean p2) throws Exception {
- return "p1=["+p1+","+req.hasQueryParameter("p1")+"],p2=["+p2+","+req.hasQueryParameter("p2")+"]";
- }
-
- //====================================================================================================
- // Form POSTS with @Content parameter
- //====================================================================================================
- @RestMethod(name="POST", path="/testFormPostAsContent/*")
- public String testFormPostAsContent(@Content Test6Bean bean,
- @HasQParam("p1") boolean hqp1, @HasQParam("p2") boolean hqp2,
- @QParam("p1") String qp1, @QParam("p2") int qp2) throws Exception {
- return "bean=["+JsonSerializer.DEFAULT_LAX.toString(bean)+"],qp1=["+qp1+"],qp2=["+qp2+"],hqp1=["+hqp1+"],hqp2=["+hqp2+"]";
- }
-
- public static class Test6Bean {
- public String p1;
- public int p2;
- }
-
- //====================================================================================================
- // Test @Param and @QParam annotations when using multi-part parameters (e.g. &key=val1,&key=val2).
- //====================================================================================================
- @RestMethod(name="GET", path="/testMultiPartParams")
- public String testMultiPartParams(
- @QParam(value="p1",multipart=true) String[] p1,
- @QParam(value="p2",multipart=true) int[] p2,
- @QParam(value="p3",multipart=true) List<String> p3,
- @QParam(value="p4",multipart=true) List<Integer> p4,
- @Param(value="p5",multipart=true) String[] p5,
- @Param(value="p6",multipart=true) int[] p6,
- @Param(value="p7",multipart=true) List<String> p7,
- @Param(value="p8",multipart=true) List<Integer> p8,
- @QParam(value="p9",multipart=true) A[] p9,
- @QParam(value="p10",multipart=true) List<A> p10,
- @Param(value="p11",multipart=true) A[] p11,
- @Param(value="p12",multipart=true) List<A> p12) throws Exception {
- ObjectMap m = new ObjectMap()
- .append("p1", p1)
- .append("p2", p2)
- .append("p3", p3)
- .append("p4", p4)
- .append("p5", p5)
- .append("p6", p6)
- .append("p7", p7)
- .append("p8", p8)
- .append("p9", p9)
- .append("p10", p10)
- .append("p11", p11)
- .append("p12", p12);
- return JsonSerializer.DEFAULT_LAX.toString(m);
- }
-
- public static class A {
- public String a;
- public int b;
- public boolean c;
- }
-
- //====================================================================================================
- // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
- // using URLENC_expandedParams property.
- // A simple round-trip test to verify that both serializing and parsing works.
- //====================================================================================================
- @RestMethod(name="POST", path="/testFormPostsWithMultiParamsUsingProperty",
- properties={
- @Property(name=URLENC_expandedParams, value="true"),
- @Property(name=UonSerializerContext.UON_simpleMode, value="true")
- }
- )
- public DTO2s.B testFormPostsWithMultiParamsViaProperty(@Content DTO2s.B content) throws Exception {
- return content;
- }
-
- //====================================================================================================
- // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
- // using @UrlEncoding(expandedParams=true) annotation.
- // A simple round-trip test to verify that both serializing and parsing works.
- //====================================================================================================
- @RestMethod(name="POST", path="/testFormPostsWithMultiParamsUsingAnnotation",
- properties={
- @Property(name=UonSerializerContext.UON_simpleMode, value="true")
- }
- )
- public DTO2s.C testFormPostsWithMultiParamsUsingAnnotation(@Content DTO2s.C content) throws Exception {
- return content;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/ParsersResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/ParsersResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/ParsersResource.java
deleted file mode 100755
index 3989782..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/ParsersResource.java
+++ /dev/null
@@ -1,111 +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.apache.juneau.server.annotation.Inherit.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.plaintext.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- * Validates correct parser is used.
- */
-@RestResource(
- path="/testParsers",
- parsers=ParsersResource.TestParserA.class,
- serializers=PlainTextSerializer.class
-)
-public class ParsersResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- @Consumes("text/a")
- public static class TestParserA extends ReaderParser {
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return (T)("text/a - " + IOUtils.read(session.getReader()).trim());
- }
- }
-
- //====================================================================================================
- // Parser defined on class.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testParserOnClass")
- public String testParserOnClass(@Content String in) {
- return in;
- }
-
- //====================================================================================================
- // Parser defined on method.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testParserOnMethod", parsers=TestParserB.class)
- public String testParserOnMethod(@Content String in) {
- return in;
- }
-
- @Consumes("text/b")
- public static class TestParserB extends ReaderParser {
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return (T)("text/b - " + IOUtils.read(session.getReader()).trim());
- }
- }
-
- //====================================================================================================
- // Parser overridden on method.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testParserOverriddenOnMethod", parsers={TestParserB.class,TestParserC.class}, parsersInherit=PARSERS)
- public String testParserOverriddenOnMethod(@Content String in) {
- return in;
- }
-
- @Consumes("text/c")
- public static class TestParserC extends ReaderParser {
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return (T)("text/c - " + IOUtils.read(session.getReader()).trim());
- }
- }
-
- //====================================================================================================
- // Parser with different Accept than Content-Type.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testParserWithDifferentMediaTypes", parsers={TestParserD.class}, parsersInherit=PARSERS)
- public String testParserWithDifferentMediaTypes(@Content String in) {
- return in;
- }
-
- @Consumes({"text/a","text/d"})
- public static class TestParserD extends ReaderParser {
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return (T)("text/d - " + IOUtils.read(session.getReader()).trim());
- }
- }
-
- //====================================================================================================
- // Check for valid error response.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testValidErrorResponse")
- public String testValidErrorResponse(@Content String in) {
- return in;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/PathResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/PathResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/PathResource.java
deleted file mode 100755
index b103aa3..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/PathResource.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- * Tests the RestServlet.getPath() method.
- */
-@RestResource(
- path="/testPath",
- children={
- PathResource.TestPath2.class
- }
-)
-public class PathResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Basic tests
- //====================================================================================================
- @RestMethod(name="GET", path="/")
- public String doGet() {
- return getPath();
- }
-
- @RestResource(
- path="/testPath2",
- children={
- PathResource.TestPath3.class
- }
- )
- public static class TestPath2 extends RestServletDefault {
- private static final long serialVersionUID = 1L;
- // Basic tests
- @RestMethod(name="GET", path="/")
- public String doGet() {
- return getPath();
- }
- }
-
- @RestResource(
- path="/testPath3"
- )
- public static class TestPath3a extends RestServletDefault {
- private static final long serialVersionUID = 1L;
- // Basic tests
- @RestMethod(name="GET", path="/")
- public String doGet() {
- return getPath();
- }
- }
-
- public static class TestPath3 extends TestPath3a {
- 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/PathsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/PathsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/PathsResource.java
deleted file mode 100755
index 8f88024..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/PathsResource.java
+++ /dev/null
@@ -1,72 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.*;
-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/PropertiesResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/PropertiesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/PropertiesResource.java
deleted file mode 100755
index 2385929..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/PropertiesResource.java
+++ /dev/null
@@ -1,89 +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 java.lang.String.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.serializer.*;
-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/RestClient2Resource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/RestClient2Resource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/RestClient2Resource.java
deleted file mode 100755
index 6c34966..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/RestClient2Resource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import java.io.*;
-
-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/Root.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/Root.java b/juneau-server-test/src/main/java/org/apache/juneau/server/Root.java
deleted file mode 100755
index 1d3f555..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/Root.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.microservice.resources.*;
-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/SerializersResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/SerializersResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/SerializersResource.java
deleted file mode 100755
index bad3a9e..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/SerializersResource.java
+++ /dev/null
@@ -1,102 +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.apache.juneau.server.annotation.Inherit.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.serializer.*;
-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";
- }
-}
[05/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/DefaultContentTypesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/DefaultContentTypesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/DefaultContentTypesTest.java
new file mode 100755
index 0000000..28bb43c
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/DefaultContentTypesTest.java
@@ -0,0 +1,497 @@
+// ***************************************************************************************************************************
+// * 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 org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+
+public class DefaultContentTypesTest {
+
+ private static String URL = "/testDefaultContentTypes";
+ private static boolean debug = false;
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on servlet annotation are picked up.
+ //====================================================================================================
+ @Test
+ public void testDefaultHeadersOnServletAnnotation() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+
+ String url = URL + "/testDefaultHeadersOnServletAnnotation";
+
+ client.setAccept("").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ client.setAccept("text/s1").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p2", r);
+
+ client.setAccept("").setContentType("text/p1");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p1", r);
+
+ client.setAccept("text/s1").setContentType("text/p1");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p1", r);
+
+ client.setAccept("text/s2").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ client.setAccept("").setContentType("text/p2");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ client.setAccept("text/s2").setContentType("text/p2");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ try {
+ client.setAccept("text/s3").setContentType("");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/s3'",
+ "Supported media-types: [text/s1, text/s2]"
+ );
+ }
+
+ try {
+ client.setAccept("").setContentType("text/p3");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p3'",
+ "Supported media-types: [text/p1, text/p2]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s3").setContentType("text/p3");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p3'",
+ "Supported media-types: [text/p1, text/p2]"
+ );
+ }
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on servlet annotation are picked up
+ // when @RestMethod.parsers/serializers annotations are used.
+ //====================================================================================================
+ @Test
+ public void testRestMethodParsersSerializers() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+
+ String url = URL + "/testRestMethodParsersSerializers";
+
+ try {
+ client.setAccept("").setContentType("");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p2'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s1").setContentType("");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p2'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("").setContentType("text/p1");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p1'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s1").setContentType("text/p1");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p1'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s2").setContentType("");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p2'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("").setContentType("text/p2");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p2'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s2").setContentType("text/p2");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p2'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s3").setContentType("");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p2'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("").setContentType("text/p3");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/s2'",
+ "Supported media-types: [text/s3]"
+ );
+ }
+
+ client.setAccept("text/s3").setContentType("text/p3");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on servlet annotation are picked up
+ // when @RestMethod.addParsers/addSerializers annotations are used.
+ //====================================================================================================
+ @Test
+ public void testRestMethodAddParsersSerializers() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+
+ String url = URL + "/testRestMethodAddParsersSerializers";
+
+ client.setAccept("").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ client.setAccept("text/s1").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p2", r);
+
+ client.setAccept("").setContentType("text/p1");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p1", r);
+
+ client.setAccept("text/s1").setContentType("text/p1");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p1", r);
+
+ client.setAccept("text/s2").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ client.setAccept("").setContentType("text/p2");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ client.setAccept("text/s2").setContentType("text/p2");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ client.setAccept("text/s3").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p2", r);
+
+ client.setAccept("").setContentType("text/p3");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p3", r);
+
+ client.setAccept("text/s3").setContentType("text/p3");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ try {
+ client.setAccept("").setContentType("text/p4");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ // Note that parsers defined on method are listed before parsers defined on class.
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p4'",
+ "Supported media-types: [text/p3, text/p1, text/p2]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s4").setContentType("");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ // Note that serializers defined on method are listed before serializers defined on class.
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/s4'",
+ "Supported media-types: [text/s3, text/s1, text/s2]"
+ );
+ }
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Various Accept incantations.
+ //====================================================================================================
+ @Test
+ public void testAccept() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT).setContentType("text/p1");
+ String r;
+
+ String url = URL + "/testAccept";
+
+ // "*/*" should match the first serializer, not the default serializer.
+ client.setAccept("*/*");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p1", r);
+
+ // "text/*" should match the first serializer, not the default serializer.
+ client.setAccept("text/*");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p1", r);
+
+ try {
+ client.setAccept("bad/*");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'bad/*'",
+ "Supported media-types: [text/s1, text/s2]"
+ );
+ }
+
+ client.setAccept("bad/*,text/*");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p1", r);
+
+ client.setAccept("text/*,bad/*");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p1", r);
+
+ client.setAccept("text/s1;q=0.5,text/s2");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p1", r);
+
+ client.setAccept("text/s1,text/s2;q=0.5");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p1", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on method annotation are picked up
+ // when @RestMethod.parsers/serializers annotations are used.
+ //====================================================================================================
+ @Test
+ public void testRestMethodParserSerializerAnnotations() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+
+ String url = URL + "/testRestMethodParserSerializerAnnotations";
+
+ client.setAccept("").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ try {
+ client.setAccept("text/s1").setContentType("");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/s1'",
+ "Supported media-types: [text/s3]"
+ );
+ }
+
+ try {
+ client.setAccept("").setContentType("text/p1");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p1'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s1").setContentType("text/p1");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p1'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s2").setContentType("");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/s2'",
+ "Supported media-types: [text/s3]"
+ );
+ }
+
+ try {
+ client.setAccept("").setContentType("text/p2");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p2'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s2").setContentType("text/p2");
+ r = client.doPut(url+"?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p2'",
+ "Supported media-types: [text/p3]"
+ );
+ }
+
+ client.setAccept("text/s3").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ client.setAccept("").setContentType("text/p3");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ client.setAccept("text/s3").setContentType("text/p3");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on method annotation are picked up
+ // when @RestMethod.addParsers/addSerializers annotations are used.
+ //====================================================================================================
+ @Test
+ public void testRestMethodAddParsersSerializersAnnotations() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+
+ String url = URL + "/testRestMethodAddParsersSerializersAnnotations";
+
+ client.setAccept("").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ client.setAccept("text/s1").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p3", r);
+
+ client.setAccept("").setContentType("text/p1");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p1", r);
+
+ client.setAccept("text/s1").setContentType("text/p1");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s1/p1", r);
+
+ client.setAccept("text/s2").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p3", r);
+
+ client.setAccept("").setContentType("text/p2");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p2", r);
+
+ client.setAccept("text/s2").setContentType("text/p2");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s2/p2", r);
+
+ client.setAccept("text/s3").setContentType("");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ client.setAccept("").setContentType("text/p3");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ client.setAccept("text/s3").setContentType("text/p3");
+ r = client.doPut(url, "").getResponseAsString();
+ assertEquals("s3/p3", r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/ErrorConditionsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/ErrorConditionsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ErrorConditionsTest.java
new file mode 100755
index 0000000..46364cc
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/ErrorConditionsTest.java
@@ -0,0 +1,220 @@
+// ***************************************************************************************************************************
+// * 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 org.apache.juneau.*;
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+
+public class ErrorConditionsTest {
+
+ private static String URL = "/testErrorConditions";
+ private static boolean debug = false;
+ private static RestClient client;
+
+ @BeforeClass
+ public static void beforeClass() {
+ client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ client.closeQuietly();
+ }
+ //====================================================================================================
+ // Test non-existent properties
+ //====================================================================================================
+ @Test
+ public void testNonExistentBeanProperties() throws Exception {
+ String url = URL + "/testNonExistentBeanProperties";
+
+ try {
+ client.doPut(url + "?noTrace=true", new ObjectMap("{f2:'foo'}")).getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Could not convert request body content to class type 'org.apache.juneau.server.test.ErrorConditionsResource$Test1' using parser 'org.apache.juneau.json.JsonParser'",
+ "Unknown property 'f2' encountered while trying to parse into class 'org.apache.juneau.server.test.ErrorConditionsResource$Test1'");
+ }
+
+ try {
+ client.doPut(url + "?noTrace=true", new ObjectMap("{f1:'foo', f2:'foo'}")).getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Could not convert request body content to class type 'org.apache.juneau.server.test.ErrorConditionsResource$Test1' using parser 'org.apache.juneau.json.JsonParser'",
+ "Unknown property 'f2' encountered while trying to parse into class 'org.apache.juneau.server.test.ErrorConditionsResource$Test1'");
+ }
+ }
+
+ //====================================================================================================
+ // Test trying to set properties to wrong data type
+ //====================================================================================================
+ @Test
+ public void testWrongDataType() throws Exception {
+ String url = URL + "/testWrongDataType";
+ try {
+ client.doPut(url + "?noTrace=true", new ObjectMap("{f1:'foo'}")).getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Could not convert request body content to class type 'org.apache.juneau.server.test.ErrorConditionsResource$Test2' using parser 'org.apache.juneau.json.JsonParser'.",
+ "Could not convert string 'foo' to class 'int'");
+ }
+ }
+
+ //====================================================================================================
+ // Test trying to parse into class with non-public no-arg constructor.
+ //====================================================================================================
+ @Test
+ public void testParseIntoNonConstructableBean() throws Exception {
+ String url = URL + "/testParseIntoNonConstructableBean";
+ try {
+ client.doPut(url + "?noTrace=true", new ObjectMap("{f1:1}")).getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Class 'org.apache.juneau.server.test.ErrorConditionsResource$Test3a' could not be instantiated.");
+ }
+ }
+
+ //====================================================================================================
+ // Test trying to parse into non-static inner class
+ //====================================================================================================
+ @Test
+ public void testParseIntoNonStaticInnerClass() throws Exception {
+ String url = URL + "/testParseIntoNonStaticInnerClass";
+ try {
+ client.doPut(url + "?noTrace=true", new ObjectMap("{f1:1}")).getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Class 'org.apache.juneau.server.test.ErrorConditionsResource$Test3b' could not be instantiated. Reason: 'No properties detected on bean class'");
+ }
+ }
+
+ //====================================================================================================
+ // Test trying to parse into non-public inner class
+ //====================================================================================================
+ @Test
+ public void testParseIntoNonPublicInnerClass() throws Exception {
+ String url = URL + "/testParseIntoNonPublicInnerClass";
+ try {
+ client.doPut(url + "?noTrace=true", new ObjectMap("{f1:1}")).getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Class 'org.apache.juneau.server.test.ErrorConditionsResource$Test3b1' could not be instantiated",
+ "Class is not public");
+ }
+ }
+
+ //====================================================================================================
+ // Test exception thrown during bean construction.
+ //====================================================================================================
+ @Test
+ public void testThrownConstructorException() throws Exception {
+ String url = URL + "/testThrownConstructorException";
+ try {
+ client.doPut(url + "?noTrace=true", "'foo'").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Could not convert request body content to class type 'org.apache.juneau.server.test.ErrorConditionsResource$Test3c' using parser 'org.apache.juneau.json.JsonParser'.",
+ "Caused by (RuntimeException): Test error");
+ }
+ }
+
+ //====================================================================================================
+ // Test trying to set parameters to invalid types.
+ //====================================================================================================
+ @Test
+ public void testSetParameterToInvalidTypes() throws Exception {
+ String url = URL + "/testSetParameterToInvalidTypes";
+ try {
+ client.doPut(url + "/1?noTrace=true&p1=foo", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Could not convert PARAM 'p1' to type 'int' on method 'org.apache.juneau.server.test.ErrorConditionsResource.testSetParameterToInvalidTypes'");
+ }
+
+ try {
+ client.doPut(url + "/foo?noTrace=true&p1=1", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Could not convert ATTR 'a1' to type 'int' on method 'org.apache.juneau.server.test.ErrorConditionsResource.testSetParameterToInvalidTypes'");
+ }
+
+ try {
+ client.doPut(url + "/1?noTrace=true&p1=1", "").setHeader("h1", "foo").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_BAD_REQUEST,
+ "Could not convert HEADER 'h1' to type 'int' on method 'org.apache.juneau.server.test.ErrorConditionsResource.testSetParameterToInvalidTypes'");
+ }
+ }
+
+ //====================================================================================================
+ // Test SC_NOT_FOUND & SC_METHOD_NOT_ALLOWED
+ //====================================================================================================
+ @Test
+ public void test404and405() throws Exception {
+ String url = URL + "/test404and405";
+ try {
+ client.doGet(URL + "/testNonExistent?noTrace=true").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_FOUND,
+ "Method 'GET' not found on resource with matching pattern on path '/testNonExistent'");
+ }
+
+ try {
+ client.doPut(url + "?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_FOUND,
+ "Method 'PUT' not found on resource with matching pattern on path '/test404and405'");
+ }
+
+ try {
+ client.doPost(url + "?noTrace=true", "").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_METHOD_NOT_ALLOWED,
+ "Method 'POST' not found on resource.");
+ }
+ }
+
+ //====================================================================================================
+ // Test SC_PRECONDITION_FAILED
+ //====================================================================================================
+ @Test
+ public void test412() throws Exception {
+ String url = URL + "/test412";
+ try {
+ client.doGet(url + "?noTrace=true").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_PRECONDITION_FAILED,
+ "Method 'GET' not found on resource on path '/test412' with matching matcher.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/GroupsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/GroupsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/GroupsTest.java
new file mode 100755
index 0000000..9fc58b3
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/GroupsTest.java
@@ -0,0 +1,122 @@
+// ***************************************************************************************************************************
+// * 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.json.*;
+import org.junit.*;
+
+
+public class GroupsTest {
+
+ private static String URL = "/testGroups";
+ private static boolean debug = false;
+
+ //====================================================================================================
+ // Serializer defined on class.
+ //====================================================================================================
+ @Test
+ public void testSerializerDefinedOnClass() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String url = URL + "/testSerializerDefinedOnClass";
+ String r;
+
+ try {
+ client.setContentType("text/p1");
+ r = client.doGet(url+"?noTrace=true").getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'application/json'",
+ "Supported media-types: [text/s1, text/s2]"
+ );
+ }
+
+ client.setAccept("text/s1").setContentType("");
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("text/s,GET", r);
+
+ client.setAccept("text/s2").setContentType("");
+ r = client.doGet(url).getResponseAsString();
+ assertEquals("text/s,GET", r);
+
+ try {
+ client.setAccept("text/s3").setContentType("");
+ r = client.doGet(url+"?noTrace=true").getResponseAsString();
+ assertEquals("text/s,GET", r);
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/s3'",
+ "Supported media-types: [text/s1, text/s2]"
+ );
+ }
+
+ try {
+ client.setAccept("text/json").setContentType("text/p1");
+ r = client.doPut(url+"?noTrace=true", new StringReader("foo")).getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/json'",
+ "Supported media-types: [text/s1, text/s2]"
+ );
+ }
+
+ try {
+ client.setAccept("text/s1").setContentType("text/json");
+ r = client.doPut(url+"?noTrace=true", new StringReader("foo")).getResponseAsString();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/json'",
+ "Supported media-types: [text/p1, text/p2]"
+ );
+ }
+
+ client.setContentType("text/p1").setAccept("text/s1");
+ r = client.doPut(url, new StringReader("foo")).getResponseAsString();
+ assertEquals("text/s,foo", r);
+
+ client.setContentType("text/p2").setAccept("text/s2");
+ r = client.doPut(url, new StringReader("foo")).getResponseAsString();
+ assertEquals("text/s,foo", r);
+
+ try {
+ client.setContentType("text/p1").setAccept("text/s3");
+ r = client.doPut(url+"?noTrace=true", new StringReader("foo")).getResponseAsString();
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported media-type in request header 'Accept': 'text/s3'",
+ "Supported media-types: [text/s1, text/s2]"
+ );
+ }
+
+ try {
+ client.setContentType("text/p3").setAccept("text/s1");
+ r = client.doPut(url+"?noTrace=true", new StringReader("foo")).getResponseAsString();
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported media-type in request header 'Content-Type': 'text/p3'",
+ "Supported media-types: [text/p1, text/p2]"
+ );
+ }
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/GzipTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/GzipTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/GzipTest.java
new file mode 100755
index 0000000..513c90d
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/GzipTest.java
@@ -0,0 +1,344 @@
+// ***************************************************************************************************************************
+// * 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 java.util.zip.*;
+
+import org.apache.http.impl.client.*;
+import org.apache.juneau.client.*;
+import org.apache.juneau.internal.*;
+import org.junit.*;
+
+/**
+ * Test Accept-Encoding and Content-Encoding handling.
+ *
+ * Note: WAS does automatic gzip decompression on http request messages, so we have to invent
+ * our own 'mycoding' compression.
+ */
+public class GzipTest {
+
+ private static boolean debug = false;
+
+ private static String testGzipOff = "/testGzipOff";
+ private static String testGzipOn = "/testGzipOn";
+
+ // Converts string into a GZipped input stream.
+ private static InputStream compress(String contents) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(contents.length()>>1);
+ GZIPOutputStream gos = new GZIPOutputStream(baos);
+ gos.write(contents.getBytes());
+ gos.finish();
+ gos.close();
+ return new ByteArrayInputStream(baos.toByteArray());
+ }
+
+ private static String decompress(InputStream is) throws Exception {
+ return IOUtils.read(new GZIPInputStream(is));
+ }
+
+ //====================================================================================================
+ // Test with no compression enabled.
+ //====================================================================================================
+ @Test
+ public void testGzipOff() throws Exception {
+ RestClient c = new TestRestClient().setAccept("text/plain").setContentType("text/plain");
+ RestCall r;
+ String url = testGzipOff;
+
+ // *** GET ***
+
+ r = c.doGet(url);
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doGet(url).setHeader("Accept-Encoding", "");
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doGet(url).setHeader("Accept-Encoding", "*");
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doGet(url).setHeader("Accept-Encoding", "identity");
+ assertEquals("foo", r.getResponseAsString());
+
+ // Should match identity.
+ r = c.doGet(url).setHeader("Accept-Encoding", "mycoding");
+ assertEquals("foo", r.getResponseAsString());
+
+ // Shouldn't match.
+ try {
+ r = c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "mycoding,identity;q=0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': 'mycoding,identity;q=0'",
+ "Supported codings: [identity]"
+ );
+ }
+
+ // Shouldn't match.
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "mycoding,*;q=0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': 'mycoding,*;q=0'",
+ "Supported codings: [identity]"
+ );
+ }
+
+ // Should match identity
+ r = c.doGet(url).setHeader("Accept-Encoding", "identity;q=0.8,mycoding;q=0.6");
+ assertEquals("foo", r.getResponseAsString());
+
+ // Should match identity
+ r = c.doGet(url).setHeader("Accept-Encoding", "mycoding;q=0.8,identity;q=0.6");
+ assertEquals("foo", r.getResponseAsString());
+
+ // Should match identity
+ r = c.doGet(url).setHeader("Accept-Encoding", "mycoding;q=0.8,*;q=0.6");
+ assertEquals("foo", r.getResponseAsString());
+
+ // Should match identity
+ r = c.doGet(url).setHeader("Accept-Encoding", "*;q=0.8,myencoding;q=0.6");
+ assertEquals("foo", r.getResponseAsString());
+
+ // Shouldn't match
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "identity;q=0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0'",
+ "Supported codings: [identity]"
+ );
+ }
+
+ // Shouldn't match
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "identity;q=0.0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0.0'",
+ "Supported codings: [identity]"
+ );
+ }
+
+ // Shouldn't match
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "*;q=0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': '*;q=0'",
+ "Supported codings: [identity]"
+ );
+ }
+
+ // Shouldn't match
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "*;q=0.0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': '*;q=0.0'",
+ "Supported codings: [identity]"
+ );
+ }
+
+
+ // *** PUT ***
+
+ r = c.doPut(url, new StringReader("foo"));
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doPut(url, new StringReader("foo")).setHeader("Content-Encoding", "");
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doPut(url, new StringReader("foo")).setHeader("Content-Encoding", "identity");
+ assertEquals("foo", r.getResponseAsString());
+
+ try {
+ c.doPut(url+"?noTrace=true", compress("foo")).setHeader("Content-Encoding", "mycoding").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
+ "Unsupported encoding in request header 'Content-Encoding': 'mycoding'",
+ "Supported codings: [identity]"
+ );
+ }
+
+ c.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test with compression enabled.
+ //====================================================================================================
+ @Test
+ public void testGzipOn() throws Exception {
+
+ // Create a client that disables content compression support so that we can get the gzipped content directly.
+ CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(TestRestClient.getSSLSocketFactory()).disableContentCompression().build();
+
+ RestClient c = new TestRestClient(httpClient).setAccept("text/plain").setContentType("text/plain");
+ RestCall r;
+ String url = testGzipOn;
+
+ // *** GET ***
+
+ r = c.doGet(url);
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doGet(url).setHeader("Accept-Encoding", "");
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doGet(url).setHeader("Accept-Encoding", "*");
+ assertEquals("foo", decompress(r.getInputStream()));
+
+ r = c.doGet(url).setHeader("Accept-Encoding", "identity");
+ assertEquals("foo", r.getResponseAsString());
+
+ // Should match identity.
+ r = c.doGet(url).setHeader("Accept-Encoding", "mycoding");
+ assertEquals("foo", decompress(r.getInputStream()));
+
+ r = c.doGet(url).setHeader("Accept-Encoding", "mycoding,identity;q=0").connect();
+ assertEquals("foo", decompress(r.getInputStream()));
+
+ r = c.doGet(url).setHeader("Accept-Encoding", "mycoding,*;q=0").connect();
+ assertEquals("foo", decompress(r.getInputStream()));
+
+ // Should match identity
+ r = c.doGet(url).setHeader("Accept-Encoding", "identity;q=0.8,mycoding;q=0.6");
+ assertEquals("foo", r.getResponseAsString());
+
+ // Should match mycoding
+ r = c.doGet(url).setHeader("Accept-Encoding", "mycoding;q=0.8,identity;q=0.6");
+ assertEquals("foo", decompress(r.getInputStream()));
+
+ // Should match mycoding
+ r = c.doGet(url).setHeader("Accept-Encoding", "mycoding;q=0.8,*;q=0.6");
+ assertEquals("foo", decompress(r.getInputStream()));
+
+ // Should match identity
+ r = c.doGet(url).setHeader("Accept-Encoding", "*;q=0.8,myencoding;q=0.6");
+ assertEquals("foo", decompress(r.getInputStream()));
+
+ // Shouldn't match
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "identity;q=0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0'",
+ "Supported codings: [mycoding, identity]"
+ );
+ }
+
+ // Shouldn't match
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "identity;q=0.0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': 'identity;q=0.0'",
+ "Supported codings: [mycoding, identity]"
+ );
+ }
+
+ // Shouldn't match
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "*;q=0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': '*;q=0'",
+ "Supported codings: [mycoding, identity]"
+ );
+ }
+
+ // Shouldn't match
+ try {
+ c.doGet(url+"?noTrace=true").setHeader("Accept-Encoding", "*;q=0.0").connect();
+ fail("Exception expected");
+ } catch (RestCallException e) {
+ checkErrorResponse(debug, e, SC_NOT_ACCEPTABLE,
+ "Unsupported encoding in request header 'Accept-Encoding': '*;q=0.0'",
+ "Supported codings: [mycoding, identity]"
+ );
+ }
+
+
+ // *** PUT ***
+
+ r = c.doPut(url, new StringReader("foo"));
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doPut(url, new StringReader("foo")).setHeader("Content-Encoding", "");
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doPut(url, new StringReader("foo")).setHeader("Content-Encoding", "identity");
+ assertEquals("foo", r.getResponseAsString());
+
+ r = c.doPut(url, compress("foo")).setHeader("Content-Encoding", "mycoding");
+ assertEquals("foo", r.getResponseAsString());
+
+ c.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test with compression enabled but with servlet using output stream directly.
+ //====================================================================================================
+ @Test
+ public void testGzipOnDirect() throws Exception {
+ // Create a client that disables content compression support so that we can get the gzipped content directly.
+ CloseableHttpClient httpClient = HttpClientBuilder.create().setSSLSocketFactory(TestRestClient.getSSLSocketFactory()).build();
+ RestClient c = new TestRestClient(httpClient).setAccept("text/plain").setContentType("text/plain");
+ RestCall r = null;
+ String s = null;
+
+ // res.getOutputStream() called....should bypass encoding.
+ r = c.doGet(testGzipOn + "/direct").setHeader("Accept-Encoding", "mycoding");
+ s = r.getResponseAsString();
+ assertEquals("test", s);
+ assertTrue(r.getResponse().getHeaders("Content-Type")[0].getValue().contains("text/direct")); // Should get header set manually.
+ assertEquals(0, r.getResponse().getHeaders("Content-Encoding").length); // Should not be set.
+
+ // res.getWriter() called....should bypass encoding.
+ r = c.doGet(testGzipOn + "/direct2").setHeader("Accept-Encoding", "mycoding");
+ s = r.getResponseAsString();
+ assertEquals("test", s);
+ assertEquals(0, r.getResponse().getHeaders("Content-Encoding").length); // Should not be set.
+
+ // res.getNegotiateWriter() called....should NOT bypass encoding.
+ r = c.doGet(testGzipOn + "/direct3").setHeader("Accept-Encoding", "mycoding");
+ try {
+ assertEquals("mycoding", r.getResponse().getHeaders("content-encoding")[0].getValue());
+ } catch (RestCallException e) {
+ // OK - HttpClient doesn't know what mycoding is.
+ // Newer versions of HttpClient ignore this condition.
+ }
+
+ // res.getNegotiateWriter() called but @RestMethod(encoders={})...should bypass encoding.
+ r = c.doGet(testGzipOn + "/direct4").setHeader("Accept-Encoding", "mycoding");
+ s = r.getResponseAsString();
+ assertEquals("test", s);
+ assertEquals(0, r.getResponse().getHeaders("Content-Encoding").length); // Should not be set.
+
+ c.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/InheritanceTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/InheritanceTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/InheritanceTest.java
new file mode 100755
index 0000000..27f70f8
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/InheritanceTest.java
@@ -0,0 +1,126 @@
+// ***************************************************************************************************************************
+// * 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 InheritanceTest {
+
+ private static RestClient client;
+
+ @BeforeClass
+ public static void beforeClass() {
+ client = new TestRestClient();
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test serializer inheritance.
+ //====================================================================================================
+ @Test
+ public void testSerializers() throws Exception {
+ String r;
+ String url = "/testInheritanceSerializers";
+ r = client.doGet(url + "/test1").getResponseAsString();
+ assertEquals("['text/s3','text/s4','text/s1','text/s2']", r);
+
+ r = client.doGet(url + "/test2").getResponseAsString();
+ assertEquals("['text/s5']", r);
+
+ r = client.doGet(url + "/test3").getResponseAsString();
+ assertEquals("['text/s5','text/s3','text/s4','text/s1','text/s2']", r);
+ }
+
+ //====================================================================================================
+ // Test parser inheritance.
+ //====================================================================================================
+ @Test
+ public void testParsers() throws Exception {
+ String r;
+ String url = "/testInheritanceParsers";
+ r = client.doGet(url + "/test1").getResponseAsString();
+ assertEquals("['text/p3','text/p4','text/p1','text/p2']", r);
+
+ r = client.doGet(url + "/test2").getResponseAsString();
+ assertEquals("['text/p5']", r);
+
+ r = client.doGet(url + "/test3").getResponseAsString();
+ assertEquals("['text/p5','text/p3','text/p4','text/p1','text/p2']", r);
+ }
+
+ //====================================================================================================
+ // Test encoder inheritance.
+ //====================================================================================================
+ @Test
+ public void testEncoders() throws Exception {
+ String url = "/testInheritanceEncoders";
+ String r = client.doGet(url + "/test").getResponseAsString();
+ assertEquals("['e3','e4','e1','e2','identity']", r);
+ }
+
+ //====================================================================================================
+ // Test filter inheritance.
+ //====================================================================================================
+ @Test
+ public void testTransforms() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.class, JsonParser.class).setAccept("text/json+simple");
+ String r;
+ String url = "/testInheritanceTransforms";
+
+ r = client.doGet(url + "/test1").getResponseAsString();
+ assertEquals("['F1','F2','Foo3']", r);
+
+ r = client.doGet(url + "/test2").getResponseAsString();
+ assertEquals("['F1','F2','F3']", r);
+
+ r = client.doGet(url + "/test3").getResponseAsString();
+ assertEquals("['F1','F2','F3']", r);
+
+ r = client.doGet(url + "/test4").getResponseAsString();
+ assertEquals("['Foo1','Foo2','F3']", r);
+
+ r = client.doGet(url + "/test5").getResponseAsString();
+ assertEquals("['F1','F2','F3']", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test properties inheritance.
+ //====================================================================================================
+ @Test
+ public void testProperties() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.class, JsonParser.class).setAccept("text/json+simple");
+ String r;
+ String url = "/testInheritanceProperties";
+
+ r = client.doGet(url + "/test1").getResponseAsString();
+ assertEquals("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}", r);
+
+ r = client.doGet(url + "/test2?override").getResponseAsString();
+ assertEquals("{p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'}", r);
+
+ r = client.doGet(url + "/test2").getResponseAsString();
+ assertEquals("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'}", r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/JacocoDummyTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/JacocoDummyTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/JacocoDummyTest.java
new file mode 100755
index 0000000..27c531a
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/JacocoDummyTest.java
@@ -0,0 +1,38 @@
+// ***************************************************************************************************************************
+// * 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.lang.reflect.*;
+
+import org.apache.juneau.server.*;
+import org.junit.*;
+
+public class JacocoDummyTest {
+
+ //====================================================================================================
+ // Dummy code to add test coverage in Jacoco.
+ //====================================================================================================
+ @Test
+ public void accessPrivateConstructorsOnStaticUtilityClasses() throws Exception {
+
+ Class<?>[] classes = new Class[] {
+ RestUtils.class
+ };
+
+ for (Class<?> c : classes) {
+ Constructor<?> c1 = c.getDeclaredConstructor();
+ c1.setAccessible(true);
+ c1.newInstance();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/LargePojosTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/LargePojosTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/LargePojosTest.java
new file mode 100755
index 0000000..c06b18f
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/LargePojosTest.java
@@ -0,0 +1,83 @@
+// ***************************************************************************************************************************
+// * 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.client.*;
+import org.apache.juneau.html.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.urlencoding.*;
+import org.apache.juneau.xml.*;
+import org.junit.*;
+
+@Ignore
+public class LargePojosTest {
+
+ private static String URL = "/testLargePojos";
+ boolean debug = false;
+
+ //====================================================================================================
+ // Test how long it takes to serialize/parse various content types.
+ //====================================================================================================
+ @Test
+ public void test() throws Exception {
+ LargePojo p;
+ long t;
+ RestClient c;
+
+ System.err.println("\n---Testing JSON---");
+ c = new TestRestClient(JsonSerializer.class, JsonParser.class);
+ for (int i = 1; i <= 3; i++) {
+ t = System.currentTimeMillis();
+ p = c.doGet(URL).getResponse(LargePojo.class);
+ System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
+ t = System.currentTimeMillis();
+ c.doPut(URL, p).run();
+ System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
+ }
+
+ System.err.println("\n---Testing XML---");
+ c = new TestRestClient(XmlSerializer.class, XmlParser.class);
+ for (int i = 1; i <= 3; i++) {
+ t = System.currentTimeMillis();
+ p = c.doGet(URL).getResponse(LargePojo.class);
+ System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
+ t = System.currentTimeMillis();
+ c.doPut(URL, p).run();
+ System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
+ }
+
+ System.err.println("\n---Testing HTML---");
+ c = new TestRestClient(HtmlSerializer.class, HtmlParser.class).setAccept("text/html+stripped");
+ for (int i = 1; i <= 3; i++) {
+ t = System.currentTimeMillis();
+ p = c.doGet(URL).getResponse(LargePojo.class);
+ System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
+ t = System.currentTimeMillis();
+ c.doPut(URL, p).run();
+ System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
+ }
+
+ System.err.println("\n---Testing UrlEncoding---");
+ c = new TestRestClient(UonSerializer.class, UonParser.class);
+ for (int i = 1; i <= 3; i++) {
+ t = System.currentTimeMillis();
+ p = c.doGet(URL).getResponse(LargePojo.class);
+ System.err.println("Download: ["+(System.currentTimeMillis() - t)+"] ms");
+ t = System.currentTimeMillis();
+ c.doPut(URL, p).run();
+ System.err.println("Upload: ["+(System.currentTimeMillis() - t)+"] ms");
+ }
+
+ c.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/test/MessagesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/MessagesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/MessagesTest.java
new file mode 100755
index 0000000..8d86fee
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/MessagesTest.java
@@ -0,0 +1,47 @@
+// ***************************************************************************************************************************
+// * 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 java.util.*;
+
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+/**
+ * Validates that resource bundles can be defined on both parent and child classes.
+ */
+public class MessagesTest {
+
+ //====================================================================================================
+ // Return contents of resource bundle.
+ //====================================================================================================
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void test() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.class,JsonParser.class);
+
+ // Parent resource should just pick up values from its bundle.
+ TreeMap r = client.doGet("/testMessages/test").getResponse(TreeMap.class);
+ assertObjectEquals("{key1:'value1a',key2:'value2a'}", r);
+
+ // Child resource should pick up values from both parent and child,
+ // ordered child before parent.
+ r = client.doGet("/testMessages2/test").getResponse(TreeMap.class);
+ assertObjectEquals("{key1:'value1a',key2:'value2b',key3:'value3b'}", r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/NlsPropertyTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/NlsPropertyTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/NlsPropertyTest.java
new file mode 100755
index 0000000..4c6c404
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/NlsPropertyTest.java
@@ -0,0 +1,48 @@
+// ***************************************************************************************************************************
+// * 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 NlsPropertyTest {
+
+ private static String URL = "/testNlsProperty";
+
+ //====================================================================================================
+ // Test getting an NLS property defined on a class.
+ //====================================================================================================
+ @Test
+ public void testInheritedFromClass() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String r = client.doGet(URL + "/testInheritedFromClass").getResponseAsString();
+ assertEquals("value1", r);
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Test getting an NLS property defined on a method.
+ //====================================================================================================
+ @Test
+ public void testInheritedFromMethod() throws Exception {
+ RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
+ String r = client.doGet(URL + "/testInheritedFromMethod").getResponseAsString();
+ assertEquals("value2", r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/NlsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/NlsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/NlsTest.java
new file mode 100755
index 0000000..e106066
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/NlsTest.java
@@ -0,0 +1,170 @@
+// ***************************************************************************************************************************
+// * 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.*;
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+public class NlsTest {
+
+ private static String URL = "/testNls";
+
+ // ====================================================================================================
+ // test1 - Pull labels from annotations only.
+ // ====================================================================================================
+ @Test
+ public void test1() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r = null;
+ String expected = null;
+
+ // Labels all pulled from annotations.
+ r = client.doOptions(URL + "/test1").getResponse(ObjectMap.class);
+ assertEquals("Test1.a", r.getString("label"));
+ assertEquals("Test1.b", r.getString("description"));
+ r = r.getObjectList("methods").getObjectMap(0);
+ assertEquals("test1", r.getString("javaMethod"));
+ assertEquals("POST", r.getString("httpMethod"));
+ expected = "[{category:'attr',name:'a',description:'Test1.d'},{category:'attr',name:'a2',description:'Test1.h'},{category:'attr',name:'e'},{category:'content',name:'',description:'Test1.f'},{category:'foo',name:'bar',description:'Test1.k'},{category:'header',name:'D',description:'Test1.g'},{category:'header',name:'D2',description:'Test1.j'},{category:'header',name:'g'},{category:'param',name:'b',description:'Test1.e'},{category:'param',name:'b2',description:'Test1.i'},{category:'param',name:'f'}]";
+ assertEquals(expected, r.getObjectList("input").toString());
+ expected = "[{status:200,description:'OK',output:[]},{status:201,description:'Test1.l',output:[{category:'foo',name:'bar',description:'Test1.m'}]}]";
+ assertEquals(expected, r.getObjectList("responses").toString());
+
+ client.closeQuietly();
+ }
+
+ // ====================================================================================================
+ // test2 - Pull labels from resource bundles only - simple keys.
+ // ====================================================================================================
+ @Test
+ public void test2() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r = null;
+ String expected = null;
+
+ // Labels all pulled from annotations.
+ r = client.doOptions(URL + "/test2").getResponse(ObjectMap.class);
+ assertEquals("Test2.a", r.getString("label"));
+ assertEquals("Test2.b", r.getString("description"));
+ r = r.getObjectList("methods").getObjectMap(0);
+ assertEquals("test2", r.getString("javaMethod"));
+ assertEquals("POST", r.getString("httpMethod"));
+ expected = "[{category:'attr',name:'a',description:'Test2.d'},{category:'attr',name:'a2',description:'Test2.h'},{category:'attr',name:'e'},{category:'content',name:'',description:'Test2.f'},{category:'foo',name:'bar',description:'Test2.k'},{category:'header',name:'D',description:'Test2.g'},{category:'header',name:'D2',description:'Test2.j'},{category:'header',name:'g'},{category:'param',name:'b',description:'Test2.e'},{category:'param',name:'b2',description:'Test2.i'},{category:'param',name:'f'}]";
+ assertEquals(expected, r.getObjectList("input").toString());
+ expected = "[{status:200,description:'OK2',output:[]},{status:201,description:'Test2.l',output:[{category:'foo',name:'bar',description:'Test2.m'}]}]";
+ assertEquals(expected, r.getObjectList("responses").toString());
+
+ client.closeQuietly();
+ }
+
+ // ====================================================================================================
+ // test3 - Pull labels from resource bundles only - keys with class names.
+ // ====================================================================================================
+ @Test
+ public void test3() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r = null;
+ String expected = null;
+
+ // Labels all pulled from annotations.
+ r = client.doOptions(URL + "/test3").getResponse(ObjectMap.class);
+ assertEquals("Test3.a", r.getString("label"));
+ assertEquals("Test3.b", r.getString("description"));
+ r = r.getObjectList("methods").getObjectMap(1);
+ assertEquals("test3", r.getString("javaMethod"));
+ assertEquals("POST", r.getString("httpMethod"));
+ expected = "[{category:'attr',name:'a',description:'Test3.d'},{category:'attr',name:'a2',description:'Test3.h'},{category:'attr',name:'e'},{category:'content',name:'',description:'Test3.f'},{category:'foo',name:'bar',description:'Test3.k'},{category:'header',name:'D',description:'Test3.g'},{category:'header',name:'D2',description:'Test3.j'},{category:'header',name:'g'},{category:'param',name:'b',description:'Test3.e'},{category:'param',name:'b2',description:'Test3.i'},{category:'param',name:'f'}]";
+ assertEquals(expected, r.getObjectList("input").toString());
+ expected = "[{status:200,description:'OK3',output:[]},{status:201,description:'Test3.l',output:[{category:'foo',name:'bar',description:'Test3.m'}]}]";
+ assertEquals(expected, r.getObjectList("responses").toString());
+
+ client.closeQuietly();
+ }
+
+ // ====================================================================================================
+ // test4 - Pull labels from resource bundles only. Values have localized variables to resolve.
+ // ====================================================================================================
+ @Test
+ public void test4() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r = null;
+ String expected = null;
+
+ // Labels all pulled from annotations.
+ r = client.doOptions(URL + "/test4").getResponse(ObjectMap.class);
+ assertEquals("baz", r.getString("label"));
+ assertEquals("baz", r.getString("description"));
+ r = r.getObjectList("methods").getObjectMap(0);
+ assertEquals("test4", r.getString("javaMethod"));
+ assertEquals("POST", r.getString("httpMethod"));
+ expected = "[{category:'attr',name:'a',description:'baz'},{category:'attr',name:'a2',description:'baz'},{category:'attr',name:'e'},{category:'content',name:'',description:'baz'},{category:'foo',name:'bar',description:'baz'},{category:'header',name:'D',description:'baz'},{category:'header',name:'D2',description:'baz'},{category:'header',name:'g'},{category:'param',name:'b',description:'baz'},{category:'param',name:'b2',description:'baz'},{category:'param',name:'f'}]";
+ assertEquals(expected, r.getObjectList("input").toString());
+ expected = "[{status:200,description:'foobazfoobazfoo',output:[]},{status:201,description:'baz',output:[{category:'foo',name:'bar',description:'baz'}]}]";
+ assertEquals(expected, r.getObjectList("responses").toString());
+
+ client.closeQuietly();
+ }
+
+ // ====================================================================================================
+ // test5 - Pull labels from resource bundles only. Values have request variables to resolve.
+ // ====================================================================================================
+ @Test
+ public void test5() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r = null;
+ String expected = null;
+
+ // Labels all pulled from annotations.
+ r = client.doOptions(URL + "/test5").getResponse(ObjectMap.class);
+ assertEquals("baz2", r.getString("label"));
+ assertEquals("baz2", r.getString("description"));
+ r = r.getObjectList("methods").getObjectMap(0);
+ assertEquals("test5", r.getString("javaMethod"));
+ assertEquals("POST", r.getString("httpMethod"));
+ expected = "[{category:'attr',name:'a',description:'baz2'},{category:'attr',name:'a2',description:'baz2'},{category:'attr',name:'e'},{category:'content',name:'',description:'baz2'},{category:'foo',name:'bar',description:'baz2'},{category:'header',name:'D',description:'baz2'},{category:'header',name:'D2',description:'baz2'},{category:'header',name:'g'},{category:'param',name:'b',description:'baz2'},{category:'param',name:'b2',description:'baz2'},{category:'param',name:'f'}]";
+ assertEquals(expected, r.getObjectList("input").toString());
+ expected = "[{status:200,description:'foobaz2foobaz2foo',output:[]},{status:201,description:'baz2',output:[{category:'foo',name:'bar',description:'baz2'}]}]";
+ assertEquals(expected, r.getObjectList("responses").toString());
+
+ client.closeQuietly();
+ }
+
+ // ====================================================================================================
+ // test6 - Pull labels from annotations only, but annotations contain variables.
+ // ====================================================================================================
+ @Test
+ public void test6() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r = null;
+ String expected = null;
+
+ // Labels all pulled from annotations.
+ r = client.doOptions(URL + "/test6").getResponse(ObjectMap.class);
+ assertEquals("baz", r.getString("label"));
+ assertEquals("baz", r.getString("description"));
+ r = r.getObjectList("methods").getObjectMap(0);
+ assertEquals("test6", r.getString("javaMethod"));
+ assertEquals("POST", r.getString("httpMethod"));
+ expected = "[{category:'attr',name:'a',description:'baz'},{category:'attr',name:'a2',description:'baz'},{category:'attr',name:'e'},{category:'content',name:'',description:'baz'},{category:'foo',name:'bar',description:'baz'},{category:'header',name:'D',description:'baz'},{category:'header',name:'D2',description:'baz'},{category:'header',name:'g'},{category:'param',name:'b',description:'baz'},{category:'param',name:'b2',description:'baz'},{category:'param',name:'f'}]";
+ assertEquals(expected, r.getObjectList("input").toString());
+ expected = "[{status:200,description:'OK',output:[]},{status:201,description:'baz',output:[{category:'foo',name:'bar',description:'baz'}]}]";
+ assertEquals(expected, r.getObjectList("responses").toString());
+
+ client.closeQuietly();
+ }
+
+}
[12/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
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();
- }
-}
[09/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/OverlappingMethodsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/OverlappingMethodsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/OverlappingMethodsTest.java
deleted file mode 100755
index 9377f6d..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/OverlappingMethodsTest.java
+++ /dev/null
@@ -1,170 +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 org.apache.juneau.client.*;
-import org.junit.*;
-
-public class OverlappingMethodsTest {
-
- private static String URL = "/testOverlappingMethods";
- private static boolean debug = false;
-
- //====================================================================================================
- // Overlapping guards
- //====================================================================================================
- @Test
- public void testOverlappingGuards1() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testOverlappingGuards1";
-
- r = client.doGet(url + "?t1=1").getResponseAsString();
- assertEquals("test1_doGet", r);
-
- try {
- client.doGet(url + "?noTrace=true").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_FORBIDDEN, "Access denied by guard");
- }
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Overlapping guards
- //====================================================================================================
- @Test
- public void testOverlappingGuards2() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testOverlappingGuards2";
- try {
- client.doGet(url + "?noTrace=true").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_FORBIDDEN, "Access denied by guard");
- }
-
- try {
- client.doGet(url + "?t1=1&noTrace=true").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_FORBIDDEN, "Access denied by guard");
- }
-
- try {
- client.doGet(url + "?t2=2&noTrace=true").connect();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_FORBIDDEN, "Access denied by guard");
- }
-
- r = client.doGet(url + "?t1=1&t2=2").getResponseAsString();
- assertEquals("test2_doGet", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Overlapping matchers
- //====================================================================================================
- @Test
- public void testOverlappingMatchers1() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testOverlappingMatchers1";
-
- r = client.doGet(url + "?t1=1").getResponseAsString();
- assertEquals("test3a", r);
-
- r = client.doGet(url + "?t2=2").getResponseAsString();
- assertEquals("test3b", r);
-
- r = client.doGet(url).getResponseAsString();
- assertEquals("test3c", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Overlapping matchers
- //====================================================================================================
- @Test
- public void testOverlappingMatchers2() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testOverlappingMatchers2";
-
- r = client.doGet(url + "?t1=1").getResponseAsString();
- assertEquals("test4b", r);
-
- r = client.doGet(url + "?t2=2").getResponseAsString();
- assertEquals("test4b", r);
-
- r = client.doGet(url + "?t1=1&t2=2").getResponseAsString();
- assertEquals("test4b", r);
-
- r = client.doGet(url + "?tx=x").getResponseAsString();
- assertEquals("test4a", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Overlapping URL patterns
- //====================================================================================================
- @Test
- public void testOverlappingUrlPatterns() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testOverlappingUrlPatterns";
-
- // [/test5] = [test5a]
- // [/test5/*] = [test5b] -- Cannot get called.
- // [/test5/foo] = [test5c]
- // [/test5/foo/*] = [test5d]
- // [/test5/{id}] = [test5e]
- // [/test5/{id}/*] = [test5f]
- // [/test5/{id}/foo] = [test5g]
- // [/test5/{id}/foo/*] = [test5h]
-
- r = client.doGet(url).getResponseAsString();
- assertEquals("test5a", r);
-
- r = client.doGet(url + "/foo").getResponseAsString();
- assertEquals("test5c", r);
-
- r = client.doGet(url + "/foo/x").getResponseAsString();
- assertEquals("test5d", r);
-
- r = client.doGet(url + "/x").getResponseAsString();
- assertEquals("test5e", r);
-
- r = client.doGet(url + "/x/x").getResponseAsString();
- assertEquals("test5f", r);
-
- r = client.doGet(url + "/x/foo").getResponseAsString();
- assertEquals("test5g", r);
-
- r = client.doGet(url + "/x/foo/x").getResponseAsString();
- assertEquals("test5h", r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/ParamsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/ParamsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/ParamsTest.java
deleted file mode 100755
index 578519c..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/ParamsTest.java
+++ /dev/null
@@ -1,716 +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.util.*;
-
-import org.apache.http.*;
-import org.apache.http.client.entity.*;
-import org.apache.http.entity.*;
-import org.apache.http.message.*;
-import org.apache.juneau.*;
-import org.apache.juneau.client.*;
-import org.apache.juneau.json.*;
-import org.junit.*;
-
-public class ParamsTest {
-
- private static String URL = "/testParams";
- private static boolean debug = false;
-
- //====================================================================================================
- // Basic tests
- //====================================================================================================
- @Test
- public void testBasic() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- RestCall r;
-
- // @Override
- // @RestMethod(name="GET",pattern="/")
- // public void doGet(RestRequest req, RestResponse res) {
- // res.setOutput("No args");
- // }
- r = client.doGet(URL);
- assertEquals("GET", r.getResponse(String.class));
-
- r = client.doGet(URL + "/getx?noTrace=true");
- try {
- r.connect();
- fail("Connection should have failed.");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_FOUND, "Method 'GET' not found on resource with matching pattern on path '/getx'");
- }
-
- // @RestMethod(name="GET",pattern="/get1")
- // public void doGet1(RestRequest req, RestResponse res) {
- // res.setOutput("/get1");
- // }
- r = client.doGet(URL + "/get1");
- assertEquals("GET /get1", r.getResponse(String.class));
-
- r = client.doGet(URL + "/get1a?noTrace=true");
- try {
- r.connect();
- fail("Connection should have failed.");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_FOUND, "Method 'GET' not found on resource with matching pattern on path '/get1a'");
- }
-
- // @RestMethod(name="GET",pattern="/get1/{foo}")
- // public void doGet(RestRequest req, RestResponse res, String foo) {
- // res.setOutput("/get1/" + foo);
- // }
- r = client.doGet(URL + "/get1/foo");
- assertEquals("GET /get1a foo", r.getResponse(String.class));
-
- // URL-encoded part should not get decoded before finding method to invoke.
- // This should match /get1/{foo} and not /get1/{foo}/{bar}
- // NOTE: When testing on Tomcat, must specify the following system property:
- // -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
- String x = "x%2Fy+z"; // [x/y z]
- r = client.doGet(URL + "/get1/"+x);
- assertEquals("GET /get1a x/y z", r.getResponse(String.class));
-
- r = client.doGet(URL + "/get1/"+x+"/"+x);
- assertEquals("GET /get1b x/y z,x/y z", r.getResponse(String.class));
-
- r = client.doGet(URL + "/get1/foo");
- assertEquals("GET /get1a foo", r.getResponse(String.class));
-
- r = client.doGet(URL + "/get1/foo/bar/baz?noTrace=true");
- try {
- r.connect();
- fail("Connection should have failed.");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_NOT_FOUND, "Method 'GET' not found on resource with matching pattern on path '/get1/foo/bar/baz'");
- }
-
- // @RestMethod(name="GET",pattern="/get3/{foo}/{bar}/*")
- // public void doGet3(RestRequest req, RestResponse res, String foo, int bar) {
- // res.setOutput("/get3/"+foo+"/"+bar+", remainder="+req.getRemainder());
- // }
- r = client.doGet(URL + "/get3/foo/123");
- assertEquals("GET /get3/foo/123 remainder=null", r.getResponse(String.class));
-
- r = client.doGet(URL + "/get3/foo/123/xxx");
- assertEquals("GET /get3/foo/123 remainder=xxx", r.getResponse(String.class));
-
- // // Test method name with overlapping name, remainder allowed.
- // @RestMethod(name="GET2")
- // public void get2(RestRequest req, RestResponse res) {
- // res.setOutput("GET2, remainder="+req.getRemainder());
- // }
- r = client.doGet(URL + "?method=get2");
- assertEquals("GET2 remainder=null", r.getResponse(String.class));
- r = client.doGet(URL + "/foo/bar?method=get2");
- assertEquals("GET2 remainder=foo/bar", r.getResponse(String.class));
- r = client.doGet(URL + "/foo/bar?method=GET2");
- assertEquals("GET2 remainder=foo/bar", r.getResponse(String.class));
-
- // // Default POST
- // @Override
- // public void doPost(RestRequest req, RestResponse res) {
- // res.setOutput("POST, remainder="+req.getRemainder());
- // }
- r = client.doPost(URL, "");
- assertEquals("POST remainder=null", r.getResponse(String.class));
- r = client.doPost(URL + "/foo", "");
- assertEquals("POST remainder=foo", r.getResponse(String.class));
-
- // // Bunch of different argument types
- // @RestMethod(name="POST",pattern="/person/{person}")
- // public void doPost(RestRequest req, RestResponse res, Person p) {
- // res.setOutput("POST, /person, name="+p.name+", age="+p.age+" remainder="+req.getRemainder());
- // }
- r = client.doPost(URL + "/person/(name=John+Smith,birthDate=Jan+12~,+1952)", "");
- assertEquals("POST /person/{name=John Smith,birthDate.year=1952} remainder=null", r.getResponse(String.class));
-
- // Fall through to top-level POST
- r = client.doPost(URL + "/person/(name:'John+Smith',age:123)/foo", "");
- assertEquals("POST remainder=person/(name:'John Smith',age:123)/foo", r.getResponse(String.class));
-
- // // Various primitive types
- // @RestMethod(name="PUT",pattern="/primitives/{xInt}.{xShort},{xLong}/{xChar}/{xFloat}/{xDouble}/{xByte}/{xBoolean}")
- // public void doPut1(RestRequest req, RestResponse res, int xInt, short xShort, long xLong, char xChar, float xFloat, double xDouble, byte xByte, boolean xBoolean) {
- // res.setOutput("PUT, /primitives/"+xInt+"."+xShort+","+xLong+"/"+xChar+"/"+xFloat+"/"+xDouble+"/"+xByte+"/"+xBoolean);
- // }
- r = client.doPut(URL + "/primitives/1/2/3/x/4/5/6/true", "");
- assertEquals("PUT /primitives/1/2/3/x/4.0/5.0/6/true", r.getResponse(String.class));
-
- // // Various primitive objects
- // @RestMethod(name="PUT",pattern="/primitiveObjects/{xInt}/{xShort}/{xLong}/{xChar}/{xFloat}/{xDouble}/{xByte}/{xBoolean}")
- // public void doPut1(RestRequest req, RestResponse res, Integer xInt, Short xShort, Long xLong, Character xChar, Float xFloat, Double xDouble, Byte xByte, Boolean xBoolean) {
- // res.setOutput("PUT /primitives/"+xInt+"/"+xShort+"/"+xLong+"/"+xChar+"/"+xFloat+"/"+xDouble+"/"+xByte+"/"+xBoolean);
- // }
- r = client.doPut(URL + "/primitiveObjects/1/2/3/x/4/5/6/true", "");
- assertEquals("PUT /primitiveObjects/1/2/3/x/4.0/5.0/6/true", r.getResponse(String.class));
-
- // // Object with forString(String) method
- // @RestMethod(name="PUT",pattern="/uuid/{uuid}")
- // public void doPut1(RestRequest req, RestResponse res, UUID uuid) {
- // res.setOutput("PUT /uuid/"+uuid);
- // }
- UUID uuid = UUID.randomUUID();
- r = client.doPut(URL + "/uuid/"+uuid, "");
- assertEquals("PUT /uuid/"+uuid, r.getResponse(String.class));
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @Param annotation - GET
- //====================================================================================================
- @Test
- public void testParamGet() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testParamGet";
-
- r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
- assertEquals("p1=[p1,p1,p1],p2=[2,2,2]", r);
-
- r = client.doGet(url + "?p1&p2").getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doGet(url).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doGet(url + "?p1").getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doGet(url + "?p2").getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
- assertEquals("p1=[foo,foo,foo],p2=[0,null,0]", r);
-
- r = client.doGet(url + "?p1&p2=1").getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[1,1,1]", r);
-
- String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
- r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
- assertEquals("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d e],p2=[1,1,1]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @Param(format=PLAIN) annotation - GET
- //====================================================================================================
- @Test
- public void testPlainParamGet() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testPlainParamGet";
-
- r = client.doGet(url + "?p1=(p1)").getResponseAsString();
- assertEquals("p1=[(p1),(p1),p1]", r);
-
- r = client.doGet(url + "?p1=$s(p1)").getResponseAsString();
- assertEquals("p1=[$s(p1),$s(p1),p1]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @Param annotation - POST
- //====================================================================================================
- @Test
- public void testParamPost() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testParamPost";
-
- r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
- assertEquals("p1=[p1,p1,p1],p2=[2,$n(2),2]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null,p2:0}")).getResponseAsString();
- assertEquals("p1=[null,\u0000,null],p2=[0,$n(0),0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null}")).getResponseAsString();
- assertEquals("p1=[null,\u0000,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p2:0}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,$n(0),0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
- assertEquals("p1=[foo,foo,foo],p2=[0,$n(0),0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null,p2:1}")).getResponseAsString();
- assertEquals("p1=[null,\u0000,null],p2=[1,$n(1),1]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d e,f/g%h=i j',p2:1}")).getResponseAsString();
- assertEquals("p1=[a/b%c=d e,f/g%h=i j,a/b%c=d e,f/g%h=i j,a/b%c=d e,f/g%h=i j],p2=[1,$n(1),1]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @Param(format=PLAIN) annotation - POST
- //====================================================================================================
- @Test
- public void testPlainParamPost() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testPlainParamPost";
-
- List<NameValuePair> nvps = new ArrayList<NameValuePair>();
- nvps.add(new BasicNameValuePair("p1", "(p1)"));
- HttpEntity he = new UrlEncodedFormEntity(nvps);
-
- r = client.doPost(url, he).getResponseAsString();
- assertEquals("p1=[(p1),(p1),p1]", r);
-
- nvps = new ArrayList<NameValuePair>();
- nvps.add(new BasicNameValuePair("p1", "$s(p1)"));
- he = new UrlEncodedFormEntity(nvps);
-
- r = client.doFormPost(url, he).getResponseAsString();
- assertEquals("p1=[$s(p1),$s(p1),p1]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @QParam annotation - GET
- //====================================================================================================
- @Test
- public void testQParamGet() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testQParamGet";
-
- r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
- assertEquals("p1=[p1,p1,p1],p2=[2,2,2]", r);
-
- r = client.doGet(url + "?p1&p2").getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doGet(url).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doGet(url + "?p1").getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doGet(url + "?p2").getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
- assertEquals("p1=[foo,foo,foo],p2=[0,null,0]", r);
-
- r = client.doGet(url + "?p1&p2=1").getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[1,1,1]", r);
-
- String x = "a%2Fb%25c%3Dd+e"; // [x/y%z=a+b]
- r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
- assertEquals("p1=[a/b%c=d e,a/b%c=d e,a/b%c=d e],p2=[1,1,1]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @QParam(format=PLAIN) annotation - GET
- //====================================================================================================
- @Test
- public void testPlainQParamGet() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testPlainQParamGet";
-
- r = client.doGet(url + "?p1=(p1)").getResponseAsString();
- assertEquals("p1=[(p1),(p1),p1]", r);
-
- r = client.doGet(url + "?p1=$s(p1)").getResponseAsString();
- assertEquals("p1=[$s(p1),$s(p1),p1]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @QParam annotation - POST
- //====================================================================================================
- @Test
- public void testQParamPost() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testQParamPost";
-
- r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null,p2:0}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p2:0}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null,p2:1}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d e,f/g%h=i j',p2:1}")).getResponseAsString();
- assertEquals("p1=[null,null,null],p2=[0,null,0]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @HasParam annotation - GET
- //====================================================================================================
- @Test
- public void testHasParamGet() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testHasParamGet";
-
- r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doGet(url + "?p1&p2").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doGet(url).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doGet(url + "?p1").getResponseAsString();
- assertEquals("p1=[true,true],p2=[false,false]", r);
-
- r = client.doGet(url + "?p2").getResponseAsString();
- assertEquals("p1=[false,false],p2=[true,true]", r);
-
- r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doGet(url + "?p1&p2=1").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- String x = "x%2Fy%25z%3Da+b"; // [x/y%z=a+b]
- r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @HasParam annotation - POST
- //====================================================================================================
- @Test
- public void testHasParamPost() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testHasParamPost";
-
- r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null,p2:0}")).getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null}")).getResponseAsString();
- assertEquals("p1=[true,true],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p2:0}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[true,true]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null,p2:1}")).getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d e,f/g%h=i j',p2:1}")).getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @HasQParam annotation - GET
- //====================================================================================================
- @Test
- public void testHasQParamGet() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testHasQParamGet";
-
- r = client.doGet(url + "?p1=p1&p2=2").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doGet(url + "?p1&p2").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doGet(url).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doGet(url + "?p1").getResponseAsString();
- assertEquals("p1=[true,true],p2=[false,false]", r);
-
- r = client.doGet(url + "?p2").getResponseAsString();
- assertEquals("p1=[false,false],p2=[true,true]", r);
-
- r = client.doGet(url + "?p1=foo&p2").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- r = client.doGet(url + "?p1&p2=1").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- String x = "x%2Fy%25z%3Da+b"; // [x/y%z=a+b]
- r = client.doGet(url + "?p1="+x+"&p2=1").getResponseAsString();
- assertEquals("p1=[true,true],p2=[true,true]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // @HasQParam annotation - POST
- //====================================================================================================
- @Test
- public void testHasQParamPost() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testHasQParamPost";
-
- r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null,p2:0}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p2:0}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:'foo',p2:0}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:null,p2:1}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{p1:'a/b%c=d e,f/g%h=i j',p2:1}")).getResponseAsString();
- assertEquals("p1=[false,false],p2=[false,false]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Form POSTS with @Content parameter
- //====================================================================================================
- @Test
- public void testFormPostAsContent() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testFormPostAsContent";
-
- r = client.doFormPost(url, new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
- assertEquals("bean=[{p1:'p1',p2:2}],qp1=[null],qp2=[0],hqp1=[false],hqp2=[false]", r);
-
- r = client.doFormPost(url, new ObjectMap("{}")).getResponseAsString();
- assertEquals("bean=[{p2:0}],qp1=[null],qp2=[0],hqp1=[false],hqp2=[false]", r);
-
- r = client.doFormPost(url+"?p1=p3&p2=4", new ObjectMap("{p1:'p1',p2:2}")).getResponseAsString();
- assertEquals("bean=[{p1:'p1',p2:2}],qp1=[p3],qp2=[4],hqp1=[true],hqp2=[true]", r);
-
- r = client.doFormPost(url+"?p1=p3&p2=4", new ObjectMap("{}")).getResponseAsString();
- assertEquals("bean=[{p2:0}],qp1=[p3],qp2=[4],hqp1=[true],hqp2=[true]", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test @Param and @QParam annotations when using multi-part parameters (e.g. &key=val1,&key=val2).
- //====================================================================================================
- @Test
- public void testMultiPartParams() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testMultiPartParams";
-
- String in = ""
- + "?p1=a&p1=b"
- + "&p2=1&p2=2"
- + "&p3=a&p3=b"
- + "&p4=1&p4=2"
- + "&p5=a&p5=b"
- + "&p6=1&p6=2"
- + "&p7=a&p7=b"
- + "&p8=1&p8=2"
- + "&p9=(a=1,b=2,c=false)&p9=(a=3,b=4,c=true)"
- + "&p10=(a=1,b=2,c=false)&p10=(a=3,b=4,c=true)"
- + "&p11=(a=1,b=2,c=false)&p11=(a=3,b=4,c=true)"
- + "&p12=(a=1,b=2,c=false)&p12=(a=3,b=4,c=true)";
- r = client.doGet(url + in).getResponseAsString();
- String e = "{"
- + "p1:['a','b'],"
- + "p2:[1,2],"
- + "p3:['a','b'],"
- + "p4:[1,2],"
- + "p5:['a','b'],"
- + "p6:[1,2],"
- + "p7:['a','b'],"
- + "p8:[1,2],"
- + "p9:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
- + "p10:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
- + "p11:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}],"
- + "p12:[{a:'1',b:2,c:false},{a:'3',b:4,c:true}]"
- +"}";
- assertEquals(e, r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Same as testMultiPartParams(), except make sure single values are still interpreted as collections.
- //====================================================================================================
- @Test
- public void testMultiPartParamsSingleValues() throws Exception {
- RestClient client = new TestRestClient().setHeader("Accept", "text/plain");
- String r;
- String url = URL + "/testMultiPartParams";
-
- String in = ""
- + "?p1=a"
- + "&p2=1"
- + "&p3=a"
- + "&p4=1"
- + "&p5=a"
- + "&p6=1"
- + "&p7=a"
- + "&p8=1"
- + "&p9=(a=1,b=2,c=false)"
- + "&p10=(a=1,b=2,c=false)"
- + "&p11=(a=1,b=2,c=false)"
- + "&p12=(a=1,b=2,c=false)";
- r = client.doGet(url + in).getResponseAsString();
- String e = "{"
- + "p1:['a'],"
- + "p2:[1],"
- + "p3:['a'],"
- + "p4:[1],"
- + "p5:['a'],"
- + "p6:[1],"
- + "p7:['a'],"
- + "p8:[1],"
- + "p9:[{a:'1',b:2,c:false}],"
- + "p10:[{a:'1',b:2,c:false}],"
- + "p11:[{a:'1',b:2,c:false}],"
- + "p12:[{a:'1',b:2,c:false}]"
- +"}";
- assertEquals(e, r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
- // using URLENC_expandedParams property.
- // A simple round-trip test to verify that both serializing and parsing works.
- //====================================================================================================
- @Test
- public void testFormPostsWithMultiParamsUsingProperty() throws Exception {
- RestClient client = new TestRestClient()
- .setHeader("Content-Type", "application/x-www-form-urlencoded")
- .setHeader("Accept", "application/x-www-form-urlencoded");
- String r;
- String url = URL + "/testFormPostsWithMultiParamsUsingProperty";
-
- String in = ""
- + "f01=a&f01=b"
- + "&f02=c&f02=d"
- + "&f03=1&f03=2"
- + "&f04=3&f04=4"
- + "&f05=(e,f)&f05=(g,h)"
- + "&f06=(i,j)&f06=(k,l)"
- + "&f07=(a=a,b=1,c=true)&f07=(a=b,b=2,c=false)"
- + "&f08=(a=a,b=1,c=true)&f08=(a=b,b=2,c=false)"
- + "&f09=((a=a,b=1,c=true))&f09=((a=b,b=2,c=false))"
- + "&f10=((a=a,b=1,c=true))&f10=((a=b,b=2,c=false))"
- + "&f11=a&f11=b"
- + "&f12=c&f12=d"
- + "&f13=1&f13=2"
- + "&f14=3&f14=4"
- + "&f15=(e,f)&f15=(g,h)"
- + "&f16=(i,j)&f16=(k,l)"
- + "&f17=(a=a,b=1,c=true)&f17=(a=b,b=2,c=false)"
- + "&f18=(a=a,b=1,c=true)&f18=(a=b,b=2,c=false)"
- + "&f19=((a=a,b=1,c=true))&f19=((a=b,b=2,c=false))"
- + "&f20=((a=a,b=1,c=true))&f20=((a=b,b=2,c=false))";
- r = client.doPost(url, new StringEntity(in)).getResponseAsString();
- assertEquals(in, r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Test multi-part parameter keys on bean properties of type array/Collection (i.e. &key=val1,&key=val2)
- // using @UrlEncoding(expandedParams=true) annotation.
- // A simple round-trip test to verify that both serializing and parsing works.
- //====================================================================================================
- @Test
- public void testFormPostsWithMultiParamsUsingAnnotation() throws Exception {
- RestClient client = new TestRestClient()
- .setHeader("Content-Type", "application/x-www-form-urlencoded")
- .setHeader("Accept", "application/x-www-form-urlencoded");
- String r;
- String url = URL + "/testFormPostsWithMultiParamsUsingAnnotation";
-
- String in = ""
- + "f01=a&f01=b"
- + "&f02=c&f02=d"
- + "&f03=1&f03=2"
- + "&f04=3&f04=4"
- + "&f05=(e,f)&f05=(g,h)"
- + "&f06=(i,j)&f06=(k,l)"
- + "&f07=(a=a,b=1,c=true)&f07=(a=b,b=2,c=false)"
- + "&f08=(a=a,b=1,c=true)&f08=(a=b,b=2,c=false)"
- + "&f09=((a=a,b=1,c=true))&f09=((a=b,b=2,c=false))"
- + "&f10=((a=a,b=1,c=true))&f10=((a=b,b=2,c=false))"
- + "&f11=a&f11=b"
- + "&f12=c&f12=d"
- + "&f13=1&f13=2"
- + "&f14=3&f14=4"
- + "&f15=(e,f)&f15=(g,h)"
- + "&f16=(i,j)&f16=(k,l)"
- + "&f17=(a=a,b=1,c=true)&f17=(a=b,b=2,c=false)"
- + "&f18=(a=a,b=1,c=true)&f18=(a=b,b=2,c=false)"
- + "&f19=((a=a,b=1,c=true))&f19=((a=b,b=2,c=false))"
- + "&f20=((a=a,b=1,c=true))&f20=((a=b,b=2,c=false))";
- r = client.doPost(url, new StringEntity(in)).getResponseAsString();
- assertEquals(in, r);
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/ParsersTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/ParsersTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/ParsersTest.java
deleted file mode 100755
index 260f2de..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/ParsersTest.java
+++ /dev/null
@@ -1,162 +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 org.apache.juneau.client.*;
-import org.apache.juneau.plaintext.*;
-import org.junit.*;
-
-public class ParsersTest {
-
- private static String URL = "/testParsers";
- private static boolean debug = false;
-
- //====================================================================================================
- // Parser defined on class.
- //====================================================================================================
- @Test
- public void testParserOnClass() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String url = URL + "/testParserOnClass";
-
- client.setContentType("text/a");
- String r = client.doPut(url, "test1").getResponseAsString();
- assertEquals("text/a - test1", r);
-
- try {
- client.setContentType("text/b");
- client.doPut(url + "?noTrace=true", "test1").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/b'",
- "Supported media-types: [text/a"
- );
- }
-
- client.setContentType("text/json").setAccept("text/json");
- r = client.doPut(url, "'test1'").getResponseAsString();
- assertEquals("\"test1\"", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Parser defined on method.
- //====================================================================================================
- @Test
- public void testParserOnMethod() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String url = URL + "/testParserOnMethod";
-
- client.setContentType("text/b");
- String r = client.doPut(url, "test2").getResponseAsString();
- assertEquals("text/b - test2", r);
-
- try {
- client.setContentType("text/a");
- client.doPut(url + "?noTrace=true", "test2").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/a'",
- "Supported media-types: [text/b]"
- );
- }
-
- try {
- client.setContentType("text/json");
- r = client.doPut(url + "?noTrace=true", "'test2'").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/json'",
- "Supported media-types: [text/b]"
- );
- }
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Parser overridden on method.
- //====================================================================================================
- @Test
- public void testParserOverriddenOnMethod() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String url = URL + "/testParserOverriddenOnMethod";
-
- client.setContentType("text/a");
- String r = client.doPut(url, "test3").getResponseAsString();
- assertEquals("text/a - test3", r);
-
- client.setContentType("text/b");
- r = client.doPut(url, "test3").getResponseAsString();
- assertEquals("text/b - test3", r);
-
- client.setContentType("text/json");
- r = client.doPut(url, "'test3'").getResponseAsString();
- assertEquals("test3", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Parser with different Accept than Content-Type.
- //====================================================================================================
- @Test
- public void testParserWithDifferentMediaTypes() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String url = URL + "/testParserWithDifferentMediaTypes";
-
- client.setContentType("text/a");
- String r = client.doPut(url, "test4").getResponseAsString();
- assertEquals("text/d - test4", r);
-
- client.setContentType("text/d");
- r = client.doPut(url, "test4").getResponseAsString();
- assertEquals("text/d - test4", r);
-
- client.setContentType("text/json");
- r = client.doPut(url, "'test4'").getResponseAsString();
- assertEquals("test4", r);
-
- client.closeQuietly();
- }
-
- //====================================================================================================
- // Check for valid error response.
- //====================================================================================================
- @Test
- public void testValidErrorResponse() throws Exception {
- RestClient client = new TestRestClient(PlainTextSerializer.class, PlainTextParser.class);
- String url = URL + "/testValidErrorResponse";
-
- try {
- client.setContentType("text/bad");
- client.doPut(url + "?noTrace=true", "test1").getResponseAsString();
- fail("Exception expected");
- } catch (RestCallException e) {
- checkErrorResponse(debug, e, SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported media-type in request header 'Content-Type': 'text/bad'",
- "Supported media-types: [text/a"
- );
- }
-
- client.closeQuietly();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/PathTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/PathTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/PathTest.java
deleted file mode 100755
index f34ed9e..0000000
--- a/juneau-server-test/src/test/java/org/apache/juneau/server/PathTest.java
+++ /dev/null
@@ -1,44 +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 PathTest {
-
- private static String URL = "/testPath";
-
- //====================================================================================================
- // Basic tests
- //====================================================================================================
- @Test
- public void testBasic() throws Exception {
- RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
- String r = null;
-
- r = client.doGet(URL).getResponse(String.class);
- assertEquals("/testPath", r);
-
- r = client.doGet(URL + "/testPath2").getResponse(String.class);
- assertEquals("/testPath/testPath2", r);
-
- r = client.doGet(URL + "/testPath2/testPath3").getResponse(String.class);
- assertEquals("/testPath/testPath2/testPath3", r);
-
- client.closeQuietly();
- }
-}
[14/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/StaticFilesResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/StaticFilesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/StaticFilesResource.java
deleted file mode 100755
index 6eac65b..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/StaticFilesResource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.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/TransformsParentResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/TransformsParentResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/TransformsParentResource.java
deleted file mode 100755
index de06b18..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/TransformsParentResource.java
+++ /dev/null
@@ -1,25 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.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/TransformsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/TransformsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/TransformsResource.java
deleted file mode 100755
index ca47d95..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/TransformsResource.java
+++ /dev/null
@@ -1,113 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.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/UrisResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/UrisResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/UrisResource.java
deleted file mode 100755
index bdd586a..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/UrisResource.java
+++ /dev/null
@@ -1,120 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.*;
-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/UrlContentResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/UrlContentResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/UrlContentResource.java
deleted file mode 100755
index c3b9f39..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/UrlContentResource.java
+++ /dev/null
@@ -1,58 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.json.*;
-import org.apache.juneau.plaintext.*;
-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/java/org/apache/juneau/server/test/AcceptCharsetResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/AcceptCharsetResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/AcceptCharsetResource.java
new file mode 100755
index 0000000..bc43ad4
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/AcceptCharsetResource.java
@@ -0,0 +1,76 @@
+// ***************************************************************************************************************************
+// * 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.RestServletContext.*;
+
+import java.io.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testAcceptCharset",
+ serializers={PlainTextSerializer.class},
+ properties={
+ // Some versions of Jetty default to ISO8601, so specify UTF-8 for test consistency.
+ @Property(name=REST_defaultCharset,value="utf-8")
+ }
+)
+public class AcceptCharsetResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Test that Q-values are being resolved correctly.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testQValues")
+ public String testQValues() {
+ return "foo";
+ }
+
+ //====================================================================================================
+ // Validate various Accept-Charset variations.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testCharsetOnResponse", parsers=TestParser.class, serializers=TestSerializer.class)
+ public String testCharsetOnResponse(@Content String in) {
+ return in;
+ }
+
+ @Consumes("text/plain")
+ public static class TestParser extends InputStreamParser {
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return (T)session.getProperties().getString("characterEncoding");
+ }
+ }
+
+ @Produces("text/plain")
+ public static class TestSerializer extends OutputStreamSerializer {
+ @Override /* Serializer */
+ protected void doSerialize(SerializerSession session, Object o) throws Exception {
+ Writer w = new OutputStreamWriter(session.getOutputStream());
+ w.append(o.toString()).append('/').append(session.getProperties().getString("characterEncoding"));
+ w.flush();
+ w.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/BeanContextPropertiesResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/BeanContextPropertiesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/BeanContextPropertiesResource.java
new file mode 100755
index 0000000..872c774
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/BeanContextPropertiesResource.java
@@ -0,0 +1,42 @@
+// ***************************************************************************************************************************
+// * 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 java.util.*;
+
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+import org.apache.juneau.transforms.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testBeanContext",
+ pojoSwaps=DateSwap.ISO8601DTZ.class
+)
+public class BeanContextPropertiesResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Validate that transforms defined on class transform to underlying bean context.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testClassTransforms/{d1}")
+ public Reader testClassTransforms(@Attr("d1") Date d1, @Param("d2") Date d2, @Header("X-D3") Date d3) throws Exception {
+ DateSwap df = DateSwap.ISO8601DTZ.class.newInstance();
+ return new StringReader(
+ "d1="+df.swap(d1)+",d2="+df.swap(d2)+",d3="+df.swap(d3)+""
+ );
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/CallbackStringsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/CallbackStringsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/CallbackStringsResource.java
new file mode 100755
index 0000000..8b8ee45
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/CallbackStringsResource.java
@@ -0,0 +1,53 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testCallback"
+)
+public class CallbackStringsResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Test GET
+ //====================================================================================================
+ @RestMethod(name="GET", path="/")
+ public ObjectMap test1(RestRequest req) throws Exception {
+ return new ObjectMap().append("method","GET").append("headers", getFooHeaders(req)).append("content", req.getInputAsString());
+ }
+
+ //====================================================================================================
+ // Test PUT
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/")
+ public ObjectMap testCharsetOnResponse(RestRequest req) throws Exception {
+ return new ObjectMap().append("method","PUT").append("headers", getFooHeaders(req)).append("content", req.getInputAsString());
+ }
+
+ private Map<String,Object> getFooHeaders(RestRequest req) {
+ Map<String,Object> m = new TreeMap<String,Object>();
+ for (Map.Entry<String,Object> e : req.getHeaders().entrySet())
+ if (e.getKey().startsWith("Foo-"))
+ m.put(e.getKey(), e.getValue());
+ return m;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/CharsetEncodingsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/CharsetEncodingsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/CharsetEncodingsResource.java
new file mode 100755
index 0000000..814455a
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/CharsetEncodingsResource.java
@@ -0,0 +1,55 @@
+// ***************************************************************************************************************************
+// * 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.annotation.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testCharsetEncodings",
+ defaultRequestHeaders={"Accept: text/s", "Content-Type: text/p"},
+ parsers={CharsetEncodingsResource.CtParser.class}, serializers={CharsetEncodingsResource.ASerializer.class}
+)
+public class CharsetEncodingsResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Consumes("text/p")
+ public static class CtParser extends ReaderParser {
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return (T)IOUtils.read(session.getReader());
+ }
+ }
+
+ @Produces("text/s")
+ public static class ASerializer extends WriterSerializer {
+ @Override /* Serializer */
+ protected void doSerialize(SerializerSession session, Object o) throws Exception {
+ session.getWriter().write(o.toString());
+ }
+ }
+
+ @RestMethod(name="PUT", path="/")
+ public String test1(RestRequest req, @Content String in) {
+ return req.getCharacterEncoding() + "/" + in + "/" + req.getCharacterEncoding();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/ClientVersionResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/ClientVersionResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ClientVersionResource.java
new file mode 100644
index 0000000..f3a10cb
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ClientVersionResource.java
@@ -0,0 +1,93 @@
+// ***************************************************************************************************************************
+// * 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.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testClientVersion",
+ children={
+ ClientVersionResource.DefaultHeader.class,
+ ClientVersionResource.CustomHeader.class
+ }
+)
+@SuppressWarnings("serial")
+public class ClientVersionResource extends Resource {
+
+ @RestResource(
+ path="/defaultHeader"
+ )
+ public static class DefaultHeader extends Resource {
+
+ @RestMethod(name="GET", path="/")
+ public String test0() {
+ return "no-version";
+ }
+
+ @RestMethod(name="GET", path="/", clientVersion="[0.0,1.0)")
+ public String test1() {
+ return "[0.0,1.0)";
+ }
+
+ @RestMethod(name="GET", path="/", clientVersion="[1.0,1.0]")
+ public String test2() {
+ return "[1.0,1.0]";
+ }
+
+ @RestMethod(name="GET", path="/", clientVersion="[1.1,2)")
+ public String test3() {
+ return "[1.1,2)";
+ }
+
+ @RestMethod(name="GET", path="/", clientVersion="2")
+ public String test4() {
+ return "2";
+ }
+ }
+
+ @RestResource(
+ path="/customHeader",
+ clientVersionHeader="Custom-Client-Version"
+ )
+ public static class CustomHeader extends Resource {
+
+ @RestMethod(name="GET", path="/")
+ public String test0() {
+ return "no-version";
+ }
+
+ @RestMethod(name="GET", path="/", clientVersion="[0.0,1.0)")
+ public String test1() {
+ return "[0.0,1.0)";
+ }
+
+ @RestMethod(name="GET", path="/", clientVersion="[1.0,1.0]")
+ public String test2() {
+ return "[1.0,1.0]";
+ }
+
+ @RestMethod(name="GET", path="/", clientVersion="[1.1,2)")
+ public String test3() {
+ return "[1.1,2)";
+ }
+
+ @RestMethod(name="GET", path="/", clientVersion="2")
+ public String test4() {
+ return "2";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/ConfigResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/ConfigResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ConfigResource.java
new file mode 100755
index 0000000..bace723
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ConfigResource.java
@@ -0,0 +1,38 @@
+// ***************************************************************************************************************************
+// * 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.ini.*;
+import org.apache.juneau.microservice.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testConfig"
+)
+@SuppressWarnings("serial")
+public class ConfigResource extends Resource {
+
+ @RestMethod(name="GET", path="/")
+ public ConfigFile test1(RestRequest req) {
+ return req.getConfig();
+ }
+
+ @RestMethod(name="GET", path="/{key}/{class}")
+ public Object test2(RestRequest req, @Attr("key") String key, @Attr("class") Class<?> c) throws Exception {
+ return req.getConfig().getObject(c, key);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/ContentResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/ContentResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ContentResource.java
new file mode 100755
index 0000000..02e925d
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ContentResource.java
@@ -0,0 +1,81 @@
+// ***************************************************************************************************************************
+// * 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.RestServletContext.*;
+
+import java.util.*;
+
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testContent",
+ properties={
+ @Property(name=REST_allowMethodParam, value="*")
+ }
+)
+public class ContentResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Basic tests
+ //====================================================================================================
+ @RestMethod(name="POST", path="/boolean")
+ public boolean testBool(@Content boolean b) {
+ return b;
+ }
+
+ @RestMethod(name="POST", path="/Boolean")
+ public Boolean testBoolean(@Content Boolean b) {
+ return b;
+ }
+
+ @RestMethod(name="POST", path="/int")
+ public int testInt(@Content int i) {
+ return i;
+ }
+
+ @RestMethod(name="POST", path="/Integer")
+ public Integer testInteger(@Content Integer i) {
+ return i;
+ }
+
+ @RestMethod(name="POST", path="/float")
+ public float testFloat(@Content float f) {
+ return f;
+ }
+
+ @RestMethod(name="POST", path="/Float")
+ public Float testFloat2(@Content Float f) {
+ return f;
+ }
+
+ @RestMethod(name="POST", path="/Map")
+ public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
+ return m;
+ }
+
+ @RestMethod(name="POST", path="/B")
+ public DTO2s.B testPojo1(@Content DTO2s.B b) {
+ return b;
+ }
+
+ @RestMethod(name="POST", path="/C")
+ public DTO2s.C testPojo2(@Content DTO2s.C c) {
+ return c;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/DTO2s.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/DTO2s.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/DTO2s.java
new file mode 100755
index 0000000..ad33642
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/DTO2s.java
@@ -0,0 +1,139 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.server.test;
+
+import java.util.*;
+
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.urlencoding.annotation.*;
+
+public class DTO2s {
+
+ @Bean(sort=true)
+ public static class A {
+ public String a;
+ public int b;
+ public boolean c;
+
+ public static A create() {
+ A t = new A();
+ t.a = "a";
+ t.b = 1;
+ t.c = true;
+ return t;
+ }
+
+ }
+
+ @SuppressWarnings("serial")
+ @Bean(sort=true)
+ public static class B {
+ public String[] f01;
+ public List<String> f02;
+ public int[] f03;
+ public List<Integer> f04;
+ public String[][] f05;
+ public List<String[]> f06;
+ public A[] f07;
+ public List<A> f08;
+ public A[][] f09;
+ public List<List<A>> f10;
+
+ private String[] f11;
+ private List<String> f12;
+ private int[] f13;
+ private List<Integer> f14;
+ private String[][] f15;
+ private List<String[]> f16;
+ private A[] f17;
+ private List<A> f18;
+ private A[][] f19;
+ private List<List<A>> f20;
+
+ public String[] getF11() { return f11; }
+ public List<String> getF12() { return f12; }
+ public int[] getF13() { return f13; }
+ public List<Integer> getF14() { return f14; }
+ public String[][] getF15() { return f15; }
+ public List<String[]> getF16() { return f16; }
+ public A[] getF17() { return f17; }
+ public List<A> getF18() { return f18; }
+ public A[][] getF19() { return f19; }
+ public List<List<A>> getF20() { return f20; }
+
+ public void setF11(String[] f11) { this.f11 = f11; }
+ public void setF12(List<String> f12) { this.f12 = f12; }
+ public void setF13(int[] f13) { this.f13 = f13; }
+ public void setF14(List<Integer> f14) { this.f14 = f14; }
+ public void setF15(String[][] f15) { this.f15 = f15; }
+ public void setF16(List<String[]> f16) { this.f16 = f16; }
+ public void setF17(A[] f17) { this.f17 = f17; }
+ public void setF18(List<A> f18) { this.f18 = f18; }
+ public void setF19(A[][] f19) { this.f19 = f19; }
+ public void setF20(List<List<A>> f20) { this.f20 = f20; }
+
+ static B create() {
+ B t = new B();
+ t.f01 = new String[]{"a","b"};
+ t.f02 = new ArrayList<String>(){{add("c");add("d");}};
+ t.f03 = new int[]{1,2};
+ t.f04 = new ArrayList<Integer>(){{add(3);add(4);}};
+ t.f05 = new String[][]{{"e","f"},{"g","h"}};
+ t.f06 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}};
+ t.f07 = new A[]{A.create(),A.create()};
+ t.f08 = new ArrayList<A>(){{add(A.create());add(A.create());}};
+ t.f09 = new A[][]{{A.create()},{A.create()}};
+ t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}};
+ t.setF11(new String[]{"a","b"});
+ t.setF12(new ArrayList<String>(){{add("c");add("d");}});
+ t.setF13(new int[]{1,2});
+ t.setF14(new ArrayList<Integer>(){{add(3);add(4);}});
+ t.setF15(new String[][]{{"e","f"},{"g","h"}});
+ t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}});
+ t.setF17(new A[]{A.create(),A.create()});
+ t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}});
+ t.setF19(new A[][]{{A.create()},{A.create()}});
+ t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}});
+ return t;
+ }
+ }
+
+ @UrlEncoding(expandedParams=true)
+ public static class C extends B {
+ @SuppressWarnings("serial")
+ static C create() {
+ C t = new C();
+ t.f01 = new String[]{"a","b"};
+ t.f02 = new ArrayList<String>(){{add("c");add("d");}};
+ t.f03 = new int[]{1,2};
+ t.f04 = new ArrayList<Integer>(){{add(3);add(4);}};
+ t.f05 = new String[][]{{"e","f"},{"g","h"}};
+ t.f06 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}};
+ t.f07 = new A[]{A.create(),A.create()};
+ t.f08 = new ArrayList<A>(){{add(A.create());add(A.create());}};
+ t.f09 = new A[][]{{A.create()},{A.create()}};
+ t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}};
+ t.setF11(new String[]{"a","b"});
+ t.setF12(new ArrayList<String>(){{add("c");add("d");}});
+ t.setF13(new int[]{1,2});
+ t.setF14(new ArrayList<Integer>(){{add(3);add(4);}});
+ t.setF15(new String[][]{{"e","f"},{"g","h"}});
+ t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}});
+ t.setF17(new A[]{A.create(),A.create()});
+ t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}});
+ t.setF19(new A[][]{{A.create()},{A.create()}});
+ t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}});
+ return t;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/DefaultContentTypesResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/DefaultContentTypesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/DefaultContentTypesResource.java
new file mode 100755
index 0000000..a35a9f3
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/DefaultContentTypesResource.java
@@ -0,0 +1,128 @@
+// ***************************************************************************************************************************
+// * 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.*;
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testDefaultContentTypes",
+ defaultRequestHeaders={" Accept : text/s2 "," Content-Type : text/p2 "},
+ parsers={DefaultContentTypesResource.P1.class,DefaultContentTypesResource.P2.class}, serializers={DefaultContentTypesResource.S1.class,DefaultContentTypesResource.S2.class}
+)
+@SuppressWarnings("synthetic-access")
+public class DefaultContentTypesResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Consumes("text/p1")
+ public static class P1 extends DummyParser { public P1() {super("p1");}}
+
+ @Consumes("text/p2")
+ public static class P2 extends DummyParser { public P2() {super("p2");}}
+
+ @Consumes("text/p3")
+ public static class P3 extends DummyParser { public P3() {super("p3");}}
+
+ @Produces("text/s1")
+ public static class S1 extends DummySerializer { public S1() {super("s1");}}
+
+ @Produces("text/s2")
+ public static class S2 extends DummySerializer { public S2() {super("s2");}}
+
+ @Produces("text/s3")
+ public static class S3 extends DummySerializer { public S3() {super("s3");}}
+
+ /**
+ * Test that default Accept and Content-Type headers on servlet annotation are picked up.
+ */
+ @RestMethod(name="PUT", path="/testDefaultHeadersOnServletAnnotation")
+ public String testDefaultHeadersOnServletAnnotation(@Content String in) {
+ return in;
+ }
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on servlet annotation are picked up
+ // when @RestMethod.parsers/serializers annotations are used.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testRestMethodParsersSerializers", parsers=P3.class, serializers=S3.class)
+ public String testRestMethodParsersSerializers(@Content String in) {
+ return in;
+ }
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on servlet annotation are picked up
+ // when @RestMethod.addParsers/addSerializers annotations are used.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testRestMethodAddParsersSerializers", parsers=P3.class, parsersInherit=PARSERS, serializers=S3.class, serializersInherit=SERIALIZERS)
+ public String testRestMethodAddParsersSerializers(@Content String in) {
+ return in;
+ }
+
+ //====================================================================================================
+ // Various Accept incantations.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testAccept")
+ public String testAccept(@Content String in) {
+ return in;
+ }
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on method annotation are picked up
+ // when @RestMethod.parsers/serializers annotations are used.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testRestMethodParserSerializerAnnotations", defaultRequestHeaders={"Accept: text/s3","Content-Type: text/p3"}, parsers=P3.class, serializers=S3.class)
+ public String testRestMethodParserSerializerAnnotations(@Content String in) {
+ return in;
+ }
+
+ //====================================================================================================
+ // Test that default Accept and Content-Type headers on method annotation are picked up
+ // when @RestMethod.addParsers/addSerializers annotations are used.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testRestMethodAddParsersSerializersAnnotations", defaultRequestHeaders={"Accept: text/s3","Content-Type: text/p3"}, parsers=P3.class, parsersInherit=PARSERS, serializers=S3.class, serializersInherit=SERIALIZERS)
+ public String testRestMethodAddParsersSerializersAnnotations(@Content String in) {
+ return in;
+ }
+
+ public static class DummyParser extends ReaderParser {
+ private String name;
+ private DummyParser(String name) {
+ this.name = name;
+ }
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return (T)name;
+ }
+ }
+
+ public static class DummySerializer extends WriterSerializer {
+ private String name;
+ private DummySerializer(String name) {
+ this.name = name;
+ }
+ @Override /* Serializer */
+ protected void doSerialize(SerializerSession session, Object output) throws Exception {
+ session.getWriter().write(name + "/" + output);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/ErrorConditionsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/ErrorConditionsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ErrorConditionsResource.java
new file mode 100755
index 0000000..45f9d2c
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/ErrorConditionsResource.java
@@ -0,0 +1,135 @@
+// ***************************************************************************************************************************
+// * 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.
+ * Validates correct parser is used.
+ */
+@RestResource(
+ path="/testErrorConditions"
+)
+public class ErrorConditionsResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Test non-existent properties
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testNonExistentBeanProperties")
+ public String testNonExistentBeanProperties(@Content Test1 in) {
+ return "OK";
+ }
+
+ public static class Test1 {
+ public String f1;
+ }
+
+ //====================================================================================================
+ // Test trying to set properties to wrong data type
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testWrongDataType")
+ public String testWrongDataType(@Content Test2 in) {
+ return "OK";
+ }
+
+ public static class Test2 {
+ public int f1;
+ }
+
+ //====================================================================================================
+ // Test trying to parse into class with non-public no-arg constructor.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testParseIntoNonConstructableBean")
+ public String testParseIntoNonConstructableBean(@Content Test3a in) {
+ return "OK";
+ }
+
+ public static class Test3a {
+ public int f1;
+ private Test3a(){}
+ }
+
+ //====================================================================================================
+ // Test trying to parse into non-static inner class
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testParseIntoNonStaticInnerClass")
+ public String testParseIntoNonStaticInnerClass(@Content Test3b in) {
+ return "OK";
+ }
+
+ public class Test3b {
+ public Test3b(){}
+ }
+
+ //====================================================================================================
+ // Test trying to parse into non-public inner class
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testParseIntoNonPublicInnerClass")
+ public String testParseIntoNonPublicInnerClass(@Content Test3b1 in) {
+ return "OK";
+ }
+
+ static class Test3b1 {
+ public Test3b1(){}
+ }
+
+ //====================================================================================================
+ // Test exception thrown during bean construction.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testThrownConstructorException")
+ public String testThrownConstructorException(@Content Test3c in) {
+ return "OK";
+ }
+
+ public static class Test3c {
+ public int f1;
+ private Test3c(){}
+ public static Test3c valueOf(String s) {
+ throw new RuntimeException("Test error");
+ }
+ }
+
+ //====================================================================================================
+ // Test trying to set parameters to invalid types.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testSetParameterToInvalidTypes/{a1}")
+ public String testSetParameterToInvalidTypes(@Param("p1") int t1, @Attr int a1, @Header("h1") int h1) {
+ return "OK";
+ }
+
+ //====================================================================================================
+ // Test SC_NOT_FOUND & SC_METHOD_NOT_ALLOWED
+ //====================================================================================================
+ @RestMethod(name="GET", path="/test404and405")
+ public String test404and405() {
+ return "OK";
+ }
+
+ //====================================================================================================
+ // Test SC_PRECONDITION_FAILED
+ //====================================================================================================
+ @RestMethod(name="GET", path="/test412", matchers=NeverMatcher.class)
+ public String test412() {
+ return "OK";
+ }
+
+ public static class NeverMatcher extends RestMatcher {
+ @Override /* RestMatcher */
+ public boolean matches(RestRequest req) {
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/GroupsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/GroupsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/GroupsResource.java
new file mode 100755
index 0000000..4f335bf
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/GroupsResource.java
@@ -0,0 +1,72 @@
+// ***************************************************************************************************************************
+// * 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.annotation.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testGroups"
+)
+public class GroupsResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ @Produces({"text/s1","text/s2"})
+ public static class SSerializer extends WriterSerializer {
+ @Override /* Serializer */
+ protected void doSerialize(SerializerSession session, Object output) throws Exception {
+ session.getWriter().write("text/s," + output);
+ }
+ }
+
+ @Consumes({"text/p1","text/p2"})
+ public static class PParser extends ReaderParser {
+ @SuppressWarnings("unchecked")
+ @Override /* Parser */
+ protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
+ return (T)IOUtils.read(session.getReader());
+ }
+ }
+
+
+ @Override /* RestServlet */
+ public SerializerGroup createSerializers(ObjectMap properties, Class<?>[] beanFilters, Class<?>[] pojoSwaps) throws Exception {
+ return new SerializerGroup().append(SSerializer.class).setProperties(properties).addBeanFilters(beanFilters).addPojoSwaps(pojoSwaps);
+ }
+
+ @Override /* RestServlet */
+ public ParserGroup createParsers(ObjectMap properties, Class<?>[] beanFilters, Class<?>[] pojoSwaps) throws Exception {
+ return new ParserGroup().append(PParser.class).setProperties(properties).addBeanFilters(beanFilters).addPojoSwaps(pojoSwaps);
+ }
+
+ //====================================================================================================
+ // Serializer defined on class.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testSerializerDefinedOnClass")
+ public String testSerializerDefinedOnClass_get() {
+ return "GET";
+ }
+
+ @RestMethod(name="PUT", path="/testSerializerDefinedOnClass")
+ public String testSerializerDefinedOnClass_put(@Content String in) {
+ return in;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/test/GzipResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/test/GzipResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/test/GzipResource.java
new file mode 100755
index 0000000..3810209
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/test/GzipResource.java
@@ -0,0 +1,111 @@
+// ***************************************************************************************************************************
+// * 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.encoders.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.server.*;
+import org.apache.juneau.server.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+public class GzipResource {
+
+ //================================================================================
+ // Encoder for "myencoding" encoding
+ //================================================================================
+ public static class MyEncoder extends GzipEncoder {
+ @Override /* Encoder */
+ public String[] getCodings() {
+ return new String[]{"mycoding"};
+ }
+ }
+
+ //====================================================================================================
+ // Test with no compression enabled.
+ //====================================================================================================
+ @RestResource(
+ path="/testGzipOff",
+ serializers=PlainTextSerializer.class,
+ parsers=PlainTextParser.class
+ )
+ public static class TestGzipOff extends RestServlet {
+ private static final long serialVersionUID = 1L;
+ @RestMethod(name="GET", path="/")
+ public String test1get() {
+ return "foo";
+ }
+ @RestMethod(name="PUT", path="/")
+ public String test1put(@Content String in) {
+ return in;
+ }
+ }
+
+ //====================================================================================================
+ // Test with compression enabled.
+ //====================================================================================================
+ @RestResource(
+ path="/testGzipOn",
+ serializers=PlainTextSerializer.class,
+ parsers=PlainTextParser.class,
+ encoders=MyEncoder.class
+ )
+ public static class TestGzipOn extends RestServlet {
+ private static final long serialVersionUID = 1L;
+ @RestMethod(name="GET", path="/")
+ public String test1() {
+ return "foo";
+ }
+ @RestMethod(name="PUT", path="/")
+ public String test1put(@Content String in) {
+ return in;
+ }
+ // This method bypasses the content type and encoding from
+ // the serializers and encoders when calling getOutputStream() directly.
+ @RestMethod(name="GET", path="/direct")
+ public void direct(RestResponse res) throws Exception {
+ res.setContentType("text/direct");
+ OutputStream os = res.getOutputStream();
+ os.write("test".getBytes());
+ os.flush();
+ }
+
+ // This method bypasses the content type and encoding from
+ // the serializers and encoders when calling getWriter() directly.
+ @RestMethod(name="GET", path="/direct2")
+ public void direct2(RestResponse res) throws Exception {
+ Writer w = res.getWriter();
+ w.append("test");
+ w.flush();
+ }
+
+ // This method uses getNegotiatedWriter() which should use GZip encoding.
+ @RestMethod(name="GET", path="/direct3")
+ public void direct3(RestResponse res) throws Exception {
+ Writer w = res.getNegotiatedWriter();
+ w.append("test");
+ w.flush();
+ }
+
+ // This method overrides the set of encoders at the method level and so shouldn't use GZip encoding.
+ @RestMethod(name="GET", path="/direct4", inheritEncoders=false)
+ public void direct4(RestResponse res) throws Exception {
+ Writer w = res.getNegotiatedWriter();
+ w.append("test");
+ w.flush();
+ }
+ }
+}
[03/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/PathsTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/PathsTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/PathsTest.java
new file mode 100755
index 0000000..4c28fec
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/PathsTest.java
@@ -0,0 +1,1368 @@
+// ***************************************************************************************************************************
+// * 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.*;
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+public class PathsTest {
+
+ private static String URL = "/testPaths";
+
+ //====================================================================================================
+ // Basic tests
+ //====================================================================================================
+ @Test
+ public void testBasic() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ ObjectMap r;
+ String url;
+
+ // [/test/testPaths]
+ // {
+ // pathInfo:null,
+ // pathInfoUndecoded:null,
+ // pathInfoParts:[],
+ // pathRemainder:null,
+ // pathRemainderUndecoded:null,
+ // requestURI:'/jazz/juneau/test/testPaths',
+ // requestParentURI:'/jazz/juneau/test',
+ // requestURL:'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletPath:'/juneau/test/testPaths',
+ // relativeServletURI:'/jazz/juneau/test/testPaths',
+ // pathRemainder2:null
+ // }
+ url = URL;
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertNull(r.getString("pathInfo"));
+ assertNull(r.getString("pathInfoUndecoded"));
+ assertEquals("[]", r.getObjectList("pathInfoParts").toString());
+ assertNull(r.getString("pathRemainder"));
+ assertNull(r.getString("pathRemainderUndecoded"));
+ assertNull(r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestParentURI").endsWith("/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+
+ // [/test/testPaths/]
+ // {
+ // pathInfo: '/',
+ // pathInfoUndecoded: '/',
+ // pathInfoParts: [
+ // ],
+ // pathRemainder: '',
+ // pathRemainderUndecoded: '',
+ // requestURI: '/jazz/juneau/test/testPaths/',
+ // requestParentURI: '/jazz/juneau/test',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/',
+ // servletPath: '/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: ''
+ // }
+ url = URL + '/';
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/", r.getString("pathInfo"));
+ assertEquals("/", r.getString("pathInfoUndecoded"));
+ assertEquals("[]", r.getObjectList("pathInfoParts").toString());
+ assertEquals("", r.getString("pathRemainder"));
+ assertEquals("", r.getString("pathRemainderUndecoded"));
+ assertEquals("", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/"));
+ assertTrue(r.getString("requestParentURI").endsWith("/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ // [/test/testPaths//]
+ // {
+ // pathInfo: '//',
+ // pathInfoParts: [''],
+ // pathRemainder: '/',
+ // requestURI: '/jazz/juneau/test/testPaths//',
+ // requestParentURI: '/jazz/juneau/test',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths//',
+ // servletPath: '/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '/'
+ // }
+ url = URL + "//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("//", r.getString("pathInfo"));
+ assertEquals("['']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/", r.getString("pathRemainder"));
+ assertEquals("/", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ // [/test/testPaths///]
+ // {
+ // pathInfo: '///',
+ // pathInfoParts: ['',''],
+ // pathRemainder: '//',
+ // requestURI: '/jazz/juneau/test/testPaths///',
+ // requestParentURI: '/jazz/juneau/test',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths///',
+ // servletPath: '/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '//'
+ // }
+ url = URL + "///";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("///", r.getString("pathInfo"));
+ assertEquals("['','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("//", r.getString("pathRemainder"));
+ assertEquals("//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths///"));
+ assertTrue(r.getString("requestParentURI").endsWith("/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths///"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ // [/test/testPaths/foo/bar]
+ // {
+ // pathInfo: '/foo/bar',
+ // pathInfoParts: [
+ // 'foo',
+ // 'bar'
+ // ],
+ // pathRemainder: 'foo/bar',
+ // requestURI: '/jazz/juneau/test/testPaths/foo/bar',
+ // requestParentURI: '/jazz/juneau/test/testPaths/foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/foo/bar',
+ // servletPath: '/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: 'foo/bar'
+ // }
+ url = URL + "/foo/bar";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/foo/bar", r.getString("pathInfo"));
+ assertEquals("['foo','bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals("foo/bar", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/foo/bar"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/foo"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/foo/bar"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ // [/test/testPaths/foo/bar/]
+ // {
+ // pathInfo: '/foo/bar/',
+ // pathInfoParts: [
+ // 'foo',
+ // 'bar'
+ // ],
+ // pathRemainder: 'foo/bar/',
+ // requestURI: '/jazz/juneau/test/testPaths/foo/bar/',
+ // requestParentURI: '/jazz/juneau/test/testPaths/foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/foo/bar/',
+ // servletPath: '/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: 'foo/bar/'
+ // }
+ url = URL + "/foo/bar/";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/foo/bar/", r.getString("pathInfo"));
+ assertEquals("['foo','bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo/bar/", r.getString("pathRemainder"));
+ assertEquals("foo/bar/", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/foo/bar/"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/foo"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/foo/bar/"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ // [/test/testPaths//foo//bar//]
+ // {
+ // pathInfo: '//foo//bar//',
+ // pathInfoParts: [
+ // '',
+ // 'foo',
+ // '',
+ // 'bar',
+ // ''
+ // ],
+ // pathRemainder: '/foo//bar//',
+ // requestURI: '/jazz/juneau/test/testPaths//foo//bar//',
+ // requestParentURI: '/jazz/juneau/test/testPaths//foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths//foo//bar//',
+ // servletPath: '/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '/foo//bar//'
+ // }
+ url = URL + "//foo//bar//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("//foo//bar//", r.getString("pathInfo"));
+ assertEquals("['','foo','','bar','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/foo//bar//", r.getString("pathRemainder"));
+ assertEquals("/foo//bar//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths//foo//bar//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths//foo/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths//foo//bar//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ // [/test/testPaths/foo%2Fbar]
+ // {
+ // pathInfo: '/foo//bar',
+ // pathInfoUndecoded: '/foo%2F%2Fbar',
+ // pathInfoParts: [
+ // 'foo//bar'
+ // ],
+ // pathRemainder: 'foo//bar',
+ // pathRemainderUndecoded: 'foo%2F%2Fbar',
+ // requestURI: '/jazz/juneau/test/testPaths/foo%2F%2Fbar',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/foo%2F%2Fbar',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: 'foo//bar',
+ // method: 1
+ // }
+ url = URL + "/foo%2F%2Fbar";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/foo//bar", r.getString("pathInfo"));
+ assertEquals("/foo%2F%2Fbar", r.getString("pathInfoUndecoded"));
+ assertEquals("['foo//bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo//bar", r.getString("pathRemainder"));
+ assertEquals("foo%2F%2Fbar", r.getString("pathRemainderUndecoded"));
+ assertEquals("foo//bar", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/foo%2F%2Fbar"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/foo%2F%2Fbar"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ // [/test/testPaths//foo%2Fbar//]
+ // {
+ // pathInfo: '//foo//bar//',
+ // pathInfoUndecoded: '//foo%2F%2Fbar//',
+ // pathInfoParts: [
+ // '',
+ // 'foo//bar',
+ // ''
+ // ],
+ // pathRemainder: '/foo//bar//',
+ // pathRemainderUndecoded: '/foo%2F%2Fbar//',
+ // requestURI: '/jazz/juneau/test/testPaths//foo%2F%2Fbar//',
+ // requestParentURI: '/jazz/juneau/test/testPaths/',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths//foo%2F%2Fbar//',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '/foo//bar//',
+ // method: 1
+ // }
+ url = URL + "//foo%2F%2Fbar//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("//foo//bar//", r.getString("pathInfo"));
+ assertEquals("//foo%2F%2Fbar//", r.getString("pathInfoUndecoded"));
+ assertEquals("['','foo//bar','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/foo//bar//", r.getString("pathRemainder"));
+ assertEquals("/foo%2F%2Fbar//", r.getString("pathRemainderUndecoded"));
+ assertEquals("/foo//bar//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths//foo%2F%2Fbar//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths//foo%2F%2Fbar//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ // [/test/testPaths/test2]
+ // {
+ // pathInfo: '/test2',
+ // pathInfoParts: [
+ // 'test2'
+ // ],
+ // pathRemainder: null,
+ // requestURI: '/jazz/juneau/test/testPaths/test2',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: null,
+ // method: 2
+ // }
+ url = URL + "/test2";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2", r.getString("pathInfo"));
+ assertEquals("['test2']", r.getObjectList("pathInfoParts").toString());
+ assertNull(r.getString("pathRemainder"));
+ assertNull(r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+
+ // [/test/testPaths/test2/]
+ // {
+ // pathInfo: '/test2/',
+ // pathInfoParts: [
+ // 'test2'
+ // ],
+ // pathRemainder: '',
+ // requestURI: '/jazz/juneau/test/testPaths/test2/',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2/',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '',
+ // method: 2
+ // }
+ url = URL + "/test2/";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/", r.getString("pathInfo"));
+ assertEquals("['test2']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("", r.getString("pathRemainder"));
+ assertEquals("", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ // [/test/testPaths/test2//]
+ // {
+ // pathInfo: '/test2//',
+ // pathInfoParts: [
+ // 'test2',
+ // ''
+ // ],
+ // pathRemainder: '/',
+ // requestURI: '/jazz/juneau/test/testPaths/test2//',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2//',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '/',
+ // method: 2
+ // }
+ url = URL + "/test2//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2//", r.getString("pathInfo"));
+ assertEquals("['test2','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/", r.getString("pathRemainder"));
+ assertEquals("/", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ // [/test/testPaths/test2///]
+ // {
+ // pathInfo: '/test2///',
+ // pathInfoParts: [
+ // 'test2',
+ // '',
+ // ''
+ // ],
+ // pathRemainder: '//',
+ // requestURI: '/jazz/juneau/test/testPaths/test2///',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2///',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '//',
+ // method: 2
+ // }
+ url = URL + "/test2///";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2///", r.getString("pathInfo"));
+ assertEquals("['test2','','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("//", r.getString("pathRemainder"));
+ assertEquals("//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2///"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2///"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ // [/test/testPaths/test2/foo/bar]
+ // {
+ // pathInfo: '/test2/foo/bar',
+ // pathInfoParts: [
+ // 'test2',
+ // 'foo',
+ // 'bar'
+ // ],
+ // pathRemainder: 'foo/bar',
+ // requestURI: '/jazz/juneau/test/testPaths/test2/foo/bar',
+ // requestParentURI: '/jazz/juneau/test/testPaths/test2/foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2/foo/bar',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: 'foo/bar',
+ // method: 2
+ // }
+ url = URL + "/test2/foo/bar";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/foo/bar", r.getString("pathInfo"));
+ assertEquals("['test2','foo','bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals("foo/bar", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/foo/bar"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2/foo"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/foo/bar"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ // [/test/testPaths/test2/foo/bar/]
+ // {
+ // pathInfo: '/test2/foo/bar/',
+ // pathInfoParts: [
+ // 'test2',
+ // 'foo',
+ // 'bar'
+ // ],
+ // pathRemainder: 'foo/bar/',
+ // requestURI: '/jazz/juneau/test/testPaths/test2/foo/bar/',
+ // requestParentURI: '/jazz/juneau/test/testPaths/test2/foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2/foo/bar/',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: 'foo/bar/',
+ // method: 2
+ // }
+ url = URL + "/test2/foo/bar/";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/foo/bar/", r.getString("pathInfo"));
+ assertEquals("['test2','foo','bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo/bar/", r.getString("pathRemainder"));
+ assertEquals("foo/bar/", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/foo/bar/"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2/foo"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/foo/bar/"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ // [/test/testPaths/test2//foo//bar//]
+ // {
+ // pathInfo: '/test2//foo//bar//',
+ // pathInfoParts: [
+ // 'test2',
+ // '',
+ // 'foo',
+ // '',
+ // 'bar',
+ // ''
+ // ],
+ // pathRemainder: '/foo//bar//',
+ // requestURI: '/jazz/juneau/test/testPaths/test2//foo//bar//',
+ // requestParentURI: '/jazz/juneau/test/testPaths/test2//foo/',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2//foo//bar//',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '/foo//bar//',
+ // method: 2
+ // }
+ url = URL + "/test2//foo//bar//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2//foo//bar//", r.getString("pathInfo"));
+ assertEquals("['test2','','foo','','bar','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/foo//bar//", r.getString("pathRemainder"));
+ assertEquals("/foo//bar//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2//foo//bar//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2//foo/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2//foo//bar//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ // [/test/testPaths/test2/foo%2Fbar]
+ // {
+ // pathInfo: '/test2/foo//bar',
+ // pathInfoUndecoded: '/test2/foo%2F%2Fbar',
+ // pathInfoParts: [
+ // 'test2',
+ // 'foo//bar'
+ // ],
+ // pathRemainder: 'foo//bar',
+ // pathRemainderUndecoded: 'foo%2F%2Fbar',
+ // requestURI: '/jazz/juneau/test/testPaths/test2/foo%2F%2Fbar',
+ // requestParentURI: '/jazz/juneau/test/testPaths/test2',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2/foo%2F%2Fbar',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: 'foo//bar',
+ // method: 2
+ // }
+ url = URL + "/test2/foo%2F%2Fbar";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/foo//bar", r.getString("pathInfo"));
+ assertEquals("/test2/foo%2F%2Fbar", r.getString("pathInfoUndecoded"));
+ assertEquals("['test2','foo//bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo//bar", r.getString("pathRemainder"));
+ assertEquals("foo%2F%2Fbar", r.getString("pathRemainderUndecoded"));
+ assertEquals("foo//bar", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/foo%2F%2Fbar"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/foo%2F%2Fbar"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ // [/test/testPaths/test2//foo%2Fbar//]
+ // {
+ // pathInfo: '/test2//foo//bar//',
+ // pathInfoUndecoded: '/test2//foo%2F%2Fbar//',
+ // pathInfoParts: [
+ // 'test2',
+ // '',
+ // 'foo//bar',
+ // ''
+ // ],
+ // pathRemainder: '/foo//bar//',
+ // pathRemainderUndecoded: '/foo%2F%2Fbar//',
+ // requestURI: '/jazz/juneau/test/testPaths/test2//foo%2F%2Fbar//',
+ // requestParentURI: '/jazz/juneau/test/testPaths/test2/',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/test2//foo%2F%2Fbar//',
+ // servletPath: '/juneau/test/testPaths',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test',
+ // relativeServletURI: '/jazz/juneau/test/testPaths',
+ // pathRemainder2: '/foo//bar//',
+ // method: 2
+ // }
+ url = URL + "/test2//foo%2F%2Fbar//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2//foo//bar//", r.getString("pathInfo"));
+ assertEquals("/test2//foo%2F%2Fbar//", r.getString("pathInfoUndecoded"));
+ assertEquals("['test2','','foo//bar','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/foo//bar//", r.getString("pathRemainder"));
+ assertEquals("/foo%2F%2Fbar//", r.getString("pathRemainderUndecoded"));
+ assertEquals("/foo//bar//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2//foo%2F%2Fbar//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2//foo%2F%2Fbar//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ // [/test/testPaths/a]
+ // {
+ // pathInfo: null,
+ // pathInfoParts: [
+ // ],
+ // pathRemainder: null,
+ // requestURI: '/jazz/juneau/test/testPaths/a',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: null,
+ // method: 3
+ // }
+ url = URL + "/a";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertNull(r.getString("pathInfo"));
+ assertEquals("[]", r.getObjectList("pathInfoParts").toString());
+ assertNull(r.getString("pathRemainder"));
+ assertNull(r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/]
+ // {
+ // pathInfo: '/',
+ // pathInfoParts: [
+ // ],
+ // pathRemainder: '',
+ // requestURI: '/jazz/juneau/test/testPaths/a/',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '',
+ // method: 3
+ // }
+ url = URL + "/a/";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/", r.getString("pathInfo"));
+ assertEquals("[]", r.getObjectList("pathInfoParts").toString());
+ assertEquals("", r.getString("pathRemainder"));
+ assertEquals("", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ // [/test/testPaths/a//]
+ // {
+ // pathInfo: '//',
+ // pathInfoParts: [
+ // ''
+ // ],
+ // pathRemainder: '/',
+ // requestURI: '/jazz/juneau/test/testPaths/a//',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a//',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '/',
+ // method: 3
+ // }
+ url = URL + "/a//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("//", r.getString("pathInfo"));
+ assertEquals("['']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/", r.getString("pathRemainder"));
+ assertEquals("/", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ // [/test/testPaths/a///]
+ // {
+ // pathInfo: '///',
+ // pathInfoParts: [
+ // '',
+ // ''
+ // ],
+ // pathRemainder: '//',
+ // requestURI: '/jazz/juneau/test/testPaths/a///',
+ // requestParentURI: '/jazz/juneau/test/testPaths',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a///',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '//',
+ // method: 3
+ // }
+ url = URL + "/a///";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("///", r.getString("pathInfo"));
+ assertEquals("['','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("//", r.getString("pathRemainder"));
+ assertEquals("//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a///"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a///"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/foo/bar]
+ // {
+ // pathInfo: '/foo/bar',
+ // pathInfoParts: [
+ // 'foo',
+ // 'bar'
+ // ],
+ // pathRemainder: 'foo/bar',
+ // requestURI: '/jazz/juneau/test/testPaths/a/foo/bar',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a/foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/foo/bar',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: 'foo/bar',
+ // method: 3
+ // }
+ url = URL + "/a/foo/bar";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/foo/bar", r.getString("pathInfo"));
+ assertEquals("['foo','bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals("foo/bar", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/foo/bar"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/foo"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/foo/bar"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/foo/bar/]
+ // {
+ // pathInfo: '/foo/bar/',
+ // pathInfoParts: [
+ // 'foo',
+ // 'bar'
+ // ],
+ // pathRemainder: 'foo/bar/',
+ // requestURI: '/jazz/juneau/test/testPaths/a/foo/bar/',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a/foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/foo/bar/',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: 'foo/bar/',
+ // method: 3
+ // }
+ url = URL + "/a/foo/bar/";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/foo/bar/", r.getString("pathInfo"));
+ assertEquals("['foo','bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo/bar/", r.getString("pathRemainder"));
+ assertEquals("foo/bar/", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/foo/bar/"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/foo"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/foo/bar/"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ // [/test/testPaths/a//foo//bar//]
+ // {
+ // pathInfo: '//foo//bar//',
+ // pathInfoParts: [
+ // '',
+ // 'foo',
+ // '',
+ // 'bar',
+ // ''
+ // ],
+ // pathRemainder: '/foo//bar//',
+ // requestURI: '/jazz/juneau/test/testPaths/a//foo//bar//',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a//foo/',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a//foo//bar//',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '/foo//bar//',
+ // method: 3
+ // }
+ url = URL + "/a//foo//bar//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("//foo//bar//", r.getString("pathInfo"));
+ assertEquals("['','foo','','bar','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/foo//bar//", r.getString("pathRemainder"));
+ assertEquals("/foo//bar//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a//foo//bar//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a//foo/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a//foo//bar//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/foo%2Fbar]
+ // {
+ // pathInfo: '/foo//bar',
+ // pathInfoUndecoded: '/foo%2F%2Fbar',
+ // pathInfoParts: [
+ // 'foo//bar'
+ // ],
+ // pathRemainder: 'foo//bar',
+ // pathRemainderUndecoded: 'foo%2F%2Fbar',
+ // requestURI: '/jazz/juneau/test/testPaths/a/foo%2F%2Fbar',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/foo%2F%2Fbar',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: 'foo//bar',
+ // method: 3
+ // }
+ url = URL + "/a/foo%2F%2Fbar";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/foo//bar", r.getString("pathInfo"));
+ assertEquals("/foo%2F%2Fbar", r.getString("pathInfoUndecoded"));
+ assertEquals("['foo//bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo//bar", r.getString("pathRemainder"));
+ assertEquals("foo%2F%2Fbar", r.getString("pathRemainderUndecoded"));
+ assertEquals("foo//bar", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/foo%2F%2Fbar"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/foo%2F%2Fbar"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ // [/test/testPaths/a//foo%2Fbar//]
+ // {
+ // pathInfo: '//foo//bar//',
+ // pathInfoUndecoded: '//foo%2F%2Fbar//',
+ // pathInfoParts: [
+ // '',
+ // 'foo//bar',
+ // ''
+ // ],
+ // pathRemainder: '/foo//bar//',
+ // pathRemainderUndecoded: '/foo%2F%2Fbar//',
+ // requestURI: '/jazz/juneau/test/testPaths/a//foo%2F%2Fbar//',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a/',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a//foo%2F%2Fbar//',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '/foo//bar//',
+ // method: 3
+ // }
+ url = URL + "/a//foo%2F%2Fbar//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("//foo//bar//", r.getString("pathInfo"));
+ assertEquals("//foo%2F%2Fbar//", r.getString("pathInfoUndecoded"));
+ assertEquals("['','foo//bar','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/foo//bar//", r.getString("pathRemainder"));
+ assertEquals("/foo%2F%2Fbar//", r.getString("pathRemainderUndecoded"));
+ assertEquals("/foo//bar//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a//foo%2F%2Fbar//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a//foo%2F%2Fbar//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+
+ // [/test/testPaths/a/test2]
+ // {
+ // pathInfo: '/test2',
+ // pathInfoParts: [
+ // 'test2'
+ // ],
+ // pathRemainder: null,
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: null,
+ // method: 4
+ // }
+ url = URL + "/a/test2";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2", r.getString("pathInfo"));
+ assertEquals("['test2']", r.getObjectList("pathInfoParts").toString());
+ assertNull(r.getString("pathRemainder"));
+ assertNull(r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/test2/]
+ // {
+ // pathInfo: '/test2/',
+ // pathInfoParts: [
+ // 'test2'
+ // ],
+ // pathRemainder: '',
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2/',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2/',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '',
+ // method: 4
+ // }
+ url = URL + "/a/test2/";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/", r.getString("pathInfo"));
+ assertEquals("['test2']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("", r.getString("pathRemainder"));
+ assertEquals("", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/test2//]
+ // {
+ // pathInfo: '/test2//',
+ // pathInfoParts: [
+ // 'test2',
+ // ''
+ // ],
+ // pathRemainder: '/',
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2//',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2//',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '/',
+ // method: 4
+ // }
+ url = URL + "/a/test2//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2//", r.getString("pathInfo"));
+ assertEquals("['test2','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/", r.getString("pathRemainder"));
+ assertEquals("/", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/test2///]
+ // {
+ // pathInfo: '/test2///',
+ // pathInfoParts: [
+ // 'test2',
+ // '',
+ // ''
+ // ],
+ // pathRemainder: '//',
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2///',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2///',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '//',
+ // method: 4
+ // }
+ url = URL + "/a/test2///";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2///", r.getString("pathInfo"));
+ assertEquals("['test2','','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("//", r.getString("pathRemainder"));
+ assertEquals("//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2///"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2///"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/test2/foo/bar]
+ // {
+ // pathInfo: '/test2/foo/bar',
+ // pathInfoParts: [
+ // 'test2',
+ // 'foo',
+ // 'bar'
+ // ],
+ // pathRemainder: 'foo/bar',
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2/foo/bar',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a/test2/foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2/foo/bar',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: 'foo/bar',
+ // method: 4
+ // }
+ url = URL + "/a/test2/foo/bar";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/foo/bar", r.getString("pathInfo"));
+ assertEquals("['test2','foo','bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo/bar", r.getString("pathRemainder"));
+ assertEquals("foo/bar", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/foo/bar"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2/foo"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/foo/bar"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/test2/foo/bar/]
+ // {
+ // pathInfo: '/test2/foo/bar/',
+ // pathInfoParts: [
+ // 'test2',
+ // 'foo',
+ // 'bar'
+ // ],
+ // pathRemainder: 'foo/bar/',
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2/foo/bar/',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a/test2/foo',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2/foo/bar/',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: 'foo/bar/',
+ // method: 4
+ // }
+ url = URL + "/a/test2/foo/bar/";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/foo/bar/", r.getString("pathInfo"));
+ assertEquals("['test2','foo','bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo/bar/", r.getString("pathRemainder"));
+ assertEquals("foo/bar/", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/foo/bar/"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2/foo"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/foo/bar/"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/test2//foo//bar//]
+ // {
+ // pathInfo: '/test2//foo//bar//',
+ // pathInfoParts: [
+ // 'test2',
+ // '',
+ // 'foo',
+ // '',
+ // 'bar',
+ // ''
+ // ],
+ // pathRemainder: '/foo//bar//',
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2//foo//bar//',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a/test2//foo/',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2//foo//bar//',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '/foo//bar//',
+ // method: 4
+ // }
+ url = URL + "/a/test2//foo//bar//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2//foo//bar//", r.getString("pathInfo"));
+ assertEquals("['test2','','foo','','bar','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/foo//bar//", r.getString("pathRemainder"));
+ assertEquals("/foo//bar//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2//foo//bar//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2//foo/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2//foo//bar//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/test2/foo%2Fbar]
+ // {
+ // pathInfo: '/test2/foo//bar',
+ // pathInfoUndecoded: '/test2/foo%2F%2Fbar',
+ // pathInfoParts: [
+ // 'test2',
+ // 'foo//bar'
+ // ],
+ // pathRemainder: 'foo//bar',
+ // pathRemainderUndecoded: 'foo%2F%2Fbar',
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2/foo%2F%2Fbar',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a/test2',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2/foo%2F%2Fbar',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: 'foo//bar',
+ // method: 4
+ // }
+ url = URL + "/a/test2/foo%2F%2Fbar";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/foo//bar", r.getString("pathInfo"));
+ assertEquals("/test2/foo%2F%2Fbar", r.getString("pathInfoUndecoded"));
+ assertEquals("['test2','foo//bar']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("foo//bar", r.getString("pathRemainder"));
+ assertEquals("foo%2F%2Fbar", r.getString("pathRemainderUndecoded"));
+ assertEquals("foo//bar", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/foo%2F%2Fbar"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/foo%2F%2Fbar"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ // [/test/testPaths/a/test2//foo%2Fbar//]
+ // {
+ // pathInfo: '/test2//foo//bar//',
+ // pathInfoUndecoded: '/test2//foo%2F%2Fbar//',
+ // pathInfoParts: [
+ // 'test2',
+ // '',
+ // 'foo//bar',
+ // ''
+ // ],
+ // pathRemainder: '/foo//bar//',
+ // pathRemainderUndecoded: '/foo%2F%2Fbar//',
+ // requestURI: '/jazz/juneau/test/testPaths/a/test2//foo%2F%2Fbar//',
+ // requestParentURI: '/jazz/juneau/test/testPaths/a/test2/',
+ // requestURL: 'https://localhost:9443/jazz/juneau/test/testPaths/a/test2//foo%2F%2Fbar//',
+ // servletPath: '/juneau/test/testPaths/a',
+ // servletURI: 'https://localhost:9443/jazz/juneau/test/testPaths/a',
+ // servletParentURI: 'https://localhost:9443/jazz/juneau/test/testPaths',
+ // relativeServletURI: '/jazz/juneau/test/testPaths/a',
+ // pathRemainder2: '/foo//bar//',
+ // method: 4
+ // }
+ url = URL + "/a/test2//foo%2F%2Fbar//";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2//foo//bar//", r.getString("pathInfo"));
+ assertEquals("/test2//foo%2F%2Fbar//", r.getString("pathInfoUndecoded"));
+ assertEquals("['test2','','foo//bar','']", r.getObjectList("pathInfoParts").toString());
+ assertEquals("/foo//bar//", r.getString("pathRemainder"));
+ assertEquals("/foo%2F%2Fbar//", r.getString("pathRemainderUndecoded"));
+ assertEquals("/foo//bar//", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2//foo%2F%2Fbar//"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2/"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2//foo%2F%2Fbar//"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ //--------------------------------------------------------------------------------
+ // Spaces
+ //--------------------------------------------------------------------------------
+ url = URL + "/%20";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/ ", r.getString("pathInfo"));
+ assertEquals("/%20", r.getString("pathInfoUndecoded"));
+ assertEquals("[' ']", r.getObjectList("pathInfoParts").toString());
+ assertEquals(" ", r.getString("pathRemainder"));
+ assertEquals("%20", r.getString("pathRemainderUndecoded"));
+ assertEquals(" ", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/%20"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/%20"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ url = URL + "/test2/%20";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/ ", r.getString("pathInfo"));
+ assertEquals("/test2/%20", r.getString("pathInfoUndecoded"));
+ assertEquals("['test2',' ']", r.getObjectList("pathInfoParts").toString());
+ assertEquals(" ", r.getString("pathRemainder"));
+ assertEquals("%20", r.getString("pathRemainderUndecoded"));
+ assertEquals(" ", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/%20"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/%20"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ url = URL + "/a/%20";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/ ", r.getString("pathInfo"));
+ assertEquals("/%20", r.getString("pathInfoUndecoded"));
+ assertEquals("[' ']", r.getObjectList("pathInfoParts").toString());
+ assertEquals(" ", r.getString("pathRemainder"));
+ assertEquals("%20", r.getString("pathRemainderUndecoded"));
+ assertEquals(" ", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/%20"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/%20"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ url = URL + "/a/test2/%20";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/ ", r.getString("pathInfo"));
+ assertEquals("/test2/%20", r.getString("pathInfoUndecoded"));
+ assertEquals("['test2',' ']", r.getObjectList("pathInfoParts").toString());
+ assertEquals(" ", r.getString("pathRemainder"));
+ assertEquals("%20", r.getString("pathRemainderUndecoded"));
+ assertEquals(" ", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/%20"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/%20"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ url = URL + "/+";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/ ", r.getString("pathInfo"));
+ assertEquals("/+", r.getString("pathInfoUndecoded"));
+ assertEquals("[' ']", r.getObjectList("pathInfoParts").toString());
+ assertEquals(" ", r.getString("pathRemainder"));
+ assertEquals("+", r.getString("pathRemainderUndecoded"));
+ assertEquals(" ", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/+"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/+"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(1, (int)r.getInt("method"));
+
+ url = URL + "/test2/+";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/ ", r.getString("pathInfo"));
+ assertEquals("/test2/+", r.getString("pathInfoUndecoded"));
+ assertEquals("['test2',' ']", r.getObjectList("pathInfoParts").toString());
+ assertEquals(" ", r.getString("pathRemainder"));
+ assertEquals("+", r.getString("pathRemainderUndecoded"));
+ assertEquals(" ", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/test2/+"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/test2"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/test2/+"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths"));
+ assertEquals(2, (int)r.getInt("method"));
+
+ url = URL + "/a/+";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/ ", r.getString("pathInfo"));
+ assertEquals("/+", r.getString("pathInfoUndecoded"));
+ assertEquals("[' ']", r.getObjectList("pathInfoParts").toString());
+ assertEquals(" ", r.getString("pathRemainder"));
+ assertEquals("+", r.getString("pathRemainderUndecoded"));
+ assertEquals(" ", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/+"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/+"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(3, (int)r.getInt("method"));
+
+ url = URL + "/a/test2/+";
+ r = client.doGet(url).getResponse(ObjectMap.class);
+ assertEquals("/test2/ ", r.getString("pathInfo"));
+ assertEquals("/test2/+", r.getString("pathInfoUndecoded"));
+ assertEquals("['test2',' ']", r.getObjectList("pathInfoParts").toString());
+ assertEquals(" ", r.getString("pathRemainder"));
+ assertEquals("+", r.getString("pathRemainderUndecoded"));
+ assertEquals(" ", r.getString("pathRemainder2"));
+ assertTrue(r.getString("requestURI").endsWith("/testPaths/a/test2/+"));
+ assertTrue(r.getString("requestParentURI").endsWith("/testPaths/a/test2"));
+ assertTrue(r.getString("requestURL").endsWith("/testPaths/a/test2/+"));
+ assertTrue(r.getString("servletPath").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletURI").endsWith("/testPaths/a"));
+ assertTrue(r.getString("servletParentURI").endsWith("/testPaths"));
+ assertTrue(r.getString("relativeServletURI").endsWith("/testPaths/a"));
+ assertEquals(4, (int)r.getInt("method"));
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/PropertiesTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/PropertiesTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/PropertiesTest.java
new file mode 100755
index 0000000..fdb8269
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/PropertiesTest.java
@@ -0,0 +1,48 @@
+// ***************************************************************************************************************************
+// * 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 PropertiesTest {
+
+ private static String URL = "/testProperties";
+
+ //====================================================================================================
+ // Properties defined on method.
+ //====================================================================================================
+ @Test
+ public void testPropertiesDefinedOnMethod() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r = client.doGet(URL + "/testPropertiesDefinedOnMethod").getResponseAsString();
+ assertTrue(r.matches("A1=a1,A2=c,B1=b1,B2=c,C=c,R1a=.*/testProperties/testPropertiesDefinedOnMethod,R1b=.*/testProperties,R2=bar,R3=baz,R4=a1,R5=c,R6=c"));
+
+ client.closeQuietly();
+ }
+
+ //====================================================================================================
+ // Make sure attributes/parameters/headers are available through ctx.getProperties().
+ //====================================================================================================
+ @Test
+ public void testProperties() throws Exception {
+ RestClient client = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r = client.doGet(URL + "/testProperties/a1?P=p1").setHeader("H", "h1").getResponseAsString();
+ assertEquals("A=a1,P=p1,H=h1", r);
+
+ client.closeQuietly();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/test/java/org/apache/juneau/server/test/RestClientTest.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/test/java/org/apache/juneau/server/test/RestClientTest.java b/juneau-server-test/src/test/java/org/apache/juneau/server/test/RestClientTest.java
new file mode 100755
index 0000000..c1d0584
--- /dev/null
+++ b/juneau-server-test/src/test/java/org/apache/juneau/server/test/RestClientTest.java
@@ -0,0 +1,199 @@
+// ***************************************************************************************************************************
+// * 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 java.util.*;
+import java.util.regex.*;
+
+import org.apache.http.entity.*;
+import org.apache.juneau.client.*;
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+public class RestClientTest {
+
+ private static String URL = "/testRestClient";
+
+ //====================================================================================================
+ // successPattern()
+ //====================================================================================================
+ @Test
+ public void testSuccessPattern() throws Exception {
+ RestClient c = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+ int rc;
+
+ r = c.doPost(URL, new StringEntity("xxxSUCCESSxxx")).successPattern("SUCCESS").getResponseAsString();
+ assertEquals("xxxSUCCESSxxx", r);
+ rc = c.doPost(URL, new StringEntity("xxxSUCCESSxxx")).successPattern("SUCCESS").run();
+ assertEquals(200, rc);
+
+ try {
+ r = c.doPost(URL, new StringEntity("xxxFAILURExxx")).successPattern("SUCCESS").getResponseAsString();
+ fail();
+ } catch (RestCallException e) {
+ assertEquals("Success pattern not detected.", e.getLocalizedMessage());
+ }
+
+ c.closeQuietly();
+ }
+
+ //====================================================================================================
+ // failurePattern()
+ //====================================================================================================
+ @Test
+ public void testFailurePattern() throws Exception {
+ RestClient c = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+ int rc;
+
+ r = c.doPost(URL, new StringEntity("xxxSUCCESSxxx")).failurePattern("FAILURE").getResponseAsString();
+ assertEquals("xxxSUCCESSxxx", r);
+ rc = c.doPost(URL, new StringEntity("xxxSUCCESSxxx")).failurePattern("FAILURE").run();
+ assertEquals(200, rc);
+
+ try {
+ r = c.doPost(URL, new StringEntity("xxxFAILURExxx")).failurePattern("FAILURE").getResponseAsString();
+ fail();
+ } catch (RestCallException e) {
+ assertEquals("Failure pattern detected.", e.getLocalizedMessage());
+ }
+
+ try {
+ r = c.doPost(URL, new StringEntity("xxxERRORxxx")).failurePattern("FAILURE|ERROR").getResponseAsString();
+ fail();
+ } catch (RestCallException e) {
+ assertEquals("Failure pattern detected.", e.getLocalizedMessage());
+ }
+
+ c.closeQuietly();
+ }
+
+ //====================================================================================================
+ // captureResponse()/getCapturedResponse()
+ //====================================================================================================
+ @Test
+ public void testCaptureResponse() throws Exception {
+ RestClient c = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ RestCall rc = c.doPost(URL, new StringEntity("xxx")).captureResponse();
+
+ try {
+ rc.getCapturedResponse();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("This method cannot be called until the response has been consumed.", e.getLocalizedMessage());
+ }
+ rc.run();
+ assertEquals("xxx", rc.getCapturedResponse());
+ assertEquals("xxx", rc.getCapturedResponse());
+
+ rc = c.doPost(URL, new StringEntity("xxx")).captureResponse();
+ assertEquals("xxx", rc.getResponseAsString());
+ assertEquals("xxx", rc.getCapturedResponse());
+ assertEquals("xxx", rc.getCapturedResponse());
+
+ try {
+ rc.getResponseAsString();
+ fail();
+ } catch (IllegalStateException e) {
+ assertEquals("Method cannot be called. Response has already been consumed.", e.getLocalizedMessage());
+ }
+
+ c.closeQuietly();
+ }
+
+ //====================================================================================================
+ // addResponsePattern()
+ //====================================================================================================
+ @Test
+ public void testAddResponsePattern() throws Exception {
+ RestClient c = new TestRestClient(JsonSerializer.DEFAULT, JsonParser.DEFAULT);
+ String r;
+
+ final List<String> l = new ArrayList<String>();
+ ResponsePattern p = new ResponsePattern("x=(\\d+),y=(\\S+)") {
+ @Override
+ public void onMatch(RestCall restCall, Matcher m) throws RestCallException {
+ l.add(m.group(1)+'/'+m.group(2));
+ }
+ @Override
+ public void onNoMatch(RestCall restCall) throws RestCallException {
+ throw new RestCallException("Pattern not found!");
+ }
+ };
+
+ r = c.doPost(URL, new StringEntity("x=1,y=2")).addResponsePattern(p).getResponseAsString();
+ assertEquals("x=1,y=2", r);
+ assertObjectEquals("['1/2']", l);
+
+ l.clear();
+
+ r = c.doPost(URL, new StringEntity("x=1,y=2\nx=3,y=4")).addResponsePattern(p).getResponseAsString();
+ assertEquals("x=1,y=2\nx=3,y=4", r);
+ assertObjectEquals("['1/2','3/4']", l);
+
+ try {
+ c.doPost(URL, new StringEntity("x=1")).addResponsePattern(p).run();
+ fail();
+ } catch (RestCallException e) {
+ assertEquals("Pattern not found!", e.getLocalizedMessage());
+ assertEquals(0, e.getResponseCode());
+ }
+
+ // Two patterns!
+ ResponsePattern p1 = new ResponsePattern("x=(\\d+)") {
+ @Override
+ public void onMatch(RestCall restCall, Matcher m) throws RestCallException {
+ l.add("x="+m.group(1));
+ }
+ @Override
+ public void onNoMatch(RestCall restCall) throws RestCallException {
+ throw new RestCallException("Pattern x not found!");
+ }
+ };
+ ResponsePattern p2 = new ResponsePattern("y=(\\S+)") {
+ @Override
+ public void onMatch(RestCall restCall, Matcher m) throws RestCallException {
+ l.add("y="+m.group(1));
+ }
+ @Override
+ public void onNoMatch(RestCall restCall) throws RestCallException {
+ throw new RestCallException("Pattern y not found!");
+ }
+ };
+
+ l.clear();
+ r = c.doPost(URL, new StringEntity("x=1,y=2\nx=3,y=4")).addResponsePattern(p1).addResponsePattern(p2).getResponseAsString();
+ assertEquals("x=1,y=2\nx=3,y=4", r);
+ assertObjectEquals("['x=1','x=3','y=2','y=4']", l);
+
+ try {
+ c.doPost(URL, new StringEntity("x=1\nx=3")).addResponsePattern(p1).addResponsePattern(p2).getResponseAsString();
+ } catch (RestCallException e) {
+ assertEquals("Pattern y not found!", e.getLocalizedMessage());
+ assertEquals(0, e.getResponseCode());
+ }
+
+ try {
+ c.doPost(URL, new StringEntity("y=1\ny=3")).addResponsePattern(p1).addResponsePattern(p2).getResponseAsString();
+ } catch (RestCallException e) {
+ assertEquals("Pattern x not found!", e.getLocalizedMessage());
+ assertEquals(0, e.getResponseCode());
+ }
+
+ c.closeQuietly();
+ }
+}
[16/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/test/java/org/apache/juneau/html/CommonTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/html/CommonTest.java b/juneau-core/src/test/java/org/apache/juneau/html/CommonTest.java
index 52fb201..c0d14fc 100755
--- a/juneau-core/src/test/java/org/apache/juneau/html/CommonTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/html/CommonTest.java
@@ -107,13 +107,13 @@ public class CommonTest {
C t1 = C.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("<table _type='object'><tr><th><string>key</string></th><th><string>value</string></th></tr><tr><td><string>f1</string></td><td><ul></ul></td></tr><tr><td><string>f2</string></td><td><table _type='array'><tr><th>s1</th><th>s2</th></tr><tr><null/></tr><tr><td><null/></td><td><string>s2</string></td></tr></table></td></tr></table>", r);
t2 = p.parse(r, C.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("<table _type='object'><tr><th><string>key</string></th><th><string>value</string></th></tr><tr><td><string>f2</string></td><td><table _type='array'><tr><th>s1</th><th>s2</th></tr><tr><null/></tr><tr><td><null/></td><td><string>s2</string></td></tr></table></td></tr></table>", r);
t2 = p.parse(r, C.class);
@@ -141,13 +141,13 @@ public class CommonTest {
D t1 = D.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("<table _type='object'><tr><th><string>key</string></th><th><string>value</string></th></tr><tr><td><string>f1</string></td><td><ul></ul></td></tr><tr><td><string>f2</string></td><td><table _type='array'><tr><th>s1</th><th>s2</th></tr><tr><null/></tr><tr><td><null/></td><td><string>s2</string></td></tr></table></td></tr></table>", r);
t2 = p.parse(r, D.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("<table _type='object'><tr><th><string>key</string></th><th><string>value</string></th></tr><tr><td><string>f2</string></td><td><table _type='array'><tr><th>s1</th><th>s2</th></tr><tr><null/></tr><tr><td><null/></td><td><string>s2</string></td></tr></table></td></tr></table>", r);
t2 = p.parse(r, D.class);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/test/java/org/apache/juneau/jena/CommonTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/jena/CommonTest.java b/juneau-core/src/test/java/org/apache/juneau/jena/CommonTest.java
index e648ac1..aa5fb50 100755
--- a/juneau-core/src/test/java/org/apache/juneau/jena/CommonTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/jena/CommonTest.java
@@ -122,13 +122,13 @@ public class CommonTest {
C t1 = C.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("<rdf:Description><jp:f1><rdf:Seq/></jp:f1><jp:f2><rdf:Seq><rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/><rdf:li rdf:parseType='Resource'><jp:s2>s2</jp:s2></rdf:li></rdf:Seq></jp:f2></rdf:Description>", strip(r));
t2 = p.parse(r, C.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("<rdf:Description><jp:f2><rdf:Seq><rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/><rdf:li rdf:parseType='Resource'><jp:s2>s2</jp:s2></rdf:li></rdf:Seq></jp:f2></rdf:Description>", strip(r));
t2 = p.parse(r, C.class);
@@ -157,13 +157,13 @@ public class CommonTest {
D t1 = D.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("<rdf:Description><jp:f1><rdf:Seq/></jp:f1><jp:f2><rdf:Seq><rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/><rdf:li rdf:parseType='Resource'><jp:s2>s2</jp:s2></rdf:li></rdf:Seq></jp:f2></rdf:Description>", strip(r));
t2 = p.parse(r, D.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("<rdf:Description><jp:f2><rdf:Seq><rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/><rdf:li rdf:parseType='Resource'><jp:s2>s2</jp:s2></rdf:li></rdf:Seq></jp:f2></rdf:Description>", strip(r));
t2 = p.parse(r, D.class);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/test/java/org/apache/juneau/jena/RdfTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/jena/RdfTest.java b/juneau-core/src/test/java/org/apache/juneau/jena/RdfTest.java
index 602c9ab..d171dd2 100755
--- a/juneau-core/src/test/java/org/apache/juneau/jena/RdfTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/jena/RdfTest.java
@@ -526,8 +526,8 @@ public class RdfTest {
@Test
@SuppressWarnings("unchecked")
public void testLooseCollectionsOfBeans() throws Exception {
- WriterSerializer s = new RdfSerializer.XmlAbbrev().setProperty(RDF_looseCollection, true);
- ReaderParser p = new RdfParser.Xml().setProperty(RDF_looseCollection, true);
+ WriterSerializer s = new RdfSerializer.XmlAbbrev().setProperty(RDF_looseCollections, true);
+ ReaderParser p = new RdfParser.Xml().setProperty(RDF_looseCollections, true);
String rdfXml, expected;
List<D> l = new LinkedList<D>();
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/test/java/org/apache/juneau/json/CommonTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/json/CommonTest.java b/juneau-core/src/test/java/org/apache/juneau/json/CommonTest.java
index 9a7c4ae..65998ad 100755
--- a/juneau-core/src/test/java/org/apache/juneau/json/CommonTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/json/CommonTest.java
@@ -106,13 +106,13 @@ public class CommonTest {
C t1 = C.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("{f1:[],f2:[null,{s2:'s2'}]}", r);
t2 = p.parse(r, C.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("{f2:[null,{s2:'s2'}]}", r);
t2 = p.parse(r, C.class);
@@ -140,13 +140,13 @@ public class CommonTest {
D t1 = D.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("{f1:[],f2:[null,{s2:'s2'}]}", r);
t2 = p.parse(r, D.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("{f2:[null,{s2:'s2'}]}", r);
t2 = p.parse(r, D.class);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java b/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java
index a3cb6dd..ca8a60a 100755
--- a/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java
@@ -105,13 +105,13 @@ public class Common_UonTest {
C t1 = C.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("$o(f1=$a(),f2=$a(%00,$o(s2=s2)))", r);
t2 = pe.parse(r, C.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("$o(f2=$a(%00,$o(s2=s2)))", r);
t2 = pe.parse(r, C.class);
@@ -138,13 +138,13 @@ public class Common_UonTest {
D t1 = D.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("$o(f1=$a(),f2=$a(%00,$o(s2=s2)))", r);
t2 = pe.parse(r, D.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("$o(f2=$a(%00,$o(s2=s2)))", r);
t2 = pe.parse(r, D.class);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java b/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java
index c276c53..073b31d 100755
--- a/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java
@@ -104,13 +104,13 @@ public class Common_UrlEncodingTest {
C t1 = C.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("f1=$a()&f2=$a(%00,$o(s2=s2))", r);
t2 = p.parse(r, C.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("f2=$a(%00,$o(s2=s2))", r);
t2 = p.parse(r, C.class);
@@ -137,13 +137,13 @@ public class Common_UrlEncodingTest {
D t1 = D.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("f1=$a()&f2=$a(%00,$o(s2=s2))", r);
t2 = p.parse(r, D.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("f2=$a(%00,$o(s2=s2))", r);
t2 = p.parse(r, D.class);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/test/java/org/apache/juneau/xml/CommonTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/src/test/java/org/apache/juneau/xml/CommonTest.java b/juneau-core/src/test/java/org/apache/juneau/xml/CommonTest.java
index 491d67d..abe8500 100755
--- a/juneau-core/src/test/java/org/apache/juneau/xml/CommonTest.java
+++ b/juneau-core/src/test/java/org/apache/juneau/xml/CommonTest.java
@@ -109,13 +109,13 @@ public class CommonTest {
C t1 = C.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("<object><f1></f1><f2><null/><object><s2>s2</s2></object></f2></object>", r);
t2 = p.parse(r, C.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("<object><f2><null/><object><s2>s2</s2></object></f2></object>", r);
t2 = p.parse(r, C.class);
@@ -143,13 +143,13 @@ public class CommonTest {
D t1 = D.create(), t2;
String r;
- s.setProperty(SERIALIZER_trimEmptyLists, false);
+ s.setProperty(SERIALIZER_trimEmptyCollections, false);
r = s.serialize(t1);
assertEquals("<object><f1></f1><f2><null/><object><s2>s2</s2></object></f2></object>", r);
t2 = p.parse(r, D.class);
assertEqualObjects(t1, t2);
- s.setProperty(SERIALIZER_trimEmptyLists, true);
+ s.setProperty(SERIALIZER_trimEmptyCollections, true);
r = s.serialize(t1);
assertEquals("<object><f2><null/><object><s2>s2</s2></object></f2></object>", r);
t2 = p.parse(r, D.class);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-releng/user-dictionary.txt
----------------------------------------------------------------------
diff --git a/juneau-releng/user-dictionary.txt b/juneau-releng/user-dictionary.txt
new file mode 100644
index 0000000..59e1fdb
--- /dev/null
+++ b/juneau-releng/user-dictionary.txt
@@ -0,0 +1,12 @@
+abbrev
+juneau
+juno
+servlet
+microservice
+lax
+jena
+zip
+json
+xml
+html
+javadoc
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/META-INF/MANIFEST.MF
----------------------------------------------------------------------
diff --git a/juneau-server-test/META-INF/MANIFEST.MF b/juneau-server-test/META-INF/MANIFEST.MF
index ba6b296..5c10c67 100755
--- a/juneau-server-test/META-INF/MANIFEST.MF
+++ b/juneau-server-test/META-INF/MANIFEST.MF
@@ -18,6 +18,6 @@ Bundle-SymbolicName: org.apache.juneau.server.test
Bundle-Version: 5.1.1000.qualifier
Bundle-Vendor: Apache Software Foundation, Juneau
Main-Class: org.apache.juneau.microservice.RestMicroservice
-Rest-Resources: org.apache.juneau.server.Root
+Rest-Resources: org.apache.juneau.server.test.Root
Main-ConfigFile: juneau-server-test.cfg
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/AcceptCharsetResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/AcceptCharsetResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/AcceptCharsetResource.java
deleted file mode 100755
index ca693ac..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/AcceptCharsetResource.java
+++ /dev/null
@@ -1,75 +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.apache.juneau.server.RestServletContext.*;
-
-import java.io.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.plaintext.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testAcceptCharset",
- serializers={PlainTextSerializer.class},
- properties={
- // Some versions of Jetty default to ISO8601, so specify UTF-8 for test consistency.
- @Property(name=REST_defaultCharset,value="utf-8")
- }
-)
-public class AcceptCharsetResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Test that Q-values are being resolved correctly.
- //====================================================================================================
- @RestMethod(name="GET", path="/testQValues")
- public String testQValues() {
- return "foo";
- }
-
- //====================================================================================================
- // Validate various Accept-Charset variations.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testCharsetOnResponse", parsers=TestParser.class, serializers=TestSerializer.class)
- public String testCharsetOnResponse(@Content String in) {
- return in;
- }
-
- @Consumes("text/plain")
- public static class TestParser extends InputStreamParser {
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return (T)session.getProperties().getString("characterEncoding");
- }
- }
-
- @Produces("text/plain")
- public static class TestSerializer extends OutputStreamSerializer {
- @Override /* Serializer */
- protected void doSerialize(SerializerSession session, Object o) throws Exception {
- Writer w = new OutputStreamWriter(session.getOutputStream());
- w.append(o.toString()).append('/').append(session.getProperties().getString("characterEncoding"));
- w.flush();
- w.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/BeanContextPropertiesResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/BeanContextPropertiesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/BeanContextPropertiesResource.java
deleted file mode 100755
index 5e1eef1..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/BeanContextPropertiesResource.java
+++ /dev/null
@@ -1,41 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import java.io.*;
-import java.util.*;
-
-import org.apache.juneau.server.annotation.*;
-import org.apache.juneau.transforms.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testBeanContext",
- pojoSwaps=DateSwap.ISO8601DTZ.class
-)
-public class BeanContextPropertiesResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Validate that transforms defined on class transform to underlying bean context.
- //====================================================================================================
- @RestMethod(name="GET", path="/testClassTransforms/{d1}")
- public Reader testClassTransforms(@Attr("d1") Date d1, @Param("d2") Date d2, @Header("X-D3") Date d3) throws Exception {
- DateSwap df = DateSwap.ISO8601DTZ.class.newInstance();
- return new StringReader(
- "d1="+df.swap(d1)+",d2="+df.swap(d2)+",d3="+df.swap(d3)+""
- );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/CallbackStringsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/CallbackStringsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/CallbackStringsResource.java
deleted file mode 100755
index da42b3d..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/CallbackStringsResource.java
+++ /dev/null
@@ -1,52 +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 java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testCallback"
-)
-public class CallbackStringsResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Test GET
- //====================================================================================================
- @RestMethod(name="GET", path="/")
- public ObjectMap test1(RestRequest req) throws Exception {
- return new ObjectMap().append("method","GET").append("headers", getFooHeaders(req)).append("content", req.getInputAsString());
- }
-
- //====================================================================================================
- // Test PUT
- //====================================================================================================
- @RestMethod(name="PUT", path="/")
- public ObjectMap testCharsetOnResponse(RestRequest req) throws Exception {
- return new ObjectMap().append("method","PUT").append("headers", getFooHeaders(req)).append("content", req.getInputAsString());
- }
-
- private Map<String,Object> getFooHeaders(RestRequest req) {
- Map<String,Object> m = new TreeMap<String,Object>();
- for (Map.Entry<String,Object> e : req.getHeaders().entrySet())
- if (e.getKey().startsWith("Foo-"))
- m.put(e.getKey(), e.getValue());
- return m;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/CharsetEncodingsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/CharsetEncodingsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/CharsetEncodingsResource.java
deleted file mode 100755
index 43b1acc..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/CharsetEncodingsResource.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testCharsetEncodings",
- defaultRequestHeaders={"Accept: text/s", "Content-Type: text/p"},
- parsers={CharsetEncodingsResource.CtParser.class}, serializers={CharsetEncodingsResource.ASerializer.class}
-)
-public class CharsetEncodingsResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- @Consumes("text/p")
- public static class CtParser extends ReaderParser {
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return (T)IOUtils.read(session.getReader());
- }
- }
-
- @Produces("text/s")
- public static class ASerializer extends WriterSerializer {
- @Override /* Serializer */
- protected void doSerialize(SerializerSession session, Object o) throws Exception {
- session.getWriter().write(o.toString());
- }
- }
-
- @RestMethod(name="PUT", path="/")
- public String test1(RestRequest req, @Content String in) {
- return req.getCharacterEncoding() + "/" + in + "/" + req.getCharacterEncoding();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/ClientVersionResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/ClientVersionResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/ClientVersionResource.java
deleted file mode 100644
index f6503ce..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/ClientVersionResource.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.microservice.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testClientVersion",
- children={
- ClientVersionResource.DefaultHeader.class,
- ClientVersionResource.CustomHeader.class
- }
-)
-@SuppressWarnings("serial")
-public class ClientVersionResource extends Resource {
-
- @RestResource(
- path="/defaultHeader"
- )
- public static class DefaultHeader extends Resource {
-
- @RestMethod(name="GET", path="/")
- public String test0() {
- return "no-version";
- }
-
- @RestMethod(name="GET", path="/", clientVersion="[0.0,1.0)")
- public String test1() {
- return "[0.0,1.0)";
- }
-
- @RestMethod(name="GET", path="/", clientVersion="[1.0,1.0]")
- public String test2() {
- return "[1.0,1.0]";
- }
-
- @RestMethod(name="GET", path="/", clientVersion="[1.1,2)")
- public String test3() {
- return "[1.1,2)";
- }
-
- @RestMethod(name="GET", path="/", clientVersion="2")
- public String test4() {
- return "2";
- }
- }
-
- @RestResource(
- path="/customHeader",
- clientVersionHeader="Custom-Client-Version"
- )
- public static class CustomHeader extends Resource {
-
- @RestMethod(name="GET", path="/")
- public String test0() {
- return "no-version";
- }
-
- @RestMethod(name="GET", path="/", clientVersion="[0.0,1.0)")
- public String test1() {
- return "[0.0,1.0)";
- }
-
- @RestMethod(name="GET", path="/", clientVersion="[1.0,1.0]")
- public String test2() {
- return "[1.0,1.0]";
- }
-
- @RestMethod(name="GET", path="/", clientVersion="[1.1,2)")
- public String test3() {
- return "[1.1,2)";
- }
-
- @RestMethod(name="GET", path="/", clientVersion="2")
- public String test4() {
- return "2";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/ConfigResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/ConfigResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/ConfigResource.java
deleted file mode 100755
index 2143b94..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/ConfigResource.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 org.apache.juneau.ini.*;
-import org.apache.juneau.microservice.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testConfig"
-)
-@SuppressWarnings("serial")
-public class ConfigResource extends Resource {
-
- @RestMethod(name="GET", path="/")
- public ConfigFile test1(RestRequest req) {
- return req.getConfig();
- }
-
- @RestMethod(name="GET", path="/{key}/{class}")
- public Object test2(RestRequest req, @Attr("key") String key, @Attr("class") Class<?> c) throws Exception {
- return req.getConfig().getObject(c, key);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/ContentResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/ContentResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/ContentResource.java
deleted file mode 100755
index 08a17db..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/ContentResource.java
+++ /dev/null
@@ -1,80 +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.apache.juneau.server.RestServletContext.*;
-
-import java.util.*;
-
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testContent",
- properties={
- @Property(name=REST_allowMethodParam, value="*")
- }
-)
-public class ContentResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Basic tests
- //====================================================================================================
- @RestMethod(name="POST", path="/boolean")
- public boolean testBool(@Content boolean b) {
- return b;
- }
-
- @RestMethod(name="POST", path="/Boolean")
- public Boolean testBoolean(@Content Boolean b) {
- return b;
- }
-
- @RestMethod(name="POST", path="/int")
- public int testInt(@Content int i) {
- return i;
- }
-
- @RestMethod(name="POST", path="/Integer")
- public Integer testInteger(@Content Integer i) {
- return i;
- }
-
- @RestMethod(name="POST", path="/float")
- public float testFloat(@Content float f) {
- return f;
- }
-
- @RestMethod(name="POST", path="/Float")
- public Float testFloat2(@Content Float f) {
- return f;
- }
-
- @RestMethod(name="POST", path="/Map")
- public TreeMap<String,String> testMap(@Content TreeMap<String,String> m) {
- return m;
- }
-
- @RestMethod(name="POST", path="/B")
- public DTO2s.B testPojo1(@Content DTO2s.B b) {
- return b;
- }
-
- @RestMethod(name="POST", path="/C")
- public DTO2s.C testPojo2(@Content DTO2s.C c) {
- return c;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/DTO2s.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/DTO2s.java b/juneau-server-test/src/main/java/org/apache/juneau/server/DTO2s.java
deleted file mode 100755
index a47412f..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/DTO2s.java
+++ /dev/null
@@ -1,139 +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 java.util.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.urlencoding.annotation.*;
-
-public class DTO2s {
-
- @Bean(sort=true)
- public static class A {
- public String a;
- public int b;
- public boolean c;
-
- public static A create() {
- A t = new A();
- t.a = "a";
- t.b = 1;
- t.c = true;
- return t;
- }
-
- }
-
- @SuppressWarnings("serial")
- @Bean(sort=true)
- public static class B {
- public String[] f01;
- public List<String> f02;
- public int[] f03;
- public List<Integer> f04;
- public String[][] f05;
- public List<String[]> f06;
- public A[] f07;
- public List<A> f08;
- public A[][] f09;
- public List<List<A>> f10;
-
- private String[] f11;
- private List<String> f12;
- private int[] f13;
- private List<Integer> f14;
- private String[][] f15;
- private List<String[]> f16;
- private A[] f17;
- private List<A> f18;
- private A[][] f19;
- private List<List<A>> f20;
-
- public String[] getF11() { return f11; }
- public List<String> getF12() { return f12; }
- public int[] getF13() { return f13; }
- public List<Integer> getF14() { return f14; }
- public String[][] getF15() { return f15; }
- public List<String[]> getF16() { return f16; }
- public A[] getF17() { return f17; }
- public List<A> getF18() { return f18; }
- public A[][] getF19() { return f19; }
- public List<List<A>> getF20() { return f20; }
-
- public void setF11(String[] f11) { this.f11 = f11; }
- public void setF12(List<String> f12) { this.f12 = f12; }
- public void setF13(int[] f13) { this.f13 = f13; }
- public void setF14(List<Integer> f14) { this.f14 = f14; }
- public void setF15(String[][] f15) { this.f15 = f15; }
- public void setF16(List<String[]> f16) { this.f16 = f16; }
- public void setF17(A[] f17) { this.f17 = f17; }
- public void setF18(List<A> f18) { this.f18 = f18; }
- public void setF19(A[][] f19) { this.f19 = f19; }
- public void setF20(List<List<A>> f20) { this.f20 = f20; }
-
- static B create() {
- B t = new B();
- t.f01 = new String[]{"a","b"};
- t.f02 = new ArrayList<String>(){{add("c");add("d");}};
- t.f03 = new int[]{1,2};
- t.f04 = new ArrayList<Integer>(){{add(3);add(4);}};
- t.f05 = new String[][]{{"e","f"},{"g","h"}};
- t.f06 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}};
- t.f07 = new A[]{A.create(),A.create()};
- t.f08 = new ArrayList<A>(){{add(A.create());add(A.create());}};
- t.f09 = new A[][]{{A.create()},{A.create()}};
- t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}};
- t.setF11(new String[]{"a","b"});
- t.setF12(new ArrayList<String>(){{add("c");add("d");}});
- t.setF13(new int[]{1,2});
- t.setF14(new ArrayList<Integer>(){{add(3);add(4);}});
- t.setF15(new String[][]{{"e","f"},{"g","h"}});
- t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}});
- t.setF17(new A[]{A.create(),A.create()});
- t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}});
- t.setF19(new A[][]{{A.create()},{A.create()}});
- t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}});
- return t;
- }
- }
-
- @UrlEncoding(expandedParams=true)
- public static class C extends B {
- @SuppressWarnings("serial")
- static C create() {
- C t = new C();
- t.f01 = new String[]{"a","b"};
- t.f02 = new ArrayList<String>(){{add("c");add("d");}};
- t.f03 = new int[]{1,2};
- t.f04 = new ArrayList<Integer>(){{add(3);add(4);}};
- t.f05 = new String[][]{{"e","f"},{"g","h"}};
- t.f06 = new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}};
- t.f07 = new A[]{A.create(),A.create()};
- t.f08 = new ArrayList<A>(){{add(A.create());add(A.create());}};
- t.f09 = new A[][]{{A.create()},{A.create()}};
- t.f10 = new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}};
- t.setF11(new String[]{"a","b"});
- t.setF12(new ArrayList<String>(){{add("c");add("d");}});
- t.setF13(new int[]{1,2});
- t.setF14(new ArrayList<Integer>(){{add(3);add(4);}});
- t.setF15(new String[][]{{"e","f"},{"g","h"}});
- t.setF16(new ArrayList<String[]>(){{add(new String[]{"i","j"});add(new String[]{"k","l"});}});
- t.setF17(new A[]{A.create(),A.create()});
- t.setF18(new ArrayList<A>(){{add(A.create());add(A.create());}});
- t.setF19(new A[][]{{A.create()},{A.create()}});
- t.setF20(new ArrayList<List<A>>(){{add(Arrays.asList(A.create()));add(Arrays.asList(A.create()));}});
- return t;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/DefaultContentTypesResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/DefaultContentTypesResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/DefaultContentTypesResource.java
deleted file mode 100755
index 70e74e6..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/DefaultContentTypesResource.java
+++ /dev/null
@@ -1,127 +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.apache.juneau.server.annotation.Inherit.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testDefaultContentTypes",
- defaultRequestHeaders={" Accept : text/s2 "," Content-Type : text/p2 "},
- parsers={DefaultContentTypesResource.P1.class,DefaultContentTypesResource.P2.class}, serializers={DefaultContentTypesResource.S1.class,DefaultContentTypesResource.S2.class}
-)
-@SuppressWarnings("synthetic-access")
-public class DefaultContentTypesResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- @Consumes("text/p1")
- public static class P1 extends DummyParser { public P1() {super("p1");}}
-
- @Consumes("text/p2")
- public static class P2 extends DummyParser { public P2() {super("p2");}}
-
- @Consumes("text/p3")
- public static class P3 extends DummyParser { public P3() {super("p3");}}
-
- @Produces("text/s1")
- public static class S1 extends DummySerializer { public S1() {super("s1");}}
-
- @Produces("text/s2")
- public static class S2 extends DummySerializer { public S2() {super("s2");}}
-
- @Produces("text/s3")
- public static class S3 extends DummySerializer { public S3() {super("s3");}}
-
- /**
- * Test that default Accept and Content-Type headers on servlet annotation are picked up.
- */
- @RestMethod(name="PUT", path="/testDefaultHeadersOnServletAnnotation")
- public String testDefaultHeadersOnServletAnnotation(@Content String in) {
- return in;
- }
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on servlet annotation are picked up
- // when @RestMethod.parsers/serializers annotations are used.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testRestMethodParsersSerializers", parsers=P3.class, serializers=S3.class)
- public String testRestMethodParsersSerializers(@Content String in) {
- return in;
- }
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on servlet annotation are picked up
- // when @RestMethod.addParsers/addSerializers annotations are used.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testRestMethodAddParsersSerializers", parsers=P3.class, parsersInherit=PARSERS, serializers=S3.class, serializersInherit=SERIALIZERS)
- public String testRestMethodAddParsersSerializers(@Content String in) {
- return in;
- }
-
- //====================================================================================================
- // Various Accept incantations.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testAccept")
- public String testAccept(@Content String in) {
- return in;
- }
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on method annotation are picked up
- // when @RestMethod.parsers/serializers annotations are used.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testRestMethodParserSerializerAnnotations", defaultRequestHeaders={"Accept: text/s3","Content-Type: text/p3"}, parsers=P3.class, serializers=S3.class)
- public String testRestMethodParserSerializerAnnotations(@Content String in) {
- return in;
- }
-
- //====================================================================================================
- // Test that default Accept and Content-Type headers on method annotation are picked up
- // when @RestMethod.addParsers/addSerializers annotations are used.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testRestMethodAddParsersSerializersAnnotations", defaultRequestHeaders={"Accept: text/s3","Content-Type: text/p3"}, parsers=P3.class, parsersInherit=PARSERS, serializers=S3.class, serializersInherit=SERIALIZERS)
- public String testRestMethodAddParsersSerializersAnnotations(@Content String in) {
- return in;
- }
-
- public static class DummyParser extends ReaderParser {
- private String name;
- private DummyParser(String name) {
- this.name = name;
- }
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return (T)name;
- }
- }
-
- public static class DummySerializer extends WriterSerializer {
- private String name;
- private DummySerializer(String name) {
- this.name = name;
- }
- @Override /* Serializer */
- protected void doSerialize(SerializerSession session, Object output) throws Exception {
- session.getWriter().write(name + "/" + output);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/ErrorConditionsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/ErrorConditionsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/ErrorConditionsResource.java
deleted file mode 100755
index da59d1d..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/ErrorConditionsResource.java
+++ /dev/null
@@ -1,134 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- * Validates correct parser is used.
- */
-@RestResource(
- path="/testErrorConditions"
-)
-public class ErrorConditionsResource extends RestServletDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Test non-existent properties
- //====================================================================================================
- @RestMethod(name="PUT", path="/testNonExistentBeanProperties")
- public String testNonExistentBeanProperties(@Content Test1 in) {
- return "OK";
- }
-
- public static class Test1 {
- public String f1;
- }
-
- //====================================================================================================
- // Test trying to set properties to wrong data type
- //====================================================================================================
- @RestMethod(name="PUT", path="/testWrongDataType")
- public String testWrongDataType(@Content Test2 in) {
- return "OK";
- }
-
- public static class Test2 {
- public int f1;
- }
-
- //====================================================================================================
- // Test trying to parse into class with non-public no-arg constructor.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testParseIntoNonConstructableBean")
- public String testParseIntoNonConstructableBean(@Content Test3a in) {
- return "OK";
- }
-
- public static class Test3a {
- public int f1;
- private Test3a(){}
- }
-
- //====================================================================================================
- // Test trying to parse into non-static inner class
- //====================================================================================================
- @RestMethod(name="PUT", path="/testParseIntoNonStaticInnerClass")
- public String testParseIntoNonStaticInnerClass(@Content Test3b in) {
- return "OK";
- }
-
- public class Test3b {
- public Test3b(){}
- }
-
- //====================================================================================================
- // Test trying to parse into non-public inner class
- //====================================================================================================
- @RestMethod(name="PUT", path="/testParseIntoNonPublicInnerClass")
- public String testParseIntoNonPublicInnerClass(@Content Test3b1 in) {
- return "OK";
- }
-
- static class Test3b1 {
- public Test3b1(){}
- }
-
- //====================================================================================================
- // Test exception thrown during bean construction.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testThrownConstructorException")
- public String testThrownConstructorException(@Content Test3c in) {
- return "OK";
- }
-
- public static class Test3c {
- public int f1;
- private Test3c(){}
- public static Test3c valueOf(String s) {
- throw new RuntimeException("Test error");
- }
- }
-
- //====================================================================================================
- // Test trying to set parameters to invalid types.
- //====================================================================================================
- @RestMethod(name="PUT", path="/testSetParameterToInvalidTypes/{a1}")
- public String testSetParameterToInvalidTypes(@Param("p1") int t1, @Attr int a1, @Header("h1") int h1) {
- return "OK";
- }
-
- //====================================================================================================
- // Test SC_NOT_FOUND & SC_METHOD_NOT_ALLOWED
- //====================================================================================================
- @RestMethod(name="GET", path="/test404and405")
- public String test404and405() {
- return "OK";
- }
-
- //====================================================================================================
- // Test SC_PRECONDITION_FAILED
- //====================================================================================================
- @RestMethod(name="GET", path="/test412", matchers=NeverMatcher.class)
- public String test412() {
- return "OK";
- }
-
- public static class NeverMatcher extends RestMatcher {
- @Override /* RestMatcher */
- public boolean matches(RestRequest req) {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/GroupsResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/GroupsResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/GroupsResource.java
deleted file mode 100755
index 0fb71af..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/GroupsResource.java
+++ /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. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testGroups"
-)
-public class GroupsResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- @Produces({"text/s1","text/s2"})
- public static class SSerializer extends WriterSerializer {
- @Override /* Serializer */
- protected void doSerialize(SerializerSession session, Object output) throws Exception {
- session.getWriter().write("text/s," + output);
- }
- }
-
- @Consumes({"text/p1","text/p2"})
- public static class PParser extends ReaderParser {
- @SuppressWarnings("unchecked")
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return (T)IOUtils.read(session.getReader());
- }
- }
-
-
- @Override /* RestServlet */
- public SerializerGroup createSerializers(ObjectMap properties, Class<?>[] beanFilters, Class<?>[] pojoSwaps) throws Exception {
- return new SerializerGroup().append(SSerializer.class).setProperties(properties).addBeanFilters(beanFilters).addPojoSwaps(pojoSwaps);
- }
-
- @Override /* RestServlet */
- public ParserGroup createParsers(ObjectMap properties, Class<?>[] beanFilters, Class<?>[] pojoSwaps) throws Exception {
- return new ParserGroup().append(PParser.class).setProperties(properties).addBeanFilters(beanFilters).addPojoSwaps(pojoSwaps);
- }
-
- //====================================================================================================
- // Serializer defined on class.
- //====================================================================================================
- @RestMethod(name="GET", path="/testSerializerDefinedOnClass")
- public String testSerializerDefinedOnClass_get() {
- return "GET";
- }
-
- @RestMethod(name="PUT", path="/testSerializerDefinedOnClass")
- public String testSerializerDefinedOnClass_put(@Content String in) {
- return in;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/GzipResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/GzipResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/GzipResource.java
deleted file mode 100755
index 673f55e..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/GzipResource.java
+++ /dev/null
@@ -1,110 +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 java.io.*;
-
-import org.apache.juneau.encoders.*;
-import org.apache.juneau.plaintext.*;
-import org.apache.juneau.server.annotation.*;
-
-/**
- * JUnit automated testcase resource.
- */
-public class GzipResource {
-
- //================================================================================
- // Encoder for "myencoding" encoding
- //================================================================================
- public static class MyEncoder extends GzipEncoder {
- @Override /* Encoder */
- public String[] getCodings() {
- return new String[]{"mycoding"};
- }
- }
-
- //====================================================================================================
- // Test with no compression enabled.
- //====================================================================================================
- @RestResource(
- path="/testGzipOff",
- serializers=PlainTextSerializer.class,
- parsers=PlainTextParser.class
- )
- public static class TestGzipOff extends RestServlet {
- private static final long serialVersionUID = 1L;
- @RestMethod(name="GET", path="/")
- public String test1get() {
- return "foo";
- }
- @RestMethod(name="PUT", path="/")
- public String test1put(@Content String in) {
- return in;
- }
- }
-
- //====================================================================================================
- // Test with compression enabled.
- //====================================================================================================
- @RestResource(
- path="/testGzipOn",
- serializers=PlainTextSerializer.class,
- parsers=PlainTextParser.class,
- encoders=MyEncoder.class
- )
- public static class TestGzipOn extends RestServlet {
- private static final long serialVersionUID = 1L;
- @RestMethod(name="GET", path="/")
- public String test1() {
- return "foo";
- }
- @RestMethod(name="PUT", path="/")
- public String test1put(@Content String in) {
- return in;
- }
- // This method bypasses the content type and encoding from
- // the serializers and encoders when calling getOutputStream() directly.
- @RestMethod(name="GET", path="/direct")
- public void direct(RestResponse res) throws Exception {
- res.setContentType("text/direct");
- OutputStream os = res.getOutputStream();
- os.write("test".getBytes());
- os.flush();
- }
-
- // This method bypasses the content type and encoding from
- // the serializers and encoders when calling getWriter() directly.
- @RestMethod(name="GET", path="/direct2")
- public void direct2(RestResponse res) throws Exception {
- Writer w = res.getWriter();
- w.append("test");
- w.flush();
- }
-
- // This method uses getNegotiatedWriter() which should use GZip encoding.
- @RestMethod(name="GET", path="/direct3")
- public void direct3(RestResponse res) throws Exception {
- Writer w = res.getNegotiatedWriter();
- w.append("test");
- w.flush();
- }
-
- // This method overrides the set of encoders at the method level and so shouldn't use GZip encoding.
- @RestMethod(name="GET", path="/direct4", inheritEncoders=false)
- public void direct4(RestResponse res) throws Exception {
- Writer w = res.getNegotiatedWriter();
- w.append("test");
- w.flush();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/InheritanceResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/InheritanceResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/InheritanceResource.java
deleted file mode 100755
index c3907b5..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/InheritanceResource.java
+++ /dev/null
@@ -1,316 +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.apache.juneau.server.annotation.Inherit.*;
-
-import java.io.*;
-import java.util.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.encoders.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.server.annotation.*;
-import org.apache.juneau.server.annotation.Properties;
-import org.apache.juneau.transform.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testInheritance",
- serializers={InheritanceResource.S1.class,InheritanceResource.S2.class},
- parsers={InheritanceResource.P1.class,InheritanceResource.P2.class},
- encoders={InheritanceResource.E1.class,InheritanceResource.E2.class},
- pojoSwaps={InheritanceResource.F1Swap.class},
- properties={@Property(name="p1",value="v1"), @Property(name="p2",value="v2")}
-)
-public class InheritanceResource extends RestServlet {
- private static final long serialVersionUID = 1L;
-
- @RestResource(
- serializers={S3.class,S4.class},
- parsers={P3.class,P4.class},
- encoders={E3.class,E4.class},
- pojoSwaps={F2Swap.class},
- properties={@Property(name="p2",value="v2a"), @Property(name="p3",value="v3"), @Property(name="p4",value="v4")}
- )
- public static class Sub extends InheritanceResource {
- private static final long serialVersionUID = 1L;
- }
-
- //====================================================================================================
- // Test serializer inheritance.
- //====================================================================================================
- @RestResource(path="/testInheritanceSerializers")
- public static class TestSerializers extends Sub {
- private static final long serialVersionUID = 1L;
-
- // Should show ['text/s3','text/s4','text/s1','text/s2']
- @RestMethod(
- name="GET",
- path="/test1"
- )
- public Reader test1(RestResponse res) {
- return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
- }
-
- // Should show ['text/s5']
- @RestMethod(
- name="GET",
- path="/test2",
- serializers=S5.class
- )
- public Reader test2(RestResponse res) {
- return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
- }
-
- // Should show ['text/s5','text/s3','text/s4','text/s1','text/s2']
- @RestMethod(
- name="GET",
- path="/test3",
- serializers=S5.class,
- serializersInherit=SERIALIZERS
- )
- public Reader test3(RestResponse res) {
- return new StringReader(new ObjectList(res.getSupportedMediaTypes()).toString());
- }
- }
-
- //====================================================================================================
- // Test parser inheritance.
- //====================================================================================================
- @RestResource(path="/testInheritanceParsers")
- public static class TestParsers extends Sub {
- private static final long serialVersionUID = 1L;
-
- // Should show ['text/p3','text/p4','text/p1','text/p2']
- @RestMethod(
- name="GET",
- path="/test1"
- )
- public Reader test1(RestRequest req) {
- return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
- }
-
- // Should show ['text/p5']
- @RestMethod(
- name="GET",
- path="/test2",
- parsers=P5.class
- )
- public Reader test2(RestRequest req) {
- return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
- }
-
- // Should show ['text/p5','text/p3','text/p4','text/p1','text/p2']
- @RestMethod(
- name="GET",
- path="/test3",
- parsers=P5.class,
- parsersInherit=PARSERS
- )
- public Reader test3(RestRequest req) {
- return new StringReader(new ObjectList(req.getSupportedMediaTypes()).toString());
- }
- }
-
- //====================================================================================================
- // Test encoder inheritance.
- //====================================================================================================
- @RestResource(path="/testInheritanceEncoders")
- public static class TestEncoders extends Sub {
- private static final long serialVersionUID = 1L;
-
- // Should show ['e3','e4','e1','e2','identity']
- @RestMethod(name="GET", path="/test")
- public Reader test(RestResponse res) throws RestServletException {
- return new StringReader(new ObjectList(res.getSupportedEncodings()).toString());
- }
- }
-
- //====================================================================================================
- // Test filter inheritance.
- //====================================================================================================
- @RestResource(path="/testInheritanceTransforms", serializers=JsonSerializer.Simple.class)
- public static class TestTransforms extends Sub {
- private static final long serialVersionUID = 1L;
-
- // Should show ['F1Swap','F2Swap','Foo3']
- @RestMethod(name="GET", path="/test1")
- public Object[] test1() {
- return new Object[]{new Foo1(), new Foo2(), new Foo3()};
- }
-
- // Should show ['F1Swap','F2Swap','F3Swap']
- // Inherited serializer already has parent filters applied.
- @RestMethod(name="GET", path="/test2", pojoSwaps=F3Swap.class)
- public Object[] test2() {
- return new Object[]{new Foo1(), new Foo2(), new Foo3()};
- }
-
- // Should show ['F1Swap','F2Swap','F3Swap']
- @RestMethod(name="GET", path="/test3", pojoSwaps=F3Swap.class, serializersInherit=TRANSFORMS)
- public Object[] test3() {
- return new Object[]{new Foo1(), new Foo2(), new Foo3()};
- }
-
- // Should show ['Foo1','Foo2','F3Swap']
- // Overriding serializer does not have parent filters applied.
- @RestMethod(name="GET", path="/test4", serializers=JsonSerializer.Simple.class, pojoSwaps=F3Swap.class)
- public Object[] test4() {
- return new Object[]{new Foo1(), new Foo2(), new Foo3()};
- }
-
- // Should show ['F1Swap','F2Swap','F3Swap']
- // Overriding serializer does have parent filters applied.
- @RestMethod(name="GET", path="/test5", serializers=JsonSerializer.Simple.class, pojoSwaps=F3Swap.class, serializersInherit=TRANSFORMS)
- public Object[] test5() {
- return new Object[]{new Foo1(), new Foo2(), new Foo3()};
- }
- }
-
- //====================================================================================================
- // Test properties inheritance.
- //====================================================================================================
- @RestResource(path="/testInheritanceProperties", serializers=JsonSerializer.Simple.class)
- public static class TestProperties extends Sub {
- private static final long serialVersionUID = 1L;
-
- // Should show {p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}
- @RestMethod(name="GET", path="/test1")
- public ObjectMap test1(@Properties ObjectMap properties) {
- return transform(properties);
- }
-
- // Should show {p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'} when override is false.
- // Should show {p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'} when override is true.
- @RestMethod(name="GET", path="/test2",
- properties={@Property(name="p4",value="v4a"), @Property(name="p5", value="v5")})
- public ObjectMap test2(@Properties ObjectMap properties, @HasParam("override") boolean override) {
- if (override) {
- properties.put("p1", "x");
- properties.put("p2", "x");
- properties.put("p3", "x");
- properties.put("p4", "x");
- properties.put("p5", "x");
- }
- return transform(properties);
- }
-
- private ObjectMap transform(ObjectMap properties) {
- ObjectMap m = new ObjectMap();
- for (Map.Entry<String,Object> e : properties.entrySet()) {
- if (e.getKey().startsWith("p"))
- m.put(e.getKey(), e.getValue());
- }
- return m;
- }
- }
-
- public static class DummyParser extends ReaderParser {
- @Override /* Parser */
- protected <T> T doParse(ParserSession session, ClassMeta<T> type) throws Exception {
- return null;
- }
- }
-
- public static class DummySerializer extends WriterSerializer {
- @Override /* Serializer */
- protected void doSerialize(SerializerSession session, Object o) throws Exception {
- session.getWriter().write(o.toString());
- }
- }
-
- @Consumes("text/p1")
- public static class P1 extends DummyParser{}
-
- @Consumes("text/p2")
- public static class P2 extends DummyParser{}
-
- @Consumes("text/p3")
- public static class P3 extends DummyParser{}
-
- @Consumes("text/p4")
- public static class P4 extends DummyParser{}
-
- @Consumes("text/p5")
- public static class P5 extends DummyParser{}
-
- @Produces("text/s1")
- public static class S1 extends DummySerializer{}
-
- @Produces("text/s2")
- public static class S2 extends DummySerializer{}
-
- @Produces("text/s3")
- public static class S3 extends DummySerializer{}
-
- @Produces("text/s4")
- public static class S4 extends DummySerializer{}
-
- @Produces("text/s5")
- public static class S5 extends DummySerializer{}
-
- public static class E1 extends IdentityEncoder {
- @Override public String[] getCodings() {
- return new String[]{"e1"};
- }
- }
-
- public static class E2 extends IdentityEncoder {
- @Override public String[] getCodings() {
- return new String[]{"e2"};
- }
- }
-
- public static class E3 extends IdentityEncoder {
- @Override public String[] getCodings() {
- return new String[]{"e3"};
- }
- }
-
- public static class E4 extends IdentityEncoder {
- @Override public String[] getCodings() {
- return new String[]{"e4"};
- }
- }
-
- public static class Foo1 {@Override public String toString(){return "Foo1";}}
- public static class Foo2 {@Override public String toString(){return "Foo2";}}
- public static class Foo3 {@Override public String toString(){return "Foo3";}}
-
- public static class F1Swap extends PojoSwap<Foo1,String> {
- @Override /* PojoSwap */
- public String swap(Foo1 o) throws SerializeException {
- return "F1";
- }
- }
-
- public static class F2Swap extends PojoSwap<Foo2,String> {
- @Override /* PojoSwap */
- public String swap(Foo2 o) throws SerializeException {
- return "F2";
- }
- }
-
- public static class F3Swap extends PojoSwap<Foo3,String> {
- @Override /* PojoSwap */
- public String swap(Foo3 o) throws SerializeException {
- return "F3";
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojo.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojo.java b/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojo.java
deleted file mode 100755
index 849112b..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojo.java
+++ /dev/null
@@ -1,45 +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 java.util.*;
-
-/**
- * A large POJO object.
- */
-@SuppressWarnings("serial")
-public class LargePojo {
- public A1Map a1Map;
- public A1List a1List;
- public A1[] a1Array;
-
- public static LargePojo create() {
- LargePojo a = new LargePojo();
- a.a1Map = new A1Map();
- a.a1List = new A1List();
- for (int i = 0; i < 20000; i++) {
- a.a1Map.put(String.valueOf(i), new A1());
- a.a1List.add(new A1());
- }
- a.a1Array = a.a1List.toArray(new A1[0]);
- return a;
- }
-
- public static class A1 {
- public String f1 = "a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789";
- }
-
- public static class A1Map extends LinkedHashMap<String,A1> {}
-
- public static class A1List extends LinkedList<A1> {}
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojosResource.java
----------------------------------------------------------------------
diff --git a/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojosResource.java b/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojosResource.java
deleted file mode 100755
index 02f9757..0000000
--- a/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojosResource.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// ***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
-// * with the License. You may obtain a copy of the License at *
-// * *
-// * http://www.apache.org/licenses/LICENSE-2.0 *
-// * *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
-// * specific language governing permissions and limitations under the License. *
-// ***************************************************************************************************************************
-package org.apache.juneau.server;
-
-import org.apache.juneau.server.annotation.*;
-import org.apache.juneau.server.jena.*;
-
-/**
- * JUnit automated testcase resource.
- */
-@RestResource(
- path="/testLargePojos"
-)
-public class LargePojosResource extends RestServletJenaDefault {
- private static final long serialVersionUID = 1L;
-
- //====================================================================================================
- // Test how long it takes to serialize/parse various content types.
- //====================================================================================================
- @RestMethod(name="GET", path="/")
- public LargePojo testGet() {
- return LargePojo.create();
- }
-
- @RestMethod(name="PUT", path="/")
- public String testPut(@Content LargePojo in) {
- return "ok";
- }
-}
[17/20] incubator-juneau git commit: Clean up Javadocs
Posted by ja...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/javadoc/overview.html
----------------------------------------------------------------------
diff --git a/juneau-core/src/main/javadoc/overview.html b/juneau-core/src/main/javadoc/overview.html
index 7eb40bd..07d18c9 100644
--- a/juneau-core/src/main/javadoc/overview.html
+++ b/juneau-core/src/main/javadoc/overview.html
@@ -55,30 +55,43 @@
}
}
</script>
-<p>
- A generalized toolkit for converting POJOs to and from a variety of content types (JSON, XML, HTML, URLs, RDF/XML, N-Tuple, Turtle, N3, SOAP, Cognos, ATOM), and a REST toolkit for building up REST interfaces using simple POJOs.
-</p>
+<ul class='spaced-list'>
+ <li>A toolkit for marshalling POJOs to a wide variety of content types using a common framework.
+ <li>A REST server API for creating self-documenting REST interfaces using POJOs.
+ <li>A REST client API for interacting with REST interfaces using POJOs.
+ <li>A remote proxy API built on top of REST.
+ <li>A sophisticated INI config file API.
+ <li>A REST microservice API that combines all the features above for creating lightweight standalone REST interfaces that start up in milliseconds.
+</ul>
<a id='TOC'></a><h5 class='toc'>Table of Contents</h5>
<ol class='toc'>
<li><p><a class='doclink' href='#Intro'>Juneau - What is it?</a></p>
- <li><p><a class='doclink' href='#Core'>Juneau Core (juneau.jar)</a></p>
+ <li><p><a class='doclink' href='#Core'>Juneau Core (org.apache.juneau)</a></p>
<ol>
- <li><p><a class='doclink' href='#Core.PojoCategories'>POJO Categories</a></p>
<li><p><a class='doclink' href='#Core.Serializers'>Serializers</a></p>
<li><p><a class='doclink' href='#Core.Parsers'>Parsers</a></p>
+ <li><p><a class='doclink' href='#Core.SerializerAndParserGroups'>SerializerGroups and ParserGroups</a></p>
<li><p><a class='doclink' href='#Core.ObjectMap'>ObjectMap and ObjectList</a></p>
<li><p><a class='doclink' href='#Core.ConfigurableProperties'>Configurable Properties</a></p>
- <li><p><a class='doclink' href='#Core.Annotations'>Annotations</a></p>
<li><p><a class='doclink' href='#Core.Transforms'>Transforms</a></p>
+ <ol>
+ <li><p><a class='doclink' href='#Core.PojoSwaps'>PojoSwaps</a></p>
+ <li><p><a class='doclink' href='#Core.BeanFilters'>BeanFilters and @Bean annotations</a></p>
+ </ol>
+ <li><p><a class='doclink' href='#Core.BeanDictionaries'>Bean Name and Dictionaries</a></p>
+ <ol>
+ <li><p><a class='doclink' href='#Core.BeanSubTypes'>Bean Subtypes</a></p>
+ </ol>
+ <li><p><a class='doclink' href='#Core.PojoCategories'>POJO Categories</a></p>
<li><p><a class='doclink' href='#Core.SimpleVarLanguage'>Simple Variable Language</a></p>
<li><p><a class='doclink' href='#Core.ConfigFile'>Configuration Files</a></p>
<li><p><a class='doclink' href='#Core.SupportedLanguages'>Supported Languages</a></p>
</ol>
- <li><p><a class='doclink' href='#Server'>Juneau Server (juneau-server.jar)</a></p>
- <li><p><a class='doclink' href='#Client'>Juneau Client (juneau-client.jar)</a></p>
- <li><p><a class='doclink' href='#Remoteable'>Remoteable services</a></p>
- <li><p><a class='doclink' href='#Microservices'>Juneau Microservices (juneau-microservice.jar)</a></p>
+ <li><p><a class='doclink' href='#Server'>Juneau Server (org.apache.juneau.server)</a></p>
+ <li><p><a class='doclink' href='#Client'>Juneau Client (org.apache.juneau.client)</a></p>
+ <li><p><a class='doclink' href='#Remoteable'>Remoteable services (org.apache.juneau.server.remoteable)</a></p>
+ <li><p><a class='doclink' href='#Microservices'>Juneau Microservices (org.apache.juneau.microservice)</a></p>
<li><p><a class='doclink' href='#Samples'>Samples</a></p>
<ol>
<li><p><a class='doclink' href='#Samples.Installing'>Installing in Eclipse</a></p>
@@ -136,33 +149,35 @@
<h2 class='topic' onclick='toggle(this)'>1 - Juneau - What is it?</h2>
<div class='topic'>
<p>
- Juneau started off as a simple library for serializing and parsing POJOs to and from JSON.
- Since then, it has expanded into serializing and parsing a variety of other content types.
- Later, entire REST client, server, and microservice APIs were developed that utilized the power of these serializers and parsers.
- Together, these features allow the construction of powerful REST interfaces wrapped around existing POJOs using very little code.
+ Juneau started off as a popular internal IBM toolkit called Juno.
+ Originally used for serializing POJOs to and from JSON, it later expanded in scope to include a variety of content types, and then later REST servlet, client, and microservice APIs.
+ It's use grew to more than 50 projects and was one of the most popular community source projects within IBM.
</p>
-
+ <p>
+ In 2016, the code was donated to the Apache Foundation under the project <l>Apache Juneau</l>.
+ </p>
<h5 class='toc'>Features</h5>
<ol class='toc'>
<li>
- <p>Extensive and extensible support for a large variety of POJOs, including structured data (beans) and unstructured data (<l>Maps</l> and <l>Collections</l>).</p>
+ <p>Extensive and extensible support for a large variety of POJOs, including structured data (beans) and unstructured data (<code>Maps</code> and <code>Collections</code>).</p>
<li>
- <p>Support for serializing POJO models to:</p>
+ <p>Serialization support:</p>
<ul>
<li>JSON (including variants)
- <li>XML
+ <li>XML
<li>HTML
<li>URL-Encoding
<li>UON (URL-Encoded Object Notation)
<li>MessagePack
- <li>RDF/XML (including abbreviated)
+ <li>RDF/XML
+ <li>RDF/XML-Abbrev
<li>N-Triple
<li>Turtle
<li>N3
<li>SOAP/XML
</ul>
<li>
- <p>Support for parsing the following into POJO models:</p>
+ <p>Parsing support:</p>
<ul>
<li>JSON (including lax syntax, comments, concatenated strings)
<li>XML
@@ -170,336 +185,110 @@
<li>URL-Encoding
<li>UON (URL-Encoded Object Notation)
<li>MessagePack
- <li>RDF/XML (including abbreviated)
+ <li>RDF/XML
+ <li>RDF/XML-Abbrev
<li>N-Triple
<li>Turtle
<li>N3
</ul>
<li>
- <p>Data Transfer Objects for the following:</p>
+ <p>Data Transfer Objects:</p>
<ul>
<li>ATOM
<li>Cognos
<li>JSON-Schema
<li>HTML 5 (in progress)
</ul>
- <p>DTOs can be used with any serializers and parsers.
+ <p>DTOs can be used with any serializers and parsers (e.g. ATOM as JSON).
<li>
- <p>Support for serializing POJO meta-models (specifically the POJO class structure itself) to:</p>
+ <p>Serialization of POJO meta-models (e.g. the POJO class structure itself) to:</p>
<ul>
<li>JSON-Schema
<li>XML-Schema
<li>HTML-Schema
</ul>
<li>
- <div>
- JSON parser supports ALL valid JSON, such as:
- <ul class='normal'>
- <li>Javascript comments.
- <li>Single or double quoted values.
- <li>Quoted (strict) or unquoted (non-strict) attributes.
- <li>JSON fragments (such as string, numeric, or boolean primitive values).
- <li>Concatenated strings.
- </ul>
- </div>
- <li>
- <div>
- REST server interface that allows POJOs to be accessed through REST calls.
- <ul class='normal'>
- <li>Serialization and parsing layer is completely transparent to developer.
- Simply pass a POJO to the toolkit, and all serialization and parsing is taken care of.
- <li>Extensible / customizable design.
- Ability to define support for additional content types, or to handle requests manually at many different levels.
- <li>Default built-in support for serializing output to all supported languages.
- <li>Default built-in support for parsing input from all supported languages.
- <li>Ability to easily design self-documenting interfaces (specifically REST interfaces described entirely through OPTIONS requests).
- <li>Ability to debug interface using nothing more than a browser, including the ability to specify any HTTP headers as GET parameters.
- </ul>
- </div>
- <li>
- <p>REST client interface that allows clients to parse POJOs from the REST server, typically in a single line of code.</p>
- <li>
- <p>No code generators required. Can be used against existing POJO models, unlike other APIs like Java Web Services.</p>
- <li>
<p>
- Serializers/parsers require only Java 1.6+.
+ Serializers/parsers require only Java 6+.
(RDF support requires Jena 2.7.1+)
</p>
<li>
<p>
- REST APIs require only Java 1.6+ and JEE 1.3+.
+ REST APIs require only Java 6+ and JEE 1.3+.
(JAX/RS integration component requires JAX/RS provider)
</p>
- <li>
- <p>Extensive and up-to-date Javadocs with color-coded code examples.</p>
- <li>
- <p>
- Code written for high-performance/high-concurrency/low-memory consumption.<br>
- Caching of POJO metadata speeds execution of serialization and parsing.<br>
- JSON parser is written using a state-machine architecture.<br>
- XML and HTML parsers are written using StAX.<br>
- POJOs are serialized/parsed directly from POJOs without a DOM layer, reducing object creation.
- </p>
- <li>
- <p>A simple-to-use JAX-RS / Wink provider for using the existing Juneau serializers and parsers in a JAX-RS environment.</p>
- <li>
- <p>An external INI-style configuration file API.</p>
- <li>
- <p>An API for defining REST resource microservices as simple executable jars.</p>
</ol>
<h5 class='topic'>Components</h5>
<p>
- Juneau consists of the following libraries:
+ Juneau ships as a single Java library called <l>juneau.jar</l>.
</p>
- <ul class='spaced-list'>
- <li><l>juneau.jar</l> - Core library that contains the serializers, parsers, and bean map support.<br>
- Prereqs Java 1.6+.<br>
- This package can be used by itself if you only need to serialize or parse from any of the supported languages, or use the Bean Map support separately.<br>
- See the following subtopic <a class='doclink' href='#Core'>Juneau Core (juneau.jar)</a> for details on this library.<br>
- <li><l>juneau-server.jar</l> - Contains the REST server APIs.<br>
- Prereqs Java 1.6+, JEE 1.3+.<br>
- This package can be used to create servlet-based REST interfaces.<br>
- See <a class='doclink' href="#Server">Juneau Server (juneau-server.jar)</a> for details on this library.<br>
- <li><l>juneau-client.jar</l> - Contains the REST client APIs.<br>
- Prereqs Java 1.6+.<br>
- This package can be used to easily communicate with Juneau REST servlets.<br>
- See <a class='doclink' href="#Client">Juneau Client (juneau-client.jar)</a> for details on this library.<br>
- <li><l>juneau-microservice.jar</l> - An API for defining REST services as executable jars.<br>
- See <a class='doclink' href="#Microservices">Juneau Microservices (juneau-microservice.jar)</a> for details on this package.<br>
- <li><l>juneau-all.jar</l> - Combines all the jars above into a single library.
+ <p>
+ Juneau requires Java 6+. The majority of the code has no other dependencies except for the following packages:
+ </p>
+ <ul class='javahierarchy'>
+ <li class='p'> {@link org.apache.juneau.jena} - RDF support. Requires Apache Jena 2.7.1+.
+ <li class='p'> {@link org.apache.juneau.server} - REST servlet support. Requires JEE 1.3+.
+ <li class='p'> {@link org.apache.juneau.client} - REST client support. Requires Apache HttpClient 4.5+.
</ul>
<p>
- Typically, you want to simply pick up and use <l>juneau-all.jar</l> as this contains everything and is not very large (< 1MB).
+ OSGi bundles are also provided that break down Juneau into the following components:
</p>
+ <ul class='spaced-list'>
+ <li><l>org.apache.juneau.core.jar</l> - Serializers, parsers, INI file support.<br>
+ <li><l>org.apache.juneau.server.jar</l> - REST servlet support.<br>
+ <li><l>org.apache.juneau.client.jar</l> - REST client support.<br>
+ <li><l>org.apache.juneau.microservice.jar</l> - Microservice support.<br>
+ </ul>
<p>
The following zip files are also provided:
</p>
<ul class='spaced-list'>
<li><l>microservice-project.zip</l> - Contains a template Eclipse project for quickly creating REST resources as executable jars.
- <li><l>microservice-samples-project.zip</l> - Contains sample code demonstrating various aspects of the Juneau Cloud Tools.<br>
+ <li><l>microservice-samples-project.zip</l> - Contains sample code demonstrating various aspects of Juneau.<br>
These are discussed in detail in the <a class='doclink' href="#Samples">Samples</a> section.
</ul>
+
+ <h5 class='topic'>A note about examples</h5>
<p class='info'>
- Many of the examples below use beans with public field properties.
- While the toolkit allows for public bean properties, it's standard practice to use getters and setters for bean properties.
- However, the examples below use public fields simply to reduce their verbosity.
+ Many of the examples below use beans with public field properties instead of standard getters/setters.
+ This is to simplify the examples.
</p>
</div>
<!-- ======================================================================================================== -->
<a id="Core"></a>
-<h2 class='topic' onclick='toggle(this)'>2 - Juneau Core (juneau.jar)</h2>
+<h2 class='topic' onclick='toggle(this)'>2 - Juneau Core (org.apache.juneau)</h2>
<div class='topic'>
<p>
- The Juneau core library <l>juneau.jar</l> contains serializers and parsers for converting POJOs to and from
- a wide variety of content types:
+ The core packages of Juneau contains serializers and parsers for converting POJOs to and from a wide variety of content types.
+ It uses a common API for defining serializers and parsers.
+ </p>
+ <p>
+ One of the goals of Juneau was to make serialization as simple as possible.
+ In a single line of code, you should be able to serialize and parse most POJOs.
+ Despite this simplicity, Juneau provides lots of extensibility and configuration properties for tailoring how POJOs are serialized and parsed.
</p>
- <ul>
- <li>JSON
- <li>XML
- <li>HTML
- <li>URL-Encoding
- <li>UON
- <li>MessagePack
- <li>RDF-XML
- <li>RDF-XML-Abbrev
- <li>Turtle
- <li>N3
- <li>N-Triple
- <li>Plain text
- <li>Cognos XML
- </ul>
<!-- ======================================================================================================== -->
- <a id="Core.PojoCategories"></a>
- <h3 class='topic' onclick='toggle(this)'>2.1 - POJO Categories</h3>
- <div class='topic'>
- <p>
- The Juneau serializers and parsers can handle a wide variety of POJOs.
- </p>
- <p>
- The following chart shows POJOs categorized into groups and whether they can be serialized or parsed:
- </p>
- <table class='styled' style='border-collapse: collapse;'>
- <tr><th>Group</th><th>Description</th><th>Examples</th><th>Can<br>serialize?</th><th>Can<br>parse?</th></tr>
- <tr class='dark bb' style='background-color:lightyellow;'>
- <td style='text-align:center'>1</td>
- <td><b>Java primitive objects</b></td>
- <td>
- <ul class='normal'>
- <li>{@code String}
- <li>{@code Integer}
- <li>{@code Float}
- <li>{@code Boolean}
- </ul>
- </td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- </tr>
- <tr class='dark bb' style='background-color:lightyellow'>
- <td style='text-align:center'>2</td>
- <td><b>Java Collections Framework objects and Java arrays</b></td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>2a</td>
- <td>
- <b>With standard keys/values</b><br>
- Map keys are group [1, 4a, 5] objects.<br>
- Map, Collection, and array values are group [1, 2, 3a, 4a, 5] objects.
- </td>
- <td>
- <ul class='normal'>
- <li>{@code HashSet<String,Integer>}
- <li>{@code TreeMap<Integer,Bean>}
- <li><code>List<<jk>int</jk>[][]></code>
- <li>{@code Bean[]}
- </ul>
- </td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>2b</td>
- <td>
- <b>With non-standard keys/values</b><br>
- Map keys are group [2, 3, 4b, 5, 6] objects.<br>
- Map, Collection, and array values are group [3b, 4, 5, 6] objects.
- </td>
- <td>
- <ul class='normal'>
- <li>{@code HashSet<Bean,Integer>}
- <li>{@code TreeMap<Integer,Reader>}
- </ul>
- </td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:salmon;text-align:center'><b>no</b></td>
- </tr>
- <tr class='dark bb' style='background-color:lightyellow'>
- <td style='text-align:center'>3</td>
- <td><b>Java Beans</b></td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>3a</td>
- <td>
- <b>With standard properties</b><br>
- These are beans that have no-arg constructors and one or more properties defined by public getter and setter methods or public fields.<br>
- Property values are group [1, 2, 3a, 4a, 5] objects.
- </td>
- <td> </td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>3b</td>
- <td>
- <b>With non-standard properties or not true beans</b><br>
- These include true beans that have no-arg constructors and one or more properties defined by getter and setter methods or properties,
- but property types include group [3b, 4b, 5, 6] objects.<br>
- This also includes classes that look like beans but aren't true beans.
- For example, classes that have getters but not setters, or classes without no-arg constructors.
- </td>
- <td> </td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:salmon;text-align:center'><b>no</b></td>
- </tr>
- <tr class='dark bb' style='background-color:lightyellow'>
- <td style='text-align:center'>4</td>
- <td>
- <b>Swapped objects</b><br>
- These are objects that are not directly serializable, but have {@link org.apache.juneau.transform.PojoSwap PojoSwaps} associated with them.
- The purpose of a POJO swap is to convert an object to another object that is easier to serialize and parse.
- For example, the {@link org.apache.juneau.transforms.DateSwap.ISO8601DT} class can be used to serialize {@link java.util.Date} objects
- to ISO8601 strings, and parse them back into {@link java.util.Date} objects.
- </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>4a</td>
- <td>
- <b>2-way swapped to group [1, 2a, 3a] objects</b><br>
- For example, a swap that converts a {@code Date} to a {@code String}.
- </td>
- <td> </td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- </tr>
- <tr class='light bb'>
- <td style='text-align:center'>4b</td>
- <td>
- <b>1-way swapped to group [1, 2, 3] objects</b><br>
- For example, a swap that converts an {@code Iterator} to a {@code List}.
- This would be one way, since you cannot reconstruct an {@code Iterator}.
- </td>
- <td> </td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:salmon;text-align:center'><b>no</b></td>
- </tr>
- <tr class='dark bb' style='background-color:lightyellow'>
- <td style='text-align:center'>5</td>
- <td>
- <b>Objects with standardized <code>static T valueOf(String)</code>/<code>static T fromString(String)</code> methods, or constructors with a <code>String</code> argument.</b><br>
- During serialization, objects are converted to strings using the <code>toString()</code> method.
- During parsing, strings are converted to objects using one of these static methods or constructors.
- </td>
- <td><code>java.util.UUID</code></td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- </tr>
- <tr class='dark' style='background-color:lightyellow'>
- <td style='text-align:center'>6</td>
- <td>
- <b>All other objects</b><br>
- Anything that doesn't fall into one of the groups above are simply converted to {@code Strings} using the {@code toString()} method.
- </td>
- <td> </td>
- <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
- <td style='background-color:salmon;text-align:center'><b>no</b></td>
- </tr>
- </table>
- <p>
- One other important note is that the serializers are designed to work on tree-shaped POJO models.
- These are models where there are no referential loops (e.g. leaves with references to nodes, or nodes in one branch referencing nodes in another branch).
- There is a serializer setting {@code detectRecursions} to look for and handle these kinds of loops (by setting these references to <jk>null</jk>),
- but it is not enabled by default since it introduces a moderate performance penalty.
- </p>
- </div>
-
- <!-- ======================================================================================================== -->
<a id="Core.Serializers"></a>
- <h3 class='topic' onclick='toggle(this)'>2.2 - Serializers</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.1 - Serializers</h3>
<div class='topic'>
<p>
- The built-in serializers in Juneau are fast and efficient, and are highly customizable, for example, allowing you to produce strict or non-strict syntax,
- various whitespace options, and automatic detection of recursions.
- </p>
- <p>
- The serializers work by serializing POJOs directly to streams instead of using intermediate Document Object Model objects.
- This allows serialization with minimal memory use.
- </p>
- <p>
- Default serialization support is provided for Java primitives, <l>Maps</l>, <l>Collections</l>, beans, and arrays. <br>
- Extensible support for other data types such as <l>Calendars</l>, <l>Dates</l>, <l>Iterators</l> is available through the use of POJO swaps.
+ The built-in serializers in Juneau are fast, efficient, and highly configurable.
+ They work by serializing POJOs directly to streams instead of using intermediate Document Object Model objects.
</p>
<p>
In most cases, you can serialize objects in one line of code by using one of the default serializers:
</p>
<p class='bcode'>
- <jc>// A simple POJO class</jc>
+ <jc>// A simple bean</jc>
<jk>public class</jk> Person {
<jk>public</jk> String <jf>name</jf> = <js>"John Smith"</js>;
<jk>public int</jk> <jf>age</jf> = 21;
}
- <jc>// Serialize a bean to JSON, XML, or HTML</jc>
+ <jc>// Serialize to JSON, XML, or HTML</jc>
Person p = <jk>new</jk> Person();
<jc>// Produces:
@@ -546,6 +335,10 @@
<jc>// Serialize a POJO to JSON</jc>
String json = serializer.serialize(someObject);
</p>
+ <p>
+ Default serialization support is provided for Java primitives, <code>Maps</code>, <code>Collections</code>, beans, and arrays. <br>
+ Extensible support for other data types such as <code>Calendars</code>, <code>Dates</code>, <code>Iterators</code> is available through the use of POJO swaps (described later).
+ </p>
<h6 class='topic'>Additional Information</h6>
<ul class='javahierarchy'>
@@ -555,22 +348,24 @@
<!-- ======================================================================================================== -->
<a id="Core.Parsers"></a>
- <h3 class='topic' onclick='toggle(this)'>2.3 - Parsers</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.2 - Parsers</h3>
<div class='topic'>
<p>
Parsers work by parsing input directly into POJOs instead of having to create intermediate Document Object Models.
This allows them to parse input with minimal object creation.
</p>
<p>
- The JSON parser can handle any valid JSON syntax (such as quoted or unquoted attributes, single or double quotes).<br>
- It can also handle JSON fragements and embedded Javascript comments.
+ Like the serializers, you can often parse objects in one line of code by using one of the default parsers:
</p>
<p class='bcode'>
<jc>// Use one of the predefined parsers.</jc>
Parser parser = JsonParser.<jsf>DEFAULT</jsf>;
- <jc>// Parse a JSON object (creates a generic ObjectMap).</jc>
+ <jc>// Parse a JSON object as a bean.</jc>
String json = <js>"{name:'John Smith',age:21}"</js>;
+ Person p = parser.parse(json, Person.<jk>class</jk>);
+
+ <jc>// Or parse it into a generic Map.</jc>
Map m1 = parser.parse(json, Map.<jk>class</jk>);
<jc>// Parse a JSON string.</jc>
@@ -582,17 +377,13 @@
Long l3 = parser.parse(json, Long.<jk>class</jk>);
Float f3 = parser.parse(json, Float.<jk>class</jk>);
- <jc>// Parse a JSON object as a bean.</jc>
- json = <js>"{name:'John Smith',age:21}"</js>;
- Person p4 = parser.parse(json, Person.<jk>class</jk>);
-
<jc>// Parse a JSON object as a HashMap<String,Person>.</jc>
json = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
- Map<String,Person> m5 = parser.parseMap(json, HashMap.<jk>class</jk>, String.<jk>class</jk>, Person.<jk>class</jk>)
+ Map<String,Person> m4 = parser.parseMap(json, HashMap.<jk>class</jk>, String.<jk>class</jk>, Person.<jk>class</jk>)
<jc>// Parse a JSON array of integers as a Collection of Integers or int[] array.</jc>
json = <js>"[1,2,3]"</js>;
- List<Integer> l6 = parser.parseCollection(json, LinkedList.<jk>class</jk>, Integer.<jk>class</jk>);
+ List<Integer> l5 = parser.parseCollection(json, LinkedList.<jk>class</jk>, Integer.<jk>class</jk>);
<jk>int</jk>[] i6 = parser.parse(json, <jk>int</jk>[].<jk>class</jk>);
</p>
<p>
@@ -617,19 +408,13 @@
Map<String,Person> m3 = <jk>new</jk> TreeMap<String,Person>();
parser.parseIntoMap(json, m3, String.<jk>class</jk>, Person.<jk>class</jk>);
</p>
- <p>
- Juneau can parse both structured models (composed of serialized beans) and unstructured models (composed of generic maps, collections, primitives, and so on).
- Any valid JSON can be parsed into an unstructured model consisting of generic {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} objects.
+ <p class='info'>
+ In the example above, we're parsing "lax" JSON (single quotes, unquoted attributes).
+ The JSON parser can handle any valid JSON syntax (such as quoted or unquoted attributes, single or double quotes).<br>
+ It can also handle JSON fragements and embedded Javascript comments.
+ Many of the JSON examples provided will use lax syntax which is easier to read since we don't have to deal with escapes.
</p>
- <p class='bcode'>
- <jc>// Parse an arbitrary JSON document into an unstructered data model
- // consisting of ObjectMaps, ObjectLists, and java primitive objects.</jc>
- Parser parser = JsonParser.<jsf>DEFAULT</jsf>;
- String json = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
- ObjectMap m = parser.parse(json, ObjectMap.<jk>class</jk>);
-
- <jc>// Use ObjectMap API to extract data from the unstructured model.</jc>
- <jk>int</jk> johnSmithAge = m.getObjectMap(<js>"a"</js>).getInt(<js>"age"</js>);
+ <p>
</p>
<h6 class='topic'>Additional Information</h6>
@@ -639,16 +424,54 @@
</div>
<!-- ======================================================================================================== -->
+ <a id="Core.SerializerAndParserGroups"></a>
+ <h3 class='topic' onclick='toggle(this)'>2.3 - SerializerGroups and ParserGroups</h3>
+ <div class='topic'>
+ <p>
+ Above the serializers and parsers are the {@link org.apache.juneau.serializer.SerializerGroup} and {@link org.apache.juneau.parser.ParserGroup} classes.
+ These classes allow serializers and parsers to be retrieved by W3C-compliant HTTP <code>Accept</code> and <code>Content-Type</code> values...
+ </p>
+ <p class='bcode'>
+ <jc>// Construct a new serializer group with configuration parameters that get applied to all serializers.</jc>
+ SerializerGroup sg = <jk>new</jk> SerializerGroup()
+ .append(JsonSerializer.<jk>class</jk>, UrlEncodingSerializer.<jk>class</jk>);
+ .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>)
+ .addTransforms(CalendarSwap.ISO8601DT.<jk>class</jk>);
+
+ <jc>// Find the appropriate serializer by Accept type and serialize our POJO to the specified writer.</jc>
+ sg.getSerializer(<js>"text/invalid, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0"</js>)
+ .serialize(myPersonObject, myWriter);
+
+ <jc>// Construct a new parser group with configuration parameters that get applied to all parsers.</jc>
+ ParserGroup pg = <jk>new</jk> ParserGroup()
+ .append(JsonSerializer.<jk>class</jk>, UrlEncodingSerializer.<jk>class</jk>);
+ .addTransforms(CalendarSwap.ISO8601DT.<jk>class</jk>);
+
+ Person p = pg.getParser(<js>"text/json"</js>).parse(myReader, Person.<jk>class</jk>);
+ </p>
+ <p>
+ The REST servlet API builds upon the <code>SerializerGroup</code> and <code>ParserGroup</code> classes
+ to provide annotated REST servlets that automatically negotiate the HTTP media types and allow the developer
+ to work with requests and responses as POJOs.
+ </p>
+ <h6 class='topic'>Additional Information</h6>
+ <ul class='javahierarchy'>
+ <li class='c'>{@link org.apache.juneau.serializer.SerializerGroup}
+ <li class='c'>{@link org.apache.juneau.parser.ParserGroup}
+ </ul>
+ </div>
+
+ <!-- ======================================================================================================== -->
<a id="Core.ObjectMap"></a>
<h3 class='topic' onclick='toggle(this)'>2.4 - ObjectMap and ObjectList</h3>
<div class='topic'>
<p>
The {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} classes are generic Java representations of JSON objects and arrays.
These classes can be used to create "unstructured" models for serialization (as opposed to "structured" models consisting of beans).
- If you want to quickly generate JSON/XML/HTML from generic maps/collections, or parse JSON/XML/HTML into generic maps/collections, these objects work well.
+ If you want to quickly generate JSON/XML/HTML from generic maps/collections, or parse JSON/XML/HTML into generic maps/collections, these classes work well.
</p>
<p>
- These classes extend directly from JCF classes:
+ These classes extend directly from the following JCF classes:
</p>
<ul class='javahierarchy'>
<li class='c'> {@link java.util.LinkedHashMap java.util.LinkedHashMap}
@@ -661,7 +484,7 @@
</ul>
</ul>
<p>
- The <l>ObjectMap</l> and <l>ObjectList</l> are very similar to the <l>JSONObject</l> and <l>JSONArray</l>
+ The <l>ObjectMap</l> and <l>ObjectList</l> classes are very similar to the <l>JSONObject</l> and <l>JSONArray</l>
classes found in other libraries. However, the names were chosen
because the concepts of <l>Maps</l> and <l>Lists</l> are already familiar to
Java programmers, and these classes can be used with any of the serialzers or parsers.
@@ -673,6 +496,25 @@
<li>Using the provided {@link org.apache.juneau.ObjectMap#serializeTo(java.io.Writer)} or {@link org.apache.juneau.ObjectList#serializeTo(java.io.Writer)} methods.
<li>Passing them to one of the {@link org.apache.juneau.serializer.Serializer} serialize methods.
</ol>
+ <p>
+ Any valid JSON can be parsed into an unstructured model consisting of generic {@link org.apache.juneau.ObjectMap} and {@link org.apache.juneau.ObjectList} objects.
+ </p>
+ <p class='bcode'>
+ <jc>// Parse an arbitrary JSON document into an unstructered data model
+ // consisting of ObjectMaps, ObjectLists, and java primitive objects.</jc>
+ Parser parser = JsonParser.<jsf>DEFAULT</jsf>;
+ String json = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
+ ObjectMap m = parser.parse(json, ObjectMap.<jk>class</jk>);
+
+ <jc>// Use ObjectMap API to extract data from the unstructured model.</jc>
+ <jk>int</jk> johnSmithAge = m.getObjectMap(<js>"a"</js>).getInt(<js>"age"</js>);
+
+ <jc>// Convert it back into JSON.</jc>
+ json = JsonSerializer.<jsf>DEFAULT</jsf>.serialize(m);
+
+ <jc>// Or convert it to XML.</jc>
+ String xml = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(m);
+ </p>
<p class='info'>
As a general rule, if you do not specify a target type during parsing, or if the target type cannot be determined
through reflection, the parsers automatically generate <l>ObjectMaps</l> and <l>ObjectLists</l>.
@@ -689,8 +531,8 @@
<h3 class='topic' onclick='toggle(this)'>2.5 - Configurable Properties</h3>
<div class='topic'>
<p>
- Serializers and parsers have a wide variety of configurable properties that can be set on them.<br>
- For example, the following code shows how to set configurable properties on the JSON serializerclass:
+ Serializers and parsers have a wide variety of configurable properties.<br>
+ For example, the following code shows how to configure a JSON serializer:
</p>
<p class='bcode'>
JsonSerializer s = <jk>new</jk> JsonSerializer()
@@ -700,7 +542,7 @@
.setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>);
</p>
<p>
- Each of the serializers and parsers contain common reusable instances with common configuration properties.<br>
+ However, each of the serializers and parsers already contain reusable instances with common configurations.<br>
For example, JSON has the following predefined reusable serializers and parsers:
</p>
<ul class='javahierarchy'>
@@ -725,79 +567,75 @@
String json = JsonSerializer.<jsf>DEFAULT_LAX</jsf>.serialize(myPojo);
</p>
<p>
- Properties can be set using the following methods:
- </p>
- <ul class='javahierarchy'>
- <li class='m'>{@link org.apache.juneau.serializer.Serializer#setProperty(String,Object)} - On any serializers.
- <li class='m'>{@link org.apache.juneau.serializer.SerializerGroup#setProperty(String,Object)} - On groups of serializers.
- <li class='m'>{@link org.apache.juneau.parser.Parser#setProperty(String,Object)} - On any parsers.
- <li class='m'>{@link org.apache.juneau.parser.ParserGroup#setProperty(String,Object)} - On groups of parsers.
- </ul>
- <p>
- The REST server API also provides various ways of setting properties:
- </p>
- <ul class='javahierarchy'>
- <li class='n'>{@link org.apache.juneau.server.annotation.RestResource#properties() @RestResource.properties()} - Annotation on instances of {@link org.apache.juneau.server.RestServlet}.
- <li class='n'>{@link org.apache.juneau.server.annotation.RestMethod#properties() @RestMethod.properties()} - Annotation on java methods in instances of {@link org.apache.juneau.server.RestServlet}.
- <li class='m'>{@link org.apache.juneau.server.RestServlet#createSerializers(ObjectMap,Class[],Class[])} - Properties can be set programmatically on serializers by overriding this method.
- <li class='m'>{@link org.apache.juneau.server.RestServlet#createParsers(ObjectMap,Class[],Class[])} - Properties can be set programmatically on parsers by overriding this method.
- </ul>
- <p>
- Similarly, the REST client API provides ways of setting properties:
+ Serializers and parsers can be locked to prevent further modification to the properties.
+ They can also be cloned to copy the configuration of other serializers and parsers.
</p>
- <ul class='javahierarchy'>
- <li class='m'>{@link org.apache.juneau.client.RestClient#setProperty(String,Object)} - Set property on the serializer and parser associated with a REST client.
- </ul>
- <p>
- The {@link org.apache.juneau.serializer.Serializer#lock()} and {@link org.apache.juneau.parser.Parser#lock()}
- methods can be used to make serializer and parser properties read only.
- All the common reusable serializers and parsers are read only.
- If you attempt to modify any properties on those instances, a {@link org.apache.juneau.LockedException} is thrown.
+ <p class='bcode'>
+ <jc>// Clone and customize an existing serializer.</jc>
+ JsonSerializer s = JsonSerializer.<jsf>DEFAULT_LAX</jsf>
+ .clone()
+ .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'"'</js>);
+
+ <jc>// Lock it so that the configuration cannot be changed.</jc>
+ s.lock();
</p>
<h6 class='topic'>Additional Information</h6>
+ <p>
+ The following is a list of all configurable properties across all serializers and parsers.
+ </p>
<ul class='javahierarchy'>
- <li class='c'>{@link org.apache.juneau.BeanContext} - Properties associated with handling beans on serializers and parsers.
- <li class='c'>{@link org.apache.juneau.serializer.SerializerContext} - Configurable properties common to all serializers.
- <li class='c'>{@link org.apache.juneau.parser.ParserContext} - Configurable properties common to all parsers.
- <li class='c'>{@link org.apache.juneau.html.HtmlSerializerContext} - Configurable properties on the HTML serializer.
- <li class='c'>{@link org.apache.juneau.html.HtmlDocSerializerContext} - Configurable properties on the HTML document serializer.
- <li class='c'>{@link org.apache.juneau.html.HtmlParserContext} - Configurable properties on the HTML parser.
- <li class='c'>{@link org.apache.juneau.jena.RdfCommonContext} - Configurable properties common to the RDF serializers and parsers.
- <li class='c'>{@link org.apache.juneau.jena.RdfSerializerContext} - Configurable properties on the RDF serializer.
- <li class='c'>{@link org.apache.juneau.jena.RdfParserContext} - Configurable properties on the RDF parsers.
- <li class='c'>{@link org.apache.juneau.json.JsonSerializerContext} - Configurable properties on the JSON serializer.
- <li class='c'>{@link org.apache.juneau.json.JsonParserContext} - Configurable properties on the JSON parser.
- <li class='c'>{@link org.apache.juneau.soap.SoapXmlSerializerContext} - Configurable properties on the SOAP/XML serializer.
- <li class='c'>{@link org.apache.juneau.urlencoding.UonSerializerContext} - Configurable properties on the URL-Encoding and UON serializers.
- <li class='c'>{@link org.apache.juneau.urlencoding.UonParserContext} - Configurable properties on the URL-Encoding and UON parsers.
- <li class='c'>{@link org.apache.juneau.xml.XmlSerializerContext} - Configurable properties on the XML serializer.
- <li class='c'>{@link org.apache.juneau.xml.XmlParserContext} - Configurable properties on the XML parser.
- <li class='c'>{@link org.apache.juneau.server.RestServletContext} - Configurable properties on the REST servlet.
+ <li class='c'><a class='doclink' href='org/apache/juneau/BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers.
+ <ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers.
+ <ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/html/HtmlSerializerContext.html#ConfigProperties'>HtmlSerializerContext</a> - Configurable properties on the HTML serializer.
+ <ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/html/HtmlDocSerializerContext.html#ConfigProperties'>HtmlDocSerializerContext</a> - Configurable properties on the HTML document serializer.
+ </ul>
+ <li class='i'><a class='doclink' href='org/apache/juneau/jena/RdfCommonContext.html#ConfigProperties'>RdfCommonContext</a> - Configurable properties common to the RDF serializers and parsers.
+ <ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/jena/RdfSerializerContext.html#ConfigProperties'>RdfSerializerContext</a> - Configurable properties on the RDF serializers.
+ </ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/json/JsonSerializerContext.html#ConfigProperties'>JsonSerializerContext</a> - Configurable properties on the JSON serializer.
+ <li class='c'><a class='doclink' href='org/apache/juneau/msgpack/MsgPackSerializerContext.html#ConfigProperties'>MsgPackSerializerContext</a> - Configurable properties on the MessagePack serializer.
+ <li class='c'><a class='doclink' href='org/apache/juneau/soap/SoapXmlSerializerContext.html#ConfigProperties'>SoapXmlSerializerContext</a> - Configurable properties on the SOAP/XML serializer.
+ <li class='c'><a class='doclink' href='org/apache/juneau/urlencoding/UonSerializerContext.html#ConfigProperties'>UonSerializerContext</a> - Configurable properties on the URL-Encoding and UON serializers.
+ <li class='c'><a class='doclink' href='org/apache/juneau/xml/XmlSerializerContext.html#ConfigProperties'>XmlSerializerContext</a> - Configurable properties on the XML serializer.
+ </ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers.
+ <ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/html/HtmlParserContext.html#ConfigProperties'>HtmlParserContext</a> - Configurable properties on the HTML parser.
+ <li class='i'><a class='doclink' href='org/apache/juneau/jena/RdfCommonContext.html#ConfigProperties'>RdfCommonContext</a> - Configurable properties common to the RDF serializers and parsers.
+ <ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/jena/RdfParserContext.html#ConfigProperties'>RdfParserContext</a> - Configurable properties on the RDF parsers.
+ </ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/json/JsonParserContext.html#ConfigProperties'>JsonParserContext</a> - Configurable properties on the JSON parser.
+ <li class='c'><a class='doclink' href='org/apache/juneau/msgpack/MsgPackParserContext.html#ConfigProperties'>MsgPackParserContext</a> - Configurable properties on the MessagePack parser.
+ <li class='c'><a class='doclink' href='org/apache/juneau/urlencoding/UonParserContext.html#ConfigProperties'>UonParserContext</a> - Configurable properties on the URL-Encoding and UON parsers.
+ <li class='c'><a class='doclink' href='org/apache/juneau/xml/XmlParserContext.html#ConfigProperties'>XmlParserContext</a> - Configurable properties on the XML parser.
+ </ul>
+ </ul>
+ <li class='c'><a class='doclink' href='org/apache/juneau/server/RestServletContext.html#ConfigProperties'>RestServletContext</a> - Configurable properties on the REST servlet.
</ul>
</div>
<!-- ======================================================================================================== -->
- <a id="Core.Annotations"></a>
- <h3 class='topic' onclick='toggle(this)'>2.6 - Annotations</h3>
+ <a id="Core.Transforms"></a>
+ <h3 class='topic' onclick='toggle(this)'>2.6 - Transforms</h3>
<div class='topic'>
<p>
- The {@link org.apache.juneau.annotation} package contains several annotations that can be applied to classes to alter how they're
- handled by the serializers and parsers.
+ By default, the Juneau framework can serialize and parse a wide variety of POJOs out-of-the-box.
+ However, two special classes are provided tailor how certain Java objects are handled by the framework.
+ These classes are:
</p>
+ <ul class='javahierarchy'>
+ <li class='c'>{@link org.apache.juneau.transform.PojoSwap} - Tailor how specific non-bean classes are handled by the framework.
+ <li class='c'>{@link org.apache.juneau.transform.BeanFilter} - Tailor how specific bean classes are handled by the framework.
+ </ul>
<p>
- For example, the {@link org.apache.juneau.annotation.Bean @Bean} annotation can be used to limit which getters and setters get
- interpreted as bean properties:
+ Annotations are also provided that allow you to use transformations directly on class definitions:
</p>
- <p class='bcode'>
- <jc>// Address class with only street/city/state properties (in that order).</jc>
- <jc>// All other properties are ignored.</jc>
- <ja>@Bean</ja>(properties={<js>"street"</js>,<js>"city"</js>,<js>"state"</js>})
- <jk>public class</jk> Address {
- ...
- </p>
-
- <h6 class='topic'>Additional Information</h6>
<ul class='javahierarchy'>
<li class='n'>{@link org.apache.juneau.annotation.Pojo @Pojo} - Used to tailor how non-bean POJOs get interpreted by the framework.
<li class='n'>{@link org.apache.juneau.annotation.Bean @Bean} - Used to tailor how beans get interpreted by the framework.
@@ -808,94 +646,489 @@
<li class='n'>{@link org.apache.juneau.annotation.ParentProperty @ParentProperty} - Identifies a setter as a method for adding a parent reference to a child object.
<li class='n'>{@link org.apache.juneau.annotation.URI @URI} - Used to identify a class or bean property as a URI.
</ul>
- </div>
+
+ <!-- ======================================================================================================== -->
+ <a id="Core.PojoSwaps"></a>
+ <h4 class='topic' onclick='toggle(this)'>2.6.1 - PojoSwaps</h4>
+ <div class='topic'>
+ <p>
+ {@link org.apache.juneau.transform.PojoSwap PojoSwaps} are a critical component of Juneau.
+ They allow the serializers and parsers to handle Java objects that wouldn't normally be serializable.
+ </p>
+ <p>
+ Swaps are very easy to understand.
+ Simply put, they can be thought of as 'object swappers' that swap in serializable objects for non-serializable ones during serialization, and vis-versa during parsing.
+ </p>
+ <p>
+ Some examples of non-serializable POJOs are <code>File</code>, <code>Reader</code>, <code>Iterable</code>, etc...
+ These are classes that aren't beans and cannot be represented as simple maps, collections, or primitives.
+ </p>
+ <p>
+ In the following example, we introduce a <code>PojoSwap</code> that will swap in ISO8601 strings for <code>Date</code> objects:
+ </p>
+ <p class='bcode'>
+ <jc>// Sample swap for converting Dates to ISO8601 strings.</jc>
+ <jk>public class</jk> MyDateSwap <jk>extends</jk> PojoSwap<Date,String> {
+
+ <jc>// ISO8601 formatter.</jc>
+ <jk>private</jk> DateFormat <jf>format</jf> = <jk>new</jk> SimpleDateFormat(<js>"yyyy-MM-dd'T'HH:mm:ssZ"</js>);
+
+ <jd>/** Converts a Date object to an ISO8601 string. */</jd>
+ <ja>@Override</ja>
+ <jk>public</jk> String swap(Date o) {
+ <jk>return</jk> <jf>format</jf>.format(o);
+ }
+
+ <jd>/** Converts an ISO8601 string to a Date object. */</jd>
+ <ja>@Override</ja>
+ <jk>public</jk> Date unswap(String o) <jk>throws</jk> ParseException {
+ <jk>try</jk> {
+ <jk>return</jk> <jf>format</jf>.parse(o);
+ } <jk>catch</jk> (java.text.ParseException e) {
+ <jk>throw new</jk> ParseException(e);
+ }
+ }
+ }
+ </p>
+ <p>
+ The swap can then be associated with serializers and parsers like so:
+ </p>
+ <p class='bcode'>
+ <jc>// Sample bean with a Date field.</jc>
+ <jk>public class</jk> MyBean {
+ <jk>public</jk> Date <jf>date</jf> = <jk>new</jk> Date(112, 2, 3, 4, 5, 6);
+ }
+
+ <jc>// Create a new JSON serializer, associate our date swap with it, and serialize a sample bean.</jc>
+ Serializer serializer = <jk>new</jk> JsonSerializer().addPojoSwaps(MyDateSwap.<jk>class</jk>);
+ String json = serializer.serialize(<jk>new</jk> MyBean()); <jc>// == "{date:'2012-03-03T04:05:06-0500'}"</jc>
+
+ <jc>// Create a JSON parser, associate our date swap with it, and reconstruct our bean (including the date).</jc>
+ ReaderParser parser = <jk>new</jk> JsonParser().addPojoSwaps(MyDateSwap.<jk>class</jk>);
+ MyBean bean = parser.parse(json, MyBean.<jk>class</jk>);
+ <jk>int</jk> day = bean.<jf>date</jf>.getDay(); <jc>// == 3</jc>
+ </p>
+ <p>
+ Several <code>PojoSwaps</code> are already provided for common Java objects:
+ </p>
+ <ul class='javahierarchy'>
+ <li class='p'>{@link org.apache.juneau.transforms}
+ <ul>
+ <li class='c'>{@link org.apache.juneau.transforms.ByteArrayBase64Swap}
+ <li class='c'>{@link org.apache.juneau.transforms.CalendarLongSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.CalendarMapSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.CalendarSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.DateLongSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.DateMapSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.DateSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.EnumerationSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.IteratorSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.ReaderSwap}
+ <li class='c'>{@link org.apache.juneau.transforms.XMLGregorianCalendarSwap}
+ </ul>
+ </ul>
+ <p class='info'>
+ The 'swapped' class type must be a serializable type.<br>
+ See the definition for Category 4 objects in <a class='doclink' href='#Core.PojoCategories'>POJO Categories</a>.
+ </p>
+ </div>
+
+ <!-- ======================================================================================================== -->
+ <a id="Core.BeanFilters"></a>
+ <h4 class='topic' onclick='toggle(this)'>2.6.2 - BeanFilters and @Bean annotations</h4>
+ <div class='topic'>
+ <p>
+ {@link org.apache.juneau.transform.BeanFilter BeanFilters} are used to control aspects of how beans are handled during serialization and parsing.
+ They allow you to control various aspects of beans, such as...
+ </p>
+ <ul>
+ <li>Which properties to include or exclude.
+ <li>Property order.
+ <li>Property naming conventions.
+ <li>Overriding reading and writing of properties.
+ </ul>
+ <p>
+ In practice, however, it's simpler to use the {@link org.apache.juneau.annotation.Bean @Bean} and {@link org.apache.juneau.annotation.BeanProperty @BeanProperty}
+ annotations on your bean classes.
+ The annotations are functionally equivalent to the bean filter class.
+ </p>
+ <p class='bcode'>
+ <jc>// Address class with only street/city/state properties (in that order).</jc>
+ <jc>// All other properties are ignored.</jc>
+ <ja>@Bean</ja>(properties={<js>"street"</js>,<js>"city"</js>,<js>"state"</js>})
+ <jk>public class</jk> Address {
+ ...
+ </p>
+ <p>
+ Bean filters are defined through {@link org.apache.juneau.transform.BeanFilterBuilder BeanFilterBuilders}.
+ The programmatic equivalent to the the annotation above would be:
+ </p>
+ <p class='bcode'>
+ <jk>public class</jk> MyAddressBeanFilter <jk>extends</jk> BeanFilterBuilder {
+
+ <jc>// Must provide a no-arg constructor!</jc>
+ <jk>public</jk> MyAddressBeanFilter() {
+ <jk>super</jk>(Address.<jk>class</jk>); <jc>// The bean class that this filter applies to.</jc>
+ setIncludeProperties(<js>"street,city,state"</js>); <jc>// The properties we want exposed.</jc>
+ }
+ }
+ </p>
+ <p>
+ Bean filters are added to serializers and parsers using the <code>addBeanFilters(Class...)</code> method.
+ For example:
+ </p>
+ <p class='bcode'>
+ <jc>// Create a new JSON serializer and associate a bean filter with it.</jc>
+ Serializer serializer = <jk>new</jk> JsonSerializer().addBeanFilters(MyAddressBeanFilter.<jk>class</jk>);
+ </p>
+ <p>
+ Note that if you use the annotation, you do NOT need to set anything on the serializers/parsers.
+ The annotations will be detected and bean filters will automatically be created for them.
+ </p>
+ <p>
+ The <code>addBeanFilter(Class...)</code> method also allows you to pass in interfaces.
+ Any class that's not a subclass of {@link org.apache.juneau.transform.BeanFilterBuilder} get interpreted
+ as bean interface classes.
+ These cause bean implementations of those interfaces to only expose the properties defined on the interface.
+ </p>
+ <p class='bcode'>
+ <jc>// An interface with the 3 properties we want serialized.</jc>
+ <jk>public interface</jk> AddressInterface {
+ <jk>public</jk> String getStreet();
+ <jk>public</jk> String getCity();
+ <jk>public</jk> String getState();
+ }
+
+ <jc>// Our bean implementation.</jc>
+ <jk>public class</jk> Address <jk>implements</jk> AddressInterface {
+ ...
+ }
+
+ <jc>// Create a new JSON serializer that only exposes street,city,state on Address bean.</jc>
+ Serializer serializer = <jk>new</jk> JsonSerializer().addBeanFilters(AddressInterface.<jk>class</jk>);
+ </p>
+ <h6 class='topic'>Additional Information</h6>
+ <ul class='javahierarchy'>
+ <li class='p'>{@link org.apache.juneau.transform}
+ </ul>
+ </div>
+
+ </div>
+
<!-- ======================================================================================================== -->
- <a id="Core.Transforms"></a>
- <h4 class='topic' onclick='toggle(this)'>2.7 - Transforms</h4>
+ <a id="Core.BeanDictionaries"></a>
+ <h3 class='topic' onclick='toggle(this)'>2.7 - Bean Names and Dictionaries</h3>
<div class='topic'>
<p>
- The programmatic equivalent to the annotations are the {@link org.apache.juneau.transform.BeanFilter} and
- {@link org.apache.juneau.transform.PojoSwap} classes.
+ While parsing into beans, Juneau attempts to determine the class types of bean properties through reflection on the bean property getter or setter.
+ Often this is insufficient if the property type is an interface or abstract class that cannot be instantiated.
+ This is where bean names and dictionaries come into play.
</p>
<p>
- The following example is equivalent to specifying the <l>@Bean</l> annotation in the previous example using a bean filter:
+ Bean names and dictionary are used for identifying class types when they cannot be inferred through reflection.
</p>
- <p class='bcode'>
- <jc>// Define bean filter that returns properties in the following order: "street", "city", "state"</jc>
- <jk>public class</jk> AddressFilter <jk>extends</jk> BeanFilter<Address> {
- <jk>public</jk> AddressFilter() {
- setProperties(<js>"street"</js>,<js>"city"</js>,<js>"state"</js>);
- }
- }
-
- WriterSerializer s = <jk>new</jk> JsonSerializer().addBeanFilters(AddressFilter.<jk>class</jk>);
- Address a = getAddress();
- String json = s.serialize(a); <jc>// Prints "{street:'...',city:'...',state;'...'}"</jc>
+ <p>
+ Bean classes are given names through the {@link org.apache.juneau.annotation.Bean#typeName() @Bean.typeName()} annotation.
+ These names are then added to the serialized output as virtual <js>"_type"</js> properties (or element names in XML).
+ </p>
+ <p>
+ On the parsing side, these type names are resolved to classes through the use of bean dictionaries.
</p>
<p>
- The {@link org.apache.juneau.transform.PojoSwap} class is a critical component of Juneau that allows serializers and parsers to
- be able to handle virtually any Java object.
- Simply put, they can be thought of as 'transformers' that convert non-serializable objects to serializable objects and vice versa.
+ For example, if a bean property is of type <code>Object</code>, then the serializer will add <js>"_type"</js> attributes so that the class can be determined during parsing.
</p>
+ <p class='bcode'>
+ <ja>@Bean</ja>(typeName=<js>"foo"</js>)
+ <jk>public class</jk> Foo {
+ <jc>// A bean property where the object types cannot be inferred since it's an Object[].</jc>
+ <ja>@BeanProperty</ja>(typeDictionary={Bar.<jk>class</jk>,Baz.<jk>class</jk>})
+ <jk>public</jk> Object[] x = <jk>new</jk> Object[]{<jk>new</jk> Bar(), <jk>new</jk> Baz()};
+ }
+
+ <ja>@Bean</ja>(typeName=<js>"bar"</js>)
+ <jk>public class</jk> Bar {}
+
+ <ja>@Bean</ja>(typeName=<js>"baz"</js>)
+ <jk>public class</jk> Baz {}
+ </p>
+ <p>
+ When serialized as JSON, <js>"_type"</js> attributes would be added when needed to infer the type during parsing:
+ </p>
+ <p class='bcode'>
+ {
+ <jsa>x</jsa>: [
+ {<jsa>_type</jsa>:<jss>'bar'</jss>},
+ {<jsa>_type</jsa>:<jss>'baz'</jss>}
+ ]
+ }
+ </p>
+ <p>
+ Type names can be represented slightly differently in different languages.
+ For example, the dictionary name is used as element names when serialized to XML.
+ This allows the <code>typeName</code> annotation to be used as a shortcut for defining element names for beans.
+ </p>
<p>
- For example, <l>Date</l> objects are not normally serializable.
- (Technically, they look like beans with getters/setters and so get serialized as such, which typically is not the desired result.)
- The following POJO swap can be used to represent dates in ISO8601 format:
+ When serialized as XML, the bean is rendered as:
</p>
<p class='bcode'>
- <jc>// Sample swap for converting Dates to ISO8601 strings.</jc>
- <jk>public class</jk> MyDateSwap <jk>extends</jk> PojoSwap<Date,String> {
-
- <jc>// ISO8601 formatter.</jc>
- <jk>private</jk> DateFormat <jf>format</jf> = <jk>new</jk> SimpleDateFormat(<js>"yyyy-MM-dd'T'HH:mm:ssZ"</js>);
-
- <jd>/** Converts a Date object to an ISO8601 string. */</jd>
- <ja>@Override</ja>
- <jk>public</jk> String swap(Date o) {
- <jk>return</jk> <jf>format</jf>.format(o);
- }
-
- <jd>/** Converts an ISO8601 string to a Date object. */</jd>
- <ja>@Override</ja>
- <jk>public</jk> Date unswap(String o) <jk>throws</jk> ParseException {
- <jk>try</jk> {
- <jk>return</jk> <jf>format</jf>.parse(o);
- } <jk>catch</jk> (java.text.ParseException e) {
- <jk>throw new</jk> ParseException(e);
- }
- }
- }
+ <xt><foo></xt>
+ <xt><x></xt>
+ <xt><bar/></xt>
+ <xt><baz/></xt>
+ <xt></x></xt>
+ <xt></foo></xt>
</p>
<p>
- The swap above can then be associated with serializers and parsers as the following example shows:
+ Bean dictionaries are defined at two levels:
</p>
- <p class='bcode'>
- <jc>// Sample bean with a Date field.</jc>
- <jk>public class</jk> MyBean {
- <jk>public</jk> Date <jf>date</jf> = <jk>new</jk> Date(112, 2, 3, 4, 5, 6);
+ <ul>
+ <li>On individual bean properties through the {@link org.apache.juneau.annotation.BeanProperty#beanDictionary() @BeanProperty.beanDictionary()} annotation.
+ <li>Globally for a parser using the {@link org.apache.juneau.parser.Parser#addToDictionary(Class...)} method.
+ </ul>
+ <p class='info'>
+ Type names do not need to be universally unique.
+ However, they must be unique within a dictionary.
+ </p>
+ <p class='info'>
+ The following reserved words cannot be used as type names: <code>object, array, number, boolean, null</code>.
+ </p>
+ <p class='info'>
+ Serialized type names are DISABLED by default.
+ They must be enabled on the serializer using the {@link org.apache.juneau.serializer.SerializerContext#SERIALIZER_addBeanTypeProperties} configuration property.
+ </p>
+ <p class='info'>
+ The <js>"_type"</js> property name can be overridden using the {@link org.apache.juneau.BeanContext#BEAN_beanTypePropertyName} configuration property.
+ </p>
+
+ <!-- ======================================================================================================== -->
+ <a id="Core.BeanSubTypes"></a>
+ <h4 class='topic' onclick='toggle(this)'>2.7.1 - Bean Subtypes</h4>
+ <div class='topic'>
+ <p>
+ In addition to the bean type name support described above, simplified support is provided
+ for bean subtypes.
+ </p>
+ <p>
+ Bean subtypes are similar in concept to bean type names, except for the following differences:
+ </p>
+ <ul>
+ <li>You specify the list of possible subclasses through an annotation on a parent bean class.
+ <li>You do not need to register the subtype classes on the bean dictionary of the parser.
+ <li>The default helper attribute name is <js>"_subtype"</js>, not <js>"_type"</js>.
+ <li>Bean subtype virtual properties are ALWAYS serialized.
+ They are not controlled by the {@link org.apache.juneau.serializer.SerializerContext#SERIALIZER_addBeanTypeProperties} setting.
+ </ul>
+ <p>
+ In the following example, the abstract class has two subclasses:
+ </p>
+ <p class='bcode'>
+ <jc>// Abstract superclass</jc>
+ <ja>@Bean</ja>(
+ subTypes={A1.<jk>class</jk>, A2.<jk>class</jk>}
+ )
+ <jk>public abstract class</jk> A {
+ <jk>public</jk> String <jf>f0</jf> = <js>"f0"</js>;
}
-
- <jc>// Create a new JSON serializer, associate our date swap with it, and serialize a sample bean.</jc>
- Serializer serializer = <jk>new</jk> JsonSerializer().addPojoSwaps(MyDateSwap.<jk>class</jk>);
- String json = serializer.serialize(<jk>new</jk> MyBean()); <jc>// == "{date:'2012-03-03T04:05:06-0500'}"</jc>
-
- <jc>// Create a JSON parser, associate our date swap with it, and reconstruct our bean (including the date).</jc>
- ReaderParser parser = <jk>new</jk> JsonParser().addPojoSwaps(MyDateSwap.<jk>class</jk>);
- MyBean bean = parser.parse(json, MyBean.<jk>class</jk>);
- <jk>int</jk> day = bean.<jf>date</jf>.getDay(); <jc>// == 3</jc>
+
+ <jc>// Subclass 1</jc>
+ <ja>@Bean</ja>(typeName=<js>"A1"</js>)
+ <jk>public class</jk> A1 <jk>extends</jk> A {
+ <jk>public</jk> String <jf>f1</jf>;
+ }
+
+ <jc>// Subclass 2</jc>
+ <ja>@Bean</ja>(typeName=<js>"A2"</js>)
+ <jk>public class</jk> A2 <jk>extends</jk> A {
+ <jk>public</jk> String <jf>f2</jf>;
+ }
+ </p>
+ <p>
+ When serialized, the subtype is serialized as a virtual <js>"_subtype"</js> property:
+ </p>
+ <p class='bcode'>
+ JsonSerializer s = JsonSerializer.<jsf>DEFAULT_LAX</jsf>;
+ A1 a1 = <jk>new</jk> A1();
+ a1.<jf>f1</jf> = <js>"f1"</js>;
+ String r = s.serialize(a1);
+ <jsm>assertEquals</jsm>(<js>"{_subtype:'A1',f1:'f1',f0:'f0'}"</js>, r);
+ </p>
+ <p>
+ The following shows what happens when parsing back into the original object.
+ </p>
+ <p class='bcode'>
+ JsonParser p = JsonParser.<jsf>DEFAULT</jsf>;
+ A a = p.parse(r, A.<jk>class</jk>);
+ <jsm>assertTrue</jsm>(a <jk>instanceof</jk> A1);
+ </p>
+ <p class='info'>
+ The <js>"_subtype"</js> property name can be overridden using the {@link org.apache.juneau.annotation.Bean#subTypeProperty() @Bean.subTypeProperty()} annotation.
+ </p>
+ </div>
+ </div>
+
+ <!-- ======================================================================================================== -->
+ <a id="Core.PojoCategories"></a>
+ <h3 class='topic' onclick='toggle(this)'>2.8 - POJO Categories</h3>
+ <div class='topic'>
+ <p>
+ The following chart shows POJOs categorized into groups and whether they can be serialized or parsed:
+ </p>
+ <table class='styled' style='border-collapse: collapse;'>
+ <tr><th>Group</th><th>Description</th><th>Examples</th><th>Can<br>serialize?</th><th>Can<br>parse?</th></tr>
+ <tr class='dark bb' style='background-color:lightyellow;'>
+ <td style='text-align:center'>1</td>
+ <td><b>Java primitive objects</b></td>
+ <td>
+ <ul class='normal'>
+ <li>{@code String}
+ <li>{@code Integer}
+ <li>{@code Float}
+ <li>{@code Boolean}
+ </ul>
+ </td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ </tr>
+ <tr class='dark bb' style='background-color:lightyellow'>
+ <td style='text-align:center'>2</td>
+ <td><b>Java Collections Framework objects and Java arrays</b></td>
+ <td> </td>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr class='light bb'>
+ <td style='text-align:center'>2a</td>
+ <td>
+ <b>With standard keys/values</b><br>
+ Map keys are group [1, 4a, 5] objects.<br>
+ Map, Collection, and array values are group [1, 2, 3a, 4a, 5] objects.
+ </td>
+ <td>
+ <ul class='normal'>
+ <li>{@code HashSet<String,Integer>}
+ <li>{@code TreeMap<Integer,Bean>}
+ <li><code>List<<jk>int</jk>[][]></code>
+ <li>{@code Bean[]}
+ </ul>
+ </td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ </tr>
+ <tr class='light bb'>
+ <td style='text-align:center'>2b</td>
+ <td>
+ <b>With non-standard keys/values</b><br>
+ Map keys are group [2, 3, 4b, 5, 6] objects.<br>
+ Map, Collection, and array values are group [3b, 4, 5, 6] objects.
+ </td>
+ <td>
+ <ul class='normal'>
+ <li>{@code HashSet<Bean,Integer>}
+ <li>{@code TreeMap<Integer,Reader>}
+ </ul>
+ </td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:salmon;text-align:center'><b>no</b></td>
+ </tr>
+ <tr class='dark bb' style='background-color:lightyellow'>
+ <td style='text-align:center'>3</td>
+ <td><b>Java Beans</b></td>
+ <td> </td>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr class='light bb'>
+ <td style='text-align:center'>3a</td>
+ <td>
+ <b>With standard properties</b><br>
+ These are beans that have no-arg constructors and one or more properties defined by public getter and setter methods or public fields.<br>
+ Property values are group [1, 2, 3a, 4a, 5] objects.
+ </td>
+ <td> </td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ </tr>
+ <tr class='light bb'>
+ <td style='text-align:center'>3b</td>
+ <td>
+ <b>With non-standard properties or not true beans</b><br>
+ These include true beans that have no-arg constructors and one or more properties defined by getter and setter methods or properties,
+ but property types include group [3b, 4b, 5, 6] objects.<br>
+ This also includes classes that look like beans but aren't true beans.
+ For example, classes that have getters but not setters, or classes without no-arg constructors.
+ </td>
+ <td> </td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:salmon;text-align:center'><b>no</b></td>
+ </tr>
+ <tr class='dark bb' style='background-color:lightyellow'>
+ <td style='text-align:center'>4</td>
+ <td>
+ <b>Swapped objects</b><br>
+ These are objects that are not directly serializable, but have {@link org.apache.juneau.transform.PojoSwap PojoSwaps} associated with them.
+ The purpose of a POJO swap is to convert an object to another object that is easier to serialize and parse.
+ For example, the {@link org.apache.juneau.transforms.DateSwap.ISO8601DT} class can be used to serialize {@link java.util.Date} objects
+ to ISO8601 strings, and parse them back into {@link java.util.Date} objects.
+ </td>
+ <td> </td>
+ <td> </td>
+ <td> </td>
+ </tr>
+ <tr class='light bb'>
+ <td style='text-align:center'>4a</td>
+ <td>
+ <b>2-way swapped to group [1, 2a, 3a] objects</b><br>
+ For example, a swap that converts a {@code Date} to a {@code String}.
+ </td>
+ <td> </td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ </tr>
+ <tr class='light bb'>
+ <td style='text-align:center'>4b</td>
+ <td>
+ <b>1-way swapped to group [1, 2, 3] objects</b><br>
+ For example, a swap that converts an {@code Iterator} to a {@code List}.
+ This would be one way, since you cannot reconstruct an {@code Iterator}.
+ </td>
+ <td> </td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:salmon;text-align:center'><b>no</b></td>
+ </tr>
+ <tr class='dark bb' style='background-color:lightyellow'>
+ <td style='text-align:center'>5</td>
+ <td>
+ <b>Objects with standardized <code>static T valueOf(String)</code>/<code>static T fromString(String)</code> methods, or constructors with a <code>String</code> argument.</b><br>
+ During serialization, objects are converted to strings using the <code>toString()</code> method.
+ During parsing, strings are converted to objects using one of these static methods or constructors.
+ </td>
+ <td><code>java.util.UUID</code></td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ </tr>
+ <tr class='dark' style='background-color:lightyellow'>
+ <td style='text-align:center'>6</td>
+ <td>
+ <b>All other objects</b><br>
+ Anything that doesn't fall into one of the groups above are simply converted to {@code Strings} using the {@code toString()} method.
+ </td>
+ <td> </td>
+ <td style='background-color:lightgreen;text-align:center'><b>yes</b></td>
+ <td style='background-color:salmon;text-align:center'><b>no</b></td>
+ </tr>
+ </table>
+ <p class='info'>
+ Serializers are designed to work on tree-shaped POJO models.
+ These are models where there are no referential loops (e.g. leaves with references to nodes, or nodes in one branch referencing nodes in another branch).
+ There is a serializer setting {@code detectRecursions} to look for and handle these kinds of loops (by setting these references to <jk>null</jk>),
+ but it is not enabled by default since it introduces a moderate performance penalty.
</p>
-
- <h6 class='topic'>Additional Information</h6>
- <ul class='javahierarchy'>
- <li class='p'><a class='doclink' href='org/apache/juneau/transform/package-summary.html#TOC'>org.apache.juneau.transform</a> - Transform API Javadocs.
- <li class='p'><a class='doclink' href='org/apache/juneau/transforms/package-summary.html#TOC'>org.apache.juneau.transforms</a> - Predefined reusable transform classes.
- </ul>
</div>
-
+
<!-- ======================================================================================================== -->
<a id="Core.SVL"></a>
- <h4 class='topic' onclick='toggle(this)'>2.8 - Simple Variable Language</h4>
+ <h4 class='topic' onclick='toggle(this)'>2.9 - Simple Variable Language</h4>
<div class='topic'>
<p>
The {@link org.apache.juneau.svl} package defines an API for a language called "Simple Variable Language".
@@ -919,7 +1152,10 @@
// 3) 'not found' string if system property not found.</jc>
String myproperty = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"$E{MYPROPERTY,$S{my.property,not found}}"</js>);
</p>
-
+ <p>
+ SVL is a large topic on it's own.
+ It is used extensively in the ConfigFile, REST and Microservice APIs.
+ </p>
<h6 class='topic'>Additional Information</h6>
<ul class='javahierarchy'>
<li class='p'><a class='doclink' href='org/apache/juneau/svl/package-summary.html#TOC'>org.apache.juneau.svl</a> - Simple Variable Language Javadocs.
@@ -928,7 +1164,7 @@
<!-- ======================================================================================================== -->
<a id="Core.ConfigFile"></a>
- <h3 class='topic' onclick='toggle(this)'>2.9 - Configuration Files</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.10 - Configuration Files</h3>
<div class='topic'>
<p>
The {@link org.apache.juneau.ini} package contains a powerful API for creating and using INI-style config files.
@@ -951,7 +1187,7 @@
<ck>key4</ck> = <cv>http://bar</cv>
</p>
<p>
- This class can be used to easily access contents of this file, using the various capabilities of the {@link org.apache.juneau.ObjectMap} class, as follows:
+ This class can be used to easily access contents of the file:
</p>
<p class='bcode'>
<jk>int</jk> key1;
@@ -1097,7 +1333,7 @@
<!-- ======================================================================================================== -->
<a id="Core.SupportedLanguages"></a>
- <h3 class='topic' onclick='toggle(this)'>2.10 - Supported Languages</h3>
+ <h3 class='topic' onclick='toggle(this)'>2.11 - Supported Languages</h3>
<div class='topic'>
<p>
Extensive javadocs exist for individual language support.
@@ -1109,6 +1345,7 @@
<li class='p'><a class='doclink' href='org/apache/juneau/jena/package-summary.html#TOC'>org.apache.juneau.jena</a> - RDF support.
<li class='p'><a class='doclink' href='org/apache/juneau/jso/package-summary.html#TOC'>org.apache.juneau.jso</a> - Java Serialized Object support.
<li class='p'><a class='doclink' href='org/apache/juneau/json/package-summary.html#TOC'>org.apache.juneau.json</a> - JSON support.
+ <li class='p'><a class='doclink' href='org/apache/juneau/msgpack/package-summary.html#TOC'>org.apache.juneau.msgpack</a> - MessagePack support.
<li class='p'><a class='doclink' href='org/apache/juneau/plaintext/package-summary.html#TOC'>org.apache.juneau.plaintext</a> - Plain-text support.
<li class='p'><a class='doclink' href='org/apache/juneau/soap/package-summary.html#TOC'>org.apache.juneau.soap</a> - SOAP support.
<li class='p'><a class='doclink' href='org/apache/juneau/urlencoding/package-summary.html#TOC'>org.apache.juneau.urlencoding</a> - URL-Encoding and UON support.
@@ -1121,7 +1358,7 @@
<!-- ======================================================================================================== -->
<a id="Server"></a>
-<h2 class='topic' onclick='toggle(this)'>3 - Juneau Server (juneau-server.jar)</h2>
+<h2 class='topic' onclick='toggle(this)'>3 - Juneau Server (org.apache.juneau.server)</h2>
<div class='topic'>
<p>
The Juneau REST Server API provides a variety of servlet-based REST resource classes that provides REST interfaces on top of existing POJOs,
@@ -1225,26 +1462,28 @@
<jk>import</jk> org.apache.juneau.xml.annotation.*;
<jd>/** Address book bean */</jd>
- <ja>@Xml</ja>(name=<js>"addressBook"</js>)
- <jk>public class</jk> AddressBook <jk>extends</jk> !LinkedList<Person> {}
+ <ja>@Bean</ja>(typeName=<js>"addressBook"</js>)
+ <jk>public class</jk> AddressBook <jk>extends</jk> LinkedList<Person> {}
<jd>/** Person bean */</jd>
- <ja>@Xml</ja>(prefix=<js>"per"</js>,name=<js>"person"</js>)
+ <ja>@Xml</ja>(prefix=<js>"per"</js>)
+ <ja>@Bean</ja>(typeName=<js>"person"</js>)
<jk>public class</jk> Person {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
+ <ja>@Rdf</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>addressBookUri</jf>;
<jk>public int</jk> <jf>id</jf>;
<jk>public</jk> String <jf>name</jf>;
- <ja>@BeanProperty</ja>(pojoSwaps=CalendarSwap.Medium.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
+ <ja>@BeanProperty</ja>(swap=CalendarSwap.Medium.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
<jk>public</jk> LinkedList<Address> <jf>addresses</jf>;
}
<jd>/** Address bean */</jd>
- <ja>@Xml</ja>(prefix=<js>"addr"</js>,name=<js>"address"</js>)
+ <ja>@Xml</ja>(prefix=<js>"addr"</js>)
+ <ja>@Bean</ja>(typeName=<js>"address"</js>)
<jk>public class</jk> Address {
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
+ <ja>@Rdf</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>personUri</jf>;
<jk>public int</jk> <jf>id</jf>;
<ja>@Xml</ja>(prefix=<js>"mail"</js>) <jk>public</jk> String <jf>street</jf>, <jf>city</jf>, <jf>state</jf>;
@@ -1288,7 +1527,7 @@
<!-- ======================================================================================================== -->
<a id="Client"></a>
-<h2 class='topic' onclick='toggle(this)'>4 - Juneau Client (juneau-client.jar)</h2>
+<h2 class='topic' onclick='toggle(this)'>4 - Juneau Client (org.apache.juneau.client)</h2>
<div class='topic'>
<p>
The REST client API provides the ability to access remote REST interfaces and transparently convert the input and output to and from POJOs using any
@@ -1331,7 +1570,7 @@
<!-- ======================================================================================================== -->
<a id="Remoteable"></a>
-<h2 class='topic' onclick='toggle(this)'>5 - Remoteable Services</h2>
+<h2 class='topic' onclick='toggle(this)'>5 - Remoteable Services (org.apache.juneau.server.remoteable)</h2>
<div class='topic'>
<p>
Juneau provides the capability of calling methods on POJOs on a server through client-side proxy interfaces.
@@ -1396,7 +1635,7 @@
<!-- ======================================================================================================== -->
<a id="Microservices"></a>
-<h2 class='topic' onclick='toggle(this)'>6 - Microservices</h2>
+<h2 class='topic' onclick='toggle(this)'>6 - Juneau Microservices (org.apache.juneau.microservice)</h2>
<div class='topic'>
<p>
<b>WARNING - The microservice API is still in beta. It may be replaced with an OSGi-based architecture.</b>
@@ -2505,18 +2744,19 @@
<h6 class='figure'>Person.java</h6>
<p class='bcode'>
<jd>/** Person bean */</jd>
- <ja>@Xml</ja>(ns=<js>"per"</js>,elementName=<js>"person"</js>)
+ <ja>@Xml</ja>(ns=<js>"per"</js>)
<ja>@Rdf</ja>(prefix=<js>"per"</js>)
+ <ja>@Bean</ja>(typeName=<js>"person"</js>)
<jk>public class</jk> Person {
<jk>private static int</jk> <jsf>nextPersonId</jsf> = 1;
<jc>// Bean properties.</jc>
- <ja>@BeanProperty</ja>(uri=<jk>true</jk>) public URI <jf>uri</jf>;
+ <ja>@Rdf</ja>(beanUri=<jk>true</jk>) public URI <jf>uri</jf>;
<jk>public</jk> URI <jf>addressBookUri</jf>;
<jk>public</jk> String <jf>id</jf>;
<jk>public</jk> String <jf>name</jf>;
- <ja>@BeanProperty</ja>(pojoSwap=CalendarSwap.Medium.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
+ <ja>@BeanProperty</ja>(swap=CalendarSwap.Medium.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
<jk>public</jk> LinkedList<Address> <jf>addresses</jf> = new LinkedList<Address>();
<jd>/** Bean constructor - Needed for instantiating on server side */</jd>
@@ -2556,11 +2796,10 @@
<ul class='spaced-list'>
<li>The <l>ns="per"</l> annotations override the default <l>"ab"</l> namespace defined on the package.
It applies to this class and all properties of this class.
- <li>The <code><ja>@BeanProperty</ja>(uri=<jk>true</jk>)</code> annotation identifies the <l>uri</l> property as the resource URI for this
- resource.
- This property has special meaning for the XML and RDF serializizers. The XML serializer serializes this as a <l>uri</l> attribute instead of an <l><uri></l> element, and
- the RDF serializer uses this property for the value of the <l>rdf:resource</l> attribute.
- <li>The <code><ja>@BeanProperty</ja>(pojoSwap=CalendarSwap.Medium.<jk>class</jk>)</code> annotation causes the date field to
+ <li>The <code><ja>@Rdf</ja>(beanUri=<jk>true</jk>)</code> annotation identifies the <l>uri</l> property as the resource URI for this resource.
+ This property has special meaning for the RDF serializer.
+ The RDF serializer uses this property for the value of the <l>rdf:resource</l> attribute.
+ <li>The <code><ja>@BeanProperty</ja>(swap=CalendarSwap.Medium.<jk>class</jk>)</code> annotation causes the date field to
be serialized in the format <l>"MM dd, yyyy"</l>.
This could have also been specified globally on the resource level through the {@link org.apache.juneau.server.annotation.RestResource#properties} annotation.
</ul>
@@ -2572,14 +2811,15 @@
<jd>/**
* Address bean
*/</jd>
- <ja>@Xml</ja>(prefix=<js>"addr"</js>,name=<js>"address"</js>)
+ <ja>@Xml</ja>(prefix=<js>"addr"</js>)
<ja>@Rdf</ja>(prefix=<js>"addr"</js>)
+ <ja>@Bean</ja>(typeName=<js>"address"</js>)
<jk>public class</jk> Address {
<jk>private static int</jk> <jsf>nextAddressId</jsf> = 1;
<jc>// Bean properties</jc>
- <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
+ <ja>@Rdf</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>;
<jk>public</jk> URI <jf>personUri</jf>;
<jk>public int</jk> <jf>id</jf>;
<ja>@Xml</ja>(prefix=<js>"mail"</js>) <ja>@Rdf</ja>(prefix=<js>"mail"</js>) <jk>public</jk> String <jf>street</jf>, <jf>city</jf>, <jf>state</jf>;
@@ -2613,13 +2853,14 @@
<h6 class='figure'>CreatePerson.java</h6>
<p class='bcode'>
<jd>/** Bean for creating a new person */</jd>
- <ja>@Xml</ja>(ns=<js>"per"</js>,elementName=<js>"person"</js>)
+ <ja>@Xml</ja>(ns=<js>"per"</js>)
<ja>@Rdf</ja>(ns=<js>"addr"</js>)
+ <ja>@Bean</ja>(typeName=<js>"person"</js>)
<jk>public class</jk> CreatePerson {
<jc>// Bean properties</jc>
<jk>public</jk> String <jf>name</jf>;
- <ja>@BeanProperty(</ja>pojoSwap=CalendarSwap.Medium.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
+ <ja>@BeanProperty(</ja>swap=CalendarSwap.Medium.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>;
<jk>public</jk> LinkedList<CreateAddress> <jf>addresses</jf>;
<jd>/** Bean constructor - Needed for instantiating on server side */</jd>
@@ -2635,8 +2876,9 @@
<h6 class='figure'>CreateAddress.java</h6>
<p class='bcode'>
<jd>/** Bean for creating a new address */</jd>
- <ja>@Xml</ja>(ns=<js>"addr"</js>,elementName=<js>"address"</js>)
+ <ja>@Xml</ja>(ns=<js>"addr"</js>)
<ja>@Rdf</ja>(ns=<js>"addr"</js>)
+ <ja>@Bean</ja>(typeName=<js>"address"</js>)
<jk>public class</jk> CreateAddress {
<jc>// Bean properties</jc>
@@ -4721,6 +4963,26 @@
<li>Support for stream-based variables - {@link org.apache.juneau.svl.StreamedVar}.
<li>Added support for context and session objects.
</ul>
+ <li>Eliminated <js>"_class"</js> properties and replaced them with <js>"_type"</js> properties.
+ The class properties were a little-used feature where we would serialize fully-qualified class names when the class type could not be inferred through reflection.
+ It's been replaced with bean type names and bean dictionaries.
+ Instead of class names, we serialize <js>"_type"</js> properties whose name is the type name defined on the bean being serialized.
+ The parsers use a 'dictionary' of bean classes to resolve those names to actual bean classes.
+ The following features were added to enable this support:
+ <ul>
+ <li>{@link org.apache.juneau.annotation.Bean#typeName() @Bean.typeName()} - Annotation that defines an identifying name for a bean class.
+ <li>{@link org.apache.juneau.transform.BeanFilterBuilder#setTypeName(String)} - Programmatic equivalent to annotation above.
+ <li>{@link org.apache.juneau.BeanContext#BEAN_beanDictionary} - List of bean classes that make up the bean dictionary for lookup
+ during parsing.
+ <li>{@link org.apache.juneau.BeanContext#BEAN_beanTypePropertyName} - The overridable type property name. Default is <js>"_type"</js>.
+ <li>{@link org.apache.juneau.annotation.BeanProperty#beanDictionary() @BeanProperty.beanDictionary()} - Define a type dictionary
+ for a particular bean property value. This overrides the value specified using {@link org.apache.juneau.BeanContext#BEAN_beanDictionary}.
+ <li>{@link org.apache.juneau.serializer.SerializerContext#SERIALIZER_addBeanTypeProperties} - Controls whether type properties are serialized.
+ </ul>
+ In addition, the {@link org.apache.juneau.annotation.Bean#typeName() @Bean.typeName()} value replaces the <code>@Xml.name()</code> annotation, and the
+ <js>"type"</js> and <js>"_class"</js> attributes in the XML and HTML serializers have been standardized on a single <js>"_type"</js> attribute.
+ <li>Refactor bean filter support to use {@link org.apache.juneau.transform.BeanFilterBuilder} class.
+ Allows the <code>BeanFilter</code> class to use final fields.
<li>{@link org.apache.juneau.msgpack MessagePack} support.
<li>Serializers can now serialize directly to {@link java.io.File Files}.
See {@link org.apache.juneau.serializer.Serializer#serialize(Object,Object)}
@@ -4743,12 +5005,6 @@
</ul>
</li>
<li>New {@link org.apache.juneau.annotation.Bean#sort() @Bean.sort()} annotation.
- <li>New methods on {@link org.apache.juneau.transform.BeanFilter}:
- <ul>
- <li>{@link org.apache.juneau.transform.BeanFilter#isSortProperties()}
- <li>{@link org.apache.juneau.transform.BeanFilter#setSortProperties(boolean)}
- </ul>
- </li>
<li>Added <ja>@Bean.properties</ja> annotations on various DTO beans to make the ordering consistent
between IBM and Oracle JVMs.<br>
IBM JVMs maintain the order of methods in a class, whereas Oracle JVMs do not.
@@ -6340,7 +6596,7 @@
New {@link org.apache.juneau.annotation.Bean#stopClass @Bean.stopClass} annotation for specifying stop classes for bean properties.
</li>
<li>
- New {@link org.apache.juneau.transform.BeanFilter#setStopClass(Class)} which is the program equivalent to the annotation above.
+ New <del><code>BeanFilter.setStopClass(Class)</code></del> which is the program equivalent to the annotation above.
</li>
<li>
New methods on {@link org.apache.juneau.dto.ResultSetList}:
@@ -7321,7 +7577,7 @@
Used for customizing bean property names.
</li>
<li>
- New {@link org.apache.juneau.annotation.BeanProperty#beanUri() @BeanProperty.beanUri} and <code>@BeanProperty.id</code> annotations.<br>
+ New <del><code>@BeanProperty.beanUri</code></del> and <del><code>@BeanProperty.id</code></del> annotations.<br>
Used for associating beans with URLs and IDs.<br>
Used by XML serializer to add a url attribute on a bean element.<br>
Used by RDF/XML serializer to construct <code>rdf:resource</code> attributes.
@@ -7659,5 +7915,4 @@
</div>
</div>
-
-</body>
\ No newline at end of file
+</body>