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 2017/09/08 23:21:18 UTC
svn commit: r21538 [9/27] - in /release/incubator/juneau:
juneau-microservice-server/ juneau-microservice-server/.settings/
juneau-microservice-server/src/ juneau-microservice-server/src/main/
juneau-microservice-server/src/main/java/ juneau-microservi...
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ClientVersionResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ClientVersionResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ClientVersionResource.java Fri Sep 8 23:21:12 2017
@@ -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.rest.test;
+
+import org.apache.juneau.microservice.*;
+import org.apache.juneau.rest.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";
+ }
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ClientVersionResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ConfigResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ConfigResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ConfigResource.java Fri Sep 8 23:21:12 2017
@@ -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.rest.test;
+
+import org.apache.juneau.ini.*;
+import org.apache.juneau.microservice.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.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.getConfigFile();
+ }
+
+ @RestMethod(name="GET", path="/{key}/{class}")
+ public Object test2(RestRequest req, @Path("key") String key, @Path("class") Class<?> c) throws Exception {
+ return req.getConfigFile().getObject(key, c);
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ConfigResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ContentResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ContentResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ContentResource.java Fri Sep 8 23:21:12 2017
@@ -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.rest.test;
+
+import static org.apache.juneau.rest.RestContext.*;
+
+import java.util.*;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.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(@Body boolean b) {
+ return b;
+ }
+
+ @RestMethod(name="POST", path="/Boolean")
+ public Boolean testBoolean(@Body Boolean b) {
+ return b;
+ }
+
+ @RestMethod(name="POST", path="/int")
+ public int testInt(@Body int i) {
+ return i;
+ }
+
+ @RestMethod(name="POST", path="/Integer")
+ public Integer testInteger(@Body Integer i) {
+ return i;
+ }
+
+ @RestMethod(name="POST", path="/float")
+ public float testFloat(@Body float f) {
+ return f;
+ }
+
+ @RestMethod(name="POST", path="/Float")
+ public Float testFloat2(@Body Float f) {
+ return f;
+ }
+
+ @RestMethod(name="POST", path="/Map")
+ public TreeMap<String,String> testMap(@Body TreeMap<String,String> m) {
+ return m;
+ }
+
+ @RestMethod(name="POST", path="/B")
+ public DTO2s.B testPojo1(@Body DTO2s.B b) {
+ return b;
+ }
+
+ @RestMethod(name="POST", path="/C")
+ public DTO2s.C testPojo2(@Body DTO2s.C c) {
+ return c;
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ContentResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/DTO2s.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/DTO2s.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/DTO2s.java Fri Sep 8 23:21:12 2017
@@ -0,0 +1,138 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import java.util.*;
+
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.urlencoding.annotation.*;
+import org.apache.juneau.utils.*;
+
+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;
+ }
+
+ }
+
+ @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 AList<String>().append("c").append("d");
+ t.f03 = new int[]{1,2};
+ t.f04 = new AList<Integer>().append(3).append(4);
+ t.f05 = new String[][]{{"e","f"},{"g","h"}};
+ t.f06 = new AList<String[]>().append(new String[]{"i","j"}).append(new String[]{"k","l"});
+ t.f07 = new A[]{A.create(),A.create()};
+ t.f08 = new AList<A>().append(A.create()).append(A.create());
+ t.f09 = new A[][]{{A.create()},{A.create()}};
+ t.f10 = new AList<List<A>>().append(Arrays.asList(A.create())).append(Arrays.asList(A.create()));
+ t.setF11(new String[]{"a","b"});
+ t.setF12(new AList<String>().append("c").append("d"));
+ t.setF13(new int[]{1,2});
+ t.setF14(new AList<Integer>().append(3).append(4));
+ t.setF15(new String[][]{{"e","f"},{"g","h"}});
+ t.setF16(new AList<String[]>().append(new String[]{"i","j"}).append(new String[]{"k","l"}));
+ t.setF17(new A[]{A.create(),A.create()});
+ t.setF18(new AList<A>().append(A.create()).append(A.create()));
+ t.setF19(new A[][]{{A.create()},{A.create()}});
+ t.setF20(new AList<List<A>>().append(Arrays.asList(A.create())).append(Arrays.asList(A.create())));
+ return t;
+ }
+ }
+
+ @UrlEncoding(expandedParams=true)
+ public static class C extends B {
+ static C create() {
+ C t = new C();
+ t.f01 = new String[]{"a","b"};
+ t.f02 = new AList<String>().append("c").append("d");
+ t.f03 = new int[]{1,2};
+ t.f04 = new AList<Integer>().append(3).append(4);
+ t.f05 = new String[][]{{"e","f"},{"g","h"}};
+ t.f06 = new AList<String[]>().append(new String[]{"i","j"}).append(new String[]{"k","l"});
+ t.f07 = new A[]{A.create(),A.create()};
+ t.f08 = new AList<A>().append(A.create()).append(A.create());
+ t.f09 = new A[][]{{A.create()},{A.create()}};
+ t.f10 = new AList<List<A>>().append(Arrays.asList(A.create())).append(Arrays.asList(A.create()));
+ t.setF11(new String[]{"a","b"});
+ t.setF12(new AList<String>().append("c").append("d"));
+ t.setF13(new int[]{1,2});
+ t.setF14(new AList<Integer>().append(3).append(4));
+ t.setF15(new String[][]{{"e","f"},{"g","h"}});
+ t.setF16(new AList<String[]>().append(new String[]{"i","j"}).append(new String[]{"k","l"}));
+ t.setF17(new A[]{A.create(),A.create()});
+ t.setF18(new AList<A>().append(A.create()).append(A.create()));
+ t.setF19(new A[][]{{A.create()},{A.create()}});
+ t.setF20(new AList<List<A>>().append(Arrays.asList(A.create())).append(Arrays.asList(A.create())));
+ return t;
+ }
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/DTO2s.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java Fri Sep 8 23:21:12 2017
@@ -0,0 +1,141 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import static org.apache.juneau.rest.annotation.Inherit.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.serializer.*;
+
+/**
+ * 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;
+
+ public static class P1 extends DummyParser { public P1(PropertyStore ps) {super(ps, "p1", "text/p1");}}
+
+ public static class P2 extends DummyParser { public P2(PropertyStore ps) {super(ps, "p2", "text/p2");}}
+
+ public static class P3 extends DummyParser { public P3(PropertyStore ps) {super(ps, "p3", "text/p3");}}
+
+ public static class S1 extends DummySerializer { public S1(PropertyStore ps) {super(ps, "s1", "text/s1");}}
+
+ public static class S2 extends DummySerializer { public S2(PropertyStore ps) {super(ps, "s2", "text/s2");}}
+
+ public static class S3 extends DummySerializer { public S3(PropertyStore ps) {super(ps, "s3", "text/s3");}}
+
+ /**
+ * Test that default Accept and Content-Type headers on servlet annotation are picked up.
+ */
+ @RestMethod(name="PUT", path="/testDefaultHeadersOnServletAnnotation")
+ public String testDefaultHeadersOnServletAnnotation(@Body 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(@Body 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(@Body String in) {
+ return in;
+ }
+
+ //====================================================================================================
+ // Various Accept incantations.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testAccept")
+ public String testAccept(@Body 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(@Body 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(@Body String in) {
+ return in;
+ }
+
+ public static class DummyParser extends ReaderParser {
+
+ private String name;
+
+ private DummyParser(PropertyStore propertyStore, String name, String...consumes) {
+ super(propertyStore, consumes);
+ this.name = name;
+ }
+
+ @Override /* Parser */
+ public ReaderParserSession createSession(ParserSessionArgs args) {
+ return new ReaderParserSession(args) {
+
+ @Override /* ParserSession */
+ @SuppressWarnings("unchecked")
+ protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
+ return (T)name;
+ }
+ };
+ }
+ }
+
+ public static class DummySerializer extends WriterSerializer {
+
+ private String name;
+
+ private DummySerializer(PropertyStore propertyStore, String name, String produces) {
+ super(propertyStore, produces);
+ this.name = name;
+ }
+
+ @Override /* Serializer */
+ public WriterSerializerSession createSession(SerializerSessionArgs args) {
+ return new WriterSerializerSession(args) {
+
+ @Override /* SerializerSession */
+ protected void doSerialize(SerializerPipe out, Object o) throws Exception {
+ out.getWriter().write(name + "/" + o);
+ }
+ };
+ }
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/DefaultContentTypesResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ErrorConditionsResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ErrorConditionsResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ErrorConditionsResource.java Fri Sep 8 23:21:12 2017
@@ -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.rest.test;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.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(@Body 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(@Body 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(@Body 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(@Body 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(@Body Test3b1 in) {
+ return "OK";
+ }
+
+ static class Test3b1 {
+ public Test3b1(){}
+ }
+
+ //====================================================================================================
+ // Test exception thrown during bean construction.
+ //====================================================================================================
+ @RestMethod(name="PUT", path="/testThrownConstructorException")
+ public String testThrownConstructorException(@Body 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(@Query("p1") int t1, @Path 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;
+ }
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/ErrorConditionsResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/FormDataResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/FormDataResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/FormDataResource.java Fri Sep 8 23:21:12 2017
@@ -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.rest.test;
+
+import static org.apache.juneau.internal.IOUtils.*;
+
+import java.io.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testFormData"
+)
+public class FormDataResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // Basic tests
+ //====================================================================================================
+ @RestMethod(name="POST", path="/*")
+ public Reader test(RestRequest req) throws IOException {
+ return new StringReader("Content-Type=["+req.getContentType()+"], contents=["+read(req.getReader())+"]");
+ }
+
+ //====================================================================================================
+ // Default values.
+ //====================================================================================================
+
+ @RestMethod(name="POST", path="/defaultFormData", defaultFormData={"f1:1","f2=2"," f3 : 3 "})
+ public ObjectMap defaultFormData(RequestFormData formData) {
+ return new ObjectMap()
+ .append("f1", formData.getString("f1"))
+ .append("f2", formData.getString("f2"))
+ .append("f3", formData.getString("f3"));
+ }
+
+ @RestMethod(name="POST", path="/annotatedFormData")
+ public ObjectMap annotatedFormData(@FormData("f1") String f1, @FormData("f2") String f2, @FormData("f3") String f3) {
+ return new ObjectMap()
+ .append("f1", f1)
+ .append("f2", f2)
+ .append("f3", f3);
+ }
+
+ @RestMethod(name="POST", path="/annotatedFormDataDefault")
+ public ObjectMap annotatedFormDataDefault(@FormData(value="f1",def="1") String f1, @FormData(value="f2",def="2") String f2, @FormData(value="f3",def="3") String f3) {
+ return new ObjectMap()
+ .append("f1", f1)
+ .append("f2", f2)
+ .append("f3", f3);
+ }
+
+ @RestMethod(name="POST", path="/annotatedAndDefaultFormData", defaultFormData={"f1:1","f2=2"," f3 : 3 "})
+ public ObjectMap annotatedAndDefaultFormData(@FormData(value="f1",def="4") String f1, @FormData(value="f2",def="5") String f2, @FormData(value="f3",def="6") String f3) {
+ return new ObjectMap()
+ .append("f1", f1)
+ .append("f2", f2)
+ .append("f3", f3);
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/FormDataResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java Fri Sep 8 23:21:12 2017
@@ -0,0 +1,87 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import static org.apache.juneau.internal.IOUtils.*;
+import static org.apache.juneau.rest.annotation.HookEvent.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.serializer.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testGroups"
+)
+public class GroupsResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ @RestHook(INIT)
+ public void init(RestConfig config) throws Exception {
+ config.addSerializers(SSerializer.class).addParsers(PParser.class);
+ }
+
+ public static class SSerializer extends WriterSerializer {
+
+ public SSerializer(PropertyStore propertyStore) {
+ super(propertyStore, "text/s1", "text/s1", "text/s2");
+ }
+
+ @Override /* Serializer */
+ public WriterSerializerSession createSession(SerializerSessionArgs args) {
+ return new WriterSerializerSession(args) {
+
+ @Override /* SerializerSession */
+ protected void doSerialize(SerializerPipe out, Object o) throws Exception {
+ out.getWriter().write("text/s," + o);
+ }
+ };
+ }
+ }
+
+ public static class PParser extends ReaderParser {
+
+ public PParser(PropertyStore propertyStore) {
+ super(propertyStore, "text/p1", "text/p2");
+ }
+
+ @Override /* Parser */
+ public ReaderParserSession createSession(ParserSessionArgs args) {
+ return new ReaderParserSession(args) {
+
+ @Override /* ParserSession */
+ @SuppressWarnings("unchecked")
+ protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
+ return (T)read(pipe.getReader());
+ }
+ };
+ }
+ }
+
+ //====================================================================================================
+ // Serializer defined on class.
+ //====================================================================================================
+ @RestMethod(name="GET", path="/testSerializerDefinedOnClass")
+ public String testSerializerDefinedOnClass_get() {
+ return "GET";
+ }
+
+ @RestMethod(name="PUT", path="/testSerializerDefinedOnClass")
+ public String testSerializerDefinedOnClass_put(@Body String in) {
+ return in;
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GroupsResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java Fri Sep 8 23:21:12 2017
@@ -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.rest.test;
+
+import java.io.*;
+
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.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(@Body 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(@Body 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();
+ }
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/GzipResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java Fri Sep 8 23:21:12 2017
@@ -0,0 +1,243 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.*;
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.http.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testHeaders",
+ serializers=HeadersResource.PlainTextAnythingSerializer.class,
+ parsers=HeadersResource.PlainTextAnythingParser.class,
+ encoders=HeadersResource.IdentityAnythingEncoder.class,
+ paramResolvers=HeadersResource.CustomHeaderParam.class
+)
+public class HeadersResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ //====================================================================================================
+ // HTTP 1.1 headers
+ //====================================================================================================
+
+ @RestMethod(name="GET", path="/accept")
+ public String accept(Accept accept) {
+ return accept.toString();
+ }
+ @RestMethod(name="GET", path="/acceptCharset")
+ public String acceptCharset(AcceptCharset acceptCharset) {
+ return acceptCharset.toString();
+ }
+ @RestMethod(name="GET", path="/acceptEncoding")
+ public String acceptEncoding(AcceptEncoding acceptEncoding) {
+ return acceptEncoding.toString();
+ }
+ @RestMethod(name="GET", path="/acceptLanguage")
+ public String acceptLanguage(AcceptLanguage acceptLanguage) {
+ return acceptLanguage.toString();
+ }
+ @RestMethod(name="GET", path="/authorization")
+ public String authorization(Authorization authorization) {
+ return authorization.toString();
+ }
+ @RestMethod(name="GET", path="/cacheControl")
+ public String cacheControl(CacheControl cacheControl) {
+ return cacheControl.toString();
+ }
+ @RestMethod(name="GET", path="/connection")
+ public String connection(Connection connection) {
+ return connection.toString();
+ }
+ @RestMethod(name="GET", path="/contentLength")
+ public String contentLength(ContentLength contentLength) {
+ return contentLength.toString();
+ }
+ @RestMethod(name="GET", path="/contentType")
+ public String contentType(ContentType contentType) {
+ return contentType.toString();
+ }
+ @RestMethod(name="GET", path="/date")
+ public String date(org.apache.juneau.http.Date date) {
+ return date.toString();
+ }
+ @RestMethod(name="GET", path="/expect")
+ public String expect(Expect expect) {
+ return expect.toString();
+ }
+ @RestMethod(name="GET", path="/from")
+ public String from(From from) {
+ return from.toString();
+ }
+ @RestMethod(name="GET", path="/host")
+ public String host(Host host) {
+ return host.toString();
+ }
+ @RestMethod(name="GET", path="/ifMatch")
+ public String IfMatch(IfMatch ifMatch) {
+ return ifMatch.toString();
+ }
+ @RestMethod(name="GET", path="/ifModifiedSince")
+ public String ifModifiedSince(IfModifiedSince ifModifiedSince) {
+ return ifModifiedSince.toString();
+ }
+ @RestMethod(name="GET", path="/ifNoneMatch")
+ public String ifNoneMatch(IfNoneMatch ifNoneMatch) {
+ return ifNoneMatch.toString();
+ }
+ @RestMethod(name="GET", path="/ifRange")
+ public String ifRange(IfRange ifRange) {
+ return ifRange.toString();
+ }
+ @RestMethod(name="GET", path="/ifUnmodifiedSince")
+ public String ifUnmodifiedSince(IfUnmodifiedSince ifUnmodifiedSince) {
+ return ifUnmodifiedSince.toString();
+ }
+ @RestMethod(name="GET", path="/maxForwards")
+ public String maxForwards(MaxForwards maxForwards) {
+ return maxForwards.toString();
+ }
+ @RestMethod(name="GET", path="/pragma")
+ public String pragma(Pragma pragma) {
+ return pragma.toString();
+ }
+ @RestMethod(name="GET", path="/proxyAuthorization")
+ public String proxyAuthorization(ProxyAuthorization proxyAuthorization) {
+ return proxyAuthorization.toString();
+ }
+ @RestMethod(name="GET", path="/range")
+ public String range(Range range) {
+ return range.toString();
+ }
+ @RestMethod(name="GET", path="/referer")
+ public String referer(Referer referer) {
+ return referer.toString();
+ }
+ @RestMethod(name="GET", path="/te")
+ public String te(TE te) {
+ return te.toString();
+ }
+ @RestMethod(name="GET", path="/upgrade")
+ public String upgrade(Upgrade upgrade) {
+ return upgrade.toString();
+ }
+ @RestMethod(name="GET", path="/userAgent")
+ public String userAgent(UserAgent userAgent) {
+ return userAgent.toString();
+ }
+ @RestMethod(name="GET", path="/warning")
+ public String warning(Warning warning) {
+ return warning.toString();
+ }
+ @RestMethod(name="GET", path="/customHeader")
+ public String customHeader(CustomHeader customHeader) {
+ return customHeader.toString();
+ }
+
+ public static class CustomHeaderParam extends RestParam {
+ public CustomHeaderParam() {
+ super(RestParamType.HEADER, "Custom", CustomHeader.class);
+ }
+ @Override
+ public Object resolve(RestRequest req, RestResponse res) throws Exception {
+ return new CustomHeader(req.getHeader("Custom"));
+ }
+ }
+
+ public static class CustomHeader {
+ public String value;
+ public CustomHeader(String value) {
+ this.value = value;
+ }
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+
+ public static class PlainTextAnythingSerializer extends PlainTextSerializer {
+ public PlainTextAnythingSerializer(PropertyStore propertyStore) {
+ super(propertyStore, "text/plain", "*/*");
+ }
+ }
+
+ public static class PlainTextAnythingParser extends PlainTextParser {
+ public PlainTextAnythingParser(PropertyStore propertyStore) {
+ super(propertyStore, "*/*");
+ }
+ }
+
+ public static class IdentityAnythingEncoder extends IdentityEncoder {
+ @Override /* Encoder */
+ public String[] getCodings() {
+ return new String[]{"*"};
+ }
+ }
+
+ //====================================================================================================
+ // Default values.
+ //====================================================================================================
+
+ @RestMethod(name="GET", path="/defaultRequestHeaders", defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ public ObjectMap defaultRequestHeaders(RequestHeaders headers) {
+ return new ObjectMap()
+ .append("h1", headers.getString("H1"))
+ .append("h2", headers.getString("H2"))
+ .append("h3", headers.getString("H3"));
+ }
+
+ @RestMethod(name="GET", path="/defaultRequestHeadersCaseInsensitive", defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ public ObjectMap defaultRequestHeadersCaseInsensitive(RequestHeaders headers) {
+ return new ObjectMap()
+ .append("h1", headers.getString("h1"))
+ .append("h2", headers.getString("h2"))
+ .append("h3", headers.getString("h3"));
+ }
+
+ @RestMethod(name="GET", path="/annotatedHeaders")
+ public ObjectMap annotatedHeaders(@Header("H1") String h1, @Header("H2") String h2, @Header("H3") String h3) {
+ return new ObjectMap()
+ .append("h1", h1)
+ .append("h2", h2)
+ .append("h3", h3);
+ }
+
+ @RestMethod(name="GET", path="/annotatedHeadersCaseInsensitive")
+ public ObjectMap annotatedHeadersCaseInsensitive(@Header("h1") String h1, @Header("h2") String h2, @Header("h3") String h3) {
+ return new ObjectMap()
+ .append("h1", h1)
+ .append("h2", h2)
+ .append("h3", h3);
+ }
+
+ @RestMethod(name="GET", path="/annotatedHeadersDefault")
+ public ObjectMap annotatedHeadersDefault(@Header(value="h1",def="1") String h1, @Header(value="h2",def="2") String h2, @Header(value="h3",def="3") String h3) {
+ return new ObjectMap()
+ .append("h1", h1)
+ .append("h2", h2)
+ .append("h3", h3);
+ }
+
+ @RestMethod(name="GET", path="/annotatedAndDefaultHeaders", defaultRequestHeaders={"H1:1","H2=2"," H3 : 3 "})
+ public ObjectMap annotatedAndDefaultHeaders(@Header(value="h1",def="4") String h1, @Header(value="h2",def="5") String h2, @Header(value="h3",def="6") String h3) {
+ return new ObjectMap()
+ .append("h1", h1)
+ .append("h2", h2)
+ .append("h3", h3);
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HeadersResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocLinksResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocLinksResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocLinksResource.java Fri Sep 8 23:21:12 2017
@@ -0,0 +1,255 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * Validates inheritance on the @HtmlDoc.links() annotation.
+ */
+@RestResource(
+ path="/testHtmlDocLinks",
+ htmldoc=@HtmlDoc(
+ links={"links1a","links1b"}
+ ),
+ children={
+ HtmlDocLinksResource.HtmlDocLinksResource2.class
+ }
+)
+public class HtmlDocLinksResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ @RestMethod(path="/test1")
+ public Object test1() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test2",
+ htmldoc=@HtmlDoc(
+ links={"links2a","links2b"}
+ )
+ )
+ public Object test2() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test3",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","links3a","links3b"}
+ )
+ )
+ public Object test3() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test4",
+ htmldoc=@HtmlDoc(
+ links={"links4a","INHERIT","links4b"}
+ )
+ )
+ public Object test4() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test5",
+ htmldoc=@HtmlDoc(
+ links={"links5a","links5b","INHERIT"}
+ )
+ )
+ public Object test5() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6a",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","[0]:links6a","[3]:links6b"}
+ )
+ )
+ public Object test6a() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6b",
+ htmldoc=@HtmlDoc(
+ links={"[1]:links6a","[2]:links6b","INHERIT"}
+ )
+ )
+ public Object test6b() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6c",
+ htmldoc=@HtmlDoc(
+ links={"[1]:links6a","[0]:links6b"}
+ )
+ )
+ public Object test6c() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6d",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","foo[0]:links6a","bar[3]:links6b"}
+ )
+ )
+ public Object test6d() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6e",
+ htmldoc=@HtmlDoc(
+ links={"foo[1]:links6a","bar[2]:links6b","INHERIT"}
+ )
+ )
+ public Object test6e() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test6f",
+ htmldoc=@HtmlDoc(
+ links={"foo[1]:links6a","bar[0]:links6b"}
+ )
+ )
+ public Object test6f() {
+ return "OK";
+ }
+
+ @RestResource(
+ path="/testHtmlDocLinks2",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","links11a","links11b"}
+ )
+ )
+ public static class HtmlDocLinksResource2 extends HtmlDocLinksResource {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @RestMethod(path="/test11")
+ public Object test11() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test12",
+ htmldoc=@HtmlDoc(
+ links={"links12a","links12b"}
+ )
+ )
+ public Object test12() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test13",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","links13a","links13b"}
+ )
+ )
+ public Object test13() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test14",
+ htmldoc=@HtmlDoc(
+ links={"links14a","INHERIT","links14b"}
+ )
+ )
+ public Object test14() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test15",
+ htmldoc=@HtmlDoc(
+ links={"links15a","links15b","INHERIT"}
+ )
+ )
+ public Object test15() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16a",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","[0]:links16a","[3]:links16b"}
+ )
+ )
+ public Object test16a() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16b",
+ htmldoc=@HtmlDoc(
+ links={"[1]:links16a","[2]:links16b","INHERIT"}
+ )
+ )
+ public Object test16b() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16c",
+ htmldoc=@HtmlDoc(
+ links={"[1]:links16a","[0]:links16b"}
+ )
+ )
+ public Object test16c() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16d",
+ htmldoc=@HtmlDoc(
+ links={"INHERIT","foo[0]:links16a","bar[3]:links16b"}
+ )
+ )
+ public Object test16d() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16e",
+ htmldoc=@HtmlDoc(
+ links={"foo[1]:links16a","bar[2]:links16b","INHERIT"}
+ )
+ )
+ public Object test16e() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test16f",
+ htmldoc=@HtmlDoc(
+ links={"foo[1]:links16a","bar[0]:links16b"}
+ )
+ )
+ public Object test16f() {
+ return "OK";
+ }
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocLinksResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java Fri Sep 8 23:21:12 2017
@@ -0,0 +1,186 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * Validates inheritance on the @HtmlDoc annotation.
+ */
+@RestResource(
+ path="/testHtmlDoc",
+ htmldoc=@HtmlDoc(
+ aside={"aside1a","aside1b","INHERIT"},
+ footer={"footer1a","footer1b"},
+ header={"header1a","header1b"},
+ nav={"nav1a","nav1b"},
+ script={"script1a","script1b"},
+ style={"style1a","style1b"},
+ stylesheet="stylesheet1"
+ ),
+ children={
+ HtmlDocResource.HtmlDocResource2.class
+ }
+)
+public class HtmlDocResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+ @RestMethod(path="/test1")
+ public Object test1() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test2",
+ htmldoc=@HtmlDoc(
+ aside={"aside2a","aside2b"},
+ footer={"footer2a","footer2b"},
+ header={"header2a","header2b"},
+ nav={"nav2a","nav2b"},
+ script={"script2a","script2b"},
+ style={"style2a","style2b"},
+ stylesheet="stylesheet2"
+ )
+ )
+ public Object test2() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test3",
+ htmldoc=@HtmlDoc(
+ aside={"INHERIT","aside3a","aside3b"},
+ footer={"INHERIT","footer3a","footer3b"},
+ header={"INHERIT","header3a","header3b"},
+ nav={"INHERIT","nav3a","nav3b"},
+ script={"INHERIT","script3a","script3b"},
+ style={"INHERIT","style3a","style3b"}
+ )
+ )
+ public Object test3() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test4",
+ htmldoc=@HtmlDoc(
+ aside={"aside4a","INHERIT","aside4b"},
+ footer={"footer4a","INHERIT","footer4b"},
+ header={"header4a","INHERIT","header4b"},
+ nav={"nav4a","INHERIT","nav4b"},
+ script={"script4a","INHERIT","script4b"},
+ style={"style4a","INHERIT","style4b"}
+ )
+ )
+ public Object test4() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test5",
+ htmldoc=@HtmlDoc(
+ aside={"aside5a","aside5b","INHERIT"},
+ footer={"footer5a","footer5b","INHERIT"},
+ header={"header5a","header5b","INHERIT"},
+ nav={"nav5a","nav5b","INHERIT"},
+ script={"script5a","script5b","INHERIT"},
+ style={"style5a","style5b","INHERIT"}
+ )
+ )
+ public Object test5() {
+ return "OK";
+ }
+
+ @RestResource(
+ path="/testHtmlDoc2",
+ htmldoc=@HtmlDoc(
+ aside={"INHERIT","aside11a","aside11b"},
+ footer={"footer11a","INHERIT","footer11b"},
+ header={"header11a","header11b","INHERIT"},
+ nav={"INHERIT","nav11a","nav11b"},
+ script={"script11a","script11b"},
+ style={"style11a","style11b"},
+ stylesheet="stylesheet11"
+ )
+ )
+ public static class HtmlDocResource2 extends HtmlDocResource {
+ private static final long serialVersionUID = 1L;
+
+ @RestMethod(path="/test11")
+ public Object test11() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test12",
+ htmldoc=@HtmlDoc(
+ aside={"aside12a","aside12b"},
+ footer={"footer12a","footer12b"},
+ header={"header12a","header12b"},
+ nav={"nav12a","nav12b"},
+ script={"script12a","script12b"},
+ style={"style12a","style12b"},
+ stylesheet="stylesheet12"
+ )
+ )
+ public Object test12() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test13",
+ htmldoc=@HtmlDoc(
+ aside={"INHERIT","aside13a","aside13b"},
+ footer={"INHERIT","footer13a","footer13b"},
+ header={"INHERIT","header13a","header13b"},
+ nav={"INHERIT","nav13a","nav13b"},
+ script={"INHERIT","script13a","script13b"},
+ style={"INHERIT","style13a","style13b"}
+ )
+ )
+ public Object test13() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test14",
+ htmldoc=@HtmlDoc(
+ aside={"aside14a","INHERIT","aside14b"},
+ footer={"footer14a","INHERIT","footer14b"},
+ header={"header14a","INHERIT","header14b"},
+ nav={"nav14a","INHERIT","nav14b"},
+ script={"script14a","INHERIT","script14b"},
+ style={"style14a","INHERIT","style14b"}
+ )
+ )
+ public Object test14() {
+ return "OK";
+ }
+
+ @RestMethod(
+ path="/test15",
+ htmldoc=@HtmlDoc(
+ aside={"aside15a","aside15b","INHERIT"},
+ footer={"footer15a","footer15b","INHERIT"},
+ header={"header15a","header15b","INHERIT"},
+ nav={"nav15a","nav15b","INHERIT"},
+ script={"script15a","script15b","INHERIT"},
+ style={"style15a","style15b","INHERIT"}
+ )
+ )
+ public Object test15() {
+ return "OK";
+ }
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
==============================================================================
--- release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java (added)
+++ release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java Fri Sep 8 23:21:12 2017
@@ -0,0 +1,328 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import static org.apache.juneau.rest.annotation.Inherit.*;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.annotation.Properties;
+import org.apache.juneau.serializer.*;
+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, @HasQuery("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 {
+
+ public DummyParser(String...consumes) {
+ super(PropertyStore.create(), consumes);
+ }
+
+ @Override /* Parser */
+ public ReaderParserSession createSession(ParserSessionArgs args) {
+ return new ReaderParserSession(args) {
+
+ @Override /* ParserSession */
+ protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception {
+ return null;
+ }
+ };
+ }
+ }
+
+ public static class DummySerializer extends WriterSerializer {
+
+ public DummySerializer(String produces) {
+ super(PropertyStore.create(), produces);
+ }
+
+ @Override /* Serializer */
+ public WriterSerializerSession createSession(SerializerSessionArgs args) {
+ return new WriterSerializerSession(args) {
+
+ @Override /* SerializerSession */
+ protected void doSerialize(SerializerPipe out, Object o) throws Exception {
+ out.getWriter().write(o.toString());
+ }
+ };
+ }
+ }
+
+ public static class P1 extends DummyParser{ public P1(PropertyStore ps) {super("text/p1");} }
+
+ public static class P2 extends DummyParser{ public P2(PropertyStore ps) {super("text/p2");} }
+
+ public static class P3 extends DummyParser{ public P3(PropertyStore ps) {super("text/p3");} }
+
+ public static class P4 extends DummyParser{ public P4(PropertyStore ps) {super("text/p4");} }
+
+ public static class P5 extends DummyParser{ public P5(PropertyStore ps) {super("text/p5");} }
+
+ public static class S1 extends DummySerializer{ public S1(PropertyStore ps) {super("text/s1");} }
+
+ public static class S2 extends DummySerializer{ public S2(PropertyStore ps) {super("text/s2");} }
+
+ public static class S3 extends DummySerializer{ public S3(PropertyStore ps) {super("text/s3");} }
+
+ public static class S4 extends DummySerializer{ public S4(PropertyStore ps) {super("text/s4");} }
+
+ public static class S5 extends DummySerializer{ public S5(PropertyStore ps) {super("text/s5");} }
+
+ 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 StringSwap<Foo1> {
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Foo1 o) throws SerializeException {
+ return "F1";
+ }
+ }
+
+ public static class F2Swap extends StringSwap<Foo2> {
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Foo2 o) throws SerializeException {
+ return "F2";
+ }
+ }
+
+ public static class F3Swap extends StringSwap<Foo3> {
+ @Override /* PojoSwap */
+ public String swap(BeanSession session, Foo3 o) throws SerializeException {
+ return "F3";
+ }
+ }
+}
Propchange: release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain