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;
+ }
/**
|