oltu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject svn commit: r1733220 - in /oltu/trunk: oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/ oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/ oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator...
Date Wed, 02 Mar 2016 06:30:01 GMT
Author: jasha
Date: Wed Mar  2 06:30:01 2016
New Revision: 1733220

URL: http://svn.apache.org/viewvc?rev=1733220&view=rev
Log:
junit.assert.* is deprecated, use org.junit.*

Modified:
    oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/MD5GeneratorTest.java
    oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthIssuerImplTest.java
    oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthRequestTest.java
    oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/BodyTokenExtractorTest.java
    oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/HeaderTokenExtractorTest.java
    oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/QueryTokenExtractorTest.java
    oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/BodyOAuthValidatorTest.java
    oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/HeaderOAuthValidatorTest.java
    oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/QueryOAuthValidatorTest.java
    oltu/trunk/openid-connect/client/src/test/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponseTest.java

Modified: oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/MD5GeneratorTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/MD5GeneratorTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/MD5GeneratorTest.java
(original)
+++ oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/MD5GeneratorTest.java
Wed Mar  2 06:30:01 2016
@@ -21,32 +21,29 @@
 
 package org.apache.oltu.oauth2.as;
 
-import junit.framework.Assert;
-
 import org.apache.oltu.oauth2.as.issuer.MD5Generator;
 import org.apache.oltu.oauth2.as.issuer.ValueGenerator;
 import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
 import org.junit.Test;
 
+import static org.junit.Assert.assertNotNull;
+
+public class MD5GeneratorTest {
+
+    private final ValueGenerator g = new MD5Generator();
 
-/**
- *
- *
- *
- */
-public class MD5GeneratorTest extends Assert {
     @Test
     public void testGenerateValue() throws Exception {
-        ValueGenerator g = new MD5Generator();
-        Assert.assertNotNull(g.generateValue());
+        assertNotNull(g.generateValue());
+    }
 
-        Assert.assertNotNull(g.generateValue("test"));
+    @Test
+    public void testGenerateValueWithParameter() throws Exception {
+        assertNotNull(g.generateValue("test"));
+    }
 
-        try {
-            g.generateValue(null);
-            fail("Exception not thrown");
-        } catch (OAuthSystemException e) {
-            //ok
-        }
+    @Test(expected = OAuthSystemException.class)
+    public void testGenerateValueFailsWithParameterNull() throws Exception {
+        g.generateValue(null);
     }
 }

Modified: oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthIssuerImplTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthIssuerImplTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthIssuerImplTest.java
(original)
+++ oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthIssuerImplTest.java
Wed Mar  2 06:30:01 2016
@@ -21,33 +21,28 @@
 
 package org.apache.oltu.oauth2.as;
 
-import junit.framework.Assert;
-
-import org.junit.Test;
 import org.apache.oltu.oauth2.as.issuer.MD5Generator;
 import org.apache.oltu.oauth2.as.issuer.OAuthIssuer;
 import org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
 
-/**
- *
- *
- *
- */
 public class OAuthIssuerImplTest {
     private OAuthIssuer issuer = new OAuthIssuerImpl(new MD5Generator());
 
     @Test
     public void testAccessToken() throws Exception {
-        Assert.assertNotNull(issuer.accessToken());
+        assertNotNull(issuer.accessToken());
     }
 
     @Test
     public void testRefreshToken() throws Exception {
-        Assert.assertNotNull(issuer.refreshToken());
+        assertNotNull(issuer.refreshToken());
     }
 
     @Test
     public void testAuthorizationCode() throws Exception {
-        Assert.assertNotNull(issuer.authorizationCode());
+        assertNotNull(issuer.authorizationCode());
     }
 }

Modified: oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthRequestTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthRequestTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthRequestTest.java
(original)
+++ oltu/trunk/oauth-2.0/authzserver/src/test/java/org/apache/oltu/oauth2/as/OAuthRequestTest.java
Wed Mar  2 06:30:01 2016
@@ -21,11 +21,6 @@
 
 package org.apache.oltu.oauth2.as;
 
-import java.util.Set;
-
-import javax.servlet.http.HttpServletRequest;
-
-import junit.framework.Assert;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.oltu.oauth2.as.request.OAuthAuthzRequest;
 import org.apache.oltu.oauth2.as.request.OAuthRequest;
@@ -39,17 +34,14 @@ import org.apache.oltu.oauth2.common.mes
 import org.apache.oltu.oauth2.common.utils.OAuthUtils;
 import org.junit.Test;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.Set;
+
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 
-/**
- *
- *
- *
- */
 public class OAuthRequestTest {
     public static final String REDIRECT_URI = "http://www.example.com/callback";
     public static final String CLIENT_ID = "test_client";
@@ -580,8 +572,8 @@ public class OAuthRequestTest {
 
         Set<String> scopes = req.getScopes();
 
-        Assert.assertTrue(findScope(scopes, "album"));
-        Assert.assertTrue(findScope(scopes, "photo"));
+        assertTrue(findScope(scopes, "album"));
+        assertTrue(findScope(scopes, "photo"));
 
         verify(request);
     }

Modified: oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/BodyTokenExtractorTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/BodyTokenExtractorTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/BodyTokenExtractorTest.java
(original)
+++ oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/BodyTokenExtractorTest.java
Wed Mar  2 06:30:01 2016
@@ -21,47 +21,35 @@
 
 package org.apache.oltu.oauth2.rs.extractor;
 
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import javax.servlet.http.HttpServletRequest;
-
-import junit.framework.Assert;
-
 import org.apache.oltu.oauth2.common.OAuth;
-import org.apache.oltu.oauth2.rs.extractor.BearerBodyTokenExtractor;
 import org.junit.Test;
 
+import javax.servlet.http.HttpServletRequest;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
-/**
- *
- *
- *
- */
 public class BodyTokenExtractorTest {
 
     @Test
     public void testGetAccessToken() throws Exception {
-
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
         expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn("sometoken");
         replay(request);
         BearerBodyTokenExtractor bte = new BearerBodyTokenExtractor();
-        Assert.assertEquals("sometoken", bte.getAccessToken(request));
+        assertEquals("sometoken", bte.getAccessToken(request));
         verify(request);
     }
 
     @Test
     public void testGetAccessTokenNull() throws Exception {
-
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
         expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn(null);
         replay(request);
         BearerBodyTokenExtractor bte = new BearerBodyTokenExtractor();
-        Assert.assertNull(bte.getAccessToken(request));
+        assertNull(bte.getAccessToken(request));
         verify(request);
     }
 }

Modified: oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/HeaderTokenExtractorTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/HeaderTokenExtractorTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/HeaderTokenExtractorTest.java
(original)
+++ oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/HeaderTokenExtractorTest.java
Wed Mar  2 06:30:01 2016
@@ -21,46 +21,34 @@
 
 package org.apache.oltu.oauth2.rs.extractor;
 
-import javax.servlet.http.HttpServletRequest;
-
-import junit.framework.Assert;
-
 import org.apache.oltu.oauth2.common.OAuth;
-import org.apache.oltu.oauth2.rs.extractor.BearerHeaderTokenExtractor;
 import org.junit.Test;
 
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import javax.servlet.http.HttpServletRequest;
 
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
-/**
- *
- *
- *
- */
 public class HeaderTokenExtractorTest {
 
     @Test
     public void testGetAccessToken() throws Exception {
-
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn("Bearer sometoken");
         replay(request);
         BearerHeaderTokenExtractor hte = new BearerHeaderTokenExtractor();
-        Assert.assertEquals("sometoken", hte.getAccessToken(request));
+        assertEquals("sometoken", hte.getAccessToken(request));
         verify(request);
     }
 
     @Test
     public void testGetAccessTokenNull() throws Exception {
-
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn(null);
         replay(request);
         BearerHeaderTokenExtractor hte = new BearerHeaderTokenExtractor();
-        Assert.assertNull(hte.getAccessToken(request));
+        assertNull(hte.getAccessToken(request));
         verify(request);
     }
 }

Modified: oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/QueryTokenExtractorTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/QueryTokenExtractorTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/QueryTokenExtractorTest.java
(original)
+++ oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/extractor/QueryTokenExtractorTest.java
Wed Mar  2 06:30:01 2016
@@ -21,52 +21,34 @@
 
 package org.apache.oltu.oauth2.rs.extractor;
 
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
+import org.junit.Test;
 
 import javax.servlet.http.HttpServletRequest;
 
-import junit.framework.Assert;
-
-import org.apache.oltu.oauth2.rs.extractor.BearerQueryTokenExtractor;
-import org.junit.Test;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
 
-
-/**
- *
- *
- *
- */
 public class QueryTokenExtractorTest {
 
     @Test
     public void testGetAccessToken() throws Exception {
-
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
-        // expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn("sometoken");
         expect(request.getQueryString()).andStubReturn("access_token=sometoken");
         replay(request);
         BearerQueryTokenExtractor qte = new BearerQueryTokenExtractor();
-        Assert.assertEquals("sometoken", qte.getAccessToken(request));
+        assertEquals("sometoken", qte.getAccessToken(request));
         verify(request);
-
     }
 
     @Test
     public void testGetAccessTokenNull() throws Exception {
-
         HttpServletRequest request = createStrictMock(HttpServletRequest.class);
         expect(request.getQueryString()).andStubReturn(null);
-
-//        expect(request.getParameter(OAuth.OAUTH_TOKEN)).andStubReturn(null);
-//        expect(request.getParameter(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
         replay(request);
         BearerQueryTokenExtractor qte = new BearerQueryTokenExtractor();
-        Assert.assertNull(qte.getAccessToken(request));
+        assertNull(qte.getAccessToken(request));
         verify(request);
-
     }
 
 }

Modified: oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/BodyOAuthValidatorTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/BodyOAuthValidatorTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/BodyOAuthValidatorTest.java
(original)
+++ oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/BodyOAuthValidatorTest.java
Wed Mar  2 06:30:01 2016
@@ -21,31 +21,21 @@
 
 package org.apache.oltu.oauth2.rs.validator;
 
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import javax.servlet.http.HttpServletRequest;
-
-import junit.framework.Assert;
-
 import org.apache.oltu.oauth2.common.OAuth;
 import org.apache.oltu.oauth2.common.error.OAuthError;
 import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
-import org.apache.oltu.oauth2.rs.validator.BearerBodyOAuthValidator;
 import org.junit.Test;
 
-/**
- *
- *
- *
- */
+import javax.servlet.http.HttpServletRequest;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
 public class BodyOAuthValidatorTest {
 
     @Test
     public void testValidateInvalidMethod() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getMethod()).andStubReturn("GET");
         expect(request.getContentType()).andStubReturn(OAuth.ContentType.URL_ENCODED);
@@ -53,10 +43,10 @@ public class BodyOAuthValidatorTest {
         try {
             BearerBodyOAuthValidator bov = new BearerBodyOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Incorrect method. POST, PUT, DELETE are supported.", e.getDescription());
+            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Incorrect method. POST, PUT, DELETE are supported.", e.getDescription());
         }
         verify(request);
     }
@@ -70,10 +60,10 @@ public class BodyOAuthValidatorTest {
         try {
             BearerBodyOAuthValidator bov = new BearerBodyOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.CodeResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Request is not single part.", e.getDescription());
+            assertEquals(OAuthError.CodeResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Request is not single part.", e.getDescription());
         }
         verify(request);
     }
@@ -87,10 +77,10 @@ public class BodyOAuthValidatorTest {
         try {
             BearerBodyOAuthValidator bov = new BearerBodyOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Bad request content type. Expecting: application/x-www-form-urlencoded",
e.getDescription());
+            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Bad request content type. Expecting: application/x-www-form-urlencoded",
e.getDescription());
         }
         verify(request);
     }
@@ -106,10 +96,10 @@ public class BodyOAuthValidatorTest {
         try {
             BearerBodyOAuthValidator bov = new BearerBodyOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Incorrect OAuth version. Found OAuth V1.0.", e.getDescription());
+            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Incorrect OAuth version. Found OAuth V1.0.", e.getDescription());
         }
         verify(request);
     }
@@ -126,10 +116,10 @@ public class BodyOAuthValidatorTest {
         try {
             BearerBodyOAuthValidator bov = new BearerBodyOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(null, e.getError());
-            Assert.assertEquals("Missing OAuth token.", e.getDescription());
+            assertEquals(null, e.getError());
+            assertEquals("Missing OAuth token.", e.getDescription());
         }
         verify(request);
     }
@@ -146,10 +136,10 @@ public class BodyOAuthValidatorTest {
         try {
             BearerBodyOAuthValidator bov = new BearerBodyOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Multiple tokens attached.", e.getDescription());
+            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Multiple tokens attached.", e.getDescription());
         }
         verify(request);
     }

Modified: oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/HeaderOAuthValidatorTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/HeaderOAuthValidatorTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/HeaderOAuthValidatorTest.java
(original)
+++ oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/HeaderOAuthValidatorTest.java
Wed Mar  2 06:30:01 2016
@@ -21,89 +21,72 @@
 
 package org.apache.oltu.oauth2.rs.validator;
 
-import javax.servlet.http.HttpServletRequest;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
 import org.apache.oltu.oauth2.common.OAuth;
 import org.apache.oltu.oauth2.common.error.OAuthError;
 import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
 import org.apache.oltu.oauth2.common.utils.OAuthUtils;
-import org.apache.oltu.oauth2.rs.validator.BearerHeaderOAuthValidator;
+import org.junit.Test;
+
+import javax.servlet.http.HttpServletRequest;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
 
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-/**
- *
- *
- *
- */
 public class HeaderOAuthValidatorTest {
 
 
     @Test
     public void testValidateNoHeader() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn(null);
         replay(request);
         try {
             BearerHeaderOAuthValidator bov = new BearerHeaderOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            org.junit.Assert.assertTrue(OAuthUtils.isEmpty(e.getError()));
-            Assert.assertEquals("Missing authorization header.", e.getDescription());
+            assertTrue(OAuthUtils.isEmpty(e.getError()));
+            assertEquals("Missing authorization header.", e.getDescription());
         }
         verify(request);
-
     }
 
     @Test
     public void testValidateInvalidHeader() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn("Basic arawersadf");
         replay(request);
         try {
             BearerHeaderOAuthValidator bov = new BearerHeaderOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            org.junit.Assert.assertTrue(OAuthUtils.isEmpty(e.getError()));
-            Assert.assertEquals("Incorrect authorization method.", e.getDescription());
+            assertTrue(OAuthUtils.isEmpty(e.getError()));
+            assertEquals("Incorrect authorization method.", e.getDescription());
         }
         verify(request);
-
     }
 
 
     @Test
     public void testValidateValidHeaderMissingField() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn("Bearer 
");
         replay(request);
         try {
             BearerHeaderOAuthValidator bov = new BearerHeaderOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Missing required parameter.", e.getDescription());
+            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Missing required parameter.", e.getDescription());
         }
         verify(request);
-
     }
 
 
     @Test
     public void testValidateValidHeaderWrongVersion() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION))
             .andStubReturn("Bearer sdfsadfsadf,oauth_signature_method=\"HMAC-SHA1\"");
@@ -111,17 +94,16 @@ public class HeaderOAuthValidatorTest {
         try {
             BearerHeaderOAuthValidator bov = new BearerHeaderOAuthValidator();
             bov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Incorrect OAuth version. Found OAuth V1.0.", e.getDescription());
+            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Incorrect OAuth version. Found OAuth V1.0.", e.getDescription());
         }
         verify(request);
     }
 
     @Test
     public void testValidateValidHeader() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getHeader(OAuth.HeaderType.AUTHORIZATION)).andStubReturn("Bearer sdfsadfsadf");
         replay(request);

Modified: oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/QueryOAuthValidatorTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/QueryOAuthValidatorTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/QueryOAuthValidatorTest.java
(original)
+++ oltu/trunk/oauth-2.0/resourceserver/src/test/java/org/apache/oltu/oauth2/rs/validator/QueryOAuthValidatorTest.java
Wed Mar  2 06:30:01 2016
@@ -21,107 +21,80 @@
 
 package org.apache.oltu.oauth2.rs.validator;
 
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import javax.servlet.http.HttpServletRequest;
-
-import junit.framework.Assert;
-
 import org.apache.oltu.oauth2.common.OAuth;
 import org.apache.oltu.oauth2.common.error.OAuthError;
 import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
 import org.apache.oltu.oauth2.common.utils.OAuthUtils;
-import org.apache.oltu.oauth2.rs.validator.BearerQueryOAuthValidator;
 import org.junit.Test;
 
-/**
- *
- *
- *
- */
+import javax.servlet.http.HttpServletRequest;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
 public class QueryOAuthValidatorTest {
 
     @Test
     public void testValidateWrongVersion() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getQueryString()).andStubReturn(OAuth.OAUTH_VERSION_DIFFER + "=HMAC-SHA1&"
-            + OAuth.OAUTH_BEARER_TOKEN
-            + "=access_token");
-        //        expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn("HMAC-SHA1");
-        //        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new
String[] {"access_token"});
+                + OAuth.OAUTH_BEARER_TOKEN
+                + "=access_token");
         replay(request);
         try {
             BearerQueryOAuthValidator qov = new BearerQueryOAuthValidator();
             qov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Incorrect OAuth version. Found OAuth V1.0.", e.getDescription());
+            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Incorrect OAuth version. Found OAuth V1.0.", e.getDescription());
         }
         verify(request);
-
     }
 
     @Test
     public void testValidateNoQuery() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getQueryString()).andStubReturn(null);
-        //        expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        //        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(null);
-        //        expect(request.getParameterValues(OAuth.OAUTH_TOKEN)).andStubReturn(null);
         replay(request);
         try {
             BearerQueryOAuthValidator qov = new BearerQueryOAuthValidator();
             qov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            org.junit.Assert.assertTrue(OAuthUtils.isEmpty(e.getError()));
-            Assert.assertEquals("Missing OAuth token.", e.getDescription());
+            assertTrue(OAuthUtils.isEmpty(e.getError()));
+            assertEquals("Missing OAuth token.", e.getDescription());
         }
         verify(request);
-
     }
 
     @Test
     public void testValidateMultipleTokens() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getQueryString()).andStubReturn(OAuth.OAUTH_BEARER_TOKEN + "=access_token1&"
-            + OAuth.OAUTH_BEARER_TOKEN
-            + "=access_token2");
-        //        expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        //        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new
String[] {"access_token1",
-        //                                                                              
                  "access_token2"});
+                + OAuth.OAUTH_BEARER_TOKEN
+                + "=access_token2");
+
         replay(request);
         try {
             BearerQueryOAuthValidator qov = new BearerQueryOAuthValidator();
             qov.performAllValidations(request);
-            Assert.fail("Exception not thrown.");
+            fail("Exception not thrown.");
         } catch (OAuthProblemException e) {
-            Assert.assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
-            Assert.assertEquals("Multiple tokens attached.", e.getDescription());
+            assertEquals(OAuthError.TokenResponse.INVALID_REQUEST, e.getError());
+            assertEquals("Multiple tokens attached.", e.getDescription());
         }
         verify(request);
-
     }
 
     @Test
     public void testValidateToken() throws Exception {
-
         HttpServletRequest request = createMock(HttpServletRequest.class);
         expect(request.getQueryString()).andStubReturn(OAuth.OAUTH_BEARER_TOKEN + "=access_token1");
-        //        expect(request.getParameter(OAuth.OAUTH_VERSION_DIFFER)).andStubReturn(null);
-        //        expect(request.getParameterValues(OAuth.OAUTH_BEARER_TOKEN)).andStubReturn(new
String[] {"access_token1"});
+
         replay(request);
         BearerQueryOAuthValidator qov = new BearerQueryOAuthValidator();
         qov.performAllValidations(request);
         verify(request);
-
     }
-
 }

Modified: oltu/trunk/openid-connect/client/src/test/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponseTest.java
URL: http://svn.apache.org/viewvc/oltu/trunk/openid-connect/client/src/test/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponseTest.java?rev=1733220&r1=1733219&r2=1733220&view=diff
==============================================================================
--- oltu/trunk/openid-connect/client/src/test/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponseTest.java
(original)
+++ oltu/trunk/openid-connect/client/src/test/java/org/apache/oltu/openidconnect/client/response/OpenIdConnectResponseTest.java
Wed Mar  2 06:30:01 2016
@@ -16,14 +16,15 @@
  */
 package org.apache.oltu.openidconnect.client.response;
 
-import static junit.framework.Assert.assertFalse;
-import static junit.framework.Assert.assertTrue;
 import junitx.util.PrivateAccessor;
 
 import org.apache.oltu.oauth2.jwt.JWT;
 import org.apache.oltu.oauth2.jwt.io.JWTReader;
 import org.junit.Test;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 public class OpenIdConnectResponseTest {
 
     private final String JWT = "eyJhbGciOiJSUzI1NiIsImtpZCI6ImJlMWRhMGIzNTY3YmQyNjVhMjUwOThmYmNjMmIwOWYyMTM0NWIzYTIifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiaWQiOiIxMDY0MjI0NTMwODI0Nzk5OTg0MjkiLCJzdWIiOiIxMDY0MjI0NTMwODI0Nzk5OTg0MjkiLCJ2ZXJpZmllZF9lbWFpbCI6InRydWUiLCJlbWFpbF92ZXJpZmllZCI6InRydWUiLCJhdWQiOiI3ODg3MzIzNzIwNzguYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJjaWQiOiI3ODg3MzIzNzIwNzguYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhenAiOiI3ODg3MzIzNzIwNzguYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJlbWFpbCI6ImFudG9uaW8uc2Fuc29AZ21haWwuY29tIiwidG9rZW5faGFzaCI6IkwySTc3Z2lCTGswUlNzMHpRMVN2Q0EiLCJhdF9oYXNoIjoiTDJJNzdnaUJMazBSU3MwelExU3ZDQSIsImlhdCI6MTM2NjcyNjMxNywiZXhwIjoxMzY2NzMwMjE3fQ.XWYi5Zj1YWAMGIml_ftoAwmvW1Y7oeybLCpzQrJVuWJpS8L8Vd2TL-RTIOEVG03VA7e0_-_frNuw7MxUgVEgh8G-Nnbk_baJ6k_3w5c1SKFamFiHHDoKLFhrt1Y8JKSuGwE02V-px4Cn0dRAQAc1IN5CU6wqCrYK0p-fv_fvy28";



Mime
View raw message