[portal-commits] JBoss Portal SVN: r5836 - trunk/identity/src/main/org/jboss/portal/test/identity/db

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Wed Dec 13 10:28:22 EST 2006


Author: bdaw
Date: 2006-12-13 10:28:19 -0500 (Wed, 13 Dec 2006)
New Revision: 5836

Added:
   trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java
Log:
cleanup

Copied: trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java (from rev 5770, trunk/identity/src/main/org/jboss/portal/test/identity/db/DBUserTestCase.java)
===================================================================
--- trunk/identity/src/main/org/jboss/portal/test/identity/db/DBUserTestCase.java	2006-12-06 09:43:49 UTC (rev 5770)
+++ trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java	2006-12-13 15:28:19 UTC (rev 5836)
@@ -0,0 +1,261 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.portal.test.identity.db;
+
+import org.jboss.portal.identity2.IdentityServiceControllerImpl;
+import org.jboss.portal.identity2.IdentityContext;
+import org.jboss.portal.identity2.ProfileMap;
+import org.jboss.portal.identity2.User;
+import org.jboss.portal.identity2.db.HibernateUserImpl;
+import org.jboss.portal.identity2.db.HibernateUserModuleImpl;
+import org.jboss.portal.identity2.db.HibernateRoleModuleImpl;
+import org.jboss.portal.identity2.db.HibernateMembershipModuleImpl;
+import org.jboss.portal.identity2.db.HibernateUserProfileModuleImpl;
+import org.jboss.portal.identity2.config.metadata.ConfigurationParser;
+import org.jboss.portal.identity2.config.info.ProfileInfoSupport;
+import org.jboss.portal.identity2.info.ProfileInfo;
+import org.jboss.portal.test.identity.UserTest;
+import org.jboss.portal.common.p3p.P3PConstants;
+import junit.framework.TestSuite;
+
+import java.util.Date;
+import java.text.SimpleDateFormat;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class DBIdentityTestCase extends DBTestCase
+{
+
+   public static TestSuite suite() throws Exception
+   {
+      System.out.println("###");
+      return createTestSuite(DBIdentityTestCase.class);
+   }
+
+   public void setUp() throws Exception
+   {
+
+      //generate hibernate mappings based on the profile file
+//      ProfileInfo info = new ProfileInfoSupport(ConfigurationParser.parseProfileConfiguration("test/config/profile-config.xml"));
+//      String pattern = "<property name=\"@name@\" column=\"@column@\" type=\"java.lang.String\" update=\"true\" insert=\"true\" unique=\"false\"/>";
+//      HibernateHelper.generateProfileMappings("hibernate/domain-template-single.hbm.xml",
+//                                              "resources/hibernate/domain-identity.hbm.xml",
+//                                              pattern,
+//                                              info,
+//                                              Thread.currentThread().getContextClassLoader());
+
+      
+
+      //initialize microcontainer stuff
+      super.setUp();
+      
+
+      //bootstrap identity modules
+      IdentityServiceControllerImpl controller = new IdentityServiceControllerImpl();
+      controller.setConfigFile("test/config/db-config.xml");
+      controller.setDefaultConfigFile("test/config/standardidentity-config.xml");
+      controller.setRegisterMBeans(false);
+      controller.start();
+      identityContext = controller.getIdentityContext();
+      this.userModule = (HibernateUserModuleImpl)identityContext.getObject(IdentityContext.TYPE_USER_MODULE);
+      this.roleModule = (HibernateRoleModuleImpl)identityContext.getObject(IdentityContext.TYPE_ROLE_MODULE);
+      this.membershipModule = (HibernateMembershipModuleImpl)identityContext.getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+      this.userProfileModule = (HibernateUserProfileModuleImpl)identityContext.getObject(IdentityContext.TYPE_USER_PROFILE_MODULE);
+
+      //
+      utc = new UserTest();
+      utc.setUserModule(userModule);
+      utc.setRoleModule(roleModule);
+      utc.setMembershipModule(membershipModule);
+      utc.setContext(this);
+      utc.populate();
+   }
+
+
+
+
+
+
+   public void testWorking() throws Exception
+   {
+      
+   }
+
+   //
+
+   public void testFindUsersUsingFilter() throws Exception
+   {
+      utc.testFindUsersUsingFilter();
+   }
+
+   public void testFindUser1() throws Exception
+   {
+      utc.testFindUser1();
+   }
+
+   public void testFindUser2() throws Exception
+   {
+      utc.testFindUser2();
+   }
+
+   public void testFindUsers() throws Exception
+   {
+      utc.testFindUsers();
+   }
+
+   public void testCreateUser() throws Exception
+   {
+      utc.testCreateUser();
+   }
+
+   public void testCreateRole() throws Exception
+   {
+      utc.testCreateRole();
+   }
+
+   public void testCountUser() throws Exception
+   {
+      utc.testCountUser();
+   }
+
+   public void testRemoveNonExistingRole() throws Exception
+   {
+      utc.testRemoveNonExistingRole();
+   }
+
+   public void testRemoveRole() throws Exception
+   {
+      utc.testRemoveRole();
+   }
+
+   public void testRemoveUser() throws Exception
+   {
+      utc.testRemoveUser();
+   }
+
+   public void testFindRoles() throws Exception
+   {
+      utc.testFindRoles();
+   }
+
+   public void testFindRoleMembers() throws Exception
+   {
+      utc.testFindRoleMembers();
+   }
+
+   public void testDynamicProperty() throws Exception
+   {
+      begin();
+      User user = userModule.createUser("testname", "testpassword");
+      ProfileMap map = ((HibernateUserImpl)user).getProfileMap();
+      assertNull(map.get("foo"));
+      assertFalse(map.isReadOnly("foo"));
+      map.put("foo", "value");
+      assertEquals("value", map.get("foo"));
+      assertFalse(map.isReadOnly("foo"));
+      commit();
+
+      begin();
+      user = userModule.findUserByUserName("testname");
+      map = ((HibernateUserImpl)user).getProfileMap();
+      assertEquals("value", map.get("foo"));
+      assertFalse(map.isReadOnly("foo"));
+      commit();
+   }
+
+   public void testStaticProperty() throws Exception
+   {
+      begin();
+
+      //
+      User user = userModule.createUser("testname", "testpassword");
+      ProfileMap map = ((HibernateUserImpl)user).getProfileMap();
+      assertEquals("testname", map.get(P3PConstants.INFO_USER_NAME_NICKNAME));
+
+      // Test cannot remove a static property
+      try
+      {
+         map.remove(P3PConstants.INFO_USER_NAME_GIVEN);
+         fail("Should not be capable to remove static property");
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+
+      // Test read only property
+      assertTrue(map.isReadOnly(P3PConstants.INFO_USER_NAME_NICKNAME));
+      try
+      {
+         map.put(P3PConstants.INFO_USER_NAME_NICKNAME, "anothername");
+         fail("Should not be capable to modify a read only static property");
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+
+      // Test non nullable and writable property
+      try
+      {
+         map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, null);
+         fail("Should not be capable to nullify a non nullable static property");
+      }
+      catch (NullPointerException expected)
+      {
+      }
+      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
+      assertEquals("true", userProfileModule.getProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+
+      // Test boolean property
+      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "false");
+      assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      assertEquals("false", userProfileModule.getProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+
+      map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
+      assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      assertEquals("true", userProfileModule.getProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+
+      userProfileModule.setProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "false");
+      assertEquals("false", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      assertEquals("false", userProfileModule.getProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+
+      userProfileModule.setProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "true");
+      assertEquals("true", map.get(User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      assertEquals("true", userProfileModule.getProperty(user, User.INFO_USER_VIEW_EMAIL_VIEW_REAL));
+      try
+      {
+         map.put(User.INFO_USER_VIEW_EMAIL_VIEW_REAL, "truee");
+         fail("Should not be capable to set a bad value to boolean property");
+      }
+      catch (IllegalArgumentException expected)
+      {
+      }
+
+      // Test date
+      Date date = ((HibernateUserImpl)user).getRegistrationDate();
+      SimpleDateFormat sdf = new SimpleDateFormat();
+      assertEquals(sdf.format(date), map.get(User.INFO_USER_REGISTRATION_DATE));
+
+      commit();
+   }
+}


Property changes on: trunk/identity/src/main/org/jboss/portal/test/identity/db/DBIdentityTestCase.java
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native




More information about the portal-commits mailing list