cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From owu...@apache.org
Subject svn commit: r1560525 [4/4] - in /cxf/fediz/trunk: ./ services/idp/ services/idp/src/main/java/org/apache/cxf/fediz/service/idp/ services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ services/idp/src/main/java/org/apache/cxf/fediz/service/i...
Date Wed, 22 Jan 2014 21:47:03 GMT
Added: 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=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPATest.java (added)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ApplicationDAOJPATest.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,349 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.fediz.service.idp.service.jpa;
+
+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;
+import org.apache.cxf.fediz.service.idp.service.ApplicationDAO;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.util.Assert;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:testContext.xml" })
+public class ApplicationDAOJPATest {
+
+    //@Autowired
+    //private IdpDAO idpDAO;
+    
+    @Autowired
+    private ApplicationDAO applicationDAO;
+    
+    //@Autowired
+    //private TrustedIdpDAO trustedIdpDAO;
+    
+    
+    @BeforeClass
+    public static void init() {
+        System.setProperty("spring.profiles.active", "jpa");
+    }
+    
+    
+    @Test
+    public void testReadAllApplications() {
+        List<Application> applications = applicationDAO.getApplications(0, 999, null);
+        // Application could have been removed, Order not given as per JUnit design
+        Assert.isTrue(1 < applications.size(), "Size doesn't match [" + applications.size() + "]");
+    }
+    
+    
+    @Test
+    public void testReadExistingApplicationEmbeddedAll() {
+        Application application = applicationDAO.getApplication("urn:org:apache:cxf:fediz:fedizhelloworld",
+                                                                Arrays.asList("all"));
+        
+        Assert.isTrue("".equals(application.getEncryptionCertificate()),
+                      "EncryptionCertificate doesn't match");
+        Assert.isTrue("3600".equals(application.getLifeTime()),
+                      "LifeTime doesn't match");
+        Assert.isTrue("http://docs.oasis-open.org/wsfed/federation/200706".equals(application.getProtocol()),
+                      "Protocol doesn't match");
+        Assert.isTrue("urn:org:apache:cxf:fediz:fedizhelloworld".equals(application.getRealm()),
+                      "Realm doesn't match");
+        Assert.isTrue("ApplicationServiceType".equals(application.getRole()),
+                      "Role doesn't match");
+        Assert.isTrue("Fedizhelloworld description".equals(application.getServiceDescription()),
+                      "ServiceDescription doesn't match");
+        Assert.isTrue("Fedizhelloworld".equals(application.getServiceDisplayName()),
+                      "ServiceDisplayName doesn't match");
+        Assert.isTrue("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0"
+                      .equals(application.getTokenType()),
+                      "TokenType doesn't match");         
+        Assert.isTrue(4 == application.getRequestedClaims().size(),
+                      "Number of claims doesn't match [" + application.getRequestedClaims().size() + "]");
+    }
+    
+    @Test
+    public void testReadExistingApplicationEmbeddedClaims() {
+        Application application = applicationDAO.getApplication("urn:org:apache:cxf:fediz:fedizhelloworld",
+                                                                Arrays.asList("claims"));
+        
+        Assert.isTrue(4 == application.getRequestedClaims().size(),
+                      "Number of claims doesn't match");
+    }
+    
+    @Test
+    public void testReadExistingApplicationEmbeddedNull() {
+        Application application = applicationDAO.getApplication("urn:org:apache:cxf:fediz:fedizhelloworld",
+                                                                null);
+        
+        Assert.isTrue(0 == application.getRequestedClaims().size(),
+                      "Number of claims doesn't match");
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryReadNonexistingApplication() {
+        applicationDAO.getApplication("urn:org:apache:cxf:fediz:fedizhelloworld:NOTEXIST", null);
+    }
+    
+    
+    @Test
+    public void testAddNewApplication() {
+        
+        String realm = "urn:org:apache:cxf:fediz:application:testaddnew";
+        Application application = createApplication(realm);
+        applicationDAO.addApplication(application);
+        
+        application = applicationDAO.getApplication(realm, null);
+        
+        Assert.isTrue("".equals(application.getEncryptionCertificate()),
+                      "EncryptionCertificate doesn't match");
+        Assert.isTrue("3600".equals(application.getLifeTime()),
+                      "LifeTime doesn't match");
+        Assert.isTrue("http://docs.oasis-open.org/wsfed/federation/200706".equals(application.getProtocol()),
+                      "Protocol doesn't match");
+        Assert.isTrue(realm.equals(application.getRealm()),
+                      "Realm doesn't match");
+        Assert.isTrue("ApplicationServiceType".equals(application.getRole()),
+                      "Role doesn't match");
+        Assert.isTrue("Fedizhelloworld2 description".equals(application.getServiceDescription()),
+                      "ServiceDescription doesn't match");
+        Assert.isTrue("Fedizhelloworld2".equals(application.getServiceDisplayName()),
+                      "ServiceDisplayName doesn't match");
+        Assert.isTrue("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
+                      .equals(application.getTokenType()),
+                      "TokenType doesn't match");         
+        Assert.isTrue(0 == application.getRequestedClaims().size(),
+                      "Number of claims doesn't match");
+    }
+    
+    @Test
+    public void testUpdateApplication() {
+        String realm = "urn:org:apache:cxf:fediz:application:testupdate";
+        
+        //Prepare
+        Application application = createApplication(realm);
+        applicationDAO.addApplication(application);
+        
+        //Testcase
+        application = new Application();
+        application.setRealm(realm);
+        application.setEncryptionCertificate("U");
+        application.setLifeTime("U3600");
+        application.setProtocol("Uhttp://docs.oasis-open.org/wsfed/federation/200706");
+        application.setRole("UApplicationServiceType");
+        application.setServiceDescription("UFedizhelloworld2 description");
+        application.setServiceDisplayName("UFedizhelloworld2");
+        application.setTokenType("Uhttp://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1");
+        
+        Assert.isTrue("U".equals(application.getEncryptionCertificate()),
+                      "EncryptionCertificate doesn't match");
+        Assert.isTrue("U3600".equals(application.getLifeTime()),
+                      "LifeTime doesn't match");
+        Assert.isTrue("Uhttp://docs.oasis-open.org/wsfed/federation/200706".equals(application.getProtocol()),
+                      "Protocol doesn't match");
+        Assert.isTrue(realm.equals(application.getRealm()),
+                      "Realm doesn't match");
+        Assert.isTrue("UApplicationServiceType".equals(application.getRole()),
+                      "Role doesn't match");
+        Assert.isTrue("UFedizhelloworld2 description".equals(application.getServiceDescription()),
+                      "ServiceDescription doesn't match");
+        Assert.isTrue("UFedizhelloworld2".equals(application.getServiceDisplayName()),
+                      "ServiceDisplayName doesn't match");
+        Assert.isTrue("Uhttp://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1"
+                      .equals(application.getTokenType()),
+                      "TokenType doesn't match");         
+        Assert.isTrue(0 == application.getRequestedClaims().size(),
+                      "Number of claims doesn't match");
+    }
+    
+    @Test(expected = DataIntegrityViolationException.class)
+    public void testTryAddExistingApplication() {
+        Application application = new Application();
+        application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
+        application.setEncryptionCertificate("");
+        application.setLifeTime("3600");
+        application.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
+        application.setRole("ApplicationServiceType");
+        application.setServiceDescription("Fedizhelloworld description");
+        application.setServiceDisplayName("Fedizhelloworld");
+        application.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
+        
+        applicationDAO.addApplication(application);
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryRemoveUnknownApplication() {
+        applicationDAO.deleteApplication("urn:org:apache:cxf:fediz:fedizhelloworld:NOTEXIST");
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testRemoveExistingApplication() {
+        String realm = "urn:org:apache:cxf:fediz:app:testdelete";
+        Application application = new Application();
+        application.setRealm(realm);
+        applicationDAO.addApplication(application);
+        
+        applicationDAO.deleteApplication(realm);
+        
+        applicationDAO.getApplication(realm, null);
+    }
+    
+    @Test
+    public void testAddClaimToApplication() {
+        //Prepare step
+        Application application = new Application();
+        application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld:testaddclaim");
+        application.setEncryptionCertificate("");
+        application.setLifeTime("3600");
+        application.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
+        application.setRole("ApplicationServiceType");
+        application.setServiceDescription("Fedizhelloworld description");
+        application.setServiceDisplayName("Fedizhelloworld");
+        application.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
+        
+        applicationDAO.addApplication(application);
+        
+        //Testcase
+        RequestClaim requestClaim = new RequestClaim();
+        requestClaim.setOptional(false);
+        requestClaim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
+        
+        applicationDAO.addClaimToApplication(application, requestClaim);
+               
+        application = applicationDAO.getApplication("urn:org:apache:cxf:fediz:fedizhelloworld:testaddclaim",
+                                                    Arrays.asList("all"));
+        
+        Assert.isTrue(1 == application.getRequestedClaims().size(), "requestedClaims size doesn't match");
+    }
+    
+    @Test(expected = DataIntegrityViolationException.class)
+    public void testTryAddExistingClaimToApplication() {
+        Application application = new Application();
+        application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
+        
+        RequestClaim requestClaim = new RequestClaim();
+        requestClaim.setOptional(false);
+        requestClaim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
+        
+        applicationDAO.addClaimToApplication(application, requestClaim);
+    }
+    
+    @Test(expected = NoResultException.class)
+    public void testTryAddUnknownClaimToApplication() {
+        Application application = new Application();
+        application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
+        
+        RequestClaim requestClaim = new RequestClaim();
+        requestClaim.setOptional(false);
+        requestClaim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/UNKOWN"));
+        
+        applicationDAO.addClaimToApplication(application, requestClaim);
+    }
+    
+    
+    @Test
+    public void testRemoveClaimFromApplication() {
+        //Prepare step
+        Application application = new Application();
+        application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld:testremoveclaim");
+        application.setEncryptionCertificate("");
+        application.setLifeTime("3600");
+        application.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
+        application.setRole("ApplicationServiceType");
+        application.setServiceDescription("Fedizhelloworld description");
+        application.setServiceDisplayName("Fedizhelloworld");
+        application.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
+        
+        applicationDAO.addApplication(application);
+        
+        RequestClaim requestClaim = new RequestClaim();
+        requestClaim.setOptional(false);
+        requestClaim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
+        
+        applicationDAO.addClaimToApplication(application, requestClaim);
+               
+        application = applicationDAO.getApplication("urn:org:apache:cxf:fediz:fedizhelloworld:testremoveclaim",
+                                                    Arrays.asList("all"));
+        Assert.isTrue(1 == application.getRequestedClaims().size(), "requestedClaims size doesn't match");
+        
+        //Testcase
+        applicationDAO.removeClaimFromApplication(application, requestClaim);
+        application = applicationDAO.getApplication("urn:org:apache:cxf:fediz:fedizhelloworld:testremoveclaim",
+                                                    Arrays.asList("all"));
+        Assert.isTrue(0 == application.getRequestedClaims().size(), "requestedClaims size doesn't match");
+    }
+    
+    @Test(expected = EntityNotFoundException.class)
+    public void testTryRemoveNotAssignedClaimFromApplication() {
+        Application application = new Application();
+        application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
+                
+        RequestClaim requestClaim = new RequestClaim();
+        requestClaim.setOptional(false);
+        requestClaim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/city"));
+        
+        applicationDAO.removeClaimFromApplication(application, requestClaim);
+    }
+    
+    @Test(expected = EntityNotFoundException.class)
+    public void testTryRemoveUnknownClaimFromApplication() {
+        Application application = new Application();
+        application.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
+                
+        RequestClaim requestClaim = new RequestClaim();
+        requestClaim.setOptional(false);
+        requestClaim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/UNKNOWN"));
+        
+        applicationDAO.removeClaimFromApplication(application, requestClaim);
+    }
+    
+    private static Application createApplication(String realm) {
+        Application application = new Application();
+        application.setRealm(realm);
+        application.setEncryptionCertificate("");
+        application.setLifeTime("3600");
+        application.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
+        application.setRole("ApplicationServiceType");
+        application.setServiceDescription("Fedizhelloworld2 description");
+        application.setServiceDisplayName("Fedizhelloworld2");
+        application.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1");
+        return application;
+    }
+
+}

Added: 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=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPATest.java (added)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/ClaimDAOJPATest.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,192 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.fediz.service.idp.service.jpa;
+
+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;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.util.Assert;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:testContext.xml" })
+public class ClaimDAOJPATest {
+
+    //@Autowired
+    //private IdpDAO idpDAO;
+    
+    //@Autowired
+    //private TrustedIdpDAO trustedIdpDAO;
+    
+    @Autowired
+    private ClaimDAO claimDAO;
+    
+    
+    @BeforeClass
+    public static void init() {
+        System.setProperty("spring.profiles.active", "jpa");
+    }
+    
+    
+    @Test
+    public void testReadAllClaims() {
+        List<Claim> claims = claimDAO.getClaims(0, 999);
+        Assert.isTrue(5 == claims.size(), "Size doesn't match");
+    }
+    
+    @Test
+    public void testReadExistingClaim() {
+        Claim claim = claimDAO.getClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname");
+        Assert.isTrue("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"
+                      .equals(claim.getClaimType().toString()),
+                      "ClaimType doesn't match");
+        Assert.isTrue("firstname".equals(claim.getDisplayName()),
+                      "Claim Display name doesn't match");
+        Assert.isTrue("Description for firstname".equals(claim.getDescription()),
+                      "Claim Description name doesn't match");
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryReadNonexistingClaim() {
+        claimDAO.getClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givennamenotexist");
+    }
+    
+    
+    @Test
+    public void testAddNewClaim() {
+        Claim claim5 = new Claim();
+        claim5.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/town"));
+        claim5.setDisplayName("Town");
+        claim5.setDescription("Town Description");
+        claimDAO.addClaim(claim5);
+        
+        List<Claim> claims = claimDAO.getClaims(0, 999);
+        Assert.isTrue(6 == claims.size(), "Size doesn't match. Claim not added");
+    }
+    
+    
+    @Test(expected = DataIntegrityViolationException.class)
+    public void testTryAddExistingClaim() {
+        Claim claim5 = new Claim();
+        claim5.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
+        claim5.setDisplayName("firstname");
+        claim5.setDescription("Description for firstname");
+        claimDAO.addClaim(claim5);
+    }
+    
+    //[TODO] UpdateClaim
+    /*
+    @Test
+    public void testUpdateIdp() {
+        String realm = "urn:org:apache:cxf:fediz:idp:testupdate";
+        //Prepare
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        //Testcase
+        idp = new Idp();
+        idp.setRealm(realm);
+        idp.setCertificate("UstsKeystoreA.properties");
+        idp.setCertificatePassword("Urealma");
+        idp.setIdpUrl("Uhttps://localhost:9443/fediz-idp/federation");
+        idp.setStsUrl("Uhttps://localhost:9443/fediz-idp-sts/REALMA");
+        idp.setServiceDisplayName("UNEW REALM");
+        idp.setServiceDescription("UIDP of New Realm");
+        idp.setUri("Urealmn");
+        idp.setProvideIDPList(true);
+        Map<String, String> authUris = new HashMap<String, String>();
+        authUris.put("default", "/login/default");
+        idp.setAuthenticationURIs(authUris);
+        List<String> protocols = new ArrayList<String>();
+        protocols.add("http://docs.oasis-open.org/wsfed/federation/200706");
+        idp.setSupportedProtocols(protocols);
+        List<String> tokenTypes = new ArrayList<String>();
+        tokenTypes.add(WSConstants.SAML2_NS);
+        idp.setTokenTypesOffered(tokenTypes);
+        idp.setUseCurrentIDP(false);
+        idpDAO.updateIdp(realm, idp);
+        
+        idp = idpDAO.getIdp(realm, null);
+        
+        Assert.isTrue("UstsKeystoreA.properties".equals(idp.getCertificate()),
+                      "Certificate doesn't match");
+        Assert.isTrue("Urealma".equals(idp.getCertificatePassword()),
+                      "Certificate password doesn't match");
+        Assert.isTrue(realm.equals(idp.getRealm()),
+                      "Realm doesn't match");
+        Assert.isTrue("UIDP of New Realm".equals(idp.getServiceDescription()),
+                      "ServiceDescription doesn't match");
+        Assert.isTrue("UNEW REALM".equals(idp.getServiceDisplayName()),
+                      "ServiceDisplayName doesn't match");        
+        Assert.isTrue("Uhttps://localhost:9443/fediz-idp/federation".equals(idp.getIdpUrl()),
+                      "IdpUrl doesn't match");
+        Assert.isTrue("Uhttps://localhost:9443/fediz-idp-sts/REALMA".equals(idp.getStsUrl()),
+                      "StsUrl doesn't match");
+        Assert.isTrue("Urealmn".equals(idp.getUri()),
+                      "Uri doesn't match");
+        Assert.isTrue(idp.isProvideIDPList(),
+                      "ProvideIDPList doesn't match");
+        Assert.isTrue(!idp.isUseCurrentIDP(),
+                      "UseCurrentIDP doesn't match");
+        Assert.isTrue(1 == idp.getAuthenticationURIs().size(),
+                      "Number of AuthenticationURIs doesn't match");
+        Assert.isTrue(1 == idp.getSupportedProtocols().size(),
+                      "Number of SupportedProtocols doesn't match");
+        Assert.isTrue(1 == idp.getTokenTypesOffered().size(),
+                      "Number of TokenTypesOffered doesn't match");
+        Assert.isTrue(0 == idp.getApplications().size(),
+                      "Number of applications doesn't match");
+        Assert.isTrue(0 == idp.getTrustedIdps().size(),
+                      "Number of trusted IDPs doesn't match");
+        Assert.isTrue(0 == idp.getClaimTypesOffered().size(),
+                      "Number of claims doesn't match");
+        
+    }
+     */
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryRemoveUnknownClaim() {
+        claimDAO.deleteClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/town/WRONG");
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testRemoveExistingClaim() {
+        claimDAO.deleteClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/email");
+        
+        claimDAO.getClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/email");
+    }
+    
+
+}

Added: 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=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPATest.java (added)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/IdpDAOJPATest.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,660 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.fediz.service.idp.service.jpa;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+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;
+import org.apache.cxf.fediz.service.idp.domain.TrustedIdp;
+import org.apache.cxf.fediz.service.idp.service.IdpDAO;
+import org.apache.ws.security.WSConstants;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.util.Assert;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:testContext.xml" })
+public class IdpDAOJPATest {
+
+    @Autowired
+    private IdpDAO idpDAO;
+    
+    
+    @BeforeClass
+    public static void init() {
+        System.setProperty("spring.profiles.active", "jpa");
+    }
+    
+    
+    @Test
+    public void testReadAllIdps() {
+        List<Idp> idps = idpDAO.getIdps(0, 999, null);
+        // Idp could have been removed, Order not given as per JUnit design
+        Assert.isTrue(0 < idps.size(), "Size doesn't match [" + idps.size() + "]");
+    }
+    
+    
+    @Test
+    public void testReadExistingIdpEmbeddedAll() {
+        Idp idp = idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:realm-A",
+                                                                Arrays.asList("all"));
+        
+        Assert.isTrue("stsKeystoreA.properties".equals(idp.getCertificate()),
+                      "Certificate doesn't match");
+        Assert.isTrue("realma".equals(idp.getCertificatePassword()),
+                      "Certificate password doesn't match");
+        Assert.isTrue("urn:org:apache:cxf:fediz:idp:realm-A".equals(idp.getRealm()),
+                      "Realm doesn't match");
+        Assert.isTrue("IDP of Realm A".equals(idp.getServiceDescription()),
+                      "ServiceDescription doesn't match");
+        Assert.isTrue("REALM A".equals(idp.getServiceDisplayName()),
+                      "ServiceDisplayName doesn't match");        
+        Assert.isTrue("https://localhost:9443/fediz-idp/federation".equals(idp.getIdpUrl()),
+                      "IdpUrl doesn't match");
+        Assert.isTrue("https://localhost:9443/fediz-idp-sts/REALMA".equals(idp.getStsUrl()),
+                      "StsUrl doesn't match");
+        Assert.isTrue("realma".equals(idp.getUri()),
+                      "Uri doesn't match");
+        Assert.isTrue(idp.isProvideIDPList(),
+                      "ProvideIDPList doesn't match");
+        Assert.isTrue(idp.isUseCurrentIDP(),
+                      "UseCurrentIDP doesn't match");
+        Assert.isTrue(1 == idp.getAuthenticationURIs().size(),
+                      "Number of AuthenticationURIs doesn't match");
+        Assert.isTrue(2 == idp.getSupportedProtocols().size(),
+                      "Number of SupportedProtocols doesn't match");
+        Assert.isTrue(2 == idp.getTokenTypesOffered().size(),
+                      "Number of TokenTypesOffered doesn't match");
+        Assert.isTrue(1 == idp.getApplications().size(),
+                      "Number of applications doesn't match");
+        Assert.isTrue(1 == idp.getTrustedIdps().size(),
+                      "Number of trusted IDPs doesn't match");
+        Assert.isTrue(4 == idp.getClaimTypesOffered().size(),
+                      "Number of claims doesn't match");
+    }
+    
+    @Test
+    public void testReadExistingIdpEmbeddedTrustedIdps() {
+        Idp idp = idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:realm-A",
+                                                                Arrays.asList("trusted-idps"));
+        
+        Assert.isTrue(1 == idp.getTrustedIdps().size(),
+                      "Number of trusted IDPs doesn't match");
+    }
+    
+    @Test
+    public void testReadExistingIdpEmbeddedClaims() {
+        Idp idp = idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:realm-A",
+                                                                Arrays.asList("claims"));
+        
+        Assert.isTrue(4 == idp.getClaimTypesOffered().size(),
+                      "Number of claims doesn't match");
+    }
+    
+    @Test
+    public void testReadExistingIdpEmbeddedApplications() {
+        Idp idp = idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:realm-A",
+                                                                Arrays.asList("applications"));
+        
+        Assert.isTrue(1 == idp.getApplications().size(),
+                      "Number of applications doesn't match");
+    }
+    
+    @Test
+    public void testReadExistingIdpEmbeddedNull() {
+        Idp idp = idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:realm-A",
+                                                                null);
+        
+        Assert.isTrue(0 == idp.getClaimTypesOffered().size(),
+                      "Number of claims doesn't match");
+        Assert.isTrue(0 == idp.getApplications().size(),
+                      "Number of applications doesn't match");
+        Assert.isTrue(0 == idp.getTrustedIdps().size(),
+                      "Number of trusted IDPs doesn't match");
+       
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryReadNonexistingIdp() {
+        idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:NOTEXIST", null);
+    }
+    
+    
+    @Test
+    public void testAddNewIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:testadd");
+        idp.setCertificate("stsKeystoreA.properties");
+        idp.setCertificatePassword("realma");
+        idp.setIdpUrl("https://localhost:9443/fediz-idp/federation");
+        idp.setStsUrl("https://localhost:9443/fediz-idp-sts/REALMN");
+        idp.setServiceDisplayName("NEW REALM");
+        idp.setServiceDescription("IDP of New Realm");
+        idp.setUri("realmn");
+        idp.setProvideIDPList(true);
+        Map<String, String> authUris = new HashMap<String, String>();
+        authUris.put("default", "/login/default");
+        idp.setAuthenticationURIs(authUris);
+        List<String> protocols = new ArrayList<String>();
+        protocols.add("http://docs.oasis-open.org/wsfed/federation/200706");
+        protocols.add("http://docs.oasis-open.org/ws-sx/ws-trust/200512");
+        idp.setSupportedProtocols(protocols);
+        List<String> tokenTypes = new ArrayList<String>();
+        tokenTypes.add(WSConstants.SAML2_NS);
+        tokenTypes.add(WSConstants.SAML_NS);
+        idp.setTokenTypesOffered(tokenTypes);
+        idp.setUseCurrentIDP(true);
+        
+        idpDAO.addIdp(idp);
+        
+        idp = idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:testadd", null);
+        
+        Assert.isTrue("stsKeystoreA.properties".equals(idp.getCertificate()),
+                      "Certificate doesn't match");
+        Assert.isTrue("realma".equals(idp.getCertificatePassword()),
+                      "Certificate password doesn't match");
+        Assert.isTrue("urn:org:apache:cxf:fediz:idp:testadd".equals(idp.getRealm()),
+                      "Realm doesn't match");
+        Assert.isTrue("IDP of New Realm".equals(idp.getServiceDescription()),
+                      "ServiceDescription doesn't match");
+        Assert.isTrue("NEW REALM".equals(idp.getServiceDisplayName()),
+                      "ServiceDisplayName doesn't match");        
+        Assert.isTrue("https://localhost:9443/fediz-idp/federation".equals(idp.getIdpUrl()),
+                      "IdpUrl doesn't match");
+        Assert.isTrue("https://localhost:9443/fediz-idp-sts/REALMN".equals(idp.getStsUrl()),
+                      "StsUrl doesn't match");
+        Assert.isTrue("realmn".equals(idp.getUri()),
+                      "Uri doesn't match");
+        Assert.isTrue(idp.isProvideIDPList(),
+                      "ProvideIDPList doesn't match");
+        Assert.isTrue(idp.isUseCurrentIDP(),
+                      "UseCurrentIDP doesn't match");
+        Assert.isTrue(1 == idp.getAuthenticationURIs().size(),
+                      "Number of AuthenticationURIs doesn't match");
+        Assert.isTrue(2 == idp.getSupportedProtocols().size(),
+                      "Number of SupportedProtocols doesn't match");
+        Assert.isTrue(2 == idp.getTokenTypesOffered().size(),
+                      "Number of TokenTypesOffered doesn't match");
+        Assert.isTrue(0 == idp.getApplications().size(),
+                      "Number of applications doesn't match");
+        Assert.isTrue(0 == idp.getTrustedIdps().size(),
+                      "Number of trusted IDPs doesn't match");
+        Assert.isTrue(0 == idp.getClaimTypesOffered().size(),
+                      "Number of claims doesn't match");
+
+    }
+    
+    
+    @Test(expected = DataIntegrityViolationException.class)
+    public void testTryAddExistingIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+        
+        idpDAO.addIdp(idp);
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryRemoveUnknownIdp() {
+        idpDAO.deleteIdp("urn:org:apache:cxf:fediz:idp:NOTEXIST");
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testRemoveExistingIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:testdelete");
+        
+        idpDAO.addIdp(idp);
+        
+        idpDAO.deleteIdp("urn:org:apache:cxf:fediz:idp:testdelete");
+        
+        idpDAO.getIdp("urn:org:apache:cxf:fediz:idp:testdelete", null);
+    }
+    
+    @Test
+    public void testUpdateIdp() {
+        String realm = "urn:org:apache:cxf:fediz:idp:testupdate";
+        //Prepare
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        //Testcase
+        idp = new Idp();
+        idp.setRealm(realm);
+        idp.setCertificate("UstsKeystoreA.properties");
+        idp.setCertificatePassword("Urealma");
+        idp.setIdpUrl("Uhttps://localhost:9443/fediz-idp/federation");
+        idp.setStsUrl("Uhttps://localhost:9443/fediz-idp-sts/REALMA");
+        idp.setServiceDisplayName("UNEW REALM");
+        idp.setServiceDescription("UIDP of New Realm");
+        idp.setUri("Urealmn");
+        idp.setProvideIDPList(true);
+        Map<String, String> authUris = new HashMap<String, String>();
+        authUris.put("default", "/login/default");
+        idp.setAuthenticationURIs(authUris);
+        List<String> protocols = new ArrayList<String>();
+        protocols.add("http://docs.oasis-open.org/wsfed/federation/200706");
+        idp.setSupportedProtocols(protocols);
+        List<String> tokenTypes = new ArrayList<String>();
+        tokenTypes.add(WSConstants.SAML2_NS);
+        idp.setTokenTypesOffered(tokenTypes);
+        idp.setUseCurrentIDP(false);
+        idpDAO.updateIdp(realm, idp);
+        
+        idp = idpDAO.getIdp(realm, null);
+        
+        Assert.isTrue("UstsKeystoreA.properties".equals(idp.getCertificate()),
+                      "Certificate doesn't match");
+        Assert.isTrue("Urealma".equals(idp.getCertificatePassword()),
+                      "Certificate password doesn't match");
+        Assert.isTrue(realm.equals(idp.getRealm()),
+                      "Realm doesn't match");
+        Assert.isTrue("UIDP of New Realm".equals(idp.getServiceDescription()),
+                      "ServiceDescription doesn't match");
+        Assert.isTrue("UNEW REALM".equals(idp.getServiceDisplayName()),
+                      "ServiceDisplayName doesn't match");        
+        Assert.isTrue("Uhttps://localhost:9443/fediz-idp/federation".equals(idp.getIdpUrl()),
+                      "IdpUrl doesn't match");
+        Assert.isTrue("Uhttps://localhost:9443/fediz-idp-sts/REALMA".equals(idp.getStsUrl()),
+                      "StsUrl doesn't match");
+        Assert.isTrue("Urealmn".equals(idp.getUri()),
+                      "Uri doesn't match");
+        Assert.isTrue(idp.isProvideIDPList(),
+                      "ProvideIDPList doesn't match");
+        Assert.isTrue(!idp.isUseCurrentIDP(),
+                      "UseCurrentIDP doesn't match");
+        Assert.isTrue(1 == idp.getAuthenticationURIs().size(),
+                      "Number of AuthenticationURIs doesn't match");
+        Assert.isTrue(1 == idp.getSupportedProtocols().size(),
+                      "Number of SupportedProtocols doesn't match");
+        Assert.isTrue(1 == idp.getTokenTypesOffered().size(),
+                      "Number of TokenTypesOffered doesn't match");
+        Assert.isTrue(0 == idp.getApplications().size(),
+                      "Number of applications doesn't match");
+        Assert.isTrue(0 == idp.getTrustedIdps().size(),
+                      "Number of trusted IDPs doesn't match");
+        Assert.isTrue(0 == idp.getClaimTypesOffered().size(),
+                      "Number of claims doesn't match");
+        
+    }
+    
+    @Test(expected = NoResultException.class)
+    public void testUpdateUnknownIdp() {
+        String realm = "urn:org:apache:cxf:fediz:idp:testupdate2";
+        
+        //Prepare
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        //Testcase
+        idp = new Idp();
+        idp.setRealm(realm);
+        idp.setCertificate("UstsKeystoreA.properties");
+        idp.setCertificatePassword("Urealma");
+        idp.setIdpUrl("Uhttps://localhost:9443/fediz-idp/federation");
+        idp.setStsUrl("Uhttps://localhost:9443/fediz-idp-sts/REALMN");
+        idp.setServiceDisplayName("UNEW REALM");
+        idp.setServiceDescription("UIDP of New Realm");
+        idp.setUri("Urealmn");
+        idp.setProvideIDPList(true);
+        Map<String, String> authUris = new HashMap<String, String>();
+        authUris.put("default", "/login/default");
+        idp.setAuthenticationURIs(authUris);
+        List<String> protocols = new ArrayList<String>();
+        protocols.add("http://docs.oasis-open.org/wsfed/federation/200706");
+        idp.setSupportedProtocols(protocols);
+        List<String> tokenTypes = new ArrayList<String>();
+        tokenTypes.add(WSConstants.SAML2_NS);
+        idp.setTokenTypesOffered(tokenTypes);
+        idp.setUseCurrentIDP(false);
+        idpDAO.updateIdp("urn:UNKNOWN", idp);
+    }
+    
+    @Test
+    public void testAddClaimToIdp() {
+        String realm = "urn:org:apache:cxf:fediz:idp:testaddclaim";
+        
+        //Prepare
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        //Testcase
+        Claim claim = new Claim();
+        claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
+        
+        idpDAO.addClaimToIdp(idp, claim);
+               
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        
+        Assert.isTrue(1 == idp.getClaimTypesOffered().size(), "claimTypesOffered size doesn't match");
+    }
+    
+    @Test(expected = DataIntegrityViolationException.class)
+    public void testTryAddExistingClaimToIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+        
+        Claim claim = new Claim();
+        claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
+        
+        idpDAO.addClaimToIdp(idp, claim);
+    }
+    
+    @Test(expected = NoResultException.class)
+    public void testTryAddUnknownClaimToIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+        
+        Claim claim = new Claim();
+        claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/UNKOWN"));
+        
+        idpDAO.addClaimToIdp(idp, claim);
+        
+    }
+    
+    @Test
+    public void testRemoveClaimFromIdp() {
+        String realm = "urn:org:apache:cxf:fediz:fedizhelloworld:testremoveclaim";
+        //Prepare step
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        Claim claim = new Claim();
+        claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"));
+        idpDAO.addClaimToIdp(idp, claim);
+               
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        Assert.isTrue(1 == idp.getClaimTypesOffered().size(),
+                      "claimTypesOffered size doesn't match [" + idp.getClaimTypesOffered().size() + "]");
+        
+        //Testcase
+        idpDAO.removeClaimFromIdp(idp, claim);
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        Assert.isTrue(0 == idp.getClaimTypesOffered().size(),
+                      "claimTypesOffered size doesn't match [" + idp.getClaimTypesOffered().size() + "]");
+    }
+    
+    @Test(expected = EntityNotFoundException.class)
+    public void testTryRemoveNotAssignedClaimFromIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+                
+        Claim claim = new Claim();
+        claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/city"));
+        
+        idpDAO.removeClaimFromIdp(idp, claim);
+    }
+    
+    @Test(expected = NoResultException.class)
+    public void testTryRemoveUnknownClaimFromIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+                
+        Claim claim = new Claim();
+        claim.setClaimType(URI.create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/UNKNOWN"));
+        
+        idpDAO.removeClaimFromIdp(idp, claim);
+    }
+    
+    @Test
+    public void testAddApplicationToIdp() {
+        String realm = "urn:org:apache:cxf:fediz:app:testaddApplication";
+        
+        //Prepare
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        //Testcase
+        //Application app = createApplication(realm);
+        Application app = new Application();
+        app.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
+        idpDAO.addApplicationToIdp(idp, app);
+               
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        
+        Assert.isTrue(1 == idp.getApplications().size(), "applications size doesn't match");
+    }
+    
+    
+    @Test(expected = DataIntegrityViolationException.class)
+    public void testTryAddExistingApplicationToIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+        
+        Application app = new Application();
+        app.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
+        
+        idpDAO.addApplicationToIdp(idp, app);
+    }
+    
+    @Test(expected = NoResultException.class)
+    public void testTryAddUnknownApplicationToIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+        
+        Application app = new Application();
+        app.setRealm("urn:org:apache:cxf:fediz:UNKNOWN");
+        
+        idpDAO.addApplicationToIdp(idp, app);
+        
+    }
+    
+    @Test
+    public void testRemoveApplicationFromIdp() {
+        String realm = "urn:org:apache:cxf:fediz:fedizhelloworld:testremoveapp";
+        //Prepare step
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        Application app = new Application();
+        app.setRealm("urn:org:apache:cxf:fediz:fedizhelloworld");
+        idpDAO.addApplicationToIdp(idp, app);
+               
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        Assert.isTrue(1 == idp.getApplications().size(),
+                      "applications size doesn't match [" + idp.getApplications().size() + "]");
+        
+        //Testcase
+        idpDAO.removeApplicationFromIdp(idp, app);
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        Assert.isTrue(0 == idp.getApplications().size(),
+                      "applications size doesn't match [" + idp.getApplications().size() + "]");
+    }
+    
+    
+    @Test(expected = EntityNotFoundException.class)
+    public void testTryRemoveNotAssignedApplicationFromIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+                
+        Application app = new Application();
+        app.setRealm("myrealm2");
+        
+        idpDAO.removeApplicationFromIdp(idp, app);
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryRemoveUnknownApplicationFromIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+                
+        Application app = new Application();
+        app.setRealm("urn:org:apache:cxf:fediz:UNKNOWN");
+        
+        idpDAO.removeApplicationFromIdp(idp, app);
+    }
+    
+    
+    
+    
+    
+    
+    @Test
+    public void testAddTrustedIdpToIdp() {
+        String realm = "urn:org:apache:cxf:fediz:trusted-idp:testaddTrustedIdp";
+        
+        //Prepare
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        //Testcase
+        //Application app = createApplication(realm);
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm("urn:org:apache:cxf:fediz:idp:realm-B");
+        idpDAO.addTrustedIdpToIdp(idp, trustedIdp);
+               
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        
+        Assert.isTrue(1 == idp.getTrustedIdps().size(), "applications size doesn't match");
+    }
+    
+    /*
+    @Test(expected = DataIntegrityViolationException.class)
+    public void testTryAddExistingTrustedIdpToIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+        
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm("urn:org:apache:cxf:fediz:idp:realm-B");
+        
+        idpDAO.addTrustedIdpToIdp(idp, trustedIdp);
+    }
+    
+    @Test(expected = NoResultException.class)
+    public void testTryAddUnknownTrustedIdpToIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+        
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm("urn:org:apache:cxf:fediz:UNKNOWN");
+        
+        idpDAO.addTrustedIdpToIdp(idp, trustedIdp);
+    }
+    
+    @Test
+    public void testRemoveTrustedIdpFromIdp() {
+        String realm = "urn:org:apache:cxf:fediz:trustedidp:testremove";
+        //Prepare step
+        Idp idp = createIdp(realm);
+        idpDAO.addIdp(idp);
+        
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm("urn:org:apache:cxf:fediz:idp:realm-B");
+        idpDAO.addTrustedIdpToIdp(idp, trustedIdp);
+               
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        Assert.isTrue(1 == idp.getTrustedIdps().size(),
+                      "trustedIdps size doesn't match [" + idp.getTrustedIdps().size() + "]");
+        
+        //Testcase
+        idpDAO.removeTrustedIdpFromIdp(idp, trustedIdp);
+        idp = idpDAO.getIdp(realm, Arrays.asList("all"));
+        Assert.isTrue(0 == idp.getTrustedIdps().size(),
+                      "trustedIdps size doesn't match [" + idp.getTrustedIdps().size() + "]");
+    }
+    
+    
+    @Test(expected = EntityNotFoundException.class)
+    public void testTryRemoveNotAssignedTrustedIdpFromIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+                
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm("trustedidp2realm");
+        
+        idpDAO.removeTrustedIdpFromIdp(idp, trustedIdp);
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryRemoveUnknownTrustedIdpFromIdp() {
+        Idp idp = new Idp();
+        idp.setRealm("urn:org:apache:cxf:fediz:idp:realm-A");
+                
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm("urn:org:apache:cxf:fediz:UNKNOWN");
+        
+        idpDAO.removeTrustedIdpFromIdp(idp, trustedIdp);
+    }
+    */
+    
+    
+    private static Idp createIdp(String realm) {
+        Idp idp = new Idp();
+        idp.setRealm(realm);
+        idp.setCertificate("stsKeystoreA.properties");
+        idp.setCertificatePassword("realma");
+        idp.setIdpUrl("https://localhost:9443/fediz-idp/federation");
+        idp.setStsUrl("https://localhost:9443/fediz-idp-sts/REALMA");
+        idp.setServiceDisplayName("NEW REALM");
+        idp.setServiceDescription("IDP of New Realm");
+        idp.setUri("realma");
+        idp.setProvideIDPList(true);
+        Map<String, String> authUris = new HashMap<String, String>();
+        authUris.put("default", "/login/default");
+        idp.setAuthenticationURIs(authUris);
+        List<String> protocols = new ArrayList<String>();
+        protocols.add("http://docs.oasis-open.org/wsfed/federation/200706");
+        protocols.add("http://docs.oasis-open.org/ws-sx/ws-trust/200512");
+        idp.setSupportedProtocols(protocols);
+        List<String> tokenTypes = new ArrayList<String>();
+        tokenTypes.add(WSConstants.SAML2_NS);
+        tokenTypes.add(WSConstants.SAML_NS);
+        idp.setTokenTypesOffered(tokenTypes);
+        idp.setUseCurrentIDP(true);
+        return idp;
+    }
+    /*
+    private static Application createApplication(String realm) {
+        Application application = new Application();
+        application.setRealm(realm);
+        application.setEncryptionCertificate("");
+        application.setLifeTime("3600");
+        application.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
+        application.setRole("ApplicationServiceType");
+        application.setServiceDescription("Fedizhelloworld description");
+        application.setServiceDisplayName("Fedizhelloworld");
+        application.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
+        return application;
+    }
+    */
+    
+
+}

Added: cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TestDBLoader.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TestDBLoader.java?rev=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TestDBLoader.java (added)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TestDBLoader.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.fediz.service.idp.service.jpa;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
+
+@Transactional
+public class TestDBLoader implements DBLoader {
+    
+    public static final String NAME = "UNITTESTDBLOADER";
+    
+    private static final Logger LOG = LoggerFactory.getLogger(TestDBLoader.class);
+    
+    private EntityManager em;
+
+    @PersistenceContext
+    public void setEntityManager(EntityManager entityManager) {
+        this.em = entityManager;
+    }
+    
+    @Override
+    public String getName() {
+        return NAME;
+    }
+    
+    public void load() {
+        
+        try {
+            ClaimEntity claimEntity5 = new ClaimEntity();
+            claimEntity5.setClaimType("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/city");
+            claimEntity5.setDisplayName("city");
+            claimEntity5.setDescription("Description for city");
+            em.persist(claimEntity5);
+                        
+            ApplicationEntity entity2 = new ApplicationEntity();
+            entity2.setEncryptionCertificate("my encryption cert2");
+            entity2.setLifeTime("22my lifetime");
+            entity2.setProtocol("22protocol");
+            entity2.setRealm("myrealm2");
+            entity2.setRole("myrole");
+            entity2.setServiceDescription("service description2");
+            entity2.setServiceDisplayName("service displayname2");
+            entity2.setTokenType("my tokentype");
+            // must be persistet here already as the ApplicationClaimEntity requires the Application Id
+            em.persist(entity2);
+            ApplicationClaimEntity ace5 = new ApplicationClaimEntity(entity2, claimEntity5);
+            ace5.setOptional(false);
+            em.persist(ace5);
+            entity2.getRequestedClaims().add(ace5);
+            em.persist(entity2);
+            
+            TrustedIdpEntity entity4 = new TrustedIdpEntity();
+            entity4.setCacheTokens(true);
+            entity4.setCertificate("trusted cert");
+            entity4.setDescription("Realm B description");
+            entity4.setFederationType("FederateIdentity");
+            entity4.setName("Realm B");
+            entity4.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
+            entity4.setRealm("trustedidp2realm");
+            entity4.setTrustType("PEER_TRUST");
+            entity4.setUrl("https://localhost:${realmB.port}/fediz-idp-remote/federation");
+            em.persist(entity4);
+            
+            em.flush();
+            
+        } catch (Exception ex) {
+            LOG.warn("Failed to initialize DB with data", ex);
+        }
+    }
+}

Added: 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=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPATest.java (added)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/service/jpa/TrustedIdpDAOJPATest.java Wed Jan 22 21:47:02 2014
@@ -0,0 +1,203 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.fediz.service.idp.service.jpa;
+
+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;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.util.Assert;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:testContext.xml" })
+public class TrustedIdpDAOJPATest {
+
+    @Autowired
+    private TrustedIdpDAO trustedIdpDAO;
+        
+    
+    @BeforeClass
+    public static void init() {
+        System.setProperty("spring.profiles.active", "jpa");
+    }
+    
+    
+    @Test
+    public void testReadAllTrustedIdps() {
+        List<TrustedIdp> trustedIdps = trustedIdpDAO.getTrustedIDPs(0, 999);
+        Assert.isTrue(2 <= trustedIdps.size(), "Size doesn't match");
+    }
+    
+    @Test
+    public void testReadExistingTrustedIdp() {
+        TrustedIdp trustedIdp = trustedIdpDAO.getTrustedIDP("urn:org:apache:cxf:fediz:idp:realm-B");
+        Assert.isTrue("trusted cert".equals(trustedIdp.getCertificate()),
+                      "Certificate name doesn't match");
+        Assert.isTrue("Realm B description".equals(trustedIdp.getDescription()),
+                      "Description name doesn't match");
+        Assert.isTrue("FederateIdentity".equals(trustedIdp.getFederationType()),
+                      "FederationType doesn't match");        
+        Assert.isTrue("Realm B".equals(trustedIdp.getName()),
+                      "Name doesn't match");      
+        Assert.isTrue("http://docs.oasis-open.org/wsfed/federation/200706".equals(trustedIdp.getProtocol()),
+                      "Protocol doesn't match");          
+        Assert.isTrue("urn:org:apache:cxf:fediz:idp:realm-B".equals(trustedIdp.getRealm()),
+                      "Realm doesn't match");          
+        Assert.isTrue("PEER_TRUST".equals(trustedIdp.getTrustType()),
+                      "TrustType doesn't match");
+        Assert.isTrue("https://localhost:${realmB.port}/fediz-idp-remote/federation".equals(trustedIdp.getUrl()),
+                      "Url doesn't match"); 
+        Assert.isTrue(trustedIdp.isCacheTokens(), "CacheTokens doesn't match"); 
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryReadNonexistingTrustedIdp() {
+        trustedIdpDAO.getTrustedIDP("urn:org:apache:cxf:fediz:idp:NOTEXIST");
+    }
+    
+    
+    @Test
+    public void testAddNewTrustedIdp() {
+        String realm = "urn:org:apache:cxf:fediz:trusted-idp:testadd";
+        TrustedIdp trustedIdp = createTrustedIdp(realm);
+        trustedIdpDAO.addTrustedIDP(trustedIdp);
+        
+        trustedIdp = trustedIdpDAO.getTrustedIDP(realm);
+        
+        Assert.isTrue("trusted cert".equals(trustedIdp.getCertificate()),
+                      "Certificate name doesn't match");
+        Assert.isTrue("Realm B description".equals(trustedIdp.getDescription()),
+                      "Description name doesn't match");
+        Assert.isTrue("FederateIdentity".equals(trustedIdp.getFederationType()),
+                      "FederationType doesn't match");        
+        Assert.isTrue("Realm B".equals(trustedIdp.getName()),
+                      "Name doesn't match");      
+        Assert.isTrue("http://docs.oasis-open.org/wsfed/federation/200706".equals(trustedIdp.getProtocol()),
+                      "Protocol doesn't match");          
+        Assert.isTrue(realm.equals(trustedIdp.getRealm()),
+                      "Realm doesn't match");          
+        Assert.isTrue("PEER_TRUST".equals(trustedIdp.getTrustType()),
+                      "TrustType doesn't match");
+        Assert.isTrue("https://localhost:${realmB.port}/fediz-idp-remote/federation".equals(trustedIdp.getUrl()),
+                      "Url doesn't match"); 
+        Assert.isTrue(!trustedIdp.isCacheTokens(), "CacheTokens doesn't match"); 
+    }
+    
+    
+    @Test
+    public void testUpdateTrustedIdp() {
+        String realm = "urn:org:apache:cxf:fediz:trusted-idp:testupdate";
+        //Prepare
+        TrustedIdp trustedIdp = createTrustedIdp(realm);
+        trustedIdpDAO.addTrustedIDP(trustedIdp);
+        
+        //Testcase
+        trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm(realm);
+        trustedIdp.setCacheTokens(true);
+        trustedIdp.setCertificate("Utrusted cert");
+        trustedIdp.setDescription("URealm B description");
+        trustedIdp.setFederationType("UFederateIdentity");
+        trustedIdp.setName("URealm B");
+        trustedIdp.setProtocol("Uhttp://docs.oasis-open.org/wsfed/federation/200706");
+        trustedIdp.setTrustType("UPEER_TRUST");
+        trustedIdp.setUrl("Uhttps://localhost:${realmB.port}/fediz-idp-remote/federation");
+        
+        trustedIdpDAO.updateTrustedIDP(realm, trustedIdp);
+        
+        trustedIdp = trustedIdpDAO.getTrustedIDP(realm);
+        
+        Assert.isTrue("Utrusted cert".equals(trustedIdp.getCertificate()),
+                      "Certificate name doesn't match");
+        Assert.isTrue("URealm B description".equals(trustedIdp.getDescription()),
+                      "Description name doesn't match");
+        Assert.isTrue("UFederateIdentity".equals(trustedIdp.getFederationType()),
+                      "FederationType doesn't match");        
+        Assert.isTrue("URealm B".equals(trustedIdp.getName()),
+                      "Name doesn't match");      
+        Assert.isTrue("Uhttp://docs.oasis-open.org/wsfed/federation/200706".equals(trustedIdp.getProtocol()),
+                      "Protocol doesn't match");          
+        Assert.isTrue(realm.equals(trustedIdp.getRealm()),
+                      "Realm doesn't match");          
+        Assert.isTrue("UPEER_TRUST".equals(trustedIdp.getTrustType()),
+                      "TrustType doesn't match");
+        Assert.isTrue("Uhttps://localhost:${realmB.port}/fediz-idp-remote/federation".equals(trustedIdp.getUrl()),
+                      "Url doesn't match"); 
+        Assert.isTrue(trustedIdp.isCacheTokens(), "CacheTokens doesn't match");
+        
+    }
+    
+    
+    @Test(expected = DataIntegrityViolationException.class)
+    public void testTryAddExistingTrustedIdp() {
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm("urn:org:apache:cxf:fediz:idp:realm-B");
+        trustedIdpDAO.addTrustedIDP(trustedIdp);
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testTryRemoveUnknownTrustedIdp() {
+        trustedIdpDAO.deleteTrustedIDP("urn:org:apache:cxf:fediz:trusted-idp:NOTEXIST");
+    }
+    
+    
+    @Test(expected = NoResultException.class)
+    public void testRemoveExistingTrustedIdp() {
+        String realm = "urn:org:apache:cxf:fediz:trusted-idp:testdelete";
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm(realm);
+        
+        trustedIdpDAO.addTrustedIDP(trustedIdp);
+        
+        trustedIdpDAO.deleteTrustedIDP(realm);
+        
+        trustedIdpDAO.getTrustedIDP(realm);
+    }
+    
+    
+    private static TrustedIdp createTrustedIdp(String realm) {
+        TrustedIdp trustedIdp = new TrustedIdp();
+        trustedIdp.setRealm(realm);
+        trustedIdp.setCacheTokens(false);
+        trustedIdp.setCertificate("trusted cert");
+        trustedIdp.setDescription("Realm B description");
+        trustedIdp.setFederationType("FederateIdentity");
+        trustedIdp.setName("Realm B");
+        trustedIdp.setProtocol("http://docs.oasis-open.org/wsfed/federation/200706");
+        trustedIdp.setTrustType("PEER_TRUST");
+        trustedIdp.setUrl("https://localhost:${realmB.port}/fediz-idp-remote/federation");
+        return trustedIdp;
+    }
+    
+
+}

Modified: cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/util/MetadataWriterTest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/util/MetadataWriterTest.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/util/MetadataWriterTest.java (original)
+++ cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/util/MetadataWriterTest.java Wed Jan 22 21:47:02 2014
@@ -21,7 +21,7 @@ package org.apache.cxf.fediz.service.idp
 
 import org.w3c.dom.Document;
 
-import org.apache.cxf.fediz.service.idp.model.IDPConfig;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
 import org.apache.cxf.fediz.service.idp.service.ConfigService;
 import org.apache.ws.security.util.DOM2Writer;
 
@@ -45,7 +45,7 @@ public class MetadataWriterTest {
     public void testWriteIDPMetadata() {
         ConfigService config = (ConfigService)applicationContext.getBean("config");
         Assert.notNull(config, "ConfigService must not be null");
-        IDPConfig idpConfig = config.getIDPConfig("urn:org:apache:cxf:fediz:idp:realm-A");
+        Idp idpConfig = config.getIDP("urn:org:apache:cxf:fediz:idp:realm-A");
         Assert.notNull(idpConfig, "IDPConfig must not be null");
         
         MetadataWriter writer = new MetadataWriter();

Added: 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=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/resources/persistence.properties (added)
+++ cxf/fediz/trunk/services/idp/src/test/resources/persistence.properties Wed Jan 22 21:47:02 2014
@@ -0,0 +1,14 @@
+#jpa.driverClassName=org.apache.derby.jdbc.ClientDriver
+#jpa.url=jdbc:derby://localhost:1527/Fediz
+#jpa.username=admin
+#jpa.password=admin
+#jpa.defaultData=true
+#jpa.platform=DerbyDictionary
+
+
+jpa.driverClassName=org.hsqldb.jdbcDriver
+jpa.url=jdbc:hsqldb:target/fediz/db/myDB;shutdown=true
+jpa.username=sa
+jpa.password=
+jpa.defaultData=true
+jpa.platform=HSQLDictionary
\ No newline at end of file

Added: cxf/fediz/trunk/services/idp/src/test/resources/testContext.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/resources/testContext.xml?rev=1560525&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/resources/testContext.xml (added)
+++ cxf/fediz/trunk/services/idp/src/test/resources/testContext.xml Wed Jan 22 21:47:02 2014
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:util="http://www.springframework.org/schema/util"
+    xmlns:context="http://www.springframework.org/schema/context"
+    xsi:schemaLocation="
+        http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+        http://www.springframework.org/schema/util
+        http://www.springframework.org/schema/util/spring-util-2.0.xsd
+        http://www.springframework.org/schema/context
+        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+    
+    <import resource="classpath:persistenceContext.xml" />
+    
+    <context:component-scan base-package="org.apache.cxf.fediz.service.idp.service"/>
+    
+    <!-- Use http://www.baeldung.com/2012/02/06/properties-with-spring/ instead -->
+      <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+    <property name="locations">
+      <list>
+        <value>classpath:persistence.properties</value>
+      </list>
+    </property>
+    <property name="ignoreResourceNotFound" value="true"/>
+    <property name="ignoreUnresolvablePlaceholders" value="true"/>
+  </bean>
+  
+  
+  <bean id="dbLoadertest" class="org.apache.cxf.fediz.service.idp.service.jpa.TestDBLoader" />
+
+</beans>
+

Modified: cxf/fediz/trunk/services/sts/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/sts/src/main/resources/log4j.properties?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/services/sts/src/main/resources/log4j.properties (original)
+++ cxf/fediz/trunk/services/sts/src/main/resources/log4j.properties Wed Jan 22 21:47:02 2014
@@ -9,7 +9,7 @@ log4j.logger.org.apache.cxf.sts.event.Lo
 
 # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=DEBUG
+log4j.appender.CONSOLE.Threshold=INFO
 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
 log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
 

Modified: cxf/fediz/trunk/systests/jetty8/pom.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/pom.xml?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/jetty8/pom.xml (original)
+++ cxf/fediz/trunk/systests/jetty8/pom.xml Wed Jan 22 21:47:02 2014
@@ -87,6 +87,12 @@
             <version>${slf4j.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>hsqldb</groupId>
+            <artifactId>hsqldb</artifactId>
+            <version>1.8.0.7</version>
+            <scope>test</scope>
+        </dependency>        
     </dependencies>
     <build>
         <testResources>

Modified: cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyPreAuthSpringTest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyPreAuthSpringTest.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyPreAuthSpringTest.java (original)
+++ cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyPreAuthSpringTest.java Wed Jan 22 21:47:02 2014
@@ -35,11 +35,11 @@ public class JettyPreAuthSpringTest exte
     public static void init() {
         System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
         System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
-        System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "debug"); 
+        System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info"); 
 
         idpHttpsPort = System.getProperty("idp.https.port");
         Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);

Modified: cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java (original)
+++ cxf/fediz/trunk/systests/jetty8/src/test/java/org/apache/cxf/fediz/integrationtests/JettyTest.java Wed Jan 22 21:47:02 2014
@@ -33,12 +33,12 @@ public class JettyTest extends AbstractT
     public static void init() {
         System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
         System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
-        System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "debug");
+        System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
         System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");
 
         idpHttpsPort = System.getProperty("idp.https.port");

Modified: cxf/fediz/trunk/systests/spring/pom.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/pom.xml?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/spring/pom.xml (original)
+++ cxf/fediz/trunk/systests/spring/pom.xml Wed Jan 22 21:47:02 2014
@@ -74,7 +74,13 @@
             <version>${project.version}</version>
             <type>test-jar</type>            
             <scope>test</scope>
-        </dependency>        
+        </dependency>
+        <dependency>
+            <groupId>hsqldb</groupId>
+            <artifactId>hsqldb</artifactId>
+            <version>1.8.0.7</version>
+            <scope>test</scope>
+        </dependency>                 
     </dependencies>
     <build>
         <testResources>

Modified: cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties (original)
+++ cxf/fediz/trunk/systests/spring/src/test/resources/log4j.properties Wed Jan 22 21:47:02 2014
@@ -1,13 +1,13 @@
 # Set root category priority to INFO and its only appender to CONSOLE.
 #log4j.rootLogger=INFO, CONSOLE
-log4j.rootLogger=DEBUG, CONSOLE
+log4j.rootLogger=INFO, CONSOLE
 #log4j.logger.org.springframework=INFO, CONSOLE
 #log4j.logger.org.springframework.security=DEBUG, CONSOLE,LOGFILE
 #log4j.logger.org.apache.cxf.fediz=DEBUG, CONSOLE,LOGFILE
 
 # CONSOLE is set to be a ConsoleAppender using a PatternLayout.
 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=DEBUG
+log4j.appender.CONSOLE.Threshold=INFO
 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
 log4j.appender.CONSOLE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n
 
@@ -15,6 +15,6 @@ log4j.appender.CONSOLE.layout.Conversion
 log4j.appender.LOGFILE=org.apache.log4j.FileAppender
 log4j.appender.LOGFILE.File=fedizhelloworld.log
 log4j.appender.LOGFILE.Append=false
-log4j.appender.LOGFILE.Threshold=DEBUG
+log4j.appender.LOGFILE.Threshold=INFO
 log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

Modified: cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties (original)
+++ cxf/fediz/trunk/systests/spring/src/test/resources/logging.properties Wed Jan 22 21:47:02 2014
@@ -24,7 +24,7 @@ handlers= java.util.logging.ConsoleHandl
 # can be overridden by a facility specific level
 # Note that the ConsoleHandler also has a separate level
 # setting to limit messages printed to the console.
-.level= FINEST
+.level= INFO
 
 ############################################################
 # Handler specific properties.
@@ -38,7 +38,7 @@ java.util.logging.FileHandler.count = 1
 java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
 
 # Limit the message that are printed on the console to WARNING and above.
-java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.level = INFO
 java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
 
 

Modified: cxf/fediz/trunk/systests/tomcat7/pom.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/tomcat7/pom.xml?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/tomcat7/pom.xml (original)
+++ cxf/fediz/trunk/systests/tomcat7/pom.xml Wed Jan 22 21:47:02 2014
@@ -88,7 +88,13 @@
          <artifactId>slf4j-jdk14</artifactId>
          <version>${slf4j.version}</version>
          <scope>test</scope>
-      </dependency> 
+      </dependency>
+        <dependency>
+            <groupId>hsqldb</groupId>
+            <artifactId>hsqldb</artifactId>
+            <version>1.8.0.7</version>
+            <scope>test</scope>
+        </dependency>      
    </dependencies>
    <build>
       <testResources>
@@ -195,6 +201,7 @@
                      <includes>
                         <include>**/integrationtests/**</include>
                      </includes>
+                     <argLine>-Xms512m -Xmx1024m -XX:MaxPermSize=256m</argLine> 
                   </configuration>
                </execution>
                <execution>

Modified: cxf/fediz/trunk/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java?rev=1560525&r1=1560524&r2=1560525&view=diff
==============================================================================
--- cxf/fediz/trunk/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java (original)
+++ cxf/fediz/trunk/systests/tomcat7/src/test/java/org/apache/cxf/fediz/integrationtests/TomcatTest.java Wed Jan 22 21:47:02 2014
@@ -70,11 +70,11 @@ public class TomcatTest extends Abstract
     public static void init() {
         System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
         System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
-        System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "debug");
-        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "debug");
+        System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web", "info");
+        System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz", "info");
         System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", "info");  
         
         idpHttpsPort = System.getProperty("idp.https.port");



Mime
View raw message