From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:10:15
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/authentication In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7247/src-test/za/org/coefficient/authentication Added Files: ProjectMemberTest.java Log Message: Added testcase to test ProjectMember class. Has a setup method which uses: CoefficientTestCase.DEFAULT_DATA so that it only has the default/basic data in the test db. No User or project in the test db. --- NEW FILE: ProjectMemberTest.java --- /** * * * Coefficient - facilitates project based collaboration * Copyright (C) 2005, Meraka Insitute, Pieter van Zyl * PO Box 395 * Pretoria 0001, RSA * This library 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 library 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 library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package za.org.coefficient.authentication; import za.org.coefficient.testing.CoefficientTestCase; import za.org.coefficient.testing.TestDBSetup; import za.org.coefficient.util.ejb.SecurityUtil; ; /** * TestCase to the the ProjectMember class * * @author pieter20 Aug 8, 2005 * */ public class ProjectMemberTest extends CoefficientTestCase { private TestDBSetup testDbSchema = null; /** * Aug 10, 2005 * @author pieter20 * @param testName */ public ProjectMemberTest(String testName) { super(testName); } /* * We setup the test db to contain on the defualt/basic data that is * uploaded by the DataLoader. (non-Javadoc) * * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); testDbSchema = TestDBSetup.getInstance(CoefficientTestCase.DEFAULT_DATA); } /** * Test the creation of a Project member and test to see if the user and * role is constructed correctly. * * @author pieter20 Aug 10, 2005 */ public void testCreateProjectMember() { CoefficientUser user = new CoefficientUser(); Role project_champ = SecurityUtil .getRoleForDescription(SecurityUtil.PROJECT_CHAMPION_ROLE_DESC); ProjectMember member = new ProjectMember(user, project_champ); assertNotNull(member.getCoefficientUser()); assertNotNull(member.getProjectRole()); } /** * Tests the equals method with: 2 members that are the same * * @author pieter20 Aug 10, 2005 */ public void testSameMember() {// on role CoefficientUser user = new CoefficientUser(); Role project_champ = SecurityUtil .getRoleForDescription(SecurityUtil.PROJECT_CHAMPION_ROLE_DESC); ProjectMember member = new ProjectMember(user, project_champ); ProjectMember otherMember = new ProjectMember(user, project_champ); assertTrue(member.equals(otherMember)); } /* * These 2 test will fail public void testSameMemberOnUserName() { // * testing username and password cannot be the same // why password? are we * enforcing this? CoefficientUser user = new CoefficientUser(); * user.setUserName("test1");// username differ user.setPassword("test1");// * pwd are the same * * CoefficientUser secondUser = new CoefficientUser(); * secondUser.setUserName("test2"); secondUser.setPassword("test1"); * * Role project_champ = SecurityUtil * .getRoleForDescription(SecurityUtil.PROJECT_CHAMPION_ROLE_DESC); * * ProjectMember member = new ProjectMember(user, project_champ); * ProjectMember otherMember = new ProjectMember(secondUser, project_champ); // * differ on username assertTrue(member.equals(otherMember)); } * * public void testSameMemberOnUserPwd() { // testing username and password * cannot be the same // why password? are we enforcing this? * CoefficientUser user = new CoefficientUser(); * user.setUserName("test1");// same usernames user.setPassword("test1");// * passwords differ * * CoefficientUser secondUser = new CoefficientUser(); * secondUser.setUserName("test1"); secondUser.setPassword("test2"); * * Role project_champ = SecurityUtil * .getRoleForDescription(SecurityUtil.PROJECT_CHAMPION_ROLE_DESC); * * ProjectMember member = new ProjectMember(user, project_champ); * ProjectMember otherMember = new ProjectMember(secondUser, project_champ); * * assertTrue(member.equals(otherMember)); } */ /** * Tests the equals method with: 2 members that are the same except on their * roles * * @author pieter20 Aug 10, 2005 */ public void testNotSameMemberOnRole() { CoefficientUser user = new CoefficientUser(); Role project_champ = SecurityUtil .getRoleForDescription(SecurityUtil.PROJECT_CHAMPION_ROLE_DESC); Role site_member = SecurityUtil .getRoleForDescription(SecurityUtil.SITE_MEMBER_ROLE_DESC); ProjectMember member = new ProjectMember(user, project_champ); ProjectMember siteMember = new ProjectMember(user, site_member); // differ on roles assertFalse(member.equals(siteMember)); } /** * Tests the equals method with: 2 members that are the same except on their * usernames. * * @author pieter20 Aug 10, 2005 */ public void testNotSameMemberOnUserName() { // testing username and password cannot be the same // why password? are we enforcing this? CoefficientUser user = new CoefficientUser(); user.setUserName("test1");// username differ user.setPassword("test1");// pwd are the same CoefficientUser secondUser = new CoefficientUser(); secondUser.setUserName("test2"); secondUser.setPassword("test1"); Role project_champ = SecurityUtil .getRoleForDescription(SecurityUtil.PROJECT_CHAMPION_ROLE_DESC); ProjectMember member = new ProjectMember(user, project_champ); ProjectMember otherMember = new ProjectMember(secondUser, project_champ); // differ on username assertFalse(member.equals(otherMember)); } /** * Tests the equals method with: 2 members that are the same except on their * passwords * * @author pieter20 Aug 10, 2005 */ public void testNotSameMemberOnUserPwd() { // testing username and password cannot be the same // why password? are we enforcing this? CoefficientUser user = new CoefficientUser(); user.setUserName("test1");// same usernames user.setPassword("test1");// passwords differ CoefficientUser secondUser = new CoefficientUser(); secondUser.setUserName("test1"); secondUser.setPassword("test2"); Role project_champ = SecurityUtil .getRoleForDescription(SecurityUtil.PROJECT_CHAMPION_ROLE_DESC); ProjectMember member = new ProjectMember(user, project_champ); ProjectMember otherMember = new ProjectMember(secondUser, project_champ); assertFalse(member.equals(otherMember)); } /** * @author pieter20 Aug 8, 2005 * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } |