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:04:50 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 61eadf526 -> bba922fb4


[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/bba922fb
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/bba922fb
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/bba922fb

Branch: refs/heads/master
Commit: bba922fb4dca56ea4f9ba641d9456e43dbfeca47
Parents: 61eadf5
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:04:32 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/bba922fb/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 850b76d..56ba35c 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/bba922fb/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/bba922fb/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 7ff03bd..2e86920 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/bba922fb/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 7094a28..23abcd1 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();
             }
@@ -291,8 +317,8 @@ public class JPAOAuthDataProviderTest extends Assert {
                 emFactory.close();
             }
         } catch (Throwable ex) {
-            ex.printStackTrace();
-        } finally {
+            ex.printStackTrace();    
+        } finally {    
             try {
                 //connection.createStatement().execute("SHUTDOWN");
             } catch (Throwable ex) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/bba922fb/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 41e7e83..6535dbb 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
@@ -54,6 +54,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