Index: topia-security/src/test/org/codelutin/topia/security/test/TopiaSecurityTest.java diff -u topia-security/src/test/org/codelutin/topia/security/test/TopiaSecurityTest.java:1.5 topia-security/src/test/org/codelutin/topia/security/test/TopiaSecurityTest.java:1.6 --- topia-security/src/test/org/codelutin/topia/security/test/TopiaSecurityTest.java:1.5 Fri Sep 15 16:12:04 2006 +++ topia-security/src/test/org/codelutin/topia/security/test/TopiaSecurityTest.java Mon Sep 18 15:49:25 2006 @@ -54,7 +54,7 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ protected static Log log = LogFactory.getLog(TopiaSecurityTest.class); - protected static String entitiesList = "org.codelutin.topia.security.test.person.PersonImpl,org.codelutin.topia.security.entities.user.TopiaUserImpl,org.codelutin.topia.security.entities.authorization.TopiaEntityAuthorizationImpl,org.codelutin.topia.security.entities.user.TopiaGroupImpl,org.codelutin.topia.security.entities.authorization.TopiaLinkAuthorizationImpl,org.codelutin.topia.security.entities.authorization.TopiaAssociationAuthorizationImpl,org.codelutin.topia.security.entities.authorization.TopiaAuthorizationImpl"; + protected static String entitiesList = TOPIA_SECURITY_PERSISTENCE_CLASSES + ",org.codelutin.topia.security.test.person.PersonImpl"; protected static Properties getProperties() { Properties config = new Properties(); @@ -63,7 +63,7 @@ config.setProperty("hibernate.show_sql", "true"); config.setProperty("topia.persistence.classes", entitiesList); - + config.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); config.setProperty("hibernate.connection.username", "sa"); config.setProperty("hibernate.connection.password", ""); @@ -84,17 +84,17 @@ /* DAOs Sécurité */ TopiaSecurityManager securityManager = new TopiaSecurityManagerImpl(context); - TopiaUserDAO topiaUserDAO = securityManager.getTopiaUserDAO(); - TopiaGroupDAO topiaGroupDAO = securityManager.getTopiaGroupDAO(); - TopiaEntityAuthorizationDAO topiaEntityAuthorizationDAO = securityManager.getTopiaEntityAuthorizationDAO(); - TopiaLinkAuthorizationDAO topiaLinkAuthorizationDAO = securityManager.getTopiaLinkAuthorizationDAO(); + TopiaUserDAO topiaUserDAO = ((TopiaSecurityManagerImpl)securityManager).getTopiaUserDAO(); + TopiaGroupDAO topiaGroupDAO = ((TopiaSecurityManagerImpl)securityManager).getTopiaGroupDAO(); + TopiaEntityAuthorizationDAO topiaEntityAuthorizationDAO = ((TopiaSecurityManagerImpl)securityManager).getTopiaEntityAuthorizationDAO(); + TopiaLinkAuthorizationDAO topiaLinkAuthorizationDAO = ((TopiaSecurityManagerImpl)securityManager).getTopiaLinkAuthorizationDAO(); /* Création d'un utilisateur */ TopiaUser thimel = topiaUserDAO.create(); thimel.setLogin("thimel"); thimel.setPassword("zou;bi@da"); thimel.update(); - securityManager.getTopiaSecurityContext().commitTransaction(); + securityManager.getSecurityContext().commitTransaction(); /* Création d'un groupe avec un utilisateur */ TopiaUser ruchaud = topiaUserDAO.create(); @@ -132,7 +132,7 @@ authorizationForThimel.setActions(LOAD); authorizationForThimel.setPrincipals(thimel.getTopiaId()); authorizationForThimel.update(); - securityManager.getTopiaSecurityContext().commitTransaction(); + securityManager.getSecurityContext().commitTransaction(); /* Création d'une autorisation Link */ TopiaLinkAuthorization linkAuthorization = topiaLinkAuthorizationDAO.create(); @@ -142,7 +142,7 @@ /* Commit */ childContext.commitTransaction(); - securityManager.getTopiaSecurityContext().commitTransaction(); + securityManager.getSecurityContext().commitTransaction(); /* Mise en marche de la sécurité */ securityManager.init(); Index: topia-security/src/test/org/codelutin/topia/security/test/TopiaSecurityTestWithTopia.java diff -u /dev/null topia-security/src/test/org/codelutin/topia/security/test/TopiaSecurityTestWithTopia.java:1.1 --- /dev/null Mon Sep 18 15:49:30 2006 +++ topia-security/src/test/org/codelutin/topia/security/test/TopiaSecurityTestWithTopia.java Mon Sep 18 15:49:25 2006 @@ -0,0 +1,72 @@ +/* *##% +* Copyright (C) 2002, 2003, 2004, 2005 Code Lutin, +* Cédric Pineau, Benjamin Poussin, +* +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*##%*/ + +package org.codelutin.topia.security.test; + +import static org.codelutin.topia.security.TopiaSecurityUtil.TOPIA_SECURITY_PERSISTENCE_CLASSES; + +import java.util.Properties; + +import junit.framework.TestCase; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaContextFactory; +import org.codelutin.topia.framework.TopiaContextImplementor; +import org.codelutin.topia.security.TopiaSecurityManager; + +public class TopiaSecurityTestWithTopia extends TestCase { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + protected static Log log = LogFactory.getLog(TopiaSecurityTestWithTopia.class); + + protected static String entitiesList = "org.codelutin.topia.security.test.person.PersonImpl"; + + protected static Properties getProperties() { + Properties config = new Properties(); + /* HSQL 2 */ + config.setProperty("hibernate.hbm2ddl.auto", "create"); + config.setProperty("hibernate.show_sql", "true"); + + config.setProperty("topia.persistence.classes", entitiesList); + config.setProperty("topia.security.manager", "org.codelutin.topia.security.TopiaSecurityManagerImpl"); + + config.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect"); + config.setProperty("hibernate.connection.username", "sa"); + config.setProperty("hibernate.connection.password", ""); + config.setProperty("hibernate.connection.driver_class", "org.h2.Driver"); + + config.setProperty("hibernate.connection.url", "jdbc:h2:mem:;LOCK_METHOD=NO"); + + return config; + } + + public void testTopia() throws Exception { + TopiaContext context = TopiaContextFactory.getContext(getProperties()); + TopiaSecurityManager securityManager = context.getSecurityManager(); + assertNotNull(securityManager); + + TopiaContextImplementor childContext = (TopiaContextImplementor) context.beginTransaction(); + securityManager = childContext.getSecurityManager(); + assertNotNull(securityManager); + } + +}