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 3683257  Javadocs.
3683257 is described below

commit 3683257087778bd40b9857888a209e29fa527d59
Author: JamesBognar <[email protected]>
AuthorDate: Thu Jul 23 12:30:13 2020 -0400

    Javadocs.
---
 juneau-doc/docs/Topics/09.juneau-rest-client.html  |  2 +-
 .../09.juneau-rest-client/01.PojoMarshalling.html  | 10 ++-
 .../09.juneau-rest-client/02.RequestHeaders.html   |  4 +-
 .../03.RequestQueryParameters.html                 |  4 +-
 .../09.juneau-rest-client/04.RequestFormData.html  |  4 +-
 .../10.juneau-rest-mock/01.MockRestClient.html     | 84 +++++++++++++++-------
 6 files changed, 74 insertions(+), 34 deletions(-)

diff --git a/juneau-doc/docs/Topics/09.juneau-rest-client.html 
b/juneau-doc/docs/Topics/09.juneau-rest-client.html
index f81c624..68d8702 100644
--- a/juneau-doc/docs/Topics/09.juneau-rest-client.html
+++ b/juneau-doc/docs/Topics/09.juneau-rest-client.html
@@ -81,7 +81,7 @@ juneau-rest-client
        <ja>@Remote</ja>(path=<js>"/petstore"</js>)
        <jk>public interface</jk> PetStore {
        
-               <ja>@RemoteMethod</ja>(httpMethod=<jsf>POST</jsf>, 
path=<js>"/pets"</js>)
+               <ja>@RemoteMethod</ja>(method=<jsf>POST</jsf>, 
path=<js>"/pets"</js>)
                Pet addPet(
                        <ja>@Body</ja> CreatePet <jv>pet</jv>,
                        <ja>@Header</ja>(<js>"E-Tag"</js>) UUID <jv>etag</jv>,
diff --git 
a/juneau-doc/docs/Topics/09.juneau-rest-client/01.PojoMarshalling.html 
b/juneau-doc/docs/Topics/09.juneau-rest-client/01.PojoMarshalling.html
index aae0540..565e59a 100644
--- a/juneau-doc/docs/Topics/09.juneau-rest-client/01.PojoMarshalling.html
+++ b/juneau-doc/docs/Topics/09.juneau-rest-client/01.PojoMarshalling.html
@@ -62,7 +62,10 @@ POJO Marshalling
        <jc>// Create a REST client with support for multiple languages.</jc>
        RestClient <jv>client</jv> = 
RestClient.<jsm>create</jsm>().universal().build();
 
-       <jv>client</jv>.post(<jsf>URI</jsf>, 
myBean).contentType(<js>"application/json"</js>).complete().assertStatus().is(200);
+       <jv>client</jv>.post(<jsf>URI</jsf>, myBean)
+               .contentType(<js>"application/json"</js>)
+               .complete()
+               .assertStatus().code().is(200);
 </p>
 
 <p>
@@ -73,7 +76,10 @@ POJO Marshalling
        RestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().build();
 
        <jc>// Use JSON for this request.</jc>
-       <jv>client</jv>.post(<jsf>URI</jsf>, 
myBean).json().complete().assertStatus().is(200);
+       <jv>client</jv>.post(<jsf>URI</jsf>, myBean)
+               .json()
+               .complete()
+               .assertStatus().code().is(200);
 </p>
 
 <p>
diff --git 
a/juneau-doc/docs/Topics/09.juneau-rest-client/02.RequestHeaders.html 
b/juneau-doc/docs/Topics/09.juneau-rest-client/02.RequestHeaders.html
index 5dc2ac1..fc7d5f6 100644
--- a/juneau-doc/docs/Topics/09.juneau-rest-client/02.RequestHeaders.html
+++ b/juneau-doc/docs/Topics/09.juneau-rest-client/02.RequestHeaders.html
@@ -46,10 +46,10 @@ Request Headers
 <h5 class='figure'>Example:</h5>
 <p class='bpcode w800'>
        <jc>// Create a client that adds a "Foo: bar" header to every 
request.</jc>
-       RestClient <jv>client</jv> = 
RestClient.<jsm>create</jsm>().header(<js>"Foo"</js>, <js>"bar"</js>).build();
+       RestClient <jv>client</jv> = 
RestClient.<jsm>create</jsm>().header(<js>"Foo"</js>,<js>"bar"</js>).build();
 
        <jc>// Or do it on every request.</jc>
-       String <jv>response</jv> = 
<jv>client</jv>.get(<jsf>URI</jsf>).header(<js>"Foo"</js>, 
<js>"bar"</js>).run().getBody().asString();
+       String <jv>response</jv> = 
<jv>client</jv>.get(<jsf>URI</jsf>).header(<js>"Foo"</js>,<js>"bar"</js>).run().getBody().asString();
 </p>
 
 <p>
diff --git 
a/juneau-doc/docs/Topics/09.juneau-rest-client/03.RequestQueryParameters.html 
b/juneau-doc/docs/Topics/09.juneau-rest-client/03.RequestQueryParameters.html
index c72668c..bf67db8 100644
--- 
a/juneau-doc/docs/Topics/09.juneau-rest-client/03.RequestQueryParameters.html
+++ 
b/juneau-doc/docs/Topics/09.juneau-rest-client/03.RequestQueryParameters.html
@@ -43,10 +43,10 @@ Request Query Parameters
 <h5 class='figure'>Example:</h5>
 <p class='bpcode w800'>
        <jc>// Create a client that adds a ?foo=bar query parameter to every 
request.</jc>
-       RestClient <jv>client</jv> = 
RestClient.<jsm>create</jsm>().query(<js>"foo"</js>, <js>"bar"</js>).build();
+       RestClient <jv>client</jv> = 
RestClient.<jsm>create</jsm>().query(<js>"foo"</js>,<js>"bar"</js>).build();
 
        <jc>// Or do it on every request.</jc>
-       String <jv>response</jv> = 
<jv>client</jv>.get(<jsf>URI</jsf>).query(<js>"foo"</js>, 
<js>"bar"</js>).run().getBody().asString();
+       String <jv>response</jv> = 
<jv>client</jv>.get(<jsf>URI</jsf>).query(<js>"foo"</js>,<js>"bar"</js>).run().getBody().asString();
 </p>
 
 <p>
diff --git 
a/juneau-doc/docs/Topics/09.juneau-rest-client/04.RequestFormData.html 
b/juneau-doc/docs/Topics/09.juneau-rest-client/04.RequestFormData.html
index 45aa0f8..4f85cae 100644
--- a/juneau-doc/docs/Topics/09.juneau-rest-client/04.RequestFormData.html
+++ b/juneau-doc/docs/Topics/09.juneau-rest-client/04.RequestFormData.html
@@ -43,10 +43,10 @@ Request Form Data
 <h5 class='figure'>Example:</h5>
 <p class='bpcode w800'>
        <jc>// Create a client that adds a foo=bar form-data parameter to every 
request.</jc>
-       RestClient <jv>client</jv> = 
RestClient.<jsm>create</jsm>().formData(<js>"foo"</js>, <js>"bar"</js>).build();
+       RestClient <jv>client</jv> = 
RestClient.<jsm>create</jsm>().formData(<js>"foo"</js>,<js>"bar"</js>).build();
 
        <jc>// Or do it on every request.</jc>
-       String <jv>response</jv> = 
<jv>client</jv>.formPost(<jsf>URI</jsf>).formData(<js>"foo"</js>, 
<js>"bar"</js>).run().getBody().asString();
+       String <jv>response</jv> = 
<jv>client</jv>.formPost(<jsf>URI</jsf>).formData(<js>"foo"</js>,<js>"bar"</js>).run().getBody().asString();
 </p>
 
 <p>
diff --git a/juneau-doc/docs/Topics/10.juneau-rest-mock/01.MockRestClient.html 
b/juneau-doc/docs/Topics/10.juneau-rest-mock/01.MockRestClient.html
index d5fd090..b345bed 100644
--- a/juneau-doc/docs/Topics/10.juneau-rest-mock/01.MockRestClient.html
+++ b/juneau-doc/docs/Topics/10.juneau-rest-mock/01.MockRestClient.html
@@ -28,7 +28,7 @@ MockRestClient
 </p>
 <p class='bpcode w800'>
        <jk>public class</jk> MockTest {
-       
+
                <jc>// A simple bean with one field.</jc>
                <jk>public static class</jk> MyBean {
                        <jk>public int</jk> <jf>foo</jf> = 1;
@@ -36,27 +36,21 @@ MockRestClient
 
                <jc>// Our REST resource to test.</jc>
                <jc>// Simply echos the response.</jc>
-               <ja>@Rest</ja>(
-                       serializers=SimpleJsonSerializer.<jk>class</jk>, 
-                       parsers=JsonParser.<jk>class</jk>
-               )
-               <jk>public static class</jk> EchoRest {
-       
-                       <ja>@RestMethod</ja>(
-                               name=<jsf>PUT</jsf>, 
-                               path=<js>"/echo"</js>
-                       )
-                       <jk>public</jk> MyBean echo(<ja>@Body</ja> MyBean 
<jv>bean</jv>) {
+               <ja>@Rest</ja>
+               <jk>public static class</jk> EchoRest <jk>implements</jk> 
BasicJsonRest {
+
+                       <ja>@RestMethod</ja>
+                       <jk>public</jk> MyBean putEcho(<ja>@Body</ja> MyBean 
<jv>bean</jv>) {
                                <jk>return</jk> <jv>bean</jv>;
                        }
                }
-               
+
                <jc>// Our JUnit test.</jc>
                <ja>@Test</ja>
                <jk>public void</jk> testEcho() <jk>throws</jk> Exception {
-               
+
                        MyBean <jv>myBean</jv> = <jk>new</jk> MyBean();
-               
+
                        <jc>// Do a round-trip on the bean through the REST 
interface</jc>
                        <jv>myBean</jv> = MockRestClient
                                .<jsm>create</jsm>(EchoRest.<jk>class</jk>)
@@ -67,7 +61,7 @@ MockRestClient
                                .assertStatus().is(200)
                                .assertBody().is(<js>"{foo:1}"</js>)
                                .getBody().as(MyBean.<jk>class</jk>);
-                               
+
                        <jsm>assertEquals</jsm>(1, 
<jv>myBean</jv>.<jf>foo</jf>);
                }
        }
@@ -76,25 +70,25 @@ MockRestClient
        Breaking apart the fluent method call above will help you understand 
how this works.
 </p>
 <p class='bpcode w800'>
-       <ja>@Test</ja>
+       <ja>@Test</ja>
        <jk>public void</jk> testEcho() <jk>throws</jk> Exception {
-      
+
                <jc>// Instantiate our mock client.</jc>
                MockRestClient <jv>client</jv> = MockRestClient
                        .<jsm>create</jsm>(EchoRest.<jk>class</jk>)
                        .simpleJson()
                        .build();
-      
+
                <jc>// Create a request.</jc>
                RestRequest <jv>req</jv> = 
<jv>client</jv>.put(<js>"/echo"</js>, <jv>myBean</jv>);
-      
+
                <jc>// Execute it (by calling RestCallHandler.service(...) and 
then returning the response object).</jc>
                RestResponse <jv>res</jv> = <jv>req</jv>.run();
-      
+
                <jc>// Run assertion tests on the results.</jc>
                <jv>res</jv>.assertStatus().is(200);
                <jv>res</jv>.assertBody().is(<js>"'foo'"</js>);
-               
+
                <jv>myBean</jv> = 
<jv>res</jv>.getBody().as(MyBean.<jk>class</jk>);
        }
 </p>
@@ -108,8 +102,48 @@ MockRestClient
 </p>
 <p>
        The <c>create(Object)</c> method can take in either <c>Class</c> 
objects or pre-instantiated beans.
-       The latter is particularly useful for testing Spring beans.
+       The latter is particularly useful for testing REST APIs written as 
Spring beans.
 </p>
+
+<p class='bpcode w800'>
+       <ja>@RunWith</ja>(SpringRunner.<jk>class</jk>)
+       <ja>@ContextConfiguration</ja>(classes = {MyApp.<jk>class</jk>})
+       <ja>@SpringBootTest</ja>
+       <jk>public class</jk> MockTest {
+
+               <ja>@Autowired</ja>
+               EchoRest <jf>echoRest</jf>;
+
+               MockRestClient <jf>client</jf>;
+
+               <ja>@Before</ja>
+               <jk>public void</jk> setup() {
+                       <jc>// Instantiate our mock client.</jc>
+                       <jf>client</jf> = MockRestClient
+                               .<jsm>create</jsm>(echoRest)
+                               .simpleJson()
+                               .build();
+               }
+
+               <jc>// Our JUnit test.</jc>
+               <ja>@Test</ja>
+               <jk>public void</jk> testEcho() <jk>throws</jk> Exception {
+
+                       MyBean <jv>myBean</jv> = <jk>new</jk> MyBean();
+
+                       <jc>// Do a round-trip on the bean through the REST 
interface</jc>
+                       <jv>myBean</jv> = <jf>client</jf>
+                               .put(<js>"/echo"</js>, <jv>myBean</jv>)
+                               .run()
+                               .assertStatus().is(200)
+                               .assertBody().is(<js>"{foo:1}"</js>)
+                               .getBody().as(MyBean.<jk>class</jk>);
+
+                       <jsm>assertEquals</jsm>(1, 
<jv>myBean</jv>.<jf>foo</jf>);
+               }
+       }
+</p>
+
 <hr>
 <p>
        The {@link oajr.mock2.MockRestRequest} object has convenience methods 
provided to allow you to set properties
@@ -119,7 +153,7 @@ MockRestClient
 <h5 class='figure'>Example:</h5>
 <p class='bpcode w800'>
        <ja>@Rest</ja>(roleGuard=<js>"ADMIN"</js>)
-       public class A {
+       <jk>public</jk> class A {
                <ja>@RestMethod</ja>
                <jk>public</jk> String get() {
                        <jk>return</jk> <js>"OK"</js>;
@@ -158,7 +192,7 @@ MockRestClient
        <ja>@Remote</ja>
        <jk>public interface</jk> MyRemoteInterface {
        
-               <ja>@RemoteMethod</ja>(httpMethod=<js>"GET"</js>, 
path=<js>"/echoQuery"</js>)
+               <ja>@RemoteMethod</ja>(method=<js>"GET"</js>, 
path=<js>"/echoQuery"</js>)
                <jk>public int</jk> 
echoQuery(<ja>@Query</ja>(name=<js>"id"</js>) <jk>int</jk> <jv>id</jv>);
        }
 

Reply via email to