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/08/27 19:49:02 UTC
[14/14] incubator-juneau git commit: Clean up test and test resource
class names.
Clean up test and test resource class names.
Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/bea31abd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/bea31abd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/bea31abd
Branch: refs/heads/master
Commit: bea31abd8960a3f3d6574084228279921be1688b
Parents: 7b87347
Author: jamesbognar <ja...@gmail.com>
Authored: Sat Aug 27 15:48:43 2016 -0400
Committer: jamesbognar <ja...@gmail.com>
Committed: Sat Aug 27 15:48:43 2016 -0400
----------------------------------------------------------------------
.../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 +
.../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 ++++
.../juneau/server/LargePojosResource.java | 40 +
.../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 | 76 +-
.../juneau/server/SerializersResource.java | 102 ++
.../juneau/server/StaticFilesResource.java | 35 +
.../apache/juneau/server/TestAcceptCharset.java | 75 -
.../server/TestBeanContextProperties.java | 41 -
.../juneau/server/TestCallbackStrings.java | 52 -
.../juneau/server/TestCharsetEncodings.java | 54 -
.../apache/juneau/server/TestClientVersion.java | 93 --
.../org/apache/juneau/server/TestConfig.java | 37 -
.../org/apache/juneau/server/TestContent.java | 80 -
.../juneau/server/TestDefaultContentTypes.java | 127 --
.../juneau/server/TestErrorConditions.java | 134 --
.../org/apache/juneau/server/TestGroups.java | 71 -
.../java/org/apache/juneau/server/TestGzip.java | 110 --
.../apache/juneau/server/TestInheritance.java | 316 ----
.../apache/juneau/server/TestLargePojos.java | 40 -
.../org/apache/juneau/server/TestMessages.java | 61 -
.../java/org/apache/juneau/server/TestNls.java | 194 ---
.../apache/juneau/server/TestNlsProperty.java | 60 -
.../apache/juneau/server/TestNoParserInput.java | 55 -
.../apache/juneau/server/TestOnPostCall.java | 93 --
.../org/apache/juneau/server/TestOnPreCall.java | 84 --
.../juneau/server/TestOptionsWithoutNls.java | 43 -
.../juneau/server/TestOverlappingMethods.java | 145 --
.../org/apache/juneau/server/TestParams.java | 292 ----
.../org/apache/juneau/server/TestParsers.java | 111 --
.../java/org/apache/juneau/server/TestPath.java | 68 -
.../org/apache/juneau/server/TestPaths.java | 72 -
.../apache/juneau/server/TestProperties.java | 89 --
.../apache/juneau/server/TestRestClient2.java | 35 -
.../apache/juneau/server/TestSerializers.java | 102 --
.../apache/juneau/server/TestStaticFiles.java | 35 -
.../apache/juneau/server/TestTransforms.java | 114 --
.../juneau/server/TestTransformsParent.java | 25 -
.../java/org/apache/juneau/server/TestUris.java | 120 --
.../apache/juneau/server/TestUrlContent.java | 58 -
.../juneau/server/TransformsParentResource.java | 25 +
.../juneau/server/TransformsResource.java | 114 ++
.../org/apache/juneau/server/UrisResource.java | 120 ++
.../juneau/server/UrlContentResource.java | 58 +
.../juneau/server/Messages2Resource.properties | 16 +
.../juneau/server/MessagesResource.properties | 16 +
.../server/NlsPropertyResource.properties | 16 +
.../apache/juneau/server/NlsResource.properties | 79 +
.../juneau/server/TestMessages.properties | 16 -
.../juneau/server/TestMessages2.properties | 16 -
.../org/apache/juneau/server/TestNls.properties | 79 -
.../juneau/server/TestNlsProperty.properties | 16 -
.../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/ContentTest.java | 706 +++++++++
.../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/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 +++
.../apache/juneau/server/SerializersTest.java | 152 ++
.../apache/juneau/server/StaticFilesTest.java | 56 +
.../juneau/server/TestAcceptCharsetTest.java | 123 --
.../server/TestBeanContextPropertiesTest.java | 37 -
.../juneau/server/TestCallbackStringsTest.java | 50 -
.../juneau/server/TestCharsetEncodingsTest.java | 96 --
.../juneau/server/TestClientVersionTest.java | 90 --
.../apache/juneau/server/TestConfigTest.java | 58 -
.../apache/juneau/server/TestContentTest.java | 706 ---------
.../server/TestDefaultContentTypesTest.java | 497 -------
.../juneau/server/TestErrorConditionsTest.java | 220 ---
.../apache/juneau/server/TestGroupsTest.java | 122 --
.../org/apache/juneau/server/TestGzipTest.java | 344 -----
.../juneau/server/TestInheritanceTest.java | 126 --
.../juneau/server/TestLargePojosTest.java | 83 --
.../apache/juneau/server/TestMessagesTest.java | 47 -
.../juneau/server/TestNlsPropertyTest.java | 48 -
.../org/apache/juneau/server/TestNlsTest.java | 170 ---
.../juneau/server/TestNoParserInputTest.java | 70 -
.../juneau/server/TestOnPostCallTest.java | 121 --
.../apache/juneau/server/TestOnPreCallTest.java | 61 -
.../server/TestOptionsWithoutNlsTest.java | 51 -
.../server/TestOverlappingMethodsTest.java | 170 ---
.../apache/juneau/server/TestParamsTest.java | 716 ---------
.../apache/juneau/server/TestParsersTest.java | 162 ---
.../org/apache/juneau/server/TestPathTest.java | 44 -
.../org/apache/juneau/server/TestPathsTest.java | 1368 ------------------
.../juneau/server/TestPropertiesTest.java | 48 -
.../juneau/server/TestRestClientTest.java | 199 ---
.../juneau/server/TestSerializersTest.java | 152 --
.../juneau/server/TestStaticFilesTest.java | 56 -
.../juneau/server/TestTransformsTest.java | 68 -
.../org/apache/juneau/server/TestUrisTest.java | 918 ------------
.../juneau/server/TestUrlContentTest.java | 74 -
.../apache/juneau/server/TransformsTest.java | 68 +
.../java/org/apache/juneau/server/UrisTest.java | 918 ++++++++++++
.../apache/juneau/server/UrlContentTest.java | 74 +
139 files changed, 10346 insertions(+), 10346 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/bea31abd/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
new file mode 100755
index 0000000..3533353
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/AcceptCharsetResource.java
@@ -0,0 +1,75 @@
+/***************************************************************************************************************************
+ * 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/bea31abd/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
new file mode 100755
index 0000000..519715a
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/BeanContextPropertiesResource.java
@@ -0,0 +1,41 @@
+/***************************************************************************************************************************
+ * 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",
+ transforms=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/bea31abd/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
new file mode 100755
index 0000000..04eaf2d
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/CallbackStringsResource.java
@@ -0,0 +1,52 @@
+/***************************************************************************************************************************
+ * 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/bea31abd/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
new file mode 100755
index 0000000..0f6e55e
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/CharsetEncodingsResource.java
@@ -0,0 +1,54 @@
+/***************************************************************************************************************************
+ * 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/bea31abd/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
new file mode 100644
index 0000000..93c2528
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/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;
+
+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/bea31abd/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
new file mode 100755
index 0000000..df8b31f
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/ConfigResource.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;
+
+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/bea31abd/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
new file mode 100755
index 0000000..efe4326
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/ContentResource.java
@@ -0,0 +1,80 @@
+/***************************************************************************************************************************
+ * 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/bea31abd/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
new file mode 100755
index 0000000..0cf5649
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/DefaultContentTypesResource.java
@@ -0,0 +1,127 @@
+/***************************************************************************************************************************
+ * 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/bea31abd/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
new file mode 100755
index 0000000..80649f2
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/ErrorConditionsResource.java
@@ -0,0 +1,134 @@
+/***************************************************************************************************************************
+ * 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/bea31abd/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
new file mode 100755
index 0000000..be2df77
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/GroupsResource.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;
+
+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<?>[] filters) throws Exception {
+ return new SerializerGroup().append(SSerializer.class).setProperties(properties).addTransforms(filters);
+ }
+
+ @Override /* RestServlet */
+ public ParserGroup createParsers(ObjectMap properties, Class<?>[] filters) throws Exception {
+ return new ParserGroup().append(PParser.class).setProperties(properties).addTransforms(filters);
+ }
+
+ //====================================================================================================
+ // 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/bea31abd/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
new file mode 100755
index 0000000..d095c8d
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/GzipResource.java
@@ -0,0 +1,110 @@
+/***************************************************************************************************************************
+ * 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/bea31abd/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
new file mode 100755
index 0000000..4c25acc
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/InheritanceResource.java
@@ -0,0 +1,316 @@
+/***************************************************************************************************************************
+ * 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},
+ transforms={InheritanceResource.F1.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},
+ transforms={F2.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 ['F1','F2','Foo3']
+ @RestMethod(name="GET", path="/test1")
+ public Object[] test1() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1','F2','F3']
+ // Inherited serializer already has parent filters applied.
+ @RestMethod(name="GET", path="/test2", transforms=F3.class)
+ public Object[] test2() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1','F2','F3']
+ @RestMethod(name="GET", path="/test3", transforms=F3.class, serializersInherit=TRANSFORMS)
+ public Object[] test3() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['Foo1','Foo2','F3']
+ // Overriding serializer does not have parent filters applied.
+ @RestMethod(name="GET", path="/test4", serializers=JsonSerializer.Simple.class, transforms=F3.class)
+ public Object[] test4() {
+ return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+ }
+
+ // Should show ['F1','F2','F3']
+ // Overriding serializer does have parent filters applied.
+ @RestMethod(name="GET", path="/test5", serializers=JsonSerializer.Simple.class, transforms=F3.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 F1 extends PojoSwap<Foo1,String> {
+ @Override /* PojoSwap */
+ public String swap(Foo1 o) throws SerializeException {
+ return "F1";
+ }
+ }
+
+ public static class F2 extends PojoSwap<Foo2,String> {
+ @Override /* PojoSwap */
+ public String swap(Foo2 o) throws SerializeException {
+ return "F2";
+ }
+ }
+
+ public static class F3 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/bea31abd/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
new file mode 100755
index 0000000..c4921d5
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/LargePojosResource.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;
+
+
+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/bea31abd/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
new file mode 100755
index 0000000..28a85bf
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/MessagesResource.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;
+
+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",
+ transforms={
+ 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/bea31abd/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
new file mode 100755
index 0000000..d943ab6
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/NlsPropertyResource.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;
+
+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/bea31abd/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
new file mode 100755
index 0000000..1dafcb5
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/NlsResource.java
@@ -0,0 +1,194 @@
+/***************************************************************************************************************************
+ * 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/bea31abd/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
new file mode 100755
index 0000000..5399196
--- /dev/null
+++ b/juneau-server-test/src/main/java/org/apache/juneau/server/NoParserInputResource.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;
+
+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);
+ }
+}