Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 9106 invoked from network); 11 Oct 2002 17:39:31 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 11 Oct 2002 17:39:31 -0000 Received: (qmail 9717 invoked by uid 97); 11 Oct 2002 17:39:51 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 9685 invoked by uid 97); 11 Oct 2002 17:39:50 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 9633 invoked by uid 97); 11 Oct 2002 17:39:48 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 11 Oct 2002 17:37:21 -0000 Message-ID: <20021011173721.40362.qmail@icarus.apache.org> From: prickett@apache.org To: jakarta-commons-sandbox-cvs@apache.org Subject: cvs commit: jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/util JUnitUtils.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N prickett 2002/10/11 10:37:21 Modified: periodicity/src/plugins-build/database project.xml Added: periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/ant GetDatabaseConnectionTask.java periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database GetDatabaseConnectionTest.java periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/util JUnitUtils.java Log: Added a dependency to junit 3.7 Added a dependency to ant 1.4.1 Added a build tag in the project.xml file for the periodicity database plugin Added an ant task to get a connection to a database Added a junit test to get a connection to the database Added a junit utility class to help with printing failures to system error Revision Changes Path 1.3 +19 -0 jakarta-commons-sandbox/periodicity/src/plugins-build/database/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/project.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- project.xml 10 Oct 2002 22:43:08 -0000 1.2 +++ project.xml 11 Oct 2002 17:37:21 -0000 1.3 @@ -16,10 +16,29 @@ scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/periodicity/src/java/plugins-build/database + Jeff Prickett prickett + + + + junit + 3.7 + + + ant + 1.4.1 + + + + + commons-dev@jakarta.apache.org + src/java + + + 1.1 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/ant/GetDatabaseConnectionTask.java Index: GetDatabaseConnectionTask.java =================================================================== package org.apache.commons.periodicity.task; /* * $Header: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/ant/GetDatabaseConnectionTask.java,v 1.1 2002/10/11 17:37:21 prickett Exp $ * $Revision: 1.1 $ * $Date: 2002/10/11 17:37:21 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2001 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 apache@apache.org. * * 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 * . * */ import org.apache.tools.ant.Task; import org.apache.tools.ant.BuildException; import org.apache.commons.periodicity.database.GetDatabaseConnectionTest; public class GetDatabaseConnectionTask extends Task { public void setUrl(String newval) { if(newval != null) { System.setProperty(GetDatabaseConnectionTest.DATABASE_URL, newval); } } public void setUser(String newval) { if(newval != null) { System.setProperty(GetDatabaseConnectionTest.DATABASE_USER, newval); } } public void setPassword(String newval) { if(newval != null) { System.setProperty(GetDatabaseConnectionTest.DATABASE_PASSWORD, newval); } } public void execute() throws BuildException { GetDatabaseConnectionTest.runStatic(); } } 1.1 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/GetDatabaseConnectionTest.java Index: GetDatabaseConnectionTest.java =================================================================== package org.apache.commons.periodicity.database; /* * $Header: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/database/GetDatabaseConnectionTest.java,v 1.1 2002/10/11 17:37:21 prickett Exp $ * $Revision: 1.1 $ * $Date: 2002/10/11 17:37:21 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2001 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 apache@apache.org. * * 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 * . * */ import java.sql.DriverManager; import java.sql.Connection; import junit.framework.TestCase; import junit.framework.TestResult; import org.apache.commons.periodicity.util.JUnitUtils; public class GetDatabaseConnectionTest extends TestCase { public static final String DATABASE_CONNECTION_TEST_NAME = "getDatabaseConnection"; public static final String DATABASE_URL = "periodicity.database.url"; public static final String DATABASE_USER = "periodicity.database.user"; public static final String DATABASE_PASSWORD = "periodicity.database.password"; private String databaseUrl = null; private String databaseUser = null; private String databasePassword = null; public GetDatabaseConnectionTest(String name) { super(name); } public static void runStatic() { GetDatabaseConnectionTest connTest = new GetDatabaseConnectionTest( GetDatabaseConnectionTest.DATABASE_CONNECTION_TEST_NAME); TestResult connResult = connTest.run(); if(connResult != null) { if(connResult.failureCount() == 0) { System.err.println("Successfully got a database connection"); } else { JUnitUtils.printFailuresToSystem(connResult); } } } protected void setUp() throws Exception { databaseUrl = System.getProperty(DATABASE_URL); databaseUser = System.getProperty(DATABASE_USER); databasePassword = System.getProperty(DATABASE_PASSWORD); } protected void runTest() { try { if(databaseUrl != null && databaseUser!= null && databasePassword != null) { Connection connection = DriverManager.getConnection(databaseUrl, databaseUser, databasePassword); connection = null; } else if(databaseUrl == null) { fail("databaseUrl == null"); } else if(databaseUser == null) { fail("databaseUser == null"); } else if(databasePassword == null) { fail("databasePassword == null"); } else { fail("Unexpected Exception"); } } catch(Exception e) { e.printStackTrace(); fail(e.getMessage()); } } protected void tearDown() throws Exception { System.setProperty(DATABASE_URL, null); System.setProperty(DATABASE_USER, null); System.setProperty(DATABASE_PASSWORD, null); } } 1.1 jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/util/JUnitUtils.java Index: JUnitUtils.java =================================================================== package org.apache.commons.periodicity.util; /* * $Header: /home/cvs/jakarta-commons-sandbox/periodicity/src/plugins-build/database/src/java/org/apache/commons/periodicity/util/JUnitUtils.java,v 1.1 2002/10/11 17:37:21 prickett Exp $ * $Revision: 1.1 $ * $Date: 2002/10/11 17:37:21 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2001 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 apache@apache.org. * * 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 * . * */ import java.util.Enumeration; import junit.framework.TestResult; import junit.framework.TestFailure; public class JUnitUtils { public static void printFailuresToSystem(TestResult results) { if(results != null) { if(results.failureCount() > 0) { Enumeration enum = results.failures(); if(enum != null) { if(enum.hasMoreElements()) { TestFailure failure = (TestFailure) enum.nextElement(); printFailureToSystemError(failure); } else if(!enum.hasMoreElements()) { System.err.println( "enum != null but, enum has no elements"); } else { System.err.println("Unexpected Exception"); } while(enum.hasMoreElements()) { TestFailure failure = (TestFailure) enum.nextElement(); printFailureToSystemError(failure); } } else if(enum == null) { System.err.println("enum == null"); } else { System.err.println("Unexpected Exception"); } } else if(results.failureCount() == 0) { System.out.println("No failures to report."); } else if(results.failureCount() < 0) { System.err.println("results.failureCount < 0"); } else { System.err.println("Unexpected Exception"); } } else if(results == null) { System.err.println("results == null"); } else { System.err.println("Unexpected Exception"); } } public static void printFailureToSystemError(TestFailure failure) { if(failure != null) { System.err.println(failure); } else if(failure == null) { System.err.println("failure == null"); } else { System.err.println("Unexpected Failure"); } } } -- To unsubscribe, e-mail: For additional commands, e-mail: