Author: dain Date: Mon Oct 4 15:51:28 2004 New Revision: 53760 Modified: geronimo/trunk/modules/derby/project.xml geronimo/trunk/modules/derby/src/test/org/apache/geronimo/derby/DerbySystemGBeanTest.java Log: Fixed line endings Assure that all temp files are deleted
Modified: geronimo/trunk/modules/derby/project.xml ============================================================================== --- geronimo/trunk/modules/derby/project.xml (original) +++ geronimo/trunk/modules/derby/project.xml Mon Oct 4 15:51:28 2004 @@ -1,95 +1,95 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!-- - - Copyright 2004 The Apache Software Foundation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<!DOCTYPE project [ -<!ENTITY % locator SYSTEM "file:locator.ent"> -%locator; -%versions; -]> - -<!-- $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ --> - -<project> - <pomVersion>3</pomVersion> - <extend>${basedir}/../../etc/project.xml</extend> - - <!-- ===================== --> - <!-- Module Identification --> - <!-- ===================== --> - - <name>Geronimo :: Derby</name> - <id>geronimo-derby</id> - <shortDescription>Integration with Embedded Derby</shortDescription> - <description>Wrapper for using Apache Derby as a bundled database.</description> - <url>http://geronimo.apache.org/modules/derby/</url> - <siteDirectory>/www/geronimo.apache.org/modules/derby</siteDirectory> - <distributionDirectory>/www/incubator.apache.org/projects/geronimo/builds/derby</distributionDirectory> - - <package>org.apache.geronimo.derby</package> - - <!-- ============ --> - <!-- Dependencies --> - <!-- ============ --> - - <dependencies> - <dependency> - <groupId>geronimo</groupId> - <artifactId>geronimo-kernel</artifactId> - <version>${pom.currentVersion}</version> - </dependency> - <dependency> - <groupId>geronimo</groupId> - <artifactId>geronimo-system</artifactId> - <version>${pom.currentVersion}</version> - </dependency> - - <dependency> - <groupId>derby</groupId> - <artifactId>derby</artifactId> - <version>&derby-version;</version> - </dependency> - <dependency> - <groupId>derby</groupId> - <artifactId>derbynet</artifactId> - <version>&derby-version;</version> - </dependency> - - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>&commons-logging-version;</version> - <url>http://jakarta.apache.org/commons/logging/</url> - </dependency> - </dependencies> - - - <!-- =================== --> - <!-- Build Specification --> - <!-- =================== --> - - <build> - <unitTest> - <includes> - <include>**/*Test.java</include> - </includes> - <excludes> - <exclude>**/Abstract*.java</exclude> - </excludes> - </unitTest> - </build> -</project> +<?xml version="1.0" encoding="ISO-8859-1"?> +<!-- + + Copyright 2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!DOCTYPE project [ +<!ENTITY % locator SYSTEM "file:locator.ent"> +%locator; +%versions; +]> + +<!-- $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ --> + +<project> + <pomVersion>3</pomVersion> + <extend>${basedir}/../../etc/project.xml</extend> + + <!-- ===================== --> + <!-- Module Identification --> + <!-- ===================== --> + + <name>Geronimo :: Derby</name> + <id>geronimo-derby</id> + <shortDescription>Integration with Embedded Derby</shortDescription> + <description>Wrapper for using Apache Derby as a bundled database.</description> + <url>http://geronimo.apache.org/modules/derby/</url> + <siteDirectory>/www/geronimo.apache.org/modules/derby</siteDirectory> + <distributionDirectory>/www/incubator.apache.org/projects/geronimo/builds/derby</distributionDirectory> + + <package>org.apache.geronimo.derby</package> + + <!-- ============ --> + <!-- Dependencies --> + <!-- ============ --> + + <dependencies> + <dependency> + <groupId>geronimo</groupId> + <artifactId>geronimo-kernel</artifactId> + <version>${pom.currentVersion}</version> + </dependency> + <dependency> + <groupId>geronimo</groupId> + <artifactId>geronimo-system</artifactId> + <version>${pom.currentVersion}</version> + </dependency> + + <dependency> + <groupId>derby</groupId> + <artifactId>derby</artifactId> + <version>&derby-version;</version> + </dependency> + <dependency> + <groupId>derby</groupId> + <artifactId>derbynet</artifactId> + <version>&derby-version;</version> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>&commons-logging-version;</version> + <url>http://jakarta.apache.org/commons/logging/</url> + </dependency> + </dependencies> + + + <!-- =================== --> + <!-- Build Specification --> + <!-- =================== --> + + <build> + <unitTest> + <includes> + <include>**/*Test.java</include> + </includes> + <excludes> + <exclude>**/Abstract*.java</exclude> + </excludes> + </unitTest> + </build> +</project> Modified: geronimo/trunk/modules/derby/src/test/org/apache/geronimo/derby/DerbySystemGBeanTest.java ============================================================================== --- geronimo/trunk/modules/derby/src/test/org/apache/geronimo/derby/DerbySystemGBeanTest.java (original) +++ geronimo/trunk/modules/derby/src/test/org/apache/geronimo/derby/DerbySystemGBeanTest.java Mon Oct 4 15:51:28 2004 @@ -1,80 +1,89 @@ -/** - * - * Copyright 2003-2004 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.geronimo.derby; - -import java.io.File; -import java.io.IOException; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.util.Properties; - -import junit.framework.TestCase; -import org.apache.geronimo.system.serverinfo.ServerInfo; - -/** - * @version $Rev: 47413 $ $Date: 2004-09-28 11:46:39 -0700 (Tue, 28 Sep 2004) $ - */ -public class DerbySystemGBeanTest extends TestCase { - private File systemDir; - - public void testCreateSystemUsingServerInfo() throws Exception { - ServerInfo serverInfo = new ServerInfo(systemDir.toString()); - String derbyDir = "var/dbderby"; - DerbySystemGBean gbean = new DerbySystemGBean(serverInfo, derbyDir); - try { - gbean.doStart(); - new org.apache.derby.jdbc.EmbeddedDriver(); - connect(); - gbean.doStop(); - assertTrue(new File(systemDir, derbyDir+"/derby.log").exists()); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - private void connect() throws SQLException { - Connection c = DriverManager.getConnection("jdbc:derby:testdb;create=true"); - c.close(); - } - - protected void setUp() throws Exception { - super.setUp(); - systemDir = File.createTempFile("derbyTest", ".tmp"); - systemDir.delete(); - systemDir.mkdir(); - - Properties props = System.getProperties(); - props.remove("derby.system.home"); - } - - protected void tearDown() throws Exception { - delete(systemDir); - super.tearDown(); - } - - private void delete(File file) throws IOException { - File[] files = file.listFiles(); - if (files != null) { - for (int i = 0; i < files.length; i++) { - delete(files[i]); - } - } - file.delete(); - } -} +/** + * + * Copyright 2003-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.derby; + +import java.io.File; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +import junit.framework.TestCase; +import org.apache.geronimo.system.serverinfo.ServerInfo; + +/** + * @version $Rev: 47413 $ $Date: 2004-09-28 11:46:39 -0700 (Tue, 28 Sep 2004) $ + */ +public class DerbySystemGBeanTest extends TestCase { + private File systemDir; + + public void testCreateSystemUsingServerInfo() throws Exception { + ServerInfo serverInfo = new ServerInfo(systemDir.toString()); + String derbyDir = "var/dbderby"; + DerbySystemGBean gbean = new DerbySystemGBean(serverInfo, derbyDir); + try { + gbean.doStart(); + new org.apache.derby.jdbc.EmbeddedDriver(); + connect(); + gbean.doStop(); + assertTrue(new File(systemDir, derbyDir+"/derby.log").exists()); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + private void connect() throws SQLException { + Connection c = DriverManager.getConnection("jdbc:derby:testdb;create=true"); + c.close(); + } + + protected void setUp() throws Exception { + try { + super.setUp(); + systemDir = File.createTempFile("derbyTest", ".tmp"); + systemDir.delete(); + systemDir.mkdir(); + + Properties props = System.getProperties(); + props.remove("derby.system.home"); + } catch (Exception e) { + delete(systemDir); + throw e; + } + } + + protected void tearDown() throws Exception { + delete(systemDir); + super.tearDown(); + } + + private void delete(File file) throws IOException { + if (file == null) { + return; + } + + File[] files = file.listFiles(); + if (files != null) { + for (int i = 0; i < files.length; i++) { + delete(files[i]); + } + } + file.delete(); + } +}