prickett 2002/10/22 23:43:27
Modified: periodicity LICENSE
periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/util
JUnitUtils.java
periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database
DriverServiceConfigEmptyTest.java
DriverServiceConfigNullTest.java
DriverServiceDbFileNonExistTest.java
TestDriverService.java
Added:
periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database
DriverServiceGetInitTest.java
Log:
Changed the License file in the top level directory to relect the correct
dates. Will change the source files before any formal "releases".
Added a printStackTraceAsString method to JUnitUtils
Added a name parameter to the TestDriverService constructor.
Overrode the default behavior of getRealPath to just be a pass through
because we are operating in a build environment, not a web environment.
Added a test to check for a correct initialization of the Driver service.
Revision Changes Path
1.2 +4 -4 jakarta-commons-sandbox/periodicity/LICENSE
Index: LICENSE
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/LICENSE,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LICENSE 12 Feb 2002 20:21:05 -0000 1.1
+++ LICENSE 23 Oct 2002 06:43:26 -0000 1.2
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
1.2 +19 -2
jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/util/JUnitUtils.java
Index: JUnitUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/util/JUnitUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JUnitUtils.java 11 Oct 2002 17:37:21 -0000 1.1
+++ JUnitUtils.java 23 Oct 2002 06:43:27 -0000 1.2
@@ -66,6 +66,8 @@
import java.util.Enumeration;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import junit.framework.TestResult;
import junit.framework.TestFailure;
@@ -147,6 +149,21 @@
else
{
System.err.println("Unexpected Failure");
+ }
+ }
+
+ public static String getStackTraceAsString(Throwable thr)
+ {
+ if(thr != null)
+ {
+ StringWriter swrt = new StringWriter();
+ PrintWriter pwrt = new PrintWriter(swrt);
+ thr.printStackTrace(pwrt);
+ return swrt.toString();
+ }
+ else
+ {
+ return null;
}
}
}
1.2 +3 -2
jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceConfigEmptyTest.java
Index: DriverServiceConfigEmptyTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceConfigEmptyTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DriverServiceConfigEmptyTest.java 23 Oct 2002 03:56:41 -0000 1.1
+++ DriverServiceConfigEmptyTest.java 23 Oct 2002 06:43:27 -0000 1.2
@@ -79,6 +79,7 @@
try
{
TestDriverService driverService = new TestDriverService(
+ DriverMetaDataService.SERVICE_NAME,
new BaseConfiguration());
driverService.init();
fail("A Driver Meta Data Service with an empty configuration " +
1.2 +5 -3
jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceConfigNullTest.java
Index: DriverServiceConfigNullTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceConfigNullTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DriverServiceConfigNullTest.java 23 Oct 2002 02:47:15 -0000 1.1
+++ DriverServiceConfigNullTest.java 23 Oct 2002 06:43:27 -0000 1.2
@@ -78,7 +78,9 @@
{
try
{
- TestDriverService driverService = new TestDriverService(null);
+ TestDriverService driverService = new TestDriverService(
+ DriverMetaDataService.SERVICE_NAME,
+ null);
driverService.init();
fail("A null configuration should throw an exception.");
}
1.2 +5 -3
jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceDbFileNonExistTest.java
Index: DriverServiceDbFileNonExistTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceDbFileNonExistTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DriverServiceDbFileNonExistTest.java 23 Oct 2002 03:56:41 -0000 1.1
+++ DriverServiceDbFileNonExistTest.java 23 Oct 2002 06:43:27 -0000 1.2
@@ -83,7 +83,9 @@
config.addProperty(
PeriodicityDriverService.DATABASE_META_DATA_FILE_KEY,
"file_does_not_exist.xml.txt.properties");
- TestDriverService driverService = new TestDriverService(config);
+ TestDriverService driverService = new TestDriverService(
+ DriverMetaDataService.SERVICE_NAME,
+ config);
driverService.init();
fail("Specifying a database file that does not exist should cause"
+ " an exception.");
1.2 +17 -4
jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/TestDriverService.java
Index: TestDriverService.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/TestDriverService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestDriverService.java 23 Oct 2002 02:25:24 -0000 1.1
+++ TestDriverService.java 23 Oct 2002 06:43:27 -0000 1.2
@@ -69,15 +69,28 @@
{
/**
* The purpose of this method is to create a test driver service
- * with the given configuration.
+ * with the given configuration and name.
* @param config The configuration of the service as a commons
* configuration object.
*/
- TestDriverService(Configuration config)
+ TestDriverService(String name, Configuration config)
{
+ setName(name);
configuration = config;
}
+
+ /**
+ * The purpose of this method is to override the default behavior of
+ * getRealPath so that it is just a pass through instead of computing
+ * a relative path according to the application base path. We are in
+ * a build environment when we are testing and not a web environment.
+ */
+
+ public String getRealPath(String path)
+ {
+ return path;
+ }
}
1.1
jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceGetInitTest.java
Index: DriverServiceGetInitTest.java
===================================================================
package org.apache.commons.periodicity.database;
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/test/org/apache/commons/periodicity/database/DriverServiceGetInitTest.java,v
1.1 2002/10/23 06:43:27 prickett Exp $
* $Revision: 1.1 $
* $Date: 2002/10/23 06:43:27 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
import junit.framework.Test;
import junit.framework.TestCase;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.periodicity.util.JUnitUtils;
public class DriverServiceGetInitTest extends TestCase
{
public DriverServiceGetInitTest(String name)
{
super(name);
}
protected void runTest()
{
try
{
BaseConfiguration config = new BaseConfiguration();
config.addProperty(
PeriodicityDriverService.DATABASE_META_DATA_FILE_KEY,
"project.xml");
TestDriverService driverService = new TestDriverService(
DriverMetaDataService.SERVICE_NAME,
config);
driverService.init();
assertTrue("Service should have been initialized.",
driverService.getInit());
}
catch(Exception e)
{
fail(JUnitUtils.getStackTraceAsString(e));
}
}
public static Test suite()
{
return new DriverServiceGetInitTest(
"PeriodicityDriverService.getInit()");
}
}
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>