Author: lwaterman
Date: Wed Dec 13 23:18:44 2006
New Revision: 487052

URL: http://svn.apache.org/viewvc?view=rev&rev=487052
Log:
Add support for JPA

Modified:
    
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java
    
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Tests.java
    
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/CompensationHandling20Tests.java
    
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Tests.java
    
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/FaultHandling20Tests.java
    
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/MessageRouting20Tests.java
    
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Tests.java

Modified: 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java?view=diff&rev=487052&r1=487051&r2=487052
==============================================================================
--- 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java 
(original)
+++ 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BPELTest.java 
Wed Dec 13 23:18:44 2006
@@ -22,11 +22,15 @@
 import org.apache.ode.bpel.engine.BpelServerImpl;
 import org.apache.ode.bpel.iapi.*;
 import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl;
+import org.apache.ode.dao.jpa.ojpa.BPELDAOConnectionFactoryImpl;
 import org.apache.ode.store.ProcessStoreImpl;
 import org.apache.ode.test.scheduler.TestScheduler;
 import org.apache.ode.utils.DOMUtils;
 import org.w3c.dom.Element;
 
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
 import javax.xml.namespace.QName;
 import java.io.File;
 import java.util.Collection;
@@ -38,12 +42,22 @@
        private BpelServerImpl server;
     private ProcessStore store;
        private MessageExchangeContextImpl mexContext;
+       private EntityManager em;
+       private EntityManagerFactory emf;
 
        @Override
        protected void setUp() throws Exception {
                server = new BpelServerImpl();
                mexContext = new MessageExchangeContextImpl();
-               server.setDaoConnectionFactory(new 
BpelDAOConnectionFactoryImpl());
+               
+               
+               if ( Boolean.getBoolean("org.apache.ode.test.persitent")) {
+                       emf = 
Persistence.createEntityManagerFactory("ode-unit-test-embedded");
+                       em = emf.createEntityManager();
+                       server.setDaoConnectionFactory(new 
org.apache.ode.dao.jpa.ojpa.BPELDAOConnectionFactoryImpl(em));
+               } else {
+                       server.setDaoConnectionFactory(new 
BpelDAOConnectionFactoryImpl());
+               }
         server.setInMemDaoConnectionFactory(new 
BpelDAOConnectionFactoryImpl());
         server.setScheduler(new TestScheduler());
                server.setBindingContext(new BindingContextImpl());
@@ -62,10 +76,12 @@
 
        @Override
        protected void tearDown() throws Exception {
+               if ( em != null ) em.close();
+               if ( emf != null ) emf.close();
                server.stop();
        }
 
-       protected void negative(String deployDir) throws Exception {
+       protected void negative(String deployDir) throws Throwable {
                try {
                        go(deployDir);
                } catch (junit.framework.AssertionFailedError ex) {
@@ -74,7 +90,7 @@
                fail("Expecting test to fail");
        }
 
-       protected void go(String deployDir) throws Exception {
+       protected void go(String deployDir) throws Throwable {
 
                /**
                 * The deploy directory must contain at least one 
"test.properties"
@@ -101,6 +117,7 @@
                        }
                }
 
+               if ( em != null ) em.getTransaction().begin();
                try {
                        Collection<QName> procs =  store.deploy(new 
File(deployDir));
             for (QName procName : procs) {
@@ -113,10 +130,16 @@
                        String responsePattern = 
testProps.getProperty("response1");
                        testResponsePattern(bpelE.getMessage(), 
responsePattern);
                        return;
+               } catch ( Exception e ) {
+                       e.printStackTrace();
+                       fail();
                }
-
+               if ( em != null ) em.getTransaction().commit();
+        
                while (testPropsFile.exists()) {
 
+                       if ( em != null ) em.getTransaction().begin();
+                       
                        Properties testProps = new Properties();
                        testProps.load(testPropsFile.toURL().openStream());
 
@@ -142,76 +165,82 @@
                         * responseN=ASYNC responseN=ONE_WAY 
responseN=COMPLETED_OK
                         *
                         */
-
-                       for (int i = 1; testProps.getProperty("request" + i) != 
null; i++) {
-
-                               String in = testProps.getProperty("request" + 
i);
-                               String responsePattern = 
testProps.getProperty("response" + i);
-
-                               mexContext.clearCurrentResponse();
-
-                               Message request = mex.createMessage(null);
-
-                               Element elem = DOMUtils.stringToDOM(in);
-                               request.setMessage(elem);
-
-
-                               mex.invoke(request);
-
-                               switch (mex.getStatus()) {
-                               case RESPONSE:
-                                       testResponsePattern(mex.getResponse(), 
responsePattern);
-                                       // TODO: test for response fault
-                                       break;
-                               case ASYNC:
-
-                                       switch 
(mex.getMessageExchangePattern()) {
-                                       case REQUEST_ONLY:
-                                               if 
(!responsePattern.equals("ASYNC"))
-                                                       assertTrue(false);
+                       try {
+                               for (int i = 1; testProps.getProperty("request" 
+ i) != null; i++) {
+       
+                                       String in = 
testProps.getProperty("request" + i);
+                                       String responsePattern = 
testProps.getProperty("response" + i);
+       
+                                       mexContext.clearCurrentResponse();
+       
+                                       Message request = 
mex.createMessage(null);
+       
+                                       Element elem = DOMUtils.stringToDOM(in);
+                                       request.setMessage(elem);
+       
+       
+                                       mex.invoke(request);
+       
+       
+                                       switch (mex.getStatus()) {
+                                       case RESPONSE:
+                                               
testResponsePattern(mex.getResponse(), responsePattern);
+                                               // TODO: test for response fault
+                                               break;
+                                       case ASYNC:
+       
+                                               switch 
(mex.getMessageExchangePattern()) {
+                                               case REQUEST_ONLY:
+                                                       if 
(!responsePattern.equals("ASYNC"))
+                                                               fail();
+                                                       break;
+                                               case REQUEST_RESPONSE:
+                                                       
testResponsePattern(mexContext.getCurrentResponse(),
+                                                                       
responsePattern);
+                                               default:
+                                                       break;
+                                               }
+       
+                                               break;
+                                       case COMPLETED_OK:
+                                               if 
(!responsePattern.equals("COMPLETED_OK"))
+                                                       
testResponsePattern(mexContext.getCurrentResponse(),
+                                                                       
responsePattern);
+                                               break;
+                                       case FAULT:
+                                               // TODO: handle Fault
+                                               System.out.println("=> " + 
mex.getFaultExplanation());
+                                               fail();
+                                               break;
+                                       case COMPLETED_FAILURE:
+                                               // TODO: handle Failure
+                                               System.out.println("=> " + 
mex.getFaultExplanation());
+                                               fail();
+                                               break;
+                                       case COMPLETED_FAULT:
+                                               // TODO: handle Failure
+                                               System.out.println("=> " + 
mex.getFaultExplanation());
+                                               fail();
+                                               break;
+                                       case FAILURE:
+                                               // TODO: handle Faulure
+                                               System.out.println("=> " + 
mex.getFaultExplanation());
+                                               fail();
                                                break;
-                                       case REQUEST_RESPONSE:
-                                               
testResponsePattern(mexContext.getCurrentResponse(),
-                                                               
responsePattern);
                                        default:
+                                               fail();
                                                break;
                                        }
-
-                                       break;
-                               case COMPLETED_OK:
-                                       if 
(!responsePattern.equals("COMPLETED_OK"))
-                                               
testResponsePattern(mexContext.getCurrentResponse(),
-                                                               
responsePattern);
-                                       break;
-                               case FAULT:
-                                       // TODO: handle Fault
-                                       System.out.println("=> " + 
mex.getFaultExplanation());
-                                       assertTrue(false);
-                                       break;
-                               case COMPLETED_FAILURE:
-                                       // TODO: handle Failure
-                                       System.out.println("=> " + 
mex.getFaultExplanation());
-                                       assertTrue(false);
-                                       break;
-                               case COMPLETED_FAULT:
-                                       // TODO: handle Failure
-                                       System.out.println("=> " + 
mex.getFaultExplanation());
-                                       assertTrue(false);
-                                       break;
-                               case FAILURE:
-                                       // TODO: handle Faulure
-                                       System.out.println("=> " + 
mex.getFaultExplanation());
-                                       assertTrue(false);
-                                       break;
-                               default:
-                                       assertTrue(false);
-                                       break;
                                }
-
+                       } catch ( Throwable e ) {
+                               e.printStackTrace();
+                               if ( em != null ) 
em.getTransaction().rollback();
+                               throw e;
                        }
                        propsFileCnt++;
                        testPropsFile = new File(deployDir + "/test" + 
propsFileCnt
                                        + ".properties");
+                       if ( em != null ) em.getTransaction().commit();
                }
        }
 

Modified: 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Tests.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Tests.java?view=diff&rev=487052&r1=487051&r2=487052
==============================================================================
--- 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Tests.java
 (original)
+++ 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/BasicActivities20Tests.java
 Wed Dec 13 23:18:44 2006
@@ -1,11 +1,11 @@
 package org.apache.ode.test;
 
 public class BasicActivities20Tests extends BPELTest {
-       public void testHelloWorld2() throws Exception {
+       public void testHelloWorld2() throws Throwable {
                go("target/test-classes/bpel/2.0/HelloWorld2");
        }
 
-       public void testNegativeTargetNS1() throws Exception {
+       public void testNegativeTargetNS1() throws Throwable {
                /**
                 * Test for an invalid targetNamespace has been entered into 
the WSDL.
                 * 
@@ -18,7 +18,7 @@
                go("target/test-classes/bpel/2.0/NegativeTargetNSTest1");
        }
        
-       public void testTimer() throws Exception {
+       public void testTimer() throws Throwable {
         go("target/test-classes/bpel/2.0/TestTimer");
        }
 

Modified: 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/CompensationHandling20Tests.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/CompensationHandling20Tests.java?view=diff&rev=487052&r1=487051&r2=487052
==============================================================================
--- 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/CompensationHandling20Tests.java
 (original)
+++ 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/CompensationHandling20Tests.java
 Wed Dec 13 23:18:44 2006
@@ -2,11 +2,11 @@
 
 public class CompensationHandling20Tests extends BPELTest {
 
-       public void testCompensationHandlers() throws Exception {
+       public void testCompensationHandlers() throws Throwable {
         go("target/test-classes/bpel/2.0/TestCompensationHandlers");
        }
        
-       public void testImplicitFaultHandler() throws Exception {
+       public void testImplicitFaultHandler() throws Throwable {
                go("target/test-classes/bpel/2.0/TestImplicitFaultHandler");
        }
        

Modified: 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Tests.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Tests.java?view=diff&rev=487052&r1=487051&r2=487052
==============================================================================
--- 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Tests.java
 (original)
+++ 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Tests.java
 Wed Dec 13 23:18:44 2006
@@ -2,28 +2,28 @@
 
 public class DataHandling20Tests extends BPELTest {
 
-    public void testXPathNamespace1() throws Exception {
+    public void testXPathNamespace1() throws Throwable {
        go("target/test-classes/bpel/2.0/TestXPathNamespace1");
     }
-    public void testXPathNamespace2() throws Exception {
+    public void testXPathNamespace2() throws Throwable {
        go("target/test-classes/bpel/2.0/TestXPathNamespace2");
     }
-       public void testSubTreeAssign() throws Exception {
+       public void testSubTreeAssign() throws Throwable {
                go("target/test-classes/bpel/2.0/TestSubTreeAssign");
        }
-    public void testAssignActivity1() throws Exception {
+    public void testAssignActivity1() throws Throwable {
         go("src/test/resources/bpel/2.0/TestAssignActivity1");
     }
-    public void testAssignActivity2() throws Exception {
+    public void testAssignActivity2() throws Throwable {
         go("src/test/resources/bpel/2.0/TestAssignActivity2");
     }
-    public void testSimpleTypeParts() throws Exception {
+    public void testSimpleTypeParts() throws Throwable {
        go("target/test-classes/bpel/2.0/TestSimpleTypeParts");
     }
-    public void testSimpleVariableType() throws Exception {
+    public void testSimpleVariableType() throws Throwable {
        go("target/test-classes/bpel/2.0/TestSimpleVariableType");
     }
-    public void testXslTransform() throws Exception {
+    public void testXslTransform() throws Throwable {
         go("target/test-classes/bpel/2.0/TestXslTransform");
     }
        

Modified: 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/FaultHandling20Tests.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/FaultHandling20Tests.java?view=diff&rev=487052&r1=487051&r2=487052
==============================================================================
--- 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/FaultHandling20Tests.java
 (original)
+++ 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/FaultHandling20Tests.java
 Wed Dec 13 23:18:44 2006
@@ -1,13 +1,13 @@
 package org.apache.ode.test;
 
 public class FaultHandling20Tests extends BPELTest {
-       public void testFaultHandlers() throws Exception {
+       public void testFaultHandlers() throws Throwable {
                go("target/test-classes/bpel/2.0/TestFaultHandlers");
        }
-    public void testFaultWithVariable() throws Exception {
+    public void testFaultWithVariable() throws Throwable {
        go("target/test-classes/bpel/2.0/TestFaultWithVariable");
     }
-       public void testCatchFaultInFaultHandler() throws Exception {
+       public void testCatchFaultInFaultHandler() throws Throwable {
                go("target/test-classes/bpel/2.0/TestCatchFaultInFaultHandler");
        }
 }

Modified: 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/MessageRouting20Tests.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/MessageRouting20Tests.java?view=diff&rev=487052&r1=487051&r2=487052
==============================================================================
--- 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/MessageRouting20Tests.java
 (original)
+++ 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/MessageRouting20Tests.java
 Wed Dec 13 23:18:44 2006
@@ -2,31 +2,31 @@
 
 public class MessageRouting20Tests extends BPELTest {
 
-       public void testCorrelation() throws Exception {
+       public void testCorrelation() throws Throwable {
                go("target/test-classes/bpel/2.0/TestCorrelation");
        }
-       public void testCorrelation1() throws Exception {
+       public void testCorrelation1() throws Throwable {
                go("target/test-classes/bpel/2.0/TestCorrelation1");
        }
-       public void testCorrelationOpaque() throws Exception {
+       public void testCorrelationOpaque() throws Throwable {
                go("target/test-classes/bpel/2.0/testCorrelationOpaque");
        }
-       public void testCorrelationAsync() throws Exception {
+       public void testCorrelationAsync() throws Throwable {
                go("target/test-classes/bpel/2.0/TestCorrelationAsync");
        }
-    public void testDynamicPick() throws Exception {
+    public void testDynamicPick() throws Throwable {
        go("target/test-classes/bpel/2.0/TestDynamicPick");
     }
-    public void testInstPick() throws Exception {
+    public void testInstPick() throws Throwable {
         go("target/test-classes/bpel/2.0/TestInstantiatingPick");
     }
-    public void testStaticOnMessage() throws Exception {
+    public void testStaticOnMessage() throws Throwable {
        go("target/test-classes/bpel/2.0/TestStaticOnMessage");
     }
-    public void testStaticPick() throws Exception {
+    public void testStaticPick() throws Throwable {
        go("target/test-classes/bpel/2.0/TestStaticPick");
     }
-       public void testNegativeCorrelation() throws Exception {
+       public void testNegativeCorrelation() throws Throwable {
                        /**
                         * This test contains invalid BPEL. There is an 
instantiating
                         * <receive> and a subsequent <pick> that does not 
define a correlation
@@ -38,7 +38,7 @@
                         */
           negative("target/test-classes/bpel/2.0/NegativeCorrelationTest");
        }
-         public void testNegativeInitialization() throws Exception {
+         public void testNegativeInitialization() throws Throwable {
                        /**
                         * This test contains invalid BPEL. There is an 
instantiating
                         * <receive> within a <scope>. The <scope> contains 
eventhandlers

Modified: 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Tests.java
URL: 
http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Tests.java?view=diff&rev=487052&r1=487051&r2=487052
==============================================================================
--- 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Tests.java
 (original)
+++ 
incubator/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Tests.java
 Wed Dec 13 23:18:44 2006
@@ -1,11 +1,11 @@
 package org.apache.ode.test;
 
 public class StructuredActivities20Tests extends BPELTest {
-       public void testFlowActivity1() throws Exception {
+       public void testFlowActivity1() throws Throwable {
                // Test Flow with XPath20
                go("target/test-classes/bpel/2.0/TestFlowActivity1");
        }
-       public void testFlowActivity2() throws Exception {
+       public void testFlowActivity2() throws Throwable {
                // Test Flow with XPath10
                go("target/test-classes/bpel/2.0/TestFlowActivity2");
        }


Reply via email to