cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7374] Completing applying the patch from Adrian, This closes #275
Date Mon, 29 May 2017 16:06:30 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 71d199035 -> 6eda41c00


[CXF-7374] Completing applying the patch from Adrian, This closes #275


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6eda41c0
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6eda41c0
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6eda41c0

Branch: refs/heads/3.1.x-fixes
Commit: 6eda41c0084895390e29974c143cc11aff2ad754
Parents: 71d1990
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Mon May 29 17:04:32 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Mon May 29 17:06:07 2017 +0100

----------------------------------------------------------------------
 .../oauth2/provider/JPAOAuthDataProvider.java   | 11 +++------
 .../JPACMTOAuthDataProviderOpenJPATest.java     |  6 ++---
 .../code/JPACMTOAuthDataProviderTest.java       |  1 +
 .../provider/JPAOAuthDataProviderTest.java      | 26 ++++++++++++++++++++
 .../src/test/resources/META-INF/persistence.xml |  1 +
 5 files changed, 35 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6eda41c0/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
index c107eb2..b25461b 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProvider.java
@@ -114,10 +114,9 @@ public class JPAOAuthDataProvider extends AbstractOAuthDataProvider {
                     }
                 }
                 boolean clientExists = em.createQuery("SELECT count(client) from Client client
"
-                                + "where client.clientId = :id",
-                        Long.class)
+                                + "where client.clientId = :id", Long.class)
                         .setParameter("id", client.getClientId())
-                        .getSingleResult() > 0 ? true : false;
+                        .getSingleResult() > 0;
                 if (clientExists) {
                     em.merge(client);
                 } else {
@@ -321,8 +320,7 @@ public class JPAOAuthDataProvider extends AbstractOAuthDataProvider {
     protected TypedQuery<BearerAccessToken> getTokensQuery(Client c, UserSubject resourceOwnerSubject,
                                                            EntityManager entityManager) {
         if (c == null && resourceOwnerSubject == null) {
-            return entityManager.createQuery("SELECT t FROM BearerAccessToken t",
-                    BearerAccessToken.class);
+            return entityManager.createQuery("SELECT t FROM BearerAccessToken t", BearerAccessToken.class);
         } else if (c == null) {
             return entityManager.createQuery(
                     "SELECT t FROM BearerAccessToken t"
@@ -349,8 +347,7 @@ public class JPAOAuthDataProvider extends AbstractOAuthDataProvider {
     protected TypedQuery<RefreshToken> getRefreshTokensQuery(Client c, UserSubject
resourceOwnerSubject,
                                                              EntityManager entityManager)
{
         if (c == null && resourceOwnerSubject == null) {
-            return entityManager.createQuery("SELECT t FROM RefreshToken t",
-                    RefreshToken.class);
+            return entityManager.createQuery("SELECT t FROM RefreshToken t", RefreshToken.class);
         } else if (c == null) {
             return entityManager.createQuery(
                     "SELECT t FROM RefreshToken t"

http://git-wip-us.apache.org/repos/asf/cxf/blob/6eda41c0/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderOpenJPATest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderOpenJPATest.java
b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderOpenJPATest.java
index 4324ba3..6e509b1 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderOpenJPATest.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderOpenJPATest.java
@@ -18,8 +18,8 @@
  */
 package org.apache.cxf.rs.security.oauth2.grants.code;
 
-import org.apache.cxf.rs.security.oauth2.provider.JPAOAuthDataProviderTest;
 import org.junit.runner.RunWith;
+
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.ContextConfiguration;
@@ -38,7 +38,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  */
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration("JPACMTCodeDataProvider.xml")
-@DirtiesContext
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
 @ActiveProfiles(value = "openJPA", inheritProfiles = false)
-public class JPACMTOAuthDataProviderOpenJPATest extends JPAOAuthDataProviderTest {
+public class JPACMTOAuthDataProviderOpenJPATest extends JPACMTOAuthDataProviderTest {
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/6eda41c0/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderTest.java
b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderTest.java
index 12a838b..86c0fe9 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderTest.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/grants/code/JPACMTOAuthDataProviderTest.java
@@ -74,6 +74,7 @@ public class JPACMTOAuthDataProviderTest extends JPAOAuthDataProviderTest
{
     @After
     @Override
     public void tearDown() {
+        tearDownClients();
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/cxf/blob/6eda41c0/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProviderTest.java
b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProviderTest.java
index 0b243f5..a49fc4c 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProviderTest.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/test/java/org/apache/cxf/rs/security/oauth2/provider/JPAOAuthDataProviderTest.java
@@ -280,10 +280,36 @@ public class JPAOAuthDataProviderTest extends Assert {
         assertEquals("http://client/redirect", c.getRedirectUris().get(0));
         assertEquals(c.getResourceOwnerSubject().getLogin(), c2.getResourceOwnerSubject().getLogin());
     }
+    
+    protected void tearDownClient(String clientId) {
+        if (getProvider() == null) {
+            return;
+        }
+        Client client = getProvider().getClient(clientId);
+        if (client != null) {
+            List<RefreshToken> refreshTokens = getProvider().getRefreshTokens(client,
null);
+            for (RefreshToken refreshToken : refreshTokens) {
+                getProvider().revokeToken(client, refreshToken.getTokenKey(), refreshToken.getTokenType());
+            }
+            List<ServerAccessToken> accessTokens = getProvider().getAccessTokens(client,
null);
+            for (ServerAccessToken accessToken : accessTokens) {
+                getProvider().revokeToken(client, accessToken.getTokenKey(), accessToken.getTokenType());
+            }
+            getProvider().removeClient(clientId);
+        }
+    }
+
+    protected void tearDownClients() {
+        tearDownClient("101");
+        tearDownClient("12345");
+        tearDownClient("56789");
+        tearDownClient("09876");
+    }
 
     @After
     public void tearDown() throws Exception {
         try {
+            tearDownClients();
             if (provider != null) {
                 getProvider().close();
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/6eda41c0/rt/rs/security/oauth-parent/oauth2/src/test/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/rt/rs/security/oauth-parent/oauth2/src/test/resources/META-INF/persistence.xml
b/rt/rs/security/oauth-parent/oauth2/src/test/resources/META-INF/persistence.xml
index 6be18f9..c708df5 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/test/resources/META-INF/persistence.xml
+++ b/rt/rs/security/oauth-parent/oauth2/src/test/resources/META-INF/persistence.xml
@@ -56,6 +56,7 @@
             <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
             <property name="openjpa.jdbc.EagerFetchMode" value="parallel"/>
             <property name="openjpa.MaxFetchDepth" value="20"/>
+            <property name="openjpa.jdbc.DBDictionary" value="SupportsSelectForUpdate=true"/>
             <!--
             <property name="openjpa.Log" value="DefaultLevel=WARN, Runtime=TRACE, Tool=INFO"/>
             -->


Mime
View raw message