oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1482098 - /oltu/whiteboard/simonetripodi/oltu-commons/src/test/java/org/apache/oltu/commons/AccessTokenResponseTestCase.java
Date Mon, 13 May 2013 20:52:38 GMT
Author: simonetripodi
Date: Mon May 13 20:52:37 2013
New Revision: 1482098

URL: http://svn.apache.org/r1482098
Log:
added the toJson() test case

Modified:
    oltu/whiteboard/simonetripodi/oltu-commons/src/test/java/org/apache/oltu/commons/AccessTokenResponseTestCase.java

Modified: oltu/whiteboard/simonetripodi/oltu-commons/src/test/java/org/apache/oltu/commons/AccessTokenResponseTestCase.java
URL: http://svn.apache.org/viewvc/oltu/whiteboard/simonetripodi/oltu-commons/src/test/java/org/apache/oltu/commons/AccessTokenResponseTestCase.java?rev=1482098&r1=1482097&r2=1482098&view=diff
==============================================================================
--- oltu/whiteboard/simonetripodi/oltu-commons/src/test/java/org/apache/oltu/commons/AccessTokenResponseTestCase.java
(original)
+++ oltu/whiteboard/simonetripodi/oltu-commons/src/test/java/org/apache/oltu/commons/AccessTokenResponseTestCase.java
Mon May 13 20:52:37 2013
@@ -24,12 +24,12 @@ import org.junit.Test;
 public final class AccessTokenResponseTestCase
 {
 
+    private static final String JSON = "{\"access_token\":\"2YotnFZFEjr1zCsicMWpAA\",\"token_type\":\"example\",\"expires_in\":3600,\"refresh_token\":\"tGzv3JOkF0XG5Qx2TlKWIA\",\"example_parameter\":\"example_value\"}";
+
     @Test
     public void fromJson()
     {
-        String source = "{\"access_token\":\"2YotnFZFEjr1zCsicMWpAA\",\"token_type\":\"example\",\"expires_in\":3600,\"refresh_token\":\"tGzv3JOkF0XG5Qx2TlKWIA\",\"example_parameter\":\"example_value\"}";
-
-        AccessTokenResponse response = AccessTokenResponse.Utils.parseJson( source );
+        AccessTokenResponse response = AccessTokenResponse.Utils.parseJson( JSON );
 
         assertEquals( "2YotnFZFEjr1zCsicMWpAA", response.getAccessToken() );
         assertEquals( "example", response.getTokenType() );
@@ -38,4 +38,18 @@ public final class AccessTokenResponseTe
         assertEquals( "example_value", response.getAuxParameter( "example_parameter" ) );
     }
 
+    @Test
+    public void toJson()
+    {
+        AccessTokenResponse response = new AccessTokenResponse.Builder()
+                                                              .setAccessToken( "2YotnFZFEjr1zCsicMWpAA"
)
+                                                              .setTokenType( "example" )
+                                                              .setExpiresIn( 3600L )
+                                                              .setRefreshToken( "tGzv3JOkF0XG5Qx2TlKWIA"
)
+                                                              .addAuxParameter( "example_parameter",
"example_value" )
+                                                              .build();
+        String actual = AccessTokenResponse.Utils.toJsonString( response );
+        assertEquals( JSON, actual );
+    }
+
 }



Mime
View raw message