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 24f02e3 Tests.
24f02e3 is described below
commit 24f02e3174c521ea92cf4cd776bdeb77b5bfe34c
Author: JamesBognar <[email protected]>
AuthorDate: Sun May 13 15:16:46 2018 -0400
Tests.
---
.../org/apache/juneau/rest/test/NlsResource.java | 189 ---------------------
.../java/org/apache/juneau/rest/test/Root.java | 2 -
.../apache/juneau/rest/test/NlsResource.properties | 86 ----------
.../apache/juneau/rest/test/NlsPropertyTest.java | 43 -----
.../java/org/apache/juneau/rest/test/NlsTest.java | 98 -----------
.../org/apache/juneau/rest/test/_TestSuite.java | 2 -
.../test/java/org/apache/juneau/rest/NlsTest.java | 69 ++++----
.../org/apache/juneau/rest/NlsTest.properties | 0
8 files changed, 37 insertions(+), 452 deletions(-)
diff --git
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsResource.java
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsResource.java
deleted file mode 100644
index eead39d..0000000
---
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsResource.java
+++ /dev/null
@@ -1,189 +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 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 BasicRestServletGroup {
- 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 BasicRestServlet {
-
- @RestMethod(
- name=POST, path="/{a}",
- description="Test1.c",
- swagger=@MethodSwagger(
- parameters={
-
"{name:'a',in:'path',type:'string',description:'Test1.d'},",
-
"{name:'b',in:'query',type:'string',description:'Test1.e'},",
-
"{in:'body',type:'string',description:'Test1.f'},",
-
"{name:'D',in:'header',type:'string',description:'Test1.g'},",
-
"{name:'a2',in:'path',type:'string',description:'Test1.h'},",
-
"{name:'b2',in:'query',type:'string',description:'Test1.i'},",
-
"{name:'D2',in:'header',type:'string',description:'Test1.j'}",
- },
- responses={
- "200: {description:'OK'},",
- "201:
{description:'Test1.l',headers:{bar:{description:'Test1.m',type:'string'}}}",
- }
- )
- )
- 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 BasicRestServlet {
-
- @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 BasicRestServlet {
-
- @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(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 BasicRestServlet {
-
- @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 BasicRestServlet {
-
- @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 BasicRestServlet {
-
- @RestMethod(
- name=POST, path="/{a}",
- description="$L{foo}",
- swagger=@MethodSwagger(
- parameters={
-
"{name:'a',in:'path',description:'$L{foo}'},",
-
"{name:'b',in:'query',description:'$L{foo}'},",
- "{in:'body',description:'$L{foo}'},",
-
"{name:'D',in:'header',description:'$L{foo}'},",
-
"{name:'a2',in:'path',description:'$L{foo}'},",
-
"{name:'b2',in:'query',description:'$L{foo}'},",
-
"{name:'D2',in:'header',description:'$L{foo}'}"
- },
- responses= {
- "200: {description:'OK'},",
- "201:
{description:'$L{foo}',headers:{bar:{description:'$L{foo}',type:'string'}}}",
- }
- )
- )
- 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;
- }
- }
-}
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 2755109..cdfc172 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
@@ -35,8 +35,6 @@ import org.apache.juneau.rest.test.client.*;
HtmlDocLinksResource.class,
InterfaceProxyResource.class,
LargePojosResource.class,
- NlsResource.class,
- NlsPropertyResource.class,
OnPostCallResource.class,
OnPreCallResource.class,
OptionsWithoutNlsResource.class,
diff --git
a/juneau-microservice/juneau-microservice-test/src/main/resources/org/apache/juneau/rest/test/NlsResource.properties
b/juneau-microservice/juneau-microservice-test/src/main/resources/org/apache/juneau/rest/test/NlsResource.properties
deleted file mode 100644
index bb638b5..0000000
---
a/juneau-microservice/juneau-microservice-test/src/main/resources/org/apache/juneau/rest/test/NlsResource.properties
+++ /dev/null
@@ -1,86 +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.
*
-# *
*
-#
***************************************************************************************************************************
-
-title = Test2.a
-description = Test2.b
-test2.summary = Test2.c
-test2.parameters = [\
- {in:"path",name:"a",description:"Test2.d"},\
- {in:"query",name:"b",description:"Test2.e"},\
- {in:"body",description:"Test2.f"},\
- {in:"header",name:"D",description:"Test2.g"},\
- {in:"path",name:"a2",description:"Test2.h"},\
- {in:"query",name:"b2",description:"Test2.i"},\
- {in:"header",name:"D2",description:"Test2.j"}\
- ]
-test2.responses = {\
- 200:{description:"OK2"},\
- 201:{description:"Test2.l"}\
- }
-
-Test3.title = Test3.a
-Test3.description = Test3.b
-Test3.test3.summary = Test3.c
-test3.parameters = [\
- {in:"path",name:"a",description:"Test3.d"},\
- {in:"query",name:"b",description:"Test3.e"},\
- {in:"body",description:"Test3.f"},\
- {in:"header",name:"D",description:"Test3.g"},\
- {in:"path",name:"a2",description:"Test3.h"},\
- {in:"query",name:"b2",description:"Test3.i"},\
- {in:"header",name:"D2",description:"Test3.j"}\
- ]
-test3.responses = {\
- 200:{description:"OK3"},\
- 201:{description:"Test3.l"}\
- }
-
-Test4.title = $L{foo}
-Test4.description = $L{foo}
-test4.parameters = [\
- {in:"path",name:"a",description:"$L{foo}"},\
- {in:"query",name:"b",description:"$L{foo}"},\
- {in:"body",description:"$L{foo}"},\
- {in:"header",name:"D",description:"$L{foo}"},\
- {in:"path",name:"a2",description:"$L{foo}"},\
- {in:"query",name:"b2",description:"$L{foo}"},\
- {in:"header",name:"D2",description:"$L{foo}"}\
- ]
-test4.responses = {\
- 200:{description:"foo$L{foo}foo$L{foo}foo"},\
- 201:{description:"$L{foo}"}\
- }
-
-foo = $L{bar}
-bar = baz
-
-Test5.title = $L{foo2}
-Test5.description = $R{resourceTitle}
-Test5.test5.summary = $R{resourceTitle}
-test5.parameters = [\
- {in:"path",name:"a",description:"$R{resourceTitle}"},\
- {in:"query",name:"b",description:"$R{resourceTitle}"},\
- {in:"body",description:"$R{resourceTitle}"},\
- {in:"header",name:"D",description:"$R{resourceTitle}"},\
- {in:"path",name:"a2",description:"$R{resourceTitle}"},\
- {in:"query",name:"b2",description:"$R{resourceTitle}"},\
- {in:"header",name:"D2",description:"$R{resourceTitle}"}\
- ]
-test5.responses = {\
-
200:{description:"foo$R{resourceTitle}foo$R{resourceTitle}foo"},\
- 201:{description:"$R{resourceTitle}"}\
- }
-Test5.foo2 = $L{bar2}
-Test5.bar2 = baz2
-
diff --git
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsPropertyTest.java
b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsPropertyTest.java
deleted file mode 100644
index 55b0272..0000000
---
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsPropertyTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.rest.test;
-
-import static org.junit.Assert.*;
-
-import org.apache.juneau.rest.client.*;
-import org.junit.*;
-
-public class NlsPropertyTest extends RestTestcase {
-
- private static String URL = "/testNlsProperty";
-
-
//====================================================================================================
- // Test getting an NLS property defined on a class.
-
//====================================================================================================
- @Test
- public void testInheritedFromClass() throws Exception {
- RestClient client = TestMicroservice.DEFAULT_CLIENT_PLAINTEXT;
- String r = client.doGet(URL +
"/testInheritedFromClass").getResponseAsString();
- assertEquals("value1", r);
- }
-
-
//====================================================================================================
- // Test getting an NLS property defined on a method.
-
//====================================================================================================
- @Test
- public void testInheritedFromMethod() throws Exception {
- RestClient client = TestMicroservice.DEFAULT_CLIENT_PLAINTEXT;
- String r = client.doGet(URL +
"/testInheritedFromMethod").getResponseAsString();
- assertEquals("value2", r);
- }
-}
diff --git
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsTest.java
b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsTest.java
deleted file mode 100644
index 8528fe7..0000000
---
a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/NlsTest.java
+++ /dev/null
@@ -1,98 +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.rest.testutils.TestUtils.*;
-
-import org.apache.juneau.dto.swagger.*;
-import org.apache.juneau.rest.client.*;
-import org.junit.*;
-
-@Ignore // TODO - These are in flux during Swagger development.
-public class NlsTest extends RestTestcase {
-
- private static String URL = "/testNls";
- private RestClient client = TestMicroservice.DEFAULT_CLIENT;
-
- //
====================================================================================================
- // test1 - Pull labels from annotations only.
- //
====================================================================================================
- @Test
- public void test1() throws Exception {
-
- Swagger s = client.doOptions(URL +
"/test1").getResponse(Swagger.class);
- assertObjectEquals("{title:'Test1.a',description:'Test1.b'}",
s.getInfo());
-
assertObjectEquals("[{'in':'path',name:'a',type:'string',description:'Test1.d',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'query',name:'b',type:'string',description:'Test1.e',schema:{description:'java.lang.String',type:'string'}},{'in':'body',type:'string',description:'Test1.f',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'header',name:'D',type:'string',description:'Test1.g',schema:{description:'java.lang.String',type:'strin
[...]
-
assertObjectEquals("{'200':{description:'OK',schema:{description:'java.lang.String',type:'string'}},'201':{description:'Test1.l',headers:{bar:{description:'Test1.m',type:'string'}}}}",
s.getPaths().get("/{a}").get("post").getResponses());
- }
-
- //
====================================================================================================
- // test2 - Pull labels from resource bundles only - simple keys.
- //
====================================================================================================
- @Test
- public void test2() throws Exception {
-
- Swagger s = client.doOptions(URL +
"/test2").getResponse(Swagger.class);
- assertObjectEquals("{title:'Test2.a',description:'Test2.b'}",
s.getInfo());
-
assertObjectEquals("[{'in':'path',name:'a',description:'Test2.d',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'query',name:'b',description:'Test2.e',schema:{description:'java.lang.String',type:'string'}},{'in':'body',description:'Test2.f',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'header',name:'D',description:'Test2.g',schema:{description:'java.lang.String',type:'string'}},{'in':'path',name:'a2',description:'Test2.h',requir
[...]
-
assertObjectEquals("{'200':{description:'OK2',schema:{description:'java.lang.String',type:'string'}},'201':{description:'Test2.l'}}",
s.getPaths().get("/{a}").get("post").getResponses());
- }
-
- //
====================================================================================================
- // test3 - Pull labels from resource bundles only - keys with class
names.
- //
====================================================================================================
- @Test
- public void test3() throws Exception {
-
- Swagger s = client.doOptions(URL +
"/test3").getResponse(Swagger.class);
- assertObjectEquals("{title:'Test3.a',description:'Test3.b'}",
s.getInfo());
-
assertObjectEquals("[{'in':'path',name:'a',description:'Test3.d',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'query',name:'b',description:'Test3.e',schema:{description:'java.lang.String',type:'string'}},{'in':'body',description:'Test3.f',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'header',name:'D',description:'Test3.g',schema:{description:'java.lang.String',type:'string'}},{'in':'path',name:'a2',description:'Test3.h',requir
[...]
-
assertObjectEquals("{'200':{description:'OK3',schema:{description:'java.lang.String',type:'string'}},'201':{description:'Test3.l'}}",
s.getPaths().get("/{a}").get("post").getResponses());
- }
-
- //
====================================================================================================
- // test4 - Pull labels from resource bundles only. Values have
localized variables to resolve.
- //
====================================================================================================
- @Test
- public void test4() throws Exception {
-
- Swagger s = client.doOptions(URL +
"/test4").getResponse(Swagger.class);
- assertObjectEquals("{title:'baz',description:'baz'}",
s.getInfo());
-
assertObjectEquals("[{'in':'path',name:'a',description:'baz',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'query',name:'b',description:'baz',schema:{description:'java.lang.String',type:'string'}},{'in':'body',description:'baz',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'header',name:'D',description:'baz',schema:{description:'java.lang.String',type:'string'}},{'in':'path',name:'a2',description:'baz',required:true},{'in':'quer
[...]
-
assertObjectEquals("{'200':{description:'foobazfoobazfoo',schema:{description:'java.lang.String',type:'string'}},'201':{description:'baz'}}",
s.getPaths().get("/{a}").get("post").getResponses());
- }
-
- //
====================================================================================================
- // test5 - Pull labels from resource bundles only. Values have request
variables to resolve.
- //
====================================================================================================
- @Test
- public void test5() throws Exception {
-
- Swagger s = client.doOptions(URL +
"/test5").getResponse(Swagger.class);
- assertObjectEquals("{title:'baz2',description:'baz2'}",
s.getInfo());
-
assertObjectEquals("[{'in':'path',name:'a',description:'baz2',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'query',name:'b',description:'baz2',schema:{description:'java.lang.String',type:'string'}},{'in':'body',description:'baz2',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'header',name:'D',description:'baz2',schema:{description:'java.lang.String',type:'string'}},{'in':'path',name:'a2',description:'baz2',required:true},{'in':
[...]
-
assertObjectEquals("{'200':{description:'foobaz2foobaz2foo',schema:{description:'java.lang.String',type:'string'}},'201':{description:'baz2'}}",
s.getPaths().get("/{a}").get("post").getResponses());
- }
-
- //
====================================================================================================
- // test6 - Pull labels from annotations only, but annotations contain
variables.
- //
====================================================================================================
- @Test
- public void test6() throws Exception {
-
- Swagger s = client.doOptions(URL +
"/test6").getResponse(Swagger.class);
- assertObjectEquals("{title:'baz',description:'baz'}",
s.getInfo());
-
assertObjectEquals("[{'in':'path',name:'a',description:'baz',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'query',name:'b',description:'baz',schema:{description:'java.lang.String',type:'string'}},{'in':'body',description:'baz',required:true,schema:{description:'java.lang.String',type:'string'}},{'in':'header',name:'D',description:'baz',schema:{description:'java.lang.String',type:'string'}},{'in':'path',name:'a2',description:'baz',required:true},{'in':'quer
[...]
-
assertObjectEquals("{'200':{description:'OK',schema:{description:'java.lang.String',type:'string'}},'201':{description:'baz',headers:{bar:{description:'baz',type:'string'}}}}",
s.getPaths().get("/{a}").get("post").getResponses());
- }
-}
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 8cd9329..eb14165 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
@@ -34,8 +34,6 @@ import org.junit.runners.Suite.*;
InterfaceProxyTest.class,
JacocoDummyTest.class,
LargePojosTest.class,
- NlsPropertyTest.class,
- NlsTest.class,
OnPostCallTest.class,
OnPreCallTest.class,
OptionsWithoutNlsTest.class,
diff --git
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/NlsTest.java
similarity index 65%
rename from
juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
rename to
juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/NlsTest.java
index d8e4f5d..c62b6e9 100644
---
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/NlsPropertyResource.java
+++
b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/NlsTest.java
@@ -10,59 +10,54 @@
// * "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;
+package org.apache.juneau.rest;
import static org.apache.juneau.http.HttpMethodName.*;
import org.apache.juneau.*;
-import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.mock.*;
import org.apache.juneau.serializer.*;
+import org.junit.*;
+import org.junit.runners.*;
/**
- * JUnit automated testcase resource.
+ * Tests various aspects of localization support.
*/
-@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;
+@SuppressWarnings({"javadoc"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class NlsTest {
//====================================================================================================
- // Test getting an NLS property defined on a class.
+ // Test getting an NLS property defined on a class or method.
//====================================================================================================
- @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}")
- }
+ @RestResource(
+ serializers={A01.class},
+ properties={@Property(name="TestProperty",value="$L{key1}")},
+ messages="NlsTest"
)
- public String testInheritedFromMethod() {
- return null;
+ public static class A {
+ @RestMethod(name=GET, path="/fromClass")
+ public String a01() {
+ return null;
+ }
+ @RestMethod(name=GET, path="/fromMethod",
+
properties={@Property(name="TestProperty",value="$L{key2}")}
+ )
+ public String a02() {
+ return null;
+ }
}
+ static MockRest a = MockRest.create(A.class);
- public static class TestSerializer extends WriterSerializer {
-
- public TestSerializer(PropertyStore ps) {
+ public static class A01 extends WriterSerializer {
+ public A01(PropertyStore ps) {
super(ps, "text/plain", 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(getProperty("TestProperty", String.class));
@@ -70,4 +65,14 @@ public class NlsPropertyResource extends RestServlet {
};
}
}
+
+ @Test
+ public void a01_fromClass() throws Exception {
+ a.request("GET", "/fromClass").execute().assertBody("value1");
+ }
+
+ @Test
+ public void a02_fromMethod() throws Exception {
+ a.request("GET", "/fromMethod").execute().assertBody("value2");
+ }
}
diff --git
a/juneau-microservice/juneau-microservice-test/src/main/resources/org/apache/juneau/rest/test/NlsPropertyResource.properties
b/juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/NlsTest.properties
similarity index 100%
rename from
juneau-microservice/juneau-microservice-test/src/main/resources/org/apache/juneau/rest/test/NlsPropertyResource.properties
rename to
juneau-rest/juneau-rest-server/src/test/resources/org/apache/juneau/rest/NlsTest.properties
--
To stop receiving notification emails like this one, please contact
[email protected].