Author: boisvert
Date: Sun Sep 17 09:17:36 2006
New Revision: 447087

URL: http://svn.apache.org/viewvc?view=rev&rev=447087
Log:
Update test cases to compile, and minor refactor to share test setup

Added:
    
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java
Modified:
    
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java
    
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java
    
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/ql/InstanceSelectionTest.java

Added: 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java?view=auto&rev=447087
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java
 (added)
+++ 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/BaseDAOTest.java
 Sun Sep 17 09:17:36 2006
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ode.daohib.bpel;
+
+import java.io.FileInputStream;
+import java.util.Properties;
+
+import javax.sql.DataSource;
+
+import junit.framework.TestCase;
+
+import org.apache.ode.bpel.dao.BpelDAOConnection;
+import org.apache.ode.daohib.SessionManager;
+import org.objectweb.jotm.Jotm;
+
+/**
+ * Testing BpelDAOConnectionImpl.listInstance. We're just producing a lot
+ * of different filter combinations and test if they execute ok. To really
+ * test that the result is the one expected would take a huge test database
+ * (with at least a process and an instance for every possible combination).
+ */
+public class BaseDAOTest extends TestCase {
+
+  protected BpelDAOConnection daoConn;
+  private Jotm jotm;
+  private DataSource ds;
+  
+  protected void initTM() throws Exception {
+    Properties hibProps = new Properties();
+    hibProps.load(new 
FileInputStream("../dao-hibernate/src/hibernate/derby.properties"));
+
+    jotm = new Jotm(true, false);
+    ds = getDataSource();
+    SessionManager sessMgr = new SessionManager(hibProps, ds, 
jotm.getTransactionManager());
+    jotm.getTransactionManager().begin();
+
+    BpelDAOConnectionFactoryImpl factoryImpl = new 
BpelDAOConnectionFactoryImpl(sessMgr);
+    daoConn = factoryImpl.getConnection();
+  }
+
+  protected void stopTM() throws Exception {
+    jotm.getTransactionManager().commit();
+  }
+
+  private DataSource getDataSource() {
+    throw new Error("Not implemented");
+  }
+
+}
\ No newline at end of file

Modified: 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java?view=diff&rev=447087&r1=447086&r2=447087
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java
 (original)
+++ 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListInstanceTest.java
 Sun Sep 17 09:17:36 2006
@@ -19,15 +19,12 @@
 
 package org.apache.ode.daohib.bpel;
 
-import org.apache.ode.bpel.common.InstanceFilter;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.daohib.SessionManager;
-import org.apache.ode.daohib.sfwk.DAOConnectionFactoryImpl;
-import junit.framework.TestCase;
-import org.objectweb.jotm.Jotm;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
-import java.io.FileInputStream;
-import java.util.*;
+import org.apache.ode.bpel.common.InstanceFilter;
 
 /**
  * Testing BpelDAOConnectionImpl.listInstance. We're just producing a lot
@@ -35,33 +32,18 @@
  * test that the result is the one expected would take a huge test database
  * (with at least a process and an instance for every possible combination).
  */
-public class ListInstanceTest extends TestCase {
+public class ListInstanceTest extends BaseDAOTest {
 
   private Map<String, List> filterElmts;
   private ArrayList<String> order;
 
-  private BpelDAOConnection daoConn;
-  private Jotm jotm;
-
   protected void setUp() throws Exception {
-    Properties hibProps = new Properties();
-    hibProps.load(new 
FileInputStream("../dao-hibernate/src/hibernate/derby.properties"));
-
-    jotm = new Jotm(true, false);
-
-    SessionManager sessMgr = new SessionManager(hibProps, 
jotm.getTransactionManager());
-    new DAOConnectionFactoryImpl(sessMgr);
-
-    jotm.getTransactionManager().begin();
-
-    BpelDAOConnectionFactoryImpl factoryImpl = new 
BpelDAOConnectionFactoryImpl(sessMgr);
-    daoConn = factoryImpl.createConnection();
-
+    initTM();
     buildFilterElements();
   }
 
   protected void tearDown() throws Exception {
-    jotm.getTransactionManager().commit();
+    stopTM();
   }
 
   public void testListInstance() throws Exception {

Modified: 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java?view=diff&rev=447087&r1=447086&r2=447087
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java
 (original)
+++ 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/bpel/ListProcessTest.java
 Sun Sep 17 09:17:36 2006
@@ -18,15 +18,12 @@
  */
 package org.apache.ode.daohib.bpel;
 
-import org.apache.ode.bpel.common.ProcessFilter;
-import org.apache.ode.bpel.dao.BpelDAOConnection;
-import org.apache.ode.daohib.SessionManager;
-import org.apache.ode.daohib.sfwk.DAOConnectionFactoryImpl;
-import junit.framework.TestCase;
-import org.objectweb.jotm.Jotm;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
-import java.io.FileInputStream;
-import java.util.*;
+import org.apache.ode.bpel.common.ProcessFilter;
 
 /**
  * Testing BpelDAOConnectionImpl.listAllProcesses. We're just producing a lot
@@ -34,33 +31,18 @@
  * test that the result is the one expected would take a huge test database
  * (with at least a process and an instance for every possible combination).
  */
-public class ListProcessTest extends TestCase {
+public class ListProcessTest extends BaseDAOTest {
 
   private Map<String, List> filterElmts;
   private ArrayList<String> order;
 
-  private BpelDAOConnection daoConn;
-  private Jotm jotm;
-
   protected void setUp() throws Exception {
-    Properties hibProps = new Properties();
-    hibProps.load(new 
FileInputStream("../dao-hibernate/src/hibernate/derby.properties"));
-
-    jotm = new Jotm(true, false);
-
-    SessionManager sessMgr = new SessionManager(hibProps, 
jotm.getTransactionManager());
-    new DAOConnectionFactoryImpl(sessMgr);
-
-    jotm.getTransactionManager().begin();
-
-    BpelDAOConnectionFactoryImpl factoryImpl = new 
BpelDAOConnectionFactoryImpl(sessMgr);
-    daoConn = factoryImpl.createConnection();
-
+    initTM();
     buildFilterElements();
   }
 
   protected void tearDown() throws Exception {
-    jotm.getTransactionManager().commit();
+    stopTM();
   }
 
   public void testListProcess() throws Exception {

Modified: 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/ql/InstanceSelectionTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/ql/InstanceSelectionTest.java?view=diff&rev=447087&r1=447086&r2=447087
==============================================================================
--- 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/ql/InstanceSelectionTest.java
 (original)
+++ 
incubator/ode/trunk/dao-hibernate/src/test/java/org/apache/ode/daohib/ql/InstanceSelectionTest.java
 Sun Sep 17 09:17:36 2006
@@ -19,20 +19,11 @@
 
 package org.apache.ode.daohib.ql;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.Collection;
 import java.util.List;
-import java.util.Properties;
-
-import org.hibernate.Session;
-import org.objectweb.jotm.Jotm;
-import org.springframework.beans.factory.xml.XmlBeanFactory;
-import org.springframework.core.io.FileSystemResource;
-import org.springframework.core.io.Resource;
 
 import org.apache.ode.daohib.SessionManager;
+import org.apache.ode.daohib.bpel.BaseDAOTest;
 import org.apache.ode.daohib.bpel.hobj.HProcess;
 import org.apache.ode.daohib.bpel.hobj.HProcessInstance;
 import org.apache.ode.daohib.ql.instances.HibernateInstancesQueryCompiler;
@@ -40,8 +31,12 @@
 import org.apache.ode.ql.tree.Builder;
 import org.apache.ode.ql.tree.BuilderFactory;
 import org.apache.ode.ql.tree.nodes.Query;
+import org.hibernate.Session;
+import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.core.io.FileSystemResource;
+import org.springframework.core.io.Resource;
 
-public class InstanceSelectionTest extends junit.framework.TestCase {
+public class InstanceSelectionTest extends BaseDAOTest {
   public static class TestCases {
     private Collection<TestCase> testCases;
 
@@ -116,29 +111,11 @@
     
   }
   private static final String BEANS_LOCATION = "test/config/test-beans.xml";
-  private static final String HIBERNATE_PROPERTIES = "hibernate.properties";
-  //
-  private Jotm jotm;
+
   private SessionManager sessionManager;
-  //private BpelDAOConnectionFactory bpelConnFactory;
   private Session session;
   private TestCases testCases;
   
-  private Properties readDBProperties() throws IOException {
-    Properties props = new Properties();
-    
-    new File("tmp").delete();
-    
-    props.put("hibernate.connection.url", 
"jdbc:derby:tmp/dao-hibernate-test;create=true;");
-    
-    InputStream is = 
InstanceSelectionTest.class.getClassLoader().getResourceAsStream(HIBERNATE_PROPERTIES);
-    try {
-      props.load(is);
-    } finally {
-      is.close();
-    }
-    return props;
-  }
   /**
    * @see junit.framework.TestCase#setUp()
    */
@@ -146,16 +123,8 @@
   protected void setUp() throws Exception {
     super.setUp();
     
-    jotm = new Jotm(true, false);
+    initTM();
     
-    sessionManager = new SessionManager(readDBProperties(), 
jotm.getTransactionManager());
-    /*
-    bpelConnFactory = new BpelDAOConnectionFactoryImpl(sessionManager);
-    
-    BpelDAOConnection bpelConn = bpelConnFactory.createConnection();
-    */
-    jotm.getTransactionManager().begin();
-
     session = sessionManager.getSession();
     session.beginTransaction();
     //init test cases
@@ -165,6 +134,7 @@
 
   }
 
+  @SuppressWarnings("unchecked")
   private void runTestCase(TestCase testCase) throws Exception {
     //TODO clean data
     


Reply via email to