This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/master by this push:
     new 12f4d12  Tests.
12f4d12 is described below

commit 12f4d12eaad6fcfbabccb2f6587165454fc4e207
Author: JamesBognar <[email protected]>
AuthorDate: Sun May 13 14:47:41 2018 -0400

    Tests.
---
 .../juneau/rest/test/InheritanceResource.java      | 326 -------------------
 .../java/org/apache/juneau/rest/test/Root.java     |   5 -
 .../apache/juneau/rest/test/InheritanceTest.java   | 116 -------
 .../org/apache/juneau/rest/test/_TestSuite.java    |   1 -
 .../org/apache/juneau/rest/InheritanceTest.java    | 345 +++++++++++++++++++++
 5 files changed, 345 insertions(+), 448 deletions(-)

diff --git 
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
 
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
deleted file mode 100644
index 797ff7e..0000000
--- 
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InheritanceResource.java
+++ /dev/null
@@ -1,326 +0,0 @@
-// 
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
-// * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              *
-// *                                                                           
                                              *
-// *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
-// *                                                                           
                                              *
-// * Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an  *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied.  See the License for the        *
-// * specific language governing permissions and limitations under the 
License.                                              *
-// 
***************************************************************************************************************************
-package org.apache.juneau.rest.test;
-
-import static org.apache.juneau.http.HttpMethodName.*;
-
-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.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,
-                       inherit="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.getConsumes()).toString());
-               }
-
-               // Should show ['text/p5']
-               @RestMethod(
-                       name=GET,
-                       path="/test2",
-                       parsers=P5.class
-               )
-               public Reader test2(RestRequest req) {
-                       return new StringReader(new 
ObjectList(req.getConsumes()).toString());
-               }
-
-               // Should show 
['text/p5','text/p3','text/p4','text/p1','text/p2']
-               @RestMethod(
-                       name=GET,
-                       path="/test3",
-                       parsers=P5.class,
-                       inherit="PARSERS"
-               )
-               public Reader test3(RestRequest req) {
-                       return new StringReader(new 
ObjectList(req.getConsumes()).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", inherit="ENCODERS")
-               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']
-               @RestMethod(name=GET, path="/test2", pojoSwaps=F3Swap.class, 
inherit="TRANSFORMS")
-               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, 
inherit="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, 
inherit="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(RequestProperties 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(RequestProperties 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(RequestProperties 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.DEFAULT, 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.DEFAULT, produces, null);
-               }
-
-               @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";
-               }
-       }
-}
diff --git 
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/Root.java
 
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/Root.java
index ab68256..903295d 100644
--- 
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/Root.java
+++ 
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/Root.java
@@ -33,11 +33,6 @@ import org.apache.juneau.rest.test.client.*;
                FormDataResource.class,
                HtmlDocResource.class,
                HtmlDocLinksResource.class,
-               InheritanceResource.TestEncoders.class,
-               InheritanceResource.TestTransforms.class,
-               InheritanceResource.TestParsers.class,
-               InheritanceResource.TestProperties.class,
-               InheritanceResource.TestSerializers.class,
                InterfaceProxyResource.class,
                LargePojosResource.class,
                MessagesResource.Messages2Resource.class,
diff --git 
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InheritanceTest.java
 
b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InheritanceTest.java
deleted file mode 100644
index a716cc8..0000000
--- 
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/InheritanceTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// 
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file *
-// * distributed with this work for additional information regarding copyright 
ownership.  The ASF licenses this file        *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance            *
-// * with the License.  You may obtain a copy of the License at                
                                              *
-// *                                                                           
                                              *
-// *  http://www.apache.org/licenses/LICENSE-2.0                               
                                              *
-// *                                                                           
                                              *
-// * Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an  *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied.  See the License for the        *
-// * specific language governing permissions and limitations under the 
License.                                              *
-// 
***************************************************************************************************************************
-package org.apache.juneau.rest.test;
-
-import static org.junit.Assert.*;
-
-import org.apache.juneau.rest.client.*;
-import org.junit.*;
-
-public class InheritanceTest extends RestTestcase {
-
-       private RestClient client = TestMicroservice.DEFAULT_CLIENT;
-
-
-       
//====================================================================================================
-       // Test serializer inheritance.
-       
//====================================================================================================
-       @Test
-       public void testSerializers() throws Exception {
-               String r;
-               String url = "/testInheritanceSerializers";
-               r = client.doGet(url + "/test1").getResponseAsString();
-               assertEquals("['text/s3','text/s4','text/s1','text/s2']", r);
-
-               r = client.doGet(url + "/test2").getResponseAsString();
-               assertEquals("['text/s5']", r);
-
-               r = client.doGet(url + "/test3").getResponseAsString();
-               
assertEquals("['text/s5','text/s3','text/s4','text/s1','text/s2']", r);
-       }
-
-       
//====================================================================================================
-       // Test parser inheritance.
-       
//====================================================================================================
-       @Test
-       public void testParsers() throws Exception {
-               String r;
-               String url = "/testInheritanceParsers";
-               r = client.doGet(url + "/test1").getResponseAsString();
-               assertEquals("['text/p3','text/p4','text/p1','text/p2']", r);
-
-               r = client.doGet(url + "/test2").getResponseAsString();
-               assertEquals("['text/p5']", r);
-
-               r = client.doGet(url + "/test3").getResponseAsString();
-               
assertEquals("['text/p5','text/p3','text/p4','text/p1','text/p2']", r);
-       }
-
-       
//====================================================================================================
-       // Test encoder inheritance.
-       
//====================================================================================================
-       @Test
-       public void testEncoders() throws Exception {
-               String url = "/testInheritanceEncoders";
-               String r = client.doGet(url + "/test").getResponseAsString();
-               assertEquals("['e3','e4','e1','e2','identity']", r);
-       }
-
-       
//====================================================================================================
-       // Test filter inheritance.
-       
//====================================================================================================
-       @Test
-       public void testTransforms() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/json+simple").build();
-               String r;
-               String url = "/testInheritanceTransforms";
-
-               r = client.doGet(url + "/test1").getResponseAsString();
-               assertEquals("['F1','F2','Foo3']", r);
-
-               r = client.doGet(url + "/test2").getResponseAsString();
-               assertEquals("['F1','F2','F3']", r);
-
-               r = client.doGet(url + "/test3").getResponseAsString();
-               assertEquals("['F1','F2','F3']", r);
-
-               r = client.doGet(url + "/test4").getResponseAsString();
-               assertEquals("['Foo1','Foo2','F3']", r);
-
-               r = client.doGet(url + "/test5").getResponseAsString();
-               assertEquals("['F1','F2','F3']", r);
-
-               client.closeQuietly();
-       }
-
-       
//====================================================================================================
-       // Test properties inheritance.
-       
//====================================================================================================
-       @Test
-       public void testProperties() throws Exception {
-               RestClient client = 
TestMicroservice.client().accept("text/json+simple").build();
-               String r;
-               String url = "/testInheritanceProperties";
-
-               r = client.doGet(url + "/test1").getResponseAsString();
-               assertEquals("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}", r);
-
-               r = client.doGet(url + "/test2?override").getResponseAsString();
-               assertEquals("{p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'}", r);
-
-               r = client.doGet(url + "/test2").getResponseAsString();
-               assertEquals("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'}", r);
-
-               client.closeQuietly();
-       }
-}
diff --git 
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java
 
b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java
index 5a04bdf..3cd3a25 100644
--- 
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java
+++ 
b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/_TestSuite.java
@@ -31,7 +31,6 @@ import org.junit.runners.Suite.*;
        FormDataTest.class,
        HtmlDocTest.class,
        HtmlDocLinksTest.class,
-       InheritanceTest.class,
        InterfaceProxyTest.class,
        JacocoDummyTest.class,
        LargePojosTest.class,
diff --git 
a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/InheritanceTest.java
 
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/InheritanceTest.java
new file mode 100644
index 0000000..87ec43c
--- /dev/null
+++ 
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/InheritanceTest.java
@@ -0,0 +1,345 @@
+// 
***************************************************************************************************************************
+// * 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;
+
+import static org.apache.juneau.http.HttpMethodName.*;
+
+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.annotation.*;
+import org.apache.juneau.rest.mock.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.transform.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+/**
+ * Tests that validate the behavior of @RestMethod(inherit).
+ */
+@SuppressWarnings({"javadoc"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class InheritanceTest {
+
+       
//=================================================================================================================
+       // Setup classes
+       
//=================================================================================================================
+
+       public static class DummyParser extends ReaderParser {
+               public DummyParser(String...consumes) {
+                       super(PropertyStore.DEFAULT, 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.DEFAULT, produces, null);
+               }
+               @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";
+               }
+       }
+       
+       
//=================================================================================================================
+       // Test serializer inheritance.
+       
//=================================================================================================================
+
+       @RestResource(serializers={S1.class,S2.class})
+       public static class A {}
+       
+       @RestResource(serializers={S3.class,S4.class})
+       public static class A01 extends A {}
+
+       @RestResource
+       public static class A02 extends A01 {
+               @RestMethod(path="/default")
+               public ObjectList a01(RestResponse res) {
+                       // Should show ['text/s3','text/s4','text/s1','text/s2']
+                       return new ObjectList(res.getSupportedMediaTypes());
+               }
+               @RestMethod(path="/onMethod", serializers=S5.class)
+               public ObjectList a02(RestResponse res) {
+                       // Should show ['text/s5']
+                       return new ObjectList(res.getSupportedMediaTypes());
+               }
+               @RestMethod(path="/onMethodInherit", serializers=S5.class, 
inherit="SERIALIZERS")
+               public ObjectList a03(RestResponse res) {
+                       // Should show 
['text/s5','text/s3','text/s4','text/s1','text/s2']
+                       return new ObjectList(res.getSupportedMediaTypes());
+               }
+       }
+       static MockRest a = MockRest.create(A02.class);
+
+       @Test
+       public void a01_serializers_default() throws Exception {
+               a.request("GET", 
"/default").execute().assertBody("['text/s3','text/s4','text/s1','text/s2']");
+       }
+       @Test
+       public void a02_serializers_onMethod() throws Exception {
+               a.request("GET", 
"/onMethod").execute().assertBody("['text/s5']");
+       }
+       @Test
+       public void a03_serializers_onMethodInherit() throws Exception {
+               a.request("GET", 
"/onMethodInherit").execute().assertBody("['text/s5','text/s3','text/s4','text/s1','text/s2']");
+       }
+
+       
//=================================================================================================================
+       // Test parser inheritance.
+       
//=================================================================================================================
+       
+       @RestResource(parsers={P1.class,P2.class})
+       public static class B {}
+
+       @RestResource(parsers={P3.class,P4.class})
+       public static class B01 extends B {}
+
+       @RestResource
+       public static class B02 extends B01 {
+               @RestMethod(path="/default")
+               public ObjectList b01(RestRequest req) {
+                       // Should show ['text/p3','text/p4','text/p1','text/p2']
+                       return new ObjectList(req.getConsumes());
+               }
+               @RestMethod(path="/onMethod", parsers=P5.class)
+               public ObjectList b02(RestRequest req) {
+                       // Should show ['text/p5']
+                       return new ObjectList(req.getConsumes());
+               }
+               @RestMethod(path="/onMethodInherit", parsers=P5.class, 
inherit="PARSERS")
+               public ObjectList bo3(RestRequest req) {
+                       // Should show 
['text/p5','text/p3','text/p4','text/p1','text/p2']
+                       return new ObjectList(req.getConsumes());
+               }
+       }
+       static MockRest b = MockRest.create(B02.class);
+
+       @Test
+       public void b01_parsers_default() throws Exception {
+               b.request("GET", 
"/default").execute().assertBody("['text/p3','text/p4','text/p1','text/p2']");
+       }
+       @Test
+       public void b02_parsers_onMethod() throws Exception {
+               b.request("GET", 
"/onMethod").execute().assertBody("['text/p5']");
+       }
+       @Test
+       public void b03_parsers_onMethodInherit() throws Exception {
+               b.request("GET", 
"/onMethodInherit").execute().assertBody("['text/p5','text/p3','text/p4','text/p1','text/p2']");
+       }
+
+       
//=================================================================================================================
+       // Test encoder inheritance.
+       
//=================================================================================================================
+       
+       @RestResource(encoders={E1.class,E2.class})
+       public static class C {}
+
+       @RestResource(encoders={E3.class,E4.class})
+       public static class C01 extends C {}
+
+       @RestResource
+       public static class C02 extends C01 {
+               @RestMethod(name=GET, inherit="ENCODERS")
+               public ObjectList test(RestResponse res) throws 
RestServletException {
+                       // Should show ['e3','e4','e1','e2','identity']
+                       return new ObjectList(res.getSupportedEncodings());
+               }
+       }
+       static MockRest c = MockRest.create(C02.class);
+
+       @Test
+       public void c01_encoders() throws Exception {
+               c.request("GET", 
"/").execute().assertBody("['e3','e4','e1','e2','identity']");
+       }
+
+       
//=================================================================================================================
+       // Test filter inheritance.
+       
//=================================================================================================================
+       
+       @RestResource(pojoSwaps={F1Swap.class})
+       public static class D {}
+
+       @RestResource(pojoSwaps={F2Swap.class})
+       public static class D01 extends D {}
+
+       @RestResource(serializers=JsonSerializer.Simple.class)
+       public static class D02 extends D01 {
+               @RestMethod(name=GET, path="/default")
+               public Object[] d01() {
+                       // Should show ['F1','F2','Foo3']
+                       return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+               }
+               @RestMethod(name=GET, path="/inheritTransforms", 
pojoSwaps=F3Swap.class, inherit="TRANSFORMS")
+               public Object[] d02() {
+                       // Should show ['F1','F2','F3']
+                       return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+               }
+               @RestMethod(name=GET, path="/overrideSerializer", 
serializers=JsonSerializer.Simple.class, pojoSwaps=F3Swap.class)
+               public Object[] d03() {
+                       // Should show ['Foo1','Foo2','F3']"
+                       // Overriding serializer does not have parent filters 
applied.
+                       return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+               }
+               @RestMethod(name=GET, 
path="/overrideSerializerInheritTransforms", 
serializers=JsonSerializer.Simple.class, pojoSwaps=F3Swap.class, 
inherit="TRANSFORMS")
+               public Object[] d04() {
+                       // Should show ['F1','F2','F3']
+                       return new Object[]{new Foo1(), new Foo2(), new Foo3()};
+               }
+       }
+       static MockRest d = MockRest.create(D02.class);
+
+       @Test
+       public void d01_transforms_default() throws Exception {
+               d.request("GET", 
"/default").json().execute().assertBody("['F1','F2','Foo3']");
+       }
+       @Test
+       public void d02_transforms_inheritTransforms() throws Exception {
+               d.request("GET", 
"/inheritTransforms").json().execute().assertBody("['F1','F2','F3']");
+       }
+       @Test
+       public void d03_transforms_overrideSerializer() throws Exception {
+               d.request("GET", 
"/overrideSerializer").json().execute().assertBody("['Foo1','Foo2','F3']");
+       }
+       @Test
+       public void d04_transforms_overrideSerializerInheritTransforms() throws 
Exception {
+               d.request("GET", 
"/overrideSerializerInheritTransforms").json().execute().assertBody("['F1','F2','F3']");
+       }
+
+       
//=================================================================================================================
+       // Test properties inheritance.
+       
//=================================================================================================================
+       
+       @RestResource(properties={@Property(name="p1",value="v1"), 
@Property(name="p2",value="v2")})
+       public static class E {}
+
+       @RestResource(properties={@Property(name="p2",value="v2a"), 
@Property(name="p3",value="v3"), @Property(name="p4",value="v4")})
+       public static class E01 extends E {}
+
+       @RestResource
+       public static class E02 extends E01 {
+               @RestMethod(name=GET, path="/default")
+               public ObjectMap test1(RequestProperties properties) {
+                       // Should show {p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}
+                       return transform(properties);
+               }
+               @RestMethod(name=GET, path="/override", 
properties={@Property(name="p4",value="v4a"), @Property(name="p5", value="v5")})
+               public ObjectMap test2(RequestProperties properties, 
@HasQuery("override") boolean override) {
+                       // 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.
+                       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(RequestProperties 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;
+               }
+       }
+       static MockRest e = MockRest.create(E02.class);
+
+       @Test
+       public void e01_properties_default() throws Exception {
+               e.request("GET", 
"/default").execute().assertBody("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4'}");
+       }
+       @Test
+       public void e02_properties_override_false() throws Exception {
+               e.request("GET", 
"/override").execute().assertBody("{p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'}");
+       }
+       @Test
+       public void e03_properties_override_true() throws Exception {
+               e.request("GET", 
"/override?override").execute().assertBody("{p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'}");
+       }
+}

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to