craigmcc 01/08/19 16:53:10
Modified: workflow build.xml
workflow/src/java/org/apache/commons/workflow Context.java
workflow/src/java/org/apache/commons/workflow/base
BaseContext.java
workflow/src/test/org/apache/commons/workflow/base
BaseContextTestCase.java BaseExecuteTestCase.java
Added: workflow/src/java/org/apache/commons/workflow/base
BaseContextBean.java
workflow/src/test/org/apache/commons/workflow/base
Address.java Employee.java
workflow/src/test/org/apache/commons/workflow/core
CoreExecuteTestCase.java
Log:
Add integration with JPath (another jakarta-commons-sandbox project) for
XPath-like navigation of the set of beans made visible through the Scopes
associated with a Context.
FIXME - It still doesn't work yet, as illustrated by problems in
BaseContextTestCase. Apparently, a Scope is not being treated like a Map
by the JPath evaluation methods, even though it works for HashMap and
other Map implementations (for example, the testJPathFunctionality test
succeeds when Employee.getAddresses() returns a HashMap but fails when it
returns a Scope).
Once this works, we'll be able to do XPath-like expressions to get and set
properties in any scope.
Revision Changes Path
1.5 +27 -5 jakarta-commons-sandbox/workflow/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/workflow/build.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- build.xml 2001/08/18 20:30:52 1.4
+++ build.xml 2001/08/19 23:53:10 1.5
@@ -3,7 +3,7 @@
<!--
"Workflow" component of the Jakarta Commons Subproject
- $Id: build.xml,v 1.4 2001/08/18 20:30:52 craigmcc Exp $
+ $Id: build.xml,v 1.5 2001/08/19 23:53:10 craigmcc Exp $
-->
@@ -22,9 +22,11 @@
<property name="jaxp.home" value="/usr/local/jaxp-1.1"/>
<property name="junit.home" value="/usr/local/junit3.7"/>
<property name="commons.home" value="../../jakarta-commons"/>
+ <property name="sandbox.home" value="../../jakarta-commons-sandbox"/>
<property name="beanutils.home" value="${commons.home}/beanutils"/>
<property name="collections.home" value="${commons.home}/collections"/>
<property name="digester.home" value="${commons.home}/digester"/>
+ <property name="jpath.home" value="${sandbox.home}/jpath"/>
<property name="servletapi.home" value="../../jakarta-servleatpi-4"/>
@@ -34,10 +36,12 @@
<!-- The locations of necessary jar files -->
<property name="jaxp.jaxp.jar" value="${jaxp.home}/jaxp.jar"/>
<property name="jaxp.parser.jar" value="${jaxp.home}/crimson.jar"/>
+ <property name="jaxp.xalan.jar" value="${jaxp.home}/xalan.jar"/>
<property name="junit.jar" value="${junit.home}/junit.jar"/>
- <property name="commons-beanutils.jar"
value="${beanutils.home}/build/commons-beanutils.jar"/>
- <property name="commons-collections.jar"
value="${collections.home}/build/commons-collections.jar"/>
- <property name="commons-digester.jar"
value="${digester.home}/lib/commons-digester.jar"/>
+ <property name="commons-beanutils.jar"
value="${beanutils.home}/dist/commons-beanutils.jar"/>
+ <property name="commons-collections.jar"
value="${collections.home}/dist/commons-collections.jar"/>
+ <property name="commons-digester.jar"
value="${digester.home}/dist/commons-digester.jar"/>
+ <property name="commons-jpath.jar"
value="${jpath.home}/dist/commons-jpath.jar"/>
<property name="servlet.jar"
value="${servletapi.home}/lib/servlet.jar"/>
@@ -86,9 +90,11 @@
<pathelement location="${build.home}/classes"/>
<pathelement location="${jaxp.jaxp.jar}"/>
<pathelement location="${jaxp.parser.jar}"/>
+ <pathelement location="${jaxp.xalan.jar}"/>
<pathelement location="${commons-beanutils.jar}"/>
<pathelement location="${commons-collections.jar}"/>
<pathelement location="${commons-digester.jar}"/>
+ <pathelement location="${commons-jpath.jar}"/>
<pathelement location="${servlet.jar}"/>
</path>
@@ -100,9 +106,13 @@
<path id="test.classpath">
<pathelement location="${build.home}/classes"/>
<pathelement location="${build.home}/tests"/>
+ <pathelement location="${jaxp.jaxp.jar}"/>
+ <pathelement location="${jaxp.parser.jar}"/>
+ <pathelement location="${jaxp.xalan.jar}"/>
<pathelement location="${commons-beanutils.jar}"/>
<pathelement location="${commons-collections.jar}"/>
<pathelement location="${commons-digester.jar}"/>
+ <pathelement location="${commons-jpath.jar}"/>
<pathelement location="${servlet.jar}"/>
<pathelement location="${junit.jar}"/>
</path>
@@ -121,9 +131,11 @@
<pathelement location="${build.home}/classes"/>
<pathelement location="${jaxp.jaxp.jar}"/>
<pathelement location="${jaxp.parser.jar}"/>
+ <pathelement location="${jaxp.xalan.jar}"/>
<pathelement location="${commons-beanutils.jar}"/>
<pathelement location="${commons-collections.jar}"/>
<pathelement location="${commons-digester.jar}"/>
+ <pathelement location="${commons-jpath.jar}"/>
<pathelement location="${servlet.jar}"/>
</path>
@@ -240,7 +252,8 @@
<target name="test" depends="compile.tests,
test.BaseActivity,
test.BaseContext,
- test.BaseExecute"
+ test.BaseExecute,
+ test.CoreExecute"
description="Run all unit test cases">
</target>
@@ -269,6 +282,15 @@
<java classname="${test.runner}" fork="yes"
failonerror="${test.failonerror}">
<arg value="org.apache.commons.workflow.base.BaseExecuteTestCase"/>
+ <classpath refid="test.classpath"/>
+ </java>
+ </target>
+
+ <target name="test.CoreExecute">
+ <echo message="Running CoreExecute tests ..."/>
+ <java classname="${test.runner}" fork="yes"
+ failonerror="${test.failonerror}">
+ <arg value="org.apache.commons.workflow.core.CoreExecuteTestCase"/>
<classpath refid="test.classpath"/>
</java>
</target>
1.5 +12 -4
jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Context.java
Index: Context.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Context.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Context.java 2001/08/19 21:25:18 1.4
+++ Context.java 2001/08/19 23:53:10 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Context.java,v
1.4 2001/08/19 21:25:18 craigmcc Exp $
- * $Revision: 1.4 $
- * $Date: 2001/08/19 21:25:18 $
+ * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Context.java,v
1.5 2001/08/19 23:53:10 craigmcc Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/08/19 23:53:10 $
*
* ====================================================================
*
@@ -63,6 +63,7 @@
import java.util.EmptyStackException;
+import org.apache.commons.jpath.JPathContext;
/**
@@ -87,7 +88,7 @@
* the Step implementations that are executed to maintain the stack's
* integrity.</p>
*
- * @version $Revision: 1.4 $ $Date: 2001/08/19 21:25:18 $
+ * @version $Revision: 1.5 $ $Date: 2001/08/19 23:53:10 $
* @author Craig R. McClanahan
*/
@@ -334,6 +335,13 @@
* <code>execute()</code> method is called, if any.</p>
*/
public Activity getActivity();
+
+
+ /**
+ * Return the JPathContext object that represents a unified namespace
+ * covering all of our registered <code>Scopes</code>.
+ */
+ public JPathContext getJPathContext();
/**
1.5 +40 -4
jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java
Index: BaseContext.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BaseContext.java 2001/08/19 21:25:18 1.4
+++ BaseContext.java 2001/08/19 23:53:10 1.5
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v
1.4 2001/08/19 21:25:18 craigmcc Exp $
- * $Revision: 1.4 $
- * $Date: 2001/08/19 21:25:18 $
+ * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v
1.5 2001/08/19 23:53:10 craigmcc Exp $
+ * $Revision: 1.5 $
+ * $Date: 2001/08/19 23:53:10 $
*
* ====================================================================
*
@@ -64,6 +64,7 @@
import java.util.EmptyStackException;
import org.apache.commons.collections.ArrayStack;
+import org.apache.commons.jpath.JPathContext;
import org.apache.commons.workflow.Activity;
import org.apache.commons.workflow.Context;
import org.apache.commons.workflow.ContextEvent;
@@ -83,7 +84,7 @@
* class. If it is used in a multiple thread environment, callers must
* take suitable precations.</p>
*
- * @version $Revision: 1.4 $ $Date: 2001/08/19 21:25:18 $
+ * @version $Revision: 1.5 $ $Date: 2001/08/19 23:53:10 $
* @author Craig R. McClanahan
*/
@@ -117,6 +118,13 @@
/**
+ * The bean representing the information about this Context made visible
+ * through JPath.
+ */
+ protected BaseContextBean bean = null;
+
+
+ /**
* The set of names associated with the registered <code>Scopes</code>.
*/
protected String names[] = new String[MAX_SCOPES];
@@ -358,6 +366,7 @@
names[scope] = name;
scopes[scope] = impl;
}
+ bean = null;
}
@@ -551,6 +560,19 @@
/**
+ * Return the JPathContext object that represents a unified namespace
+ * covering all of our registered <code>Scopes</code>.
+ */
+ public JPathContext getJPathContext() {
+
+ if (bean == null)
+ bean = new BaseContextBean(this);
+ return (JPathContext.newContext(bean));
+
+ }
+
+
+ /**
* <p>Set the <code>Activity</code> to be executed, and make the first
* defined <code>Step</code> within this <code>Activity</code> the next
* action to be performed by <code>execute()</code>.</p>
@@ -660,6 +682,20 @@
public void removeContextListener(ContextListener listener) {
support.removeContextListener(listener);
+
+ }
+
+
+ // -------------------------------------------------------- Package Methods
+
+
+ /**
+ * Return the array of registered <code>Scope</code> names for this
+ * <code>Context</code>.
+ */
+ String[] getScopeNames() {
+
+ return (this.names);
}
1.1
jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContextBean.java
Index: BaseContextBean.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContextBean.java,v
1.1 2001/08/19 23:53:10 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/08/19 23:53:10 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.workflow.base;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.workflow.Context;
/**
* Custom JavaBean representing the properties of a <code>BaseContext</code>
* that are made visible via JPath.
*/
public class BaseContextBean {
private BaseContext baseContext = null;
private HashMap scopes = null;
public BaseContextBean(BaseContext baseContext) {
super();
this.baseContext = baseContext;
}
public Map getLocal() {
return ((Map) baseContext.getScope(Context.LOCAL_SCOPE));
}
public Map getScopes() {
if (scopes != null)
return (scopes);
scopes = new HashMap();
String names[] = baseContext.getScopeNames();
for (int i = 0; i < names.length; i++) {
if (names[i] == null)
continue;
scopes.put(names[i], baseContext.getScope(i));
}
return (scopes);
}
}
1.4 +148 -4
jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseContextTestCase.java
Index: BaseContextTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseContextTestCase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BaseContextTestCase.java 2001/08/19 21:25:18 1.3
+++ BaseContextTestCase.java 2001/08/19 23:53:10 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseContextTestCase.java,v
1.3 2001/08/19 21:25:18 craigmcc Exp $
- * $Revision: 1.3 $
- * $Date: 2001/08/19 21:25:18 $
+ * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseContextTestCase.java,v
1.4 2001/08/19 23:53:10 craigmcc Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/08/19 23:53:10 $
*
* ====================================================================
*
@@ -67,6 +67,7 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.commons.jpath.JPathContext;
import org.apache.commons.workflow.Context;
import org.apache.commons.workflow.Scope;
@@ -76,7 +77,7 @@
* functions that are not dependent upon an associated Activity.</p>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.3 $ $Date: 2001/08/19 21:25:18 $
+ * @version $Revision: 1.4 $ $Date: 2001/08/19 23:53:10 $
*/
public class BaseContextTestCase extends TestCase {
@@ -249,6 +250,149 @@
context.remove("BaseContextTestCase.D", Context.LOCAL_SCOPE);
assertTrue("Should not contain D #2",
!context.contains("BaseContextTestCase.D"));
+
+ }
+
+
+ /**
+ * Test the returned JPathContext for accessing items in the unified
+ * namespace.
+ */
+ public void testJPathContext() {
+
+ // Set up an extra scope and put one object in each scope
+ Scope extra = new BaseScope();
+ context.addScope(Context.LOCAL_SCOPE + 1, "extra", extra);
+ context.put("local0", "This is local0");
+ context.put("extra0", "This is extra0", Context.LOCAL_SCOPE + 1);
+
+ // Validate access using Context access methods
+ assertEquals("Context can find extra",
+ extra,
+ context.get("extra", Context.LOCAL_SCOPE));
+ assertEquals("Context can find local0",
+ "This is local0",
+ context.get("local0", Context.LOCAL_SCOPE));
+ assertEquals("Context can find extra0",
+ "This is extra0",
+ context.get("extra0", Context.LOCAL_SCOPE + 1));
+
+ // Extract the associated JPathContext
+ JPathContext jpc = context.getJPathContext();
+ assertNotNull("Context can find JPathContext", jpc);
+ assertNotNull("JPathContext can find scopes",
+ jpc.getValue("scopes"));
+ assertNotNull("JPathContext can find local",
+ jpc.getValue("scopes/local"));
+ assertNotNull("JPathContext can find extra #1",
+ jpc.getValue("scopes/extra"));
+ try {
+ Object value = jpc.getValue("local");
+ System.out.println("local --> " + value);
+ } catch (Throwable t) {
+ System.out.println("local --> EXCEPTION");
+ t.printStackTrace(System.out);
+ }
+ try {
+ Object value = jpc.getValue("local/extra");
+ System.out.println("local/extra --> " + value);
+ } catch (Throwable t) {
+ System.out.println("local/extra --> EXCEPTION");
+ t.printStackTrace(System.out);
+ }
+ try {
+ Object value = jpc.getValue("local/local0");
+ System.out.println("local/local0 --> " + value);
+ } catch (Throwable t) {
+ System.out.println("local/local0 --> EXCEPTION");
+ t.printStackTrace(System.out);
+ }
+ try {
+ Object value = jpc.getValue("scopes/extra");
+ System.out.println("scopes/extra --> " + value);
+ } catch (Throwable t) {
+ System.out.println("scopes/extra --> EXCEPTION");
+ t.printStackTrace(System.out);
+ }
+ try {
+ Object value = jpc.getValue("scopes/extra/extra0");
+ System.out.println("scopes/extra/extra0 --> " + value);
+ } catch (Throwable t) {
+ System.out.println("scopes/extra/extra0 --> EXCEPTION");
+ t.printStackTrace(System.out);
+ }
+ try {
+ Object value = jpc.getValue("scopes/local");
+ System.out.println("scopes/local --> " + value);
+ } catch (Throwable t) {
+ System.out.println("scopes/local --> EXCEPTION");
+ t.printStackTrace(System.out);
+ }
+ try {
+ Object value = jpc.getValue("scopes/local/extra");
+ System.out.println("scopes/local/extra --> " + value);
+ } catch (Throwable t) {
+ System.out.println("scopes/local/extra --> EXCEPTION");
+ t.printStackTrace(System.out);
+ }
+ try {
+ Object value = jpc.getValue("scopes/local/local0");
+ System.out.println("scopes/local/local0 --> " + value);
+ } catch (Throwable t) {
+ System.out.println("scopes/local/local0 --> EXCEPTION");
+ t.printStackTrace(System.out);
+ }
+
+
+ /* FIXME - these fail accessing a Scope as a Map is not working
+ assertNotNull("JPathContext can find extra #2",
+ jpc.getValue("scopes/local/extra"));
+
+ // Validate access using JPath access methods
+ assertEquals("JPathContext can find local0",
+ "This is local0",
+ (String) jpc.getValue("scopes/local/local0"));
+ assertEquals("JPathContext can find extra0 #1",
+ "This is extra0",
+ (String) jpc.getValue("scopes/extra/extra0"));
+ assertEquals("JPathContext can find extra0 #1",
+ "This is extra0",
+ (String) jpc.getValue("scopes/local/extra/extra0"));
+ */
+
+ }
+
+
+ /**
+ * Test basic JPath functionality that we rely on.
+ */
+ public void testJPathFunctionality() {
+
+ Employee emp = new Employee("Test First Name", "Test Last Name");
+ Address homeAddress = new Address();
+ homeAddress.setZipCode("HmZip");
+ emp.addAddress("home", homeAddress);
+ Address officeAddress = new Address();
+ officeAddress.setZipCode("OfZip");
+ emp.addAddress("office", officeAddress);
+
+ JPathContext jpc = JPathContext.newContext(emp);
+ assertNotNull("Can create JPathContext", jpc);
+
+ assertEquals("Get firstName", "Test First Name",
+ (String) jpc.getValue("firstName"));
+ assertEquals("Get lastName", "Test Last Name",
+ (String) jpc.getValue("lastName"));
+ assertNotNull("Get addresses", jpc.getValue("addresses"));
+ System.out.println("addresses is " + jpc.getValue("addresses"));
+ assertEquals("Get addresses/home/zipCode",
+ "HmZip",
+ (String) jpc.getValue("addresses/home/zipCode"));
+ assertEquals("Get addresses/office/zipCode",
+ "OfZip",
+ (String) jpc.getValue("addresses/office/zipCode"));
+ System.out.println("addresses/home is " + jpc.getValue("addresses/home"));
+ System.out.println("addresses/office is " +
jpc.getValue("addresses/office"));
}
1.2 +6 -6
jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseExecuteTestCase.java
Index: BaseExecuteTestCase.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseExecuteTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseExecuteTestCase.java 2001/08/18 20:30:52 1.1
+++ BaseExecuteTestCase.java 2001/08/19 23:53:10 1.2
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseExecuteTestCase.java,v
1.1 2001/08/18 20:30:52 craigmcc Exp $
- * $Revision: 1.1 $
- * $Date: 2001/08/18 20:30:52 $
+ * $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseExecuteTestCase.java,v
1.2 2001/08/19 23:53:10 craigmcc Exp $
+ * $Revision: 1.2 $
+ * $Date: 2001/08/19 23:53:10 $
*
* ====================================================================
*
@@ -75,12 +75,12 @@
/**
- * <p>Test Case for the BaseActivity class. These tests exercise those
- * features of Activity and Step implementations that do not perform any
- * Step execution (and therefore require a Context).</p>
+ * <p>Test Case for the BaseActivity class. These tests exercise
+ * basic <code>Activity</code> execution capabilities, without requiring
+ * any existing <code>Step</code> implementations.</p>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.1 $ $Date: 2001/08/18 20:30:52 $
+ * @version $Revision: 1.2 $ $Date: 2001/08/19 23:53:10 $
*/
public class BaseExecuteTestCase extends TestCase {
1.1
jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/Address.java
Index: Address.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/Address.java,v
1.1 2001/08/19 23:53:10 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/08/19 23:53:10 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.workflow.base;
/**
* Bean for JPath testing.
*/
public class Address {
public Address() {
this("My Street", "My City", "US", "MyZip");
}
public Address(String street, String city, String state, String zipCode) {
super();
setStreet(street);
setCity(city);
setState(state);
setZipCode(zipCode);
}
private String city = null;
public String getCity() {
return (this.city);
}
public void setCity(String city) {
this.city = city;
}
private String state = null;
public String getState() {
return (this.state);
}
public void setState(String state) {
this.state = state;
}
private String street = null;
public String getStreet() {
return (this.street);
}
public void setStreet(String street) {
this.street = street;
}
private String zipCode = null;
public String getZipCode() {
return (this.zipCode);
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public String toString() {
StringBuffer sb = new StringBuffer("Address[");
sb.append("street=");
sb.append(street);
sb.append(", city=");
sb.append(city);
sb.append(", state=");
sb.append(state);
sb.append(", zipCode=");
sb.append(zipCode);
sb.append("]");
return (sb.toString());
}
}
1.1
jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/Employee.java
Index: Employee.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/Employee.java,v
1.1 2001/08/19 23:53:10 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/08/19 23:53:10 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.workflow.base;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.workflow.Scope;
/**
* Bean for JPath testing.
*/
public class Employee {
public Employee() {
this("My First Name", "My Last Name");
}
public Employee(String firstName, String lastName) {
super();
setFirstName(firstName);
setLastName(lastName);
}
private HashMap addresses = new HashMap();
/*
private Scope addresses = new BaseScope();
*/
public void addAddress(String key, Address address) {
addresses.put(key, address);
}
public HashMap getAddresses() {
return ((HashMap) addresses);
}
public void removeAddress(String key) {
addresses.remove(key);
}
private String firstName = null;
public String getFirstName() {
return (this.firstName);
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
private String lastName = null;
public String getLastName() {
return (this.lastName);
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String toString() {
StringBuffer sb = new StringBuffer("Employee[");
sb.append("firstName=");
sb.append(firstName);
sb.append(", lastName=");
sb.append(lastName);
sb.append("]");
return (sb.toString());
}
}
1.1
jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/core/CoreExecuteTestCase.java
Index: CoreExecuteTestCase.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/core/CoreExecuteTestCase.java,v
1.1 2001/08/19 23:53:10 craigmcc Exp $
* $Revision: 1.1 $
* $Date: 2001/08/19 23:53:10 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.commons.workflow.core;
import java.util.EmptyStackException;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.commons.workflow.Activity;
import org.apache.commons.workflow.Context;
import org.apache.commons.workflow.Scope;
import org.apache.commons.workflow.Step;
import org.apache.commons.workflow.StepException;
import org.apache.commons.workflow.base.BaseExecuteTestCase;
/**
* <p>Test Case for the <code>core</code> library of <code>Step</code>
* implementations.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.1 $ $Date: 2001/08/19 23:53:10 $
*/
public class CoreExecuteTestCase extends BaseExecuteTestCase {
// ----------------------------------------------------- Instance Variables
// ----------------------------------------------------------- Constructors
/**
* Construct a new instance of this test case.
*
* @param name Name of the test case
*/
public CoreExecuteTestCase(String name) {
super(name);
}
// --------------------------------------------------- Overall Test Methods
/**
* Set up instance variables required by this test case.
*/
public void setUp() {
super.setUp();
}
/**
* Return the tests included in this test suite.
*/
public static Test suite() {
return (new TestSuite(CoreExecuteTestCase.class));
}
/**
* Tear down instance variables required by this test case.
*/
public void tearDown() {
super.tearDown();
}
// ------------------------------------------------ Individual Test Methods
}