You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/01/31 17:54:50 UTC

svn commit: r149272 - in geronimo/trunk/modules/timer: ./ src/java/org/apache/geronimo/timer/jdbc/ src/test/org/apache/geronimo/timer/jdbc/

Author: djencks
Date: Mon Jan 31 08:54:46 2005
New Revision: 149272

URL: http://svn.apache.org/viewcvs?view=rev&rev=149272
Log:
Update timer to work with derby

Added:
    geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/AxionJDBCWorkerPersistenceTest.java
    geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/DerbyJDBCWorkerPersistenceTest.java
    geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTestAbstract.java
      - copied, changed from r149201, geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTest.java
Removed:
    geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTest.java
Modified:
    geronimo/trunk/modules/timer/project.xml
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledTransactionalTimer.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java

Modified: geronimo/trunk/modules/timer/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/project.xml?view=diff&r1=149271&r2=149272
==============================================================================
--- geronimo/trunk/modules/timer/project.xml (original)
+++ geronimo/trunk/modules/timer/project.xml Mon Jan 31 08:54:46 2005
@@ -55,9 +55,9 @@
         </dependency>
 
         <dependency>
-             <groupId>geronimo</groupId>
-             <artifactId>geronimo-j2ee</artifactId>
-             <version>${pom.currentVersion}</version>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-j2ee</artifactId>
+            <version>${pom.currentVersion}</version>
         </dependency>
 
         <dependency>
@@ -66,13 +66,13 @@
             <version>${pom.currentVersion}</version>
         </dependency>
 
-         <dependency>
+        <dependency>
             <groupId>geronimo</groupId>
             <artifactId>geronimo-transaction</artifactId>
             <version>${pom.currentVersion}</version>
         </dependency>
 
-       <dependency>
+        <dependency>
             <groupId>geronimo-spec</groupId>
             <artifactId>geronimo-spec-jta</artifactId>
             <version>${geronimo_spec_jta_version}</version>
@@ -101,6 +101,12 @@
             <url>http://www.extreme.indiana.edu/xgws/xsoap/xpp</url>
             <!-- can we get by with 1.1.3.3_min?-->
             <version>${xpp3_version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>incubator-derby</groupId>
+            <artifactId>derby</artifactId>
+            <version>${derby_version}</version>
         </dependency>
 
         <dependency>

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java?view=diff&r1=149271&r2=149272
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java Mon Jan 31 08:54:46 2005
@@ -17,6 +17,10 @@
 
 package org.apache.geronimo.timer.jdbc;
 
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
 import EDU.oswego.cs.dl.util.concurrent.Executor;
 import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -35,9 +39,9 @@
     public JDBCStoreThreadPooledNonTransactionalTimer(ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper,
                                                       TransactionContextManager transactionContextManager,
                                                       Executor threadPool,
-                                                      Kernel kernel) {
+                                                      Kernel kernel) throws SQLException {
         super(new NontransactionalExecutorTaskFactory(),
-                new JDBCWorkerPersistence(kernel, managedConnectionFactoryWrapper), threadPool, transactionContextManager);
+                new JDBCWorkerPersistence(kernel.getKernelName(), (DataSource)managedConnectionFactoryWrapper.$getResource(), false), threadPool, transactionContextManager);
     }
 
 

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledTransactionalTimer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledTransactionalTimer.java?view=diff&r1=149271&r2=149272
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledTransactionalTimer.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledTransactionalTimer.java Mon Jan 31 08:54:46 2005
@@ -17,6 +17,10 @@
 
 package org.apache.geronimo.timer.jdbc;
 
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
 import EDU.oswego.cs.dl.util.concurrent.Executor;
 import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper;
 import org.apache.geronimo.gbean.GBeanInfo;
@@ -39,9 +43,9 @@
             TransactionContextManager transactionContextManager,
             ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper,
             Executor threadPool,
-            Kernel kernel) {
+            Kernel kernel) throws SQLException {
         super(new TransactionalExecutorTaskFactory(transactionContextManager, repeatCount),
-                new JDBCWorkerPersistence(kernel, managedConnectionFactoryWrapper), threadPool, transactionContextManager);
+                new JDBCWorkerPersistence(kernel.getKernelName(), (DataSource)managedConnectionFactoryWrapper.$getResource(), false), threadPool, transactionContextManager);
     }
 
 

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java?view=diff&r1=149271&r2=149272
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistence.java Mon Jan 31 08:54:46 2005
@@ -22,19 +22,12 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Types;
-import java.util.Date;
-import java.util.Collection;
 import java.util.ArrayList;
-
+import java.util.Collection;
+import java.util.Date;
 import javax.sql.DataSource;
 
 import com.thoughtworks.xstream.XStream;
-import org.apache.geronimo.connector.outbound.ManagedConnectionFactoryWrapper;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
-import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.timer.PersistenceException;
 import org.apache.geronimo.timer.Playback;
 import org.apache.geronimo.timer.WorkInfo;
@@ -44,14 +37,17 @@
  * TODO use an insert returning or stored procedure to insert.
  *
  * @version $Rev$ $Date$
- *
- * */
-public class JDBCWorkerPersistence implements WorkerPersistence, GBeanLifecycle {
+ */
+public class JDBCWorkerPersistence implements WorkerPersistence {
 
     private static final String createSequenceSQL = "create sequence timertasks_seq";
-    private static final String createTableSQL = "create table timertasks (id long primary key, serverid varchar(256) not null, timerkey varchar(256) not null, userid varchar(4096), userinfo varchar(4096), firsttime long not null, period long, atfixedrate boolean not null)";
+    private static final String createTableSQLWithSequence = "create table timertasks (id long primary key, serverid varchar(256) not null, timerkey varchar(256) not null, userid varchar(4096), userinfo varchar(4096), firsttime long not null, period long, atfixedrate boolean not null)";
+    private static final String createTableSQLWithIdentity =
+"create table timertasks (id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), serverid varchar(256) not null, timerkey varchar(256) not null, userid varchar(4096), userinfo varchar(4096), firsttime NUMERIC(18,0) not null, period NUMERIC(18, 0), atfixedrate CHAR(1))";
     private static final String sequenceSQL = "select timertasks_seq.nextval";
-    private static final String insertSQL = "insert into timertasks (id, serverid, timerkey, userid, userinfo, firsttime, period, atfixedrate) values (?, ?, ?, ?, ?, ?, ?, ?)";
+    private static final String identitySQL = "values IDENTITY_VAL_LOCAL()";
+    private static final String insertSQLWithSequence = "insert into timertasks (id, serverid, timerkey, userid, userinfo, firsttime, period, atfixedrate) values (?, ?, ?, ?, ?, ?, ?, ?)";
+    private static final String insertSQLWithIdentity = "insert into timertasks (serverid, timerkey, userid, userinfo, firsttime, period, atfixedrate) values (?, ?, ?, ?, ?, ?, ?)";
     private static final String deleteSQL = "delete from timertasks where id=?";
     private static final String selectSQL = "select id, userid, userinfo, firsttime, period, atfixedrate from timertasks where serverid = ? and timerkey=?";
     private static final String fixedRateUpdateSQL = "update timertasks set firsttime = firsttime + period where id = ?";
@@ -59,24 +55,19 @@
     private static final String selectByKeySQL = "select id from timertasks where serverid = ? and timerkey = ? and (userid = ? or ? is null)";
 
     private final String serverUniqueId;
-    private final ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper;
-    private DataSource dataSource;
+    private final DataSource dataSource;
+    private boolean useSequence = false;
 
-    public JDBCWorkerPersistence(Kernel kernel, ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper) {
-        assert managedConnectionFactoryWrapper != null;
-        //TODO construct a unique name.
-        this.serverUniqueId = kernel.getKernelName();
-        this.managedConnectionFactoryWrapper = managedConnectionFactoryWrapper;
-    }
-
-    protected JDBCWorkerPersistence(String serverUniqueId, DataSource datasource) {
+    protected JDBCWorkerPersistence(String serverUniqueId, DataSource datasource, boolean useSequence) throws SQLException {
         this.serverUniqueId = serverUniqueId;
-        this.managedConnectionFactoryWrapper = null;
         this.dataSource = datasource;
-    }
-
-    public ManagedConnectionFactoryWrapper getManagedConnectionFactoryWrapper() {
-        return managedConnectionFactoryWrapper;
+        this.useSequence = useSequence;
+        if (this.useSequence) {
+            execSQL(createSequenceSQL);
+            execSQL(createTableSQLWithSequence);
+        } else {
+            execSQL(createTableSQLWithIdentity);
+        }
     }
 
 
@@ -84,42 +75,81 @@
         try {
             Connection c = dataSource.getConnection();
             try {
-                long id;
-                PreparedStatement seqStatement = c.prepareStatement(sequenceSQL);
-                try {
-                    ResultSet seqRS = seqStatement.executeQuery();
+                if (useSequence) {
+                    long id;
+                    PreparedStatement seqStatement = c.prepareStatement(sequenceSQL);
                     try {
-                        seqRS.next();
-                        id = seqRS.getLong(1);
+                        ResultSet seqRS = seqStatement.executeQuery();
+                        try {
+                            seqRS.next();
+                            id = seqRS.getLong(1);
+                        } finally {
+                            seqRS.close();
+                        }
                     } finally {
-                        seqRS.close();
+                        seqStatement.close();
                     }
-                } finally {
-                    seqStatement.close();
-                }
-                workInfo.setId(id);
-                PreparedStatement insertStatement = c.prepareStatement(insertSQL);
-                try {
-                    String serializedUserId = serialize(workInfo.getUserId());
-                     String serializedUserKey = serialize(workInfo.getUserInfo());
-                    insertStatement.setLong(1, id);
-                    insertStatement.setString(2, serverUniqueId);
-                    insertStatement.setString(3, workInfo.getKey());
-                    insertStatement.setString(4, serializedUserId);
-                    insertStatement.setString(5, serializedUserKey);
-                      insertStatement.setLong(6, workInfo.getTime().getTime());
-                    if (workInfo.getPeriod() == null) {
-                        insertStatement.setNull(7, Types.NUMERIC);
-                    } else {
-                        insertStatement.setLong(7, workInfo.getPeriod().longValue());
+                    workInfo.setId(id);
+                    PreparedStatement insertStatement = c.prepareStatement(insertSQLWithSequence);
+                    try {
+                        String serializedUserId = serialize(workInfo.getUserId());
+                        String serializedUserKey = serialize(workInfo.getUserInfo());
+                        insertStatement.setLong(1, id);
+                        insertStatement.setString(2, serverUniqueId);
+                        insertStatement.setString(3, workInfo.getKey());
+                        insertStatement.setString(4, serializedUserId);
+                        insertStatement.setString(5, serializedUserKey);
+                        insertStatement.setLong(6, workInfo.getTime().getTime());
+                        if (workInfo.getPeriod() == null) {
+                            insertStatement.setNull(7, Types.NUMERIC);
+                        } else {
+                            insertStatement.setLong(7, workInfo.getPeriod().longValue());
+                        }
+                        insertStatement.setBoolean(8, workInfo.getAtFixedRate());
+                        int result = insertStatement.executeUpdate();
+                        if (result != 1) {
+                            throw new PersistenceException("Could not insert!");
+                        }
+                    } finally {
+                        insertStatement.close();
                     }
-                    insertStatement.setBoolean(8, workInfo.getAtFixedRate());
-                    int result = insertStatement.executeUpdate();
-                    if (result != 1) {
-                        throw new PersistenceException("Could not insert!");
+                } else {
+                    PreparedStatement insertStatement = c.prepareStatement(insertSQLWithIdentity);
+                    try {
+                        String serializedUserId = serialize(workInfo.getUserId());
+                        String serializedUserKey = serialize(workInfo.getUserInfo());
+                        insertStatement.setString(1, serverUniqueId);
+                        insertStatement.setString(2, workInfo.getKey());
+                        insertStatement.setString(3, serializedUserId);
+                        insertStatement.setString(4, serializedUserKey);
+                        insertStatement.setLong(5, workInfo.getTime().getTime());
+                        if (workInfo.getPeriod() == null) {
+                            insertStatement.setNull(6, Types.NUMERIC);
+                        } else {
+                            insertStatement.setLong(6, workInfo.getPeriod().longValue());
+                        }
+                        insertStatement.setBoolean(7, workInfo.getAtFixedRate());
+                        int result = insertStatement.executeUpdate();
+                        if (result != 1) {
+                            throw new PersistenceException("Could not insert!");
+                        }
+                    } finally {
+                        insertStatement.close();
                     }
-                } finally {
-                    insertStatement.close();
+                    long id;
+                    PreparedStatement identityStatement = c.prepareStatement(identitySQL);
+                    try {
+                        ResultSet seqRS = identityStatement.executeQuery();
+                        try {
+                            seqRS.next();
+                            id = seqRS.getLong(1);
+                        } finally {
+                            seqRS.close();
+                        }
+                    } finally {
+                        identityStatement.close();
+                    }
+                    workInfo.setId(id);
                 }
             } finally {
                 c.close();
@@ -280,26 +310,6 @@
         return xStream.fromXML(serializedRunnable);
     }
 
-    public void doStart() throws WaitingException, Exception {
-        if (managedConnectionFactoryWrapper != null) {
-            dataSource = (DataSource) managedConnectionFactoryWrapper.$getResource();
-        }
-        if (createSequenceSQL != null && !createSequenceSQL.equals("")) {
-            execSQL(createSequenceSQL);
-        }
-        if (createTableSQL != null && !createTableSQL.equals("")) {
-            execSQL(createTableSQL);
-        }
-    }
-
-    public void doStop() throws WaitingException, Exception {
-        dataSource = null;
-    }
-
-    public void doFail() {
-        dataSource = null;
-    }
-
     private void execSQL(String sql) throws SQLException {
         Connection c = dataSource.getConnection();
         try {
@@ -314,33 +324,6 @@
         } finally {
             c.close();
         }
-    }
-
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(JDBCWorkerPersistence.class);
-//        infoFactory.addAttribute("sequenceSQL", String.class, true);
-//        infoFactory.addAttribute("insertSQL", String.class, true);
-//        infoFactory.addAttribute("deleteSQL", String.class, true);
-//        infoFactory.addAttribute("fixedRateUpdateSQL", String.class, true);
-//        infoFactory.addAttribute("selectSQL", String.class, true);
-
-        infoFactory.addAttribute("createSequenceSQL", String.class, true);
-        infoFactory.addAttribute("createTableSQL", String.class, true);
-
-        infoFactory.addAttribute("kernel", Kernel.class, false);
-
-        infoFactory.addReference("managedConnectionFactoryWrapper", ManagedConnectionFactoryWrapper.class);
-
-//        infoFactory.setConstructor(new String[]{"kernel", "managedConnectionFactoryWrapper", "sequenceSQL", "insertSQL", "deleteSQL", "fixedRateUpdateSQL", "selectSQL"});
-        infoFactory.setConstructor(new String[]{"kernel", "managedConnectionFactoryWrapper"});
-
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
     }
 
 }

Added: geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/AxionJDBCWorkerPersistenceTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/AxionJDBCWorkerPersistenceTest.java?view=auto&rev=149272
==============================================================================
--- geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/AxionJDBCWorkerPersistenceTest.java (added)
+++ geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/AxionJDBCWorkerPersistenceTest.java Mon Jan 31 08:54:46 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ * 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.timer.jdbc;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import org.axiondb.jdbc.AxionDataSource;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public class AxionJDBCWorkerPersistenceTest extends JDBCWorkerPersistenceTestAbstract {
+
+    protected void setUp() throws Exception {
+        useSequence = true;
+        datasource = new AxionDataSource("jdbc:axiondb:testdb");
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        Connection c = datasource.getConnection();
+        Statement s = c.createStatement();
+        s.execute("SHUTDOWN");
+        s.close();
+        c.close();
+    }
+
+}

Added: geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/DerbyJDBCWorkerPersistenceTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/DerbyJDBCWorkerPersistenceTest.java?view=auto&rev=149272
==============================================================================
--- geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/DerbyJDBCWorkerPersistenceTest.java (added)
+++ geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/DerbyJDBCWorkerPersistenceTest.java Mon Jan 31 08:54:46 2005
@@ -0,0 +1,110 @@
+/**
+ *
+ * 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.timer.jdbc;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+import java.sql.SQLException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+import org.apache.derby.jdbc.EmbeddedDataSource;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public class DerbyJDBCWorkerPersistenceTest extends JDBCWorkerPersistenceTestAbstract {
+    private static final String SYSTEM_HOME = "derby.system.home";
+    private static final String SHUTDOWN_ALL = "jdbc:derby:;shutdown=true";
+
+    private File systemDir;
+
+
+    private void connect() throws SQLException {
+        Connection c = DriverManager.getConnection("jdbc:derby:testdb;create=true");
+        c.close();
+    }
+
+    protected void setUp() throws Exception {
+        useSequence = false;
+        try {
+            systemDir = File.createTempFile("derbyTest", ".tmp");
+            systemDir.delete();
+            systemDir.mkdirs();
+        } catch (Exception e) {
+            delete(systemDir);
+            throw e;
+        }
+        String derbyDir = "var/dbderby";
+        File derby = new File(systemDir, derbyDir);
+        System.setProperty(SYSTEM_HOME, derby.getAbsolutePath());
+
+        // set the magic system property that causes derby to use explicity
+        // file sync instead of relying on vm support for file open rws
+        System.setProperty("derby.storage.fileSyncTransactionLog", "true");
+
+        // load the Embedded driver to initialize the home
+        new org.apache.derby.jdbc.EmbeddedDriver();
+
+        EmbeddedDataSource datasource = new EmbeddedDataSource();
+        datasource.setDatabaseName("SystemDatabase");
+        datasource.setCreateDatabase("create");
+        try {
+            Connection c = datasource.getConnection();
+            c.close();
+        } catch (SQLException e) {
+            while (e.getNextException() != null) {
+                e.printStackTrace();
+                e = e.getNextException();
+            }
+            throw e;
+        }
+        this.datasource = datasource;
+//        assertTrue(new File(systemDir, derbyDir + "/derby.log").exists());
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+//        ((EmbeddedDataSource)datasource).setShutdownDatabase("shutdown");
+        try {
+            DriverManager.getConnection(SHUTDOWN_ALL, null, null);
+        } catch (SQLException e) {
+            //ignore.. expected??
+        }
+//        Connection c = datasource.getConnection();
+//        c.close();
+        delete(systemDir);
+        super.tearDown();
+//        Thread.sleep(5000);
+    }
+
+    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();
+    }
+
+}

Copied: geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTestAbstract.java (from r149201, geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTest.java)
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTestAbstract.java?view=diff&rev=149272&p1=geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTest.java&r1=149201&p2=geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTestAbstract.java&r2=149272
==============================================================================
--- geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTest.java (original)
+++ geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/jdbc/JDBCWorkerPersistenceTestAbstract.java Mon Jan 31 08:54:46 2005
@@ -21,15 +21,13 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.Statement;
-import java.util.Date;
 import java.util.Collection;
-
+import java.util.Date;
 import javax.sql.DataSource;
 
 import junit.framework.TestCase;
 import org.apache.geronimo.timer.Playback;
 import org.apache.geronimo.timer.WorkInfo;
-import org.apache.geronimo.timer.jdbc.JDBCWorkerPersistence;
 import org.axiondb.jdbc.AxionDataSource;
 
 /**
@@ -38,7 +36,7 @@
  * @version $Rev$ $Date$
  *
  * */
-public class JDBCWorkerPersistenceTest extends TestCase {
+public class JDBCWorkerPersistenceTestAbstract extends TestCase {
 
 
     private final String countSQL = "select count(*) from timertasks";
@@ -49,7 +47,8 @@
     private Object userId = null;
 
     private JDBCWorkerPersistence jdbcWorkerPersistence;
-    private DataSource datasource;
+    protected DataSource datasource;
+    protected boolean useSequence;
 
 
     private WorkInfo workInfo;
@@ -57,22 +56,12 @@
     protected Long period;
 
     protected void setUp() throws Exception {
-        datasource = new AxionDataSource("jdbc:axiondb:testdb");
-        jdbcWorkerPersistence = new JDBCWorkerPersistence(serverUniqueId, datasource);
-        jdbcWorkerPersistence.doStart();
+        jdbcWorkerPersistence = new JDBCWorkerPersistence(serverUniqueId, datasource, useSequence);
         time = new Date(System.currentTimeMillis());
         period = new Long(1000);
         workInfo = new WorkInfo(key, userId, userInfo, time, period, true);
     }
 
-    protected void tearDown() throws Exception {
-        jdbcWorkerPersistence.doStop();
-        Connection c = datasource.getConnection();
-        Statement s = c.createStatement();
-        s.execute("SHUTDOWN");
-        s.close();
-        c.close();
-    }
 
     public void testSaveCancel() throws Exception {
         assertEquals(0, countRows());