incubator-agila-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r219030 - in /incubator/agila/trunk/modules/bpm: ./ src/test-resources/ src/test/org/apache/agila/impl/dao/ src/test/org/apache/agila/util/
Date Thu, 14 Jul 2005 11:41:24 GMT
Author: clim
Date: Thu Jul 14 04:41:23 2005
New Revision: 219030

URL: http://svn.apache.org/viewcvs?rev=219030&view=rev
Log:
Fix for Agila-16 (Use HSQLDB when running the test cases)

Added:
    incubator/agila/trunk/modules/bpm/src/test-resources/jdbc.properties
    incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/DBHelper.java
Modified:
    incubator/agila/trunk/modules/bpm/project.properties
    incubator/agila/trunk/modules/bpm/project.xml
    incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/impl/dao/DAOTestCaseSupport.java
    incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/JDBCTestCase.java

Modified: incubator/agila/trunk/modules/bpm/project.properties
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpm/project.properties?rev=219030&r1=219029&r2=219030&view=diff
==============================================================================
--- incubator/agila/trunk/modules/bpm/project.properties (original)
+++ incubator/agila/trunk/modules/bpm/project.properties Thu Jul 14 04:41:23 2005
@@ -6,3 +6,6 @@
 
 maven.junit.jvmargs=-ea
 
+maven.repo.remote=\
+http://people.apache.org/~clim/maven,\
+http://www.ibiblio.org/maven

Modified: incubator/agila/trunk/modules/bpm/project.xml
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpm/project.xml?rev=219030&r1=219029&r2=219030&view=diff
==============================================================================
--- incubator/agila/trunk/modules/bpm/project.xml (original)
+++ incubator/agila/trunk/modules/bpm/project.xml Thu Jul 14 04:41:23 2005
@@ -136,6 +136,14 @@
                <war.bundle>true</war.bundle>
            </properties>
       </dependency>
+
+       <!-- Used for testing -->
+       <dependency>
+           <groupId>hsqldb</groupId>
+           <artifactId>hsqldb</artifactId>
+           <version>1.8.0.1</version>
+       </dependency>
+
   </dependencies>
 
   <build>
@@ -175,8 +183,9 @@
             </includes>
             <resources>
                 <resource>
-                    <directory>${pom.build.unitTestSourceDirectory}</directory>
+                    <directory>${basedir}/src/test-resources</directory>
                     <includes>
+                        <include>**/*.properties</include>
                         <include>**/*.xml</include>
                     </includes>
                 </resource>

Added: incubator/agila/trunk/modules/bpm/src/test-resources/jdbc.properties
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpm/src/test-resources/jdbc.properties?rev=219030&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpm/src/test-resources/jdbc.properties (added)
+++ incubator/agila/trunk/modules/bpm/src/test-resources/jdbc.properties Thu Jul 14 04:41:23
2005
@@ -0,0 +1,6 @@
+### JDBC Properties ###
+
+jdbc.driver=org.hsqldb.jdbcDriver
+jdbc.url=jdbc:hsqldb:mem:agila
+jdbc.username=sa
+jdbc.password=

Modified: incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/impl/dao/DAOTestCaseSupport.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/impl/dao/DAOTestCaseSupport.java?rev=219030&r1=219029&r2=219030&view=diff
==============================================================================
--- incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/impl/dao/DAOTestCaseSupport.java
(original)
+++ incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/impl/dao/DAOTestCaseSupport.java
Thu Jul 14 04:41:23 2005
@@ -16,14 +16,12 @@
 
 package org.apache.agila.impl.dao;
 
-import org.apache.agila.util.JDBCUtil;
-import org.apache.agila.util.XMLUtil;
+import junit.framework.TestCase;
 import org.apache.agila.engine.Instance;
 import org.apache.agila.engine.InstanceID;
 import org.apache.agila.engine.Token;
 import org.apache.agila.engine.TokenID;
 import org.apache.agila.impl.TokenImpl;
-import org.apache.agila.impl.dao.AgilaDAO;
 import org.apache.agila.model.BusinessProcess;
 import org.apache.agila.model.BusinessProcessID;
 import org.apache.agila.model.NodeID;
@@ -34,17 +32,14 @@
 import org.apache.agila.services.user.GroupID;
 import org.apache.agila.services.user.UserID;
 import org.apache.agila.services.user.UserInfo;
-import org.apache.agila.services.user.GroupID;
-
-import junit.framework.TestCase;
+import org.apache.agila.util.JDBCUtil;
+import org.apache.agila.util.XMLUtil;
 
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
-
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
-
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -227,9 +222,22 @@
     }
 
     public void testGetTasksForUser() {
+
+        TaskImpl task = new TaskImpl();
+
+        task.setUserID( new UserID( 1 ) );
+        task.setTaskDescription( "Task Description" );
+        task.setTaskExpirationDate( new Date() );
+        task.setSourceTokenID( new TokenID( 1 ) );
+        task.setTaskStatus( Task.TASK_INCOMPLETE );
+        task.setInstanceID( new InstanceID( 1 ) );
+
+        TaskID taskID = dao.insertTask( task );
+
         List tasks = dao.getTasksForUser( new UserID( 1 ), Task.TASK_INCOMPLETE );
         assertNotNull( "Tasks should not be null", tasks );
         assertTrue( tasks.size() > 0 );
+
     }
 
     public void testGetTasksForTeams() {

Added: incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/DBHelper.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/DBHelper.java?rev=219030&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/DBHelper.java (added)
+++ incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/DBHelper.java Thu Jul
14 04:41:23 2005
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+package org.apache.agila.util;
+
+public final class DBHelper {
+
+    public static String businessProcess = "CREATE TABLE bpm_businessprocess (" +
+        " businessprocessid numeric(11) DEFAULT '0'," +
+        " name varchar(255) DEFAULT '' NOT NULL," +
+        " xml varchar(4096)," +
+        " PRIMARY KEY (businessprocessid) )";
+
+    public static String instance = "CREATE TABLE bpm_instance (" +
+        " instanceid numeric(11) DEFAULT '0' NOT NULL," +
+        " processid numeric(11) DEFAULT '0' NOT NULL," +
+        " graphname varchar(255)," +
+        " params binary," +
+        " status numeric(11)," +
+        " startdate datetime," +
+        " stepdate datetime," +
+        " PRIMARY KEY (instanceid) )";
+
+    public static String task = "CREATE TABLE bpm_task (" +
+        " id numeric(11) DEFAULT'0' NOT NULL," +
+        " userid numeric(11)," +
+        " groupid numeric(11)," +
+        " description varchar(255)," +
+        " expiration datetime," +
+        " tokenid numeric(11) DEFAULT'0' NOT NULL," +
+        " status numeric(11) DEFAULT '0' NOT NULL," +
+        " instanceid numeric(11) DEFAULT '0' NOT NULL," +
+        " PRIMARY KEY (id) )";
+
+    public static String token = "CREATE TABLE bpm_token (" +
+        " tokenid numeric(11) DEFAULT '0' NOT NULL," +
+        " instanceid numeric(11) DEFAULT '0' NOT NULL," +
+        " nodeid numeric(11) DEFAULT '0' NOT NULL," +
+        " state numeric(11) DEFAULT '0' NOT NULL," +
+        " active tinyint," +
+        " PRIMARY KEY (tokenid) )";
+
+    public static String uniqueKey = "CREATE TABLE bpm_unique_key (" +
+        " next_hi integer IDENTITY," +
+        " tstamp timestamp NOT NULL)";
+
+    public static String userInfo = "CREATE TABLE bpm_userinfo (" +
+        " userid numeric(11) DEFAULT '0' NOT NULL," +
+        " name varchar(255) DEFAULT '' NOT NULL," +
+        " password varchar(255) DEFAULT '' NOT NULL," +
+        " principal varchar(255) DEFAULT '' NOT NULL," +
+        " isadmin tinyint," +
+        " PRIMARY KEY (userid) )";
+}

Modified: incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/JDBCTestCase.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/JDBCTestCase.java?rev=219030&r1=219029&r2=219030&view=diff
==============================================================================
--- incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/JDBCTestCase.java (original)
+++ incubator/agila/trunk/modules/bpm/src/test/org/apache/agila/util/JDBCTestCase.java Thu
Jul 14 04:41:23 2005
@@ -16,39 +16,11 @@
 
 package org.apache.agila.util;
 
-import org.apache.agila.util.JDBCUtil;
-import org.apache.agila.util.XMLUtil;
-import org.apache.agila.engine.Instance;
-import org.apache.agila.engine.InstanceID;
-import org.apache.agila.engine.Token;
-import org.apache.agila.engine.TokenID;
-import org.apache.agila.impl.TokenImpl;
-import org.apache.agila.impl.dao.AgilaDAO;
 import org.apache.agila.impl.dao.DAOTestCaseSupport;
-import org.apache.agila.model.BusinessProcess;
-import org.apache.agila.model.BusinessProcessID;
-import org.apache.agila.model.NodeID;
-import org.apache.agila.services.InstanceServiceInfo;
-import org.apache.agila.services.task.Task;
-import org.apache.agila.services.task.TaskID;
-import org.apache.agila.services.task.TaskImpl;
-import org.apache.agila.services.user.UserID;
-import org.apache.agila.services.user.UserInfo;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
 
 import java.sql.Connection;
-import java.sql.SQLException;
 import java.sql.Statement;
 
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 public class JDBCTestCase extends DAOTestCaseSupport {
 
     public void testGetInstance() {
@@ -73,5 +45,25 @@
 
     public void setUp() throws Exception {
         dao = JDBCUtil.getInstance();
+
+        Connection connection = ((JDBCUtil)dao).getConnection();
+        Statement statement = connection.createStatement();
+
+        statement.addBatch( DBHelper.businessProcess );
+        statement.addBatch( DBHelper.instance );
+        statement.addBatch( DBHelper.task );
+        statement.addBatch( DBHelper.token );
+        statement.addBatch( DBHelper.uniqueKey );
+        statement.addBatch( DBHelper.userInfo );
+
+        statement.executeBatch();
+    }
+
+    public void tearDown() throws Exception {
+
+        Connection connection = ((JDBCUtil)dao).getConnection();
+        connection.createStatement().execute( "SHUTDOWN" );
+
+        super.tearDown();
     }
 }



Mime
View raw message