Commits

Anonymous committed d56f84d

Initial import from SourceForge

Comments (0)

Files changed (2)

src/java/com/opensymphony/workflow/util/Validatable.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.workflow.util;
+
+import com.opensymphony.workflow.InvalidWorkflowDescriptorException;
+
+
+/**
+ * Abstact base class for elements that can be validated.
+ *
+ * @author <a href="mailto:vorburger@users.sourceforge.net">Michael Vorburger</a>
+ * @version $Revision: 1.1.1.1 $
+ */
+public interface Validatable {
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    /**
+     * Validate this element, and propagate validation to all contained sub-elements.
+     * Should throw an InvalidWorkflowDescriptorException with details in message if the element
+     * is invalid. Validity checks should be checks that cannot be encapsulated in the DTD.
+     *
+     * Validation has to be called explicitly on writting, a writeXML() does not validate implicitly;
+     * it *IS* thus possible to write invalid descriptor files.  This could be useful for e.g.
+     * a graphical workflow definition editor which would like to write incomplete definitions.
+     * Validation *IS* performed on loading a workflow definition.
+     *
+     * @see  com.opensymphony.workflow.loader.WorkflowLoader#load
+     * @throws InvalidWorkflowDescriptorException
+     */
+    public void validate() throws InvalidWorkflowDescriptorException;
+}

src/test/com/opensymphony/workflow/UnconditionalResultTestCase.java

+package com.opensymphony.workflow;
+
+import junit.framework.TestCase;
+import com.opensymphony.workflow.loader.WorkflowDescriptor;
+
+/**
+ * Test Case for AbstractWorkflow.
+ *
+ * @author <a href="mailto:vorburger@users.sourceforge.net">Michael Vorburger</a>
+ * @version $Id: UnconditionalResultTestCase.java,v 1.1.1.1 2003-02-13 01:05:14 hani Exp $ (Created on Feb 11, 2003 at 7:48:39 PM)
+ */
+public class UnconditionalResultTestCase extends TestCase {
+
+    public UnconditionalResultTestCase(String s) {
+        super(s);
+    }
+
+    /**
+     * Test whether an invalid unconditional-result in an initial-actions is indeed rejected as it should.
+     *
+     * @see <a href="http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WF-130">Jira issue WF-130</a>
+     * @throws Exception If error while executing testing
+     */
+    public void testCheckResultInitialActionUnconditionalResult() throws Exception {
+
+      try
+      {
+        WorkflowDescriptor descriptor = DescriptorLoader.getDescriptor("file:unconditional-result.xml");
+        descriptor.validate();
+        fail("descriptor loaded successfully, even though unconditional-result element is incorrect");
+      }
+      catch(InvalidWorkflowDescriptorException e)
+      {
+        //the descriptor is invalid, which is correct
+      }
+      catch(Exception ex)
+      {
+        ex.printStackTrace();
+        fail("descriptor failed to load as expected, but a " + ex.getClass() + " exception was caught instead of InvalidWorkflowDescriptorException");
+      }
+    }
+}