Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxy.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxy.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxy.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,191 @@
+//
***************************************************************************************************************************
+// * 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.remoteable.*;
+import org.apache.juneau.rest.test.pojos.*;
+
+/**
+ * Interface proxy exposed in InterfaceProxyResource and tested in
InterfaceProxyTest.
+ */
+@Remoteable
+public interface InterfaceProxy {
+
+ public static final String SWAP =
"swap-~!@#$%^&*()_+`-={}[]|:;\"<,>.?/";
+
+
//--------------------------------------------------------------------------------
+ // Test return types.
+
//--------------------------------------------------------------------------------
+
+ // Various primitives
+ void returnVoid();
+ int returnInt();
+ Integer returnInteger();
+ boolean returnBoolean();
+ float returnFloat();
+ Float returnFloatObject();
+ String returnString();
+ String returnNullString();
+ int[][][] returnInt3dArray();
+ Integer[][][] returnInteger3dArray();
+ String[][][] returnString3dArray();
+ List<Integer> returnIntegerList();
+ List<List<List<Integer>>> returnInteger3dList();
+ List<Integer[][][]> returnInteger1d3dList();
+ List<int[][][]> returnInt1d3dList();
+ List<String> returnStringList();
+
+ // Beans
+ ABean returnBean();
+ ABean[][][] returnBean3dArray();
+ List<ABean> returnBeanList();
+ List<ABean[][][]> returnBean1d3dList();
+ Map<String,ABean> returnBeanMap();
+ Map<String,List<ABean>> returnBeanListMap();
+ Map<String,List<ABean[][][]>> returnBean1d3dListMap();
+ Map<Integer,List<ABean>> returnBeanListMapIntegerKeys();
+
+ // Typed beans
+ TypedBean returnTypedBean();
+ TypedBean[][][] returnTypedBean3dArray();
+ List<TypedBean> returnTypedBeanList();
+ List<TypedBean[][][]> returnTypedBean1d3dList();
+ Map<String,TypedBean> returnTypedBeanMap();
+ Map<String,List<TypedBean>> returnTypedBeanListMap();
+ Map<String,List<TypedBean[][][]>> returnTypedBean1d3dListMap();
+ Map<Integer,List<TypedBean>> returnTypedBeanListMapIntegerKeys();
+
+ // Swapped POJOs
+ SwappedPojo returnSwappedPojo();
+ SwappedPojo[][][] returnSwappedPojo3dArray();
+ Map<SwappedPojo,SwappedPojo> returnSwappedPojoMap();
+ Map<SwappedPojo,SwappedPojo[][][]> returnSwappedPojo3dMap();
+
+ // Implicit swapped POJOs
+ ImplicitSwappedPojo returnImplicitSwappedPojo();
+ ImplicitSwappedPojo[][][] returnImplicitSwappedPojo3dArray();
+ Map<ImplicitSwappedPojo,ImplicitSwappedPojo>
returnImplicitSwappedPojoMap();
+ Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]>
returnImplicitSwappedPojo3dMap();
+
+ // Enums
+ TestEnum returnEnum();
+ TestEnum[][][] returnEnum3d();
+ List<TestEnum> returnEnumList();
+ List<List<List<TestEnum>>> returnEnum3dList();
+ List<TestEnum[][][]> returnEnum1d3dList();
+ Map<TestEnum,TestEnum> returnEnumMap();
+ Map<TestEnum,TestEnum[][][]> returnEnum3dArrayMap();
+ Map<TestEnum,List<TestEnum[][][]>> returnEnum1d3dListMap();
+
+
//--------------------------------------------------------------------------------
+ // Test server-side exception serialization.
+
//--------------------------------------------------------------------------------
+
+ void throwException1() throws InterfaceProxyException1;
+ void throwException2() throws InterfaceProxyException2;
+
+
//--------------------------------------------------------------------------------
+ // Test parameters
+
//--------------------------------------------------------------------------------
+
+ // Various primitives
+ void setNothing();
+ void setInt(int x);
+ void setInteger(Integer x);
+ void setBoolean(boolean x);
+ void setFloat(float x);
+ void setFloatObject(Float x);
+ void setString(String x);
+ void setNullString(String x);
+ void setInt3dArray(int[][][] x);
+ void setInteger3dArray(Integer[][][] x);
+ void setString3dArray(String[][][] x);
+ void setIntegerList(List<Integer> x);
+ void setInteger3dList(List<List<List<Integer>>> x);
+ void setInteger1d3dList(List<Integer[][][]> x);
+ void setInt1d3dList(List<int[][][]> x);
+ void setStringList(List<String> x);
+
+ // Beans
+ void setBean(ABean x);
+ void setBean3dArray(ABean[][][] x);
+ void setBeanList(List<ABean> x);
+ void setBean1d3dList(List<ABean[][][]> x);
+ void setBeanMap(Map<String,ABean> x);
+ void setBeanListMap(Map<String,List<ABean>> x);
+ void setBean1d3dListMap(Map<String,List<ABean[][][]>> x);
+ void setBeanListMapIntegerKeys(Map<Integer,List<ABean>> x);
+
+ // Typed beans
+ void setTypedBean(TypedBean x);
+ void setTypedBean3dArray(TypedBean[][][] x);
+ void setTypedBeanList(List<TypedBean> x);
+ void setTypedBean1d3dList(List<TypedBean[][][]> x);
+ void setTypedBeanMap(Map<String,TypedBean> x);
+ void setTypedBeanListMap(Map<String,List<TypedBean>> x);
+ void setTypedBean1d3dListMap(Map<String,List<TypedBean[][][]>> x);
+ void setTypedBeanListMapIntegerKeys(Map<Integer,List<TypedBean>> x);
+
+ // Swapped POJOs
+ void setSwappedPojo(SwappedPojo x);
+ void setSwappedPojo3dArray(SwappedPojo[][][] x);
+ void setSwappedPojoMap(Map<SwappedPojo,SwappedPojo> x);
+ void setSwappedPojo3dMap(Map<SwappedPojo,SwappedPojo[][][]> x);
+
+ // Implicit swapped POJOs
+ void setImplicitSwappedPojo(ImplicitSwappedPojo x);
+ void setImplicitSwappedPojo3dArray(ImplicitSwappedPojo[][][] x);
+ void
setImplicitSwappedPojoMap(Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x);
+ void
setImplicitSwappedPojo3dMap(Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]>
x);
+
+ // Enums
+ void setEnum(TestEnum x);
+ void setEnum3d(TestEnum[][][] x);
+ void setEnumList(List<TestEnum> x);
+ void setEnum3dList(List<List<List<TestEnum>>> x);
+ void setEnum1d3dList(List<TestEnum[][][]> x);
+ void setEnumMap(Map<TestEnum,TestEnum> x);
+ void setEnum3dArrayMap(Map<TestEnum,TestEnum[][][]> x);
+ void setEnum1d3dListMap(Map<TestEnum,List<TestEnum[][][]>> x);
+
+
//--------------------------------------------------------------------------------
+ // Test multi-parameters
+
//--------------------------------------------------------------------------------
+
+ void setMultiParamsInts(int x1, int[][][] x2, int[][][] x2n,
List<int[][][]> x3, List<int[][][]> x3n);
+ void setMultiParamsInteger(Integer x1, Integer x1n, Integer[][][] x2,
Integer[][][] x2n, List<Integer[][][]> x3, List<Integer[][][]> x3n);
+ void setMultiParamsFloat(float x1, float[][][] x2, float[][][] x2n,
List<float[][][]> x3, List<float[][][]> x3n);
+ void setMultiParamsFloatObject(Float x1, Float x1n, Float[][][] x2,
Float[][][] x2n, List<Float[][][]> x3, List<Float[][][]> x3n);
+ void setMultiParamsString(String x1, String[][][] x2, String[][][] x2n,
List<String[][][]> x3, List<String[][][]> x3n);
+ void setMultiParamsBean(ABean x1, ABean[][][] x2, ABean[][][] x2n,
List<ABean[][][]> x3, List<ABean[][][]> x3n, Map<String,ABean> x4,
Map<String,ABean> x4n, Map<String,List<ABean[][][]>> x5,
Map<String,List<ABean[][][]>> x5n);
+ void setMultiParamsSwappedPojo(SwappedPojo x1, SwappedPojo[][][] x2,
SwappedPojo[][][] x2n, List<SwappedPojo[][][]> x3, List<SwappedPojo[][][]> x3n,
Map<SwappedPojo,SwappedPojo> x4, Map<SwappedPojo,SwappedPojo> x4n,
Map<SwappedPojo,List<SwappedPojo[][][]>> x5,
Map<SwappedPojo,List<SwappedPojo[][][]>> x5n);
+ void setMultiParamsImplicitSwappedPojo(ImplicitSwappedPojo x1,
ImplicitSwappedPojo[][][] x2, ImplicitSwappedPojo[][][] x2n,
List<ImplicitSwappedPojo[][][]> x3, List<ImplicitSwappedPojo[][][]> x3n,
Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4,
Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4n,
Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5,
Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5n);
+ void setMultiParamsEnum(TestEnum x1, TestEnum[][][] x2, TestEnum[][][]
x2n, List<TestEnum[][][]> x3, List<TestEnum[][][]> x3n, Map<TestEnum,TestEnum>
x4, Map<TestEnum,TestEnum> x4n, Map<TestEnum,List<TestEnum[][][]>> x5,
Map<TestEnum,List<TestEnum[][][]>> x5n);
+
+
//--------------------------------------------------------------------------------
+ // Helper classes
+
//--------------------------------------------------------------------------------
+
+ @SuppressWarnings("serial")
+ public static class InterfaceProxyException1 extends Throwable {
+ public InterfaceProxyException1(String msg) {
+ super(msg);
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class InterfaceProxyException2 extends Throwable {
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxy.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxyResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxyResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxyResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,738 @@
+//
***************************************************************************************************************************
+// * 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 java.util.Arrays.*;
+import static org.apache.juneau.rest.test.TestUtils.*;
+import static org.junit.Assert.*;
+
+import java.util.*;
+
+import org.apache.juneau.json.*;
+import org.apache.juneau.microservice.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.test.pojos.*;
+import org.apache.juneau.utils.*;
+import org.junit.*;
+
+/**
+ * Tests inteface proxies exposed through
<code>@RestMethod(name="PROXY")</code>
+ */
+@RestResource(
+ path="/testInterfaceProxyResource")
+public class InterfaceProxyResource extends ResourceJena {
+ private static final long serialVersionUID = 1L;
+
+
//====================================================================================================
+ // Test that Q-values are being resolved correctly.
+
//====================================================================================================
+ @RestMethod(name="PROXY", path="/proxy/*")
+ public InterfaceProxy getProxy() {
+ return new InterfaceProxy() {
+
+
//--------------------------------------------------------------------------------
+ // Test return types.
+
//--------------------------------------------------------------------------------
+
+ // Various primitives
+
+ @Override
+ public void returnVoid() {
+ }
+
+ @Override
+ public Integer returnInteger() {
+ return 1;
+ }
+
+ @Override
+ public int returnInt() {
+ return 1;
+ }
+
+ @Override
+ public boolean returnBoolean() {
+ return true;
+ }
+
+ @Override
+ public float returnFloat() {
+ return 1f;
+ }
+
+ @Override
+ public Float returnFloatObject() {
+ return 1f;
+ }
+
+ @Override
+ public String returnString() {
+ return "foobar";
+ }
+
+ @Override
+ public String returnNullString() {
+ return null;
+ }
+
+ @Override
+ public int[][][] returnInt3dArray() {
+ return new int[][][]{{{1,2},null},null};
+ }
+
+ @Override
+ public Integer[][][] returnInteger3dArray() {
+ return new Integer[][][]{{{1,null},null},null};
+ }
+
+ @Override
+ public String[][][] returnString3dArray() {
+ return new
String[][][]{{{"foo","bar",null},null},null};
+ }
+
+ @Override
+ public List<Integer> returnIntegerList() {
+ return asList(new Integer[]{1,null});
+ }
+
+ @Override
+ public List<List<List<Integer>>> returnInteger3dList() {
+ return new AList<List<List<Integer>>>()
+ .append(
+ new AList<List<Integer>>()
+ .append(
+ new
AList<Integer>().append(1).append(null)
+ )
+ .append(null)
+ )
+ .append(null);
+ }
+
+ @Override
+ public List<Integer[][][]> returnInteger1d3dList() {
+ return new AList<Integer[][][]>().append(new
Integer[][][]{{{1,null},null},null}).append(null);
+ }
+
+ @Override
+ public List<int[][][]> returnInt1d3dList() {
+ return new AList<int[][][]>().append(new
int[][][]{{{1,2},null},null}).append(null);
+ }
+
+ @Override
+ public List<String> returnStringList() {
+ return asList(new String[]{"foo","bar",null});
+ }
+
+ // Beans
+
+ @Override
+ public ABean returnBean() {
+ return new ABean().init();
+ }
+
+ @Override
+ public ABean[][][] returnBean3dArray() {
+ return new ABean[][][]{{{new
ABean().init(),null},null},null};
+ }
+
+ @Override
+ public List<ABean> returnBeanList() {
+ return asList(new ABean().init());
+ }
+
+ @Override
+ public List<ABean[][][]> returnBean1d3dList() {
+ return new AList<ABean[][][]>().append(new
ABean[][][]{{{new ABean().init(),null},null},null}).append(null);
+ }
+
+ @Override
+ public Map<String,ABean> returnBeanMap() {
+ return new
AMap<String,ABean>().append("foo",new ABean().init());
+ }
+
+ @Override
+ public Map<String,List<ABean>> returnBeanListMap() {
+ return new
AMap<String,List<ABean>>().append("foo",asList(new ABean().init()));
+ }
+
+ @Override
+ public Map<String,List<ABean[][][]>>
returnBean1d3dListMap() {
+ return new
AMap<String,List<ABean[][][]>>().append("foo", new
AList<ABean[][][]>().append(new ABean[][][]{{{new
ABean().init(),null},null},null}).append(null));
+ }
+
+ @Override
+ public Map<Integer,List<ABean>>
returnBeanListMapIntegerKeys() {
+ return new
AMap<Integer,List<ABean>>().append(1,asList(new ABean().init()));
+ }
+
+ // Typed beans
+
+ @Override
+ public TypedBean returnTypedBean() {
+ return new TypedBeanImpl().init();
+ }
+
+ @Override
+ public TypedBean[][][] returnTypedBean3dArray() {
+ return new TypedBean[][][]{{{new
TypedBeanImpl().init(),null},null},null};
+ }
+
+ @Override
+ public List<TypedBean> returnTypedBeanList() {
+ return asList((TypedBean)new
TypedBeanImpl().init());
+ }
+
+ @Override
+ public List<TypedBean[][][]> returnTypedBean1d3dList() {
+ return new AList<TypedBean[][][]>().append(new
TypedBean[][][]{{{new TypedBeanImpl().init(),null},null},null}).append(null);
+ }
+
+ @Override
+ public Map<String,TypedBean> returnTypedBeanMap() {
+ return new
AMap<String,TypedBean>().append("foo",new TypedBeanImpl().init());
+ }
+
+ @Override
+ public Map<String,List<TypedBean>>
returnTypedBeanListMap() {
+ return new
AMap<String,List<TypedBean>>().append("foo",asList((TypedBean)new
TypedBeanImpl().init()));
+ }
+
+ @Override
+ public Map<String,List<TypedBean[][][]>>
returnTypedBean1d3dListMap() {
+ return new
AMap<String,List<TypedBean[][][]>>().append("foo", new
AList<TypedBean[][][]>().append(new TypedBean[][][]{{{new
TypedBeanImpl().init(),null},null},null}).append(null));
+ }
+
+ @Override
+ public Map<Integer,List<TypedBean>>
returnTypedBeanListMapIntegerKeys() {
+ return new
AMap<Integer,List<TypedBean>>().append(1,asList((TypedBean)new
TypedBeanImpl().init()));
+ }
+
+ // Swapped POJOs
+
+ @Override
+ public SwappedPojo returnSwappedPojo() {
+ return new SwappedPojo();
+ }
+
+ @Override
+ public SwappedPojo[][][] returnSwappedPojo3dArray() {
+ return new SwappedPojo[][][]{{{new
SwappedPojo(),null},null},null};
+ }
+
+ @Override
+ public Map<SwappedPojo,SwappedPojo>
returnSwappedPojoMap() {
+ return new
AMap<SwappedPojo,SwappedPojo>().append(new SwappedPojo(), new SwappedPojo());
+ }
+
+ @Override
+ public Map<SwappedPojo,SwappedPojo[][][]>
returnSwappedPojo3dMap() {
+ return new
AMap<SwappedPojo,SwappedPojo[][][]>().append(new SwappedPojo(), new
SwappedPojo[][][]{{{new SwappedPojo(),null},null},null});
+ }
+
+ // Implicit swapped POJOs
+
+ @Override
+ public ImplicitSwappedPojo returnImplicitSwappedPojo() {
+ return new ImplicitSwappedPojo();
+ }
+
+ @Override
+ public ImplicitSwappedPojo[][][]
returnImplicitSwappedPojo3dArray() {
+ return new ImplicitSwappedPojo[][][]{{{new
ImplicitSwappedPojo(),null},null},null};
+ }
+
+ @Override
+ public Map<ImplicitSwappedPojo,ImplicitSwappedPojo>
returnImplicitSwappedPojoMap() {
+ return new
AMap<ImplicitSwappedPojo,ImplicitSwappedPojo>().append(new
ImplicitSwappedPojo(), new ImplicitSwappedPojo());
+ }
+
+ @Override
+ public
Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]>
returnImplicitSwappedPojo3dMap() {
+ return new
AMap<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]>().append(new
ImplicitSwappedPojo(), new ImplicitSwappedPojo[][][]{{{new
ImplicitSwappedPojo(),null},null},null});
+ }
+
+ // Enums
+
+ @Override
+ public TestEnum returnEnum() {
+ return TestEnum.TWO;
+ }
+
+ @Override
+ public TestEnum[][][] returnEnum3d() {
+ return new
TestEnum[][][]{{{TestEnum.TWO,null},null},null};
+ }
+
+ @Override
+ public List<TestEnum> returnEnumList() {
+ return new
AList<TestEnum>().append(TestEnum.TWO).append(null);
+ }
+
+ @Override
+ public List<List<List<TestEnum>>> returnEnum3dList() {
+ return new AList<List<List<TestEnum>>>()
+ .append(
+ new AList<List<TestEnum>>()
+ .append(
+ new
AList<TestEnum>().append(TestEnum.TWO).append(null)
+ )
+ .append(null)
+ .append(null)
+ );
+ }
+
+ @Override
+ public List<TestEnum[][][]> returnEnum1d3dList() {
+ return new AList<TestEnum[][][]>().append(new
TestEnum[][][]{{{TestEnum.TWO,null},null},null}).append(null);
+ }
+
+ @Override
+ public Map<TestEnum,TestEnum> returnEnumMap() {
+ return new
AMap<TestEnum,TestEnum>().append(TestEnum.ONE,TestEnum.TWO);
+ }
+
+ @Override
+ public Map<TestEnum,TestEnum[][][]>
returnEnum3dArrayMap() {
+ return new
AMap<TestEnum,TestEnum[][][]>().append(TestEnum.ONE, new
TestEnum[][][]{{{TestEnum.TWO,null},null},null});
+ }
+
+ @Override
+ public Map<TestEnum,List<TestEnum[][][]>>
returnEnum1d3dListMap() {
+ return new
AMap<TestEnum,List<TestEnum[][][]>>().append(TestEnum.ONE, new
AList<TestEnum[][][]>().append(new
TestEnum[][][]{{{TestEnum.TWO,null},null},null}).append(null));
+ }
+
+
//--------------------------------------------------------------------------------
+ // Test server-side exception serialization.
+
//--------------------------------------------------------------------------------
+
+ @Override
+ public void throwException1() throws
InterfaceProxy.InterfaceProxyException1 {
+ throw new
InterfaceProxy.InterfaceProxyException1("foo");
+ }
+
+ @Override
+ public void throwException2() throws
InterfaceProxy.InterfaceProxyException2 {
+ throw new
InterfaceProxy.InterfaceProxyException2();
+ }
+
+
//--------------------------------------------------------------------------------
+ // Test parameters
+
//--------------------------------------------------------------------------------
+
+ // Various primitives
+
+ @Override
+ public void setNothing() {
+ }
+
+ @Override
+ public void setInt(int x) {
+ assertEquals(1, x);
+ }
+
+ @Override
+ public void setInteger(Integer x) {
+ assertEquals((Integer)1, x);
+ }
+
+ @Override
+ public void setBoolean(boolean x) {
+ assertTrue(x);
+ }
+
+ @Override
+ public void setFloat(float x) {
+ assertTrue(1f == x);
+ }
+
+ @Override
+ public void setFloatObject(Float x) {
+ assertTrue(1f == x);
+ }
+
+ @Override
+ public void setString(String x) {
+ assertEquals("foo", x);
+ }
+
+ @Override
+ public void setNullString(String x) {
+ assertNull(x);
+ }
+
+ @Override
+ public void setInt3dArray(int[][][] x) {
+ assertObjectEquals("[[[1,2],null],null]", x);
+ }
+
+ @Override
+ public void setInteger3dArray(Integer[][][] x) {
+ assertObjectEquals("[[[1,null],null],null]", x);
+ }
+
+ @Override
+ public void setString3dArray(String[][][] x) {
+
assertObjectEquals("[[['foo',null],null],null]", x);
+ }
+
+ @Override
+ public void setIntegerList(List<Integer> x) {
+ assertObjectEquals("[1,null]", x);
+ assertClass(Integer.class, x.get(0));
+ }
+
+ @Override
+ public void setInteger3dList(List<List<List<Integer>>>
x) {
+ assertObjectEquals("[[[1,null],null],null]", x);
+ assertClass(Integer.class,
x.get(0).get(0).get(0));
+ }
+
+ @Override
+ public void setInteger1d3dList(List<Integer[][][]> x) {
+
assertObjectEquals("[[[[1,null],null],null],null]", x);
+ assertClass(Integer[][][].class, x.get(0));
+ assertClass(Integer.class, x.get(0)[0][0][0]);
+ }
+
+ @Override
+ public void setInt1d3dList(List<int[][][]> x) {
+
assertObjectEquals("[[[[1,2],null],null],null]", x);
+ assertClass(int[][][].class, x.get(0));
+ }
+
+ @Override
+ public void setStringList(List<String> x) {
+ assertObjectEquals("['foo','bar',null]", x);
+ }
+
+ // Beans
+
+ @Override
+ public void setBean(ABean x) {
+ assertObjectEquals("{a:1,b:'foo'}", x);
+ }
+
+ @Override
+ public void setBean3dArray(ABean[][][] x) {
+
assertObjectEquals("[[[{a:1,b:'foo'},null],null],null]", x);
+ }
+
+ @Override
+ public void setBeanList(List<ABean> x) {
+ assertObjectEquals("[{a:1,b:'foo'}]", x);
+ }
+
+ @Override
+ public void setBean1d3dList(List<ABean[][][]> x) {
+
assertObjectEquals("[[[[{a:1,b:'foo'},null],null],null],null]", x);
+ }
+
+ @Override
+ public void setBeanMap(Map<String,ABean> x) {
+ assertObjectEquals("{foo:{a:1,b:'foo'}}", x);
+ }
+
+ @Override
+ public void setBeanListMap(Map<String,List<ABean>> x) {
+ assertObjectEquals("{foo:[{a:1,b:'foo'}]}", x);
+ }
+
+ @Override
+ public void
setBean1d3dListMap(Map<String,List<ABean[][][]>> x) {
+
assertObjectEquals("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}", x);
+ }
+
+ @Override
+ public void
setBeanListMapIntegerKeys(Map<Integer,List<ABean>> x) {
+ assertObjectEquals("{'1':[{a:1,b:'foo'}]}", x);
// Note: JsonSerializer serializes key as string.
+ assertClass(Integer.class,
x.keySet().iterator().next());
+ }
+
+ // Typed beans
+
+ @Override
+ public void setTypedBean(TypedBean x) {
+
assertObjectEquals("{_type:'TypedBeanImpl',a:1,b:'foo'}", x);
+ assertClass(TypedBeanImpl.class, x);
+ }
+
+ @Override
+ public void setTypedBean3dArray(TypedBean[][][] x) {
+
assertObjectEquals("[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null]",
x);
+ assertClass(TypedBeanImpl.class, x[0][0][0]);
+ }
+
+ @Override
+ public void setTypedBeanList(List<TypedBean> x) {
+
assertObjectEquals("[{_type:'TypedBeanImpl',a:1,b:'foo'}]", x);
+ assertClass(TypedBeanImpl.class, x.get(0));
+ }
+
+ @Override
+ public void setTypedBean1d3dList(List<TypedBean[][][]>
x) {
+
assertObjectEquals("[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]",
x);
+ assertClass(TypedBeanImpl.class,
x.get(0)[0][0][0]);
+ }
+
+ @Override
+ public void setTypedBeanMap(Map<String,TypedBean> x) {
+
assertObjectEquals("{foo:{_type:'TypedBeanImpl',a:1,b:'foo'}}", x);
+ assertClass(TypedBeanImpl.class, x.get("foo"));
+ }
+
+ @Override
+ public void
setTypedBeanListMap(Map<String,List<TypedBean>> x) {
+
assertObjectEquals("{foo:[{_type:'TypedBeanImpl',a:1,b:'foo'}]}", x);
+ assertClass(TypedBeanImpl.class,
x.get("foo").get(0));
+ }
+
+ @Override
+ public void
setTypedBean1d3dListMap(Map<String,List<TypedBean[][][]>> x) {
+
assertObjectEquals("{foo:[[[[{_type:'TypedBeanImpl',a:1,b:'foo'},null],null],null],null]}",
x);
+ assertClass(TypedBeanImpl.class,
x.get("foo").get(0)[0][0][0]);
+ }
+
+ @Override
+ public void
setTypedBeanListMapIntegerKeys(Map<Integer,List<TypedBean>> x) {
+
assertObjectEquals("{'1':[{_type:'TypedBeanImpl',a:1,b:'foo'}]}", x); // Note:
JsonSerializer serializes key as string.
+ assertClass(TypedBeanImpl.class,
x.get(1).get(0));
+ }
+
+ // Swapped POJOs
+
+ @Override
+ public void setSwappedPojo(SwappedPojo x) {
+ assertTrue(x.wasUnswapped);
+ }
+
+ @Override
+ public void setSwappedPojo3dArray(SwappedPojo[][][] x) {
+
assertObjectEquals("[[['"+SWAP+"',null],null],null]", x);
+ assertTrue(x[0][0][0].wasUnswapped);
+ }
+
+ @Override
+ public void
setSwappedPojoMap(Map<SwappedPojo,SwappedPojo> x) {
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}",
x);
+ Map.Entry<SwappedPojo,SwappedPojo> e =
x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue().wasUnswapped);
+ }
+
+ @Override
+ public void
setSwappedPojo3dMap(Map<SwappedPojo,SwappedPojo[][][]> x) {
+
assertObjectEquals("{'"+SWAP+"':[[['"+SWAP+"',null],null],null]}", x);
+ Map.Entry<SwappedPojo,SwappedPojo[][][]> e =
x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue()[0][0][0].wasUnswapped);
+ }
+
+ // Implicit swapped POJOs
+
+ @Override
+ public void setImplicitSwappedPojo(ImplicitSwappedPojo
x) {
+ assertTrue(x.wasUnswapped);
+ }
+
+ @Override
+ public void
setImplicitSwappedPojo3dArray(ImplicitSwappedPojo[][][] x) {
+
assertObjectEquals("[[['"+SWAP+"',null],null],null]", x);
+ assertTrue(x[0][0][0].wasUnswapped);
+ }
+
+ @Override
+ public void
setImplicitSwappedPojoMap(Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x) {
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}",
x);
+
Map.Entry<ImplicitSwappedPojo,ImplicitSwappedPojo> e =
x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue().wasUnswapped);
+ }
+
+ @Override
+ public void
setImplicitSwappedPojo3dMap(Map<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]>
x) {
+
assertObjectEquals("{'"+SWAP+"':[[['"+SWAP+"',null],null],null]}", x);
+
Map.Entry<ImplicitSwappedPojo,ImplicitSwappedPojo[][][]> e =
x.entrySet().iterator().next();
+ assertTrue(e.getKey().wasUnswapped);
+ assertTrue(e.getValue()[0][0][0].wasUnswapped);
+ }
+
+ // Enums
+
+ @Override
+ public void setEnum(TestEnum x) {
+ assertEquals(TestEnum.TWO, x);
+ }
+
+ @Override
+ public void setEnum3d(TestEnum[][][] x) {
+
assertObjectEquals("[[['TWO',null],null],null]", x);
+ }
+
+ @Override
+ public void setEnumList(List<TestEnum> x) {
+ assertObjectEquals("['TWO',null]", x);
+ assertClass(TestEnum.class, x.get(0));
+ }
+
+ @Override
+ public void setEnum3dList(List<List<List<TestEnum>>> x)
{
+
assertObjectEquals("[[['TWO',null],null,null]]", x);
+ assertClass(TestEnum.class,
x.get(0).get(0).get(0));
+ }
+
+ @Override
+ public void setEnum1d3dList(List<TestEnum[][][]> x) {
+
assertObjectEquals("[[[['TWO',null],null],null],null]", x);
+ assertClass(TestEnum[][][].class, x.get(0));
+ }
+
+ @Override
+ public void setEnumMap(Map<TestEnum,TestEnum> x) {
+ assertObjectEquals("{ONE:'TWO'}", x);
+ Map.Entry<TestEnum,TestEnum> e =
x.entrySet().iterator().next();
+ assertClass(TestEnum.class, e.getKey());
+ assertClass(TestEnum.class, e.getValue());
+ }
+
+ @Override
+ public void
setEnum3dArrayMap(Map<TestEnum,TestEnum[][][]> x) {
+
assertObjectEquals("{ONE:[[['TWO',null],null],null]}", x);
+ Map.Entry<TestEnum,TestEnum[][][]> e =
x.entrySet().iterator().next();
+ assertClass(TestEnum.class, e.getKey());
+ assertClass(TestEnum[][][].class, e.getValue());
+ }
+
+ @Override
+ public void
setEnum1d3dListMap(Map<TestEnum,List<TestEnum[][][]>> x) {
+
assertObjectEquals("{ONE:[[[['TWO',null],null],null],null]}", x);
+ Map.Entry<TestEnum,List<TestEnum[][][]>> e =
x.entrySet().iterator().next();
+ assertClass(TestEnum.class, e.getKey());
+ assertClass(TestEnum[][][].class,
e.getValue().get(0));
+ }
+
+
//--------------------------------------------------------------------------------
+ // Test multi-parameters
+
//--------------------------------------------------------------------------------
+
+ @Override
+ public void setMultiParamsInts(int x1, int[][][] x2,
int[][][] x2n, List<int[][][]> x3, List<int[][][]> x3n) {
+ assertObjectEquals("1", x1);
+ assertObjectEquals("[[[1,2],null],null]", x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[[1,2],null],null],null]", x3);
+ assertClass(int[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsInteger(Integer x1, Integer
x1n, Integer[][][] x2, Integer[][][] x2n, List<Integer[][][]> x3,
List<Integer[][][]> x3n) {
+ assertObjectEquals("1", x1);
+ assertObjectEquals("[[[1,null],null],null]",
x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[[1,null],null],null],null]", x3);
+ assertClass(Integer[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsFloat(float x1, float[][][]
x2, float[][][] x2n, List<float[][][]> x3, List<float[][][]> x3n) {
+ assertObjectEquals("1.0", x1);
+ assertObjectEquals("[[[1.0,2.0],null],null]",
x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[[1.0,2.0],null],null],null]", x3);
+ assertClass(float[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsFloatObject(Float x1, Float
x1n, Float[][][] x2, Float[][][] x2n, List<Float[][][]> x3, List<Float[][][]>
x3n) {
+ assertObjectEquals("1.0", x1);
+ assertObjectEquals("[[[1.0,null],null],null]",
x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[[1.0,null],null],null],null]", x3);
+ assertClass(Float[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsString(String x1,
String[][][] x2, String[][][] x2n, List<String[][][]> x3, List<String[][][]>
x3n) {
+ assertObjectEquals("'foo'", x1);
+
assertObjectEquals("[[['foo',null],null],null]", x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[['foo',null],null],null],null]", x3);
+ assertClass(String[][][].class, x3.get(0));
+ assertNull(x3n);
+ }
+
+ @Override
+ public void setMultiParamsBean(ABean x1, ABean[][][]
x2, ABean[][][] x2n, List<ABean[][][]> x3, List<ABean[][][]> x3n,
Map<String,ABean> x4, Map<String,ABean> x4n, Map<String,List<ABean[][][]>> x5,
Map<String,List<ABean[][][]>> x5n) {
+ assertObjectEquals("{a:1,b:'foo'}", x1);
+
assertObjectEquals("[[[{a:1,b:'foo'},null],null],null]", x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[[{a:1,b:'foo'},null],null],null],null]", x3);
+ assertClass(ABean[][][].class, x3.get(0));
+ assertNull(x3n);
+ assertObjectEquals("{foo:{a:1,b:'foo'}}", x4);
+ assertNull(x4n);
+
assertObjectEquals("{foo:[[[[{a:1,b:'foo'},null],null],null],null]}", x5);
+ assertNull(x5n);
+ }
+
+ @Override
+ public void setMultiParamsSwappedPojo(SwappedPojo x1,
SwappedPojo[][][] x2, SwappedPojo[][][] x2n, List<SwappedPojo[][][]> x3,
List<SwappedPojo[][][]> x3n, Map<SwappedPojo,SwappedPojo> x4,
Map<SwappedPojo,SwappedPojo> x4n, Map<SwappedPojo,List<SwappedPojo[][][]>> x5,
Map<SwappedPojo,List<SwappedPojo[][][]>> x5n) {
+ assertObjectEquals("'"+SWAP+"'", x1);
+
assertObjectEquals("[[['"+SWAP+"',null],null],null]", x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[['"+SWAP+"',null],null],null],null]", x3);
+ assertClass(SwappedPojo[][][].class, x3.get(0));
+ assertNull(x3n);
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}",
x4);
+ assertNull(x4n);
+
assertObjectEquals("{'"+SWAP+"':[[[['"+SWAP+"',null],null],null],null]}", x5);
+ assertNull(x5n);
+ }
+
+ @Override
+ public void
setMultiParamsImplicitSwappedPojo(ImplicitSwappedPojo x1,
ImplicitSwappedPojo[][][] x2, ImplicitSwappedPojo[][][] x2n,
List<ImplicitSwappedPojo[][][]> x3, List<ImplicitSwappedPojo[][][]> x3n,
Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4,
Map<ImplicitSwappedPojo,ImplicitSwappedPojo> x4n,
Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5,
Map<ImplicitSwappedPojo,List<ImplicitSwappedPojo[][][]>> x5n) {
+ assertObjectEquals("'"+SWAP+"'", x1);
+
assertObjectEquals("[[['"+SWAP+"',null],null],null]", x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[['"+SWAP+"',null],null],null],null]", x3);
+ assertClass(ImplicitSwappedPojo[][][].class,
x3.get(0));
+ assertNull(x3n);
+ assertObjectEquals("{'"+SWAP+"':'"+SWAP+"'}",
x4);
+ assertNull(x4n);
+
assertObjectEquals("{'"+SWAP+"':[[[['"+SWAP+"',null],null],null],null]}", x5);
+ assertNull(x5n);
+ }
+
+ @Override
+ public void setMultiParamsEnum(TestEnum x1,
TestEnum[][][] x2, TestEnum[][][] x2n, List<TestEnum[][][]> x3,
List<TestEnum[][][]> x3n, Map<TestEnum,TestEnum> x4, Map<TestEnum,TestEnum>
x4n, Map<TestEnum,List<TestEnum[][][]>> x5, Map<TestEnum,List<TestEnum[][][]>>
x5n) {
+ assertObjectEquals("'TWO'", x1);
+
assertObjectEquals("[[['TWO',null],null],null]", x2);
+ assertNull(x2n);
+
assertObjectEquals("[[[['TWO',null],null],null],null]", x3);
+ assertClass(TestEnum[][][].class, x3.get(0));
+ assertNull(x3n);
+ assertObjectEquals("{ONE:'TWO'}", x4);
+ assertNull(x4n);
+
assertObjectEquals("{ONE:[[[['TWO',null],null],null],null]}", x5);
+ assertNull(x5n);
+ }
+ };
+ }
+
+ private static void assertObjectEquals(String e, Object o) {
+ Assert.assertEquals(e, JsonSerializer.DEFAULT_LAX.toString(o));
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/InterfaceProxyResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojo.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojo.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojo.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,45 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import java.util.*;
+
+/**
+ * A large POJO object.
+ */
+@SuppressWarnings("serial")
+public class LargePojo {
+ public A1Map a1Map;
+ public A1List a1List;
+ public A1[] a1Array;
+
+ public static LargePojo create() {
+ LargePojo a = new LargePojo();
+ a.a1Map = new A1Map();
+ a.a1List = new A1List();
+ for (int i = 0; i < 20000; i++) {
+ a.a1Map.put(String.valueOf(i), new A1());
+ a.a1List.add(new A1());
+ }
+ a.a1Array = a.a1List.toArray(new A1[0]);
+ return a;
+ }
+
+ public static class A1 {
+ public String f1 =
"a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789";
+ }
+
+ public static class A1Map extends LinkedHashMap<String,A1> {}
+
+ public static class A1List extends LinkedList<A1> {}
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojosResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojosResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojosResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,39 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.microservice.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testLargePojos"
+)
+public class LargePojosResource extends ResourceJena {
+ private static final long serialVersionUID = 1L;
+
+
//====================================================================================================
+ // Test how long it takes to serialize/parse various content types.
+
//====================================================================================================
+ @RestMethod(name="GET", path="/")
+ public LargePojo testGet() {
+ return LargePojo.create();
+ }
+
+ @RestMethod(name="PUT", path="/")
+ public String testPut(@Body LargePojo in) {
+ return "ok";
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/LargePojosResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/MessagesResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/MessagesResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/MessagesResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,62 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+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.
+ * Validates that resource bundles can be defined on both parent and child
classes.
+ */
+@RestResource(
+ path="/testMessages",
+ messages="MessagesResource",
+ pojoSwaps={
+ MessagesResource.ResourceBundleSwap.class
+ }
+)
+public class MessagesResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+
//====================================================================================================
+ // Return contents of resource bundle.
+
//====================================================================================================
+ @RestMethod(name="GET", path="/test")
+ public Object test(@Messages ResourceBundle nls) {
+ return nls;
+ }
+
+
+ @SuppressWarnings("serial")
+ @RestResource(
+ path="/testMessages2",
+ messages="Messages2Resource"
+ )
+ public static class Messages2Resource extends MessagesResource {}
+
+ public static class ResourceBundleSwap extends MapSwap<ResourceBundle> {
+ @Override /* Transform */
+ public ObjectMap swap(BeanSession session, ResourceBundle o)
throws SerializeException {
+ ObjectMap m = new ObjectMap();
+ for (String k : o.keySet())
+ m.put(k, o.getString(k));
+ return m;
+ }
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/MessagesResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,71 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.serializer.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testNlsProperty",
+ serializers={NlsPropertyResource.TestSerializer.class},
+ properties={
+ @Property(name="TestProperty",value="$L{key1}")
+ },
+ messages="NlsPropertyResource"
+)
+public class NlsPropertyResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+
//====================================================================================================
+ // Test getting an NLS property defined on a class.
+
//====================================================================================================
+ @RestMethod(name="GET", path="/testInheritedFromClass")
+ public String testInheritedFromClass() {
+ return null;
+ }
+
+
//====================================================================================================
+ // Test getting an NLS property defined on a method.
+
//====================================================================================================
+ @RestMethod(name="GET", path="/testInheritedFromMethod",
+ properties={
+ @Property(name="TestProperty",value="$L{key2}")
+ }
+ )
+ public String testInheritedFromMethod() {
+ return null;
+ }
+
+ public static class TestSerializer extends WriterSerializer {
+
+ public TestSerializer(PropertyStore propertyStore) {
+ super(propertyStore, "text/plain");
+ }
+
+ @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(getStringProperty("TestProperty"));
+ }
+ };
+ }
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,197 @@
+//
***************************************************************************************************************************
+// * 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.*;
+import org.apache.juneau.utils.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testNls",
+ children={
+ NlsResource.Test1.class,
+ NlsResource.Test2.class,
+ NlsResource.Test3.class,
+ NlsResource.Test4.class,
+ NlsResource.Test5.class,
+ NlsResource.Test6.class
+ }
+)
+@SuppressWarnings({"serial"})
+public class NlsResource extends RestServletGroupDefault {
+ private static final long serialVersionUID = 1L;
+
+
//====================================================================================================
+ // test1 - Pull labels from annotations only.
+
//====================================================================================================
+ @RestResource(
+ path="/test1",
+ messages="NlsResource",
+ title="Test1.a",
+ description="Test1.b"
+ )
+ public static class Test1 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}",
+ description="Test1.c",
+ swagger=@MethodSwagger(
+ parameters={
+ @Parameter(in="path", name="a",
description="Test1.d"),
+ @Parameter(in="query", name="b",
description="Test1.e"),
+ @Parameter(in="body",
description="Test1.f"),
+ @Parameter(in="header", name="D",
description="Test1.g"),
+ @Parameter(in="path", name="a2",
description="Test1.h"),
+ @Parameter(in="query", name="b2",
description="Test1.i"),
+ @Parameter(in="header", name="D2",
description="Test1.j"),
+ },
+ responses={
+ @Response(200),
+ @Response(value=201,
+ description="Test1.l",
+ headers={
+ @Parameter(in="foo",
name="bar", description="Test1.m"),
+ }
+ )
+ }
+ )
+ )
+ public String test1(@Path("a") String a, @Query("b") String b,
@Body String c, @Header("D") String d,
+ @Path("e") String e, @Query("f") String f,
@Header("g") String g) {
+ return null;
+ }
+ }
+
+
//====================================================================================================
+ // test2 - Pull labels from resource bundles only - simple keys.
+
//====================================================================================================
+ @RestResource(
+ path="/test2",
+ messages="NlsResource"
+ )
+ public static class Test2 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}"
+ )
+ public String test2(@Path("a") String a, @Query("b") String b,
@Body String c, @Header("D") String d,
+ @Path("e") String e, @Query("f") String f,
@Header("g") String g) {
+ return null;
+ }
+ }
+
+
//====================================================================================================
+ // test3 - Pull labels from resource bundles only - keys with class
names.
+
//====================================================================================================
+ @RestResource(
+ path="/test3",
+ messages="NlsResource"
+ )
+ public static class Test3 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}"
+ )
+ public String test3(@Path("a") String a, @Query("b") String b,
@Body String c, @Header("D") String d,
+ @Path("e") String e, @Query("f") String f,
@Header("g") String g) {
+ return null;
+ }
+
+ @RestMethod(
+ name="GET", path="/"
+ )
+ public Object test3a(@Messages MessageBundle mb) {
+ return mb;
+ }
+ }
+
+
//====================================================================================================
+ // test4 - Pull labels from resource bundles only. Values have
localized variables to resolve.
+
//====================================================================================================
+ @RestResource(
+ path="/test4",
+ messages="NlsResource"
+ )
+ public static class Test4 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}"
+ )
+ public String test4(@Path("a") String a, @Query("b") String b,
@Body String c, @Header("D") String d,
+ @Path("e") String e, @Query("f") String f,
@Header("g") String g) {
+ return null;
+ }
+ }
+
+
//====================================================================================================
+ // test5 - Pull labels from resource bundles only. Values have request
variables to resolve.
+
//====================================================================================================
+ @RestResource(
+ path="/test5",
+ messages="NlsResource"
+ )
+ public static class Test5 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}"
+ )
+ public String test5(@Path("a") String a, @Query("b") String b,
@Body String c, @Header("D") String d,
+ @Path("e") String e, @Query("f") String f,
@Header("g") String g) {
+ return null;
+ }
+ }
+
+
//====================================================================================================
+ // test6 - Pull labels from annotations only, but annotations contain
variables.
+
//====================================================================================================
+ @RestResource(
+ path="/test6",
+ messages="NlsResource",
+ title="$L{foo}",
+ description="$L{foo}"
+ )
+ public static class Test6 extends RestServletDefault {
+
+ @RestMethod(
+ name="POST", path="/{a}",
+ description="$L{foo}",
+ swagger=@MethodSwagger(
+ parameters={
+ @Parameter(in="path", name="a",
description="$L{foo}"),
+ @Parameter(in="query", name="b",
description="$L{foo}"),
+ @Parameter(in="body",
description="$L{foo}"),
+ @Parameter(in="header", name="D",
description="$L{foo}"),
+ @Parameter(in="path", name="a2",
description="$L{foo}"),
+ @Parameter(in="query", name="b2",
description="$L{foo}"),
+ @Parameter(in="header", name="D2",
description="$L{foo}")
+ },
+ responses={
+ @Response(200),
+ @Response(value=201,
+ description="$L{foo}",
+ headers={
+ @Parameter(in="foo",
name="bar", description="$L{foo}"),
+ }
+ )
+ }
+ )
+ )
+ public String test6(@Path("a") String a, @Query("b") String b,
@Body String c, @Header("D") String d,
+ @Path("e") String e, @Query("f") String f,
@Header("g") String g) {
+ return null;
+ }
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NoParserInputResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NoParserInputResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NoParserInputResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,57 @@
+//
***************************************************************************************************************************
+// * 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.plaintext.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testNoParserInput",
+ serializers=PlainTextSerializer.class
+)
+public class NoParserInputResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+
//====================================================================================================
+ // @Body annotated InputStream.
+
//====================================================================================================
+ @RestMethod(name="PUT", path="/testInputStream")
+ public String testInputStream(@Body InputStream in) throws Exception {
+ return read(in);
+ }
+
+
//====================================================================================================
+ // @Body annotated Reader.
+
//====================================================================================================
+ @RestMethod(name="PUT", path="/testReader")
+ public String testReader(@Body Reader in) throws Exception {
+ return read(in);
+ }
+
+
//====================================================================================================
+ // @Body annotated PushbackReader.
+ // This should always fail since the servlet reader is not a pushback
reader.
+
//====================================================================================================
+ @RestMethod(name="PUT", path="/testPushbackReader")
+ public String testPushbackReader(@Body PushbackReader in) throws
Exception {
+ return read(in);
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NoParserInputResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,110 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import static org.apache.juneau.rest.annotation.HookEvent.*;
+
+import java.util.*;
+
+import org.apache.juneau.*;
+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.utils.*;
+
+/**
+ * JUnit automated testcase resource.
+ * Validates that headers
+ */
+@RestResource(
+ path="/testOnPostCall",
+ serializers=OnPostCallResource.TestSerializer.class,
+ properties={
+ @Property(name="p1",value="sp1"), // Unchanged servlet-level
property.
+ @Property(name="p2",value="sp2"), // Servlet-level property
overridden by onPostCall.
+ @Property(name="p3",value="sp3"), // Servlet-level property
overridded by method.
+ @Property(name="p4",value="sp4") // Servlet-level property
overridden by method then onPostCall.
+ }
+)
+public class OnPostCallResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ public static class TestSerializer extends WriterSerializer {
+
+ public TestSerializer(PropertyStore propertyStore) {
+ super(propertyStore, "test/s1", "text/s1", "text/s2",
"text/s3");
+ }
+
+ @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("p1="+getStringProperty("p1")+",p2="+getStringProperty("p2")+",p3="+getStringProperty("p3")+",p4="+getStringProperty("p4")+",p5="+getStringProperty("p5")+",contentType="+getStringProperty("mediaType"));
+ }
+
+ @Override /* SerializerSession */
+ public Map<String,String> getResponseHeaders() {
+ ObjectMap p = getProperties();
+ if
(p.containsKey("Override-Content-Type"))
+ return new
AMap<String,String>().append("Content-Type",
p.getString("Override-Content-Type"));
+ return Collections.emptyMap();
+ }
+ };
+ }
+ }
+
+ @RestHook(POST_CALL)
+ public void onPostCall(RestRequest req, RestResponse res) {
+ ObjectMap properties = req.getProperties();
+ properties.put("p2", "xp2");
+ properties.put("p4", "xp4");
+ properties.put("p5", "xp5"); // New property
+ String overrideAccept = req.getHeader("Override-Accept");
+ if (overrideAccept != null)
+ req.getHeaders().put("Accept", overrideAccept);
+ String overrideContentType =
req.getHeader("Override-Content-Type");
+ if (overrideContentType != null)
+ properties.put("Override-Content-Type",
overrideContentType);
+ }
+
+
+
//====================================================================================================
+ // Test1 - Properties overridden via properties annotation.
+
//====================================================================================================
+ @RestMethod(name="PUT", path="/testPropertiesOverridenByAnnotation",
+ properties={
+ @Property(name="p3",value="mp3"),
+ @Property(name="p4",value="mp4")
+ },
+ defaultRequestHeaders="Accept: text/s2"
+ )
+ public String testPropertiesOverridenByAnnotation() {
+ return "";
+ }
+
+
//====================================================================================================
+ // Test2 - Properties overridden programmatically.
+
//====================================================================================================
+ @RestMethod(name="PUT", path="/testPropertiesOverriddenProgramatically")
+ public String testPropertiesOverriddenProgramatically(RestRequest req,
@Properties ObjectMap properties) throws Exception {
+ properties.put("p3", "pp3");
+ properties.put("p4", "pp4");
+ String accept = req.getHeader("Accept");
+ if (accept == null || accept.isEmpty())
+ req.getHeaders().put("Accept", "text/s2");
+ return "";
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OnPostCallResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,95 @@
+//
***************************************************************************************************************************
+// * 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.HookEvent.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ * Validates that headers
+ */
+@RestResource(
+ path="/testOnPreCall",
+ parsers=OnPreCallResource.TestParserA.class,
+ serializers=PlainTextSerializer.class,
+ properties={
+ @Property(name="p1",value="sp1"), // Unchanged servlet-level
property.
+ @Property(name="p2",value="sp2"), // Servlet-level property
overridden by onPreCall.
+ @Property(name="p3",value="sp3"), // Servlet-level property
overridded by method.
+ @Property(name="p4",value="sp4") // Servlet-level property
overridden by method then onPreCall.
+ }
+)
+public class OnPreCallResource extends RestServlet {
+ private static final long serialVersionUID = 1L;
+
+ public static class TestParserA extends ReaderParser {
+
+ public TestParserA(PropertyStore propertyStore) {
+ super(propertyStore, "text/a1", "text/a2", "text/a3");
+ }
+
+ @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 {
+ String matchingContentType =
getStringProperty("mediaType");
+ return
(T)("p1="+getStringProperty("p1")+",p2="+getStringProperty("p2")+",p3="+getStringProperty("p3")+",p4="+getStringProperty("p4")+",p5="+getStringProperty("p5")+",contentType="+matchingContentType);
+ }
+ };
+ }
+ }
+
+ @RestHook(PRE_CALL)
+ public void onPreCall(RestRequest req) {
+ ObjectMap properties = req.getProperties();
+ properties.put("p2", "xp2");
+ properties.put("p4", "xp4");
+ properties.put("p5", "xp5"); // New property
+ String overrideContentType =
req.getHeader("Override-Content-Type");
+ if (overrideContentType != null)
+ req.getHeaders().put("Content-Type",
overrideContentType);
+ }
+
+
+
//====================================================================================================
+ // Properties overridden via properties annotation.
+
//====================================================================================================
+ @RestMethod(name="PUT", path="/testPropertiesOverriddenByAnnotation",
+ properties={
+ @Property(name="p3",value="mp3"),
+ @Property(name="p4",value="mp4")
+ }
+ )
+ public String testPropertiesOverriddenByAnnotation(@Body String in) {
+ return in;
+ }
+
+
//====================================================================================================
+ // Properties overridden programmatically.
+
//====================================================================================================
+ @RestMethod(name="PUT",
path="/testPropertiesOverriddenProgrammatically")
+ public String testPropertiesOverriddenProgrammatically(RestRequest req,
@Properties ObjectMap properties) throws Exception {
+ properties.put("p3", "pp3");
+ properties.put("p4", "pp4");
+ return req.getBody().asType(String.class);
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OnPreCallResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OptionsWithoutNlsResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OptionsWithoutNlsResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OptionsWithoutNlsResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,44 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.dto.swagger.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testOptionsWithoutNls"
+)
+public class OptionsWithoutNlsResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+
//====================================================================================================
+ // Should get to the options page without errors
+
//====================================================================================================
+ @RestMethod(name="OPTIONS", path="/testOptions/*")
+ public Swagger testOptions(RestRequest req) {
+ return req.getSwagger();
+ }
+
+
//====================================================================================================
+ // Missing resource bundle should cause {!!x} string.
+
//====================================================================================================
+ @RestMethod(name="GET", path="/testMissingResourceBundle")
+ public String test(RestRequest req) {
+ return req.getMessage("bad", 1, 2, 3);
+ }
+
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OptionsWithoutNlsResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OverlappingMethodsResource.java
==============================================================================
---
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OverlappingMethodsResource.java
(added)
+++
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OverlappingMethodsResource.java
Fri Sep 8 23:21:12 2017
@@ -0,0 +1,146 @@
+//
***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
+// * with the License. You may obtain a copy of the License at
*
+// *
*
+// * http://www.apache.org/licenses/LICENSE-2.0
*
+// *
*
+// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
+// * specific language governing permissions and limitations under the
License. *
+//
***************************************************************************************************************************
+package org.apache.juneau.rest.test;
+
+import org.apache.juneau.plaintext.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+
+/**
+ * JUnit automated testcase resource.
+ */
+@RestResource(
+ path="/testOverlappingMethods",
+ serializers=PlainTextSerializer.class
+)
+public class OverlappingMethodsResource extends RestServletDefault {
+ private static final long serialVersionUID = 1L;
+
+
//====================================================================================================
+ // Overlapping guards
+
//====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingGuards1",
guards=Test1Guard.class)
+ public String testOverlappingGuards1() {
+ return "test1_doGet";
+ }
+
+
//====================================================================================================
+ // Overlapping guards
+
//====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingGuards2",
guards={Test1Guard.class, Test2Guard.class})
+ public String testOverlappingGuards2() {
+ return "test2_doGet";
+ }
+
+ public static class Test1Guard extends RestGuard {
+ @Override /* RestGuard */
+ public boolean isRequestAllowed(RestRequest req) {
+ return req.getQuery().getString("t1","").equals("1");
+ }
+ }
+
+ public static class Test2Guard extends RestGuard {
+ @Override /* RestGuard */
+ public boolean isRequestAllowed(RestRequest req) {
+ return req.getQuery().getString("t2","").equals("2");
+ }
+ }
+
+
//====================================================================================================
+ // Overlapping matchers
+
//====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingMatchers1",
matchers=Test3aMatcher.class)
+ public String testOverlappingMatchers1() {
+ return "test3a";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingMatchers1",
matchers=Test3bMatcher.class)
+ public String test3b_doGet() {
+ return "test3b";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingMatchers1")
+ public String test3c_doGet() {
+ return "test3c";
+ }
+
+ public static class Test3aMatcher extends RestMatcher {
+ @Override /* RestMatcher */
+ public boolean matches(RestRequest req) {
+ return req.getQuery().getString("t1","").equals("1");
+ }
+ }
+
+ public static class Test3bMatcher extends RestMatcher {
+ @Override /* RestMatcher */
+ public boolean matches(RestRequest req) {
+ return req.getQuery().getString("t2","").equals("2");
+ }
+ }
+
+
//====================================================================================================
+ // Overlapping matchers
+
//====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingMatchers2")
+ public String test4a_doGet() {
+ return "test4a";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingMatchers2",
matchers={Test3aMatcher.class, Test3bMatcher.class})
+ public String test4b_doGet() {
+ return "test4b";
+ }
+
+
//====================================================================================================
+ // Overlapping URL patterns
+
//====================================================================================================
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns")
+ public String testOverlappingUrlPatterns1() {
+ return "test5a";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/*")
+ public String testOverlappingUrlPatterns2() {
+ return "test5b";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/foo")
+ public String testOverlappingUrlPatterns3() {
+ return "test5c";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/foo/*")
+ public String testOverlappingUrlPatterns4() {
+ return "test5d";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}")
+ public String testOverlappingUrlPatterns5() {
+ return "test5e";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/*")
+ public String testOverlappingUrlPatterns6() {
+ return "test5f";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/foo")
+ public String testOverlappingUrlPatterns7() {
+ return "test5g";
+ }
+
+ @RestMethod(name="GET", path="/testOverlappingUrlPatterns/{id}/foo/*")
+ public String testOverlappingUrlPatterns8() {
+ return "test5h";
+ }
+}
Propchange:
release/incubator/juneau/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/OverlappingMethodsResource.java
------------------------------------------------------------------------------
svn:mime-type = text/plain