incubator-agila-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r165042 [19/30] - in /incubator/agila/trunk: ./ config/ modules/ modules/bpel/ modules/bpel/client/ modules/bpel/client/api/ modules/bpel/client/api/src/ modules/bpel/client/api/src/conf/ modules/bpel/client/api/src/java/ modules/bpel/client/api/src/java/org/ modules/bpel/client/api/src/java/org/apache/ modules/bpel/client/api/src/java/org/apache/agila/ modules/bpel/client/api/src/java/org/apache/agila/bpel/ modules/bpel/client/api/src/java/org/apache/agila/bpel/client/ modules/bpel/client/api/src/test/ modules/bpel/client/api/src/test/junit/ modules/bpel/client/api/src/test/junit/org/ modules/bpel/client/api/src/test/junit/org/apache/ modules/bpel/client/api/src/test/junit/org/apache/agila/ modules/bpel/client/api/src/test/junit/org/apache/agila/bpel/ modules/bpel/client/api/src/test/junit/org/apache/agila/bpel/client/ modules/bpel/client/web/ modules/bpel/client/web/src/ modules/bpel/client/web/src/conf/ modules/bpel/client/web/src/java/ modules/bpel/client/web/src/java/org/ modules/bpel/client/web/src/java/org/apache/ modules/bpel/client/web/src/java/org/apache/agila/ modules/bpel/client/web/src/java/org/apache/agila/bpel/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/common/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/deployer/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/engine/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/global/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/global/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/security/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/action/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/user/form/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/util/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/worklist/ modules/bpel/client/web/src/java/org/apache/agila/bpel/web/worklist/action/ modules/bpel/client/web/src/webapp/ modules/bpel/client/web/src/webapp/META-INF/ modules/bpel/client/web/src/webapp/WEB-INF/ modules/bpel/client/web/src/webapp/WEB-INF/classes/ modules/bpel/client/web/src/webapp/images/ modules/bpel/client/web/src/webapp/images/audit/ modules/bpel/client/web/src/webapp/style/ modules/bpel/common/ modules/bpel/common/src/ modules/bpel/common/src/aspect/ modules/bpel/common/src/conf/ modules/bpel/common/src/java/ modules/bpel/common/src/java/org/ modules/bpel/common/src/java/org/apache/ modules/bpel/common/src/java/org/apache/agila/ modules/bpel/common/src/java/org/apache/agila/bpel/ modules/bpel/common/src/java/org/apache/agila/bpel/common/ modules/bpel/common/src/java/org/apache/agila/bpel/common/aspect/ modules/bpel/common/src/java/org/apache/agila/bpel/common/configuration/ modules/bpel/common/src/java/org/apache/agila/bpel/common/util/ modules/bpel/common/src/java/org/apache/agila/bpel/common/util/logger/ modules/bpel/common/src/test/ modules/bpel/common/src/test/junit/ modules/bpel/common/src/test/junit/org/ modules/bpel/common/src/test/junit/org/apache/ modules/bpel/common/src/test/junit/org/apache/agila/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/common/ modules/bpel/common/src/test/junit/org/apache/agila/bpel/common/util/ modules/bpel/dist/ modules/bpel/dist/src/ modules/bpel/dist/src/java/ modules/bpel/dist/src/java/org/ modules/bpel/dist/src/java/org/apache/ modules/bpel/dist/src/java/org/apache/agila/ modules/bpel/dist/src/java/org/apache/agila/bpel/ modules/bpel/dist/src/java/org/apache/agila/bpel/util/ modules/bpel/dist/src/script/ modules/bpel/engine/ modules/bpel/engine/common/ modules/bpel/engine/common/src/ modules/bpel/engine/common/src/aspect/ modules/bpel/engine/common/src/hibernate/ modules/bpel/engine/common/src/hibernate/org/ modules/bpel/engine/common/src/hibernate/org/apache/ modules/bpel/engine/common/src/hibernate/org/apache/agila/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/hibernate/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/java/ modules/bpel/engine/common/src/java/org/ modules/bpel/engine/common/src/java/org/apache/ modules/bpel/engine/common/src/java/org/apache/agila/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/aspect/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/execution/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/execution/impl/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/lifecycle/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/event/lifecycle/dao/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/lifecycle/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/monitoring/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/persistence/ modules/bpel/engine/common/src/java/org/apache/agila/bpel/engine/common/transaction/ modules/bpel/engine/common/src/test/ modules/bpel/engine/common/src/test/junit/ modules/bpel/engine/common/src/test/junit/org/ modules/bpel/engine/common/src/test/junit/org/apache/ modules/bpel/engine/common/src/test/junit/org/apache/agila/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/common/ modules/bpel/engine/common/src/test/junit/org/apache/agila/bpel/engine/common/event/ modules/bpel/engine/common/src/test/resources/ modules/bpel/engine/core/ modules/bpel/engine/core/src/ modules/bpel/engine/core/src/aspect/ modules/bpel/engine/core/src/hibernate/ modules/bpel/engine/core/src/hibernate/org/ modules/bpel/engine/core/src/hibernate/org/apache/ modules/bpel/engine/core/src/hibernate/org/apache/agila/ modules/bpel/engine/core/src/hibernate/org/apache/agila/bpel/ modules/bpel/engine/core/src/hibernate/org/apache/agila/bpel/engine/ modules/bpel/engine/core/src/java/ modules/bpel/engine/core/src/java/org/ modules/bpel/engine/core/src/java/org/apache/ modules/bpel/engine/core/src/java/org/apache/agila/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/exception/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/impl/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/definition/impl/dao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/dao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/core/dynamic/impl/xao/ modules/bpel/engine/core/src/java/org/apache/agila/bpel/engine/priv/expression/ modules/bpel/engine/core/s
Date Wed, 27 Apr 2005 20:28:07 GMT
Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestProcessVersioning.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestProcessVersioning.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestProcessVersioning.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestProcessVersioning.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,154 @@
+/*
+ * 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.bpel.engine.core.definition;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.client.AgilaDeployer;
+import org.apache.agila.bpel.common.util.StringUtil;
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.persistence.FinderException;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.impl.ProcessImpl;
+
+/**
+ * @author mriou
+ */
+public class TestProcessVersioning extends TestCase {
+
+    private AgilaDeployer deployer;
+
+    protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+		SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+		schemaExport.create(true, true);
+		
+        deployer = new AgilaDeployer();
+    }
+
+    protected void tearDown() throws Exception {
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+    
+    public void testDoubleDeploy() throws Exception {
+        String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("loop.xml"));
+        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("loop-defs.xml"));
+        deployer.deploy(processDesc, wsDefs);
+        
+        TransactionManager.beginTransaction();
+        ProcessImpl process1 = (ProcessImpl) ProcessFactory.getByName("loop", 
+                "http://www.apache.org/agila/example/loop/process/");
+        assertEquals("Version after first creation is not 0", 0, process1.getVersion());
+        TransactionManager.commitTransaction();
+
+        // Deploying again, should recreate the process incrementing its version  
+        deployer.deploy(processDesc, wsDefs);
+
+        TransactionManager.beginTransaction();
+        ProcessImpl process2 = (ProcessImpl) ProcessFactory.getByName("loop", 
+                "http://www.apache.org/agila/example/loop/process/");
+        assertEquals("Version after first creation is not 0", 1, process2.getVersion());
+        TransactionManager.commitTransaction();
+    }
+    
+    public void testDelete() throws Exception {
+        String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("loop.xml"));
+        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("loop-defs.xml"));
+        deployer.deploy(processDesc, wsDefs);
+        
+        TransactionManager.beginTransaction();
+        ProcessImpl process1 = (ProcessImpl) ProcessFactory.getByName("loop", 
+                "http://www.apache.org/agila/example/loop/process/");
+        assertEquals("Version after first creation is not 0", 0, process1.getVersion());
+        TransactionManager.commitTransaction();
+
+        // Deploying again, should recreate the process incrementing its version  
+        deployer.deploy(processDesc, wsDefs);
+
+        TransactionManager.beginTransaction();
+        ProcessImpl process2 = (ProcessImpl) ProcessFactory.getByName("loop", 
+                "http://www.apache.org/agila/example/loop/process/");
+        assertEquals("Version after first creation is not 0", 1, process2.getVersion());
+        TransactionManager.commitTransaction();
+
+        // And again for deletion  
+        deployer.deploy(processDesc, wsDefs);
+
+        TransactionManager.beginTransaction();
+        ProcessImpl process3 = (ProcessImpl) ProcessFactory.getByName("loop", 
+                "http://www.apache.org/agila/example/loop/process/");
+        assertEquals("Version after first creation is not 0", 2, process3.getVersion());
+        TransactionManager.commitTransaction();
+    
+        // Now deleting
+        TransactionManager.beginTransaction();
+        process3 = (ProcessImpl) ProcessFactory.getByName("loop", 
+                "http://www.apache.org/agila/example/loop/process/");
+        ProcessFactory.deleteProcess("http://www.apache.org/agila/example/loop/process/");
+        TransactionManager.commitTransaction();
+
+        // Shouldn't be able to find it anymore
+        TransactionManager.beginTransaction();
+        try {
+            ProcessImpl processDel = (ProcessImpl) ProcessFactory.getByName("loop",
+                    "http://www.apache.org/agila/example/loop/process/");
+            fail("A process has been found after deletion.");
+        } catch (FinderException e) { }
+        TransactionManager.commitTransaction();
+    }
+
+    public void testResurrection() throws Exception {
+        String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("loop.xml"));
+        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("loop-defs.xml"));
+        deployer.deploy(processDesc, wsDefs);
+        
+        TransactionManager.beginTransaction();
+        ProcessImpl process1 = (ProcessImpl) ProcessFactory.getByName("loop", 
+                "http://www.apache.org/agila/example/loop/process/");
+        assertEquals("Version after first creation is not 0", 0, process1.getVersion());
+        TransactionManager.commitTransaction();
+
+        // Deleting
+        TransactionManager.beginTransaction();
+        ProcessFactory.deleteProcess("http://www.apache.org/agila/example/loop/process/");
+        TransactionManager.commitTransaction();
+
+        // Shouldn't be able to find it anymore
+        TransactionManager.beginTransaction();
+        try {
+            ProcessImpl processDel = (ProcessImpl) ProcessFactory.getByName("loop",
+                    "http://www.apache.org/agila/example/loop/process/");
+            fail("A process has been found after deletion.");
+        } catch (FinderException e) { }
+        TransactionManager.commitTransaction();
+
+        // Deploying again, should recreate the process with a 0 version  
+        deployer.deploy(processDesc, wsDefs);
+
+        TransactionManager.beginTransaction();
+        ProcessImpl process2 = (ProcessImpl) ProcessFactory.getByName("loop", 
+                "http://www.apache.org/agila/example/loop/process/");
+        assertEquals("Version after first creation is not 0", 0, process2.getVersion());
+        TransactionManager.commitTransaction();
+    }
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestReceive.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestReceive.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestReceive.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestReceive.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,98 @@
+/*
+ * 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.bpel.engine.core.definition;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.CorrelationRef;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Receive;
+import org.apache.agila.bpel.util.BeanTester;
+
+public class TestReceive extends TestCase {
+
+	public static Receive receive = null;
+
+    public static String REC_OPERATION = "operation";
+    public static String REC_PARTNER = "partner";
+    public static String REC_NS = "http://DefaulNS";
+    public static String REC_PORT = "portType";
+    public static String REC_VAR = "variable";
+
+	private BeanTester beanTester = new BeanTester(new String[] {"Id", "Index"});
+	private TestProcess testProcess = new TestProcess();
+
+	protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+		SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+		schemaExport.create(true, true);
+
+        TransactionManager.beginTransaction();
+		testProcess.testCreate();
+	}
+
+	protected void tearDown() throws Exception {
+		TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+	}
+
+	public void testCreate() throws Exception {
+		receive = (Receive) ActivityFactory.createActivity(Receive.class, TestProcess.testProcess);
+        receive.setCreateInstance(false);
+        ActivityFactory.addCorrelationRef(receive, TestProcess.CORRELATION_NAME, true, CorrelationRef.NONE);
+		beanTester.initializeProperties("testReceive", receive);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		Receive resultReceive = (Receive) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+		assertTrue("Receive attributes values have been changed.", beanTester.testValues("testReceive", resultReceive));
+        assertEquals("Receive correlation set name has changed", TestProcess.CORRELATION_NAME, ((CorrelationRef)resultReceive.getCorrelations().iterator().next()).getSet());
+        assertEquals("Receive correlation initiate has changed", true, ((CorrelationRef)resultReceive.getCorrelations().iterator().next()).isInitiate());
+        assertEquals("Receive correlation pattern has changed", CorrelationRef.NONE, ((CorrelationRef)resultReceive.getCorrelations().iterator().next()).getPattern());
+        resultReceive.setReply(false);
+		receive = resultReceive;
+	}
+
+	public void testCreateWithValues() throws Exception {
+		receive = (Receive) ActivityFactory.createActivity(Receive.class, TestProcess.testProcess);
+        receive.setCreateInstance(false);
+        ActivityFactory.addCorrelationRef(receive, TestProcess.CORRELATION_NAME, false, CorrelationRef.NONE);
+        receive.setOperation(REC_OPERATION);
+        receive.setPartner(REC_PARTNER);
+        receive.setPortType(REC_PORT);
+        receive.setVariable(REC_VAR);
+		receive.setNamespace(REC_NS);
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		Receive resultReceive = (Receive) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+        assertNotNull("A null receive has been found", resultReceive);
+		receive = resultReceive;
+	}
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestSequence.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestSequence.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestSequence.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestSequence.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,94 @@
+/*
+ * 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.bpel.engine.core.definition;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.priv.core.definition.Activity;
+import org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Invoke;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Sequence;
+import org.apache.agila.bpel.util.BeanTester;
+
+/**
+ * Tests a simple sequence with three invokes (as a sequence by itself
+ * doesn't really make sense).
+ */
+public class TestSequence extends TestCase {
+
+	public static Sequence testSequence = null;
+
+	private TestProcess testProcess = new TestProcess();
+	private ProcessFactory processFactory = new ProcessFactory();
+	private ActivityFactory activityFactory = new ActivityFactory();
+	private BeanTester beanTester = new BeanTester(new String[] {"Id", "Index"});
+
+	protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+		SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+		schemaExport.create(true, true);
+
+        TransactionManager.beginTransaction();
+		testProcess.testCreate();
+	}
+
+	protected void tearDown() throws Exception {
+		TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();	}
+
+	public void testCreate() throws Exception {
+		testSequence = (Sequence) ActivityFactory.createActivity(Sequence.class, TestProcess.testProcess);
+		Invoke invoke1 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSequence);
+		beanTester.initializeProperties("invoke1", invoke1);
+		Invoke invoke2 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSequence);
+		beanTester.initializeProperties("invoke2", invoke2);
+		Invoke invoke3 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSequence);
+		beanTester.initializeProperties("invoke3", invoke3);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		Sequence resultSeq = (Sequence) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+		assertNotNull("Sequence process is null", resultSeq.getProcess());
+		Activity act1 = (Activity) resultSeq.getActivities().get(0);
+		assertTrue("First activity in the sequence is not an Invoke", act1 instanceof Invoke);
+		assertTrue("First activity attributes have been changed", beanTester.testValues("invoke1", act1));
+		Activity act2 = (Activity) resultSeq.getActivities().get(1);
+		assertTrue("Second activity in the sequence is not an Invoke", act2 instanceof Invoke);
+		assertTrue("Second activity attributes have been changed", beanTester.testValues("invoke2", act2));
+		Activity act3 = (Activity) resultSeq.getActivities().get(2);
+		assertTrue("Third activity in the sequence is not an Invoke", act3 instanceof Invoke);
+		assertTrue("Third activity attributes have been changed", beanTester.testValues("invoke3", act3));
+
+        invoke1.setInputVariable(null);
+        invoke1.setOutputVariable(null);
+        invoke2.setInputVariable(null);
+        invoke2.setOutputVariable(null);
+        invoke3.setInputVariable(null);
+        invoke3.setOutputVariable(null);
+	}
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestSwitch.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestSwitch.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestSwitch.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestSwitch.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,134 @@
+/*
+ * 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.bpel.engine.core.definition;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.priv.core.definition.Activity;
+import org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Invoke;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Switch;
+import org.apache.agila.bpel.util.BeanTester;
+
+/**
+ * Tests a simple switch with three invokes (as a switch by itself
+ * doesn't really make sense).
+ */
+public class TestSwitch extends TestCase {
+
+	public static Switch testSwitch = null;
+
+	private TestProcess testProcess = new TestProcess();
+	private BeanTester beanTester = new BeanTester(new String[] {"Id", "Index"});
+
+	protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+		SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+		schemaExport.create(true, true);
+
+        TransactionManager.beginTransaction();
+		testProcess.testCreate();
+	}
+
+	protected void tearDown() throws Exception {
+		TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+
+    public void testSimpleCreate() throws Exception {
+        testSwitch = (Switch) ActivityFactory.createActivity(Switch.class, TestProcess.testProcess);
+        Invoke invoke1 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSwitch);
+        beanTester.initializeProperties("invoke1", invoke1);
+        Invoke invoke2 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSwitch);
+        beanTester.initializeProperties("invoke2", invoke2);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        Switch resultSeq = (Switch) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+        assertNotNull("Switch process is null", resultSeq.getProcess());
+        Activity act1 = (Activity) resultSeq.getActivities().get(0);
+        assertTrue("First activity in the switch is not an Invoke", act1 instanceof Invoke);
+        assertTrue("First activity attributes have been changed", beanTester.testValues("invoke1", act1));
+        Activity act2 = (Activity) resultSeq.getActivities().get(1);
+        assertTrue("Second activity in the switch is not an Invoke", act2 instanceof Invoke);
+        assertTrue("Second activity attributes have been changed", beanTester.testValues("invoke2", act2));
+
+    }
+
+	public void testCreateNoOtherwise() throws Exception {
+		testSwitch = (Switch) ActivityFactory.createActivity(Switch.class, TestProcess.testProcess);
+		Invoke invoke1 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSwitch);
+        invoke1.setOperation("operation1");
+        invoke1.setPartner("partner1");
+        invoke1.setPortType("portType1");
+		Invoke invoke2 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSwitch);
+        invoke2.setOperation("operation2");
+        invoke2.setPartner("partner2");
+        invoke2.setPortType("portType2");
+
+        testSwitch.addCondition("1 > 2", invoke1);
+        testSwitch.addCondition("1 < 2", invoke2);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		Switch resultSeq = (Switch) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+		assertNotNull("Switch process is null", resultSeq.getProcess());
+	}
+
+	public void testCreateWithOtherwise() throws Exception {
+		testSwitch = (Switch) ActivityFactory.createActivity(Switch.class, TestProcess.testProcess);
+		Invoke invoke1 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSwitch);
+        invoke1.setOperation("operation1");
+        invoke1.setPartner("partner1");
+        invoke1.setNamespace("http;//DefaultNS1");
+        invoke1.setPortType("portType1");
+		Invoke invoke2 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSwitch);
+        invoke2.setOperation("operation2");
+        invoke2.setPartner("partner2");
+        invoke2.setNamespace("http;//DefaultNS2");
+        invoke2.setPortType("portType2");
+        Invoke invoke3 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSwitch);
+        invoke3.setOperation("operation3");
+        invoke3.setPartner("partner3");
+        invoke3.setNamespace("http;//DefaultNS3");
+        invoke3.setPortType("portType3");
+
+        testSwitch.addCondition("1 > 2", invoke1);
+        testSwitch.addCondition("1 = 2", invoke2);
+        testSwitch.setOtherwise(invoke3);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		Switch resultSeq = (Switch) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+		assertNotNull("Switch process is null", resultSeq.getProcess());
+
+	}
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestTerminate.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestTerminate.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestTerminate.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestTerminate.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,88 @@
+/*
+ * 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.bpel.engine.core.definition;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.priv.core.definition.Activity;
+import org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Invoke;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Sequence;
+import org.apache.agila.bpel.engine.priv.core.definition.Terminate;
+import org.apache.agila.bpel.util.BeanTester;
+
+/**
+ * To test the terminate we create a sequence containing one terminate and
+ * two invokes making sure that when executing the invokes are not.
+ */
+public class TestTerminate extends TestCase {
+
+	public static Sequence testSequence = null;
+
+	private TestProcess testProcess = new TestProcess();
+	private BeanTester beanTester = new BeanTester(new String[] {"Id", "Index"});
+
+	protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+		SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+		schemaExport.create(true, true);
+
+        TransactionManager.beginTransaction();
+		testProcess.testCreate();
+	}
+
+	protected void tearDown() throws Exception {
+		TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+	}
+
+	public void testCreate() throws Exception {
+		testSequence = (Sequence) ActivityFactory.createActivity(Sequence.class, TestProcess.testProcess);
+		Terminate terminate = (Terminate) ActivityFactory.createActivity(Terminate.class, testSequence);
+		beanTester.initializeProperties("terminate", terminate);
+		Invoke invoke2 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSequence);
+		beanTester.initializeProperties("invoke2", invoke2);
+		Invoke invoke3 = (Invoke) ActivityFactory.createActivity(Invoke.class, testSequence);
+		beanTester.initializeProperties("invoke3", invoke3);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		Sequence resultSeq = (Sequence) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+		assertNotNull("Sequence process is null", resultSeq.getProcess());
+		Activity act1 = (Activity) resultSeq.getActivities().get(0);
+		assertTrue("First activity in the sequence is not a Terminate", act1 instanceof Terminate);
+		assertTrue("First activity attributes have been changed", beanTester.testValues("terminate", act1));
+		Activity act2 = (Activity) resultSeq.getActivities().get(1);
+		assertTrue("Second activity in the sequence is not an Invoke", act2 instanceof Invoke);
+		assertTrue("Second activity attributes have been changed", beanTester.testValues("invoke2", act2));
+		Activity act3 = (Activity) resultSeq.getActivities().get(2);
+		assertTrue("Third activity in the sequence is not an Invoke", act3 instanceof Invoke);
+		assertTrue("Third activity attributes have been changed", beanTester.testValues("invoke3", act3));
+
+	}
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestWait.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestWait.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestWait.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/definition/TestWait.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,92 @@
+/*
+ * 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.bpel.engine.core.definition;
+
+import java.util.Calendar;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Wait;
+import org.apache.agila.bpel.util.BeanTester;
+
+import com.sun.msv.datatype.xsd.DatatypeFactory;
+
+public class TestWait extends TestCase {
+
+	public static Wait wait = null;
+
+	private BeanTester beanTester = new BeanTester(new String[] {"Id", "Index"});
+	private TestProcess testProcess = new TestProcess();
+
+	protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+		SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+		schemaExport.create(true, true);
+
+        TransactionManager.beginTransaction();
+		testProcess.testCreate();
+	}
+
+	protected void tearDown() throws Exception {
+		TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+	}
+
+	public void testCreate() throws Exception {
+		wait = (Wait) ActivityFactory.createActivity(Wait.class, TestProcess.testProcess);
+		beanTester.initializeProperties("testWait", wait);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		Wait resultWait = (Wait) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+		assertTrue("Wait attributes values have been changed.", beanTester.testValues("testWait", resultWait));
+		wait = resultWait;
+	}
+
+	/**
+	 * Creates a wait configured to wait one minute from the execution time.
+	 */
+	public void testCreateOneMn() throws Exception {
+		Calendar nowPlusOne = Calendar.getInstance();
+		nowPlusOne.add(Calendar.SECOND, 30);
+		String nowPlusOneStr = DatatypeFactory.getTypeByName("dateTime").serializeJavaObject(nowPlusOne, null);
+		wait = (Wait) ActivityFactory.createActivity(Wait.class, TestProcess.testProcess);
+		wait.setDuration(false);
+		wait.setTime(nowPlusOneStr);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		Wait resultWait = (Wait) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+                TestProcess.testProcess.getNamespace()).getActivity();
+		assertEquals("Wait duration has been changed.", false, resultWait.isDuration());
+		assertEquals("Wait time has been changed.", nowPlusOneStr, resultWait.getTime());
+		wait = resultWait;
+	}
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestAssignEC.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestAssignEC.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestAssignEC.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestAssignEC.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,164 @@
+/*
+ * 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.bpel.engine.core.dynamic;
+
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.dom4j.Document;
+import org.apache.agila.bpel.client.AgilaDeployer;
+import org.apache.agila.bpel.common.util.StringUtil;
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.persistence.XMLDataAccess;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.core.definition.TestAssign;
+import org.apache.agila.bpel.engine.core.definition.TestProcess;
+import org.apache.agila.bpel.engine.priv.core.definition.Assign;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Sequence;
+import org.apache.agila.bpel.engine.priv.core.definition.AgilaProcess;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContext;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+import org.apache.agila.bpel.engine.priv.core.dynamic.impl.xao.VariableXAO;
+import org.apache.log4j.Logger;
+
+/**
+ * Testing the Assign execution.
+ */
+public class TestAssignEC extends TestCase {
+
+    private AgilaDeployer deployer;
+    private Logger log = Logger.getLogger(getClass());
+    private TestProcess testProcess = new TestProcess();
+    private TestAssign testAssign = new TestAssign();
+
+    protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+        SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+        schemaExport.create(true, true);
+
+        deployer = new AgilaDeployer();
+    }
+
+    protected void tearDown() throws Exception {
+        deployer = null;
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+
+//    public void testExecute() throws Exception {
+//        TransactionManager.beginTransaction();
+//        XMLDataAccess.cleanCollection("/testProcess");
+//        testProcess.testCreateWithCorrelation();
+//        testAssign.testCreate();
+//
+//        // Executing the first receive, so that we can set variable during it's waiting.
+//        Map corrProp = new HashMap();
+//        corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+//        corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+//        Receive firstAct = (Receive)((Sequence) ProcessFactory.getByName(TestProcess.testProcess.getName(),
+//                TestProcess.testProcess.getNamespace()).getActivity()).getActivities().get(0);
+//        firstAct.execute(TestProcess.CORRELATION_NAME, corrProp);
+//
+//        TransactionManager.commitTransaction();
+//        TransactionManager.beginTransaction();
+//
+//        // Setting the variables and deblocking the receive to have the assign executed.
+//        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+//        Document doc1 = DocumentHelper.createDocument();
+//        Element root1 = doc1.addElement("message");
+//        root1.addElement("part11").addElement("subpart1").setText("someText");
+//        root1.addElement("part12").setText("part2");
+//
+//        Document doc2 = DocumentHelper.createDocument();
+//        Element root2 = doc2.addElement("message");
+//        root2.addElement("part21").addElement("subpart2").setText("someOtherText");
+//        root2.addElement("part22").setText("part22");
+//
+//        VariableXAO.createVariable(TestProcess.testProcess.getName(), "variable1", ((ProcessInstanceImpl)createdInstance).getId(), doc1);
+//        VariableXAO.createVariable(TestProcess.testProcess.getName(), "variable2", ((ProcessInstanceImpl)createdInstance).getId(), doc2);
+//
+//        ((ReceiveEC)((SequenceEC)createdInstance.getChildExecutionContext()).getExecutionContexts().get(0)).acknowledgeMessage(null);
+//
+//        // Checking execution is done
+//        createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+//        assertEquals("Process is not completed after execution ended", ProcessInstance.COMPLETED, createdInstance.getStatus());
+//        assertEquals("Assign is not completed after execution ended", ExecutionContext.COMPLETED, createdInstance.getChildExecutionContext().getStatus());
+//
+//        // Check that variables have been updated
+//        Document resultDoc = XMLDataAccess.getDocument("/" + TestProcess.testProcess.getName() +
+//                "/variable/", "variable2" + ((ProcessInstanceImpl)createdInstance).getId());
+//        Element newPart = resultDoc.getRootElement().element("part21");
+//        assertNotNull("Could not find the newly assigned part in the variable", newPart);
+//        assertNotNull("The newly assigned part doesn't include the expected element", newPart.element("subpart1"));
+//
+//        TransactionManager.commitTransaction();
+//    }
+
+    public void testSequentialAssigns() throws Exception {
+        String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-assign.xml"));
+        log.info(processDesc);
+        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-assign-defs.xml"));
+        log.info(wsDefs);
+        deployer.deploy(processDesc, wsDefs);
+		//log.info("deploy3");
+        TransactionManager.beginTransaction();
+        XMLDataAccess.cleanCollection("/test-assign");
+        
+        AgilaProcess process = ProcessFactory.getByName("test-assign",
+                "http://www.apache.org/agila/test/assign/process/");
+
+        // Getting first assign in the process and executing it
+        System.out.println("1 " + process.getActivity());
+        System.out.println("2 " + ((Sequence)process.getActivity()).getActivities());
+        System.out.println("3 " + ((Sequence)process.getActivity()).getActivities().get(0));
+        try {
+	        ExecutionContext context =
+	                ((Assign)((Sequence)process.getActivity()).getActivities().get(0)).execute(null, null);
+	
+	        TransactionManager.commitTransaction();
+	        TransactionManager.beginTransaction();
+	
+	        // Checking variable 2 that has been double assigned to make sure the part has been replaced
+	        Document resultVar2 = VariableXAO.getVariable("test-assign", "assignVar2", context.fetchInstance().getId());
+	        System.out.println(resultVar2.asXML());
+	        assertEquals("Double assigned variable has 2 parts!", 1, resultVar2.getRootElement().elements().size());
+	        
+	        // Checking that variable 4 holds only one element subnumber
+	        Document resultVar4 = VariableXAO.getVariable("test-assign", "assignVar4", context.fetchInstance().getId());
+	        assertEquals("Result variable is holding a wrong value", 1,
+	                resultVar4.getRootElement().element("mainpart").element("number").elements().size());
+	        
+	        // Checking that the last assigned variable has the expected value and two subnumber elmts
+	        Document resultVar5 = VariableXAO.getVariable("test-assign", "assignVar5", context.fetchInstance().getId());
+	        System.out.println(resultVar5.asXML());
+	        assertEquals("Result variable is holding a wrong value", "2.0",
+	                resultVar5.getRootElement().element("mainpart").element("number").element("subnumber").getText());
+	        assertEquals("Result variable is holding a wrong value", "2.0",
+	                resultVar5.getRootElement().element("mainpart").element("number").element("subnumber").getText());
+	        assertEquals("Instance is not complete", ProcessInstance.COMPLETED, context.fetchInstance().getStatus());
+	
+	        TransactionManager.commitTransaction();
+        } catch (Exception e) {
+        	e.printStackTrace();
+        }
+    }
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestEmptyEC.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestEmptyEC.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestEmptyEC.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestEmptyEC.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,93 @@
+/*
+ * 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.bpel.engine.core.dynamic;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.core.definition.TestEmpty;
+import org.apache.agila.bpel.engine.core.definition.TestProcess;
+import org.apache.agila.bpel.engine.priv.core.dynamic.EmptyEC;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContext;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContextFactory;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstanceFactory;
+
+public class TestEmptyEC extends TestCase {
+
+	public EmptyEC testEmptyEC = null;
+
+    private TestEmpty testEmpty = new TestEmpty();
+    private TestProcess testProcess = new TestProcess();
+
+    protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+        SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+        schemaExport.create(true, true);
+
+        TransactionManager.beginTransaction();
+        testProcess.testCreateWithCorrelation();
+        // Empty is using the process created in TestProcess
+        testEmpty.testCreate();
+    }
+
+    protected void tearDown() throws Exception {
+        TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+
+    public void testCreate() throws Exception {
+        Map corrProp = new HashMap();
+        corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+        corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+        ProcessInstance pi = ProcessInstanceFactory.createProcessInstance(TestEmpty.empty.getProcess(),
+				TestProcess.CORRELATION_NAME, corrProp);
+		EmptyEC emptyEC = (EmptyEC) ExecutionContextFactory.createExecutionContext(TestEmpty.empty, pi);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+		assertTrue("Instance child ec is not a EmptyEC",
+				createdInstance.getChildExecutionContext() instanceof EmptyEC);
+		testEmptyEC = (EmptyEC) createdInstance.getChildExecutionContext();
+    }
+
+	public void testExecute() throws Exception {
+		Map corrProp = new HashMap();
+		corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+		corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+
+		TestEmpty.empty.execute(TestProcess.CORRELATION_NAME, corrProp);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+		assertEquals("Process is not completed after execution ended", ProcessInstance.COMPLETED, createdInstance.getStatus());
+		assertEquals("Empty is not completed after execution ended", ExecutionContext.COMPLETED, createdInstance.getChildExecutionContext().getStatus());
+	}
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestFlow.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestFlow.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestFlow.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestFlow.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,83 @@
+/*
+ * 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.bpel.engine.core.dynamic;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.apache.agila.bpel.client.AgilaDeployer;
+import org.apache.agila.bpel.common.util.StringUtil;
+import org.apache.agila.bpel.engine.AgilaEngineFactory;
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.priv.messaging.MessageBroker;
+import org.apache.agila.bpel.engine.priv.messaging.impl.DefaultMessageBrokerImpl;
+import org.apache.agila.bpel.util.BeanTester;
+import org.apache.agila.bpel.util.EngineResultTester;
+
+public class TestFlow extends TestCase {
+
+    private AgilaDeployer deployer;
+
+    protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+        SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+        schemaExport.create(true, true);
+
+        deployer = new AgilaDeployer();
+    }
+
+    protected void tearDown() throws Exception {
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+
+    public void testExecuteWithDescription() throws Exception {
+        String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-flow.xml"));
+        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-flow-defs.xml"));
+        deployer.deploy(processDesc, wsDefs);
+
+        // Starting the process.
+        Document doc = DocumentHelper.createDocument();
+        doc.addElement("message").addElement("main").addElement("tstflowid")
+                .setText((String) BeanTester.generateRandomValue(String.class));
+        Document result = AgilaEngineFactory.getEngine().acknowledge("initiatingPartner", "initiatingPort", "initiatingOp", doc);
+        assertTrue("A problem occured when the message as been sent", EngineResultTester.test(result));
+
+        Thread.sleep(10000);
+
+        // Checking that both branches have been executed
+        Document receivedDoc = MessageBroker.getMessage("firstBranchPartner", "firstBranchPort", "firstBranchOp");
+        assertNotNull("First branch document has not been sent.", receivedDoc);
+        receivedDoc = MessageBroker.getMessage("secondBranchPartner", "secondBranchPort", "secondBranchOp");
+        assertNotNull("Second branch document has not been sent.", receivedDoc);
+
+        // Completing the first branch
+        result = AgilaEngineFactory.getEngine().acknowledge("firstBranchPartner", "firstBranchPort", "firstBranchOp", doc);
+        assertTrue("A problem occured when the message as been sent", EngineResultTester.test(result));
+
+        Thread.sleep(10000);
+
+        // CHecking that everything is done
+        receivedDoc = DefaultMessageBrokerImpl.getMessage("lastPartner", "lastPort", "lastOp");
+        assertNotNull("Document received ", receivedDoc);
+    }
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestInvokeEC.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestInvokeEC.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestInvokeEC.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestInvokeEC.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,201 @@
+/*
+ * 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.bpel.engine.core.dynamic;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.dom4j.Document;
+import org.apache.agila.bpel.client.AgilaDeployer;
+import org.apache.agila.bpel.common.util.StringUtil;
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.persistence.XMLDataAccess;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.core.definition.TestInvoke;
+import org.apache.agila.bpel.engine.core.definition.TestProcess;
+import org.apache.agila.bpel.engine.exception.SelectionFailureException;
+import org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Assign;
+import org.apache.agila.bpel.engine.priv.core.definition.Assignment;
+import org.apache.agila.bpel.engine.priv.core.definition.Invoke;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Sequence;
+import org.apache.agila.bpel.engine.priv.core.definition.AgilaProcess;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContext;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContextFactory;
+import org.apache.agila.bpel.engine.priv.core.dynamic.InvokeEC;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstanceFactory;
+import org.apache.agila.bpel.engine.priv.core.dynamic.impl.xao.VariableXAO;
+import org.apache.agila.bpel.engine.priv.messaging.impl.DefaultMessageBrokerImpl;
+import org.apache.log4j.Logger;
+
+public class TestInvokeEC extends TestCase {
+
+	public InvokeEC testInvokeEC = null;
+
+	private Logger log = Logger.getLogger(getClass());
+    
+    private TestInvoke testInvoke = new TestInvoke();
+    private TestProcess testProcess = new TestProcess();
+    private AgilaDeployer deployer;
+
+    protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+        SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+        schemaExport.create(true, true);
+
+        deployer = new AgilaDeployer();
+
+        TransactionManager.beginTransaction();
+        testProcess.testCreateWithCorrelation();
+    }
+
+    protected void tearDown() throws Exception {
+        TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+
+    public void testCreate() throws Exception {
+        // Invoke is using the process created in TestProcess
+        testInvoke.testCreate();
+
+        Map corrProp = new HashMap();
+        corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+        corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+        ProcessInstance pi = ProcessInstanceFactory.createProcessInstance(TestInvoke.invoke.getProcess(),
+				TestProcess.CORRELATION_NAME, corrProp);
+		InvokeEC invokeEC = (InvokeEC) ExecutionContextFactory.createExecutionContext(TestInvoke.invoke, pi);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+		assertTrue("Instance child ec is not a InvokeEC",
+				createdInstance.getChildExecutionContext() instanceof InvokeEC);
+		testInvokeEC = (InvokeEC) createdInstance.getChildExecutionContext();
+    }
+
+	public void testExecuteWithSelectionFailure() throws Exception {
+        // Invoke is using the process created in TestProcess
+        testInvoke.testCreate();
+
+		Map corrProp = new HashMap();
+		corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+		corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+
+        try {
+		    TestInvoke.invoke.execute(TestProcess.CORRELATION_NAME, corrProp);
+            fail("Executing an invoke with an input variable that has not been set should " +
+                    "result with a selection failure exception.");
+        } catch (SelectionFailureException sfe) {
+            // We should get a selection failure error as the input variable of invoke has
+            // not been set
+        }
+	}
+	
+	public void testExecuteInvoke() throws Exception
+	{
+		TransactionManager.commitTransaction();
+		String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-invoke.xml"));
+        log.info(processDesc);
+        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-invoke-defs.xml"));
+        log.info(wsDefs);
+        deployer.deploy(processDesc, wsDefs);
+        TransactionManager.beginTransaction();
+        XMLDataAccess.cleanCollection("/test-invoke");
+        
+        AgilaProcess process = ProcessFactory.getByName("test-invoke",
+                "http://www.apache.org/agila/test/invoke/service/");
+
+        ExecutionContext context =
+            ((Assign)((Sequence)process.getActivity()).getActivities().get(0)).execute(null, null);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+        assertEquals("Process is not completed after execution ended", ExecutionContext.COMPLETED, context.getStatus());
+        assertNotNull("The message produced by the invoke has not been received by the MessageBroker",
+                DefaultMessageBrokerImpl.getMessage("partner","http://www.apache.org/agila/test/invoke/service/", "porttype", "operation"));
+	}
+
+    public void xtestExecuteWithInput() throws Exception {
+        Assign firstActivity = createInvoke("inputVar", null);
+
+        Map corrProp = new HashMap();
+        corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+        corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+
+        firstActivity.execute(TestProcess.CORRELATION_NAME, corrProp);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+        assertEquals("Process is not completed after execution ended", ProcessInstance.COMPLETED, createdInstance.getStatus());
+        assertNotNull("The message produced by the invoke has not been received by the MessageBroker",
+                DefaultMessageBrokerImpl.getMessage("partner","http://DefaultNS", "porttype", "operation"));
+    }
+
+    public void xtestExecuteWithInputOutput() throws Exception {
+        Assign firstActivity = createInvoke("inputVar", null);
+
+        Map corrProp = new HashMap();
+        corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+        corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+
+        firstActivity.execute(TestProcess.CORRELATION_NAME, corrProp);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+        assertEquals("Process is not completed after execution ended", ProcessInstance.COMPLETED, createdInstance.getStatus());
+        assertNotNull("The message produced by the invoke has not been received by the MessageBroker",
+        DefaultMessageBrokerImpl.getMessage("partner", "http://DefaultNS","porttype", "operation"));
+        Document outputVariable = VariableXAO.getVariable(TestProcess.testProcess.getName(), "inputVar", createdInstance.getId());
+        System.out.println("Output Variable : " + outputVariable);
+        assertNotNull("The invoke didn't store any variable as output", outputVariable);
+    }
+
+    private Assign createInvoke(String input, String output) throws Exception {
+        Sequence sequence = (Sequence) ActivityFactory.createActivity(Sequence.class, TestProcess.testProcess);
+        Assign assign = (Assign) ActivityFactory.createActivity(Assign.class, sequence);
+        Assignment assignement = ActivityFactory.addAssignment(assign, Assignment.EXPRESSION, Assignment.VARIABLE_PART);
+        assignement.setFromFirstValue("0");
+        assignement.setToFirstValue("inputVar");
+        assignement.setToSecondValue("main");
+
+        Invoke invoke = (Invoke) ActivityFactory.createActivity(Invoke.class, sequence);
+        invoke.setOperation("operation");
+        invoke.setNamespace("http://DefaultNS");
+        invoke.setPartner("partner");
+        invoke.setPortType("porttype");
+        invoke.setInputVariable(input);
+        invoke.setOutputVariable(output);
+
+        return assign;
+    }
+
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestPickEC.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestPickEC.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestPickEC.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestPickEC.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,224 @@
+/*
+ * 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.bpel.engine.core.dynamic;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.client.AgilaDeployer;
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.priv.core.definition.ActivityFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.AlarmEvent;
+import org.apache.agila.bpel.engine.priv.core.definition.CorrelationRef;
+import org.apache.agila.bpel.engine.priv.core.definition.Invoke;
+import org.apache.agila.bpel.engine.priv.core.definition.Pick;
+import org.apache.agila.bpel.engine.priv.core.definition.ProcessFactory;
+import org.apache.agila.bpel.engine.priv.core.definition.Property;
+import org.apache.agila.bpel.engine.priv.core.definition.AgilaProcess;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstanceFactory;
+import org.apache.agila.bpel.engine.priv.messaging.impl.DefaultMessageBrokerImpl;
+
+import com.sun.msv.datatype.xsd.DatatypeFactory;
+
+public class TestPickEC extends TestCase {
+
+    private AgilaDeployer deployer;
+
+    private AgilaProcess process;
+    private Pick pick;
+    private Invoke invoke1;
+    private Invoke invoke2;
+    private Invoke invoke3;
+
+    protected void setUp() throws Exception {
+        SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+        schemaExport.create(true, true);
+
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+        deployer = new AgilaDeployer();
+    }
+
+    protected void tearDown() throws Exception {
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+
+//    public void testDirectExecute() throws Exception {
+//        System.out.println("######################################## testDirectExecute");
+//        TransactionManager.beginTransaction();
+//        createPick();
+//
+//        HashMap corrMap = new HashMap();
+//        corrMap.put("mainProp", "MP21");
+//        pick.execute("mainCorr", corrMap);
+//
+//        Document doc = DocumentHelper.createDocument();
+//        Element part = doc.addElement("message").addElement("main");
+//        part.addElement("orderid").setText("217");
+//        part.addElement("customerid").setText("E24F56");
+//        ((PickEC)pick.getExecutionContexts().iterator().next()).acknowledgeMessage(invoke2, doc);
+//
+//        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation("mainCorr", corrMap);
+//        assertNotNull("Could not find any instance created with specified correlation", createdInstance);
+//        assertEquals("Instance is not terminated", ProcessInstance.COMPLETED, createdInstance.getStatus());
+//        assertNotNull("Correct invoke has not been executed",
+//                DefaultMessageBrokerImpl.getMessage("partner2", "porttype2", "operation2"));
+//        TransactionManager.commitTransaction();
+//    }
+
+    public void testAlarm() throws Exception {
+        TransactionManager.beginTransaction();
+        createPick();
+
+        HashMap corrMap = new HashMap();
+        corrMap.put("mainProp", "MP21");
+        pick.execute("mainCorr", corrMap);
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation("mainCorr", corrMap);
+        assertEquals("Process is not active after execution", ProcessInstance.ACTIVE, createdInstance.getStatus());
+
+        TransactionManager.commitTransaction();
+        Thread.sleep(70000);
+        TransactionManager.beginTransaction();
+
+        createdInstance = ProcessInstanceFactory.findInstanceByCorrelation("mainCorr", corrMap);
+        assertEquals("Process is not completed after execution ended", ProcessInstance.COMPLETED, createdInstance.getStatus());
+        assertNotNull("Correct invoke has not been executed",
+                DefaultMessageBrokerImpl.getMessage("partner3", "porttype3", "operation3"));
+        TransactionManager.commitTransaction();
+//        Thread.sleep(10000);
+    }
+
+//    public void testSimplePickWithDescription() throws Exception {
+//        String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-pick.xml"));
+//        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-pick-defs.xml"));
+//        deployer.deploy(processDesc, wsDefs);
+//
+//        // Starting the second onMessage in test pick.
+//        Document doc = DocumentHelper.createDocument();
+//        doc.addElement("message").addElement("main").addElement("pickid")
+//                .setText((String) BeanTester.generateRandomValue(String.class));
+//        Document result = AgilaEngineFactory.getEngine().acknowledge("secPartner", "secPort", "secOp", doc);
+//        assertTrue("A problem occured when the message as been sent", EngineResultTester.test(result));
+//
+//        Thread.sleep(10000);
+//
+//        Document receivedDoc = DefaultMessageBrokerImpl.getMessage("somePartner", "somePort", "someOp");
+//        assertNotNull("Document received ", receivedDoc);
+//    }
+//
+//    public void testDoublePickWithDescription() throws Exception {
+//        String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-pick.xml"));
+//        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-pick-defs.xml"));
+//        deployer.deploy(processDesc, wsDefs);
+//
+//        // Starting the first onMessage in test pick.
+//        Document doc = DocumentHelper.createDocument();
+//        doc.addElement("message").addElement("main").addElement("pickid")
+//                .setText((String) BeanTester.generateRandomValue(String.class));
+//        Document result = AgilaEngineFactory.getEngine().acknowledge("outPartner", "outPort", "outOp", doc);
+//        assertTrue("A problem occured when the message as been sent", EngineResultTester.test(result));
+//
+//        Thread.sleep(10000);
+//
+//        result = AgilaEngineFactory.getEngine().acknowledge("inPartner", "inPort", "inOp", doc);
+//        assertTrue("A problem occured when the message as been sent", EngineResultTester.test(result));
+//
+//        Thread.sleep(10000);
+//
+//        Document receivedDoc = DefaultMessageBrokerImpl.getMessage("aPartner", "aPort", "anOp");
+//        assertNotNull("Document received ", receivedDoc);
+//    }
+//
+//    public void testDoublePickAlarmWithDescription() throws Exception {
+//        String processDesc = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-pick.xml"));
+//        String wsDefs = StringUtil.convert(getClass().getClassLoader().getResourceAsStream("test-pick-defs.xml"));
+//        deployer.deploy(processDesc, wsDefs);
+//
+//        // Starting the first onMessage in test pick.
+//        Document doc = DocumentHelper.createDocument();
+//        doc.addElement("message").addElement("main").addElement("pickid")
+//                .setText((String) BeanTester.generateRandomValue(String.class));
+//        Document result = AgilaEngineFactory.getEngine().acknowledge("outPartner", "outPort", "outOp", doc);
+//        assertTrue("A problem occured when the message as been sent", EngineResultTester.test(result));
+//
+//        Thread.sleep(80000);
+//
+//        Document receivedDoc = DefaultMessageBrokerImpl.getMessage("otherPartner", "otherPort", "otherOp");
+//        assertNotNull("Document received ", receivedDoc);
+//    }
+
+    private void createPick() throws Exception {
+        process = ProcessFactory.createProcess("TestProcess", "");
+        Property prop11 = ProcessFactory.addProperty(process, "corrProp11", "xs:string");
+        ProcessFactory.addPropertyAlias(prop11, "tns:msg1", "main", "/orderid");
+        Property prop12 = ProcessFactory.addProperty(process, "corrProp12", "xs:string");
+        ProcessFactory.addPropertyAlias(prop12, "tns:msg2", "main", "/customerid");
+        Property prop21 = ProcessFactory.addProperty(process, "corrProp21", "xs:string");
+        ProcessFactory.addPropertyAlias(prop21, "tns:msg1", "main", "/shipid");
+        Property prop22 = ProcessFactory.addProperty(process, "corrProp22", "xs:string");
+        ProcessFactory.addPropertyAlias(prop22, "tns:msg2", "main", "/shipperid");
+        Property propMain = ProcessFactory.addProperty(process, "mainProp", "xs:string");
+        ProcessFactory.addPropertyAlias(propMain, "tns:mainmsg", "main", "/mainid");
+        ProcessFactory.addCorrelation(process, "correlation1", "corrProp11 corrProp12");
+        ProcessFactory.addCorrelation(process, "correlation2", "corrProp21 corrProp22");
+        ProcessFactory.addCorrelation(process, "mainCorr", "mainProp");
+
+        pick = (Pick) ActivityFactory.createActivity(Pick.class, process);
+        invoke1 = (Invoke) ActivityFactory.createActivity(Invoke.class, pick);
+        invoke1.setName("invoke1");
+        invoke1.setPartner("partner1");
+        invoke1.setOperation("operation1");
+        invoke1.setPortType("porttype1");
+        invoke2 = (Invoke) ActivityFactory.createActivity(Invoke.class, pick);
+        invoke2.setName("invoke2");
+        invoke2.setPartner("partner2");
+        invoke2.setOperation("operation2");
+        invoke2.setPortType("porttype2");
+        invoke3 = (Invoke) ActivityFactory.createActivity(Invoke.class, pick);
+        invoke3.setName("invoke3");
+        invoke3.setPartner("partner3");
+        invoke3.setOperation("operation3");
+        invoke3.setPortType("porttype3");
+
+        CorrelationRef cref1 = ActivityFactory.createCorrelationRef("correlation1", true, CorrelationRef.IN);
+        HashSet cref1List = new HashSet();
+        cref1List.add(cref1);
+        ActivityFactory.addMessageEvent(pick, invoke1, "link1", "port1", "op1", "var1", cref1List);
+        CorrelationRef cref2 = ActivityFactory.createCorrelationRef("correlation1", true, CorrelationRef.IN);
+        HashSet cref2List = new HashSet();
+        cref2List.add(cref2);
+        ActivityFactory.addMessageEvent(pick, invoke2, "link2", "port2", "op2", "var2", cref2List);
+        ActivityFactory.addAlarmEvent(pick, invoke3, createDate30SecsLater(), AlarmEvent.DEADLINE_EXPR);
+    }
+
+    private String createDate30SecsLater() throws Exception {
+        Calendar nowPlus30 = Calendar.getInstance();
+        nowPlus30.add(Calendar.SECOND, 30);
+        String nowPlus30Str = DatatypeFactory.getTypeByName("dateTime").serializeJavaObject(nowPlus30, null);
+        System.out.println("=> " + nowPlus30Str);
+        return nowPlus30Str;
+    }
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestProcessInstance.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestProcessInstance.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestProcessInstance.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestProcessInstance.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,78 @@
+/*
+ * 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.bpel.engine.core.dynamic;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.core.definition.TestProcess;
+import org.apache.agila.bpel.engine.core.definition.TestWait;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContextFactory;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstanceFactory;
+
+public class TestProcessInstance extends TestCase {
+
+    public static ProcessInstance testProcessInstance = null;
+
+    private TestProcess testProcess = new TestProcess();
+    private TestWait testWait = new TestWait();
+
+    protected void setUp() throws Exception {
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+        SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+        schemaExport.create(true, true);
+
+        TransactionManager.beginTransaction();
+        testProcess.testCreateWithCorrelation();
+        testWait.testCreate();
+    }
+
+    protected void tearDown() throws Exception {
+        TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+
+    public void testCreate() throws Exception {
+        Map corrProp = new HashMap();
+        corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+        corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+        ProcessInstance pi = ProcessInstanceFactory.createProcessInstance(TestProcess.testProcess,
+                TestProcess.CORRELATION_NAME, corrProp);
+
+        ExecutionContextFactory.createExecutionContext(TestWait.wait, pi);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+        assertEquals("Created process instance doesn't have two properties", 2, createdInstance.getProperties().size());
+        assertEquals("First property doesn't have same value", "2578", createdInstance.getPropertyFromName(TestProcess.CORRELATION_PROP1).getValue());
+        assertEquals("Second property doesn't have same value", "12", createdInstance.getPropertyFromName(TestProcess.CORRELATION_PROP2).getValue());
+
+    }
+
+}

Added: incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestReceiveEC.java
URL: http://svn.apache.org/viewcvs/incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestReceiveEC.java?rev=165042&view=auto
==============================================================================
--- incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestReceiveEC.java (added)
+++ incubator/agila/trunk/modules/bpel/engine/core/src/test/junit/org/apache/agila/bpel/engine/core/dynamic/TestReceiveEC.java Wed Apr 27 13:27:43 2005
@@ -0,0 +1,131 @@
+/*
+ * 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.bpel.engine.core.dynamic;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import net.sf.hibernate.cfg.Configuration;
+import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.apache.agila.bpel.engine.common.lifecycle.LifecycleManager;
+import org.apache.agila.bpel.engine.common.transaction.TransactionManager;
+import org.apache.agila.bpel.engine.core.definition.TestProcess;
+import org.apache.agila.bpel.engine.core.definition.TestReceive;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContext;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ExecutionContextFactory;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstance;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ProcessInstanceFactory;
+import org.apache.agila.bpel.engine.priv.core.dynamic.ReceiveEC;
+
+public class TestReceiveEC extends TestCase {
+
+	public ReceiveEC testReceiveEC = null;
+
+    private TestReceive testReceive = new TestReceive();
+    private TestProcess testProcess = new TestProcess();
+
+    protected void setUp() throws Exception {
+        SchemaExport schemaExport = new SchemaExport(new Configuration().configure());
+        schemaExport.create(true, true);
+
+        LifecycleManager.getLifecycleManager().createResources();
+        LifecycleManager.getLifecycleManager().startResources();
+
+        TransactionManager.beginTransaction();
+        testProcess.testCreateWithCorrelation();
+        // Receive is using the process created in TestProcess
+        testReceive.testCreate();
+    }
+
+    protected void tearDown() throws Exception {
+        TransactionManager.commitTransaction();
+
+        LifecycleManager.getLifecycleManager().stopResources();
+        LifecycleManager.getLifecycleManager().destroyResources();
+    }
+
+    public void testCreate() throws Exception {
+        Map corrProp = new HashMap();
+        corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+        corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+        ProcessInstance pi = ProcessInstanceFactory.createProcessInstance(TestReceive.receive.getProcess(),
+				TestProcess.CORRELATION_NAME, corrProp);
+		ExecutionContextFactory.createExecutionContext(TestReceive.receive, pi);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+		assertTrue("Instance child ec is not a ReceiveEC",
+				createdInstance.getChildExecutionContext() instanceof ReceiveEC);
+		testReceiveEC = (ReceiveEC) createdInstance.getChildExecutionContext();
+    }
+
+	public void testExecuteWithoutVariable() throws Exception {
+		Map corrProp = new HashMap();
+		corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+		corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+
+		TestReceive.receive.execute(TestProcess.CORRELATION_NAME, corrProp);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+        assertTrue("Instance child is not a ReceiveEC", createdInstance.getChildExecutionContext() instanceof ReceiveEC);
+        ((ReceiveEC)createdInstance.getChildExecutionContext()).acknowledgeMessage(null);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		ProcessInstance executedInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+		assertEquals("Process is not completed after execution ended", ProcessInstance.COMPLETED, executedInstance.getStatus());
+		assertEquals("Receive is not completed after execution ended", ExecutionContext.COMPLETED, executedInstance.getChildExecutionContext().getStatus());
+	}
+
+	public void testExecuteWithVariable() throws Exception {
+        // Creating a dummy element to assign variable as incoming message
+        Document doc = DocumentHelper.createDocument();
+        Element elmt = doc.addElement("message");
+        elmt.addElement("test").addAttribute("test", "test");
+
+        // Executing
+		Map corrProp = new HashMap();
+		corrProp.put(TestProcess.CORRELATION_PROP1, "2578");
+		corrProp.put(TestProcess.CORRELATION_PROP2, "12");
+
+		TestReceive.receive.execute(TestProcess.CORRELATION_NAME, corrProp);
+
+		TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+        ProcessInstance createdInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+        assertTrue("Instance child is not a ReceiveEC", createdInstance.getChildExecutionContext() instanceof ReceiveEC);
+        ((ReceiveEC)createdInstance.getChildExecutionContext()).acknowledgeMessage(doc);
+
+        TransactionManager.commitTransaction();
+        TransactionManager.beginTransaction();
+
+		ProcessInstance executedInstance = ProcessInstanceFactory.findInstanceByCorrelation(TestProcess.CORRELATION_NAME, corrProp);
+		assertEquals("Process is not completed after execution ended", ProcessInstance.COMPLETED, executedInstance.getStatus());
+		assertEquals("Receive is not completed after execution ended", ExecutionContext.COMPLETED, executedInstance.getChildExecutionContext().getStatus());
+	}
+}



Mime
View raw message