cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1561489 - in /cxf/fediz/trunk/services/idp/src: main/java/org/apache/cxf/fediz/service/idp/service/jpa/ main/resources/ test/java/org/apache/cxf/fediz/service/idp/service/jpa/ test/resources/
Date Sun, 26 Jan 2014 13:59:22 GMT
Author: owulff
Date: Sun Jan 26 13:59:22 2014
New Revision: 1561489

URL: http://svn.apache.org/r1561489
Log:
Use Spring DAO exceptions to encapsulate DAO layer

Modified:
    cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPAImpl.java
    cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPAImpl.java
    cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPAImpl.java
    cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPAImpl.java
    cxf/fediz/trunk/services/idp/src/main/resources/persistenceContext.xml
    cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPATest.java
    cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPATest.java
    cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPATest.java
    cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPATest.java
    cxf/fediz/trunk/services/idp/src/test/resources/persistence.properties

Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPAImpl.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPAImpl.java?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPAImpl.java
(original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPAImpl.java
Sun Jan 26 13:59:22 2014
@@ -36,10 +36,10 @@ import org.apache.cxf.fediz.service.idp.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
-@Component
+@Repository
 @Transactional
 public class ApplicationDAOJPAImpl implements ApplicationDAO {
     

Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPAImpl.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPAImpl.java?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPAImpl.java
(original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPAImpl.java
Sun Jan 26 13:59:22 2014
@@ -32,11 +32,11 @@ import org.apache.cxf.fediz.service.idp.
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
 
-@Component
+@Repository
 @Transactional
 public class ClaimDAOJPAImpl implements ClaimDAO {
     

Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPAImpl.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPAImpl.java?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPAImpl.java
(original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPAImpl.java
Sun Jan 26 13:59:22 2014
@@ -36,10 +36,10 @@ import org.apache.cxf.fediz.service.idp.
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
-@Component
+@Repository
 @Transactional
 public class IdpDAOJPAImpl implements IdpDAO {
     

Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPAImpl.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPAImpl.java?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPAImpl.java
(original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPAImpl.java
Sun Jan 26 13:59:22 2014
@@ -30,12 +30,12 @@ import org.apache.cxf.fediz.service.idp.
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
 
 @Transactional
-@Component
+@Repository
 public class TrustedIdpDAOJPAImpl implements TrustedIdpDAO {
     
     private static final Logger LOG = LoggerFactory.getLogger(TrustedIdpDAOJPAImpl.class);

Modified: cxf/fediz/trunk/services/idp/src/main/resources/persistenceContext.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/resources/persistenceContext.xml?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/resources/persistenceContext.xml (original)
+++ cxf/fediz/trunk/services/idp/src/main/resources/persistenceContext.xml Sun Jan 26 13:59:22
2014
@@ -47,7 +47,7 @@
         <property name="dataSource" ref="dataSource"/>
         <property name="jpaVendorAdapter">
             <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
-                <property name="showSql" value="true"/>
+                <property name="showSql" value="false"/>
                 <property name="generateDdl" value="true"/>
                 <property name="databasePlatform" value="org.apache.openjpa.jdbc.sql.${jpa.platform}"/>
             </bean>
@@ -119,6 +119,9 @@
          http://docs.spring.io/spring/docs/3.1.4.RELEASE/spring-framework-reference/htmlsingle/#orm-jpa-straight
     -->
     <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
+    
+    <!-- Requires updates to unit testing as no JPA exceptions are returned  -->
+    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"
/>
 
     <bean id="config" class="org.apache.cxf.fediz.service.idp.service.jpa.ConfigServiceJPA"
>
     	<property name="idpService" ref="idpServiceImpl" />

Modified: cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPATest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPATest.java?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPATest.java
(original)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPATest.java
Sun Jan 26 13:59:22 2014
@@ -22,9 +22,6 @@ import java.net.URI;
 import java.util.Arrays;
 import java.util.List;
 
-import javax.persistence.EntityNotFoundException;
-import javax.persistence.NoResultException;
-
 
 import org.apache.cxf.fediz.service.idp.domain.Application;
 import org.apache.cxf.fediz.service.idp.domain.RequestClaim;
@@ -36,6 +33,8 @@ import org.junit.runner.RunWith;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.orm.jpa.JpaObjectRetrievalFailureException;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.util.Assert;
@@ -114,7 +113,7 @@ public class ApplicationDAOJPATest {
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryReadNonexistingApplication() {
         applicationDAO.getApplication("urn:org:apache:cxf:fediz:fedizhelloworld:NOTEXIST",
null);
     }
@@ -206,13 +205,13 @@ public class ApplicationDAOJPATest {
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryRemoveUnknownApplication() {
         applicationDAO.deleteApplication("urn:org:apache:cxf:fediz:fedizhelloworld:NOTEXIST");
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testRemoveExistingApplication() {
         String realm = "urn:org:apache:cxf:fediz:app:testdelete";
         Application application = new Application();
@@ -264,7 +263,7 @@ public class ApplicationDAOJPATest {
         applicationDAO.addClaimToApplication(application, requestClaim);
     }
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryAddUnknownClaimToApplication() {
         Application application = new Application();
         application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
@@ -309,7 +308,7 @@ public class ApplicationDAOJPATest {
         Assert.isTrue(0 == application.getRequestedClaims().size(), "requestedClaims size
doesn't match");
     }
     
-    @Test(expected = EntityNotFoundException.class)
+    @Test(expected = JpaObjectRetrievalFailureException.class)
     public void testTryRemoveNotAssignedClaimFromApplication() {
         Application application = new Application();
         application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
@@ -321,7 +320,7 @@ public class ApplicationDAOJPATest {
         applicationDAO.removeClaimFromApplication(application, requestClaim);
     }
     
-    @Test(expected = EntityNotFoundException.class)
+    @Test(expected = JpaObjectRetrievalFailureException.class)
     public void testTryRemoveUnknownClaimFromApplication() {
         Application application = new Application();
         application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");

Modified: cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPATest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPATest.java?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPATest.java
(original)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPATest.java
Sun Jan 26 13:59:22 2014
@@ -21,8 +21,6 @@ package org.apache.cxf.fediz.service.idp
 import java.net.URI;
 import java.util.List;
 
-import javax.persistence.NoResultException;
-
 import org.apache.cxf.fediz.service.idp.domain.Claim;
 import org.apache.cxf.fediz.service.idp.service.ClaimDAO;
 
@@ -32,6 +30,7 @@ import org.junit.runner.RunWith;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.util.Assert;
@@ -76,7 +75,7 @@ public class ClaimDAOJPATest {
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryReadNonexistingClaim() {
         claimDAO.getClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givennamenotexist");
     }
@@ -175,13 +174,13 @@ public class ClaimDAOJPATest {
      */
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryRemoveUnknownClaim() {
         claimDAO.deleteClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/town/WRONG");
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testRemoveExistingClaim() {
         claimDAO.deleteClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/email");
         

Modified: cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPATest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPATest.java?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPATest.java
(original)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPATest.java
Sun Jan 26 13:59:22 2014
@@ -25,9 +25,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.persistence.EntityNotFoundException;
-import javax.persistence.NoResultException;
-
 import org.apache.cxf.fediz.service.idp.domain.Application;
 import org.apache.cxf.fediz.service.idp.domain.Claim;
 import org.apache.cxf.fediz.service.idp.domain.Idp;
@@ -41,6 +38,8 @@ import org.junit.runner.RunWith;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.orm.jpa.JpaObjectRetrievalFailureException;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.util.Assert;
@@ -149,7 +148,7 @@ public class IdpDAOJPATest {
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryReadNonexistingIdp() {
         idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:NOTEXIST", null);
     }
@@ -229,13 +228,13 @@ public class IdpDAOJPATest {
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryRemoveUnknownIdp() {
         idpDAO.deleteIdp("urn:org:apache:cxf:fediz:idp:NOTEXIST");
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testRemoveExistingIdp() {
         Idp idp = new Idp();
         idp.setRealm("urn:org:apache:cxf:fediz:idp:testdelete");
@@ -314,7 +313,7 @@ public class IdpDAOJPATest {
         
     }
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testUpdateUnknownIdp() {
         String realm = "urn:org:apache:cxf:fediz:idp:testupdate2";
         
@@ -376,7 +375,7 @@ public class IdpDAOJPATest {
         idpDAO.addClaimToIdp(idp, claim);
     }
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryAddUnknownClaimToIdp() {
         Idp idp = new Idp();
         idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
@@ -410,7 +409,7 @@ public class IdpDAOJPATest {
                       "claimTypesOffered size doesn't match [" + idp.getClaimTypesOffered().size()
+ "]");
     }
     
-    @Test(expected = EntityNotFoundException.class)
+    @Test(expected = JpaObjectRetrievalFailureException.class)
     public void testTryRemoveNotAssignedClaimFromIdp() {
         Idp idp = new Idp();
         idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
@@ -421,7 +420,7 @@ public class IdpDAOJPATest {
         idpDAO.removeClaimFromIdp(idp, claim);
     }
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryRemoveUnknownClaimFromIdp() {
         Idp idp = new Idp();
         idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
@@ -463,7 +462,7 @@ public class IdpDAOJPATest {
         idpDAO.addApplicationToIdp(idp, app);
     }
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryAddUnknownApplicationToIdp() {
         Idp idp = new Idp();
         idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
@@ -498,7 +497,7 @@ public class IdpDAOJPATest {
     }
     
     
-    @Test(expected = EntityNotFoundException.class)
+    @Test(expected = JpaObjectRetrievalFailureException.class)
     public void testTryRemoveNotAssignedApplicationFromIdp() {
         Idp idp = new Idp();
         idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
@@ -510,7 +509,7 @@ public class IdpDAOJPATest {
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryRemoveUnknownApplicationFromIdp() {
         Idp idp = new Idp();
         idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");

Modified: cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPATest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPATest.java?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPATest.java
(original)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPATest.java
Sun Jan 26 13:59:22 2014
@@ -20,8 +20,6 @@ package org.apache.cxf.fediz.service.idp
 
 import java.util.List;
 
-import javax.persistence.NoResultException;
-
 import org.apache.cxf.fediz.service.idp.domain.TrustedIdp;
 import org.apache.cxf.fediz.service.idp.service.TrustedIdpDAO;
 
@@ -31,6 +29,7 @@ import org.junit.runner.RunWith;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 import org.springframework.util.Assert;
@@ -79,7 +78,7 @@ public class TrustedIdpDAOJPATest {
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryReadNonexistingTrustedIdp() {
         trustedIdpDAO.getTrustedIDP("urn:org:apache:cxf:fediz:idp:NOTEXIST");
     }
@@ -165,13 +164,13 @@ public class TrustedIdpDAOJPATest {
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testTryRemoveUnknownTrustedIdp() {
         trustedIdpDAO.deleteTrustedIDP("urn:org:apache:cxf:fediz:trusted-idp:NOTEXIST");
     }
     
     
-    @Test(expected = NoResultException.class)
+    @Test(expected = EmptyResultDataAccessException.class)
     public void testRemoveExistingTrustedIdp() {
         String realm = "urn:org:apache:cxf:fediz:trusted-idp:testdelete";
         TrustedIdp trustedIdp = new TrustedIdp();

Modified: cxf/fediz/trunk/services/idp/src/test/resources/persistence.properties
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/resources/persistence.properties?rev=1561489&r1=1561488&r2=1561489&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/resources/persistence.properties (original)
+++ cxf/fediz/trunk/services/idp/src/test/resources/persistence.properties Sun Jan 26 13:59:22
2014
@@ -7,7 +7,7 @@
 
 
 jpa.driverClassName=org.hsqldb.jdbcDriver
-jpa.url=jdbc:hsqldb:target/fediz/db/myDB;shutdown=true
+jpa.url=jdbc:hsqldb:target/unit/fediz/db/myDB;shutdown=true
 jpa.username=sa
 jpa.password=
 jpa.defaultData=true



Mime
View raw message