You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(66) |
Aug
(61) |
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Pieter v. Z. <pv...@us...> - 2005-08-10 09:22:21
|
Update of /cvsroot/coefficient/coefficient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23016 Modified Files: changelog.txt Log Message: added in some notes of where some of the RSS changes where made. Index: changelog.txt =================================================================== RCS file: /cvsroot/coefficient/coefficient/changelog.txt,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** changelog.txt 10 Aug 2005 08:35:20 -0000 1.35 --- changelog.txt 10 Aug 2005 09:22:12 -0000 1.36 *************** *** 42,45 **** --- 42,50 ---- pvz: added junit 3.8.1 to lib/junit + 22/07/2005 + pvz for tfogwill: Added the RSS feeder and blog modules. Added RSSItemCreatedEvent, Added createRSSItem and getRSSOrigin methods + to BaseModule. added RSS stuff and events to Projects module and added RSSFeeds=East to DefaultTheme.properties. + + ------------------- version 0.9.6: |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:52:32
|
Update of /cvsroot/coefficient/coefficient/lib/junit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16682/lib/junit Removed Files: junit-3.7.jar Log Message: removed junit-3.7 and replaved with latest version: 3.8.1 --- junit-3.7.jar DELETED --- |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:35:29
|
Update of /cvsroot/coefficient/coefficient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12720 Modified Files: changelog.txt Log Message: added : ProjectMemberTest and ProjectTest, CoefficientTestCase.DEFAULT_DATA. Changed TestDBSetup: constructor and getInstance and added testSuites. Index: changelog.txt =================================================================== RCS file: /cvsroot/coefficient/coefficient/changelog.txt,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** changelog.txt 5 Aug 2005 12:57:02 -0000 1.34 --- changelog.txt 10 Aug 2005 08:35:20 -0000 1.35 *************** *** 2,5 **** --- 2,17 ---- ===================== + 10/08/2005 + pvz: Added ProjectMemberTest and ProjectTest to test the Project and ProjectMember classes. There is more work needed here. + ProjectMemberTest has a setup method which uses: CoefficientTestCase.DEFAULT_DATA + + pvz: Changed TestDBSetup: constructor TestDBSetup(String type) and getInstance(String type) to use CoefficientTestCase.DEFAULT_DATA + pvz: added CoefficientCoreTestSuite (includes ProjectMemberTest and ProjectTest currently) and + CoefficientModulesTestSuite (not being used at the moment) and CoefficientAllTestSuite. + + pvz: added comments to UserAdmin about some improvements. + + + 05/08/2005 pvz: added getters and setters in BaseCoefficientContext for the 3 maps: session,requestData and requestAttributes. These are added so *************** *** 11,14 **** --- 23,28 ---- setupBasics is now called here. This class is now a singleton. Add the results: the context into a map. + PVZ: added the license and removed CURRENT_PROJECT from CoefficientTestCase and TestDBSetup + 03/08/2005 pvz: added XMLJndiUtil to create a (at this stage) mock JNDI table from the server.xml.snippit. |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:32:36
|
Update of /cvsroot/coefficient/coefficient/src/za/org/coefficient/modules/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12136/src/za/org/coefficient/modules/user Modified Files: UserAdmin.java Log Message: added a comment and FIXME. Maybe we can improve this in later versions. Index: UserAdmin.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src/za/org/coefficient/modules/user/UserAdmin.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** UserAdmin.java 25 May 2005 13:32:33 -0000 1.10 --- UserAdmin.java 10 Aug 2005 08:32:27 -0000 1.11 *************** *** 413,416 **** --- 413,417 ---- public CoefficientContext saveUser(CoefficientContext ctx) throws HibernateException { CoefficientUser user = null; + //FIXME: Seems we set this somewhere else otherwise we default to -1. Try to find better solution to this. Long id = ctx.getParameterAsLong("id", -1); long confId = -1; *************** *** 464,468 **** } } ! if (id.longValue() > 0) { ctx.setSessionAttribute(Constants.USER_SESSION_STRING, user); --- 465,469 ---- } } ! //FIXME: Why do we have this here if it is never true?!!! We don't know the id of the current user object?! if (id.longValue() > 0) { ctx.setSessionAttribute(Constants.USER_SESSION_STRING, user); |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:22:40
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10072/src-test/za/org/coefficient/testing Added Files: CoefficientModulesTestSuite.java CoefficientCoreTestSuite.java CoefficientAllTestSuite.java Log Message: added some testSuites so that we can test the: core. the modules and everything in one test run. The modules test suite is not finished as it need to include the modules jar files. --- NEW FILE: CoefficientAllTestSuite.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.testing; import junit.framework.Test; import junit.framework.TestSuite; /** * This TestSuite runs all the tests and test suites for the core and all the * modules. The Modules and the core jar files must be on the classpath. * * @author pieter20 Aug 8, 2005 */ public class CoefficientAllTestSuite { /** * Aug 8, 2005 * * @author pieter20 */ public CoefficientAllTestSuite() { super(); // TODO Auto-generated constructor stub } public static Test suite() { TestSuite allTestsTestSuite = new TestSuite(); allTestsTestSuite.addTest(CoefficientCoreTestSuite.suite()); allTestsTestSuite.addTest(CoefficientModulesTestSuite.suite()); // add in the rest of the modules test cases or test suites. return allTestsTestSuite; } /** * @author pieter20 Aug 8, 2005 * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } --- NEW FILE: CoefficientModulesTestSuite.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.testing; import junit.framework.Test; import junit.framework.TestSuite; /** * Runs the tests of each of the modules * @author pieter20 Aug 8, 2005 */ public class CoefficientModulesTestSuite { /** * Aug 8, 2005 * * @author pieter20 */ public CoefficientModulesTestSuite() { super(); // TODO Auto-generated constructor stub } /** * TODO:for this to work the compiling of the tests will need to include * the modules jar files. Maybe create a seperate build: one for core test cases which excludes this class * and one for all test cases. Or use CruiseControl to run each of the test for the modules including the test for the core. * @author pieter20 * Aug 8, 2005 * * @return Test: the testSuite */ public static Test suite() { TestSuite modulesTestSuite = new TestSuite(); //modulesTestSuite.addTestSuite(MailForumTest.class); //add in the rest of the modules test cases or test suites. return modulesTestSuite; } /** * @author pieter20 Aug 8, 2005 * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } --- NEW FILE: CoefficientCoreTestSuite.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.testing; import za.org.coefficient.authentication.ProjectMemberTest; import za.org.coefficient.core.ProjectTest; import junit.framework.Test; import junit.framework.TestSuite; import junit.swingui.TestRunner; /** * Runs all the tests for the Coefficient Core * @author pieter20 * Aug 8, 2005 * */ public class CoefficientCoreTestSuite { /** * Aug 8, 2005 * @author pieter20 */ public CoefficientCoreTestSuite() { super(); // TODO Auto-generated constructor stub } public static Test suite() { TestSuite coreTestSuite = new TestSuite(); coreTestSuite.addTestSuite(ProjectTest.class); coreTestSuite.addTestSuite(ProjectMemberTest.class); return coreTestSuite; } /** * @author pieter20 Aug 8, 2005 * @param args */ public static void main(String[] args) { //using the swingui //TestRunner.run(suite()); } } |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:20:10
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9583/src-test/za/org/coefficient/testing Modified Files: CoefficientTestCase.java Log Message: adde comments and : DEFAULT_DATA Index: CoefficientTestCase.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing/CoefficientTestCase.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CoefficientTestCase.java 5 Aug 2005 13:41:53 -0000 1.3 --- CoefficientTestCase.java 10 Aug 2005 08:19:58 -0000 1.4 *************** *** 27,36 **** /** ! * @author pvzyl Jul 19, 2005 This forms the base class for testing in ! * Coefficient */ public class CoefficientTestCase extends TestCase { public static String CURRENT_CONTEXT = "CURRENT_CONTEXT"; /** --- 27,41 ---- /** ! * This forms the base class for testing in Coefficient ! * We created a seperate test folder, but same package structure based on the ! * JUnit Primer: http://www.clarkware.com/articles/JUnitPrimer.html Step 5. ! * and recommendations from TFogwill. ! * ! * @author pvzyl Jul 19, 2005 */ public class CoefficientTestCase extends TestCase { public static String CURRENT_CONTEXT = "CURRENT_CONTEXT"; + public static String DEFAULT_DATA="DEFAULT_DATA"; /** |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:14:10
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8042/src-test/za/org/coefficient/core Added Files: ProjectTest.java Log Message: Added testcase to test Project class. Test a lot of properties in one test method. --- NEW FILE: ProjectTest.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.core; import za.org.coefficient.testing.CoefficientTestCase; /** * @author pieter20 Aug 8, 2005 TestCase to test the Project class. */ public class ProjectTest extends CoefficientTestCase { /** * Aug 8, 2005 * * @author pieter20 * @param testName * The name of the current test */ public ProjectTest(String testName) { super(testName); } /* * * Start: testing the setting of project properties */ /** * Test setting the active status of a project * * @author pieter20 Aug 8, 2005 */ public void testSetActiveProject() { Project testProject = new Project(); testProject.setActive(true); assertTrue(testProject.getActive()); } /** * Test setting some of the properties of a project * * @author pieter20 Aug 8, 2005 */ public void testSettingProperties() { Project testProject = new Project(); testProject.setShortName("test"); assertEquals(testProject.getShortName(), "test"); testProject.setName("Testing Project"); assertEquals(testProject.getName(), "Testing Project"); testProject.setDescription("This project is used to test"); assertEquals(testProject.getDescription(), "This project is used to test"); testProject.setHomePage("none"); assertEquals(testProject.getHomePage(), "none"); testProject.setIsPublic(true); assertTrue(testProject.getIsPublic()); } /** * @author pieter20 Aug 8, 2005 * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:13:35
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7969/src-test/za/org/coefficient/core Log Message: Directory /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/core added to the repository |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:12:20
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7697/src-test/za/org/coefficient/testing Modified Files: TestDBSetup.java Log Message: Changed TestDBSetup: constructor TestDBSetup(String type) and getInstance(String type) to use CoefficientTestCase.DEFAULT_DATA We can now specify what kind of initial state we want the test db to be in. Index: TestDBSetup.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing/TestDBSetup.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestDBSetup.java 5 Aug 2005 13:41:53 -0000 1.3 --- TestDBSetup.java 10 Aug 2005 08:12:11 -0000 1.4 *************** *** 3,7 **** * * Coefficient - facilitates project based collaboration ! * Copyright (C) 2005, Meraka Insitute * PO Box 395 * Pretoria 0001, RSA --- 3,7 ---- * * Coefficient - facilitates project based collaboration ! * Copyright (C) 2005, Meraka Insitute, Pieter van Zyl * PO Box 395 * Pretoria 0001, RSA *************** *** 38,42 **** /** ! * @author pieter20 Jul 20, 2005 This class is based/inspired on the following * article on ServerSide:Unit-Testing Hibernate with HSQL DB by Alex * Vollmer It initializes and creates the defualt db and one: project --- 38,42 ---- /** ! * This class is based/inspired on the following * article on ServerSide:Unit-Testing Hibernate with HSQL DB by Alex * Vollmer It initializes and creates the defualt db and one: project *************** *** 46,49 **** --- 46,50 ---- * context? * The test db is created in memory. + * @author pieter20 Jul 20, 2005 */ public class TestDBSetup { *************** *** 68,72 **** * @author pieter20 This constructor creates and initializes the test db * with the basic data that is need for testing. It uses the ! * DataLoaderUtil to initialize the db. */ public TestDBSetup() { --- 69,73 ---- * @author pieter20 This constructor creates and initializes the test db * with the basic data that is need for testing. It uses the ! * DataLoaderUtil to initialize the db and then we create a User, and a Project. */ public TestDBSetup() { *************** *** 75,78 **** --- 76,102 ---- currentSetupMap = setupBasics(); } + + + /** + * Aug 10, 2005 + * This method can take a type description, which decides which kind of test db we want initiliazed. + * DEFAULT_DATA means we only want the default data which is uploaded by the DataLoader. + * Currently there are no other types. We will add them later as the testing framework grows. + * @author pieter20 + * @param type + */ + public TestDBSetup(String type) { + + if (type.compareTo(CoefficientTestCase.DEFAULT_DATA)==1) { + DataLoaderUtil dataLoader = new DataLoaderUtil(); + dataLoader.initializeDataIfNeeded(); + } else {//extra: an user and a project. + DataLoaderUtil dataLoader = new DataLoaderUtil(); + dataLoader.initializeDataIfNeeded(); + currentSetupMap = setupBasics(); + } + + + } /** *************** *** 92,95 **** --- 116,136 ---- return instance; } + + /** + * @author pieter20 Aug 5, 2005 This method enforces/implements the + * Singleton Pattern for this class + * @return the current instance or a new TestDBSetup instance + */ + public static TestDBSetup getInstance(String type) { + if (instance == null) { + synchronized (TestDBSetup.class) { + if (instance == null) { + setInstance(new TestDBSetup(type)); + + } + } + } + return instance; + } /** |
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 } } |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:09:54
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/authentication In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7120/src-test/za/org/coefficient/authentication Log Message: Directory /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/authentication added to the repository |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:06:34
|
Update of /cvsroot/coefficient/mailForum/src-test/za/org/coefficient/modules/mailforum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6406/modules/mailForum/src-test/za/org/coefficient/modules/mailforum Added Files: MailForumModuleTestSuite.java Log Message: added MailForumModuleTestSuite to included all test cases for the mailForum module --- NEW FILE: MailForumModuleTestSuite.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.modules.mailforum; import junit.framework.Test; import junit.framework.TestSuite; /** * This TestSuite includes all the test cases for the mailForum module. * * @author pieter20 Aug 8, 2005 * */ public class MailForumModuleTestSuite { /** * Aug 8, 2005 * * @author pieter20 */ public MailForumModuleTestSuite() { super(); } /** * Currently there is only one test case: MailForumTest which test the forum * creation * * @author pieter20 Aug 10, 2005 * @return */ public static Test suite() { TestSuite mailForumModuleTestSuite = new TestSuite(); mailForumModuleTestSuite.addTestSuite(MailForumTest.class); return mailForumModuleTestSuite; } /** * @author pieter20 Aug 8, 2005 * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub } } |
From: Pieter v. Z. <pv...@us...> - 2005-08-10 08:06:34
|
Update of /cvsroot/coefficient/mailForum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6406/modules/mailForum Modified Files: changelog.txt Log Message: added MailForumModuleTestSuite to included all test cases for the mailForum module Index: changelog.txt =================================================================== RCS file: /cvsroot/coefficient/mailForum/changelog.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** changelog.txt 5 Aug 2005 12:56:26 -0000 1.8 --- changelog.txt 10 Aug 2005 08:06:26 -0000 1.9 *************** *** 1,3 **** --- 1,11 ---- + ============= + MailForum Module + ============= + + 10/08/2005 + pvz: added MailForumModuleTestSuite to included all test cases for the mailForum module + 05/08/2005 + pvz: added in MailForumTest: testForumCreation(), setupBasics(), checkExistence(to test if and object was created in the db) added CURRENT_CONTEXT and CURRENT_PROJECT. I am now using ONE context object as I am setting up the test case. |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 13:42:32
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25497/src-test/za/org/coefficient/testing Modified Files: TestDBSetup.java CoefficientTestCase.java Log Message: added the license and removed CURRENT_PROJECT Index: CoefficientTestCase.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing/CoefficientTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CoefficientTestCase.java 5 Aug 2005 12:48:35 -0000 1.2 --- CoefficientTestCase.java 5 Aug 2005 13:41:53 -0000 1.3 *************** *** 1,4 **** --- 1,21 ---- /** * + * + * Coefficient - facilitates project based collaboration + * Copyright (C) 2005, Meraka Insitute + * 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.testing; *************** *** 10,15 **** /** ! * @author pvzyl Jul 19, 2005 ! * */ public class CoefficientTestCase extends TestCase { --- 27,32 ---- /** ! * @author pvzyl Jul 19, 2005 This forms the base class for testing in ! * Coefficient */ public class CoefficientTestCase extends TestCase { *************** *** 17,22 **** public static String CURRENT_CONTEXT = "CURRENT_CONTEXT"; - public static String CURRENT_PROJECT = "CURRENT_PROJECT"; - /** * Jul 19, 2005 --- 34,37 ---- *************** *** 41,45 **** * @throws Exception */ ! public static Object invokeOpOnModule(CoefficientContext ctx) throws Exception { Invoker testModuleInvoker = new TestModuleInvoker();// this should also // be a singleton? --- 56,61 ---- * @throws Exception */ ! public static Object invokeOpOnModule(CoefficientContext ctx) ! throws Exception { Invoker testModuleInvoker = new TestModuleInvoker();// this should also // be a singleton? Index: TestDBSetup.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing/TestDBSetup.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestDBSetup.java 5 Aug 2005 12:47:38 -0000 1.2 --- TestDBSetup.java 5 Aug 2005 13:41:53 -0000 1.3 *************** *** 1,4 **** --- 1,21 ---- /** * + * + * Coefficient - facilitates project based collaboration + * Copyright (C) 2005, Meraka Insitute + * 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.testing; *************** *** 21,31 **** /** ! * @author pieter20 Jul 20, 2005 This class is based on the following article on ! * ServerSide:Unit-Testing Hibernate with HSQL DB by Alex Vollmer ! * It initializes and creates the defualt db and one: project and user. ! * It then adds the user as a member to the project and logins in the user */ public class TestDBSetup { private static TestDBSetup instance; private HashMap currentSetupMap = null; --- 38,53 ---- /** ! * @author pieter20 Jul 20, 2005 This class is based/inspired on the following ! * article on ServerSide:Unit-Testing Hibernate with HSQL DB by Alex ! * Vollmer It initializes and creates the defualt db and one: project ! * and user. It then adds the user as a member to the project and logins ! * in the user NB: Please note that I am adding values to ONE context ! * over calls to different modules. One can try and clean-up the ! * context? ! * The test db is created in memory. */ public class TestDBSetup { private static TestDBSetup instance; + private HashMap currentSetupMap = null; *************** *** 49,53 **** */ public TestDBSetup() { - // pvz: make this TestDBSetup a singleton DataLoaderUtil dataLoader = new DataLoaderUtil(); dataLoader.initializeDataIfNeeded(); --- 71,74 ---- *************** *** 55,63 **** } - /** ! * @author pieter20 ! * Aug 5, 2005 ! * This method enforces/implements the Singleton Pattern for this class * @return the current instance or a new TestDBSetup instance */ --- 76,82 ---- } /** ! * @author pieter20 Aug 5, 2005 This method enforces/implements the ! * Singleton Pattern for this class * @return the current instance or a new TestDBSetup instance */ *************** *** 75,81 **** /** ! * @author pieter20 ! * Aug 5, 2005 ! * used to set the static instance object * @param instance_ */ --- 94,98 ---- /** ! * @author pieter20 Aug 5, 2005 used to set the static instance object * @param instance_ */ *************** *** 103,108 **** /** ! * @author pieter20 Jul 31, 2005 Creates a default test project. ! * The properties of the project is hardcoded. * @return the newly created project */ --- 120,125 ---- /** ! * @author pieter20 Jul 31, 2005 Creates a default test project. The ! * properties of the project is hardcoded. * @return the newly created project */ *************** *** 281,288 **** /** ! * @author pieter20 ! * Aug 5, 2005 ! * The user needs to be logged in to be able to make calls in the ! * system * @param ctx */ --- 298,303 ---- /** ! * @author pieter20 Aug 5, 2005 The user needs to be logged in to be able to ! * make calls in the system * @param ctx */ *************** *** 318,324 **** /** ! * @author pieter20 ! * Aug 5, 2005 ! * Utility method to list all the projects created. */ private void listAllProjects() { --- 333,338 ---- /** ! * @author pieter20 Aug 5, 2005 Utility method to list all the projects ! * created. */ private void listAllProjects() { *************** *** 342,352 **** /** ! * @author pieter20 ! * Aug 5, 2005 ! * This method initializes and creates the defualt testing project and user. ! * It then adds the user as a member to the project and logins in the user. ! * The stage is then set for testing ! * @return a HashMap containing the CURRENT_PROJECT =projct ! * and the CURRENT_CONTEXT = ctx */ private HashMap setupBasics() { --- 356,364 ---- /** ! * @author pieter20 Aug 5, 2005 This method initializes and creates the ! * defualt testing project and user. It then adds the user as a ! * member to the project and logins in the user. The stage is then ! * set for testing ! * @return a HashMap containing the CURRENT_CONTEXT = ctx */ private HashMap setupBasics() { *************** *** 355,359 **** // creates a default project without going through the project module. Project testProject = createProject(); ! currentSetupMap.put(CoefficientTestCase.CURRENT_PROJECT, testProject); CoefficientTestingContext ctx = new CoefficientTestingContext( new HashMap(), new HashMap(), new HashMap()); --- 367,371 ---- // creates a default project without going through the project module. Project testProject = createProject(); ! CoefficientTestingContext ctx = new CoefficientTestingContext( new HashMap(), new HashMap(), new HashMap()); *************** *** 372,382 **** } - /** ! * @author pieter20 ! * Aug 5, 2005 ! * This methods is the main method of obtaining the current state that has been created for testing. ! * @return a HashMap containing the CURRENT_PROJECT =projct ! * and the CURRENT_CONTEXT = ctx */ public HashMap getCurrentSetupMap() { --- 384,391 ---- } /** ! * @author pieter20 Aug 5, 2005 This methods is the main method of obtaining ! * the current state that has been created for testing. ! * @return a HashMap containing the CURRENT_CONTEXT = ctx */ public HashMap getCurrentSetupMap() { |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 13:35:24
|
Update of /cvsroot/coefficient/mailForum/src-test/za/org/coefficient/modules/mailforum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24234/modules/mailForum/src-test/za/org/coefficient/modules/mailforum Modified Files: MailForumTest.java Log Message: added the license Index: MailForumTest.java =================================================================== RCS file: /cvsroot/coefficient/mailForum/src-test/za/org/coefficient/modules/mailforum/MailForumTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MailForumTest.java 5 Aug 2005 12:53:28 -0000 1.3 --- MailForumTest.java 5 Aug 2005 13:35:15 -0000 1.4 *************** *** 1,4 **** --- 1,20 ---- /** * + * Coefficient - facilitates project based collaboration + * Copyright (C) 2005, Meraka Insitute + * 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.modules.mailforum; *************** *** 17,21 **** /** * @author pieter20 Jul 19, 2005 ! * */ public class MailForumTest extends CoefficientTestCase { --- 33,37 ---- /** * @author pieter20 Jul 19, 2005 ! * TestCase to test the MailForum module. */ public class MailForumTest extends CoefficientTestCase { |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 12:57:13
|
Update of /cvsroot/coefficient/coefficient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17978 Modified Files: changelog.txt Log Message: pvz: CoefficientTestCase: moved "CURRENT_CONTEXT"and "CURRENT_PROJECT" here from MailForumTest case pvz: TestDBSetup: moved some methods for setting up the db from MailforumTest to this class. setupBasics is now called here. This class is now a singleton. Add the results: the context into a map. Index: changelog.txt =================================================================== RCS file: /cvsroot/coefficient/coefficient/changelog.txt,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** changelog.txt 3 Aug 2005 08:44:10 -0000 1.33 --- changelog.txt 5 Aug 2005 12:57:02 -0000 1.34 *************** *** 2,5 **** --- 2,14 ---- ===================== + 05/08/2005 + pvz: added getters and setters in BaseCoefficientContext for the 3 maps: session,requestData and requestAttributes. These are added so + that we can have acces to thm when testing.Maybe I should move CoefficientTestingContext in the same package name so that + I can remove these public methods. + + pvz: CoefficientTestCase: moved "CURRENT_CONTEXT"and "CURRENT_PROJECT" here from MailForumTest case + pvz: TestDBSetup: moved some methods for setting up the db from MailforumTest to this class. + setupBasics is now called here. This class is now a singleton. Add the results: the context into a map. + 03/08/2005 pvz: added XMLJndiUtil to create a (at this stage) mock JNDI table from the server.xml.snippit. |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 12:56:42
|
Update of /cvsroot/coefficient/mailForum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17940/modules/mailForum Modified Files: changelog.txt Log Message: MailForumTest: both tests (testForumCreation and testListingOfForums) are now working. moved some methods for setting up the db from MailforumTest to the TestDBSetup class. One instance is created of the db and context and used by both tests. Need to move the code in the constructor to the setUp(); tearDown(); methods of the testcase Index: changelog.txt =================================================================== RCS file: /cvsroot/coefficient/mailForum/changelog.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** changelog.txt 5 Aug 2005 09:13:33 -0000 1.7 --- changelog.txt 5 Aug 2005 12:56:26 -0000 1.8 *************** *** 4,7 **** --- 4,11 ---- added loginUser to login the user and set the user in the session. + pvz: MailForumTest: both tests (testForumCreation and testListingOfForums) are now working. moved some methods for setting up the db from MailforumTest to + the TestDBSetup class. One instance is created of the db and context and used by both tests. Need to move the code in the constructor to the + setUp(); tearDown(); methods of the testcase + 02/08/2005 pvzyl: Added src-test to this module and the MailForumTest case |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 12:53:39
|
Update of /cvsroot/coefficient/mailForum/src-test/za/org/coefficient/modules/mailforum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17598/modules/mailForum/src-test/za/org/coefficient/modules/mailforum Modified Files: MailForumTest.java Log Message: both test are now working. moved some methods for setting up the db from MailforumTest to the TestDBSetup class. One instance is created of the db and context and used by both tests. Need to move the code in the constructor to the setUp(); tearDown(); methods of the testcase Index: MailForumTest.java =================================================================== RCS file: /cvsroot/coefficient/mailForum/src-test/za/org/coefficient/modules/mailforum/MailForumTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MailForumTest.java 5 Aug 2005 09:13:33 -0000 1.2 --- MailForumTest.java 5 Aug 2005 12:53:28 -0000 1.3 *************** *** 7,27 **** import java.util.HashMap; import java.util.List; - import java.util.Locale; import java.util.Map; - import java.util.TimeZone; - import net.sf.hibernate.HibernateException; import net.sf.hibernate.util.HibernateUtil; - - import za.org.coefficient.authentication.CoefficientUser; - import za.org.coefficient.authentication.Role; - import za.org.coefficient.core.Constants; - import za.org.coefficient.core.Project; - import za.org.coefficient.interfaces.CoefficientContext; - import za.org.coefficient.testing.CoefficientTestCase; import za.org.coefficient.testing.CoefficientTestingContext; import za.org.coefficient.testing.TestDBSetup; ! import za.org.coefficient.util.ejb.SecurityUtil; /** --- 7,17 ---- import java.util.HashMap; import java.util.List; import java.util.Map; import net.sf.hibernate.HibernateException; import net.sf.hibernate.util.HibernateUtil; import za.org.coefficient.testing.CoefficientTestCase; import za.org.coefficient.testing.CoefficientTestingContext; import za.org.coefficient.testing.TestDBSetup; ! /** *************** *** 31,38 **** public class MailForumTest extends CoefficientTestCase { private TestDBSetup testDbSchema = null; ! ! private static String CURRENT_CONTEXT = "CURRENT_CONTEXT"; ! ! private static String CURRENT_PROJECT = "CURRENT_PROJECT"; /** --- 21,25 ---- public class MailForumTest extends CoefficientTestCase { private TestDBSetup testDbSchema = null; ! private HashMap currentSetupMap = null; /** *************** *** 43,304 **** public MailForumTest(String name) { super(name); } - private void listAllProjects() { - try { - List list = HibernateUtil.findAll(Project.class); - System.out - .println("MailForumsTest.testListForums()->list size od project list:" - + list.size()); - list = HibernateUtil.findAll(Role.class); - System.out - .println("MailForumsTest.testListForums()->list size of all roles in db:" - + list.size()); - - } catch (HibernateException e) { - System.err - .println("MailForumsTest.testListForums()->Could not retrieve any projects" - + e); - } - - }// end listAllProjects() - - /** - * @author pieter20 Jul 31, 2005 Setup the default db - */ - public void setupTestDb() { - // setup the default test db. - testDbSchema = new TestDBSetup(); - } - - /** - * @author pieter20 Jul 31, 2005 Create's a project that will be used - * throughout the test - * @return object of type Project - */ - private Project createProject() { - Project project = testDbSchema.setupDefaultProject(); - try { - HibernateUtil.saveOrUpdate(project); - } catch (HibernateException e) { - System.err - .println("MailForumsTest.testListForums()->Project not saved" - + e); - } - - assertNotNull(project); - return project; - } - - /** - * @author pieter20 Aug 3, 2005 Using the project module: Projects - * @return - */ - private Project createPublicProject(Map requestMap, CoefficientContext ctx, - String module) { - // TODO: Try to uses the project module later. Not using it now as it - // complicates the testing. Seperation of concerns. - // requestMap.put("shortName", "test"); - // requestMap.put("name", "Testing Project"); - // requestMap.put("homePage", "none"); - // requestMap.put("description", "This project is used to test"); - // requestMap.put("isPrivate", "off"); - // - // ArrayList mods = new ArrayList(); - // mods.add(module); - // requestMap.put("modules", mods); - // - // requestMap.put("module", "project"); - // requestMap.put("op", "createProject"); - // - // - // ctx = new CoefficientTestingContext(new HashMap(), requestMap, - // new HashMap()); - // - // Object result = null; - // // call method: - // try { - // result = invokeOpOnModule(ctx); - // } catch (Exception e) { - // System.err.println(e); - // } - // // checks if the user has been created - // assertNotNull(result); - return null; - } - - private CoefficientUser createUserObject() { - CoefficientUser user = new CoefficientUser(); - user.setFullName("Tester"); - user.setEmail("pv...@cs..."); - user.setPassword("test"); - user.setUserName("test"); - user.setLanguage(Locale.US); - user.setTimeZone(TimeZone.getDefault()); - user.setActive(true); - return user; - } - - /** - * @author pieter20 Jul 31, 2005 Create a user for this test TODO: Should i - * sent through CoefficientTestingContext or the interface: - * CoefficientContext - * @param requestMap - * @param ctx - * @param project - */ - private void createUser(CoefficientTestingContext ctx, Project project) { - HashMap requestMap = (HashMap) ctx.getRequestData(); - // set user - // this could be done by calling the module UserAdmin - requestMap.put("fullName", "Pieter van Zyl"); - requestMap.put("email", "pv...@cs..."); - requestMap.put("password1", "green"); - requestMap.put("userName", "pvzyl"); - requestMap.put("language", Locale.US); - requestMap.put("timeZone", TimeZone.getDefault()); - requestMap.put("active", new Boolean(true)); - // Note: systemRole can not be populated using the BeanUtils. - // We do not cater for the Role object in: - // BaseCoefficientContext.setProperties(.. - - requestMap.put("module", "UserAdmin"); - requestMap.put("op", "saveUser"); - - // this will force the user to be added to the context. - - ctx.setRequestData(requestMap); - - ctx.setProject(project); - - Object result = null; - // call method: - try { - result = invokeOpOnModule(ctx); - } catch (Exception e) { - System.err.println(e); - } - // checks if the user has been created - assertNotNull(result); - - }// end createUser - - /** - * @author pieter20 Jul 31, 2005 Create a user for this test TODO: Should i - * sent through CoefficientTestingContext or the interface: - * CoefficientContext - * @param requestMap - * @param ctx - * @param project - */ - private void createUserNotUsingModule(CoefficientTestingContext ctx, - Project project) { - HashMap requestMap = (HashMap) ctx.getRequestData(); - // set user - // this could be done by calling the module UserAdmin - - requestMap.put("password1", "green"); - - // Note: systemRole can not be populated using the BeanUtils. - // We do not cater for the Role object in: - // BaseCoefficientContext.setProperties(.. - - requestMap.put("module", "UserAdmin"); - requestMap.put("op", "saveUser"); - requestMap.put("password1", "green"); - - ctx.setRequestData(requestMap); - - ctx.setProject(project); - - Object result = null; - // call method: - try { - result = invokeOpOnModule(ctx); - } catch (Exception e) { - System.err.println(e); - } - // checks if the user has been created - assertNotNull(result); - - }// end createUser - - /** - * @author pieter20 Jul 31, 2005 Associate a user with a project. The user - * is specified as a parameter in the requestMap. - * @param requestMap - * @param ctx - * @param project - */ - private void addUserToProject(CoefficientTestingContext ctx, Project project) { - HashMap requestMap = (HashMap) ctx.getRequestData(); - // associate member/user with project. Use MemberAdmin module's method: - // addMember - requestMap.put("module", "MemberAdmin"); - requestMap.put("op", "addMember"); - - ctx.setRequestData(requestMap); - ctx.setProject(project); - - Object result = null; - // call method: - try { - result = invokeOpOnModule(ctx); - } catch (Exception e) { - System.err.println(e); - } - // checks if the user/member has been associated with this project: - assertNotNull(result); - - }// end addUserToProject() - - private void loginUser(CoefficientTestingContext ctx) { - HashMap requestMap = (HashMap) ctx.getRequestData(); - // login using the new user - requestMap.put("username", "pvzyl"); - requestMap.put("password", "green"); - requestMap.put("module", "Security"); - requestMap.put("op", "login"); - - ctx.setRequestData(requestMap); - - Object result = null; - // call method: - try { - result = invokeOpOnModule(ctx); - } catch (Exception e) { - System.err.println(e); - } - // checks if the login was successfull - assertNotNull(result); - assertTrue(ctx.isError()); - - } - - private HashMap setupBasics() { - HashMap currentSetupMap = new HashMap(); - - // setup the default test db. - setupTestDb(); - - // creates a default project without going through the project module. - Project testProject = createProject(); - currentSetupMap.put(CURRENT_PROJECT, testProject); - CoefficientTestingContext ctx = new CoefficientTestingContext( - new HashMap(), new HashMap(), new HashMap()); - - createUser(ctx, testProject); - // login user by calling tHe nodule or - // creating the coefficient user object on my side - loginUser(ctx); - - // associate member/user with project. Use MemberAdmin module's method: - // addMember: - addUserToProject(ctx, testProject); - currentSetupMap.put(CURRENT_CONTEXT, ctx); - return currentSetupMap; - - }// end setupBasics - private boolean checkExistence(String className) { try { --- 30,37 ---- public MailForumTest(String name) { super(name); + testDbSchema = TestDBSetup.getInstance(); + currentSetupMap = testDbSchema.getCurrentSetupMap();//contains the current context and state } private boolean checkExistence(String className) { try { *************** *** 323,333 **** } public void testForumCreation() { ! HashMap currentSetupMap = setupBasics(); ! Map requestMap = null; CoefficientTestingContext ctx = null; ! ctx = (CoefficientTestingContext) currentSetupMap.get(CURRENT_CONTEXT); requestMap = ctx.getRequestData(); --- 56,72 ---- } + /** + * @author pieter20 + * Aug 5, 2005 + * Tests to see if the MailForum module can create a new forum + */ public void testForumCreation() { ! System.out ! .println("MailForumsTest.testForumCreation()-> starting testing"); Map requestMap = null; CoefficientTestingContext ctx = null; ! ctx = (CoefficientTestingContext) currentSetupMap ! .get(CoefficientTestCase.CURRENT_CONTEXT); requestMap = ctx.getRequestData(); *************** *** 395,407 **** /** ! * @author pieter20 Jul 19, 2005 Test to see if the Forum lists the correct ! * amount of forums */ public void testListingOfForums() { ! HashMap currentSetupMap = setupBasics(); Map requestMap = null; CoefficientTestingContext ctx = null; ! ctx = (CoefficientTestingContext) currentSetupMap.get(CURRENT_CONTEXT); requestMap = ctx.getRequestData(); --- 134,149 ---- /** ! * @author pieter20 Jul 19, 2005 Test to see if the Mailforum module ! * can list a forum. */ public void testListingOfForums() { ! ! System.out ! .println("MailForumsTest.testListingOfForums()-> starting testing"); Map requestMap = null; CoefficientTestingContext ctx = null; ! ctx = (CoefficientTestingContext) currentSetupMap ! .get(CoefficientTestCase.CURRENT_CONTEXT); requestMap = ctx.getRequestData(); *************** *** 429,433 **** int exist = ctx.getPage().getCenter().indexOf("forumid"); System.out ! .println("MailForumsTest.testListForums()-> contains forum: " + exist); } catch (Exception e) { --- 171,175 ---- int exist = ctx.getPage().getCenter().indexOf("forumid"); System.out ! .println("MailForumsTest.testListingOfForums()-> contains forum: " + exist); } catch (Exception e) { |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 12:48:45
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16855/src-test/za/org/coefficient/testing Modified Files: CoefficientTestCase.java Log Message: moved "CURRENT_CONTEXT"and "CURRENT_PROJECT" here from MailForumTest case Index: CoefficientTestCase.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing/CoefficientTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CoefficientTestCase.java 2 Aug 2005 08:06:25 -0000 1.1 --- CoefficientTestCase.java 5 Aug 2005 12:48:35 -0000 1.2 *************** *** 15,19 **** public class CoefficientTestCase extends TestCase { ! // add CoefficientTestingContext here /** --- 15,21 ---- public class CoefficientTestCase extends TestCase { ! public static String CURRENT_CONTEXT = "CURRENT_CONTEXT"; ! ! public static String CURRENT_PROJECT = "CURRENT_PROJECT"; /** *************** *** 31,46 **** /** ! * @author pieter20 ! * Jul 31, 2005 ! * @param ctx, containing: the parameters, the module and the method to invoke ! * @return an object of type CoefficientContext, which contains a map of the result. * @throws Exception */ ! public Object invokeOpOnModule(CoefficientContext ctx) throws Exception { Invoker testModuleInvoker = new TestModuleInvoker();// this should also ! // be a singleton? Object context = testModuleInvoker.invoke(ctx);// calls the ! // BaseInvoker.invoke(ctx) if (context instanceof CoefficientContext) { --- 33,50 ---- /** ! * @author pieter20 Jul 31, 2005 ! * @param ctx, ! * containing: the parameters, the module and the method to ! * invoke ! * @return an object of type CoefficientContext, which contains a map of the ! * result. * @throws Exception */ ! public static Object invokeOpOnModule(CoefficientContext ctx) throws Exception { Invoker testModuleInvoker = new TestModuleInvoker();// this should also ! // be a singleton? Object context = testModuleInvoker.invoke(ctx);// calls the ! // BaseInvoker.invoke(ctx) if (context instanceof CoefficientContext) { |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 12:47:47
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16683/src-test/za/org/coefficient/testing Modified Files: TestDBSetup.java Log Message: moved some methods for setting up the db from MailforumTest to this class. setupBasics is now called here. This class is now a singleton. Add the results: the context into a map. Index: TestDBSetup.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/testing/TestDBSetup.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestDBSetup.java 2 Aug 2005 08:06:25 -0000 1.1 --- TestDBSetup.java 5 Aug 2005 12:47:38 -0000 1.2 *************** *** 4,8 **** --- 4,12 ---- package za.org.coefficient.testing; + import java.util.HashMap; import java.util.List; + import java.util.Locale; + import java.util.Map; + import java.util.TimeZone; import net.sf.hibernate.Hibernate; *************** *** 11,14 **** --- 15,19 ---- import za.org.coefficient.authentication.CoefficientUser; + import za.org.coefficient.authentication.Role; import za.org.coefficient.core.Project; import za.org.coefficient.interfaces.CoefficientContext; *************** *** 18,23 **** --- 23,32 ---- * @author pieter20 Jul 20, 2005 This class is based on the following article on * ServerSide:Unit-Testing Hibernate with HSQL DB by Alex Vollmer + * It initializes and creates the defualt db and one: project and user. + * It then adds the user as a member to the project and logins in the user */ public class TestDBSetup { + private static TestDBSetup instance; + private HashMap currentSetupMap = null; static { *************** *** 31,54 **** } } ! /** * Jul 31, 2005 ! * @author pieter20 ! * This constructor creates and initializes the test db with the basic data that is need for ! * testing. It uses the DataLoaderUtil to initialize the db. */ public TestDBSetup() { ! //pvz: make this TestDBSetup a singleton DataLoaderUtil dataLoader = new DataLoaderUtil(); dataLoader.initializeDataIfNeeded(); } /** * @author pieter20 ! * Jul 31, 2005 ! * Creates a default test project. ! * @return */ ! public Project setupDefaultProject() { Project project = new Project(); --- 40,111 ---- } } ! /** * Jul 31, 2005 ! * ! * @author pieter20 This constructor creates and initializes the test db ! * with the basic data that is need for testing. It uses the ! * DataLoaderUtil to initialize the db. */ public TestDBSetup() { ! // pvz: make this TestDBSetup a singleton DataLoaderUtil dataLoader = new DataLoaderUtil(); dataLoader.initializeDataIfNeeded(); + currentSetupMap = setupBasics(); } + /** * @author pieter20 ! * Aug 5, 2005 ! * This method enforces/implements the Singleton Pattern for this class ! * @return the current instance or a new TestDBSetup instance */ ! public static TestDBSetup getInstance() { ! if (instance == null) { ! synchronized (TestDBSetup.class) { ! if (instance == null) { ! setInstance(new TestDBSetup()); ! ! } ! } ! } ! return instance; ! } ! ! /** ! * @author pieter20 ! * Aug 5, 2005 ! * used to set the static instance object ! * @param instance_ ! */ ! private static void setInstance(TestDBSetup instance_) { ! instance = instance_; ! } ! ! /** ! * @author pieter20 Jul 31, 2005 Create's a project that will be used ! * throughout the test ! * @return object of type Project ! */ ! private Project createProject() { ! Project project = setupDefaultProject(); ! try { ! HibernateUtil.saveOrUpdate(project); ! } catch (HibernateException e) { ! System.err.println("TestDBSetup.createProject()->Project not saved" ! + e); ! } ! ! CoefficientTestCase.assertNotNull(project); ! return project; ! } ! ! /** ! * @author pieter20 Jul 31, 2005 Creates a default test project. ! * The properties of the project is hardcoded. ! * @return the newly created project ! */ ! private Project setupDefaultProject() { Project project = new Project(); *************** *** 64,74 **** /** ! * @author pieter20 ! * Jul 31, 2005 ! * Creates a custom project with parameters passed through the context. * @param ctx * @return */ ! public Project setupProject(CoefficientContext ctx) { Project prj = new Project(); --- 121,130 ---- /** ! * @author pieter20 Jul 31, 2005 Creates a custom project with parameters ! * passed through the context. * @param ctx * @return */ ! private Project setupProject(CoefficientContext ctx) { Project prj = new Project(); *************** *** 98,100 **** --- 154,386 ---- } + /** + * @param requestMap + * TODO + * @param ctx + * TODO + * @param module + * TODO + * @author pieter20 Aug 3, 2005 Using the project module: Projects + * @return + */ + private Project createPublicProject(Map requestMap, CoefficientContext ctx, + String module) { + // TODO: Try to uses the project module later. Not using it now as it + // complicates the testing. Seperation of concerns. + // requestMap.put("shortName", "test"); + // requestMap.put("name", "Testing Project"); + // requestMap.put("homePage", "none"); + // requestMap.put("description", "This project is used to test"); + // requestMap.put("isPrivate", "off"); + // + // ArrayList mods = new ArrayList(); + // mods.add(module); + // requestMap.put("modules", mods); + // + // requestMap.put("module", "project"); + // requestMap.put("op", "createProject"); + // + // + // ctx = new CoefficientTestingContext(new HashMap(), requestMap, + // new HashMap()); + // + // Object result = null; + // // call method: + // try { + // result = invokeOpOnModule(ctx); + // } catch (Exception e) { + // System.err.println(e); + // } + // // checks if the user has been created + // assertNotNull(result); + return null; + } + + /** + * + * @author pieter20 Jul 31, 2005 Create a user for this test TODO: Should i + * sent through CoefficientTestingContext or the interface: + * CoefficientContext + * @param ctx + */ + private void createUser(CoefficientTestingContext ctx) { + HashMap requestMap = (HashMap) ctx.getRequestData(); + // set user + // this could be done by calling the module UserAdmin + requestMap.put("fullName", "Pieter van Zyl"); + requestMap.put("email", "pv...@cs..."); + requestMap.put("password1", "green"); + requestMap.put("userName", "pvzyl"); + requestMap.put("language", Locale.US); + requestMap.put("timeZone", TimeZone.getDefault()); + requestMap.put("active", new Boolean(true)); + // Note: systemRole can not be populated using the BeanUtils. + // We do not cater for the Role object in: + // BaseCoefficientContext.setProperties(.. + + requestMap.put("module", "UserAdmin"); + requestMap.put("op", "saveUser"); + + // this will force the user to be added to the context. + + ctx.setRequestData(requestMap); + + Object result = null; + // call method: + try { + result = CoefficientTestCase.invokeOpOnModule(ctx); + } catch (Exception e) { + System.err.println(e); + } + // checks if the user has been created + CoefficientTestCase.assertNotNull(result); + + } + + /** + * @author pieter20 Aug 5, 2005 Create a user by not using the UserAdmin + * @return a CoefficientUser object + */ + private CoefficientUser createUserObject() { + CoefficientUser user = new CoefficientUser(); + user.setFullName("Tester"); + user.setEmail("pv...@cs..."); + user.setPassword("test"); + user.setUserName("test"); + user.setLanguage(Locale.US); + user.setTimeZone(TimeZone.getDefault()); + user.setActive(true); + return user; + } + + /** + * @author pieter20 Jul 31, 2005 Associate a user with a project. The user + * is specified as a parameter in the requestMap. + * @param ctx + */ + private void addUserToProject(CoefficientTestingContext ctx) { + HashMap requestMap = (HashMap) ctx.getRequestData(); + // associate member/user with project. Use MemberAdmin module's method: + // addMember + requestMap.put("module", "MemberAdmin"); + requestMap.put("op", "addMember"); + + ctx.setRequestData(requestMap); + + Object result = null; + // call method: + try { + result = CoefficientTestCase.invokeOpOnModule(ctx); + } catch (Exception e) { + System.err.println(e); + } + // checks if the user/member has been associated with this project: + CoefficientTestCase.assertNotNull(result); + + } + + /** + * @author pieter20 + * Aug 5, 2005 + * The user needs to be logged in to be able to make calls in the + * system + * @param ctx + */ + private void loginUser(CoefficientTestingContext ctx) { + HashMap requestMap = (HashMap) ctx.getRequestData(); + // login using the new user + requestMap.put("username", "pvzyl"); + requestMap.put("password", "green"); + requestMap.put("module", "Security"); + requestMap.put("op", "login"); + + ctx.setRequestData(requestMap); + + Object result = null; + // call method: + try { + result = CoefficientTestCase.invokeOpOnModule(ctx); + } catch (Exception e) { + System.err.println(e); + } + // checks if the login was successfull + CoefficientTestCase.assertNotNull(result); + CoefficientTestCase.assertTrue(ctx.isError()); + + } + + /* + * + * + * Utility methods: + * + */ + + /** + * @author pieter20 + * Aug 5, 2005 + * Utility method to list all the projects created. + */ + private void listAllProjects() { + try { + List list = HibernateUtil.findAll(Project.class); + System.out + .println("TestDBSetup.listAllProjects()->list size od project list:" + + list.size()); + list = HibernateUtil.findAll(Role.class); + System.out + .println("TestDBSetup.listAllProjects()->list size of all roles in db:" + + list.size()); + + } catch (HibernateException e) { + System.err + .println("TestDBSetup.listAllProjects()->Could not retrieve any projects" + + e); + } + + } + + /** + * @author pieter20 + * Aug 5, 2005 + * This method initializes and creates the defualt testing project and user. + * It then adds the user as a member to the project and logins in the user. + * The stage is then set for testing + * @return a HashMap containing the CURRENT_PROJECT =projct + * and the CURRENT_CONTEXT = ctx + */ + private HashMap setupBasics() { + HashMap currentSetupMap = new HashMap(); + + // creates a default project without going through the project module. + Project testProject = createProject(); + currentSetupMap.put(CoefficientTestCase.CURRENT_PROJECT, testProject); + CoefficientTestingContext ctx = new CoefficientTestingContext( + new HashMap(), new HashMap(), new HashMap()); + ctx.setProject(testProject); + createUser(ctx); + // login user by calling tHe nodule or + // creating the coefficient user object on my side + loginUser(ctx); + + // associate member/user with project. Use MemberAdmin module's method: + // addMember: + addUserToProject(ctx); + currentSetupMap.put(CoefficientTestCase.CURRENT_CONTEXT, ctx); + return currentSetupMap; + + } + + + /** + * @author pieter20 + * Aug 5, 2005 + * This methods is the main method of obtaining the current state that has been created for testing. + * @return a HashMap containing the CURRENT_PROJECT =projct + * and the CURRENT_CONTEXT = ctx + */ + public HashMap getCurrentSetupMap() { + return currentSetupMap; + } + } |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 09:13:42
|
Update of /cvsroot/coefficient/mailForum/src-test/za/org/coefficient/modules/mailforum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12684/modules/mailForum/src-test/za/org/coefficient/modules/mailforum Modified Files: MailForumTest.java Log Message: added in MailForumTest: testForumCreation(), setupBasics(), checkExistence(to test if and object was created in the db) added CURRENT_CONTEXT and CURRENT_PROJECT. I am now using ONE context object as I am setting up the test case. added loginUser to login the user and set the user in the session. Index: MailForumTest.java =================================================================== RCS file: /cvsroot/coefficient/mailForum/src-test/za/org/coefficient/modules/mailforum/MailForumTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MailForumTest.java 2 Aug 2005 07:13:41 -0000 1.1 --- MailForumTest.java 5 Aug 2005 09:13:33 -0000 1.2 *************** *** 4,7 **** --- 4,8 ---- package za.org.coefficient.modules.mailforum; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; *************** *** 13,17 **** --- 14,20 ---- import net.sf.hibernate.util.HibernateUtil; + import za.org.coefficient.authentication.CoefficientUser; import za.org.coefficient.authentication.Role; + import za.org.coefficient.core.Constants; import za.org.coefficient.core.Project; import za.org.coefficient.interfaces.CoefficientContext; *************** *** 20,24 **** import za.org.coefficient.testing.CoefficientTestingContext; import za.org.coefficient.testing.TestDBSetup; ! /** --- 23,27 ---- import za.org.coefficient.testing.CoefficientTestingContext; import za.org.coefficient.testing.TestDBSetup; ! import za.org.coefficient.util.ejb.SecurityUtil; /** *************** *** 29,32 **** --- 32,39 ---- private TestDBSetup testDbSchema = null; + private static String CURRENT_CONTEXT = "CURRENT_CONTEXT"; + + private static String CURRENT_PROJECT = "CURRENT_PROJECT"; + /** * Jul 19, 2005 *************** *** 85,95 **** /** ! * @author pieter20 Jul 31, 2005 Create a user for this test * @param requestMap * @param ctx * @param project */ ! private void createUser(Map requestMap, CoefficientContext ctx, ! Project project) { // set user // this could be done by calling the module UserAdmin --- 92,153 ---- /** ! * @author pieter20 Aug 3, 2005 Using the project module: Projects ! * @return ! */ ! private Project createPublicProject(Map requestMap, CoefficientContext ctx, ! String module) { ! // TODO: Try to uses the project module later. Not using it now as it ! // complicates the testing. Seperation of concerns. ! // requestMap.put("shortName", "test"); ! // requestMap.put("name", "Testing Project"); ! // requestMap.put("homePage", "none"); ! // requestMap.put("description", "This project is used to test"); ! // requestMap.put("isPrivate", "off"); ! // ! // ArrayList mods = new ArrayList(); ! // mods.add(module); ! // requestMap.put("modules", mods); ! // ! // requestMap.put("module", "project"); ! // requestMap.put("op", "createProject"); ! // ! // ! // ctx = new CoefficientTestingContext(new HashMap(), requestMap, ! // new HashMap()); ! // ! // Object result = null; ! // // call method: ! // try { ! // result = invokeOpOnModule(ctx); ! // } catch (Exception e) { ! // System.err.println(e); ! // } ! // // checks if the user has been created ! // assertNotNull(result); ! return null; ! } ! ! private CoefficientUser createUserObject() { ! CoefficientUser user = new CoefficientUser(); ! user.setFullName("Tester"); ! user.setEmail("pv...@cs..."); ! user.setPassword("test"); ! user.setUserName("test"); ! user.setLanguage(Locale.US); ! user.setTimeZone(TimeZone.getDefault()); ! user.setActive(true); ! return user; ! } ! ! /** ! * @author pieter20 Jul 31, 2005 Create a user for this test TODO: Should i ! * sent through CoefficientTestingContext or the interface: ! * CoefficientContext * @param requestMap * @param ctx * @param project */ ! private void createUser(CoefficientTestingContext ctx, Project project) { ! HashMap requestMap = (HashMap) ctx.getRequestData(); // set user // this could be done by calling the module UserAdmin *************** *** 107,114 **** requestMap.put("module", "UserAdmin"); requestMap.put("op", "saveUser"); requestMap.put("password1", "green"); ! ctx = new CoefficientTestingContext(new HashMap(), requestMap, ! new HashMap()); ctx.setProject(project); --- 165,212 ---- requestMap.put("module", "UserAdmin"); requestMap.put("op", "saveUser"); + + // this will force the user to be added to the context. + + ctx.setRequestData(requestMap); + + ctx.setProject(project); + + Object result = null; + // call method: + try { + result = invokeOpOnModule(ctx); + } catch (Exception e) { + System.err.println(e); + } + // checks if the user has been created + assertNotNull(result); + + }// end createUser + + /** + * @author pieter20 Jul 31, 2005 Create a user for this test TODO: Should i + * sent through CoefficientTestingContext or the interface: + * CoefficientContext + * @param requestMap + * @param ctx + * @param project + */ + private void createUserNotUsingModule(CoefficientTestingContext ctx, + Project project) { + HashMap requestMap = (HashMap) ctx.getRequestData(); + // set user + // this could be done by calling the module UserAdmin + + requestMap.put("password1", "green"); + + // Note: systemRole can not be populated using the BeanUtils. + // We do not cater for the Role object in: + // BaseCoefficientContext.setProperties(.. + + requestMap.put("module", "UserAdmin"); + requestMap.put("op", "saveUser"); requestMap.put("password1", "green"); ! ctx.setRequestData(requestMap); ctx.setProject(project); *************** *** 133,138 **** * @param project */ ! private void addUserToProject(Map requestMap, CoefficientContext ctx, ! Project project) { // associate member/user with project. Use MemberAdmin module's method: // addMember --- 231,236 ---- * @param project */ ! private void addUserToProject(CoefficientTestingContext ctx, Project project) { ! HashMap requestMap = (HashMap) ctx.getRequestData(); // associate member/user with project. Use MemberAdmin module's method: // addMember *************** *** 140,145 **** requestMap.put("op", "addMember"); ! ctx = new CoefficientTestingContext(new HashMap(), requestMap, ! new HashMap()); ctx.setProject(project); --- 238,242 ---- requestMap.put("op", "addMember"); ! ctx.setRequestData(requestMap); ctx.setProject(project); *************** *** 156,164 **** }// end addUserToProject() ! /** ! * @author pieter20 Jul 19, 2005 ! * Test to see if the Forum lists the correct amount of forums ! */ ! public void testListForums() { // setup the default test db. --- 253,281 ---- }// end addUserToProject() ! private void loginUser(CoefficientTestingContext ctx) { ! HashMap requestMap = (HashMap) ctx.getRequestData(); ! // login using the new user ! requestMap.put("username", "pvzyl"); ! requestMap.put("password", "green"); ! requestMap.put("module", "Security"); ! requestMap.put("op", "login"); ! ! ctx.setRequestData(requestMap); ! ! Object result = null; ! // call method: ! try { ! result = invokeOpOnModule(ctx); ! } catch (Exception e) { ! System.err.println(e); ! } ! // checks if the login was successfull ! assertNotNull(result); ! assertTrue(ctx.isError()); ! ! } ! ! private HashMap setupBasics() { ! HashMap currentSetupMap = new HashMap(); // setup the default test db. *************** *** 167,179 **** // creates a default project without going through the project module. Project testProject = createProject(); ! listAllProjects(); ! Map requestMap = new HashMap(); ! CoefficientTestingContext ctx = null; - createUser(requestMap, ctx, testProject); // associate member/user with project. Use MemberAdmin module's method: // addMember: ! addUserToProject(requestMap, ctx, testProject); // add all parameters that are need into the context map --- 284,408 ---- // creates a default project without going through the project module. Project testProject = createProject(); ! currentSetupMap.put(CURRENT_PROJECT, testProject); ! CoefficientTestingContext ctx = new CoefficientTestingContext( ! new HashMap(), new HashMap(), new HashMap()); ! createUser(ctx, testProject); ! // login user by calling tHe nodule or ! // creating the coefficient user object on my side ! loginUser(ctx); // associate member/user with project. Use MemberAdmin module's method: // addMember: ! addUserToProject(ctx, testProject); ! currentSetupMap.put(CURRENT_CONTEXT, ctx); ! return currentSetupMap; ! ! }// end setupBasics ! ! private boolean checkExistence(String className) { ! try { ! List list = HibernateUtil.findAll(Class.forName(className)); ! ! System.out.println("MailForumsTest.checkExistence()->list size:" ! + list.size()); ! // System.out ! // .println("MailForumsTest.checkExistence()->list contains: " ! // + name + " : " + list.contains(name)); ! // return list.contains(name); ! return (list.size() == 1); ! } catch (HibernateException e) { ! System.err ! .println("MailForumsTest.checkExistence()->Could not retrieve any objects" ! + e); ! } catch (ClassNotFoundException e) { ! e.printStackTrace(); ! } ! return false; ! ! } ! ! public void testForumCreation() { ! HashMap currentSetupMap = setupBasics(); ! ! Map requestMap = null; ! CoefficientTestingContext ctx = null; ! ! ctx = (CoefficientTestingContext) currentSetupMap.get(CURRENT_CONTEXT); ! requestMap = ctx.getRequestData(); ! ! // if the context is null something went wrong!! ! assertNotNull(requestMap); ! // set project ! requestMap.put("mailAddressSnippet", ""); ! requestMap.put("fullName", "Test Forum List"); ! requestMap.put("mailSubjectPrefix", "test-forum"); ! requestMap.put("description", " This forum is used for testing"); ! requestMap.put("requireMembershipToView", "true"); ! requestMap.put("requireMembershipToPost", "true"); ! requestMap.put("moderated", "false"); ! requestMap.put("openSubscription", "false");// setRequirePermissionToSubscribe ! requestMap.put("footer", " Test Forum Footer"); ! requestMap.put("maxMessageSize", "1000"); ! requestMap.put("maxAttachmentSize", "0"); ! ! requestMap.put("module", "MailForum"); ! requestMap.put("op", "forumSaveAction"); ! ! ctx.setRequestData(requestMap); ! // ctx.setProject(testProject); ! ! Object result = null; ! // call method: ! try { ! result = invokeOpOnModule(ctx); ! } catch (Exception e) { ! System.err.println(e); ! } ! // the list should be empty and not null: ! assertNotNull(result); ! // check to see if a certain tag is present in the result wich is a page ! // object containing an ! // html string ! if (result instanceof CoefficientTestingContext) { ! ctx = (CoefficientTestingContext) result; ! try { ! int fullNameExist = ctx.getPage().getCenter().indexOf( ! "fullName"); ! int forumIdExist = ctx.getPage().getCenter().indexOf("forumid"); ! System.out ! .println("MailForumsTest.testForumCreation()-> contains fullName str: " ! + fullNameExist ! + " contains forumid str: " ! + forumIdExist); ! } catch (Exception e) { ! e.printStackTrace(); ! } ! ! } else { ! System.out ! .println("MailForumTest.testForumCreation()->We are only interested in CoefficientTestingContext objects!!!!"); ! ! }// end if tag check ! // OR white box testing: ! boolean existsInDb = checkExistence("org.dithaka.messaging.Forum"); ! assertTrue(existsInDb); ! System.out ! .println("MailForumsTest.testForumCreation()-> exists in db: " ! + existsInDb); ! ! } ! ! /** ! * @author pieter20 Jul 19, 2005 Test to see if the Forum lists the correct ! * amount of forums ! */ ! public void testListingOfForums() { ! HashMap currentSetupMap = setupBasics(); ! Map requestMap = null; ! CoefficientTestingContext ctx = null; ! ! ctx = (CoefficientTestingContext) currentSetupMap.get(CURRENT_CONTEXT); ! requestMap = ctx.getRequestData(); // add all parameters that are need into the context map *************** *** 181,187 **** requestMap.put("module", "MailForum"); requestMap.put("op", "forumList"); ! ctx = new CoefficientTestingContext(new HashMap(), requestMap, ! new HashMap()); ! ctx.setProject(testProject); Object result = null; --- 410,414 ---- requestMap.put("module", "MailForum"); requestMap.put("op", "forumList"); ! ctx.setRequestData(requestMap); Object result = null; *************** *** 194,198 **** // the list should be empty and not null: assertNotNull(result); ! if (result instanceof CoefficientTestingContext) { ctx = (CoefficientTestingContext) result; --- 421,427 ---- // the list should be empty and not null: assertNotNull(result); ! // check to see if a certain tag is present in the result wich is a page ! // object containing an ! // html string if (result instanceof CoefficientTestingContext) { ctx = (CoefficientTestingContext) result; *************** *** 212,215 **** } ! } } --- 441,445 ---- } ! }// end test case: testListForums ! } |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 09:13:41
|
Update of /cvsroot/coefficient/mailForum In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12684/modules/mailForum Modified Files: changelog.txt Log Message: added in MailForumTest: testForumCreation(), setupBasics(), checkExistence(to test if and object was created in the db) added CURRENT_CONTEXT and CURRENT_PROJECT. I am now using ONE context object as I am setting up the test case. added loginUser to login the user and set the user in the session. Index: changelog.txt =================================================================== RCS file: /cvsroot/coefficient/mailForum/changelog.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** changelog.txt 30 Jun 2005 11:21:27 -0000 1.6 --- changelog.txt 5 Aug 2005 09:13:33 -0000 1.7 *************** *** 1,2 **** --- 1,13 ---- + 05/08/2005 + pvz: added in MailForumTest: testForumCreation(), setupBasics(), checkExistence(to test if and object was created in the db) + added CURRENT_CONTEXT and CURRENT_PROJECT. I am now using ONE context object as I am setting up the test case. + added loginUser to login the user and set the user in the session. + + 02/08/2005 + pvzyl: Added src-test to this module and the MailForumTest case + + =========== + V0-9-6: + =========== 30/06/2005 pvz: these jars should not be here. These must be copied or be build from the Dithaka project and either be moved here |
From: Pieter v. Z. <pv...@us...> - 2005-08-05 09:08:39
|
Update of /cvsroot/coefficient/coefficient/src/za/org/coefficient/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11901/src/za/org/coefficient/core Modified Files: BaseCoefficientContext.java Log Message: added getters and setters in BaseCoefficientContext for the 3 maps: session,requestData and requestAttributes. These are added so that we can have acces to them when testing.Maybe I should move CoefficientTestingContext in the same package name so that I can remove these public methods and move them into CoefficientTestingContext Index: BaseCoefficientContext.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src/za/org/coefficient/core/BaseCoefficientContext.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** BaseCoefficientContext.java 22 Oct 2004 08:33:46 -0000 1.9 --- BaseCoefficientContext.java 5 Aug 2005 09:08:29 -0000 1.10 *************** *** 612,615 **** --- 612,639 ---- } } + + public Map getRequestAttributes() { + return requestAttributes; + } + + public void setRequestAttributes(Map requestAttributes) { + this.requestAttributes = requestAttributes; + } + + public Map getRequestData() { + return requestData; + } + + public void setRequestData(Map requestData) { + this.requestData = requestData; + } + + public Map getSession() { + return session; + } + + public void setSession(Map session) { + this.session = session; + } } |
From: Pieter v. Z. <pv...@us...> - 2005-08-03 08:50:22
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/invokers/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6123/src-test/za/org/coefficient/invokers/test Modified Files: TestModuleInvoker.java Log Message: added XMLJndiUtil to create the modules Index: TestModuleInvoker.java =================================================================== RCS file: /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/invokers/test/TestModuleInvoker.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestModuleInvoker.java 2 Aug 2005 08:06:25 -0000 1.1 --- TestModuleInvoker.java 3 Aug 2005 08:50:05 -0000 1.2 *************** *** 4,11 **** package za.org.coefficient.invokers.test; import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.beanutils.PropertyUtils; - import za.co.csir.icomtek.workflow.interfaces.WorkflowContext; import za.org.coefficient.authentication.Role; --- 4,12 ---- package za.org.coefficient.invokers.test; + import java.util.Hashtable; + import org.apache.commons.beanutils.MethodUtils; import org.apache.commons.beanutils.PropertyUtils; import za.co.csir.icomtek.workflow.interfaces.WorkflowContext; import za.org.coefficient.authentication.Role; *************** *** 15,18 **** --- 16,20 ---- import za.org.coefficient.interfaces.ThemeLocalIf; import za.org.coefficient.invokers.base.BaseInvoker; + import za.org.coefficient.util.common.XMLJndiUtil; import za.org.coefficient.util.ejb.SecurityUtil; *************** *** 27,30 **** --- 29,40 ---- private static final String CREATE = "create"; + private static Hashtable mockJNDI = null; + + private static String SERVER_XML_FILE = "server.xml.snippit"; + + static { + mockJNDI = XMLJndiUtil.createMockJNDI(SERVER_XML_FILE); + } + /** * Jul 19, 2005 *************** *** 41,94 **** * @see za.org.coefficient.invokers.base.BaseInvoker#getService(java.lang.String) * This method acts as a lookup for the module/class in JNDI. JNDI is ! * not used but simulated using a if statement to return an instance of ! * the requested object. This is done for testing so that we don't need * a container. */ public Object getService(String serviceName) throws Exception { - // new Object[]{"za.org.coefficient.modules.mailforum.MailForum"} Object module = null; ! System.out.println("TestModuleInvoker.getService()-> serviceName: " ! + serviceName); ! if (serviceName == "UserAdmin") { ! module = (Object) Class.forName( ! "za.org.coefficient.modules.user.UserAdmin").newInstance(); ! } else if (serviceName == "MailForum") { ! module = (Object) Class.forName( ! "za.org.coefficient.modules.mailforum.MailForum") ! .newInstance(); ! } else if (serviceName == "Configuration") { ! module = (Object) Class.forName( ! "za.org.coefficient.modules.configuration.Configuration") ! .newInstance(); ! ! } else if (serviceName == "Role") { ! // TODO:Pvzyl: we ! // need to improve ! // this. Why should ! // this be called in ! // an EJB? Move this ! // method to the ! // Role class ! module = (Object) Class.forName( ! "za.org.coefficient.util.common.Roles").newInstance(); ! ! } else if (serviceName == "AttributeDataManagement") { ! module = (Object) Class ! .forName( ! "za.org.coefficient.modules.attribute.AttributeDataManagement") ! .newInstance(); ! ! } else if (serviceName == "MemberAdmin") { ! module = (Object) Class.forName( ! "za.org.coefficient.modules.user.MemberAdmin") ! .newInstance(); ! ! } else if (serviceName == "DefaultTheme") { ! module = (Object) Class.forName( ! "za.org.coefficient.themes.defaultTheme.DefaultTheme") ! .newInstance(); ! ! } else { ! return null; } --- 51,63 ---- * @see za.org.coefficient.invokers.base.BaseInvoker#getService(java.lang.String) * This method acts as a lookup for the module/class in JNDI. JNDI is ! * not used but simulated using the XMLJndiUtil. ! * This is done for testing so that we don't need * a container. */ public Object getService(String serviceName) throws Exception { Object module = null; ! if (mockJNDI != null) { ! String className = (String) mockJNDI.get(serviceName); ! module = (Object) Class.forName(className).newInstance(); } *************** *** 141,145 **** CoefficientContext ctx) throws Exception { Object retVal = null; ! //is this the best place to put this security? return invokeOpOnModuleWithoutSecurity(module, operation, ctx); --- 110,114 ---- CoefficientContext ctx) throws Exception { Object retVal = null; ! // is this the best place to put this security? return invokeOpOnModuleWithoutSecurity(module, operation, ctx); |
From: Pieter v. Z. <pv...@us...> - 2005-08-03 08:47:36
|
Update of /cvsroot/coefficient/coefficient/src-test/za/org/coefficient/util/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5736/src-test/za/org/coefficient/util/common Added Files: XMLJndiUtil.java Log Message: This class reads in a server.xml file and uses the Resource tags/elements to create a lookup table (mock jndi) --- NEW FILE: XMLJndiUtil.java --- /** * */ package za.org.coefficient.util.common; import java.io.IOException; import java.io.InputStream; import java.util.Hashtable; import java.util.Iterator; import org.apache.velocity.anakia.NodeList; import org.apache.xerces.parsers.DOMParser; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * @author pieter20 Aug 2, 2005 * This class reads in a server.xml file and uses the Resource tags/elements to * create a lookup table (mock jndi) */ public class XMLJndiUtil { /** * @author pieter20 * Aug 3, 2005 * @param fileName * @return */ public static InputStream getFileInputStream(String fileName) { InputStream xmlFile = null; // See if it is in the classpath xmlFile = XMLJndiUtil.class.getResourceAsStream("/WEB-INF/" + fileName); // See if it is in the jar if (xmlFile == null) { xmlFile = XMLJndiUtil.class.getResourceAsStream("/" + fileName); if (xmlFile == null) { xmlFile = XMLJndiUtil.class.getResourceAsStream(fileName); } }// end nested if if (xmlFile == null) { System.out.println("XMLReaderUtil.getFileInputStream()-> File not found!!!"); } return xmlFile; } /** * @author pieter20 * Aug 3, 2005 * This method reads in a xml file: server.xml and creates a mock JNDI * lookup table. The table is implemented currently as a hashtable. The "Resource" * tag element and its attributes are used. A DOM parser is used. * @param xmlFileName * @return Hashtable containing some */ public static Hashtable createMockJNDI(String xmlFileName) { Hashtable xmlTable = new Hashtable(); DOMParser domParser = new DOMParser(); InputStream xmlFile = getFileInputStream(xmlFileName); InputSource xmlSource = new InputSource(xmlFile); try { domParser.parse(xmlSource); } catch (IOException io) { io.printStackTrace(); } catch (SAXException sax) { sax.printStackTrace(); } Document doc = domParser.getDocument(); org.w3c.dom.NodeList list = doc.getElementsByTagName("Resource"); for (int i = 0; i < list.getLength(); i++) { Element resourceElement = (Element)list.item(i); Attr name = resourceElement.getAttributeNode("name"); Attr className = resourceElement.getAttributeNode("type"); xmlTable.put(name.getValue(),className.getValue()); }//end for return xmlTable; } /** * @author pieter20 Aug 2, 2005 * @param args */ public static void main(String[] args) { Hashtable mockJNDI = createMockJNDI("server.xml.snippit"); Iterator jndiItems = mockJNDI.keySet().iterator(); while (jndiItems.hasNext()) { String name = (String) jndiItems.next(); String classType = (String)mockJNDI.get(name); System.out.println("name: "+name+" -> type: "+classType ); } } } |